[NEWBIE] How to export lightmap for glTF 2.0?


I’ve done the protocol explained in the doc:

But lightmap doesn’t display in threeJs.

I’d need help to find my errors. Thanks if you can :wink:

Here’s the screen of display error in threejs:


I’ve just tried the classic multiply approach, displaying is perfect in blender:

But… my glTF is worse…


Now glTF exports lightmap with texture coordinates. HELP ME !!!

If i believe this topic, the problem is in gltf exporter:

According to these people:

Threejs doesn’t use directly the second texture as a lightmap, so, maybe i need a some javascript workaround ?..

I’ve found the workaround. glTF doesn’t support lightmaps, so, store the texture elsewhere, for example in emissiveMap. Then, in your 3d engine, create a new material using it as a lightmap.

let newMat = new THREE.MeshBasicMaterial({map: obj.material.map , lightMap: obj.material.emissiveMap });
obj.material = newMat;

Now it works.


Here’s the final version of my shader:

Thx for writing down the solution as well with so much detailed.
Had the same issue and this helped a lot!