Sign in to follow this  
axon

Understanding R32F Texture Format

Recommended Posts

I'm rendering to texture a height field. When I view the R32F format texture I see Aqua (Blue + Green) to White instead of Black to white (when rendering to X8R8G8B8). I would have thought black is black regardless of the format?

Share this post


Link to post
Share on other sites
The green and blue components are being regarded as 1.0 since they are missing from the texture data.

If you use a texture format which doesn't contain a particular channel, it is advisable not to use the missing channels as they could result in undefined behavior (although in theory the behavior is defined).

Quoting from the SDK, chapter D3DFORMAT:
Quote:

The default value for formats that contain undefined channels (G16R16, A8, and so on) is 1. The only exception is the A8 format, which is initialized to 000 for the three color channels.

Share this post


Link to post
Share on other sites
Cheers.

Now that's fixed, can anyone suggest why the colouring is more granular than when I use A8R8G8B8 to store this info?

Somehow I'm losing resolution when I convert back to the X8R8G8B8 format. (there are less levels than when I use R32F to encode a single colour than if I use a single channel of A8R8G8B8???).

Share this post


Link to post
Share on other sites
Many cards that support floating-point textures do not support them with filtering of any kind. Maybe the granularity is a by-product of that fact instead of an issue with color precision?

Share this post


Link to post
Share on other sites
I agree with what Nik02 says [smile]

Converting from 32bit floating point to 8 bit integer is almost guaranteed to introduce some rounding/precision errors. The lack of filtering support is only likely to make this more obvious.

You get similar effects when you do shadow mapping and try to render the R32F depth texture to the screen for debugging.


Although, if you use the "raw" FP32 values they should be fine and with a good precision - it's just the debugging/output part that'll be broken.

hth
Jack

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