fixed glsl 1.0 version of the postShadowFilter shader
This commit is contained in:
parent
68c082c13d
commit
662a0151e2
@ -40,8 +40,8 @@ vec3 getPosition(in float depth, in vec2 uv){
|
||||
pos = m_ViewProjectionMatrixInverse * pos;
|
||||
return pos.xyz / pos.w;
|
||||
}
|
||||
|
||||
vec3 approximateNormal(in vec4 worldPos,in vec2 texCoord){
|
||||
#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;
|
||||
@ -52,14 +52,10 @@ vec3 approximateNormal(in vec4 worldPos,in vec2 texCoord){
|
||||
vec3 v1 = (worldPos - worldPos2).xyz;
|
||||
vec3 v2 = (worldPos3 - worldPos2).xyz;
|
||||
return normalize(cross(v1, v2));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void main(){
|
||||
#if !defined( RENDER_SHADOWS )
|
||||
gl_FragColor = texture2D(m_Texture,texCoord);
|
||||
return;
|
||||
#endif
|
||||
|
||||
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
|
||||
|
||||
#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…
x
Reference in New Issue
Block a user