# Coordinate System Setup

This is something I have always wondered about for years. In the Coordinate System Setup settings there are 3 options TS, LH, and RH. TS obviously is for Tangent Space, but what is LH, and RH? I don't see any reference to them in the manual.

My 3D software Lightwave uses. Y+ facing up X+ Z+ Far

TS uses Y+ facing down X+ Near Z+
LH uses Y+ facing up X+ Z+ Far
RH uses Y+ facing up X+ Near Z+

LH matches my coordinate system, but it generates a green normal map instead a purple normal map, so I always use TS and flip the Y and Z in my software. I've always wondered why I couldn't use LH since it's a match or use RH and flip the Z which is only flipping one coordinate vs the two that I have to flip using TS. The reason I don't use RH is I don't know what it means and have always assumed I needed to use Tangent Space maps.

• edited June 28

The LH coordinate system uses a -1 to represent Near. This will always result in a weaker Blue component when encoding a number ranged -1 to +1 into a value of 0 to +1.

Let's take a normal vector. ( 0, 0, -1 ) that points Near in LH coordinate system. Now we convert it ( X, Y, Z ) [-1 to +1 for each component] to ( R, G, B ) [0 to 1, for each component] by doing the following:

`RGB = ( XYZ + 1.0 ) * 0.5`

`( 0.5, 0.5, 0 ) = ( ( 0, 0, -1 ) + 1.0 ) * 0.5`

This creates a color pixel with no Blue and half intensity Red and Green. Because the Z component of a LH normal vector will almost always be in the range -1 to 0, the most Blue that encoded color can have is 0.5. This will cause the drab greens you are seeing in the LH normal map.

Similarly...

Take a normal vector. ( 0, 0, 1 ) that points Near in RH coordinate system and encode it to color in the same way:

`( 0.5, 0.5, 1 ) = ( ( 0, 0, 1 ) + 1 ) * 0.5`

This creates a color pixel with a dominant Blue and half intensity Red and Green. Because the Z component of a RH normal vector will almost always be in the range 0 to 1.0, the minimum Blue that encoded color can have is 0.5. It will always cause the purple ranged normal maps we are used to seeing.

Your shader is most likely converting the RGB color back to XYZ using the following formula:

`XYZ = ( RGB * 2 ) - 1`

LH
`( 0, 0, -1 ) = ( 0.5, 0.5, 0 ) * 2 - 1`

RH
`( 0, 0, 1 ) = ( 0.5, 0.5, 1 ) * 2 - 1`