0
\$\begingroup\$

I am using Ogre3D and I am using stencil shadows for my character. They work pretty well, but I have 2 problems: first, the shadow is applied to the entity it is casting the shadow, and secondly, the shadow goes through all the entities on the screen, and I would like to apply the shadow to only the first entity.

Also, the shadow gets rendered on the back of the model.

Images showing the problems:

first

second

\$\endgroup\$
1
  • 1
    \$\begingroup\$ This seems to be normal behaviour for stencil shadows. Normally the platforms would Also shadow their underside + parts of platforms under them. A hack would be to cap the extrusion to somewhere in the middle of the platform. \$\endgroup\$
    – Valmond
    Sep 16, 2013 at 9:34

1 Answer 1

1
\$\begingroup\$

When you render stencil shadows, you have to extrude the silhouette edges out a large distance from the light. If you only extrude them down to the first platform, though, they will only affect that platform. The shadow volume will also have to be capped for this to work, in case you're not already doing that.

By extruding the volume to a level between the top and bottom surfaces of the platform, you can also ensure that the shadow appears only on the top side of the platform.

Another possibility, if you only need to cast shadows onto flat surfaces (the platforms), would be to switch to projected shadows. That's where you render the shadow caster using a matrix that squashes its geometry onto the floor, and use blending to darken the floor in that area. You can use the stencil test to prevent double-blending. It's a good bit simpler than shadow volumes, if you can work within its restrictions.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .