A 3D Engine in Roblox

I will be making another method for inputting an assetid instead, while also leaving this method so that there is backwards compatibility. I’ve also been working on image transparency, and sorting triangles doesn’t seem to slow down anything. This was a big worry for me, but now I am almost done with image transparency.

1 Like

That’s awesome. Can’t wait to see the end result.

Also do u think could have a version that takes a roblox scene and renders the models from ur camera instance? Then it would basically be a shader!

I could create a new version, and I know it’s possible because someone here has already done it. Once I finalize everything, though, I might start making games with this. My dream is to make a Mario 64-esque game using this Engine, which takes a lot of work.

1 Like

Yeah, This is so useful for anything, if you add custom camera CFraming instead of freecam.
There could be other qol stuff (that aren’t needed for sm64) like shaders as model textures and postproccessing. Oh, and isometric camera (maybe by setting 0 fov?).

(let’s hope nintendo doesnt sue you, prob by making it different than sm64? :person_shrugging:)

Those are my suggestions for the engine, by the way.

btuh, you aren’t calling :Clear() at the start of :Update() function.
that’s why it’s what I call ‘buggy mess’ (without the sky)

This is hands down one of the most impressive things I’ve seen on here. I believe dynamicimages will really help this engine further!

2 Likes

uhm, DynamicImages got renamed to EditableImages and they’re already being used on the engine :person_facepalming:

It’s what most games do since it isn’t really necessary and just takes more time for processing. If it bothers you, you can always change it.

ah, didn’t notice, but makes sense since you are also rendering the Skybox. also, you forgot to anchor the skybox to the camera so it doesnt look buggy when exiting skybox.

Yeah, I was also thinking ‘what if you could add custom shader textures to models?’, that’d definetly be cool, since you could make cool stuff like reflections and portals, Literally.
(i already suggested that:

)

If Roblox would give us access to GPU functions or acceleration then this could really shine.
I would love to see high performance 3D engines created in Roblox.

Currently if you want any acceptable real-time performance with more than 60fps I feel like you gotta utilize parallel Luau a lot and hope that enough players have processors with 8+ cores.

I have a 16 core CPU but even that’s gonna struggle at some point if you draw too complex graphics.

Is there an game on Roblox right now that utilizes this? I actually want to test what’s the highest amount of 3D objects/polygons I can draw before frame rate drops below 20.

For now there is no game that uses this Engine since native code and EditableImage are still in Studio Beta. You could always just open up studio and test the features there.

The biggest bottleneck with a 3D engine in Roblox is that rasterizing triangles is extremely slow. Triangle rasterization is not easy to parallelize at all because it requires access to an array for applying the pixels to the EditableImage, which can’t be shared unless it uses SharedTable. SharedTable is absurdly slow and basically unusable for something like this, so that won’t cut it either.

The only thing that is actually parallelizable is vertex transformation, but that also has its drawbacks…

1 Like

Even if it is slow, the results are far better than I would have ever expected. It runs like the N64, which I see as an achievement since it is literally Roblox. Yes, the methods are sometimes slow and there are optimizations out there, but I still am in awe with the thought of making my own custom game using everything from the ground up.

Last time I heard from you, you also mentioned creating a 3D renderer, how is that going?

I was more or less talking about what parts of a 3D engine would need to be parallelized for it to actually improve performance.
My 3D renderer currently still runs in real-time with thousands of triangles but has issues with fps drops when you get closer to an object, because bigger triangles takes a lot more time to rasterize. That’s mainly because I use resolutions above 512x512 but can’t really improve it a lot anymore, even with parallel.

Also tried my hand at making something close to OpenGL with custom vertex and fragment shader support but those require custom function calls in hotcode so that won’t work well at all in real-time… Did do some tests with it and got pretty cool results but just not feasible on high resolutions.

How many triangles are you able to render before there are noticeable fps drops? For me it is around 3000 triangles and that gets me to 30 FPS. This also accounts for sorting, clipping, and other preprocessing like texture correction. If you have any methods for optimization, could you share them with me?

Why is your 3D engine clipping triangles in the first place? Why does it need to do that?

I clip triangles since it makes the experience more realistic. Without triangle clipping, then triangles whose points are sometimes offscreen will not render. This will result in triangles spontaneously disappearing which looks pretty bad. With triangle clipping, I can seamlessly add two or more triangles in place of one so if some of the triangle’s points are offscreen, then it won’t just disappear.

Think of it as how triangles are supposed to have three points. If one point is offscreen, it technically does not exist. Therefore, the “triangle” cannot be rendered since it isn’t a triangle anymore.

New release which fixes some bugs that were brought up here, and also ideas that were suggested. Full description can be found on the release page.

Release v2.4 · HeroShiner46/Roblox-3D-Engine (github.com)

You will only need to do triangle culling, clipping is not actually required and only adds more triangles to rasterize which drops performance. I get that the ConsoleGameEngine guy was doing that too for some reason but you don’t actually need it in practice. You can completely get rid of it if you also make some changes to the triangle rasterizer.

How would I remove the clipping while also not rendering points that are offscreen? If I don’t remove points that are offscreen, then this will reduce performance. What is your solution for when some points of a triangle or even all points are offscreen?