PDA

View Full Version : tangent space for selfshadow and stuff



SirKnight
03-22-2002, 08:42 PM
I have in my program used a tangent space light vector for the z part of my attenuation and used it in the selfshadow term and i have implemented it without really understanding why it works the way it does which is actually unusual for me and i now have decided to ask why. http://www.opengl.org/discussion_boards/ubb/smile.gif Ok here goes (my lighting engine is based from Ron Frazier's paper btw), why would using a tangent space light vector (scaled for brightness in this case) work as the z part of the attenuation (after being squared and then added to the XY radial texture of course)? I just dont see how that can substitute for the z part.
Second question, When doing selfshadow it works nicely to use 8*(N.L) but i noticed in Ron's code he just does this (where tsL is the tangent space light): 8*expand(tsL.z). How does using the z part of the tangent light substitute for N.L? I have looked at all the presentations and everything that talks about tangent space and i just cant figure these two questions of mine out. I understand how to compute tangent space though. That part isnt bad.

Well, i hope you can understand what im asking here, its late and i can hardly keep my eyes open so if something makes no sence i wouldnt be suprised. http://www.opengl.org/discussion_boards/ubb/smile.gif

Thanks.

-SirKnight

dUckmAnn
03-23-2002, 02:11 AM
Question 1: In tangent space, the polygon lies in the plane z=0. If the light-vector is also transformed to tangent-space then the z-component of the pixel-lightposition vector is equal for all pixels. Imagine that the floor of your room represents your polygon in tangent-space, then it's clear that the z-component of the floor to the lightbulb-position is always the same for each and every point of your floor. Square thar distance and add it to the (X^2 + Y^2)-texture and you have your attenuation-function.
Question 2: for the self-shadowing term you take 8(N.L) where N is the unperturbed surface normal (= normal of the polygon in tangent-space) and this calculation is also done in tangent space. This normal in tangent-space = (0, 0, 1).
==> N.L = Nx*Lx + Ny*Ly + Nz*Lz
==> N.L = 0 *Lx + 0 *Ly + 1 *Lz = Lz

I hope this clears things a little

Carl

[This message has been edited by dUckmAnn (edited 03-23-2002).]

SirKnight
03-23-2002, 07:00 AM
Ah i see. Thanks, this has made it much clearer.

-SirKnight