# tguen_03

Members

6

100 Neutral

• Rank
Newbie
1. ## stencil shadows infinite extrusion

Thanks for your reply Eric. 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.

5. ## stencil shadows infinite extrusion

Thanks for your reply Goldberg, but these slides doesn't answer my question. Furthermore they dont use the zFail method with a inifite projection matrix. The slides describe another way, where cliping is done at the near plane and conventional zPass method is used. 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)/(f-n), 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 ?
6. ## stencil shadows infinite extrusion

Thanks for your reply! [quote name='Eric Lengyel' timestamp='1329472372' post='4913844'] First, you must realize the homogeneous vector (x, y, z, 0) corresponds to the point at infinity in the 3D direction (x, y, z). [/quote] 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: [quote] Point Po(x_0,y_0) is a fixed point of the line a. Suppose, the vector [b]v[/b](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. [/quote] Its copied from this great homepage [url="http://home.scarlet.be/math/homog.htm"]http://home.scarlet.be/math/homog.htm[/url] [quote name='Eric Lengyel' timestamp='1329472372' post='4913844'] 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. [/quote] 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. [sharedmedia=gallery:images:1775] 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? [sharedmedia=gallery:images:1774] I would realy appreciate if you or someone else could give me the last peaces of the puzzle. Thanks!