elm-community / webgl

Moved to elm-explorations/webgl
https://package.elm-lang.org/packages/elm-explorations/webgl/latest
BSD 3-Clause "New" or "Revised" License
131 stars 18 forks source link

Arrays in shaders #56

Closed SjorsVanGelderen closed 6 years ago

SjorsVanGelderen commented 6 years ago

The type of an array in a shader is incorrectly inferred as just the primitive type. Example:

uniform int  palette[64];

yields

But the definition (shown above) is a:

    Shader
        {}
        { palette : Int }
        {}

Where palette should probably have been inferred as Array Int.

Combined with the inability to generate textures at runtime, this is a real obstruction when for example creating a graphics editing application.

SjorsVanGelderen commented 6 years ago

I think the createUniformSetter function should check the size of the incoming uniform, and use the appropriate type accordingly. The biggest hurdle probably is that the GLSL parser that is being used doesn't infer the types correctly.

w0rm commented 6 years ago

@SjorsVanGelderen Hi, this is a known limitation https://github.com/elm-community/webgl/issues/36

What kind of graphics editing application do you have in mind? It would be better first to know more about the use case.

The current plan is to rewrite the glsl parser, integrate it with the Elm compiler, and only after we can think about supporting more types in shaders.

w0rm commented 6 years ago

Closing because this is tracked in #36