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.
- 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 ...
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.