Quick update: I now believe that it has nothing to do with WebGL.
I’ve created a new Ellie.
I’ve replaced the Dict with an Array → im now getting 14 Frames locally, 7 in Ellie.
Also i added a way to skip frames (
renderEvery on line 55). If this would be a WebGL issue, then the frames should not change when increasing
renderEvery. But in fact when doubling it, the fps drop by half.
Another observation: removing the laplace function gets me up to 60 fps in Ellie. Heres the laplace function:
convolution : List ( ( Int, Int ), Float )
[ [ 0.05, 0.2, 0.05 ]
, [ 0.2, -1, 0.2 ]
, [ 0.05, 0.2, 0.05 ]
(\j list ->
|> List.indexedMap (\i factor -> ( ( i, j ), factor ))
get : ( Int, Int ) -> Array (Array a) -> Maybe a
get ( i, j ) grid =
|> Array.get j
|> Maybe.andThen (Array.get i)
laplace : (( Float, Float ) -> Float) -> ( Int, Int ) -> Array (Array ( Float, Float )) -> Float
laplace fun ( x, y ) dict =
(\( ( i, j ), factor ) ->
|> get ( x - 1 + i, y - 1 + j )
|> Maybe.map fun
|> Maybe.withDefault (fun ( 1, 0 ))
For a given point it sums up the neighbors (using the weights defined in convolution). Every cell has two values, thats why i need to pass
fun along, the function is currently called twice per cell: once with
fun = Tuple.first and once with
fun = Tuple.second. My next experiment will be to get rid of
fun. This should theoretically double the fps.