float4x4 worldViewProj;
float4 vLight;
struct VS_OUTPUT
{
float4 Pos : POSITION;
float4 Diff : COLOR0;
float2 Tex1 : TEXCOORD0;
float2 Tex2 : TEXCOORD1;
};
VS_OUTPUT vs_main(float4 inPos : POSITION, float3 inNormal : NORMAL, float2 Tex1 : TEXCOORD0, float2 Tex2 : TEXCOORD1 )
{
VS_OUTPUT Out;
Out.Pos = mul(inPos, worldViewProj);
Out.Diff = float4(0, 0, 0, 0); //the problem is with this line,
//Out.Diff = -dot( inNormal, vLight ); //this works, but the previous line doesn't
Out.Diff.r = inPos.y/2;
Out.Diff.g = inPos.y/4;
Out.Diff.b = inPos.y/8;
Out.Tex1 = Tex1;
Out.Tex2 = Tex2;
return Out;
}
The problem is with Out.Diff being initialized. If I try and set it to float4(0, 0, 0, 0), then the program crashes, but if I initially set it to -dot( inNormal, vLight ), then it works perfectly. Am I missing something here?
Any help would be appreciated, thank you.
HLSL Vertex Shader - Whats wrong with this?
Hello all, I've just recently got a vertex shader in my program working and today I tried manipulating some things to get myself familiar with the whole programable stuff. I ran into a strange problem though and I'm not sure why it occurs. The shader compiles, but the program crashes (I'm at school at the moment and don't have the debug output available) and I'm not sure why. I was hoping someone could take a look and let me know what is wrong with what I'm doing.
that doesn't make much sense.
Diff is a float4, and you're saying when you set it to another float4 it doesn't work, whereas when u set it to a scalar it works? Because the output of the dot product is a scalar.
Try:
Output.Diff = float4(inPos.y/2, inPos.y/4, inPos.y/8, 1);
I really don't think it should crash though, although you might get nothing on the screen if alpha blending is enabled since you are setting your alpha component to 0.
Diff is a float4, and you're saying when you set it to another float4 it doesn't work, whereas when u set it to a scalar it works? Because the output of the dot product is a scalar.
Try:
Output.Diff = float4(inPos.y/2, inPos.y/4, inPos.y/8, 1);
I really don't think it should crash though, although you might get nothing on the screen if alpha blending is enabled since you are setting your alpha component to 0.
Try using float4(0,0,0,1) instead of float4(0,0,0,0)
Are you sure your program is crashing? Perhaps you are just not seeing any rendering? With Diff = float4(0,0,0,0) you are setting the alpha to 0 which may cause it to not render anything depending on your render state settings.
Are you sure your program is crashing? Perhaps you are just not seeing any rendering? With Diff = float4(0,0,0,0) you are setting the alpha to 0 which may cause it to not render anything depending on your render state settings.
yes, the program actually crashes, null pointer error. I just got home now, so i'll load the debugger up and find out whats going on.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement