# Pre-calculating Dot3 Light vectors?

This topic is 4950 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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!

##### Share on other sites
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!

##### Share on other sites
Quote:
 Original post by d000hgA 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

##### Share on other sites
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.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• ### Forum Statistics

• Total Topics
633303
• Total Posts
3011278
• ### Who's Online (See full list)

There are no registered users currently online

×