Sign in to follow this  
MrDoomMaster

Cg Shader problem

Recommended Posts

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:
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[i]] ) * IN.weights[i]).xyz;
		skinnedNormal += (mul( normal, bones[IN.indices[i]] ) * IN.weights[i]).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;
}

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.

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this