Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

[wgsl-in]/[glsl-out] Bug with vec types and modulo operator #1451

Closed
superdump opened this issue Oct 7, 2021 · 0 comments · Fixed by #1452
Closed

[wgsl-in]/[glsl-out] Bug with vec types and modulo operator #1451

superdump opened this issue Oct 7, 2021 · 0 comments · Fixed by #1452
Labels
area: back-end Outputs of shader conversion kind: bug Something isn't working lang: GLSL OpenGL Shading Language

Comments

@superdump
Copy link
Contributor

I had some code in wgsl like this:

    let rgb = clamp(
        abs(
            ((hue * 6.0 + vec3<f32>(0.0, 4.0, 2.0)) % 6.0 - 3.0
        ) - 1.0,
        vec3<f32>(0.0),
        vec3<f32>(1.0)
    );

and hit this when trying to run on WebGL2:

Internal error in VERTEX shader: ERROR: 0:244: '%' : wrong operand types - no operation '%' exists that takes a left-hand operand of type 'highp 3-component vector of float' and a right operand of type 'const 3-component vector of float' (or there is no acceptable conversion)

It's specifically the calculated vec3 % constant vec3 that seems to be the problem. I can work around it by individually calculating each component, but I think this is a bug somewhere, perhaps in glsl-out?

@kvark kvark added area: back-end Outputs of shader conversion kind: bug Something isn't working lang: GLSL OpenGL Shading Language labels Oct 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: back-end Outputs of shader conversion kind: bug Something isn't working lang: GLSL OpenGL Shading Language
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants