babbleon Posted March 1, 2018 Share Posted March 1, 2018 Hello, I would like to convert the material definitions in a .babylon file to the most basic PBR possible. Currently, exported from Blender, I have two materials; bed.Floor & Bed.Wood: "materials":[ { "name":"bed.Floor", "id":"bed.Floor", "ambient":[ 1, 1, 1 ], "diffuse":[ 1, 1, 1 ], "specular":[ 0, 0, 0 ], "emissive":[ 0, 0, 0 ], "specularPower":50, "alpha":1, "backFaceCulling":true, "checkReadyOnlyOnce":false, "maxSimultaneousLights":4 }, { "name":"bed.Wood", "id":"bed.Wood", "ambient":[ 1, 1, 1 ], "diffuse":[ 1, 1, 1 ], "specular":[ 0, 0, 0 ], "emissive":[ 0, 0, 0 ], "specularPower":30, "alpha":1, "backFaceCulling":true, "checkReadyOnlyOnce":false, "maxSimultaneousLights":4 } ], I would like to manually edit this file so that BJS treats this as PBR? But can't work out what to do. Yes, I know I can create new materials in my scene script... but would be grateful if anyone could advise what changes I need to make to the .babylon file by hand? Hope this makes sense! Thank you all. Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 1, 2018 Share Posted March 1, 2018 I do not know, but please post your hand changes. PBR will not be in version 5.6 of exporter, but knowing what to write will help for the future. I can give a hint though. Look through this file, and add a tag every time you see a '@serialize()' line. For instance: "directIntensity": 1 Once you do the leg work, post what you got and maybe someone can further explain. Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 1, 2018 Author Share Posted March 1, 2018 @JCPalmer - thank you for this hint. I will have a mess around with this later on this evening. In the mean time, below is what extracted from here. Let's see if I put these in my .babylon, it will automagically make it a PBR - are things ever that simple? alphaCutOff = 0.4; ambientTextureStrength: number = 1.0; directIntensity: number = 1.0; disableBumpMap: boolean = false; disableLighting = false; emissiveIntensity: number = 1.0; environmentIntensity: number = 1.0; forceAlphaTest = false; forceIrradianceInFragment = false; forceNormalForward = false; indexOfRefraction = 0.66; invertNormalMapX = false; invertNormalMapY = false; invertRefractionY = false; linkRefractionWithTransparency = false; maxSimultaneousLights = 4; metallic: number; microSurface = 1.0; parallaxScaleBias = 0.05; roughness: number; specularIntensity: number = 1.0; twoSidedLighting = false; useAlphaFresnel = false; useAlphaFromAlbedoTexture = false; useAmbientInGrayScale = false; useAmbientOcclusionFromMetallicTextureRed = false; useAutoMicroSurfaceFromReflectivityMap = false; useHorizonOcclusion = true; useLightmapAsShadowmap = false; useLinearAlphaFresnel = false; useMetallnessFromMetallicTextureBlue = false; useMicroSurfaceFromReflectivityMapAlpha = false; useObjectSpaceNormalMap = false; useParallax = false; useParallaxOcclusion = false; usePhysicalLightFalloff = true; useRadianceOcclusion = true; useRadianceOverAlpha = true; useRoughnessFromMetallicTextureAlpha = true; useRoughnessFromMetallicTextureGreen = false; useSpecularOverAlpha = true; Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted March 1, 2018 Share Posted March 1, 2018 In this case there are just a lot of numbers and booleans. Once you start dealing with nested arrays or frame animation, a .babylon get a lot more tricky Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted March 1, 2018 Share Posted March 1, 2018 You can directly export to PBR using the GLTF exporter, if this file format is adequate for your needs. Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 1, 2018 Author Share Posted March 1, 2018 @V!nc3r - thank you. I tried that but it only supports one animation - as far as I'm aware. However, I have just looked at the GLTF file and the material bit of it may work in the .babylon : "materials": [ { "emissiveFactor": [ 0.0, 0.0, 0.0 ], "name": "Floor", "pbrMetallicRoughness": { "baseColorFactor": [ 0.64000004529953, 0.64000004529953, 0.64000004529953, 1.0 ], "metallicFactor": 0.0, "roughnessFactor": 1.0 } }, { "emissiveFactor": [ 0.0, 0.0, 0.0 ], "name": "Wood", "pbrMetallicRoughness": { "baseColorFactor": [ 1.0, 1.0, 1.0, 1.0 ], "baseColorTexture": { "index": 0, "texCoord": 0 }, "metallicFactor": 0.20000000298023224, "roughnessFactor": 0.5 } } ], @JCPalmer - as a start, I think I will try this as I know it works at least in GLTF... but I have to run now. Quote Link to comment Share on other sites More sharing options...
babbleon Posted March 1, 2018 Author Share Posted March 1, 2018 @JCPalmer Okay, so.. it looks like all you need to do is add the following to the .babylon file: "customType":"BABYLON.PBRMaterial" My materials now look like this: "materials":[ { "name":"bed.Floor", "id":"bed.Floor", "customType":"BABYLON.PBRMaterial", "ambient":[ 1, 1, 1 ], "diffuse":[ 1, 1, 1 ], "specular":[ 0, 0, 0 ], "emissive":[ 0, 0, 0 ], "specularPower":50, "alpha":1, "backFaceCulling":true, "checkReadyOnlyOnce":false, "maxSimultaneousLights":4 }, { "name":"bed.Wood", "id":"bed.Wood", "customType":"BABYLON.PBRMaterial", "ambient":[ 1, 1, 1 ], "diffuse":[ 1, 1, 1 ], "specular":[ 0, 0, 0 ], "emissive":[ 0, 0, 0 ], "specularPower":30, "alpha":1, "backFaceCulling":true, "checkReadyOnlyOnce":false, "maxSimultaneousLights":4 } ], Some of the properties are maybe redundant as it's now a PBRMaterial, but if you log these materials to console they show as PBR. Here's a playground that exports the scene.materials as a .babylon, you can pick through the file to see how things are done with PBR. JCPalmer 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.