PDA

View Full Version : High precision blending on 128-bit color card


vpegorar
19-Jul-2003, 02:01
Hi everybody !

I am doing volume rendering in openGL under windows using 3D textures. As I am rendering scientific data, I want to have the most details as possible and, as a consequence, I want to use lots of slices. But as I increase the number of slices, I calculate the slices color in such a way that the alpha value of each slice gets smaller and smaller in order to get the same global attenuation. The problem is that I reach a point where the alpha values are so small that they do not have any effect any more.
The only possibility that I see to solve my problem would be to compute the process with values coded on at least 2 bytes instead of only one. But I don't know how to do that. If I set the internal format of the texture with ALPHA_16, instead of ALPHA_8, glGetTexLevelParameteriv(GL_TEXTURE_3D_EXT,0,GL_TE XTURE_ALPHA_SIZE,&val2) still give me 8 as result, while glGetTexLevelParameteriv(GL_TEXTURE_3D_EXT,0,GL_TE XTURE_INTERNAL_FORMAT,&val1) returns the same internal format as I asked for. Moreover, even if the texture would be coded on 16 bits instead of 8, I am not even sure that the data wouldn't be resized on 1 byte during the computation. I have tried to change the pixel format descriptor, or use glutInitDisplayString ,hoping that this would define the format used for calculations in openGL, but it seems that alpha size bigger than 8 bits is not supported.

Actually, I am using a GeForce FX 5900 Ultra that has true 128-bit color precision (thanks to CineFX 2.0 Engine), according to <http://www.nvidia.com/view.asp?PAGE=fx_5900>
Instead of using some tricks in opengl, I would rather, if possible, use this 128-bit hardware feature, but I still don't know how to do that. The rendering is currently definitely not computed using 32 bits per color chanel, so how can I "activate" it ? I hope that this is not only dedicated to floating point pbuffers, that do not support blending.

Does anybody know how to solve my problem ?

Thanks.

bloodbob
19-Jul-2003, 05:28
Actually, I am using a GeForce FX 5900 Ultra that has true 128-bit color precision (thanks to CineFX 2.0 Engine), according to <http://www.nvidia.com/view.asp?PAGE=fx_5900>
Instead of using some tricks in opengl, I would rather, if possible, use this 128-bit hardware feature, but I still don't know how to do that. The rendering is currently definitely not computed using 32 bits per color chanel, so how can I "activate" it ?

LOL unfortunately I doubt your ever gonna get full 128-bit rendering with your video. You could try enable quality hints where ever possible but OGL standard set the minium accuracy at 16bits(per compent)? or it might even be less.

As far as the texture format I can't help you there I've never really fiddled with them.

arjan de lumens
19-Jul-2003, 08:14
128-bit color precision in the NV3x architectures is only available in 2D textures, pbuffers, and shader programs - other than that, you are pretty much limited to 32-bit color precision. See extensions 281 and 282 in the OpenGL Extension Registry (http://oss.sgi.com/projects/ogl-sample/registry/) for more details.

If you need such a large dynamic range for alpha values, you might try to store alpha values like this in the 3d texture map (with both alpha and alpha' as numbers in the range [0,1]):

alpha' = (log alpha) * (-1/const)

with the const value dependent on the dynamic range you want (larger value=larger range, at cost of precision; for your purposes, I'd estimate that a const somewhere in the range 10 to 15 should work well, although you will need to experiment a little), and then in a pixel shader program reconstruct the desired alpha-value with something like

alpha = exp( alpha' * -const)

(Alternatively, you might switch to ATI R3xx cards, which apparently do support floating-point 3D textures :wink: )

You might not be able to get alpha blending directly for a floating-point pbuffer, but you can always use pbuffers as textures and swap back and forth between 2 or so pbuffers, implementing alpha-blend between pbuffers as pixel shader programs. This works fine as long as you process the whole frame for each alpha-blend pass; if you only wish to process part of the frame, it gets a bit hairier, though.