elm-explorations / webgl

Functional rendering with WebGL in Elm
https://package.elm-lang.org/packages/elm-explorations/webgl/latest/
BSD 3-Clause "New" or "Revised" License
117 stars 17 forks source link

How to build a Shader without the [glsl|...|] syntax ? #40

Closed titouanc closed 1 year ago

titouanc commented 1 year ago

The documentation states

Normally you specify a shader with a [glsl| |] block.

Is there any other way to build a Shader without the [glsl| ...|] syntactical construct ? I would like to generate shader code in Elm, and therefore I don't have any shader code at compile time to put in there.

w0rm commented 1 year ago

@titouanc this used to work in the past through the unsafe shader function. The functionality was removed in 0.19 because the shader inputs depend on Elm record field names. Starting from 0.19 the field names are mangled when compiled in the optimize mode (to reduce asset size). In order for these names to match, the shader inputs had to be known at compile time.

titouanc commented 1 year ago

Thanks for your fast reply @w0rm ! Unless you have another suggestion that would allow me to use native Elm webgl, I will then resort to ports and manage the webgl context in javascript.