Pre-calculating Dot3 Light vectors?

Started by
2 comments, last by d000hg 18 years, 11 months ago
Hi there. I've always assumed this is something I could do but when I refreshed myself on the details of Dot3 I think maybe I misunderstood... A Dot3/Normal map has normals stored in the rgb data of the texture. These normals are in the 'triangle space' defined by the orientation of the triangle. At each vertex/pixel, we need a lighting vector, which is the world directional light vector transformed into the 'triangle space'. That part is fine. However, shouldn't the camera position affect things? As you view the same point from different angles, shouldn't the normal-mapping be affected? Or is that only for specualr effects? If so, I can precalculate a transformed light vector for each vertex in my terrain and get full-scene normal-mapping on a GF2MX!
Advertisement
Hi there,

First, yes, diffuse lighting is independent of viewing position.

Specular lighting is, but your normal texture is still fine to use with it. To calculate specular you basically take into account these 3 factors:
- per-fragment normal vector
- light position
- viewer position

I'm not sure it's possible to calculate per-pixel specular on GF2MX however.

GL!
Maciej Sawitus
my blog | my games
Quote:Original post by d000hg
A Dot3/Normal map has normals stored in the rgb data of the texture. These normals are in the 'triangle space' defined by the orientation of the triangle.


The normals are NOT necessarily in 'triangle space' or tangent space. They can be in any space you want. For animated characters, tangent space is probably best since when triangle orientation changes due to animation, you'd get problems with other spaces. But for static terrain other spaces (like object space) might also be fine. The big advantage: You just have to transform the light vector once into object coordinates and not many times into the tangent coordinates of every triangle.

Quote:...and get full-scene normal-mapping on a GF2MX!

Per-pixel diffuse is no problem. It's even quite fast. From the times I had a GF2MX I remember that specular is possible with register combiners, but you are limited to specular exponents of 2, 4, 8 and 16 (since you compute something like r=specular dot product thing; r=r*r; r=r*r; ...). However, I'm absolutely not sure whether I remember correctly.

Lutz
I'm using D3D so I think that option isn't available. I'd be happy to get normal-mapping on my terrain detail textures for a GF2 though. Specular may have to be limited but I can live with that.

This topic is closed to new replies.

Advertisement