# Determining shadow projection for non-intersecting points

## Recommended Posts

I have yet another shadow projection question. This one is tricky and I'm not sure I can solve it without some expert help :) take a look at this: shadow projection controls: click + mouse to drag camera W, A, S, D to move camera UP, DOWN to change light y SPACE to toggle between projection error SHIFT to toggle between light and camera position CONTROL to move light to mouse position now, as to the error. You can clearly see that the vector between the light and a vertex does not intersect the desired plane there is an error, a pink line represents the bad vertex. here is how I'm projecting vertices onto a plane:

r : point on a plane
n : plane normal
p : vertex position
l : light position

private function projectVertex(r:Point3D, n:Point3D, p:Point3D, l:Point3D):Point3D {

var a:Point3D = Point3D.difference(p, l);
var s:Point3D;

var d:Number;
var t:Number;

d = n.x * a.x + n.y * a.y + n.z * a.z;

if (d > 0) {

t = (n.x * (r.x - p.x) + n.y * (r.y - p.y) + n.z * (r.z - p.z)) / d;

if (t >= 0) {

s = new Point3D();

s.x = p.x + (t * a.x);
s.y = p.y + (t * a.y);
s.z = p.z + (t * a.z);

return s;
}
}

return null;
}

when a point cannot reach the plane it is returned as null and the pink line is drawn to that point. I don't have a stencil buffer. I don't have a z / depth buffer. I have crappy old flash player with no hardware at all :( I am stumped. Any ideas? Thanks.

##### Share on other sites
Hi,
You must maintain a technique like depth buffering otherwise you can't determine which is the nearest point.

Why don't you track the distances of intersection and points and take only the shortest nonnegative distances from the set if you don't have depth buffer ?

otherwise i can't see why a light projection cannot intersect a plane , a plane is infinite and a point can't be parallel to the plane ?

##### Share on other sites
I'm sorry I don't follow you.

I cannot use a depth buffer and there is no ray casting going on here. Its simply a plane projected onto another plane.

I think I might need to look into a shadow matrix, but everything I have found on shadow matrices uses openGL which I don't have.

"i can't see why a light projection cannot intersect a plane , a plane is infinite and a point can't be parallel to the plane ?"

its not a point, but a vector, the direction of this vector is pointing away from the plane so it will never intersect. I thought of maybe using the inverted vector to project back to the plane (vector from vertex to light rather than light to vertex) But haven't been very successful in doing so.

## Create an account or sign in to comment

You need to be a member in order to leave a comment

## Create an account

Sign up for a new account in our community. It's easy!

Register a new account

• ### Forum Statistics

• Total Topics
628300
• Total Posts
2981894

• 9
• 9
• 11
• 10
• 10