I found the problem in the fragment shader.
The shadow2DProj function end's with ".w" - I change this to ".r" and now it work![]()
I found the problem in the fragment shader.
The shadow2DProj function end's with ".w" - I change this to ".r" and now it work![]()
Ah! Ok. Pre-GLSL 1.3, you can set how the rgba (xyzw) vec4 return value is set by the shadow texture lookup via GL_DEPTH_TEXTURE_MODE:Originally Posted by AMDFX
Code :GL_INTENSITY = rrrr GL_LUMINANCE = rrr1 GL_ALPHA = 000r GL_RED = r001
The default is LUMINANCE, so you were probably getting "1" before when you were using .w.
Post-GLSL 1.3, DEPTH_TEXTURE_MODE is deprecated and GLSL behaves as if its always set to LUMINANCE (so you get a rrr1 return, where r is the depth comparison value).
I'm trying to implement the PCF Soft Shadows in my own project. The idea is to adapt the code from the example.
Unfortunately, I'm getting an incorrect lighting, very bright and without shadows. I need some help diagnosing the issue.
I'm using a QGLWidget (from Qt) to render. Before this implementation, I was just doing rendering on the widget; however, I've seen that the tutorial uses two FBO objects. I copied that part, but I don't know if I have to change also my code.
This is the result that I'm getting:
http://minddebuggers.com/fotos/rendering-wrong.jpg
This is a reference of what I get without lighting:
http://minddebuggers.com/fotos/rendering-OK.jpg
Thanks in advance.
I have some trouble with the simple shadow mapping.
I'm using textureProj() with sampler2DShadow.
Maybe i put the wrong TextureMatrix.
Proj-Light --> perspective projection of the light
View-Light --> view matrix of the light
I do the following:
- for the depth texture:
Code :glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL); glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
- during shadow map rendering (with FBO like the tutorial) I use Proj-Light and View-Light*ModelMatrix
respectively as projection and model-view matrix
- during the regular rendering pass I use the following TextureMatrix:
TextureMatrix = Bias * Proj-Light * View-Light * ModelMatrix;
- vertex shader:
- fragment shader:Code :shadowmapCoord = TextureMatrix * inputVertex:
Code :shadow = textureProj(shadowMap, shadowmapCoord )
The result is no shadow at all...
Any help is much appreciate!
I think we need to see the entire shader. Many subtle things could be wrong.
OMG you're right. I accidentally changed some piece of my spaghetti code, and.. tahdah.. it works! I can see the Moiré pattern!
Thanks anyway.