3 ms·
Surface Normals and Linear Transformations
- kaoD 4y agoWhat is ^T here? Transpose maybe? EDIT: Looks like it is transpose indeed https://en.m.wikipedia.org/wiki/Transpose https://en.m.wikipedia.org/wiki/Transpose
- alipang 4y agoThis is a really intuitive way of thinking about it. The best way I could work this out was to start with the special case of pure scaling in a single direction. For instance when scaling by "a" in the x direction M = (a 0; 0 1) It's pretty easy to see by graphing an example that in order for the normal to work out correctly you must scale it by the inverse scale factor (1 / a), so the correct choice of M is the inverse, M⁻¹, i.e. M = ((1 /a) 0; 0 1). This of course generalises to scaling in multiple directions (just multiply the matrices) - i.e. to diagonal matrices. For M = (a 0; 0 b) the correct choice for transforming the normals is M = ((1/a) 0; 0 (1/b)); By applying singular value decomposition you get M = UDV So choosing M' = M⁻¹ᵀ you'll get M' = (UDV)⁻¹ᵀ = UD⁻¹V Since orthogonal matrices U, V will actually correctly transform the normals (they're rotations or reflections) you can intuitively understand that M' will work for transforming the normals. Question is - where does the transpose part actually come from? It's a of a bit "magic" choice. This article makes it very clear that this "arises from" the transpose in the dot product, (t⋅n = tᵀn), as the dot product defines orthogonality!
- taneq 4y agoAh, I remember having to figure this out way back in the day when writing a toy ray-tracer. In a raytracer it's a little more obvious what's going on because typically you only write code to intersect with a unit sphere, unit cube etc. and then instead of transforming the primitive itself, you apply the inverse transformation to the ray. So you're already thinking about inverse transformations when you get to calculating the normal.
- mbrodersen 4y agoSimply transform the point x and the point (x + n), subtract the two, and normalise. You now have the correct normal. It’s that simple. I used this method all the time while working on commercial game engines. You can use the same idea to invert transforms by simply imagining the transform as a 3D coordinate system in space and calculating the inverse relative to the origin and axis vectors of that coordinate system. No need to first generate the inverse transform matrix.