3D Pipes in Direct3D 10 - another one bites the du

Published December 15, 2007
Advertisement
I've mentioned it a couple of times recently, but I sat my 70-536 MCTS .NET exam on Tuesday afternoon. Scored 859 which is a pass (>700). Yay.

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 );
Why was I using a weighted blend to determine the position and a simple average for the normal...??

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 ) );
Let's give that a shot...



* 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.
Previous Entry Security is hard
Next Entry HAPPY NEW YEAR
0 likes 2 comments

Comments

Gaiiden
congrats on passing the exam dude
December 15, 2007 03:06 PM
Todo
What he said :-).
December 16, 2007 11:39 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Advertisement
Advertisement