Skip to content

Tone mapping

Lighting a PBR scene can produce colors brighter than a display can show. A tone mapper compresses that range into the visible output, preserving more useful detail in bright areas and giving lighting a more natural appearance.

This is particularly useful with bright lights and HDR environment maps. Tune lighting and tone mapping together, since both affect the final image.

jMonkeyEngine provides KHRToneMapFilter, which uses the Khronos neutral PBR tone-mapping curve. Add it to a post-processing chain in simpleInitApp():

import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.KHRToneMapFilter;

// Inside simpleInitApp():
FilterPostProcessor filters = new FilterPostProcessor(assetManager);
filters.addFilter(new KHRToneMapFilter());
viewPort.addProcessor(filters);

The filter is part of the jme3-effects module. If your viewport already has a FilterPostProcessor, add the filter to that processor.

Filter order matters: try the tone mapper after effects that should operate on the lit scene, and check the result with your own lighting and assets. To preserve bright detail, keep it from being clipped earlier in the rendering chain.

For a complete PBR scene setup, see PBR and environment lighting.