Jump to content
  • Advertisement
Sign in to follow this  
SapphireStorm

DX11 [DX11] Pixel Shader Output

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

Can you write values outside of the range of 0.0-1.0 to a render target? I was going to use a pixel shader to compute some position information and store it in a texture. However, most of the data falls outside of the normal color range and gets clamped.

Share this post


Link to post
Share on other sites
Advertisement
It depends on your render target format.

and format with

NORM is from [-1.0f,1.0f]
UNROM is from [0.0f,1.0f]
FLOAT is from [minfloat,maxfloat, nan, inf]

So you can do it if you use the right format.

Share this post


Link to post
Share on other sites
You can write whatever range value you want out of a pixel shader, whether it be floating point or integer. What happens to that value depends on the format of the render target you use. For instance, UNORM formats like R8G8B8A8_UNORM will clamp the value to [0,1] and then store that value in an integer representation. SNORM will clamp to [-1, 1] and do the same. SINT and UINT will truncate floating point values to integer, and output as either signed or unsigned respectively. FLOAT formats don't do any truncation or clamping, and just store the floating point value in the precision specified by the format. So if you want to store XYZ position, then you probably want to use either R16G16B16A16_FLOAT or R32G32B32A32_FLOAT (depending on how much precision you need for that position).

If you're interested in the full rules for format conversion (which apply to both writing to textures and sampling them), you can find them here: http://msdn.microsoft.com/en-us/library/dd607323(v=vs.85).aspx

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!