GLTFpack + fresnel material rendering wrong

Moving from Three.js to Babylon and trying things out, love how the node material system works! Though the learning curve seems quite steep so far compared to three.

For some reason when importing a gltfpack-ed glb model then setting it’s material to a fresnel node material, it’s color becomes the brightest one in my ramp.

Importing the same model, but without the compression works fine, so my line of thought is that the GLTFpack removes somehow computed normals or tangents or whatever which is used by the fresnel, so it appears as if “all” the faces are pointing towards the camera?

Though trying to do:

for (const mesh of scene.meshes){
    const pos = mesh.getVerticesData(BABYLON.VertexBuffer.PositionKind)
    const ind = mesh.getIndices()
    let new_norm = []
    BABYLON.VertexData.ComputeNormals(pos, ind, new_norm)
    mesh.updateVerticesData(BABYLON.VertexBuffer.NormalKind, new_norm)
}

Breaks everything even more, so I don’t know what I’m doing I guess.
Here’s a demo scene, where I’m importing the same model with and without gltfpack compression.
The uncompressed shows up correct.
I’m compressing it by running gltfpack -cc -i demo_scene.glb -o demo_scene_compressed.glb

And here’s the node material I’m using:

Thanks for any help!

You must normalize the world normal before connecting it to the fresnel node input.

It works with the non compressed mesh because the scaling of the mesh is (1,1,1), but, for some reason, the compressed mesh has a scaling of (0.0002, 0.0002, 0.0002).

1 Like

Amazing tip, thank you!