[workarround]Terrain paint / light probe issue

Hello,

my problem is terrain changing color to bright green when light probe is generated and ONLY when texture painting was done. (third video is issue)

in HALF of videos time is generating light probe

  1. No texture painting done, light probe WAS loaded(ok) (here is use alphamap green for one texture):
    2019 01 23 13 30 49 - YouTube

  2. Texture painting done, no light probe loaded (ok) (here is use alphamap black for no texture):
    2019 01 23 13 24 35 - YouTube

  3. Texture painting done, light probe WAS loaded (issue) (here is use alphamap black for no texture):
    2019 01 23 13 27 05 - YouTube

the only changes between videos was alphamap / loading probe / doing texture change.
Even when i use black alphamap and one time paint all map, then light probe issue appear too.
(any texture paint lead to problem)

to do texture change im using SDK files (with removed sdk related code, just to use in game):
filesss

as see in third video, light probe generate proper texture, after second generation texture also have green ground

Please help, thanks :slight_smile:

The default terrain material shouldn’t even be affected by light probes. There was such a bug some time ago though, so what jme version are you using? Also make sure you have gamma correction enabled.

1 Like

sorry, forgot to write.

im using 3.2.2 currently (newest one)

why gamma correction should be enabled? i dont see relation here. i dont have gamma correction filter.

also its how i do light probe. (i anyway run it in 10-th frame so enqueue not needed trully) - one for main player only - it was my purpose

public void initLightProbe(Vector3f vector) {
    environmentCamera.setPosition(vector);
    enqueue(() -> {
        enqueue(() -> {
            LightProbe lastLightProbe = lightProbe;
            lightProbe = LightProbeFactory.makeProbe(environmentCamera, rootNode, new JobProgressAdapter<LightProbe>() {
                @Override
                public void done(LightProbe result) {
                    Node tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager);
                    if(lastLightProbe != null){
                        rootNode.removeLight(lastLightProbe);
                    }
                    ((BoundingSphere) lightProbe.getBounds()).setRadius(1000);
                    rootNode.addLight(lightProbe);
                }
            });
            return "true";
        });
        return "true";
    });
}

here can see its definetly about lightProbe. when i set 20 meters distance, nothing other is affected.

but why this happen only if i just paint terrain? its really odd. like some trash memory in some objects/classes. Even if it would be Texture class or something about this, then terrain is not PBR so why affected by it.

ggggggg

and this is what i receive if i paint All map single time (single paintTexture method usage)
gggggggggggggggggg

The light probe auto generates an environment map and uses it for reflection, so when you generate your light probe you should only supply the things you want to reflect.

You should be able to supply it with a child node instead of the whole root node to stop it reflecting the ground.

1 Like

I should also note that if you don’t use gamma correction, things will probably appear “washed out” or overly white - a bit like a tv with brightness too high. The blacks will appear as though they are dark grey and vibrancy will be lost.

No idea why gamma correction helped in my case, but you can read more here: Ludum Dare 41 - #17 by grizeldi

this deprecated filter helped you?

bbbbddd

second dont help,

about filter i got:
Uncaught exception thrown in Thread[jME3 Main,5,main]
AssetNotFoundException: Common/MatDefs/Post/GammaCorrection.j3md

maybe i should switch to LWJGL 3? but i heard it have a lot issues?

im using LWJGL 2.9.3

The correct procedure is to set gamma correction in app settings and use tonemapfilter.

    app.settings.setGammaCorrection(true);
    filterManager.addToneMapFilter();

this dont help. colors are more “toned” but issue still exist… this is not solution

This is the solution. I was also just helping with your gamma issue.

what gamma issue? i had no gamma issue…

This one.

I’m also quite certain that Rémy wrote somewhere that gamma correction is a must if you use PBR.

I read so many documents on it over the course of a few days I can’t remember exactly where, unfortunately.

? this was to @grizeldi who suggested it might help, but it dont.

no its not, read the topic again, PBR work fine if i dont paint on terrain texture (video 1)

its not topic issue.

i made simple testcase, but there both painted and non-painted are affected by lightprobe.

it would be ok, like you say that gamma should correct.

BUT:
when i leave my original terrain not “painted”, just using standard alphamap green color, then light probe dont affect it.

its visible on video 1

why video 1 then is not affected by probe light? its very odd for me

Not the filter. As @jayfella said, I fixed my issue by checking the checkbox for gamma correction in the display settings popup. I also had some issue with PBR when I didn’t have gamma correction enabled in later projects, so might just want to leave gamma correction enabled in order to avoid future problems.

Watched the videos and what is going on seems quite strange. Almost if the probe renderer got a different looking material for the terrain. What material definition/shader is your terrain using and how are you painting the terrain from black to the dirt textured color?

1 Like
    mat_terrain = new Material(assetManager, "Common/MatDefs/Terrain/TerrainLighting.j3md");
    mat_terrain.setBoolean("useTriPlanarMapping", false);
    mat_terrain.setFloat("Shininess", 0.1f);
    mat_terrain.setColor("Specular", new ColorRGBA(0.1f, 0.1f, 0.1f, 1f));
    mat_terrain.setTexture("AlphaMap", assetManager.loadTexture("Textures/Terrain/splat/startAlphamap.png"));

so TerrainLighting.

if light probe affect non-pbr shaders too, then IDK why it don’t affect my terrain when i dont paint it.

while i made a quick demo and it affect it there. there is something really odd.

Anyway i dont understand why same looking terrain painted “more times” give much more light than once-time painted… it give me a headache.

It’s most likely a race condition (hence the random behaviour) since the light probe is threaded, its uncertain when it takes its “snapshot” of the scene to generate its env map.

You can alleviate this by either adding your terrain on the completed event of the lightprobe or just not giving the lightprobe the terrain to begin with.

2 Likes

not sure what is the issue, but certainly there is some.

Anyway i made workarround, you suggested before to add lightProbe to other node, but before i tried and moved all to objectNode thats why it was not working for me. When i move just lightprobe itself and not touch makeProbe method node, then its fine.

public void updateLightProbe(Vector3f vector) {
    environmentCamera.setPosition(vector);
    final LightProbe lastLightProbe = lightProbe;
    lightProbe = LightProbeFactory.makeProbe(environmentCamera, rootNode, new JobProgressAdapter<LightProbe>() {
        @Override
        public void done(LightProbe result) {
            Node tex = EnvMapUtils.getCubeMapCrossDebugViewWithMipMaps(result.getPrefilteredEnvMap(), assetManager);
            if(lastLightProbe != null){
                objectsNode.removeLight(lastLightProbe);
            }
            ((BoundingSphere) lightProbe.getBounds()).setRadius(100);
            objectsNode.addLight(lightProbe);
        }
    });
}

Anyway IMO issue still exist, because light source should not change its “bright/color” when texturing terrain and when light probe is in same node as terrain.

@nehon do you maybe know why Painting on terrain make light probe light change its light? (when painting all terrain with one texture give same result in texture like using just alphamap with one color - and both cases are different in probe light)

in short, each paint(even if no change in texture itself) change lightprobe intensity/color