The light scattering filter is another example of an effect that uses the post-processor that we are already familiar with from a previous chapter.
Make a copy of
Main.java
and name the classSunLight.java
. Remember to also refactor the first line of themain()
method to the following:SunLight app = new SunLight();
Specify the direction of the sunlight as a vector.
private Vector3f lightDir = new Vector3f(-0.39f, -0.32f, -0.74f);
Create one
FilterPostProcessor
per game, and aLightScatteringFilter
.private FilterPostProcessor fpp; private LightScatteringFilter sunLightFilter;
Use the
lightDir
vector to create aDirectionalLight
and add it to therootNode
.public void simpleInitApp() { DirectionalLight sun = new DirectionalLight(); sun.setDirection(lightDir); sun.setColor(ColorRGBA.White.clone().multLocal(2)); rootNode.addLight(sun);
Initialize the
FilterPostProcessor
and add it to theviewPort
.fpp = new FilterPostProcessor(assetManager...