Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Elegant GLSL Shadow buffer ?

Started by nicolasbol Dec 14, 2008 at 4:16 PM 0 replies 650+ views
Original Post
nicolasbol
nicolasbol
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]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.