Hardware skinning - incorrect normals/invisible faces/model

Problems building or running the engine, queries about how to use features etc.
Post Reply
User avatar
Mind Calamity
Ogre Magi
Posts: 1255
Joined: Sat Dec 25, 2010 2:55 pm
Location: Macedonia
x 81

Hardware skinning - incorrect normals/invisible faces/model

Post by Mind Calamity »

I'm having a problem integrating hardware skinning into my (somewhat modified) cascaded shadow map shader:

My vertex shader is as follows:

Code: Select all

void main_vp
(
	float4 iPosition : POSITION,
	float3 iNormal : NORMAL,
	float4 iTexCoord0 : TEXCOORD0,
	float4 iColor : COLOR0,
 	float4 BlendIdx	:	BLENDINDICES,
	float4 BlendWgt	:	BLENDWEIGHT,
	
	out float4 oPosition : POSITION,
	out float4 oTexCoord0 : TEXCOORD0,
	out float3 oNormal : TEXCOORD1,
	out float4 oShadowLightspacePos : TEXCOORD2,

	uniform float4x4 viewProjMatrix,
	uniform float3x4 worldMatrix3x4Array[80],
	uniform float4x4 worldViewProj,
	uniform float4x4 worldMat,
	uniform float4x4 texMatrix0
)
{
	float4 blendPos = float4(0,0,0,0);
	int i;
	
	for (i = 0; i < 3; ++i)
	{
		blendPos += float4(mul(worldMatrix3x4Array[BlendIdx[i]], iPosition).xyz, 1.0) * BlendWgt[i];
	}

	oPosition = mul(viewProjMatrix, blendPos);
	oTexCoord0 = iTexCoord0;
	oNormal = normalize(mul(float3x3(worldMat), iNormal));

	float3 newnormal = float3(0,0,0);
	for (i = 0; i < 3; ++i)
	{
		newnormal += mul((float3x3)worldMatrix3x4Array[BlendIdx[i]], iNormal) * BlendWgt[i];
	}
	oNormal = newnormal;

	oShadowLightspacePos = mul(texMatrix0, blendPos);

	oTexCoord0.z = oPosition.z;
} 
Here are screenshots of images with and without artefacts: [Screenshot 1][Screenshot 2]

It seems to occur at random (most of the time the model is displayed correctly, sometimes with artefacts, and sometimes not at all - but the shadow is still projected), I haven't been able to track down the issue yet.

Edit: Here's a rare one with the model being invisible: http://i.imgur.com/rormops.jpg
BitBucket username changed to iboshkov (from MindCalamity)
Do you need help? What have you tried?
- xavier
---------------------
HkOgre - a Havok Integration for OGRE | Simple SSAO | My Blog | My YouTube | My DeviantArt
Post Reply