blender
01-02-2004, 04:45 AM
Hi, I'm trying to make a vertex shaders
that multiplies the vertex position with a proper bone matrix and performs a simple diffuse lighting.
Here's my code:
struct vpin
{
float4 position : POSITION;
float4 normal : NORMAL;
float4 color : COLOR0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct vpout
{
float4 position : POSITION;
float4 color : COLOR0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
vpout main(vpin IN, uniform float4x4 ModelViewProj,
uniform float3x4 Bones[64], uniform float3 Light, uniform float3 LRGB)
{
vpout OUT;
float3x4 m;
float3 pos;
float3 normal;
int index=(int)IN.position.w;
/* get proper position and normal vectors */
OUT.position.xyz = mul(Bones[index], IN.position);
OUT.position = mul(ModelViewProj, OUT.position);
normal = mul(Bones[index], IN.normal);
normal.x -= m[0][3];
normal.y -= m[1][3];
normal.z -= m[2][3];
/* define diffuse color by light */
OUT.color.a = IN.color.a;
OUT.color.rgb = clamp( dot(Light, normal), 0.0f, 1.0f)*LRGB;
/* pass texture coordinates */
OUT.texcoord0 = IN.texcoord0;
OUT.texcoord1 = IN.texcoord1;
return OUT;
}
When I compile it with NVidia's compiler with arbvp1 path it crashes. Damn it!
When I reduce the bone matrix constant array to 16 ir compiles fine.
Any ideas what's this about?
that multiplies the vertex position with a proper bone matrix and performs a simple diffuse lighting.
Here's my code:
struct vpin
{
float4 position : POSITION;
float4 normal : NORMAL;
float4 color : COLOR0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
struct vpout
{
float4 position : POSITION;
float4 color : COLOR0;
float2 texcoord0 : TEXCOORD0;
float2 texcoord1 : TEXCOORD1;
};
vpout main(vpin IN, uniform float4x4 ModelViewProj,
uniform float3x4 Bones[64], uniform float3 Light, uniform float3 LRGB)
{
vpout OUT;
float3x4 m;
float3 pos;
float3 normal;
int index=(int)IN.position.w;
/* get proper position and normal vectors */
OUT.position.xyz = mul(Bones[index], IN.position);
OUT.position = mul(ModelViewProj, OUT.position);
normal = mul(Bones[index], IN.normal);
normal.x -= m[0][3];
normal.y -= m[1][3];
normal.z -= m[2][3];
/* define diffuse color by light */
OUT.color.a = IN.color.a;
OUT.color.rgb = clamp( dot(Light, normal), 0.0f, 1.0f)*LRGB;
/* pass texture coordinates */
OUT.texcoord0 = IN.texcoord0;
OUT.texcoord1 = IN.texcoord1;
return OUT;
}
When I compile it with NVidia's compiler with arbvp1 path it crashes. Damn it!
When I reduce the bone matrix constant array to 16 ir compiles fine.
Any ideas what's this about?