Jump to content

Loading model with HDRCubeTexture from .babylon file


Karl Hulme
 Share

Recommended Posts

Hello,

What is the correct format of a .babylon file so that it can load an HDR texture into the reflectionTexture slot of a PBRMaterial?

I know how to do this in code:

var hdrTexture = new BABYLON.HDRCubeTexture("/g/test/interior.hdr", scene, 512);

But I can't achieve the same thing with a .babylon file that is loaded with BABYLON.SceneLoader.ImportMesh.

This is the last format I tried:

{
  "materials": 
  [
    {
      "customType":"BABYLON.PBRMaterial",
      "name":"Material",
      "id":"Material",
      "alpha":1,
      "backFaceCulling":true,
      "albedoTexture":         // the albedo loads fine!
      {
        "name":"DefaultMaterial_Base_Color.png",
        "level":1,
        "hasAlpha":0,
        "coordinatesMode":0,
        "uOffset":0,
        "vOffset":0,
        "uScale":1,
        "vScale":1,
        "uAng":0,
        "vAng":0,
        "wAng":0,
        "wrapU":true,
        "wrapV":true,
        "coordinatesIndex":0
      },
      "reflectionTexture":    // this causes an error on load!
      {
        "name":"interior.hdr",
        "level":1,
        "hasAlpha":0,
        "coordinatesMode":3,
        "size":512,
        "uOffset":0,
        "vOffset":0,
        "uScale":1,
        "vScale":1,
        "uAng":0,
        "vAng":0,
        "wAng":0,
        "wrapU":true,
        "wrapV":true,
        "coordinatesIndex":0
      }
    }
  ],
  "meshes":[{...}]
}

The model loads fine.  As does the albedo texture (shown) and the reflectivity and normal textures (not shown).  But when I include the Reflection texture it fails.  The message in the console is: "babylon.js:3 BJS - [12:09:33]: Error while trying to load texture: /g/test/interior.hdr". 

Any help much appreciated.

kind regards
Karl

Link to comment
Share on other sites

Hello,

The fix is in a pull request and should then be available by tomorrow evening in the repo:

https://github.com/BabylonJS/Babylon.js/pull/1244

Basically, you ll only need to add this line in your json to fix it after updating to the latest version: 

"customType": "BABYLON.HDRCubeTexture",

{

      "reflectionTexture":    // this causes an error on load!
      {
        "customType": "BABYLON.HDRCubeTexture",
        "name":"interior.hdr",
        "level":1,
        "hasAlpha":0,
        "coordinatesMode":3,
        "size":512,
        "uOffset":0,
        "vOffset":0,
        "uScale":1,
        "vScale":1,
        "uAng":0,
        "vAng":0,
        "wAng":0,
        "wrapU":true,
        "wrapV":true,
        "coordinatesIndex":0
      }

}

Hope that will help you.

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