Harald JOHNSEN wrote:
> I have started to add some volumetric shadows in Flightgear.  It
> uses the standard stencil method to count shadow volume

Wow, nice work.  How are you handling silhouette optimization?

For those interested, the basic idea behind stencil shadows is that,
for every triangle in the input mesh, you render three infinitely long
triangles from the sides of the original to a "point" along the line
leading away from the light source.

So the number of vertices you need to push goes up by a factor of
four, and the number of pixels you need to fill goes up by a *lot* --
each small original triangle gets smeared all the way out to the edge
of the screen in the shadow edges.  I did a prototype stencil shadow
engine about two years ago, and saw something like a 15x slowdown when
stenciling was enabled.

The "standard" way to optimize this involves detecting which triangles
are on the "silhouette" of the object*, because those are the only
ones which define the shadow volume.  Since the silhouette is a 1D
feature, and the polygon mesh is 2D, the number of edges on the
silhouette goes roughly as the square root of the object's polygon
count; so this can be a really important optimization.

* Stated exactly: the silhouette is a subset of triangle pairs sharing
  an edge where one triangle is front-facing with respect to the light
  source, and the other is back-facing may be on the silhouette.

The problem is that detecting this silhouette (or at least an
approximation) in a situation where the object and light source can
have any orientation is a big mess, and I never found a good way to do
it.  Lots of really complicated code got me nowhere.

Basically, the whole experience convinced me that a shadow buffer
approach, which is *much* simpler conceptually (just draw the thing
into a texture from the point of view of the light source), was a
better idea.  Shadow buffers don't need the really complicated
silhouette optimization work to make them run fast.  It is true that
shadow buffers don't work for self-shadowing objects (shadow of the
vertical stabilizer on the wing, etc...), though.

Andy





_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to