# Difference between floating point render target and normal render target

This topic is 3968 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Could someone please explain what is the difference between floating point render targets and a normal render target like A8R8G8B8? I mean both types of render target takes float4 as output from the pixel shader, so what is the difference? Is A8R8G8B8 a integer render target? What happens in the pixel shader when I write: return float4(1.0, 0.0, 0.0, 1.0); So my question is if A8R8G8B8 is an integer render target then what happens when i return a color value in the range of 0.0 and 1.0? Does the hardware automatically convert it to between 0 and 255 (integer) and display the result? Thanks in advance :)

##### Share on other sites
Quote:
 Original post by JBondSo my question is if A8R8G8B8 is an integer render target then what happens when i return a color value in the range of 0.0 and 1.0? Does the hardware automatically convert it to between 0 and 255 (integer) and display the result?

Yep, it's an integer render target (0-255).

I'm not if the hardware does it, or if the shader-compiler changes your code to use special integer maths behind the scenes... But yes, the end result is that you're really only working with [0-255] integers, and not with floating point.

##### Share on other sites
An integer rendertarget, like A8R8G8B8, takes a value between 0.0 and 1.0 and converts it into an integer by multiplying with the maximum integer value for each channel. For instance, if you output 0.75 to a channel from the shader using an A8R8G8B8 rendertarget, it writes 0.75*255 = 191 to that channel. Same for other integer formats.

A floating-point rendertarget will directly write whatever value you output, using the precision of the target (i.e. FP16, FP32, etc.).

##### Share on other sites
What happens when I write something out of the 0-1 range into an integer rener target? does it clamp? overflow?
Do you mean I can safely write any floating point number into a floating point render target even if its outside of the 0-1 range?
Thanks!

##### Share on other sites
Quote:
 Original post by JBondWhat happens when I write something out of the 0-1 range into an integer rener target? does it clamp? overflow? Do you mean I can safely write any floating point number into a floating point render target even if its outside of the 0-1 range?Thanks!
Okay, I don't really do any hardware 3D programming at all, but IIRC it would clamp, as that is the basics of how High Dynamic Range (HDR) works.

##### Share on other sites
Quote:
 Original post by JBondWhat happens when I write something out of the 0-1 range into an integer rener target? does it clamp? overflow?

It will clamp (or "saturate", to use the lingo).

Quote:
 Do you mean I can safely write any floating point number into a floating point render target even if its outside of the 0-1 range?

Absolutely. That is why HDR works. Floating-point values allow you to represent very large differences in light intensity in your scene, without knowing beforehand what the maximum and minimum light values will be (hence this range is dynamic).

##### Share on other sites
Quote:
 converts it into an integer by multiplying with the maximum integer value for each channel
so what terminologie is correct: integer render target or fixed-point render target? I believe integer ... any thoughts?

##### Share on other sites
Quote:
 Original post by wolfso what terminologie is correct: integer render target or fixed-point render target? I believe integer ... any thoughts?
I prefer fixed-point, to differentiate between "normalized" integer and the newer "unnormalized" integer formats (as in GL_EXT_texture_integer, I'm not sure of the D3D counterpart).

##### Share on other sites
Another question, how is floating point represented in the hardware in the floating point render target? I mean does it have a sign bit, an expont part, and a significand part as in IEEE floating point? what kind of precision can I expect from say a R32F? Thanks!

##### Share on other sites
According to NVidia, sometimes when you ask for a 16-bit float texture, they'll actually give you a 32-bit texture instead.

32-bit floats do follow the IEEE standard.
I'm not sure if there is a IEEE standard for 16-bit floats, but they probably have 1 sign bit, 5 exponent bits, and 10 mantissa bits.

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633694
• Total Posts
3013378
×