notoriousRob
12-27-2010, 01:50 PM
Hello. I am having some issues with a simple implemenation of variance shadows in OpenGL 3.2, GLSL 1.2. I have tried to solve the problem by reading these forums and searching the net at large but, I finally have to post and ask for direct help.
I'm linking a zip of the c++ file and shaders for anyone wishing to bypass my probably muddled explanation. It uses GLM for the matrix and vector math. The lighting is an ambient and diffuse point light.
http://dl.dropbox.com/u/7187892/vsm.zip
The image in the right top corner is of the first pass.
http://i.imgur.com/ysaaY.png (http://imgur.com/ysaaY)
The problem seems to be in the comparison of depths from the shadow map texture lookup and and the depth calculated in the fragment shader of the 2nd pass. I have tried various approaches with the matrix used to get the coordinates.
mat4 shadowMatrix = bias * lightPMVMatrix;
//mat4 shadowMatrix = bias * lightPMVMatrix * inverse(vsmView);
//via the orange book
//mat4 shadowMatrix = bias * modelMatrix * lightViewMatrix * lightPerspective;
Below is the way I am calculating the depth for the 2nd pass which, I think may be too simplistic.
Vertex Shader
varying vec4 worldDepth;
...
worldDepth = LightModel * vPos;
Fragment Shader
float d = length(lightPos - worldDepth.xyz)/far;
The strangest issue is that no matter what I do I can not get the box to cast any shadow. If so, I would at least know I am on the right track and probably be able to solve my other issues. I would appreciate anyone that can point me in the right direction to get over this hump.
I'm linking a zip of the c++ file and shaders for anyone wishing to bypass my probably muddled explanation. It uses GLM for the matrix and vector math. The lighting is an ambient and diffuse point light.
http://dl.dropbox.com/u/7187892/vsm.zip
The image in the right top corner is of the first pass.
http://i.imgur.com/ysaaY.png (http://imgur.com/ysaaY)
The problem seems to be in the comparison of depths from the shadow map texture lookup and and the depth calculated in the fragment shader of the 2nd pass. I have tried various approaches with the matrix used to get the coordinates.
mat4 shadowMatrix = bias * lightPMVMatrix;
//mat4 shadowMatrix = bias * lightPMVMatrix * inverse(vsmView);
//via the orange book
//mat4 shadowMatrix = bias * modelMatrix * lightViewMatrix * lightPerspective;
Below is the way I am calculating the depth for the 2nd pass which, I think may be too simplistic.
Vertex Shader
varying vec4 worldDepth;
...
worldDepth = LightModel * vPos;
Fragment Shader
float d = length(lightPos - worldDepth.xyz)/far;
The strangest issue is that no matter what I do I can not get the box to cast any shadow. If so, I would at least know I am on the right track and probably be able to solve my other issues. I would appreciate anyone that can point me in the right direction to get over this hump.