Right, finally twigged what was causing the messed up normals. I apologise for the repeated THUD noise you're hearing but I felt I needed to simultaneously kick myself and hit my head against the desk.
The follow-on investigation to the previous journal entry yielded unsurprisingly that the matrix transformations were a big part in it. Changing the rotations about gave some better and some worse results. Despite working through all the theory on paper and trying combinations in code I couldn't settle on any changes that fixed all cases. I panicked briefly thinking that my architecture was at fault and that I couldn't express the matrix transformations in the way that I'd need to.
I had assumed it was entirely the applications fault that the image was wrong. Then, by simple static code analysis I spotted this in my shader:
float3 p = lerp( pA, pB, v.blend_weight );// Transform the world-space position to final projection-space coordso.position = mul( float4( p, 1.0f ), mViewProj );// Transform the normal vectorfloat3 nA = mul( v.normal, (float3x3)v.blend_from );float3 nB = mul( v.normal, (float3x3)v.blend_to );o.normal = normalize( nA + nB );
hmm... so let me see:
float3 p = lerp( pA, pB, v.blend_weight );// Transform the world-space position to final projection-space coordso.position = mul( float4( p, 1.0f ), mViewProj );// Transform the normal vectorfloat3 nA = mul( v.normal, (float3x3)v.blend_from );float3 nB = mul( v.normal, (float3x3)v.blend_to );o.normal = normalize( lerp( nA, nB, v.blend_weight ) );
* slaps forehead *
By comparison, we now have:
Working
Broken
You may notice that a few of the joints are still showing artifacts. I'm pretty sure I know what that's about (that is app-side matrix manipulation) and I'll get on the case ASAP.
For now, I'm just happy to have gotten it mostly working [grin]
If you want, you can grab the relevant code as ChangeSet #14522.