Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Work around for #176 "Scene graph is not properly updated for renderi… #490

Merged

Conversation

neph1
Copy link
Contributor

@neph1 neph1 commented Apr 4, 2023

…ng" when adding LightProbe to a Geometry.

It seems the issue happens inside LightProbeFactory. I think this is an acceptable solution for now, since the consequences of the error are pretty bad.

If someone really wants a LightProbe for just one Geometry, they can replicate it by adding the Geometry to a Node and add the LightProbe to that.

…d for rendering" when adding LightProbe to a Geometry.
@tonihele
Copy link
Contributor

tonihele commented Apr 4, 2023 via email

@neph1
Copy link
Contributor Author

neph1 commented Apr 4, 2023

My first test was to comment out:

node.addLight(lightProbe);
node.updateModelBound();

And it still happened

Edit:
The action itself is enqueued, but iiirc LightProbeFactory is doing things async

@neph1
Copy link
Contributor Author

neph1 commented Apr 4, 2023

This is probably the culprit:
EnvironmentCamera:

@Override
    public void render(final RenderManager renderManager) {
        if (isBusy()) {
            final SnapshotJob job = jobs.get(0);

            for (int i = 0; i < 6; i++) {
                viewports[i].clearScenes();
                viewports[i].attachScene(job.scene);
                renderManager.renderViewPort(viewports[i], 0.16f);
                buffers[i] = BufferUtils.createByteBuffer(
                        size * size * imageFormat.getBitsPerPixel() / 8);
                renderManager.getRenderer().readFrameBufferWithFormat(
                        framebuffers[i], buffers[i], imageFormat);
                images[i] = new Image(imageFormat, size, size, buffers[i],
                        ColorSpace.Linear);
                MipMapGenerator.generateMipMaps(images[i]);
            }

            final TextureCubeMap map = EnvMapUtils.makeCubeMap(images[0],
                    images[1], images[2], images[3], images[4], images[5],
                    imageFormat);
            debugEnv = map;
            job.callback.done(map);
            map.getImage().dispose();
            jobs.remove(0);
        }
    }

I guess proper handling would be to let the LightProbe finish its rendering and then attach it. Or just add it and let the user "update the maps" themselves?

Edit: Tried the latter, and got the same exception when clicking "refresh the maps". So it's something with geometries. Has anyone tried doing this through code?

@neph1
Copy link
Contributor Author

neph1 commented Apr 26, 2023

Acceptable temp fix? I'll merge this soon unless there's further discussion.

@neph1 neph1 merged commit d2b4815 into jMonkeyEngine:master May 4, 2023
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants