hello folks
here i am with my lil shader i wrote
its new for me to work with structs and i guess i ran there into a small problem...
"undeclared identfier 'cubeCrd'"
what did i do wrong?
Code:
float4x4 matWorldViewProj;
float4x4 matWorld;
float3 vecViewDir;
texture mtlSkin1;
samplerCUBE cubeMap = sampler_state
{
Texture=<mtlSkin1>;
};
struct VSHin
{
float4 pos :POSITION;
float3 normal :NORMAL;
};
struct VSHout
{
float4 pos :POSITION;
float3 cubeCrd :TEXCOORD0;
};
VSHout cubicVS( VSHin IN,
VSHout OUT)
{
OUT.pos = mul(IN.pos,matWorldViewProj);
float3 V = normalize(-vecViewDir);
float3 N = normalize(mul(IN.normal, matWorld));
OUT.cubeCrd = 2*N*(dot(N,V))-V;//here i could use reflect
return OUT;
}
float4 cubicPS(VSHout IN):COLOR
{
return texCUBE(cubeMap,cubeCrd);
}
technique cubemapping
{
pass p0
{
vertexShader = compile vs_1_1 cubicVS();
pixelShader = compile ps_1_1 cubicPS();
}
}
edit:without the structs it works perfect...no one knows where the problem is?
Code:
float4x4 matWorldViewProj;
float4x4 matWorld;
float3 vecViewDir;
texture mtlSkin1;
samplerCUBE cubeMap = sampler_state
{
Texture=<mtlSkin1>;
};
void cubicVS( in float4 pos :POSITION,
in float3 normal :NORMAL,
out float4 oPos :POSITION,
out float3 cubeCrd :TEXCOORD0)
{
oPos = mul(pos,matWorldViewProj);
float3 V = normalize(-vecViewDir);
float3 N = normalize(mul(normal, matWorld));
cubeCrd = 2*N*(dot(N,V))-V;//here i could use reflect
}
float4 cubicPS(in float3 cubeCrd:TEXCOORD0):COLOR
{
return texCUBE(cubeMap,cubeCrd);
}
technique cubemapping
{
pass p0
{
vertexShader = compile vs_1_1 cubicVS();
pixelShader = compile ps_1_1 cubicPS();
}
}