Standard Material compilation error (WebGPU)

Hello,

Enabling emissive as illumination on a Standard Material fails to compile shaders on a WebGPU engine.

const mat = new StandardMaterial(`some_material`, scene);
mat.useEmissiveAsIllumination = true;

It produces this error (Firefox, Ubuntu 24.04):


Shader 'fragment' parsing error: inconsistent type passed as argument #2 to `clamp`
    ┌─ wgsl:423:25
    │
423 │ var color: vec4f= vec4f(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);
    │                         ^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^ argument #2 has type {AbstractFloat}
    │                               │                                                                                                  
    │                               this argument has type vec3<f32>, which constrains subsequent arguments
    │
    = note: Because argument #1 has type vec3<f32>, only the following types
    = note: (or types that automatically convert to them) are accepted for argument #2:
    = note: allowed type: vec3<f32>

I can open a Github issue if required.

Many Thanks

cc @Evgeni_Popov

Welcome aboard!

Thanks for reporting, here’s the fix:

3 Likes