Jump to content
  • Advertisement
Sign in to follow this  
c-mos

cg shader question...

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

Hello, i've seen in some shader examples that ppl use this for instance float4 color : TEXCOORD1 float4 pos : TEXCOORD2; My question is, why do they use the TEXCOORD indexes ? For color you usually use COLOR, or COLOR0...COLORn kind regards, c-mos

Share this post


Link to post
Share on other sites
Advertisement
Because they're using a texture coordinate as a color, for shaders, it's just a convention. It's the same as passing with another indexer.

Share this post


Link to post
Share on other sites
Hardware registers were originally intended only for certain types of data. Since data in those registers is going to get interpolated across a primitive it allowed an easy way for doing algorithms on a per fragment level instead of a per vertex level. By sending the position through as a texture coordinate through the vertex shader more accurate positions for the fragment shader are generated because you get the point between points. The standard rasterizer is going to interpolate color and texture coordinates(0-15). More recent hardware may allow the use of generic registers for interpolating values across a primitive.

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!