Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for uniform array type inference failure #37

Open
costructuralist opened this issue Jul 11, 2021 · 2 comments
Open

Workaround for uniform array type inference failure #37

costructuralist opened this issue Jul 11, 2021 · 2 comments

Comments

@costructuralist
Copy link

I have the following Elm type for uniforms:

type alias Uniforms = { cellColors : List Vec3 }

In a vertex shader I have the following declaration for an array of vec3 uniform:

uniform vec3 cellColors[9];

The GLSL parser, however, is inferring/parsing the type of the cellColors variable to be Vec3, and not Array Vec3.

It seems as if this is a bug in the underlying GLSL parsing library: noteed/language-glsl#19

Is there a way to work around this bug?

@w0rm
Copy link
Collaborator

w0rm commented Jul 11, 2021

Hi. Array uniforms are not supported in the elm compiler. This is not a bug, but a missing feature. The supported shader types are listed in the package docs: Int, Float, Texture and Vec2, Vec3, Vec4, Mat4 from the linear-algebra package.

This bit in the compiler derives the type signature for shaders https://github.com/elm/compiler/blob/master/compiler/src/Parse/Shader.hs#L170

@w0rm
Copy link
Collaborator

w0rm commented Jul 11, 2021

Maybe you could use a few Mat4 uniforms to pass the same amount of data.

Or a texture image, if the data is constant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants