Sign in to follow this  
SteveDeFacto

HDR causing X-Ray effect...

Recommended Posts

SteveDeFacto    109
When I create a texture using GL_RGBA16F and bind it to my frame buffer it appears as though the polygons are semi transparent to each other when I render my scene to it. Here is how I create the texture:

[code]glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, Width, Height, 0, GL_RGBA, GL_FLOAT, NULL);[/code]

Any ideas what could be causing this? Even though I don't think it's enabled could it be something to do with the stencil buffer maybe?

Share this post


Link to post
Share on other sites
Digitalfragment    1504
[quote name='SteveDeFacto' timestamp='1313218284' post='4848534']When I create a texture using GL_RGBA16F and bind it to my frame buffer it appears as though the polygons are semi transparent to each other when I render my scene to it. Here is how I create the texture:

[code]glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, Width, Height, 0, GL_RGBA, GL_FLOAT, NULL);[/code]

Any ideas what could be causing this? Even though I don't think it's enabled could it be something to do with the stencil buffer maybe?
[/quote]

Most likely your shaders and/or blend functions are causing values to go below zero. Floating point targets are not clamped, ensure you do a max(0, value) at the end of your shaders unless you are intentionally allowing negative values.

Share this post


Link to post
Share on other sites
SteveDeFacto    109
[quote name='Digitalfragment' timestamp='1313219273' post='4848538']
[quote name='SteveDeFacto' timestamp='1313218284' post='4848534']When I create a texture using GL_RGBA16F and bind it to my frame buffer it appears as though the polygons are semi transparent to each other when I render my scene to it. Here is how I create the texture:

[code]glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, Width, Height, 0, GL_RGBA, GL_FLOAT, NULL);[/code]

Any ideas what could be causing this? Even though I don't think it's enabled could it be something to do with the stencil buffer maybe?
[/quote]

Most likely your shaders and/or blend functions are causing values to go below zero. Floating point targets are not clamped, ensure you do a max(0, value) at the end of your shaders unless you are intentionally allowing negative values.
[/quote]

I added this to the end of all my fragment shaders:

[code]Out.color = max(float4(0.0, 0.0, 0.0, 1.0), Out.color);[/code]

But it still happens...

Share this post


Link to post
Share on other sites
SteveDeFacto    109

Code I'm using to initialize the frame buffer and texture:[code]
glGenFramebuffers(1, &rendertarget->frameBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, rendertarget->frameBuffer);
glGenRenderbuffers(1, &rendertarget->depthBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, rendertarget->depthBuffer);
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rendertarget->depthBuffer);
glGenTextures(1, &rendertarget->BaseTexture);
glBindTexture(GL_TEXTURE_2D, rendertarget->BaseTexture);
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, 0, GL_RGBA, GL_FLOAT, NULL);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, rendertarget->BaseTexture, 0);
GLenum status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
if(status != GL_FRAMEBUFFER_COMPLETE)
{
OutputDebugString( L"Unable to create frame buffer" );
}[/code]

Share this post


Link to post
Share on other sites
Digitalfragment    1504
[quote name='SteveDeFacto' timestamp='1313223994' post='4848551']
Code I'm using to initialize the frame buffer and texture:[code]
snip
[/code]
[/quote]

What are you using for your clear colour / clear depth, and what blend functions are you using? I don't see anything out of the ordinary with your framebuffer construction.

Share this post


Link to post
Share on other sites
SteveDeFacto    109
[quote name='Digitalfragment' timestamp='1313234877' post='4848595']
[quote name='SteveDeFacto' timestamp='1313223994' post='4848551']
Code I'm using to initialize the frame buffer and texture:[code]
snip
[/code]
[/quote]

What are you using for your clear colour / clear depth, and what blend functions are you using? I don't see anything out of the ordinary with your framebuffer construction.
[/quote]

I figured it out. It was not that the alpha was going below zero but that it was over 1.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this