# OpenGL bright lines appearing in shadow area

## Recommended Posts

Posted (edited)

I am getting bright lines appearing within the shadow area when using shadow mapping (as you can see in the shadowed part of the wall below)

// vertex shader
uniform mediump vec4 uvOffset;
uniform lowp vec3 lightDirection;
uniform highp mat4 matrixPVM;
uniform highp mat3 matrixVM;
uniform highp mat4 matrixTexProjM;
attribute lowp vec3 inNorm;
attribute highp vec3 inVertex;
attribute mediump vec2 texCoordAttr;
varying lowp vec3 normal;
varying lowp float diffuseLight;
varying mediump vec2 texCoordVar;
void main(void)
{
lowp vec3 normal = normalize(matrixVM * inNorm);
diffuseLight = max(dot(normal, lightDirection), 0.0)*1.5;
gl_Position = matrixPVM * vec4(inVertex, 1.0);
shadowCoord = matrixTexProjM * vec4(inVertex, 1.0);
texCoordVar = (texCoordAttr.xy * uvOffset.zw) + uvOffset.xy;
}

uniform sampler2D sampler2d;
uniform lowp float ambientLight;
varying mediump vec2 texCoordVar;
varying lowp float diffuseLight;
uniform lowp vec4 color1;
void main(void)
{
if (diffuseLight < 0.2)
{
}
lowp float light;
light = diffuseLight + ambientLight;
{
light *= 0.8;
}
lowp vec4 texColor  = texture2D(sampler2d, texCoordVar).rgba;
lowp vec3 color = texColor.rgb * light;
gl_FragColor = vec4(color*color1.rgb, color1.a*texColor.a);
}

Does anyone have any idea what might be the problem and how to resolve it? Many thanks for any answers.

Edited by Ed Welch

##### Share on other sites
Posted (edited)

Maybe you need to check if your wall side normal faces the same direction as light goes to it => dot(light_frag_dir, wall_side_normal) >= 0.0) and consider that shadowed, if that wont helps then its peter panning problem

Edited by _WeirdCat_

##### Share on other sites
11 hours ago, _WeirdCat_ said:

Maybe you need to check if your wall side normal faces the same direction as light goes to it => dot(light_frag_dir, wall_side_normal) >= 0.0) and consider that shadowed, if that wont helps then its peter panning problem

I thought peter panning was caused by using an offset. I am using no offset.

I don't understand your first comment. It sounds like you are talking about calculation of diffuse light, not the shadow.

##### Share on other sites

But when the dot product is equal or bigger than 0 the face area is considered to be in shadow so its shadowed anyway shadowmapping aint that precise what you think, the bigger difference between shadowmap projection matrix (zfar and znear vals) will give you peter panning. This is because of depth precision issue (floating point inaccuracy) anyway i think you could shrink the output image and try to use screen spaced shadows

##### Share on other sites
4 hours ago, _WeirdCat_ said:

But when the dot product is equal or bigger than 0 the face area is considered to be in shadow so its shadowed anyway shadowmapping aint that precise what you think, the bigger difference between shadowmap projection matrix (zfar and znear vals) will give you peter panning. This is because of depth precision issue (floating point inaccuracy) anyway i think you could shrink the output image and try to use screen spaced shadows

I don't think so. The shadow is calculated by this line:

diffuse light is calculated by the dot product of the normal:

diffuseLight = max(dot(normal, lightDirection), 0.0);

I tried making the light projection narrower (ie. near and far closer together). It makes no difference, the white areas still remain the same

## Create an account

Register a new account

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 17
• 24
• 13
• 20