Jump to content
  • Advertisement
Sign in to follow this  
thomas3711

OpenGL Overlaying screen with FBO texture via Cg shaders

This topic is 3351 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, I've been looking all over the internet for this and found a lot of resources, but I still can get this right. And I did not find any example that is doing exactly what Iam trying to do. So rendered my whole scene into texture via FBO, with some mask textures on it. And I try to overlay my whole screen with content of this FBO texture. Apart from other things I do in my shaders, I set texturing unit 2 to be expected in shaders along with its texturing coordinates and try to extract color information from this texture: void main_vertex(float2 MaskTexCoord : TEXCOORD2, out float2 oMaskTexCoord : TEXCOORD2) { oMaskTexCoord = MaskTexCoord; } void main_fragment(out float4 oColor : COLOR, float2 MaskTexCoord : TEXCOORD2, uniform sampler2D MyMask: TEXUNIT2) { float4 decal2 = tex2D(MyMask, MaskTexCoord); oColor.xyz = color_values_counted_earlier + 0.5 * decal2; } In OpenGL code I set my mask texture for the texturing unit2: glActiveTextureARB(GL_TEXTURE2_ARB); glBindTexture(GL_TEXTURE_2D,GlowMaskTexture); Please what am I doing wrong ?

Share this post


Link to post
Share on other sites
Advertisement
I don't know what you are doing wrong, because i don't what's the problem, can you be a bit more specific on what you problem is?

Share this post


Link to post
Share on other sites
OK so I'll try to be more clear. I've got scene rendered with some mask in texture (let's say glow mask). Texture has got exact the same size as my screen (let's say 1024x768). I want to create this glow effect. But before getting to problem of bluring the texture, Iam trying apply it on the scene, overlay the whole scene with it.

scene is rendered in texture.
I want to add color from this texture to appropriate pixel in output. But when I read from my texture in shader and try to apply this color, Iam not getting correct values. It seems to be all messed up. It is not combined one to one (i.e. final scene render + scene rendered to texture).

Share this post


Link to post
Share on other sites
I've changed access to my mask like this:
float4 decal2 = tex2D(GlowMask, position.xy);

And this is what Iam getting:
shader problems

On the rectangle on the left side you can see sceen rendered to texture (it is inverted in x-axis, which is because of FBO i think). I then apply it on the scene, but as you can see the result is strange.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!