Using render to texture to draw a 3d gui

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Adversus
Posts: 128
Joined: Sun Oct 05, 2008 10:58 pm
Contact:

Using render to texture to draw a 3d gui

Post by Adversus »

I have this working except that what I'm finding is that when you render a gui element to a texture it doesn't give the exact same result as rendering to the framebuffer.

I've tested them side by side using an image file that I generated by writing the texture.

I've looked through all the code and there doesn't seem to be a problem and it's very subtle so has anyone else noticed this and is it a known issue (either with opengl, irrlicht or drivers) or is there something I'm missing?

I've tested the filtering and I'm pretty sure it's not that besides I'm not doing any resizing.

I think it's mainly an issue with the alpha. Could it be that render target textures don't use the same precision as normal textures even if their color formats are the same?
Adversus
Posts: 128
Joined: Sun Oct 05, 2008 10:58 pm
Contact:

Re: Using render to texture to draw a 3d gui

Post by Adversus »

Ignore as I've fixed this.

For anyone who is interested to know you need to use glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA) when drawing the texture on the billboard back to screen.

However that still doesn't explain why the actual rendered texture is different than the source texture so does anyone knows why? Or maybe I don't want to know. :-)
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Using render to texture to draw a 3d gui

Post by mongoose7 »

Are you saying that you are comparing an image A with an image B obtained by rendering A as a texture on a billboard and converting it to an image?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Using render to texture to draw a 3d gui

Post by hendu »

I'd bet the image was exactly the same if you dump it directly by using createImage from the RTT. Having double-alpha effects is common, and just means you need to be careful in how you draw your texture to the screen.
Adversus
Posts: 128
Joined: Sun Oct 05, 2008 10:58 pm
Contact:

Re: Using render to texture to draw a 3d gui

Post by Adversus »

mongoose - yea that's what I'm doing.

btw - Using the pre-multiplied doesn't work right either although it is better. Another solution is to render it twice which again is better but not quite the same.
Post Reply