Shadows?

Started by
4 comments, last by Daivuk 17 years, 7 months ago
Hi, I am currently working on implimenting some shadows into my game and am experiencing super slow FPS. What I mean by slow is the max my video card can do with vsysn on which is about 60 FPS when I am not rendering my shadows down to about 5 or so FPS. I have one fairly complex model (maybe 60 or so pollies), compaired to my two other ones which are basically a cube with a slanted front. I am not sure why I am experiencing such slow FPS. My models are 3ds models and I am trying to draw the shadows with some code modified form a nehe tutorial. I know that it can be optimized, but still why would it drop do much. Is there a much better way to do shadows because it seems like many games can handle dynamic shadows with way more complex models than mine with no problems?
Advertisement
Quote:Original post by starfleetrp
Is there a much better way to do shadows because it seems like many games can handle dynamic shadows with way more complex models than mine with no problems?
You havnt told us how you are currently doing your shadows, so how can we suggest a better way?
Allways question authority......unless you're on GameDev.net, then it will hurt your rating very badly so just shut the fuck up.
Ok, like I said I am using the code from the NeHe tutorial, what I am using is:

[source lang = "cpp"]	glDisable(GL_LIGHTING);	glDepthMask(GL_FALSE);	glDepthFunc(GL_LEQUAL);	glEnable(GL_STENCIL_TEST);	glColorMask(0, 0, 0, 0);	glStencilFunc(GL_ALWAYS, 1, 0xffffffff);	// first pass, stencil operation decreases stencil value	glFrontFace(GL_CCW);	glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);        //Code to draw the faces/triangles	glFrontFace(GL_CW);	glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);        //Code to draw the faces/triangles	glFrontFace(GL_CCW);	glColorMask(1, 1, 1, 1);	//draw a shadowing rectangle covering the entire screen	glColor4f(0.0f, 0.0f, 0.0f, 0.4f);	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_TRIANGLE_STRIP);		glVertex3f(-0.1f, 0.1f,-0.10f);		glVertex3f(-0.1f,-0.1f,-0.10f);		glVertex3f( 0.1f, 0.1f,-0.10f);		glVertex3f( 0.1f,-0.1f,-0.10f);	glEnd();	glPopMatrix();	glDisable(GL_BLEND);	glDepthFunc(GL_LEQUAL);	glDepthMask(GL_TRUE);	glEnable(GL_LIGHTING);	glDisable(GL_STENCIL_TEST);	glShadeModel(GL_SMOOTH);
I can't see how any shadow gets drawn with that as you've cut out so much code.I can think of 3 ways of doing shadows:

1)use depth texture when drawing with camera at light source
2)use shaders
3)stencil - I think this is what you're doing.

The stencil way will always be slow as you're doing multiple renders of each object. To speed things up try adding your objects to a display list or vbo so you're not sending all the data down to the card each time.




You should use shaders to improve the performance. Especially when you use stencil shadows - making extrusions in a shader is a good idea.
-- SirMike - http://www.sirmike.org
Actually, stencil shadow without shaders can be very fast. But it sure you will need vertex shaders to increase performances

http://www.angelfire.com/games5/duktroa/RealTimeShadowTutorial.htm

Check out this tutorial (mine) I explained well how to acheive the effect using the stencil buffer.

But note that you need a fast algo for silhouette determination and stuff like that.

And as said ade-the-heat try putting your models into the VRAM to decrease transfert.

This topic is closed to new replies.

Advertisement