Jump to content
  • Advertisement
Sign in to follow this  
timmie

OpenGL Multipass rendering.

This topic is 5051 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

Ok, I posted this on the OpenGL message board (http://www.opengl.org/discussion_boards/cgi_directory/ultimatebb.cgi?ubb=get_topic;f=3;t=012433), but I only got one reply, so I figured I'd ask here as well. Basically, I'm working on getting (simulated) dynamic lighting working, but ran into a bit of a problem. Normally it works great, but I also implemented something similar to Quake3's shaders (http://zdoomgl.mancubus.net/docs/shaders.html) which kind of mess things up since they don't follow the same blending methods as normal geometry. The basic passes look like this: - depth pass - color pass (GL_ONE, GL_ZERO) - light passes (1 for each light) (GL_SRC_ALPHA, GL_ONE) - texture pass (GL_DST_COLOR, GL_ZERO) - possibly a fog pass as well (for the colored per-sector fog) But with the shaders, the texture pass changes and won't use the same blending modes, so the color pass gets overwritten. I'm just wondering if there's a reasonably simple way of getting around this. Thanks :)

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure what your exact question is... But I'll try anyway. If I understood correctly the texture is overwriting the colour from your colour pass and light pass. You're going to have to set the GL_TEXTURE_ENV_MODE to GL_MODULATE, to multiply the texture colour with the current colour of the pixel.

Hope this helps...

Share this post


Link to post
Share on other sites
If i get it right, your shader pass is overwriting the blend function parameters with the blend function parameters in the shader file. If you implemented (i read written) it yourself you should be able to just remove the line where they are being changed. You could also just allow only some blend functions and reset the blend functions every pass.

Btw, the texture should be added by multiplying the texture color by the lighting color, what James Trotter said should work. You could also try glBlendFunc(GL_ZERO,GL_SRC_COLOR) as GL_SRC_COLOR might use the fragment color instead of the glColorX color when GL_COLOR_MATERIAL isn't enabled, i am not sure though.

And by color pass you mean ambient lighting pass, i guess?

Share this post


Link to post
Share on other sites
Oh, the lighting works fine for the basic surfaces, it's just when I get into the shaders with their multiple layers. The more I think about it, though, the more I think I'm going to have to render the textured geometry to a texture or something and then blend that on top of the ambient/lighting result. Sounds more complicated than I wanted to get into, but you only learn by doing, I suppose!

http://timmie.squabble.org/screenshots/lights/klight_2.jpg

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!