Skip to content

LightProbeGenerator: WebGL error with gl.readPixels in some cases #26765

@hybridherbst

Description

@hybridherbst

Description

When trying to use the LightProbeGenerator there are some cases where it fails.

The error message is different on
Safari: Error: WebGL: INVALID_OPERATION: readPixels: pixels is not TypeUint16
Chrome: WebGL: INVALID_OPERATION: readPixels: type HALF_FLOAT but ArrayBufferView not Uint16Array

and the coefficients being returned are all 0.

Reproduction steps

Run the fiddle in Safari or Chrome
Note WebGL: INVALID_OPERATION: readPixels: pixels is not TypeUint16 error in the console

image

Code

new EXRLoader().load('https://dl.polyhaven.org/file/ph-assets/HDRIs/exr/1k/farm_sunset_1k.exr', reflection => { 
    const size = Math.min(reflection.image.width, 512);
    const target = new THREE.WebGLCubeRenderTarget(size);
    let rt = target.fromEquirectangularTexture(renderer, reflection);
    const sampledProbe = LightProbeGenerator.fromCubeRenderTarget(renderer, rt);
    console.log("spherical harmonics", sampledProbe.sh);
});

Live example

https://jsfiddle.net/tkgobqnc/20/

Screenshots

No response

Version

r156

Device

Desktop

Browser

Chrome, Firefox, Safari, Edge

OS

MacOS

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions