For larger scenes, you should try a DirectionalLightShadowFilter
object from the com.jme3.shadow
package.
You can use a copy of ShadowDirectional.java
for the following exercise:
Add a directional light source to the scene:
public void simpleInitApp() { DirectionalLight sunLight = new DirectionalLight(); sunLight.setDirection(new Vector3f(.3f, -0.5f, -0.5f)); rootNode.addLight(sunLight);
If you re-use code from the
ShadowDirectional.java
class, deactivate the previously createdDirectionalLightShadowRenderer
object, or at least comment out itsaddProcessor()
line:// viewPort.addProcessor(dlsr);
Create a
DirectionalLightShadowFilter
object in thesimpleInitApp()
method. Use thesetLight()
method to specify your scene's directional light source:DirectionalLightShadowFilter dlsf = new DirectionalLightShadowFilter(assetManager, 1024, 2); dlsf.setLight(sun); dlsf.setEnabled(true);
Create a
FilterPostProcessor
object (if your scene doesn't already have...