Original Post
Right,
seems like i just don't get the idea how to lookup this damn cube texture in frag shader.
As in my previous post that was not resolved, i have
- cube depth texture with 6 faces rendered from light position
- Light view matrix, obtained by:
after doing lookat from light position into the cubemap face direction.
- Light projection matrix, obtained by:
I am just writing depth when rendering to 6 faces of a cubemap, there is no shader involved - this is made off screen with FBO.
After that, a final scene comes in - and i pass matrices to vert and a
- Vertex shader:
- Fragment shader:
Can somebody please take a look, and help me out to project a cube shadow ?
The effect is nothing, i can bet this is because of matrices, as when i mangle with them i get some results sometimes, but they are not correct.

EDIT:
going with the 'additional shader' that stores the dist in the rgba instead of depth.
will come back with results.
seems like i just don't get the idea how to lookup this damn cube texture in frag shader.
As in my previous post that was not resolved, i have
- cube depth texture with 6 faces rendered from light position
glGenTextures(1, &tDepthCubeMap);
glBindTexture(GL_TEXTURE_CUBE_MAP, tDepthCubeMap);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri( GL_TEXTURE_CUBE_MAP, GL_DEPTH_TEXTURE_MODE , GL_LUMINANCE );
glTexParameterf( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE );
glTexParameterf( GL_TEXTURE_CUBE_MAP, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
for (int face = 0; face < 6; face++)
glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, GL_DEPTH_COMPONENT32F , 512, 512, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);
- Light view matrix, obtained by:
glGetFloatv(GL_MODELVIEW_MATRIX, mLightViewMatrix);after doing lookat from light position into the cubemap face direction.
- Light projection matrix, obtained by:
gluPerspective(90, 512/512,10,LightsManager.getLight(0)->radius);
glGetFloatv(GL_PROJECTION_MATRIX, mLightProjectionMatrix);
I am just writing depth when rendering to 6 faces of a cubemap, there is no shader involved - this is made off screen with FBO.
After that, a final scene comes in - and i pass matrices to vert and a
uniform samplerCubeShadow shadowMap; to the fragment. - Vertex shader:
varying vec4 Projection;
vec4 wsvertex= mLightViewMatrix * gl_Vertex;
vec4 wslight= mLightViewMatrix * vec4(lightType[0].position.x,lightType[0].position.y,lightType[0].position.z,1) ;
Projection= normalize( wsvertex - wslight );
- Fragment shader:
uniform samplerCubeShadow shadowMap;
float cDepth=texture( shadowMap, (Projection));
gl_FragColor= vec4(1,0,0,1)* cDepth ; // do it red + shade
Can somebody please take a look, and help me out to project a cube shadow ?
The effect is nothing, i can bet this is because of matrices, as when i mangle with them i get some results sometimes, but they are not correct.

EDIT:
going with the 'additional shader' that stores the dist in the rgba instead of depth.
will come back with results.