Time for action – let the sun shine in

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.

  1. Make a copy of Main.java and name the class SunLight.java. Remember to also refactor the first line of the main() method to the following:
    SunLight app = new SunLight();
  2. Specify the direction of the sunlight as a vector.
      private Vector3f lightDir = new Vector3f(-0.39f, -0.32f, -0.74f);
  3. Create one FilterPostProcessor per game, and a LightScatteringFilter.
      private FilterPostProcessor fpp;
      private LightScatteringFilter sunLightFilter;
  4. Use the lightDir vector to create a DirectionalLight and add it to the rootNode.
     public void simpleInitApp() { DirectionalLight sun = new ...

Get jMonkeyEngine 3.0 Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.