Lit and Unlit Polygon(N . L, 3D or 4D ?)

Started by
11 comments, last by timw 18 years, 7 months ago
Hi guys, Why, when we calculate to determine if a polygon lit or unlit, we must do dot product between the 4D plane vector of a polygon with the 4D light coordinate(as seen in http://www.gamasutra.com/features/20021011/lengyel_01.htm) ? Assuming we only use w = 1 in both light and polygon, weren't it just enough to do dot product between the polygon normal and light coordinate(or, vector pointing light with tail at origin) ? Thanks :)
Advertisement
I can't say I understand what you're asking completely, but all lighting dot products are 3-d. if your direction vectors have 0 as the 4th dimension as they should, then it should be ok, because the 4th component will contribute nothing to the dor product. If they have 1 in the 4th dimension it's not cool.

generally we use
z = 1 or something for points, positions
z = 0 for directions because when we transform directions by matrices, we don't want the translation, only the rotation. if this makes sense.

Tim
ok so N^L should give you the scale factor for diffuse irradiance of the point light. this fromula is a 3-d thing. and a 4d vector with a z component of 1 would give a dot product that is greater then the dot product we want by 1.

I think there is a misunderstanding in what the formula is actually doing here.
N is the normal vector, L is the vector pointing to the light from the point being shaded.
so if P is the position of the light(IN 3D) and X is the position(IN 3D) on the suface we are shading. then L = normalize(P - X) L is NOT the vector pointing to the light with tail at origin(that vector is simply the position of the light), it's the vector pointing to the light with tail at X if you want to think of it that way. also, it is NORMALIZED but it doesn't really need to be if you just want to determin the if the surface is facing the light. because this check only checks the sign of the result, not the magnitude, but you'll need a normalized L for the diffuse irradiance calculation anyway.

recal that X^Y= |X||Y|cos(angle b/w X & Y)
so if |X| and |Y| = 1 we have
X^Y = cos(angle b/w X & Y)

if the angle b/w x and y is between [0 and 90) we see that X^Y is a positive number, if the angle is > 90 we have X^Y is negative. if this angle is > 90 we know that the surface is not facing the light. Draw this on paper to convince yourself.
so

if(X^Y < 0)
NOT FACING LIGHT
else
FACING LIGHT

summing up N is the surface normal
L is the vector from the surface location X to the light position P, aka (P -X)
Thanks for correcting my misunderstanding.
To cut it short, I wonder why in that tutorial he did 4D dot product ? Not 3D dot product ? And why he used (-N.V1) as the fourth element ? Why not used 0 or 1 directly ?(I know that the fourth element is (-N.V1), so in essence, why he used plane equation to do dot product, not just using normal of the plane ?)
what exactly is -N.V1? and also, what vector has this as it's 4th component? the normal N? or the light direction vector (P - X)? you can think of what I this test as pluging the light position into the equation of the plane that is tangent to the surface at the point X.

the equation of the plane
N^(P - X) where X is a point on the plane and N is the normal. if we plug in a point P the result is positive if P is above the plane, 0 if P is on the plane and negative if P is below the plane. the notion of above and below depends on the direction of the normal of course. this is a vaild interpretation of the problem, just not the one I usually use. I'd like to take a look at that link you gave me but its giving me a sign in thing. anyway, if what I said makes sense then you understand the problem. and if I take a dot product of 2 3space vectors this result is the same as taking the dot product of 2 4space vectors with the same x, y, z components and the w component set to zero. I mean you can impliment this using 4 d vectors, the only possible reason I could think of is convience. it's not mathematically necessary to need that 4th component, but a lot of other things in graphics use it for various things, so it's probably an engin design issue, only support 4d vectors and just define the 3d operation. you know what? I just had an idea of why his technique works. we have in our eqauation a vector subtraction (X - P) if both X and P have a w component of 1, which they proabbly do, then the w component of the result will be zero and thus the w component will contribute nothing to the dot product. recal that the dot product of 2 n dimensional vectors X, Y is.

sum(X1*Y1 + ...+ Xn*Yn)

if it's 4d, and one of the X4 or Y4 is zero the equation reduces to
X1*Y1 + X2*Y2 + X3*Y3 which is exactly the equation for a 3d dot product.

tim
Well, thanks for the reply Timw. And I have further question(sorry !)... Suppose the light position and polygon have different w, why when doing dot product they use (Nx, Ny, Nz, -(N.V1) instead of (Nx, Ny, Nz, Nw) ?
Thanks.
(BTW, Any good place for NURBS tutorial ?)
I can't see the link, it requires log in I'm not gonna sign up. explain to me what is V1?? also, what is the 4th compoment of the light position vector? N.V1 I'm assuming it's N dot V1, but I don't know what V1 is.
Well, V1 is the coordinate of the first vertex in the polygon... N.V1 usually used to calculate D from plane equation(Ax + By + Cz + D = 0)... Yes, the "." is dot product...

The 4th component of light is simply w (w=1 for positional light, w=0 for directional light).

I quote the article :
Quote:
Armed with the edge list for a triangle mesh, we determine the silhou¹ette by first calculating the dot product between the light position and the plane of each triangle. For a triangle whose vertex indexes are i1, i2, and i3, the (unnormalized) outward-pointing normal direction N is given by

N = (Vi2 - Vi1) x (Vi3 - Vi1)

since the vertices are assumed to be wound counterclockwise. The 4D plane vector K corresponding to the triangle is then given by

K = { Nx, Ny, Nz, -N.Vi1 }

Let L represent the 4D homogeneous position of the light source. For point light sources, LW≠0, and for infinite directional light sources, LW=0. A triangle faces the light source if K·L>0; otherwise, the triangle faces away from the light source. The silhouette is equal to the set of edges shared by one triangle facing the light and one triangle facing away from the light.

Sorry, but anyone can anyone enlight me ?
I thought this was interesting, so here is what I think.

Using the fourth dimension allows for positional and purely directional lights to be used in the same context by representing it as a position in 4 space in which division by the w coordinate gives the light's position by projecting it into 3 space. Since if the w is 0, dividing the x,y,z coords by it puts the light source at infinity, so this kind of light's position can only be represented in 4d.

First you have the 4D vector for the triangle plane as it states
The dot product of this 4D vector with a 4D point gives the side of the plane the point is on, if it's positive, the light is on the positive side of the plane, meaning it is lit, otherwise it isn't.

This topic is closed to new replies.

Advertisement