Implement Exponential Shadow map
This commit is contained in:
parent
7679213e26
commit
9113aa7a39
@ -42,16 +42,21 @@ float getShadowFactor(vec3 pos, float bias, int index)
|
||||
|
||||
//float shadowmapz = 2. * texture(shadowtex, vec3(shadowtexcoord, shadowcoord.z).x - 1.;
|
||||
// bias += smoothstep(0.001, 0.1, moved) * 0.014; // According to the warping
|
||||
float sum = 0.;
|
||||
for (float i = -1.5; i <= 1.5; i+= 1.)
|
||||
{
|
||||
for (float j = -1.5; j <= 1.5; j+= 1.)
|
||||
{
|
||||
float z = texture(shadowtex, vec3(shadowtexcoord +vec2(i, j) / 1024., float(index))).x;
|
||||
sum += (z > 0.5 * shadowcoord.z + 0.5) ? 1. : 0.;
|
||||
}
|
||||
}
|
||||
return sum / 16.;
|
||||
|
||||
// float sum = 0.;
|
||||
// for (float i = -1.5; i <= 1.5; i+= 1.)
|
||||
// {
|
||||
// for (float j = -1.5; j <= 1.5; j+= 1.)
|
||||
// {
|
||||
// float z = texture(shadowtex, vec3(shadowtexcoord +vec2(i, j) / 1024., float(index))).x;
|
||||
// sum += (z > 0.5 * shadowcoord.z + 0.5) ? 1. : 0.;
|
||||
// }
|
||||
// }
|
||||
// return sum / 16.;
|
||||
|
||||
float z = texture(shadowtex, vec3(shadowtexcoord, float(index))).x;
|
||||
float d = .5 * shadowcoord.z + .5;
|
||||
return min(exp(1024 *(z - d)), 1.);
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
@ -978,11 +978,8 @@ void IrrDriver::renderShadows()
|
||||
glDepthMask(GL_TRUE);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_FRONT);
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.5, 0.);
|
||||
m_rtts->getShadowFBO().Bind();
|
||||
|
||||
glClearColor(1., 1., 1., 1.);
|
||||
glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
|
||||
glClearColor(0., 0., 0., 0.);
|
||||
@ -1022,9 +1019,6 @@ void IrrDriver::renderShadows()
|
||||
renderInstancedShadow<NormalMat>(cascade);
|
||||
}
|
||||
}
|
||||
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
glCullFace(GL_BACK);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user