Hi,
I’ve been working on a new and improved Shadow Volume SceneProcessor based on the JME2 one, with a few improvements.
- New: More/better Caching (caching some stuff per Mesh, and others per Geometry
- New: Support for inefficient shapes (i.e. ones with edges that share coordinates but do not share indexes)
- New: Works in JME3 (80% of the old code has been modified, rewritten, or is new)
- New: Trivial to use (just 2 lines of code to add the scene processor)
- New: Surface bias to make it look better
- New: No issues with being inside of the shadow (modified z-fail)
- Trivial to use (rootNode.setShadowMode(ShadowMode.CastAndReceive);)
- No aliasing
- Requires my StencilBuffer addition to RenderState
- Coming soon: optimized shadow volumes for spheres
-
Note: The two existing shadow methods (Basic and PSSM) are likely better for most game applications: high poly count, high numbers of lights, anything with moving lights, or large numbers of moving objects, and anything with partially transparent shadow casters, but worse for other applications: distant shadow casters, large static scenes, surface-self shadowing (at least until biasing is properly used in them- the demos don't seem to use it), and other specific cases.
In my case I want to do space scenes with relatively few objects, at relatively large distances, so shadow volumes work well and look good.
Screenshots:
Based on the PSSM Test:
http://i.imgur.com/TG5db.jpg
http://i.imgur.com/VH679.jpghttp://i.imgur.com/MtfVc.jpg
(Note, framerates are lower than they could be because I have moving objects in the scene)
Here is the code for the ShadowVolumeRenderer:
https://bitbucket.org/josephduchesne/shadowvolumes-for-jmonkeyengine3/src/175f1ebcb576/src/mygame/
main.java is the test file.
If you have any comments, questions, or concerns let me know :)
A note on the usage of z-fail: The patent specifically requires incrementing the stencil on back face depth fail, and decrementing on the front face. My code does the opposite: it decrement-wraps on back face fail, and increment-wraps on front face fail. Additionally this is done in one step using new two sided stencil buffer functionality in OpenGL 2.0. To my knowledge this implementation is non-infringing, however it's trivial to modify it to z-pass, although that reintroduces camera placement issues.