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.