Jump to content
  • Advertisement
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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