Some other 3D projections
Posted: 2012-09-26T11:49:07-07:00
I just created some flavors of the environment mapping script. To see the differences between them clearly, I applied them to a special testing setup (pictures below):
All of the projection types come in a version which uses 1 respectively 4 averaged surface normals. Click on a picture to get the used fx script with comments.
Radial Mapping
This is the simplest reflective projection. It uses the surface normal directly to look up the color (instead of calculating a reflection ray). It should (and does) produce exactly the used emap, so normal calculation has been sucessfully proven to be correct. The Sobel algorithm used by Anthony could also be applied to the test pictures and should give the same result. So let's compare!
|
8.528s _____________| 9.162s
Environment Mapping with distant camera
When using a distant camera no height variable (OIz) is needed and the incoming vector can be set to (0,0,-1). This simplifies the calculation of the reflected ray significantly at the price of all horizontal faces beeing set to the emap's center color. Thus the illusion gets often damaged. The calculation of a reflection ray causes some kind of minifiying glass (also known as fisheye effect), due to the fact that the angle between incoming and outgoing ray is doubled. All pixels below the 45° latitude reflect the bottom half of the environment sphere (which just mirrors the top half).
|
9.846s _____________| 11.505s
Environment Mapping with perspective camera
This is the original script from the tutorial on the beginning. The rendering time is more than twice than with distant camera but this just reflects the added complexity of an adjustable camera height (above scripts have been reduced as much as possible, of course). Beside the improved realism we can increase the fisheye effect by moving the camera nearer to the reflecting surface .
|
23.969s ____________| 25.249s
Conclusions
- The heightfield is a half sphere that was generated using a canvas of 128x128 pixels and the following fx expression: sqrt(1-(2*i/w-1)^2-(2*j/h-1)^2) (as far as I can see, this is the most accurate method, though not the fastest, to do so).
- The environment map is specially designed to analyze surface discontinuities (taken from a 3D software).
All of the projection types come in a version which uses 1 respectively 4 averaged surface normals. Click on a picture to get the used fx script with comments.
Radial Mapping
This is the simplest reflective projection. It uses the surface normal directly to look up the color (instead of calculating a reflection ray). It should (and does) produce exactly the used emap, so normal calculation has been sucessfully proven to be correct. The Sobel algorithm used by Anthony could also be applied to the test pictures and should give the same result. So let's compare!
|
8.528s _____________| 9.162s
Environment Mapping with distant camera
When using a distant camera no height variable (OIz) is needed and the incoming vector can be set to (0,0,-1). This simplifies the calculation of the reflected ray significantly at the price of all horizontal faces beeing set to the emap's center color. Thus the illusion gets often damaged. The calculation of a reflection ray causes some kind of minifiying glass (also known as fisheye effect), due to the fact that the angle between incoming and outgoing ray is doubled. All pixels below the 45° latitude reflect the bottom half of the environment sphere (which just mirrors the top half).
|
9.846s _____________| 11.505s
Environment Mapping with perspective camera
This is the original script from the tutorial on the beginning. The rendering time is more than twice than with distant camera but this just reflects the added complexity of an adjustable camera height (above scripts have been reduced as much as possible, of course). Beside the improved realism we can increase the fisheye effect by moving the camera nearer to the reflecting surface .
|
23.969s ____________| 25.249s
Conclusions
- Rendering time between 1 normal and 4 averaged normals is is only slightly higher, due to the fact, that the addition of the 4 vectors can be highly simplified. As 4 vectors represent the orientation of the surface much better than one, this method should be favored (even if the visual impact with the test setup is minor).
- There's also a pixel shift to the left and top with 1 normal, caused by the asymmetric calculation.
- Overall accuracy and antialiasing are on a good level (except at the very outher zone) thanks to the high normal count per angle. Multipliying heightfield pixels with a good interpolation method will be a reasonable way to improve image quality (as already statet earlier).