• Create Account

### #ActualHodgman

Posted 31 July 2012 - 11:40 PM

If you think about it you can see how the sign for the Z component is always positive

Think some more. The rasterized triangles are not in view-space; they have gone through a perspective transformation, which allows them to be facing slightly away from the camera and still be visible, and still pass the 'backfacing' test (i.e. they are not back-facing in post-projection space, but are back-facing in view-space, so they aren't culled, but do have negative view-space z).
To visualise, imagine standing in a room where the floor is slightly sloping downwards away from you, and the roof is slightly sloping upwards away from you -- both the floor and roof normals are pointing away from the camera, but because of perspective, they are both visible!

But if you need more than just my word, I can tell you that we use this type of compression at work, and I can promise with actual hands-on experience that it works.

Yes, it mostly works, but has artefacts on glancing angles (and gets worse the larger the FOV).
Tactfully raise this issue with your senior graphics programmer, or show the artefacts to a senior artist, and make yourself look good

Basically, we are helping because the original topic poster assumed the normals need to be used in world coordinates. You can define 2 components in world space and then derive the third in view space later, inside the shaders, at whatever point lighting needs to be done.

Would you care to explain to the OP how to compress his 3 world-space values down to just two values, how to transform these 2 values into view-space, and then how to reconstruct the missing 3rd view-space component correctly?
e.g. say I've got two test world-space normals, for the floor and roof of a room A=(0,0,1) B=(0,0,-1) and my view-matrix is identity, to simplify things.
Step 1) Drop the world-space z component: A=(0,0) B=(0,0)
Step 2) Transform to view-space: A=(0,0) B=(0,0)
Step 3) Reconstruct view-space z component: A=(0,0,1) B=(0,0,1) ... now the floor and the roof have the same normal.

Again, if you want to use this technique and correctly reconstruct the missing component, you need to store a sign-bit somewhere so that you can flip the reconstructed component in some cases. e.g. you could store x in 16-bits, y in 15 bits, and the sign of z in y's spare bit.

### #7Hodgman

Posted 31 July 2012 - 08:47 PM

If you think about it you can see how the sign for the Z component is always positive

Think some more. The rasterized triangles are not in view-space; they have gone through a perspective transformation, which allows them to be facing slightly away from the camera and still be visible, and still pass the 'backfacing' test (i.e. they are not back-facing in post-projection space, but are back-facing in view-space, so they aren't culled, but do have negative view-space z).
To visualise, imagine standing in a room where the floor is slightly sloping downwards away from you, and the roof is slightly sloping upwards away from you -- both the floor and roof normals are pointing away from the camera, but because of perspective, they are both visible!

But if you need more than just my word, I can tell you that we use this type of compression at work, and I can promise with actual hands-on experience that it works.

Yes, it mostly works, but has artefacts on glancing angles (and gets worse the larger the FOV).
Tactfully raise this issue with your senior graphics programmer, or show the artefacts to a senior artist, and make yourself look good

Basically, we are helping because the original topic poster assumed the normals need to be used in world coordinates. You can define 2 components in world space and then derive the third in view space later, inside the shaders, at whatever point lighting needs to be done.

Would you care to explain to the OP how to compress his 3 world-space values down to just two values, how to transform these 2 values into view-space, and then how to reconstruct the missing 3rd view-space component correctly?
e.g. say I've got two test world-space normals, for the floor and roof of a room A=(0,0,1) B=(0,0,-1) and my view is looking down the Z axis, so that the view-matrix is identity, to simplify things.
Step 1) Drop the world-space z component: A=(0,0) B=(0,0)
Step 2) Transform to view-space: A=(0,0) B=(0,0)
Step 3) Reconstruct view-space z component: A=(0,0,1) B=(0,0,1) oh... now the floor and the roof have the same normal.

Again, if you want to use this technique and correctly reconstruct the missing component, you need to store a sign-bit somewhere so that you can flip the reconstructed component in some cases. e.g. you could store x in 16-bits, y in 15 bits, and the sign of z in y's spare bit.

### #6Hodgman

Posted 31 July 2012 - 08:44 PM

If you think about it you can see how the sign for the Z component is always positive

Think some more. The rasterized triangles are not in view-space; they have gone through a perspective transformation, which allows them to be facing slightly away from the camera and still be visible, and still pass the 'backfacing' test (i.e. they are not back-facing in post-projection space, but are back-facing in view-space, so they aren't culled, but do have negative view-space z).
To visualise, imagine standing in a room where the floor is slightly sloping downwards away from you, and the roof is slightly sloping upwards away from you -- both the floor and roof normals are pointing away from the camera, but because of perspective, they are both visible!

But if you need more than just my word, I can tell you that we use this type of compression at work, and I can promise with actual hands-on experience that it works.

Yes, it mostly works, but has artefacts on glancing angles (and gets worse the larger the FOV). Raise this issue with your senior graphics programmer, or show the artefacts to a senior artist, and make yourself look good

Basically, we are helping because the original topic poster assumed the normals need to be used in world coordinates. You can define 2 components in world space and then derive the third in view space later, inside the shaders, at whatever point lighting needs to be done.

Would you care to explain to the OP how to compress his 3 world-space values down to just two values, how to transform these 2 values into view-space, and then how to reconstruct the missing 3rd view-space component correctly?
e.g. say I've got two test world-space normals, for the floor and roof of a room A=(0,0,1) B=(0,0,-1) and my view is looking down the Z axis, so that the view-matrix is identity, to simplify things.
Step 1) Drop the world-space z component: A=(0,0) B=(0,0)
Step 2) Transform to view-space: A=(0,0) B=(0,0)
Step 3) Reconstruct view-space z component: A=(0,0,1) B=(0,0,1) oh... now the floor and the roof have the same normal.

Again, if you want to use this technique and correctly reconstruct the missing component, you need to store a sign-bit somewhere so that you can flip the reconstructed component in some cases. e.g. you could store x in 16-bits, y in 15 bits, and the sign of z in y's spare bit.

### #5Hodgman

Posted 31 July 2012 - 08:44 PM

If you think about it you can see how the sign for the Z component is always positive

Think some more. The rasterized triangles are not in view-space; they have gone through a perspective transformation, which allows them to be facing slightly away from the camera and still be visible, and still pass the 'backfacing' test (i.e. they are not back-facing in post-projection space, but are back-facing in view-space, so they aren't culled, but do have negative view-space z).
To visualise, imagine standing in a room where the floor is slightly sloping downwards away from you, and the roof is slightly sloping upwards away from you -- both the floor and roof normals are pointing away from the camera, but because of perspective, they are both visible!

But if you need more than just my word, I can tell you that we use this type of compression at work, and I can promise with actual hands-on experience that it works.

Yes, it mostly works, but has artefacts on glancing angles (and gets worse the larger the FOV). Raise this issue with your senior graphics programmer, or show the artefacts to a senior artist, and make yourself look good

Basically, we are helping because the original topic poster assumed the normals need to be used in world coordinates. You can define 2 components in world space and then derive the third in view space later, inside the shaders, at whatever point lighting needs to be done.

Would you care to explain to the OP how to compress his 3 world-space values down to just two values, how to transform these 2 values into view-space, and then how to reconstruct the missing 3rd view-space component correctly?
e.g. say I've got two test world-space normals, for the floor and roof of a room A=(0,0,1) B=(0,0,-1) and my view is looking down the Z axis, so that the view-matrix is identity, to simplify things.
Step 1) Drop the world-space z component: A=(0,0) B=(0,0)
Step 2) Transform to view-space: A=(0,0) B=(0,0)
Step 3) Reconstruct view-space z component: A=(0,0,1) B=(0,0,1) oh... now the floor and the roof have the same normal.

Again, if you want to use this technique and correctly reconstruct the missing component, you need to store a sign-bit somewhere so that you can flip the reconstructed component in some cases. e.g. you could store x in 16-bits, y in 15 bits, and the sign of z in y's spare bit.
I'd appreciate it if you took the correction like an adult instead of down-voting it.

### #4Hodgman

Posted 31 July 2012 - 08:40 PM

If you think about it you can see how the sign for the Z component is always positive

Think some more. The rasterized triangles are not in view-space; they have gone through a perspective transformation, which allows them to be facing slightly away from the camera and still be visible, and still pass the 'backfacing' test (i.e. they are not back-facing in post-projection space, but are back-facing in view-space, so they aren't culled, but do have negative view-space z).
To visualise, imagine standing in a room where the floor is slightly sloping downwards away from you, and the roof is slightly sloping upwards away from you -- both the floor and roof normals are pointing away from the camera, but because of perspective, they are both visible!

But if you need more than just my word, I can tell you that we use this type of compression at work, and I can promise with actual hands-on experience that it works.

Yes, it mostly works, but has artefacts on glancing angles (and gets worse the larger the FOV). Raise this issue with your senior graphics programmer, or show the artefacts to a senior artist, and make yourself look good

Basically, we are helping because the original topic poster assumed the normals need to be used in world coordinates. You can define 2 components in world space and then derive the third in view space later, inside the shaders, at whatever point lighting needs to be done.

Would you care to explain to the OP how to compress his 3 world-space values down to just two values, how to transform these 2 values into view-space, and then how to reconstruct the missing 3rd view-space component correctly?
e.g. say I've got two test world-space normals, for the floor and roof of a room A=(0,0,1) B=(0,0,-1) and my view is looking down the Z axis, so that the view-matrix is identity, to simplify things.
Step 1) Drop the world-space z component: A=(0,0) B=(0,0)
Step 2) Transform to view-space: A=(0,0) B=(0,0)
Step 3) Reconstruct view-space z component: A=(0,0,1) B=(0,0,1) oh... now the floor and the roof have the same normal.

Again, if you want to use this technique and correctly reconstruct the missing component, you need to store a sign-bit somewhere so that you can flip the reconstructed component in some cases.
I'd appreciate it if you took the correction like an adult instead of down-voting it.

### #3Hodgman

Posted 31 July 2012 - 08:39 PM

If you think about it you can see how the sign for the Z component is always positive

Think some more. The rasterized triangles have gone through a perspective transformation, which allows them to be facing slightly away from the camera and still be visible, and still pass the 'backfacing' test (i.e. they are not back-facing in post-projection space, but are back-facing in view-space, so they aren't culled, but do have negative view-space z).
To visualise, imagine standing in a room where the floor is slightly sloping downwards away from you, and the roof is slightly sloping upwards away from you -- both the floor and roof normals are pointing away from the camera, but because of perspective, they are both visible!

But if you need more than just my word, I can tell you that we use this type of compression at work, and I can promise with actual hands-on experience that it works.

Yes, it mostly works, but has artefacts on glancing angles (and gets worse the larger the FOV). Raise this issue with your senior graphics programmer, or show the artefacts to a senior artist, and make yourself look good

Basically, we are helping because the original topic poster assumed the normals need to be used in world coordinates. You can define 2 components in world space and then derive the third in view space later, inside the shaders, at whatever point lighting needs to be done.

Would you care to explain to the OP how to compress his 3 world-space values down to just two values, how to transform these 2 values into view-space, and then how to reconstruct the missing 3rd view-space component correctly?
e.g. say I've got two test world-space normals, for the floor and roof of a room A=(0,0,1) B=(0,0,-1) and my view is looking down the Z axis, so that the view-matrix is identity, to simplify things.
Step 1) Drop the world-space z component: A=(0,0) B=(0,0)
Step 2) Transform to view-space: A=(0,0) B=(0,0)
Step 3) Reconstruct view-space z component: A=(0,0,1) B=(0,0,1) oh... now the floor and the roof have the same normal.

Again, if you want to use this technique and correctly reconstruct the missing component, you need to store a sign-bit somewhere so that you can flip the reconstructed component in some cases.
I'd appreciate it if you took the correction like an adult instead of down-voting it.

PARTNERS