[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

shadow of sphere on a curved surface



I am aware of a technique of creating the shadow of an object on a
plane by using the equation of the plane to modify the modelview
matrix in OpenGL.  Using this I got the shadow of a sphere on a plane.
Now I want to cast the shadow of one sphere on another sphere, i.e a
curved surface.  

A couple of years ago I had derived formulae for doing such a thing
using brute force approach.  I used to check each and every point in
the scenario as follows-

Consider p as point to be tested whether in shadow (umbra) or not.
The light source is extended and bigger than the sphere.  For the
point p, find the nearest point N on the axis of the conical shadow of
the sphere.  Next, find the distance between p and N.  Let's call it
D.  Now find the radius of cross section of the shadow cone at N.
Let's call the radius as r.  Now if r < D, the point is not in umbra.
If it is otherwise, it is in umbra.

The above approach worked perfectly since all the spheres were drawn
with latitude and longitude points, not polygons.

Now with OpenGL, I have thought of a number of options.  Consider the
curved surface is drawn as polygons.  For a particular polygon, find
the plane in which it lies.  Then project the sphere onto this plane
and then clip everything outside the polygon.  (I don't know how to do
this clipping.  Can anyone explain? )  This procedure seems to be
extremely expensive since the whole sphere will be projected on every
plane corresponding every polygon on the curved surface.

All these calculations have to be done in realtime.  What can be other
better ways of doing this?


-- 
Abhir Joshi
http://education.vsnl.com/abhir/