PDA

View Full Version : There must be a trick???!!!



wis mak
07-09-2002, 02:23 AM
I'm doing per pixel bup mapping using pertubed normal map. I calculate tangent-space as follows:

For a planar polygon:
Calculate the coefficients of
A1x + B1s + C1t + D1 = 0 ---> I
A2y + B2s + C2t + D2 = 0 ---> II
A3z + B3s + C3t + D3 = 0 ---> III
(NOTE: I'm not solving simultaneous system)

I evaluate cross and dot product: (for eq. I)
| i j k |
| x1 - x0 s1 - s0 t1 - t0 |
| x2 - x0 s2 - s0 t2 - t0 |

and dot the result vector by
[(x - x0), (s - s0), (t - t0)]

The same for for eq. II:

| i j k |
| y1 - y0 s1 - s0 t1 - t0 |
| y2 - y0 s2 - s0 t2 - t0 |

and dot the result vector by
[(y - y0), (s - s0), (t - t0)]

The same for for eq. III:

| i j k |
| z1 - z0 s1 - s0 t1 - t0 |
| z2 - z0 s2 - s0 t2 - t0 |

and dot the result vector by
[(z - z0), (s - s0), (t - t0)]

After I have the all the cooeficinets, I drive the vectors [T B N] as follows:

T = [dx/ds dy/ds dz/ds]
= [-B1/A -B2/A -B3/A] since A does not change for all the equations.

N = T x [dx/dt dy/dt dz/dt]

B = N x T

Finally I normalize T, B, and N

My normal map is generated by Adobe Photoshop NVIDIA normalmap plugin.

The light vector is multiplied by Tangent-Space:

[L.x L.y L.z]*[T B N]

I Normalize the resultant vector by a cube-map.

What is wrong with my algorithm that it does not refelct correct results?

Your help will be apreciated.

wis mak
07-09-2002, 03:47 AM
Please help.

Mezz
07-09-2002, 04:39 AM
Perhaps compare your code with that at
www.geocities.com/sdtmezz (http://www.geocities.com/sdtmezz)

(Click calculation source).

Offhand, I see that you are computing a few dot product for no reason and you are assigning the tangent wrongly. It is B that does not change for all the calculations, and it is A that DOES change (because A is your difference in x/y/z).

Unless you've chosen to compute the space a different way.

Also, you may be victim of an inverted green channel in the normal map - I've heard that nVidia's normal map generator does this (but I've not experienced it first hand, so don't hold me to it).

-Mezz

wis mak
07-09-2002, 06:59 AM
Is normal map construction affects the results, somehow related to tangent-space?

wis mak
07-09-2002, 07:08 AM
I'm sorry. But I had to try a normal map generated by NVIDIA plugin in your demo, and it worked fine. So the problem lies under my tangent-space calculations.

wis mak
07-09-2002, 09:05 AM
The gray scale dot product still looks very dark and incorrect although I've changed my tangent-space calculations to that of your demos' source.
Thanks.

nobodii
07-09-2002, 11:24 AM
What do you mean by [Lx Ly Lx]x[T B N] .. maybe your doing it the wrong way ?