Skip to content

PBR and environment lighting

Physically based rendering (PBR) describes a surface using properties such as base color, metallic and roughness. Metallic surfaces reflect their surroundings strongly; roughness controls how sharp or broad those reflections appear. Textures from glTF provide these properties per pixel.

A PBR scene needs both suitable materials and lighting. Direct lights illuminate surfaces, while a light probe supplies image-based lighting from the surrounding environment. If that environment is empty or dark, a metal object can appear black even when its material is configured correctly.

Bake an environment

The GPU-accelerated EnvironmentProbeControl can bake the parts of a scene you tag. Attach the sky first, tag it, and attach the control to the scene:

Spatial sky = SkyFactory.createSky(assetManager,
        "Textures/Sky/Path.hdr", SkyFactory.EnvMapType.EquirectMap);
rootNode.attachChild(sky);

EnvironmentProbeControl probe = new EnvironmentProbeControl(assetManager, 256);
rootNode.addControl(probe);
probe.tag(sky);

Replace the example path with your own environment texture. The control bakes automatically, using only the tagged geometry to build its environment map. When you tag a node, its existing children are visited; remember to tag any geometry you add later as well.

If the environment changes, call probe.rebake() to update the probe. For scenes with multiple probes, EnvironmentProbeControl.tagGlobal(spatial) tags geometry for all of them. Placement and influence matter for local environments, and baking has a cost, so measure before rebaking frequently.

See jme3test.light.pbr.TestPBRSimple in the engine examples for a complete runnable scene and imports. The API reference describes the available probe options. Support and performance depend on the renderer and device.

Try a small scene

Download PbrScene.java and add it to a desktop project with jMonkeyEngine 3.10. It builds a simple environment and five metallic spheres with increasing roughness, then bakes a probe. No downloaded assets are required. Compare the sharp and blurred reflections as you move the camera.

For a production scene, replace the demonstration environment with an HDR sky and import a glTF model as described in exporting and importing glTF models. Tag only the environment you intend to bake.

Tone mapping

PBR lighting and HDR environments can produce highlights brighter than a display can show. A tone mapper maps those values into the visible range, helping preserve highlight detail and giving the scene a balanced appearance.

Adjust lighting and tone mapping together. See Tone mapping for an example using the Khronos neutral filter.

Troubleshooting

Symptom Check
Metal appears black Is there a light probe? Is the tagged environment bright enough and within the probe's influence?
Reflections look wrong or stale Check the probe position, the tagged geometry and whether rebake() was requested after changes.
The model differs from Blender Check the exported glTF materials, supported extensions, lighting, tone mapping and color management in both applications.
Reflections are too sharp Increase roughness in the source material or the PBR material parameters.
Baking is costly Use a smaller cube-map resolution, bake less often and profile on target hardware.

A probe approximates lighting in an area; it is not a full simulation of multiple light bounces. Add direct lights and shadows where the scene needs them.