Jump to content
  • Advertisement
Sign in to follow this  
Cyraxx

OpenGL Multiple Passes

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

Hey. When I create vertex and fragment shaders in ATI's RenderMonkey I have the option to render a pass to a texture and thereby having multiple passes in my shader. How do I do the same thing with my OpenGL code, that is I need to render one pass to a texture and then use this texture in a second pass etc. ?

Share this post


Link to post
Share on other sites
Advertisement
1-set your view port to the dimensions of your texture
2-render your stuff normally
3-bind the texture where you want the result to be rendererd and use glCopyTexSubImage2D
4-Tada :D
Well there are other alternatives such as the use of FBOs and Pixel buffers, let me know if you would like to know more about them :)

Share this post


Link to post
Share on other sites
Thanks for the reply.

This seems to work, but is there a way to dump the Z-buffer to texture as well? I'm trying to do some tranparency stuff and it would be helpful to have access to the Z-buffer?

Maybe FBOs and Pixel buffers are the answer? :) (I have no idea what those are.)

Share this post


Link to post
Share on other sites
"glReadPixels" function easy to use to get depth value, but it is really slow. some more function can be used for this but i recommend you to get the values from fragment shader. gl_color.z is the z-buffer value for that pixel.

Share this post


Link to post
Share on other sites
I thought you could do it with glCopyTexSubImage2D, but it appears you cannot. You will want to use glCopyTexImage2D (Does the same thing, someone tell me why you would want to use glCopyTexSubImage2D instead, please). This may be slower, then SubImage, but i'm not sure. This function takes a parameter "internal format" that you can set to GL_DEPTH_COMPONENT, to copy the z buffer.

SIDE NOTE: JCD, How'd it go with nvidia???

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!