fixed glsl 1.0 version of the postShadowFilter shader

define_list_fix
Rémy Bouquet 9 years ago
parent 68c082c13d
commit 662a0151e2
  1. 50
      jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadowFilter.frag
  2. 2
      jme3-core/src/main/resources/Common/MatDefs/Shadow/PostShadowFilter.j3md

@ -40,26 +40,22 @@ vec3 getPosition(in float depth, in vec2 uv){
pos = m_ViewProjectionMatrixInverse * pos;
return pos.xyz / pos.w;
}
#ifndef BACKFACE_SHADOWS
vec3 approximateNormal(in vec4 worldPos,in vec2 texCoord){
float step = g_ResolutionInverse.x ;
float stepy = g_ResolutionInverse.y ;
float depth2 = texture2D(m_DepthTexture,texCoord + vec2(step,-stepy)).r;
float depth3 = texture2D(m_DepthTexture,texCoord + vec2(-step,-stepy)).r;
vec4 worldPos2 = vec4(getPosition(depth2,texCoord + vec2(step,-stepy)),1.0);
vec4 worldPos3 = vec4(getPosition(depth3,texCoord + vec2(-step,-stepy)),1.0);
vec3 v1 = (worldPos - worldPos2).xyz;
vec3 v2 = (worldPos3 - worldPos2).xyz;
return normalize(cross(v1, v2));
}
#endif
vec3 approximateNormal(in vec4 worldPos,in vec2 texCoord){
float step = g_ResolutionInverse.x ;
float stepy = g_ResolutionInverse.y ;
float depth2 = texture2D(m_DepthTexture,texCoord + vec2(step,-stepy)).r;
float depth3 = texture2D(m_DepthTexture,texCoord + vec2(-step,-stepy)).r;
vec4 worldPos2 = vec4(getPosition(depth2,texCoord + vec2(step,-stepy)),1.0);
vec4 worldPos3 = vec4(getPosition(depth3,texCoord + vec2(-step,-stepy)),1.0);
vec3 v1 = (worldPos - worldPos2).xyz;
vec3 v2 = (worldPos3 - worldPos2).xyz;
return normalize(cross(v1, v2));
}
void main(){
#if !defined( RENDER_SHADOWS )
gl_FragColor = texture2D(m_Texture,texCoord);
return;
#endif
void main(){
float depth = texture2D(m_DepthTexture,texCoord).r;
vec4 color = texture2D(m_Texture,texCoord);
@ -72,7 +68,6 @@ void main(){
// get the vertex in world space
vec4 worldPos = vec4(getPosition(depth,texCoord),1.0);
vec3 normal = approximateNormal(worldPos, texCoord);
vec3 lightDir;
#ifdef PSSM
@ -80,14 +75,17 @@ void main(){
#else
lightDir = worldPos.xyz - m_LightPos;
#endif
float ndotl = dot(normal, lightDir);
if(ndotl > -0.0){
gl_FragColor = color;
return;
}
#ifndef BACKFACE_SHADOWS
vec3 normal = approximateNormal(worldPos, texCoord);
float ndotl = dot(normal, lightDir);
if(ndotl > -0.0){
gl_FragColor = color;
return;
}
#endif
#if (!defined(POINTLIGHT) && !defined(PSSM))
vec3 lightDir = worldPos.xyz - m_LightPos;
if( dot(m_LightDir,lightDir) < 0.0){
gl_FragColor = color;
return;

@ -59,8 +59,6 @@ MaterialDef Post Shadow {
FADE : FadeInfo
PSSM : Splits
POINTLIGHT : LightViewProjectionMatrix5
//if no shadow map don't render shadows
RENDER_SHADOWS : ShadowMap0
BACKFACE_SHADOWS : BackfaceShadows
}

Loading…
Cancel
Save