diff --git a/jme3-core/src/main/java/com/jme3/material/logic/ShadowStaticPassLightingLogic.java b/jme3-core/src/main/java/com/jme3/material/logic/ShadowStaticPassLightingLogic.java index 5bc4c7fed..dfeec2c2b 100755 --- a/jme3-core/src/main/java/com/jme3/material/logic/ShadowStaticPassLightingLogic.java +++ b/jme3-core/src/main/java/com/jme3/material/logic/ShadowStaticPassLightingLogic.java @@ -126,9 +126,9 @@ public class ShadowStaticPassLightingLogic extends StaticPassLightingLogic { } ambientLightColor.a = 1.0f; - defines.set(numDirLightsDefineId, tempDirLights.size()); - defines.set(numPointLightsDefineId, tempPointLights.size()); - defines.set(numSpotLightsDefineId, tempSpotLights.size()); + defines.set(numDirLightsDefineId, tempDirLights.size() - numShadowDirLights); + defines.set(numPointLightsDefineId, tempPointLights.size() - numShadowPointLights); + defines.set(numSpotLightsDefineId, tempSpotLights.size() - numShadowSpotLights); defines.set(numShadowDirLightsDefineId, numShadowDirLights); defines.set(numShadowPointLightsDefineId, numShadowPointLights); @@ -153,7 +153,10 @@ public class ShadowStaticPassLightingLogic extends StaticPassLightingLogic { Uniform shadowMatricesUniform = shader.getUniform("g_ShadowMatrices"); - shadowMatricesUniform.setMatrix4Length(numShadowDirLights * 4 + numShadowSpotLights); + shadowMatricesUniform.setMatrix4Length( + numShadowDirLights * 4 + + numShadowPointLights * 6 + + numShadowSpotLights); int shadowMatrixIndex = 0; for (int i = 0; i < numShadowDirLights; i++) { diff --git a/jme3-core/src/main/java/com/jme3/material/logic/StaticPassLightingLogic.java b/jme3-core/src/main/java/com/jme3/material/logic/StaticPassLightingLogic.java index c99ef68e7..630814e37 100644 --- a/jme3-core/src/main/java/com/jme3/material/logic/StaticPassLightingLogic.java +++ b/jme3-core/src/main/java/com/jme3/material/logic/StaticPassLightingLogic.java @@ -127,7 +127,7 @@ public class StaticPassLightingLogic extends DefaultTechniqueDefLogic { } protected float getShadowMapIndex(Light light) { - return 1.0f; + return -1.0f; } protected void updateLightListUniforms(Matrix4f viewMatrix, Shader shader) { diff --git a/jme3-core/src/main/resources/Common/MatDefs/Light/StaticLighting.frag b/jme3-core/src/main/resources/Common/MatDefs/Light/StaticLighting.frag index 890cdba03..d53b88cc7 100755 --- a/jme3-core/src/main/resources/Common/MatDefs/Light/StaticLighting.frag +++ b/jme3-core/src/main/resources/Common/MatDefs/Light/StaticLighting.frag @@ -19,9 +19,12 @@ #define DIR_SHADOW_LIGHT_END (NUM_SHADOW_DIR_LIGHTS * 2) #define DIR_LIGHT_START (DIR_SHADOW_LIGHT_END) -#define DIR_LIGHT_END (NUM_DIR_LIGHTS * 2) +#define DIR_LIGHT_END (DIR_LIGHT_START + NUM_DIR_LIGHTS * 2) -#define POINT_LIGHT_START (DIR_LIGHT_END) +#define POINT_SHADOW_LIGHT_START (DIR_LIGHT_END) +#define POINT_SHADOW_LIGHT_END (POINT_SHADOW_LIGHT_START + NUM_SHADOW_POINT_LIGHTS * 2) + +#define POINT_LIGHT_START (POINT_SHADOW_LIGHT_END) #define POINT_LIGHT_END (POINT_LIGHT_START + NUM_POINT_LIGHTS * 2) #define SPOT_SHADOW_LIGHT_START (POINT_LIGHT_END) @@ -32,6 +35,8 @@ #define LIGHT_DATA_SIZE (SPOT_LIGHT_END) +uniform vec3 g_CameraPosition; + uniform sampler2D m_AmbientMap; uniform float m_AlphaDiscardThreshold; uniform float m_Shininess;