Skinned mesh?


I’m trying to get some skinning going in shaderland.

Is this basically the right approach? I was mildly suprised to find you can’t have int attributes so the int(…) stuff looks ugly to me.

It’s also a tad slow - perhaps there’s a better way?

attribute vec4	_vertexIndices;
attribute vec3	_vertexWeights;
uniform mat4	_vertexMatrices[32];
uniform mat3	_cofactorMatrices[32];
void main(){
	int i0=int(_vertexIndices.x);
	int i1=int(_vertexIndices.y);
	int i2=int(_vertexIndices.z);
	int i3=int(_vertexIndices.w);

	float w0=_vertexWeights.x;
	float w1=_vertexWeights.y;
	float w2=_vertexWeights.z;
	float w3=1.0-(w0+w1+w2);

		_vertexMatrices[i3]*bmx_VertexPosition*w3 );

		_cofactorMatrices[i3]*bmx_VertexNormal*w3 ); 
		_cofactorMatrices[i3]**w3 );



This will get you into trouble:
uniform mat4 _vertexMatrices[32];
uniform mat3 _cofactorMatrices[32];
It’s using up 224 vectors and might not run in HW or compile on some implementations.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.