Ray tracing (SIMPLE)

Made a very simpe raytracing system. note i have been programming for only a year (any language) so i needed some AI help to get the math right and understand raycasts. it is a very barren “raytracing” and i havent though of lighting yet.


you can change the amount of times it will maximally bounce

does anyone better than me have any ideas/suggestions?

4 Likes

It’s good, but remember, ray tracing is more than one ray, you would have to make a lot of them, that’s why they’re so expensive. A lot of optimisation will be needed, but looks good at the moment!

2 Likes

Im primarily a builder and I never intended to use it outside of maybe showcases, (if i do decide to finish) and its cool to see such an effect produced in ROBLOX. thanks for the feedback!

2 Likes

Ok, so I upgraded the system a little, since its a module I added parameters allowing control over maximum bounces and rays shot. they also now fire off random points of the origin. (removed wall for easier vision)

I got ~0.35s render time for this scene, which had around 200 rays with 10 bounces.

I read on multithreading, which could decrease reder times and load. But since I want to make a global illumination system, should I approach that with multithreading instead, or have both the rays and probes be multithread?

The GI would work by making probes on the voxel grid, 4x4x4 (roblox) and then have each probe shoot rays, collect data based off objects it hits (color) and also check if the object is in sunlight and relay the data, then adding light to the probe based off distance from sunlight (inverse square law to get brightness).

sorry for long msg

edit: some rays stop midair cause i need to adjust the length property - looking for an optimization for extremely long rays though.

2 Likes

Wow, that’s cool, though the render time, is really bad, its not suitable for real time renders, unless you can reduce that number, maybe use occlusion culling, I think roblox already added that as a feature and may cause less lag.

Im not sure, Im not experienced in graphics programming nor parrallel luau. I would try both methods to see which one is faster.

But good job, keep working on it!

2 Likes

I intended for static baked lighting, but the loadtimes are far too long, and I will do some bts optimization. Thanks for the reply!

2 Likes

Ok. I did some realtime testing, and for my hardware I’d say it’s pretty good. (real time simulation, 30hz refresh rate given and 250 rays drawn with 5 bounces each) gave me around 25fps. I have a laptop, and it is by no means made for these things (Intel Iris Xe graphics). I implemented multithreading and got raw load times for rayshooting at around 0.02-0.03, and drawtimes (though these are optional and not needed for future light data gathering) of around 0.03. total render time: approx 0.05-0.08

1 Like