 Home
 » Viewing Profile: Posts: t_guen03
t_guen03
Member Since 15 Feb 2012Offline Last Active Feb 27 2012 06:49 AM
Community Stats
 Group Members
 Active Posts 6
 Profile Views 1,210
 Submitted Links 0
 Member Title Member
 Age Age Unknown
 Birthday Birthday Unknown

Gender
Not Telling
Posts I've Made
In Topic: stencil shadows infinite extrusion
19 February 2012  03:18 PM
I finally got it. I didn't consider the hardware which will create the correct vertice if clipping is needed because
w_c <= z_c <= w_c is not fulfilled.
For people who are curious, here is my solution:
The hardware will find the last Vertice V_l in the direction given by a vector v = (x,y,z,0) starting from a Vertice V_o which is in the view frustrum and will take this Vertice to create the primitive. The Vertice V_l will have a positive w coordinate if v is pointing to the camera, since only then w_c <= z_c <= w_c can be fulfilled, thus allowing the found point to have a negative z coordinate after the projective division. The Vertice V_l is found by interpolating the values of x,y,z,w on the line from P*V_o and P*v, where P is the projection matrix. The x,y,z values can be interpolated linearly, while the w coordinate gets interpolated by interpolating its reciprocal linearly because it stores the depth. The last Point on the line fullfiling
w_c <= x_c <= w_c
w_c <= y_c <= w_c
w_c <= z_c <= w_c
is then taken.
As a result the extrusion in clipspace is not like in my sketches, but rather like in viewspace and thus correctly done.
I hope its correct what i just wrote : )
Thanks again Eric for your patience and helping me to solve my problem.
In Topic: stencil shadows infinite extrusion
18 February 2012  06:37 AM
thank your for your responses.
You're the first to address to my be my last name only
And I've been in these forums since 2006 ;)
Yey, im the first one : )
You seem to think that if one of the vertices has z > 1 then the triangle can't be rasterized on screen, it doesn't work like that.
Yes i realy thought this way, thanks for making this clear.
The shadow volume covers everything except what you've shaded.
But wouldn't this be false either. The shadow volume would enclose more objects then it should (Ok, in my sketch there is only one object, but if there would be more, then the shadow volume would enclose objects which were originally not shadowed)
The situation gets even worse, when you think about a shadow volume perpendicular to the z axis in eye space.
I wonder, why this behaviour is never mentioned in texts describing stencil shadows. Sketches i saw are just extruding the shadow volumes in eyespace where everything looks fine, but in clipspace i got this mess, where everything goes to the far plane.
In Topic: stencil shadows infinite extrusion
17 February 2012  01:15 PM
But there is one thing in common with my problem. They use vectors with w = 0 to extend vertices in one direction. The slides just say, OpenGL is required to draw homogenous coordinates with w = 0 correctly. But what shall this mean. Isn't it only the projection matrix i use, which determines if my vertices are drawed correctly. With the standard projection matrix, homogenous coordinates with w = 0 get mapped to a z coordinate of (f+n)/(fn), which is >1, thus the vertices shouldn't get drawed correctly. So i don't understand why the slides state they would.
Additionally, at the slides, directions ( vectors with w = 0 ) get extruded in the direction the direction points, but how you can see in my sketches, all directions get only extruded to the far plane and never in the direction to the near plane.
Obviously i am wrong, could someone tell me where ?
In Topic: stencil shadows infinite extrusion
17 February 2012  09:38 AM
First, you must realize the homogeneous vector (x, y, z, 0) corresponds to the point at infinity in the 3D direction (x, y, z).
I refreshed my knowledge in projetive geometry and i finally see, why every direction has the similar point in homogenous coordinates. For people who are curious, here is the math:
Point Po(x_0,y_0) is a fixed point of the line a.
Suppose, the vector v(a,b) is a direction vector of that line.
Then, for point P different from Po, we have:
P(x,y) is on line a
<=>
There is a real number r such that
x = x_0 + r * a and y = y_0 + r * b
<=>
P has homogeneous coordinates (x_0 + r * a, y_0 + r * b, 1) with r not 0.
<=>
P has homogeneous coordinates
(x_0 / r + a, y_0 / r + b, 1/r)
If r grows infinitely, P recedes indefinitely along that line and the homogeneous coordinates of P approach to (a,b,0).
But (a,b,0) are not the homogeneous coordinates of a point!
Now, we add to the line a one extra point. We call that point 'the point at infinity of the line a' or 'the ideal point of a'.
That special point receives, by definition, (a,b,0) and each real multiple of (a,b,0) as homogeneous coordinates.
Its copied from this great homepage http://home.scarlet.be/math/homog.htm
Points at infinity in front of the camera and points at infinity behind the camera both get a z coordinate of 1.0 in normalized device coordinates (NDC), after division by the w coordinate.
Then its realy like i thought, but why does the zFail method work if the points at infinity are all mapped to the far plane. I made two sketches to make clear my thoughts.
The first picture shows a scene with a light in front of the camera, a triangle between the camera and the light and a square which gets shadow by the triangle. I also drew the shadow volume how it should be.
The next picture shows the final result in clip space. Thus the point at infinity are mapped to the far plane, the shadow volume is flipped and the square is not shadowed anymore. Where is my error in reasoning?
I would realy appreciate if you or someone else could give me the last peaces of the puzzle.
Thanks!
In Topic: stencil shadows infinite extrusion
16 February 2012  04:45 AM
Is there something unclear about my question ?
I thought it would be no problem to explain this to me, since everyone is using stencil shadows.
So let me know if i something is unclear, i realy must know this : )
Thanks