Problems with MRT in Fragment Shader

Started by
-1 comments, last by Malei 14 years, 4 months ago
Hi, every one! I'm currently trying to rendering front and back faces of a object to two textures which bind to a FBO during one pass. I successfully made it by the setting the gl_layer = layerid in geometry shader. (layerid is labeled by a calculation with the camera position and the normal of the vertex). The key sentence in my vertex shader vertex shader: float layer = dot( normalize(eyeSpaceNorm), -normalize(eyeSpacePos.xyz) ); gl_TexCoord[0].w = layer; geometry shader: gl_Layer = int(gl_TexCoordIn[0][0].w); fragment shader: Just simply output the color. And the result is correct, I did correctly get the front and back colors of the object during one pass. However, for some reasons, I have to do this by using the fragment shader. After carefully bind the multiple textures with the FBO, GLenum drawbuffers[2] = {GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT} glDrawBuffers(2, drawbuffers); vertex shader: float layer = dot( normalize(eyeSpaceNorm), -normalize(eyeSpacePos.xyz) ); gl_TexCoord[0].w = layer; fragment shader gl_FragData[layerId] = ..... However, I can only get the front face, There is a wierd output of the second texture. And if I changed the judge sentence, like if(depth>0.5) gl_FragData[0]=.. else gl_FragData[1]=.. The output of the two images is the seperate part of the front face, there is no back face. How did this happened?

This topic is closed to new replies.

Advertisement