Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


[DX11] Pixel Shader Output


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 SapphireStorm   Members   -  Reputation: 140

Like
0Likes
Like

Posted 20 July 2011 - 01:38 PM

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.

Sponsor:

#2 DieterVW   Members   -  Reputation: 700

Like
1Likes
Like

Posted 20 July 2011 - 01:42 PM

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.

#3 MJP   Moderators   -  Reputation: 11786

Like
2Likes
Like

Posted 20 July 2011 - 01:45 PM

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




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS