GLSL refactor of rendering logic. Now using fragment shader for pixel calculations, dramatically speeding up by something like 30-50x. This makes the Digital Cymatics Equation Generator much more fun to use.
Note that this refactor was done almost entirely by ChatGPT Codex. This was a massive win. Here are the prompts used in this refactor:
~ PROMPT 1: Rewrite fuzzygraph.js to use GLSL for rendering fuzzy graphs. Keep the following function names, and continue to export them: parseEquationString, displayGraph, calcWindowBounds, getXWidth, makeLinearMapper. In index.html, make the fewest changes possible to make it work. Keep the vertex shader simple. Most of the work should be done as a fragment shader. Call this file fuzzygraph_glsl.js.
~ PROMPT 2: This seems to work, but is very slow - no speedup over the purely cpu-bound original version. The calculateFuncForWindow function is still using a CPU-bound 2-deep for-loop. This code should be moved to glsl also. Refactor things more if need be to move more of the computation (especially the most CPU-bound parts like those executed for every pixel) to GLSL code.
~ PROMPT 3: That looks great. Good job AI. There are a few remaining bugs though. The image is inverted - please invert y axis. Also, the Invert Color functionality is not working. Lastly, when the graph first loads, it is off-center. But when I hit the home button, it centers correctly. Please fix these bugs.
~ PROMPT 4: Those fixes worked. There seems to be a slightly different behavior in how min and max overrides are working. I'm not sure if in the bug is in the new code (fuzzygraph_glsl.js) or the previous code (in fuzzygraph.js). Can you identify what the difference is?
~ PROMPT 5: Let's leave it for now. Another error: the error shown with the mouse goes over the canvas is inverted on the y-axis. Fix this.
~ PROMPT 6: Based on the differences described under your "Difference in min/max handling" above, modify the glsl version of fuzzygraph so it handles the min and max overrides as the old version did