Sign in to follow this  
wanghuajie1982

HLSL: map TEXCOORD in 3 vertices to pixel shadow

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


Link to post
Share on other sites
the VerticeShader is:

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


Link to post
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 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