shader-park / shader-park-core

A JavaScript library for creating real-time 2D and 3D shaders. JS -> Shader. https://shaderpark.com/ https://twitter.com/shaderpark

Home Page:https://shaderpark.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Compiler Rewrites

torinmb opened this issue · comments

  1. change the binary ops and built-in functions we have to just return the glsl strings rather than appending it to the total source.
  2. make a function in regular js called "createVar(name, value)" or "assignVar(name, value)" which actually creates the line assigning a variable.
  3. using esprima to convert regular assignment statements (ones using any type of = symbol) to the function created in step two.
  4. make tweaks to the branch rewriting we already implemented and any other features we need to update so that they play nice with this new setup.

Turns out 1 was already supported. For 2, VariableDeclarations can be replaced with makeVar, and overwrite/update "=" type expressions can be replaced with a new "updateVar" function. "For" loops might need a special case here (should for loops be just generated in glsl without unrolling after all? This may be the only way to "break" from loops)