Disabling ClearCoat results in missing object within next Screenshot

Hello together, I’ve found a strange bug regarding screenshots and clearcoat:

After disabling the clearcoat property of an PBRMaterial the object becomes invisible within the next Screenshot. If I do another screenshot afterwards the object becomes visible again (within the screenshot). It doesn’t seem to be a timing issue. Even if I wait a few seconds the object is still invisible in the screenshot.

  • I’m using BABYLON.Tools.CreateScreenshotUsingRenderTargetAsync for the screenshot.
  • For disabling the clearcoat property I’m only setting mat.clearCoat.isEnabled to false

Playground:

  • Press “Sceenshot” → screenshot looks fine
  • Press “Remove Clearcoat” → rendering looks fine
  • Press “Screenshot” → sphere is missing in screenshot :frowning:
  • Press “Screenshot” again → its working again

Not sure if this helps, but I just found out, that this bug only applys to CreateScreenshotUsingRenderTarget and CreateScreenshotUsingRenderTargetAsync.

CreateScreenshot and CreateScreenshotAsync seems to be working as intended.

@carolhmj might it be related to your latest changes ??? if not let me know and I ll have a look

As an additoinal site node: I’ve just tested it in some older projects of mine. I was able to reproduce the issue with babylon version 5.0.3 but not with 4.2.0.

Hmmm it probably is, I’ll have to look into how clearcoat changes the renderlist :open_mouth:

EDIT: NVM, since it’s reproducible in 5.0.3 it’s probably something older?

The problem is that some defines are not reset to their default value when switching the clearcoat state (enable/disable).

Here’s a PR that will fix it:

I have also performed the same fix for the other PBR components (anisotropy, sheen, etc).

5 Likes