• entries
422
1540
• views
488663

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

84 views

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.

congrats on passing the exam dude

##### Link to comment
What he said :-).

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account