Imported GLB model won't light up

Confused about lighting imported models. The only kind of light that will illuminate my model (using the Shark BJS model) is a Hemi. Every other light type won’t light up the model. Model works fine in sandbox (assume there’s a Hemi in there). What concept am I not getting?

Playground: Spotlight directly above Shark does not light it, but lights box below it.
https://www.babylonjs-playground.com/#3JTH72#8

Hi @bigrig

Can you check that the model normals are correct? Some documentation to help you investigate : Show Vertex Normals - Babylon.js Documentation

Hey @bigrig,

Another thing to check would be the Inspector. It’s an awesome tool that’s perfect for troubleshooting stuff like this.

Here’s some documentation on it: The Inspector overview - Babylon.js Documentation

And here’s a link to a video series going over the features at a 10,000 ft. view: YouTube

Hope this is helpful!

Well that was interesting. When I display normals, they form a massive (1000x) bigger shark above the shark. So this means that, somehow, normals have been scaled, while the model remained small?

https://www.babylonjs-playground.com/#3JTH72#10

@PirateJC, thx for tip. Am an avid inspector user… but haven’t been able to figure this one out even with its help.

In Blender, the normals look pretty… normal.

1 Like

The normal seem fine to me but the positions are not.
It’s like a scaling issue between the bindpose and the animation.
But at the same time, the normals computed by skinning should be computed the same way as positions.
Your animation is using skin mesh?

Hm, not sure about the animation - i just grabbed the stock BJS shark model. Maybe the extra large normals are a red herring though. Here’s a similar example where the normals look totally fine (right sized) - but still no illumination on the model:

https://www.babylonjs-playground.com/#3JTH72#11

(side note: i do notice that when i move an imported GLB around the scene using position.x, its normals stay in the position to which it was originally imported.)

Directional light works fine.
I bet for an issue in spotlight computation with scaled normals. Any idea @sebavan ?

Actually PBR and so GLTF are using a different light falloff than standard. Also, PBR can only work well with and environement lighting used for IBL :

https://doc.babylonjs.com/how_to/physically_based_rendering#light-setup
https://doc.babylonjs.com/how_to/use_hdr_environment

so you could do:

scene.environmentTexture = new BABYLON.CubeTexture.CreateFromPrefilteredData("textures/environment.env", scene);

to setup env lighting in your PG: https://www.babylonjs-playground.com/#3JTH72#12

2 Likes

Thanks @sebavan. The same does not seem to be true for GLTFs that are not PBRs? For the second example model (which is actually the model i’m working with, versus the shark, which i’d just used as a BJS standard), the env lighting does make a difference, but only a bit. Ie: still hard to see the model in the space. Any tips for lighting a non-PBR in GLTF format? Or would you just convert to some other format that works better with BJS?

https://www.babylonjs-playground.com/#3JTH72#13

ps. I tried exporting it as a .babylon file from Blender, but same result. here’s the export log:

Exporter version: 6.1.2, Blender version: 2.80 (sub 75)
========= Conversion from Blender to Babylon.js =========
	Scene settings used :
		inline textures     :  false
		Material Type       :  PBR
		Positions Precision :  4
		Normals Precision   :  3
		UVs Precision       :  3
		Vert Color Precision:  3
		Mat Weight Precision:  2
		texture directory   :  public/models/astrolowpoly/
	Python World class constructor completed
	processing begun of camera (UniversalCamera):  Camera
	processing begun of mesh:  Astronaut_mesh
		processing begun of material:  Astronaut_mat
			WARNING: unsupported node type(ShaderNodeMixRGB) will trigger baking
			processing texture 
				texture type:  diffuseTexture, mapped using: "TEXCOORD_0"
			Baking texture, type: DIFFUSE, mapped using: TEXCOORD_0
			processing texture Astronaut_mat_DIFFUSE
				texture type:  diffuseTexture, mapped using: "TEXCOORD_0"
			bake time:  0 min, 1.7102 secs
		Custom split normals with tangents being used
		num positions      :  3322
		num normals        :  3322
		num tangents       :  3322
		num uvs            :  6644
		num uvs2           :  0
		num colors         :  0
		num indices        :  4812
	processing begun of light (POINT):  fill
	processing begun of light (POINT):  key
	processing begun of light (POINT):  back
========= Writing of JSON file started =========
========= Writing of JSON file completed =========
========= end of processing =========
elapsed time:  0 min, 2.1686 secs

And the model: is here: https://bjs-playground.s3.amazonaws.com/astro.glb

Got it!
Directional light + the ENV texture did the trick. Holy moly!

https://www.babylonjs-playground.com/#3JTH72#14

1 Like