Issue with roughnessMap & metalnessMap with GLTFExporter in .glb

Hello guys !

I got an issue, i’m on it since 4 days and i realy dont understand why i got this !!

So i have an OBJ with all materials (DiffuseMaps, MetalnessMaps, roughnessMaps etc…), its all good on the obj one, but when i try to export a GLB with GLTFExporter, i got a lot of issue with materials and especially the Roughness and metalnessMap.

I’m doing this :

/*
Canvas Final Composite
*/

    const texture_merged = document.createElement('canvas');
    texture_merged.width = width;
    texture_merged.height = height;

    const texture_ctx = texture_merged.getContext('2d');
    texture_ctx.fillRect(0, 0, width, height);
    texture_ctx.globalCompositeOperation = "lighter";

    let tmp_canvas = document.createElement('canvas');
    tmp_canvas.width = width;
    tmp_canvas.height = height;

    let tmp_ctx = tmp_canvas.getContext('2d');
    tmp_ctx.globalCompositeOperation = "multiply";

    /*
        RED Channel : AO
    */

    if(aoMap){
        tmp_ctx.clearRect(0, 0, width, height)
        tmp_ctx.drawImage(aoMap.image, 0, 0);        
        tmp_ctx.fillStyle = "#FF0000";
        tmp_ctx.fillRect(0, 0, width, height);

        texture_ctx.drawImage(tmp_canvas, 0, 0);
    }

    /*
        GREEN Channel : Roughness
    */

    if(roughnessMap){
        tmp_ctx.clearRect(0, 0, width, height)
        tmp_ctx.drawImage(roughnessMap.image, 0, 0);        
        tmp_ctx.fillStyle = "#00FF00";
        tmp_ctx.fillRect(0, 0, width, height);

        texture_ctx.drawImage(tmp_canvas, 0, 0);
    }

    /*
        BLUE Channel : Metalness
    */

    if(metalnessMap){
        tmp_ctx.clearRect(0, 0, width, height)
        tmp_ctx.drawImage(metalnessMap.image, 0, 0);
        tmp_ctx.fillStyle = "#0000FF";
        tmp_ctx.fillRect(0, 0, width, height);
        texture_ctx.drawImage(tmp_canvas, 0, 0);
    }

    /*
        Draw Final Texture
    */

    texture_ctx.drawImage(tmp_canvas, 0, 0);

    return texture_merged;

To generate the aoRoughnessMetalnessMap to generate the gltf, but i got the wrong materials … i dontk now why, and i dont know why my diffuseMaps are more visible on the GLB exported than the OBJ …

The render is less metalness like the factors are not good as the obj values

I don’t think it’s possible to export roughness or metallic maps to OBJ at all, so I’m not sure what you’re comparing here, or how to reproduce your results. Could you include a live demo, or the full code in a ZIP?

No i try to export from OBJ --> GLTF/GLB :slight_smile: So when i use GLTFExporter, i pass the model as argument to the exporter, and when i try to export, it says that the metalnessmap and rougnessmap are not the same so they are ignored, that’s why i’m trying to generate aoRoughnessMetalnessMap and pass it to metalnessmap & roughnessmap of the mesh