Switch to full stage
Loading Project
Loading project …

Instructions

USE TURBOWARP: https://turbowarp.org/868607896 This contains flashing images 'V' to show/hide variables Res is the resolution (smaller Res = higher resolution) DirX and DirY are the directions of the camera CamX, CamY, and CamZ are the coordinates of the camera RaysPerPixel is the number of rays sent out per pixel per frame (higher value = more realistic but slower) DOF is the depth of field (the distance that has a sharp image, but everywhere else is blurrier) LightX, LightY, and Light Z are the directions of the light

Notes and Credits

USE TURBOWARP: https://turbowarp.org/868607896 All my code. The example render took about 10 minutes on TurboWarp with a resolution of 0.25 and 1 ray per pixel for a lot of frames Includes specular reflection, refraction, lighting (objects can emit light), fresnel reflection (objects are more reflective when you view them edge on), diffuse reflection (works in combination with specular reflection), transmission (transparent objects let some light through and some reflects away), specular highlights, diffuse transmission (like in frosted glass) and depth of field (the distance where the image is clearest) Most of the algorithm I learnt from Sebastian Lague's Ray Tracing video: https://www.youtube.com/watch?v=Qz0KTGYJtUk Fresnel from: https://blog.demofox.org/2017/01/09/raytracing-reflection-refraction-fresnel-total-internal-reflection-and-beers-law/ Refraction from: https://samdriver.xyz/article/refraction-sphere and: https://registry.khronos.org/OpenGL/specs/gl/GLSLangSpec.1.20.pdf on page 66

TurboWarp is a Scratch mod that compiles projects to JavaScript to make them run really fast. Try it out by inputting a project ID or URL above or choosing a featured project below.