Rendering second camera to texture has lighting issues for imported gltf materials when flipping y on render target

Rendering a 2nd camera to a texture does seem to render lighting wrong on imported gltf materials when flipY is set to true on render target. It seems to invert the lighting direction, as turning the light by 180 degrees seems to render the object as it should appear. Here is a basic project showing the issue:
The flipY bool is exposed to the editor and clicking the left mouse button inverts lightdirection on x.

I use the following function for doing the rendering:

RenderToMaterial.prototype.createNewRenderTexture = function () {
    var device =;

    // Make sure we clean up the old textures first and remove 
    // any references
    if (this.texture && this.renderTarget) {
        var oldRenderTarget = this.renderTarget;
        var oldTexture = this.texture;

        this.renderTarget = null;
        this.texture = null;


    // Create a new texture based on the current width and height of 
    // the screen reduced by the scale
    var colorBuffer = new pc.Texture(device, {
        width: this.renderResolution.x,
        height: this.renderResolution.y,
        format: pc.PIXELFORMAT_R8_G8_B8,
        autoMipmap: true

    colorBuffer.minFilter = pc.FILTER_LINEAR;
    colorBuffer.magFilter = pc.FILTER_LINEAR;

    var renderTarget = new pc.RenderTarget({
        colorBuffer: colorBuffer,
        depth: true,
        flipY: this.flipY,
        samples: 2
    }); = renderTarget;

    this.texture = colorBuffer;
    this.renderTarget = renderTarget;

    // Create a new Basic material
    var material = new pc.BasicMaterial();

    // Set the material to have a texture map that is multiplied by a red color
    //material.color.set(10, 10, 10);
    material.colorMap = this.texture;

    // Notify the material that it has been modified

    if ( = this.texture;
    if ([0].material = material;

I had a closer look at this and it looks like the material created from the model has two side lighting enabled which is not exposed in the editor to disable.

I’ve created a ticket for this but in the short term, can you disable two sided lighting in the material in your modelling program and try re-exporting it please?

Otherwise, you can disable it via devtools by selecting the asset in the Editor and running the following code:

editor.selection.item.set('data.twoSidedLighting', false)


Thanks for looking into it. I did avoid the flipY option for the time beeing, as this was working as well. But I just tried to enable backface culling on the material in blender and it did indeed solve the issue. So for anyone using Blender → On The Material scroll down to Settings and Tick “Backface Culling” for the twoSidedLighting option not beeing exported into a glb/gltf.

1 Like