[Chapter 10: Lighting Fundamentals] How to apply normal matrix in non-linearly case?

In Diffuse Reflection theory Part:
Did you mention the problem where scaling an object leads to normal not being correct ?

But if i want to handle this case using normalFrom4x4 in MathLibrary.swift file can it solve the problem ?
In the Geometry group, open Model.swift , and in render(encoder:uniforms:params:), change from below code:

uniforms.normalMatrix = uniforms.modelMatrix.upperLeft

To:

uniforms.normalMatrix = float3x3(normalFrom4x4: uniforms.modelMatrix)

If I misunderstood, Could you show me ? Thank!

This is an excellent article explaining how to do non-linear normal transformation.

https://paroj.github.io/gltut/Illumination/Tut09%20Normal%20Transformation.html

1 Like

Hi @caroline
Thank you.

How to check that normal surfaces are displaying correctly? I mean unit testing for 3D software in general.
(eg check the correctness of the transformation)
So can you share the tools you usually use for testing?

I test slowly, and I would love to know of better tools, but I havenโ€™t found any yet. I examine values using the GPU frame capture, and sometimes I get it wrong.

2 Likes