Jump to content
  • Advertisement
Sign in to follow this  
Malei

Problems with MRT in Fragment Shader

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

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?

Share this post


Link to post
Share on other sites
Advertisement
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!