A 3D Engine in Roblox

Roblox 3D Engine


Introduction

I created a 3D Engine inside Roblox!
Yes I know this is strange, why make a 3D Engine in a 3D Game? Well I say, why not?
This engine includes not only basic stuff like object file loading, texturing, and shading, but it also includes so many helpful functions and even CFrame support! This engine also uses @Ethanthegrand14’s CanvasDraw module CanvasDraw - A powerful pixel-based graphics engine (Draw pixels, lines, triangles, read PNG image data, and much more!) - Resources / Community Resources - Developer Forum | Roblox to draw to the screen, and it is super fast! You can find the source code to the engine on my github along with a release that is easier to use: OrangeCash090/Roblox-3D-Engine: A satisfactory 3D Engine that works for roblox. (github.com)

Features

  • Object File loading
  • Textures
  • View Plane Clipping
  • Z Depth Buffer
  • Support for CFrame Matrices
  • Model functions like moving, rotating and sizing
  • And much more!

Other Information

To draw to the screen on Roblox, my engine uses the CanvasDraw module. I do not own this module, and it is only as optimized as the creator made it to be.
This also uses ported code from Python which this guy made: https://www.youtube.com/c/@FinFet. It also uses a triangle clipping function that was ported from this guy’s ConsoleGameEngine: https://www.youtube.com/c/@javidx9.

Note: This engine is not perfect, it still needs to be optimized more. Large amounts of triangles impact performance, and so does a lot of colors at once.

242 Likes

This is by far the best 3D engine I’ve ever seen on roblox. I made one myself awhile ago, but it had problems, especially with clipping large polygons, and it didn’t have texturing or a Z-buffer.

I am very impressed. This is my new favourite creation. Keep up the great work!

Also great use of CanvasDraw. Sticking to relatively low colour and resolution textures to ensure the module will run with a low load on the UIGradient compression.

47 Likes

I can see them now: Puppet Combo-esque games inside of Roblox! It’s crazy to think that there will be games made inside of games to make even more games, games-ception! This is one step further into making that a reality. I am also impressed.

17 Likes

I mean I don’t really see much purpose here, however this is still impressive, the fact you managed to make a 3D engine inside roblox blows my mind, like I have no idea how 3D graphics even work. Good job!

19 Likes

This is really cool, and I bet once DynamicImages release you could optimize drawing even further.

15 Likes

Yeah, might be possible to push the resolution to way higher numbers!!! Perhaps even native?!?!?!

9 Likes

I honestly like the pixelated look, but it really depends on how DynamicImage really works and how performant it is (imagine its somehow worse than CanvasDraw haha)

13 Likes

DynamicImage would have to be faster lol. CanvasDraw sucks at rendering high quality and high colour and noisy images due to the UIGradient compression getting over loaded with the amount of instances and per-pixel calculations needed

Any custom roblox canvas will be somewhat slow due to the sheer amount of instances being updated and rendered.

Hopefully DynamicImage will be like 3 to 10 times faster

9 Likes

That’s the big catch with all of these solutions that we see with these full-scale renders. It is too slow if you use just parts and the calculations (specifically the cframe and color operations) that you would do to greedy mesh them also aren’t worth it for real-time video. All of these solutions take almost a couple hundred milliseconds to process. I’ve done some testing and there is one cool thing though. If you do just parts and you cache the colors it actually is slightly faster than using the UIGradient trick and you are able to render video at 60 fps. with the colors taking up the entire canvas. UIGradient can also render video at 60fps but when there are a lot of changing colors on the screen it lags to about 30-40 fps. 30 fps is possible also at 200x200 with the part method. Hopefully, dynamic images will give us direct access to some sort of frame buffer so we can just dump an array of pixels and have the GPU render directly to the screen instead of creating multiple instances and rendering those individually. That’s why it is slow. The rasterization math is actually pretty fast.

11 Likes

This is a very cool project but doesnt viewport frames already do the same thing except with native support? I understand this is amazing and awesome but in terms of usability it doesn’t appear to offer anything beyond what a viewport can already do.

8 Likes

Yes this may sound useless but think of it this way: you have more freedom. With being able to have all of the vertices and triangles of meshes in real time, you can do collisions and other things. Also, viewport frames have limitations of what they can do like rendering lighting and not being able to render GUI instances. It may sound useless, but you have so much freedom down to what pixels are being rendered to the screen.

11 Likes

thats so cool, i would never had thought of making this :joy:

7 Likes

Incredible Resource!
I’ve used the recently released DynamicImage and !native and it made the code run 10x faster. I wish they released by now but it has a bug with CanvasFrames.

Keep up the good work :slight_smile:

7 Likes

10x faster?? just out of curiosity, have you tried increasing the resolution seeing how high you could get it to run? and if so, how high could you have made it until it started slowing down?

7 Likes

Increasing the resolution didn’t have much effect, I was able to go to 300x300 with decent FPS :smile:
The biggest problem isn’t the renderer but the math involved for reading triangle data. What I did was enabled the !native beta feature and used multi-threading and it helped plenty :slight_smile:

6 Likes

that’s incredible. Can’t wait for DynamicImage to come out. It will make CanvasDraw and custom pixel graphics on roblox much more usable!

7 Likes

You got it!

18 Likes

Holy crap. That is amazing. this is like a dream come true. I have so many custom renderer projects that I want having at least 200x200 running at 60 FPS, rather than 100x100 at almost 60 FPS.

7 Likes

Yep. I wish there was a way to make the math calculations faster on top of --!native and ConnectParrallel and DynamicImage

5 Likes

Incredible use of this module! I am so happy that you found out some optimizations. I see that you have made both physics and a character as well! That is truly amazing. I have also been experimenting with physics, DynamicImage, and Native, but I have never heard of this “ConnectParallel” How do you enable it/use it? I would love to include new optimizations to this base module, because even I am surprised that you rendered crossroads in decent fps!

9 Likes