Skip to content

WebGLRenderer alpha GLTFLoader texture issue #21744

@enijar

Description

@enijar

Describe the bug

There is an issue with some incorrect texture colours when loading a GLTF model via GLTFLoader when WebGLRenderer is instantiated with alpha set to true.

To Reproduce

Steps to reproduce the behavior:

Instantiate WebGLRenderer with alpha set to false.

Code

import * as THREE from "three";
import { GLTFLoader } from "three/examples/jsm/loaders/GLTFLoader";

const renderer = new THREE.WebGLRenderer({
  // ...
  antialias: true,
  alpha: true // this is what causes the texture colour issue
});

const width = 1024;
const height = 768;
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);

const ambientLight = new THREE.AmbientLight();
scene.add(ambientLight);

// Load model and add to scene
const loader = new GLTFLoader();
loader.load("model.gltf", (gltf) => {
  scene.add(gltf.scene);
});

// Render scene
(function render() {
  renderer.render(scene, camera);
  requestAnimationFrame(animate);
})();

Live Demos

alpha: true alpha: false
https://codesandbox.io/s/pedantic-cloud-vgppt?file=/src/index.js https://codesandbox.io/s/dry-http-fdykp?file=/src/index.js

Below is the output where WebGLRenderer has been instantiated with alpha set to true and false

alpha: true alpha: false
image

Expected behavior

I believe setting the alpha to true or false shouldn't have an effect on how solid textures are rendered. The expected behaviour would be for textures to render consistently regardless of the alpha setting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions