Two days ago, while browsing YouTube, I came across this video by Sebastian Lague:
I remembered attempting something like this a bit over a year ago, by following a guide on raytracing shaders, and implementing it in Roblox, and decided I would try again, using this video as a guide.
I’m currently using GradientCanvas for the render previews and ViewportCanvas for the final image. I’m using Actors so I can run the “shader” several times in parallel, where the number of Actors is equal to the number of rays cast per pixel. Everything else functions the same as the shader in the video (source code here), and is configurable through this menu:
You can change the direction of the sun by rotating the floating black part using the btools.
Parts with PointLights inside them are treated as being emmisive, and part reflectance controls how shiny they appear. Currently I haven’t found a way to make the smoothness or specularColor properties configurable outside of Studio, but I plan to make a tool to change it (maybe by extending the btools functionality.)
The last thing I haven’t made changeable is the sky colors, and I’m not yet sure how I plan to make that happen.
Here’s a few renders:
(scale = 4, no sun/sky, depth of field strength = 100, frames = 100, rays per pixel = 64, everything else default, average 8 seconds/frame)
(scale = 4, frames = 200, rays per pixel = 64, everything else default, average 6 seconds/frame)
Currently, on my PC, with default settings, it renders at somewhere between 0.3 and 0.6 seconds per frame, depending on how many of the rays will shoot straight into the sky, and how many will reach the max bounce count.
Now, I’m no expert in raytracing or optimizations (though the video does explain things very nicely), so I couldn’t try to optimize it myself, but I’m hoping Sebastian will make another video about optimizing the raytracer, so I can squeeze some more performance out of this.