Sign in to follow this  
c-mos

cg shader question...

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this