struct vertex_in
{
float3 position : POSITION;
float3 normal : NORMAL;
float3 tangent : TANGENT;
float4 weights : BLENDWEIGHT;
int4 indices : BLENDINDICES;
float2 uv : TEXCOORD0;
};
struct vertex_out
{
float4 position : POSITION;
float2 texCoord : TEXCOORD0;
float3 normal : TEXCOORD1;
};
// the main function
vertex_out main( vertex_in IN,
uniform float4x4 bones[5],
uniform float4x4 modelView : state.matrix.modelview[0],
uniform float4x4 projection : state.matrix.projection
)
{
vertex_out OUT;
// skin the vertex position and normal
float4 position = float4(IN.position, 1);
float4 normal = float4(IN.normal, 0);
// the skinned attributes
float3 skinnedPos = (float3)0;
float3 skinnedNormal = (float3)0;
// perform the skinning
for(unsigned int i=0; i<4; ++i)
{
skinnedPos += (mul( position, bones[IN.indices] ) * IN.weights).xyz;
skinnedNormal += (mul( normal, bones[IN.indices] ) * IN.weights).xyz;
}
skinnedPos = mul( modelView, float4(skinnedPos,1) ).xyz;
OUT.position = mul( projection, float4(skinnedPos,1) );
OUT.normal = mul( modelView, float4(skinnedNormal, 1) ).xyz;
OUT.texCoord = IN.uv;
return OUT;
}
Cg Shader problem
Hi,
I'm compiling my Cg Shader for the profile arbvp1, however for some reason it won't let me use BLENDWEIGHT. I'll show you the source code below:
This is the error I'm getting when I run it through the compiler:
warning C7019: "weights" is too large for semantic "BLENDWEIGHT", which is size 1
And this is the command line I'm using:
cgc test.cg -profile arbvp1 -nocode
Does anyone know why it isn't working? I'm new to shaders, so go easy on me.
try float weights : BLENDWEIGHT; instead of float4, since BLENDWEIGHT is size 1.
im just guessing, i dont know cg
im just guessing, i dont know cg
I'm sending 4 float values in BLENDWEIGHT, so I need it to be float4. In the Cg documentation, they have Cg samples (under Improved skinning examples) that define BLENDWEIGHT as a float4.
Why don't you use a texcoord for your weights? Use TEXCOORD1
And what about this? I think GPUs prefer working with float
int4 indices : BLENDINDICES;
And what about this? I think GPUs prefer working with float
int4 indices : BLENDINDICES;
Quote:Original post by V-man
Why don't you use a texcoord for your weights? Use TEXCOORD1
And what about this? I think GPUs prefer working with float
int4 indices : BLENDINDICES;
This might be a good work around for now, but I still need to figure out why my shader isn't working with BLENDWEIGHT.
Also, the BLENDINDICES binding used to be a float4, however I switched it to int4 to see if it would work. They're indices, so it would make sense for them to be integers, not floats. If it doesn't work I was going to switch it back to float4
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement