[NEWBIE] How to export lightmap for glTF 2.0?

Hi,

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:

lightmap_wrong

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

But… my glTF is worse…

lightmap_wrong_2

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.dispose();
obj.material = newMat;

Now it works.

lightmap_ok

Here’s the final version of my shader: