Color output with MRT

Started by
-1 comments, last by billy_billy 14 years, 8 months ago
Hi, I'm trying to accomplish the following. I want to render a few objects and save both the color data and modified depth data into textures. In order to do so, I'm using an FBO with a texture color attachment, a color attachment for the modified depth data, and a depth renderbuffer. When I render my objects, (in this case, just a simple cube), the output I get from the render that was put into the color attachment of my FBO looks like the depth calculations are not being performed as expected. As I'm thinking about it, this makes sense in a way, but I don't understand what I'd need to do to fix it. So, again, I have an FBO with two color attachments, and a depth renderbuffer. I render my cube to one of these color attachments using the following (simplified) vertex and fragment shaders. [Vertex] void main(void) { gl_FrontColor = gl_Color; gl_Position = ftransform(); } [Fragment] void main(void) { gl_FragData[0] = gl_Color; gl_FragData[1] = vec4(1.0, 0.0, 0.0, 0.0); } What's put in the color attachment (where I expect to find just a simple rendered cube) (generated by gl_FragData[0]) is a colored cube with some of the faces missing, almost as if rendered in immediate mode without DEPTH_TEST enabled. I suspect this is somehow due to the fact that my fragment shader emits gl_FrontColor, and does nothing with gl_BackColor, but I could be wrong. The big question here is how can I generate a texture using this FBO setup and variations of the above shaders to produce a texture that looks exactly as if I had rendered the cube to the screen in immediate mode? Can anyone see what I'm doing wrong here? Thanks.

This topic is closed to new replies.

Advertisement