You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Say we want to add a new function, tom(z) = 1 - z. In the current code, we have to:
Create Operator::TOM
Create a FullOperator with the function tom's properties, such as arity, precedence, etc (which will, of course, default to the same as every other unary function)
In our shader code, create a macro #define TOM SHADER_TOM
In our shader code, add a block guard #ifndef SHADER_TOM #define SHADER_TOM 0u #endif
Implement vec2 tom(vec2 z)
Add to evaluate_unary_operator a clause if(op == TOM){return tom(param);}
This makes no sense! There is no good reason for us to do anything but steps 1,2,5. And, since we already have a lot of string manipulation, and a dedicated library (preprocessor/) created just for manipulating shaders at runtime, this process can, and should, very well be optimized.
Another good thing comes from this: we have a "mini-compiler" for our interpreter. I reckon there's some optimizations to be made to make the switch-case and stack manipulation to be made.
Activity
Sekqies commentedon Jan 24, 2026
Done! Commit