Skip to content

Normals should be multiplied by the transposed inverse of the transform matrix. #2955

Closed
@HackerFoo

Description

@HackerFoo

I noticed that normals are not transformed correctly when scaled non-uniformly:

v_WorldNormal = mat3(Model) * Vertex_Normal;

https://www.scratchapixel.com/lessons/mathematics-physics-for-computer-graphics/geometry/transforming-normals

Example (a sphere stretched along one axis) with incorrect normals:
Screen Shot 2021-10-11 at 3 23 04 PM

Corrected normals:
Screen Shot 2021-10-11 at 3 26 59 PM

I used this as a quick fix, but computing the inverse in the shader isn't a great idea:
HackerFoo@a711633

The proper fix would pass the precomputed transposed inverse into the shader.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-MathFundamental domain-agnostic mathematical operationsC-BugAn unexpected or incorrect behavior

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions