From 9f7d5410b737047c8e628050167ffbd54d25baa0 Mon Sep 17 00:00:00 2001 From: "sha..rd" Date: Sat, 25 Jun 2011 19:27:23 +0000 Subject: [PATCH] * Tried to fix NVIDIA shininess==0 bug (again!) * MTL loader now properly follows spec regarding initial values of colors * TangentBinormalGenerator now throws proper exception on missing normals git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7730 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- engine/nbproject/project.properties | 2 +- engine/src/core-data/Common/MatDefs/Light/Lighting.frag | 4 +++- .../src/core-plugins/com/jme3/scene/plugins/MTLLoader.java | 7 +++++-- .../src/core/com/jme3/util/TangentBinormalGenerator.java | 4 ++++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/engine/nbproject/project.properties b/engine/nbproject/project.properties index e90693767..1a727630b 100644 --- a/engine/nbproject/project.properties +++ b/engine/nbproject/project.properties @@ -78,7 +78,7 @@ jnlp.signed=true jnlp.signing=generated jnlp.signing.alias= jnlp.signing.keystore= -main.class=jme3test.export.TestOgreConvert +main.class=testcases.ObjImport manifest.file=MANIFEST.MF meta.inf.dir=${src.dir}/META-INF mkdist.disabled=false diff --git a/engine/src/core-data/Common/MatDefs/Light/Lighting.frag b/engine/src/core-data/Common/MatDefs/Light/Lighting.frag index 8b8cc827e..579ee86f5 100644 --- a/engine/src/core-data/Common/MatDefs/Light/Lighting.frag +++ b/engine/src/core-data/Common/MatDefs/Light/Lighting.frag @@ -101,7 +101,9 @@ float lightComputeSpecular(in vec3 norm, in vec3 viewdir, in vec3 lightdir, in f vec2 computeLighting(in vec3 wvPos, in vec3 wvNorm, in vec3 wvViewDir, in vec3 wvLightDir){ float diffuseFactor = lightComputeDiffuse(wvNorm, wvLightDir, wvViewDir); float specularFactor = lightComputeSpecular(wvNorm, wvViewDir, wvLightDir, m_Shininess); - specularFactor *= step(1.0, m_Shininess); + + // if shininess is == 0, spec == 0, if shininess > 1, spec == 1 + specularFactor *= min(1.0, m_Shininess); #ifdef HQ_ATTENUATION float att = clamp(1.0 - g_LightPosition.w * length(lightVec), 0.0, 1.0); diff --git a/engine/src/core-plugins/com/jme3/scene/plugins/MTLLoader.java b/engine/src/core-plugins/com/jme3/scene/plugins/MTLLoader.java index 4709abe93..a366a61f7 100644 --- a/engine/src/core-plugins/com/jme3/scene/plugins/MTLLoader.java +++ b/engine/src/core-plugins/com/jme3/scene/plugins/MTLLoader.java @@ -92,8 +92,8 @@ public class MTLLoader implements AssetLoader { } protected void resetMaterial(){ - ambient.set(ColorRGBA.Black); - diffuse.set(ColorRGBA.Black); + ambient.set(ColorRGBA.DarkGray); + diffuse.set(ColorRGBA.LightGray); specular.set(ColorRGBA.Black); shininess = 16; shadeless = false; @@ -189,6 +189,9 @@ public class MTLLoader implements AssetLoader { specular.set(readColor()); }else if (cmd.equals("ns")){ shininess = scan.nextFloat(); /* (128f / 1000f)*/ + if (specular.equals(ColorRGBA.Black)){ + specular.set(ColorRGBA.White); + } }else if (cmd.equals("d") || cmd.equals("tr")){ alpha = scan.nextFloat(); transparent = true; diff --git a/engine/src/core/com/jme3/util/TangentBinormalGenerator.java b/engine/src/core/com/jme3/util/TangentBinormalGenerator.java index b796fa46a..7a2cdec37 100644 --- a/engine/src/core/com/jme3/util/TangentBinormalGenerator.java +++ b/engine/src/core/com/jme3/util/TangentBinormalGenerator.java @@ -165,6 +165,10 @@ public class TangentBinormalGenerator { v[i] = new Vector3f(); t[i] = new Vector2f(); } + + if (mesh.getBuffer(Type.Normal) == null){ + throw new IllegalArgumentException("The given mesh has no normal data!"); + } VertexData[] vertices; switch (mesh.getMode()) {