fixed glsl 1.0 version of the postShadowFilter shader
This commit is contained in:
parent
056dbdf981
commit
b42bf7f67e
@ -40,7 +40,7 @@ vec3 getPosition(in float depth, in vec2 uv){
|
|||||||
pos = m_ViewProjectionMatrixInverse * pos;
|
pos = m_ViewProjectionMatrixInverse * pos;
|
||||||
return pos.xyz / pos.w;
|
return pos.xyz / pos.w;
|
||||||
}
|
}
|
||||||
|
#ifndef BACKFACE_SHADOWS
|
||||||
vec3 approximateNormal(in vec4 worldPos,in vec2 texCoord){
|
vec3 approximateNormal(in vec4 worldPos,in vec2 texCoord){
|
||||||
float step = g_ResolutionInverse.x ;
|
float step = g_ResolutionInverse.x ;
|
||||||
float stepy = g_ResolutionInverse.y ;
|
float stepy = g_ResolutionInverse.y ;
|
||||||
@ -53,13 +53,9 @@ vec3 approximateNormal(in vec4 worldPos,in vec2 texCoord){
|
|||||||
vec3 v2 = (worldPos3 - worldPos2).xyz;
|
vec3 v2 = (worldPos3 - worldPos2).xyz;
|
||||||
return normalize(cross(v1, v2));
|
return normalize(cross(v1, v2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(){
|
|
||||||
#if !defined( RENDER_SHADOWS )
|
|
||||||
gl_FragColor = texture2D(m_Texture,texCoord);
|
|
||||||
return;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
void main(){
|
||||||
float depth = texture2D(m_DepthTexture,texCoord).r;
|
float depth = texture2D(m_DepthTexture,texCoord).r;
|
||||||
vec4 color = texture2D(m_Texture,texCoord);
|
vec4 color = texture2D(m_Texture,texCoord);
|
||||||
|
|
||||||
@ -72,7 +68,6 @@ void main(){
|
|||||||
|
|
||||||
// get the vertex in world space
|
// get the vertex in world space
|
||||||
vec4 worldPos = vec4(getPosition(depth,texCoord),1.0);
|
vec4 worldPos = vec4(getPosition(depth,texCoord),1.0);
|
||||||
vec3 normal = approximateNormal(worldPos, texCoord);
|
|
||||||
|
|
||||||
vec3 lightDir;
|
vec3 lightDir;
|
||||||
#ifdef PSSM
|
#ifdef PSSM
|
||||||
@ -80,14 +75,17 @@ void main(){
|
|||||||
#else
|
#else
|
||||||
lightDir = worldPos.xyz - m_LightPos;
|
lightDir = worldPos.xyz - m_LightPos;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef BACKFACE_SHADOWS
|
||||||
|
vec3 normal = approximateNormal(worldPos, texCoord);
|
||||||
float ndotl = dot(normal, lightDir);
|
float ndotl = dot(normal, lightDir);
|
||||||
if(ndotl > -0.0){
|
if(ndotl > -0.0){
|
||||||
gl_FragColor = color;
|
gl_FragColor = color;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if (!defined(POINTLIGHT) && !defined(PSSM))
|
#if (!defined(POINTLIGHT) && !defined(PSSM))
|
||||||
vec3 lightDir = worldPos.xyz - m_LightPos;
|
|
||||||
if( dot(m_LightDir,lightDir) < 0.0){
|
if( dot(m_LightDir,lightDir) < 0.0){
|
||||||
gl_FragColor = color;
|
gl_FragColor = color;
|
||||||
return;
|
return;
|
||||||
|
@ -59,8 +59,6 @@ MaterialDef Post Shadow {
|
|||||||
FADE : FadeInfo
|
FADE : FadeInfo
|
||||||
PSSM : Splits
|
PSSM : Splits
|
||||||
POINTLIGHT : LightViewProjectionMatrix5
|
POINTLIGHT : LightViewProjectionMatrix5
|
||||||
//if no shadow map don't render shadows
|
|
||||||
RENDER_SHADOWS : ShadowMap0
|
|
||||||
BACKFACE_SHADOWS : BackfaceShadows
|
BACKFACE_SHADOWS : BackfaceShadows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user