Advertisement

Shadow volume (lesson 28)

Started by May 23, 2003 05:15 AM
23 comments, last by greg2 21 years, 9 months ago
I have tried to change the Lesson 28 code because i use gluLookAt for one of my project and i can''t know where to draw the blended quad. I have tried to change my view with glOrtho in the "CastShadow" function. But the shadow is not displayed.
  
/////////////////////////////////////////////////////

	glMatrixMode(GL_PROJECTION);				
	glPushMatrix();						
	glLoadIdentity();					
	glOrtho( 0, 640, 480, 0, 0, 1 );	
	glMatrixMode(GL_MODELVIEW);		
///////////////////////////////////////////////////////////

	glColor4f(0.0f,0.0f,0.0f,0.0f);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
	glStencilFunc(GL_NOTEQUAL,0,0xffffffff);
	glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);

	glPushMatrix();
	glLoadIdentity();
	glBegin(GL_QUADS);
		glVertex3f(0.0f  ,0.0f   ,-0.10f);
		glVertex3f(640.0f,0.0f   ,-0.10f);
		glVertex3f(640.0f,480.0f,-0.10f);
		glVertex3f(0.0f  ,480.0f ,-0.10f);
	glEnd();
	glPopMatrix();

	glDisable(GL_BLEND);
	glDepthFunc(GL_LEQUAL);
	glDepthMask(GL_TRUE);
	glEnable(GL_LIGHTING);
	glDisable(GL_STENCIL_TEST);
	glShadeModel(GL_SMOOTH);
////////////////////////////////////////////

	glMatrixMode( GL_PROJECTION );				
	glPopMatrix();						
	glMatrixMode( GL_MODELVIEW );
/////////////////////////////////////////  

  
Is it because the stencil buffer is cleared by this change? how can i draw this quad (as fast as possible) when i use gluPerspective and gluLookAt ? Thanks.
Post your FULL DrawGLScene()

========================
Leyder Dylan (dylan.leyder@slug-production.be.tf
http://www.slug-production.be.tf/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
Advertisement
If you disable stencil test, does the giant quad fill the screen ?

I think that you have backface culling enabled. Are you sure that you are sending vertices of the quad in the correct order ?

Also, depth test must be disabled for this part. Call glDisable(GL_DEPTH_TEST) ... and don''t forget to enable it again after, if needed.
It''s working!
i have add glDisable(GL_DEPTH_TEST), and the most important think... i have change the color of my quad:
glColor4f(0.0f,0.0f,0.0f,0.0f); is not very visible

Sorry for this stupid error.
And thanks.
But i have an another question about this lesson.
Why do the walls become darken when the light is near?
It should be the opposite (they sould be more lighted).
Are you using Per Pixel Diffuse ?

If yes, try the Per Pixel Lightning.

========================
Leyder Dylan (dylan.leyder@slug-production.be.tf
http://www.slug-production.be.tf/
========================Leyder Dylan (dylan.leyder@slug-production.be.tf http://users.skynet.be/fa550206/Slug-Production/Index.htm/
Advertisement
You''re experiencing per-vertex lighting issues.
Two solutions :
1- tesselate your wall. That is, instead of rendering a big quad for the wall, subdivide the wall in many mini-quads.
2- use per-pixel lighting (as Leyder Dylan proposed). This can be simply done with lightmapping, or better with realtime per-pixel lighting computations in a shader (need decent hardware).

I recommend the first solution which is easier to implement and supported by all OpenGL implementations, unlike per-pixel lighting which either need multitexturing or any kind of fragment shading capabilities.
i am surprised.
Why OpenGL lights do such error?
(i have not modifier the lesson 28, i have just see this problem)

In reality the nearest a light is the brightest the objects are. And it seems to be the inverse with openGL.
Why do i have to one of your 2 solution (i just want to understand).
Unlesss you use a fragment program and do per-pixel lighting, lighting is done per vertex. So the wall gets lighter when the light is nearer the wall''s vertices. You can give your wall more vertices to make it look better.


Why you shouldn''t use iostream.h - ever! | A Good free online C++ book
"So the wall gets lighter when the light is nearer the wall''s vertices."
This is not what i see in the demo of this lesson.

The wall gets Darker when the light is nearer the wall''s vertices.

This topic is closed to new replies.

Advertisement