Sign in to follow this  
Zosimas

Cannot retrieve LightVector in Pixel Shader

Recommended Posts

Zosimas    122
Why when I use this in my HLSL shader, everything work fine:


struct vertexOutput {
float4 HPosition : POSITION;
float2 UV : TEXCOORD0;
float3 LightVec : TEXCOORD1;
float3 WorldNormal : TEXCOORD2;
float3 WorldTangent : TEXCOORD3;
float3 WorldBinormal : TEXCOORD4;
float3 WorldView : TEXCOORD5;
};

/*Pixel Shader*/
float4 depthMap_PS(vertexOutput IN) : COLOR
{
float3 Ln = normalize(IN.LightVec);
float c = length(Ln);
return float4(c,0,0,1);
}



but when I use this I get an "E_FAIL" error: ?


struct vertexOutput {
float4 HPosition : POSITION;
float2 UV : TEXCOORD0;
float3 LightVec : TEXCOORD1;
float3 WorldNormal : TEXCOORD2;
float3 WorldTangent : TEXCOORD3;
float3 WorldBinormal : TEXCOORD4;
float3 WorldView : TEXCOORD5;
};

/*Pixel Shader*/
float4 depthMap_PS(vertexOutput IN) : COLOR
{
float c = length(IN.lightVec);
return float4(c,0,0,1);
}



Why can't I get IN.LightVec in Pixel Shader?

Share this post


Link to post
Share on other sites
Buckeye    10747
Quote:
float c = length(IN.lightVec);

Did you try IN.LightVec? HLSL is case-sensitive. [wink]

EDIT: You'll get more information in you check the error message buffer when you compile the shader.

Share this post


Link to post
Share on other sites
Buckeye    10747
Compare very carefully:

IN.lightVec

and

IN.LightVec

There's a capital letter you're missing in the first line.

(cross-post) glad you got it.

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