Hi ! (especially @sebavan the master of masters ?)
It has been noticed in the Babylon.JS Editor that PBR materials don’t look same once a project is closed and re-opened (link to the issue: The editor Scenes and the post-play Scenes are completely different · Issue #286 · BabylonJS/Editor · GitHub)
I have finally found a repro on playground and it looks like it is related to pbr materials when they are parsed.
Playground repro: https://playground.babylonjs.com/#FEEK7G#222
In this repro, 1 second after scene is ready the material is serialized then parsed to be re-applied (like saving/loading an editor project).
Once the pbr material is serialized then parsed, we can see that the level of the environment texture applied on the PBR material is higher than at startup.
Do you have any idea?
The problem is the environment BRDF texture which gets serialized but which should not, else you will get a new BRDF texture for each PBR material whereas you should have a single texture as it is the same for all materials.
The easiest way to fix the problem is to set the BRDF texture to null just before serializing. That way, it won’t be serialized, and when parsing the json string the global BRDF texture will be used instead of a new created one:
https://playground.babylonjs.com/#FEEK7G#223
@Evgeni_Popov are you creating a PR to prevent its serialization ??? otherwise I ll do it, this is really strange it gets serialized.
Well, in all generality the user can override the BRDF and provide their own… So in that case, I guess we should serialize it?
1 Like
yup good catch we should not serialize / desirialize only if default ?
1 Like
@Evgeni_Popov you rox !
Just for my information, what is the difference between the default one and a custom ? Why serializing the default brdf texture causes the problem and not a custom one ?
In fact the serialization of the BRDF is currently bugged, so it is a problem in itself (and I don’t really know how to fix it…). However, when the BRDF is the default one we should not serialize it, so the problem is avoided…
From the next nightly it will not be serialized anymore so no more issue.
4 Likes