Login  Register

Re: Model corruption with Background Node

Posted by philjord on Sep 20, 2021; 2:54am
URL: https://forum.jogamp.org/Model-corruption-with-Background-Node-tp4041238p4041294.html

Hi,

The issue you are facing is resultant from a bug in the JoglPipeline code

the method
textureFillBackground

should reset the various disabled features at the end, however it misses the gl.glDepthMask(true);

On the first pass through the Renderer.doWork it calls resetImmediateRendering() which calls resetRenderingAttributes, which fixes the mask and therefore hides the bug.

On the second render (being offScreen and manual mode) it doesn't call the resetImmediateRendering so the bug is exposed.

So this bug would seem to be easy to hit in the wild, however offscreen cases like JCanvas3D use continuous immediate mode which suppresses the bug as well.

Luckily there is a very simple work around, if you set your offscreen buffer again, it will trigger the reset on the next render. The buffer can be set to the current buffer.

So if you modify OffScreenRenderer.render to include one line:

public BufferedImage render() throws IOException {
            long start = System.nanoTime();
         
            if(ON_SCREEN){
                JFrame frame = new JFrame("Render");
                frame.setSize(RENDER_WIDTH, RENDER_HEIGHT);
                frame.getContentPane().setLayout(new BorderLayout());
                frame.getContentPane().add("Center", canvas);
                frame.setVisible(true);
            }else {
//Force attribute reset on the canvas
canvas.setOffScreenBuffer(buffer);
                canvas.renderOffScreenBuffer();
                canvas.waitForOffScreenRendering();
            }

            System.out.println("Rendering took " + ((System.nanoTime() - start) / 1000000) + "ms");
            return buffer.getImage();
        }


I found this fixed the issue for my reproduction using your provided code (thanks for the clear code).


Thanks very much for finding this quite bad bug, I'll get a fix into 1.6 and 1.7; it appears to occur throughout the code lines, including the newer programmable pipeline.

I apologize for the slowness of this response as well, I'm in New Zealand and we went back into a lock down last month, which for desk bound people like myself increases the work load rather than decreasing it.

If you try the work around above and give me feedback that would be great.

Thanks.