View Full Version : FBO doubt
11-09-2010, 12:16 PM
Does anyone know if openGL clamps to [0..1] the color values when a FBO it set?
If I need to store a per-fragment value that lies outside the range [0..1], which output fragment shader variable I must use?
I read in an article that is possible to store these values in texture coordinates, this wans't really clear to me.
Thanks in advance.
11-09-2010, 04:52 PM
If it is an integer format like GL_RGBA8, GL_LUMINANCE8, GL_LUMINANCE16 and the others, then values are clamped from 0.0 to 1.0 before being converted to an integer, then written.
If it is a floating point format like GL_RGBA32F, then there is no clamping.
There are also the new integer formats that do a "raw write" so it does not clamp either.
11-09-2010, 06:44 PM
V-man's got you covered, but a little more info that might help you out.
* Normalized fixed-point formats: GL_RGBA8, GL_LUMINANCE8, ... (anything that's not *F, *I, or *UI I think)
* Floating-point formats: GL_RGBA16F, GL_LUMINANCE16F, ... *F formats
* Unnormalized fixed-point formats: RGBA8I, RGBA8UI, ... *I and *UI formats (I think the spec calls these integer formats)
Note that with ARB_color_buffer_float (http://www.opengl.org/registry/specs/ARB/color_buffer_float.txt), you can configure fragment clamping with glClampColor( GL_CLAMP_FRAGMENT_COLOR, ... ). By default it clamps for normalized fixed-point, but not for floating-point. That extension probably pre-dates unnormalized fixed-point formats though, so who knows for them. I notice this is in the GL 3.0 spec, but was deprecated in 3.1. However if you're running in a compatibility profile, you should have it.
As V-man indicated, I think the modern way to do what you want is to use an integer format (unnormalized fixed-point -- *UI or *I) or floating-point format (*F). However, IIRC the former (integer formats) prevents you from using MSAA (including multisample alpha), alpha test, and blending.
One other thing. I have this recollection that the spec says with integer formats, you have to be careful to match the type of the output in your shader with the target you bind. So you probably don't use out vec4/etc., but uvec4/ivec4/etc. Not sure but that's my guess.
11-11-2010, 05:50 PM
V-man and Dark Photon, you guys helps a lot. I saw in a code the use of GL_RGBA32F, but I was not sure how this work.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.