• Advertisement
Sign in to follow this  

Elegant GLSL Shadow buffer ?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been studying shadow buffer for a while now and I must have misunderstood something ; Let me explain how I do it. The principle is to render the scene from the light POV first. Then save the modelviewtransformation matrix in the texture matrix, add a bias (to transform coordinate from [-1,1] to [0,1]). Step two: Render the scene with the camera modelViewProjection. In the shader,perform a w divide and finally use the texture matrix to lookup the shadow buffer and hence decide whether a fragment is in shadow or not. What i find inelegant is that I now have to maintain both the MODELVIEW and the TEXTURE matrix when rendering several instances of the same object: What used to be nice:
glPushMatrix();
	glTranslatef(50,0,50);
	glutSolidCube(30);
glPopMatrix();

	
glPushMatrix();	
	glTranslatef(-50,0,-50);
	glutSolidCube(30);		
glPopMatrix();
Now looks like:
glPushMatrix();
		glTranslatef(50,0,50);
		glMatrixMode(GL_TEXTURE);
			glPushMatrix();
				glTranslatef(50,0,50);
		glutSolidCube(30);
			glPopMatrix();
		glMatrixMode(GL_MODELVIEW);
	glPopMatrix();

	
	glPushMatrix();	
		glTranslatef(-50,0,-50);
		glMatrixMode(GL_TEXTURE);
			glPushMatrix();
				glTranslatef(-50,0,-50);
				glutSolidCube(30);
			glPopMatrix();
		glMatrixMode(GL_MODELVIEW);
	glPopMatrix();
Am I completely missing the point or is it the way to go ? [Edited by - nicolasbol on December 14, 2008 4:55:16 PM]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement