Is there any reliable way to convert a StandardMaterial to a PBRMaterial?
I’d like to convert some demo scenes to PBR, just so I can have access to the PBRMaterial debug modes.
There are no reliable ways unfortunately as they have pretty different techniques…
That said, what do you need from the debug mode in standard ?
I’m interested in the ability to render material proprieties for a whole scene, much alike one would render to buffers in deferred shading. PBR can render things like screen space normals and surface albedo.
You can quite easily do the same thing with a custom material:
https://playground.babylonjs.com/#LZ0656#1
You will need to look at the fragment code of the standard material to find the variables you would like to display in debug mode.
You can also do it with a uniform instead of a define (less intrusive code, but less performant in the fragment shader):
That does seem like it could work. I’d just have to replace each standard material with a custom one, and copy the proprieties of the original material to the custom.
Is there any documentation on CustomMaterial and PBRCustomMaterial? Could only find this post:
There is this https://github.com/BabylonJS/Babylon.js/tree/master/materialsLibrary/src/custom, but it’s not up to date.
It still can help.
There’s no need to copy the properties, a CustomMaterial
subclasses the StandardMaterial
class, so all properties you need are already there. You simply need to replace new StandardMaterial(...)
by new CustomMaterial(...)
.
There’s no need to copy the properties, a
CustomMaterial
subclasses theStandardMaterial
class, so all properties you need are already there. You simply need to replacenew StandardMaterial(...)
bynew CustomMaterial(...)
.
No, I mean, looping through all the scene materials and replacing them with CustomMaterials with cloned proprieties. I’m loading a random scenes that already have materials defined.