This topic is 3672 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I'm trying to get GLSL shadowmapping working. I've made functions so that they wouldn't clutter the main. I believe the problem is in the texture matrix projecting. Here's the draw part of the main:
glLibUseShader(BlankShader)

#Clears color/depth buffers, resets matrix
Window.clear()
#Set the view from the light's point of view.
LightView.set_view()
gluLookAt(0,100,0,
0,0,-4,
0.0,1.0,0.0)

#Self-explanatory
DrawTeapot()
DrawFloor()

#Not quite sure if this is right.  I'll provide function later.
#Render scene to a depth texture.  I've tested this, and I'm sure it works.
depthmap = glLibSceneToDepthMap(512,depthmap)

#Clear window again
Window.clear()
#Set the camera's view (no call to gluLookAt() because camera at origin).
View3D.set_view()

glLightfv(GL_LIGHT0,GL_POSITION,[0,100,0,1.0])

#Not entirely sure about these either.
glMatrixMode(GL_TEXTURE)

DrawTeapot()
DrawFloor()


Here's where the texture matrix is projected:
def glLibShadowGetProjMat(lightpos,center,angle,near,far):
glMatrixMode(GL_PROJECTION)
gluPerspective(angle,1.0,near,far)
LightProjectionMatrix = glGetFloatv(GL_PROJECTION_MATRIX)
glMatrixMode(GL_MODELVIEW)
gluLookAt(lightpos[0],lightpos[1],lightpos[2],
center[0],center[1],center[2],
0.0,1.0,0.0)

LightViewMatrix = glGetFloatv(GL_MODELVIEW_MATRIX)

glMatrixMode(GL_TEXTURE)
glPushMatrix()
[0.0,0.5,0.0,0.0],
[0.0,0.0,0.5,0.0],
[0.5,0.5,0.5,1.0]])
glMultMatrixf(LightProjectionMatrix)
glMultMatrixf(LightViewMatrix)
TextureMatrix = glGetFloatv(GL_TEXTURE_MATRIX)
glPopMatrix()
return TextureMatrix


Finally, the relevant parts of the shaders:
//RELEVANT VERTEX SHADER SECTION
ProjCoord = gl_TextureMatrix[0]*(gl_ModelViewMatrix*gl_Vertex);
//ProjCoord is then sent to the fragment shader.

//color created, set by a phong lighting model here

rValue = clamp(rValue, 0.0, 1.0);

vec3 CoordPos = ProjCoord.xyz / ProjCoord.w;

if(CoordPos.x>=0.0 && CoordPos.y>=0.0 && CoordPos.x<=1.0 && CoordPos.y<=1.0) {
color *= rValue;
}


All this doesn't work, though. Strangely, I don't see the teapot object at all (should be about mid-screen here). I do however see the floor (gold on the bottom), which isn't entirely blank. I see a ghost image of the teapot on it, which looks like someone took the depth texture, and combined it with the floor material: Please help me fix this! Thanks, Geometrian

1. 1
2. 2
3. 3
Rutin
13
4. 4
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633696
• Total Posts
3013390
×