• Advertisement
Sign in to follow this  

HDR causing X-Ray effect...

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

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:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, Width, Height, 0, GL_RGBA, GL_FLOAT, NULL);

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
Advertisement
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:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, Width, Height, 0, GL_RGBA, GL_FLOAT, NULL);

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?


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

[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:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, Width, Height, 0, GL_RGBA, GL_FLOAT, NULL);

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?


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:

Out.color = max(float4(0.0, 0.0, 0.0, 1.0), Out.color);

But it still happens...

Share this post


Link to post
Share on other sites

Code I'm using to initialize the frame buffer and texture:
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" );
}

Share this post


Link to post
Share on other sites

Code I'm using to initialize the frame buffer and texture:
snip



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

[quote name='SteveDeFacto' timestamp='1313223994' post='4848551']
Code I'm using to initialize the frame buffer and texture:
snip



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
Sign in to follow this  

  • Advertisement