Glitch on screenshot

Hi everyone !

I’m having a weird glitch on my screenshots (made using the script from here : Capturing a screenshot | Learn PlayCanvas)

I have 4 cameras, and I generate these 4 images. Some of them have a glitch and I don’t understand what the origin of this is. I use the same script on other projets with no problems.
It also appears using only one camera instead of 4, so it doesn’t seem to be related to that.

Unfortunately, I cannot share the project but will try to give details if needed.

Could this be a texture related problem? Or maybe a layer problem?
It doesn’t happen with all my 3D models, and I don’t see this glitch in the editor or launch mode.

These are the 4 pictures generated on the same model :

Bigger version of the glitch :

In editor :

Thanks in advance for the help :sweat_smile:

Oh maybe this could help. I think the camera might be moving while generating the screenshot…
These 2 renders are with the same setting, just the takescreenshot event launched several times.

Not seen that before but the way I would go about debugging this is to have the screenshot camera rendering to a viewport instead of a texture and screenshot to see if it’s rendering what you are seeing in the screenshot.

If it is, then I would Spector.js to breakdown the drawcalls.

2 Likes

Offhand, it looks like Z fighting maybe?

Oooh it actually does reproduce it ! (You can see the silhouette of the model on the second image)
I’m going to inspect this :slight_smile:

Edit : Looks this has something to do with my probably way too small “Near Clip” setting.
I’ve always overlooked this one and put something really small such as 0.01
Using 0.5 removes this particular glitch. Can’t really reproduce the strange christmas texture glitch yet, but could be the same thing…

Ok… These glitches do not appear anymore (for now! :slight_smile:)

So the first glitch (the christmas texture thing), it might have something to do with the fact that I called initialize() from orbitCamera right before raising the ui:takeScreenshot event . Not sure why I did that, I only needed focus() . I guess some initialization stuff happened while generating the screenshot.

And the second glitch was the too little Near Clip setting. This one I guess that some shaders mess up when the Near Clip is too close from the camera

The original issue is due to the how much information about depth it can store in the depth buffer. The smaller the distance between the near clip and far clip of the camera, the more accurate the depth is.

See: Depth Buffer Precision - OpenGL Wiki

1 Like