Skip to content

WEBGL // UBO (Uniform Buffer Object) with onBeforeCompile is not working. #31086

@dghez

Description

@dghez

I'm trying to use UBO paired with onBeforeCompile but looks like is not possible.
I'm pretty sure my setup of the UBO is working because i'm using that on other materials, but with ShaderMaterials directly.

Here is what i'm trying:

el.material.onBeforeCompile = (shader) => {
            shader.uniformsGroups = [globalUniforms]

            shader.fragmentShader = shader.fragmentShader.replace(
                `#include <common>`, /* glsl*/ `
                  #include <common>
                  #include <globalUBO>
              `
            )
        }

But yells at me.

Image

Any clue?

Version

0.174.0

Device

No response

Browser

No response

OS

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions