Jump to content
  • Advertisement
Sign in to follow this  
devronious

pixel shader clamping...

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

If I pass a color of (125,180,125,180) from the vertex shader to the pixel shader will it be automatically clamped between 0 and 1, or anywhere else along the way for that matter? Also if I pass a texture coordinate of (125,80) thru the same way will it be clamped between 0 and 1? Thanks in advance, Devin

Share this post


Link to post
Share on other sites
Advertisement
It depends, but passing any floating point value from the vertex shader to the pixel shader should not be clamped. However, there are stages were they _will_ be, for example:

1) values that get written to the (default) framebuffer get clamped within the range 0..1, to fit them within the 8-bit integer RGBX format that common desktops use.

2) in OpenGL, vertex attributes provided in integer formats (such as glColor3ub) get clamped as well, and appear in shader code as normalized floating points.

But, your first example appears to mix up two different formats (unless the high values signify a powerful light source). You specify a vertex colour using unsigned bytes, and expect them to be normalized. As of now, shaders don't support integers. Integer values will be converted to floating point values (and possibly mutated in the process).

Texture coordinates can contain any floating point value you feed them, and won't be touched, as goes for any other vertex attribute or uniform constant.

EDIT: I wasn't aware of any SM1 issues, so I refer you to Namethatnobodyelsetook's post.


[Edited by - Todo on January 27, 2007 9:54:21 AM]

Share this post


Link to post
Share on other sites
Things passed as COLOR0 or COLOR1 are clamped between 0 and 1. Where (0,0,0) is black and (1,1,1) is white. Your D3DCOLOR values are magically divided by 255 before reaching the shader.

Texture coordinates that aren't sampled, but used as colors or other values in a calculation are clamped between 0 and 1 in shader model 1. In shader model 2, any values can be passed.

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!