How to make model lighting/pre-processing in code the same as how a model appears in the sandbox?

Hey @johntdaly7

Fun topic, I just did some learning about this myself! I agree it’s not documented well enough. I’m going to change that! I’ll add a new doc section about the Sandbox and reference the lighting setup that’s in it, so in the future, folks can recreate it in the playground more easily. Thanks for the awesome question.

Ok so here we go:

This playground has nothing in it apart from a camera, a loaded gltf model, and the exact environment that’s used in the Sandbox by default.

Quick note here, in the Sandbox we have 2 different environments to choose from through this button:

The playground specifically recreates the environment used for the DEFAULT environment, not the studio environment.

You’ll also want to use this asset to drag into the sandbox to compare the two. It’s the same asset used in the playground.

Ok so now let’s look at the environment code used in the playground:

Check out lines 10-15 in the playground:

let lighting = BABYLON.CubeTexture.CreateFromPrefilteredData(“”, scene); = “runyonCanyon”;
lighting.gammaSpace = false;
scene.environmentTexture = lighting;
scene.createDefaultSkybox(scene.environmentTexture, true, (scene.activeCamera.maxZ - scene.activeCamera.minZ)/2, 0.3, false);

The first 4 lines create a cubemap texture in the scene and assign that to the scene’s environment texture.
The 5th line creates a default skybox using the environment texture, setting the scale, and blur.
The 6th line adds a default light setup to the scene.

That’s pretty much it!

Thanks again for asking this one! It was a fun one to learn myself and I agree we need to document it better. I’ll tackle this!