BabylonJS/Babylon.js · error · Error

HDR prefiltering is not available in WebGL 1., you can use r

Error message

HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.

What it means

HDRFiltering (HDR irradiance pipeline) prefilter() bakes an HDR texture into a pre-filtered IBL texture. It throws when engine._features.allowTexturePrefiltering is false, which is the case on WebGL 1 (or engines lacking the feature). The message advises using the real-time filtering path instead of offline prefiltering.

Source

Thrown at packages/dev/core/src/Materials/Textures/Filtering/hdrIrradianceFiltering.ts:206

     * @param texture Texture to filter
     * @returns true if the filter is ready
     */
    public isReady(texture: BaseTexture) {
        return texture.isReady() && this._effectWrapper.effect.isReady();
    }

    /**
     * Prefilters a cube texture to contain IBL irradiance.
     * Prefiltering will be invoked at the end of next rendering pass.
     * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
     * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
     * @param texture Texture to filter
     * @returns Promise called when prefiltering is done
     */
    // eslint-disable-next-line @typescript-eslint/naming-convention
    public async prefilter(texture: BaseTexture): Promise<BaseTexture> {
        if (!this._engine._features.allowTexturePrefiltering) {
            throw new Error("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.");
        }

        if (this.useCdf) {
            this._cdfGenerator = new IblCdfGenerator(this._engine);
            this._cdfGenerator.iblSource = texture;

            await this._cdfGenerator.renderWhenReady();
        }

        this._effectRenderer = new EffectRenderer(this._engine);
        this._effectWrapper = this._createEffect(texture);
        await this._effectWrapper.effect.whenCompiledAsync();

        const irradianceTexture = this._prefilterInternal(texture);

        if (this.useCdf) {
            // eslint-disable-next-line github/no-then
            await this._cdfGenerator.findDominantDirection().then((dir) => {

View on GitHub (pinned to 0592b347b8)

Solutions

  1. Check engine._features.allowTexturePrefiltering before calling prefilter() and branch to real-time filtering when false
  2. Use a pre-converted .env (prefiltered) cube texture instead of prefiltering .hdr at runtime on WebGL 1
  3. Force WebGL 2 context (or WebGPU engine) in application bootstrap so the feature flag is enabled
  4. If the error surfaces from a loader, update the loading code to fall back to non-prefiltered IBL estimation on unsupported engines

Example fix

// before
const filtering = new HDRFiltering(engine);
const baked = await filtering.prefilter(hdrTexture);
// after
let baked: BaseTexture;
if (engine._features.allowTexturePrefiltering) {
    baked = await new HDRFiltering(engine).prefilter(hdrTexture);
} else {
    baked = CubeTexture.CreateFromPrefilteredData('environment.env', scene);
}
Defensive patterns

Strategy: fallback

Validate before calling

if (!engine._features.allowTexturePrefiltering) {
    return CubeTexture.CreateFromPrefilteredData('environment.env', scene);
}
const baked = await hdrIrradianceFiltering.prefilter(hdrTexture);

Type guard

function supportsTexturePrefiltering(engine: AbstractEngine): boolean {
    return !!engine._features?.allowTexturePrefiltering;
}

Try / catch

try {
    baked = await filtering.prefilter(hdrTexture);
} catch (e) {
    if (String(e?.message).includes('HDR prefiltering')) {
        baked = CubeTexture.CreateFromPrefilteredData('environment.env', scene);
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: Calling hdrIrradianceFiltering.prefilter(texture) on a WebGL 1 engine or any engine whose _features.allowTexturePrefiltering is false; also reached indirectly via loaders (e.g., _loadTexture invoking prefilter) on unsupported engines.

Common situations: Legacy browser or iOS device limited to WebGL 1; loading an HDR environment for IBL in a scene; a tool/importer path that always calls prefilter without checking engine capabilities.

Related errors


AI-assisted analysis of BabylonJS/Babylon.js@0592b347b8 (2026-08-30). Data as JSON: /api/errors/dd54f8a956a9b3b7. Report an issue: GitHub.