Jump to content

.babylon from Blender, materials to PBR


babbleon
 Share

Recommended Posts

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

@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;

 

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

@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.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...