PBR + RenderToTexture + EnvironmentCamera

PBR needs a LightProbe, which needs an EnvironmentCamera which is an AppState, right? I need some model rendered to texture using PBR, so I only want to have the preview viewport rendered in the EnvironmentCamera.

Any hint on how this scenario is supposed to work?

well… the preview is the render of a scene right?
Think of the probe as a light. A classic scene even in a preview would have some lights, right? Here you’ll have a light probe.
So set up your scene with a nice HDR skybox, then place the env camera in the center and generate a probe. then add your model into it.
also, you can save the probe in a j3o. And all texture data needed by the probe will be also saved. So basically you can then just load the probe without having to use the Env cam every time.

Thanks! I was aware of this - I just wasn’t aware that the scene(rootnode) for the 6 viewports is provided by the LightProbeFactory.makeProbe… So it will work.

Nevertheless, is there a way to manually use the EnvironmentCamera without attaching it as an appstate? The reason behind this, is that the offscreen rendering is only part of one dialog in the UI and I would like to avoid to have a dependecy to the application object to set it up…

Well, no it’s an appstate.
But don’t you have a probe in your main scene?
Because you could reuse it, can’t you?

I just had a similar idea: I don’t reuse the lightprobe (because I might have different sky in the main scene), but I reuse the EnvironmentCamera. And its working like a charm! Thanks a lot!!!

1 Like

My example in:


public void updateLightProbe() {
        EXECUTOR_MANAGER.addEditorThreadTask(() -> {

            final Node stateNode = getStateNode();

            frame = 0;

    public void update(float tpf) {

        if (frame == 2) {

            final Node customSkyNode = getCustomSkyNode();

            final Array<Spatial> customSky = getCustomSky();
            customSky.forEach(spatial -> customSkyNode.attachChild(spatial.clone(false)));

1 Like