Is real-time performant Ray-Tracing possible?

Hey, I’ve seen some programmers post their work with Roblox “ray tracing” on twitter, or even here, but they haven’t made it open source, I’ve been wondering how it even works and how it would be possible in Roblox

2 Likes

I’d take a look at this Ray tracing how? - #7 by CoderHusk

Hey there.

As you know, real-time ray-tracing already makes a huge impact on performance when using a GPU to perform the math-operations.
I wouldn’t say it’s impossible but it sure is very much limited by the fact that ROBLOX has no API or framework for us developers to utilize the GPU, meaning everything is done on the CPU.
There is some advice I can give you as I have already some experience with creating my own ray-tracing engines in roblox.

  • Use threads (actors) to split up your work-load when rendering/ displaying the render to the user.
    Utilizing multiple threads greatly improves render-times for images with bigger resolution.

  • Use the “EditableImage”-Instance instead of many Frames or Label when displaying the final render.
    It is easier to work with and the :writePixels() method makes you draw all pixels at once rather than having to create each pixel using nested loops.

But to come back to your question.
Yes, it’s possible, but don’t expect to much. Trying to real-time render a scene in 1080p is not realistic here as we can only use the CPU for the math-operations. But if limited to a smaller viewport with a resolution of 80x80 pixels you surely can achieve real-time ray-tracing running at stable 20 to 25 fps.

Here are some of my results:

(real-time ray-tracing)

(bigger scene-renders)
These images take around 1 to 2 second to render.


If u have questions, please let me know.

  • DosenSupp2_0
5 Likes

if roblox doesn’t have an API, then why not we ask them to add it? this gonna have a huge impact on roblox if they really add it

If you’re referring to GPU API, as far as my understanding goes, it’s both a security issue and a hardware issue. I personally think Roblox can still do this if they truly wanted to, but it doesn’t seem to be their priority at the moment.

I believe Roblox could create top-level API that could work dynamically with any GPU architecture while also including security safe guards to prevent any potential security issues. I can’t really say this for certain as I have no real experience with GPU operations, only what little I’ve learned from different videos. But I do still think Roblox could figure it out, especially when other game engines allow you to do the same (though I realize that Roblox isn’t exactly in the same boat as there’s also mobile support and I’m sure this is much more complicated than I realize).

1 Like

i think to surely make the game secured is to make a admin or staff to test it before publishing it public or maybe other ideas

That’s not really practical. Roblox already limits what you can do with code, that way you can’t crash somebody’s computer (only their Roblox client), run malicious code outside of Roblox, DDoS servers, etc. I’m sure they can do the same for GPU code, however I do think it would be a more complex issue. I do believe that GPU sandboxing exists, but I have no idea what the limitations of that are, or how that scales with lower-end hardware like mobile devices. I wish I could give a better explanation, but as I stated in my previous reply, I don’t really know enough about this to give any solid answers. This is all things that I’ve either been told or learned through videos.

1 Like

I don’t know why no one asked to add it before and don’t worry im also a developer i
completely understand what you trying to say i made my own raytracing before and the problem is same as yours

I was told by somebody who was at one of the previous RDCs that security was the reason why. They asked while they were there. I wish I could find the original reply I got. I might not be recalling what they said correctly, but I’m pretty sure security was the main thing that was mentioned. I may edit this reply later if I find it.

This is a different reply, but it’s more in-depth:

I hope there’s eventually some way that we can use the GPU in the future, but it doesn’t seem like that will be the case anytime soon. It’s just a bit sad when there are so many impressive visuals that we’ll simply be unable to do. I’ve even seen some cool attempts at shaders using EditableImages, but obviously that’s not performant on the CPU.