Page 1 of 1

Can't get hardware skinning working

Posted: Thu Feb 17, 2005 12:44 am
by DigitalGhost
I tried making my own model in 3dsmax and putting it in the skeletalanimation project instead of the robot mesh. It works, but I'm only able to get Software skinning.

this line: if (p->hasVertexProgram())

is failing.

What does it mean to not have a vertex program? did I do something wrong in MAX?

Posted: Thu Feb 17, 2005 12:52 am
by sinbad
Hardware skinning has to be implemented in a vertex program. See http://www.ogre3d.org/docs/manual/manual_20.html#SEC76 , the section labelled "Skeletal Animation in Vertex Programs". We provide 2 example vertex programs for skinning.

Posted: Mon Feb 21, 2005 8:52 pm
by DigitalGhost
Hey, thanks for answering so fast.

I got the vertex thing loaded by putting it in the material file, but now I get this weird glitch. Basically, one of the legs of the model is messed up from the knee down. It looks like it's trying to draw a polygon from the top of the knee to some point at infinity. Do you have any idea what could be causing this?

Here is a screenshot of what I'm talking about:

Image

Problem fixed

Posted: Mon Feb 21, 2005 11:10 pm
by DigitalGhost
The problem was that the example vertex program only supported 24 bones. It's since been fixed.

Fix

Posted: Tue Feb 22, 2005 7:57 pm
by thorgrim
Hi,

The fix was for the 4 weight bones skinning, but the one that come with ogre is using a profile of vs_1_1 which limit the number of bones (24).

However, I have changed the shader to provide a bigger array using a profile of vs_2_0.

I have several models being full H-Anim compliant (78 bones) and hardware skinning work perfectly.

Here is the sknippet is case you need it:

Code: Select all


// Basic hardware skinning using four indexed weights per vertex
vertex_program vhd/HardwareSkinningFourWeightsFullHANIM cg
{
   source vhd_Basic.cg
   entry_point hardwareSkinningFourWeightsFullHANIM_vp
   profiles vs_2_0 arbvp1
   includes_skeletal_animation true
}


/*
  Four-weight-per-vertex hardware skinning, 2 lights
  The trouble with vertex programs is they're not general purpose, but
  fixed function hardware skinning is very poorly supported
*/
void hardwareSkinningFourWeightsFullHANIM_vp(
	float4 position : POSITION,
	float3 normal   : NORMAL,
	float2 uv       : TEXCOORD0,
	float4 blendIdx : BLENDINDICES,
	float4 blendWgt : BLENDWEIGHT,
	

	out float4 oPosition : POSITION,
	out float2 oUv       : TEXCOORD0,
	out float4 colour           : COLOR,
	// Support up to 78 bones of float3x4
	uniform float3x4   worldMatrix3x4Array[78],
	uniform float4x4 viewProjectionMatrix,
	uniform float3   lightPos[2],
	uniform float4   lightDiffuseColour[2],
	uniform float4   ambient)
{
	// transform by indexed matrix
	float4 blendPos = float4(0,0,0,0);
	int i;
	for (i = 0; i < 4; ++i)
	{
		blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
	}
	// view / projection
	oPosition = mul(viewProjectionMatrix, blendPos);
	// transform normal
	float3 norm = float3(0,0,0);
	for (i = 0; i < 4; ++i)
	{
		norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) * 
		blendWgt[i];
	}
	norm = normalize(norm);
	float3 lightDir0 = normalize(lightPos[0] - blendPos);
	float3 lightDir1 = normalize(lightPos[1] - blendPos);

	
	oUv = uv;
	colour = ambient + 
		(saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) + 
		(saturate(dot(lightDir1, norm)) * lightDiffuseColour[1]);
		
	oUv = uv;

	
}	





Re: Fix

Posted: Tue Feb 22, 2005 9:35 pm
by sinbad
thorgrim wrote: I have several models being full H-Anim compliant (78 bones) and hardware skinning work perfectly.
78? :shock: Yowsers. Glad it works!

Re: Fix

Posted: Sat May 14, 2005 5:16 am
by DigitalGhost
thorgrim wrote:Hi,

The fix was for the 4 weight bones skinning, but the one that come with ogre is using a profile of vs_1_1 which limit the number of bones (24).

However, I have changed the shader to provide a bigger array using a profile of vs_2_0.

I have several models being full H-Anim compliant (78 bones) and hardware skinning work perfectly.

Here is the sknippet is case you need it:
When I try your vertex skinning program, I get this error:
(0): error C3001: no program defined