NicholasFrancis
01-01-2002, 03:12 AM
hi guys.
I've successfully gotten a mock-up stencil shadowing to work, and now I need to find a good algo for generating the shadow silhouettes. I wanted to discuss this with you before implementing it.
Anyways, my algo looks like this:
[quote]<pre>
foreach light {
foreach nearby object {
if (we have silhouette info from last frame) {
Foreach edge in silhouette {
if it is not an edge anymore, use a flood-fill principle to find the new edge.
}
} else {
Do a brute-force search for the edges
}
}
}
This involves the following steps:
make all silhouette edges potential silhoutte candidates
Each poly adjacent to the edge is either 'inside' or 'outside'
foreach candidate {
get face normal to light for faces on each side.
if (inside poly faces away from light) {
if (outside poly faces from light) {
mark edge as silhouette.
mark all other edges of both polys as candidates.
} else {
mark all other edges of inside poly as candidates.
}
}
if (inside poly faces light) {
if (outside poly faces away from light) {
candidate is an edge.
} else {
all other edges of outside poly are candidates.
}
}
}
[/CODE]
the principle is that I maintain the silhouette from last frame and the check if it is still valid. Where it isn't, I do a flood-fill style updating on the faces around to find the new silhouette.
Do you think this a good method, or is there something that's better?
Cheer,
Nicholas
I've successfully gotten a mock-up stencil shadowing to work, and now I need to find a good algo for generating the shadow silhouettes. I wanted to discuss this with you before implementing it.
Anyways, my algo looks like this:
[quote]<pre>
foreach light {
foreach nearby object {
if (we have silhouette info from last frame) {
Foreach edge in silhouette {
if it is not an edge anymore, use a flood-fill principle to find the new edge.
}
} else {
Do a brute-force search for the edges
}
}
}
This involves the following steps:
make all silhouette edges potential silhoutte candidates
Each poly adjacent to the edge is either 'inside' or 'outside'
foreach candidate {
get face normal to light for faces on each side.
if (inside poly faces away from light) {
if (outside poly faces from light) {
mark edge as silhouette.
mark all other edges of both polys as candidates.
} else {
mark all other edges of inside poly as candidates.
}
}
if (inside poly faces light) {
if (outside poly faces away from light) {
candidate is an edge.
} else {
all other edges of outside poly are candidates.
}
}
}
[/CODE]
the principle is that I maintain the silhouette from last frame and the check if it is still valid. Where it isn't, I do a flood-fill style updating on the faces around to find the new silhouette.
Do you think this a good method, or is there something that's better?
Cheer,
Nicholas