One material darker than rest in screenshot

When i use ScreenshotTools.CreateScreenshotAsync or ScreenshotTools.CreateScreenshotUsingRenderTarget (i tried using both with the same result on both), one of our materials looks significantly darker than it does in the actual scene. However all other materials appear the same. Do you have any clues as to what might be causing this behavior?

This first image is taking a screenshot using OS, the curtain is a very bright blue.

This image is using babylonjs ScreenshotTools

(the bottom right is cropped out only bc there is an identifying watermark i removed from the file after generation).

This is really strange indeed… Could you repro in the playground ?

I cannot… we use a custom shader and a custom mesh format that we parse and then build babylon meshes out of… haha it would probably take me a few days to figure out how the heck to reproduce it in the playground. Wish i had a better answer than that. Let me poke around and see if i can find a quick way to reproduce it, was operating on wishful thinking that this would be a common problem and someone would go “make sure you turn on this option in the screenshot”

Unfortunately I can not think of any good reason :frowning: maybe you have some values in alpha so it blends with the background locally ?

There is some alpha stuff in the material, is there a reason why the screenshot wouldnt include the alpha stuff?

You would not see it blend with the background of the page which is the dom but the background of your picture viewer which might be dark

Would it not blend with the clear color if we were using mimetype jpeg?

not if you are not in blend mode, it would replace the alpha of the pixel with the one in the output shader.

Does the screenshot call just gather the existing pixels, or does it render a new frame (possibly in a different mode?)

It renders with the exact same mode.

So then if it looks bright in the scene, then in theory, it should look bright in the screenshot frame? Guess i didnt fully understand your comment about the blending

In the scene it could if you put alpha show the underlying dom color but once in screen shot it would show your picture viewer background color. so if one is bright and the other dark it could give this effect.

A repro here would definitely help :slight_smile:

Oh i gotcha. Nah we have a white clear color, and no alpha in the DOM, so it def isnt showing through the background behind it. I managed to get the mesh up into the playground, still trying to figure out how to get the material on it. Babylon.js Playground

Would it help to give you the “Export to babylon” file from the inspector?

@sebavan of really interesting note… this ONLY happens when using mimetype jpg… for mimetype png it seems correct. Does that lend any clues?

This is even weirder but definitely related to alpha then.

Well… we fixed it. we do UV2 material combination between an object space map and another material, and the wrong two materials were getting combined, resulting in a texture with multiple main textures, one of which had transparency, which in turn did weird stuff in the shader. So in other words… no one else will ever have this problem and its def not a bug with babylon. That was fun. Thanks @sebavan

1 Like