HLSL: map TEXCOORD in 3 vertices to pixel shadow

This topic is 3218 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I am new guy to HLSL. I want to use HLSL to map a texture to a triangle. this is the PixelShader struct C3E3f_Output { float4 color : COLOR; }; C3E3f_Output C3E3f_texture(float2 texCoord : TEXCOORD0, uniform sampler2D decal) { C3E3f_Output OUT; OUT.color = tex2D(decal, texCoord); return OUT; } you see the texCoord is stored in TEXCOORD0. the confuse thing for me is that a triangle only have 3 vertices which means we only have 3 TEXCOORDs. but in the PixelShader how we get the right TEXCOORD? you know in a triangle there are many pixels which have different TEXCOORD.

Share on other sites

struct C3E2v_Output {
float4 position : POSITION;
float4 color : COLOR;
float2 texCoord : TEXCOORD0;
};

C3E2v_Output C3E2v_varying(float2 position : POSITION,
float4 color : COLOR,
float2 texCoord : TEXCOORD0)
{
C3E2v_Output OUT;

OUT.position = float4(position, 0, 1);
OUT.color = color;
OUT.texCoord = texCoord;

return OUT;
}

Share on other sites
another same thing is that:
I see a pixel shader using Normal for parameter.

also a triangle with three vertices only have 3 Normal, how can we get the correct Normal for those many pixels in the Pixershader?

Thank you for your help very much

Share on other sites
The GPU interpolates the values from the vertices to get the single value for each pixel

Share on other sites
thank you very much

1. 1
Rutin
27
2. 2
3. 3
4. 4
5. 5

• 11
• 11
• 10
• 13
• 20
• Forum Statistics

• Total Topics
632948
• Total Posts
3009399
• Who's Online (See full list)

There are no registered users currently online

×