float4x4 matWorld ;
float4x4 matViewProjection ;
float4x4 matWorldView ;
float4x4 matView ;
float4x4 worldInv;
struct vertexInput {
float3 position : POSITION;
float2 texCoordDiffuse : TEXCOORD0;
float3 normal : NORMAL;
float3 tangent : TANGENT;
float4 col : COLOR0;
};
struct vertexOutput {
float4 hPosition : POSITION;
float2 texCoordDiffuse : TEXCOORD0;
float3 normal : TEXCOORD1;
float3 tlight : TEXCOORD2;
};
vertexOutput VSIT(vertexInput IN)
{
vertexOutput OUT;
float3x3 worldToTangentSpace;
worldToTangentSpace[0] = mul(IN.tangent, matWorld);
worldToTangentSpace[1] = mul(cross(IN.tangent, IN.normal), matWorld);
worldToTangentSpace[2] = mul(IN.normal, matWorld);
OUT.normal = worldToTangentSpace[2];
OUT.tlight = mul(worldToTangentSpace,float3(1,0,0) );
OUT.hPosition = mul( float4( IN.position.xyz , 1.0) , matViewProjection);
OUT.texCoordDiffuse = IN.texCoordDiffuse;
return OUT;
}
float4 PSIT(vertexOutput OUT) : COLOR
{
float light = dot(normalize(OUT.normal),normalize(OUT.tlight) );
return float4(light*float3(1,1,1),1);
}
technique Test
{
pass Pass_0
{
VertexShader = compile vs_3_0 VSIT();
PixelShader = compile ps_3_0 PSIT();
}
}
Tangent Lighting Bad(Picture)
It seems my tangent lighting shader is not working right. It's giving me a funky tangent Light vector.
Should be like this:
But ends up like this:
Hmm... last post vanished....
here it is again:
here it is again:
Quote:
I have a question:
How do you get that low color depth look? Is it just the screenshot? I would really like to know if someone knows how to get that look in a high color depth application.
To your problem:
Your normal is in world space and your tLight vector in tangent space, maybe that´s the cause of the problem?
Quote:Original post by matches81
Hmm... last post vanished....
here it is again:Quote:
I have a question:
How do you get that low color depth look? Is it just the screenshot? I would really like to know if someone knows how to get that look in a high color depth application.
To your problem:
Your normal is in world space and your tLight vector in tangent space, maybe that´s the cause of the problem?
Yes! That did it, thank you! I was soo blind
The low color depth look was just from me saving it as a GIF. I am unsure on how to get that look with shaders.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement