I want to try using Babylon to restore the GLB model exported from Blender in a local project, but I found that the rendering effect of the imported GLB model is not consistent with that of the Sandbox page. The Sandbox page effect is closer to the effect in Blender, so I don’t understand why these differences are caused?
I have also looked at the source code of the sandbox page and tried to fix it based on 3D Commerce Certified Viewer | Babylon.js Documentation, but none of them were able to solve this problem;
Here are some relevant version information:
system
: MacOS 11browser:
Chrome 120.0.6099.109BabylonJS
: 6.33.2
The local code is as follows:
import { CubeTexture, Engine, Scene, SceneLoader } from "babylonjs";
import 'babylonjs-loaders'
const forceSRGBBufferSupportState = false
const antialias = true
function createScene(scene: Scene, engine: Engine) {
const env = CubeTexture.CreateFromPrefilteredData('https://assets.babylonjs.com/environments/studio.env', scene)
scene.environmentTexture = env
scene.createDefaultCamera(true, true, true)
scene.createDefaultSkybox(env, true, (scene.activeCamera!.maxZ - scene.activeCamera!.minZ) / 2, 0.3, false);
engine.runRenderLoop(() => {
scene.render()
})
window.addEventListener('resize', () => {
engine.resize()
})
}
export function test(canvas: HTMLCanvasElement) {
const engine = new Engine(canvas, antialias, {
// useHighPrecisionMatrix: true,
// premultipliedAlpha: false,
// preserveDrawingBuffer: true,
// antialias,
forceSRGBBufferSupportState: forceSRGBBufferSupportState,
})
SceneLoader.Load('models/', 'test.glb', engine, model => {
console.log(model)
createScene(model, engine)
model.debugLayer.show()
})
}
This is the effect of the Sandbox page:
And this is the effect of my local project, which is clearly inconsistent with the effect of the Sandbox page:
But another confusing point for me is that when I used INSPECTOR’s “CAPURE With RTT” function to take screenshots, the image I got was actually not consistent with the effect I saw on the canvas element, but rather closer to the effect of the Sandbox page:
Here is the GLB model I used: