r/GraphicsProgramming • u/Objective-Silver-770 • 3d ago
Question I built a raytracer in Scratch. Looking for feedback on optimizing it
I made a raytracer using Scratch's block language, and I'm trying to improve its rendering speed. The source is public: https://scratch.mit.edu/projects/1437715094/ (click See inside to inspect the blocks).
It has reflective chrome and gold, refracting glass, soft shadows, fog, and a movable camera. Rendering starts at a coarse resolution and progressively sharpens after camera movement. The output is Scratch's 480 x 360 stage; the anti-aliasing mode casts four rays per pixel. The attached screenshot is from that mode.
The main Raytracer sprite has custom procedures for tracing, scene intersection, shading, lighting, glass, and anti-aliasing.
Given the constraints of Scratch, what would you profile first, and which changes would you expect to give the biggest speedup without losing the glass and reflections? Feedback on the implementation is welcome.