Sign in to follow this  
zaneski13

Multipass Rendering (basic)

Recommended Posts

zaneski13    104
I made a post about 3 weeks ago and I didn't get the information I needed so I'll just try again... I'm trying to make an object with 2 different shaders applied to it. I'm starting out really basic. I made 2 different color shaders. one makes the color red and the other blue. I enable blending and use the values GL_ONE, GL_ONE. I then draw a triangle onto the screen using my mesh class. I then apply the red material. (red shader) I repeat this process only I use gl_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA as my blending mode and I apply the blue material. I also set the glColor to glColor4f(1.0f,1.0f,1.0f,0.5f) so I draw the blue triangle with a 50 percent alpha. When I compile and run this program however, I only see the blue triangle. I think this is because in the blue shader is use gl_FragColor(0.0f, 0.0f, 1.0f, 1.0f) Notice that I pass 1 as alpha. How should I blend the red triangle and the blue triangle to get some sort of purple triangle? Thanks!

Share this post


Link to post
Share on other sites
stalef    607
AFAIK, setting glColor4f(1.0f,1.0f,1.0f,0.5f) will only work for FFP, and has no effect when shaders are used. Alpha used for blending will be the alpha value set by your shader.

[Edited by - stalef on February 12, 2010 7:41:54 PM]

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this