Gamma correction and IBL

I have a scene and using only a HDR Skymap together with a LightProbe and EnvironmentCamera, so I am basically using only image based lightning. I have objects using the PBR shader material and other ones using the “normal” Lightning version.

If I have turned off gamma correction everything works fine and looks ok (every object is illuminated). But if I turn on gamma correction the objects using the Lightning shader go completely black - the PBR Objects are still displayed normal. If I add any additional Light (like an ambient or directional light) its working again for all the objects.

My initial thought was that the Lightning shader does not use the IBL from the Lightprobe - but then the objects would be always dark and not only when I turn gamma correction on! Right?

Ideas?

99.99% sure that regular lighting shader only works with regular lights.

I think the fact that it worked with IBL is a fluke and interesting in that it might point to some other strange bug.

I will defer to others, though. But I can’t figure out how lighting-based objects would even render without at least one directional light in the scene.

What Paul says.
regular lighting needs at least one of the original lights (ambient, point, directional or spot)
PBR works with lightProbe for IBL or directional , point and spot for direct lighting. Ambient has no effect
Note that PBR is only correct with gamma correction on, else you’ll have a very much darker render.

That’s weird it works without gama correction with regular lighting and no light… because that’s pretty much what we had in 3.0.

You are right - and all of what you both are saying makes totally sens. But I am using the latest master version and you can see the result without Gamma-Correction in my previous video:

The character uses PBR materials, the rest of the scene is normal Lightning material, no additional lights attached…
If I turn on gamma correction, the character might look better, but the rest of the scene disappears :wink:

And btw - I am not totally sure that ambient really has no effect on PBR, last time I tried it it seemed to me that the character model is also getting brighter, but maybe it was just an “illusion” because the environment got lit up…

If you want to use the regular lighting shader then you need regular lights.

1 Like

I know, and tbh - I don’t even really care about this issue, because I already had my solution before writing this post: I will convert every asset to PBR, which has been the plan anyway.

Just thought its strange that its actually working, but only as long as you have turned off the gamma correction and I thought this behaviour might help to find some more general problem. But maybe not :wink:

Only with a simple test case.

It could be a half-dozen different things causing the problem… 5 of them are probably user/setup specific.

Here you go:

public class TestLightNodeWithoutLights extends SimpleApplication {
private LightProbe _lightProbe;
private EnvironmentCamera _environmentCamera ;
public static final JobProgressAdapter<LightProbe> EMPTY_JOB_ADAPTER = new JobProgressAdapter<LightProbe>() {
    @Override
    public void done(final LightProbe result) {
    }
};

public static void main(String[] args) {
    TestLightNodeWithoutLights app = new TestLightNodeWithoutLights();
    app.start();
}
    
@Override
public void simpleInitApp() {       
    Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Path.hdr", SkyFactory.EnvMapType.EquirectMap);
    rootNode.attachChild(sky);
    Spatial bumpy = (Spatial) assetManager.loadModel("Models/MonkeyHead/MonkeyHead.mesh.xml");
    rootNode.attachChild(bumpy);

    _environmentCamera = new EnvironmentCamera(128, new Vector3f(0, 10, 3)) {
        @Override
        protected void initialize(Application app) {
            super.initialize(app);
            _lightProbe = LightProbeFactory.makeProbe(_environmentCamera, rootNode, EMPTY_JOB_ADAPTER);
            ((BoundingSphere) _lightProbe.getBounds()).setRadius(200);
            _lightProbe.setPosition(_environmentCamera.getPosition());
            rootNode.addLight(_lightProbe);
        }
    };
    stateManager.attach(_environmentCamera);
    _environmentCamera.setEnabled(true);
}

}

Without gamma correction:

With gamme correction enabled:

When enabling this
renderManager.setPreferredLightMode(TechniqueDef.LightMode.SinglePass);

Its even more obvious without gamma correction:

But the version with gamma correction stays the same (black model).

uh ho… well looks like a bug… I wonder how it actually works :))
Will look into it…

Thanks! Let me know when I can support you.