A 3D Engine in Roblox

Gotcha >:D

Since I’m using Roblox to do some of the heavy engine calculations (which lessens overall strain since Luau is still interpreted for now). I’m also able to get away with using roblox functions that can determine if something is being “rendered” (Camera:WorldToScreenPoint()) to ignore it from doing project_points() or any other expensive math calculations (It’s pretty much just scuffed culling).

(Note: There’s piano in the background)

Before:

After:

2 Likes

I was also trying to experiment with adding more ‘lights’ on top of the current light_dir, it was really fun experimenting with it

5 Likes

Wow, I never thought of that! I should probably add my own culling so that it renders better anyways. Cool stuff!

3 Likes

Bug (when trying to load the helicopter):

The Fix:

2 Likes

Issue found with LoadGroupFromName in V2 : (

I was wanting to manipulate CFrames of separate meshes that are in one obj. I was testing this Quake 3 model for an experiment but it would result in this error.
RobloxStudioBeta_I1GdCJTbHR

Not sure what’s going on. But after doing a bit of digging I found a few culprits but not a solution:

For whatever reason, it would start in here
RobloxStudioBeta_mgY1IbCvuf

If parts[1] and voffset are equal or if voffset is greater, the face_verts table would now have invalid indexes (peep the warnings) therefore causing the problem

TLDR: vertoffsets and texoffsets are causing issues.

RobloxStudioBeta_WraUpof1xt

Note: This only occurs with LoadGroupFromName and not LoadFromName
quakeguy.lua (46.9 KB)

2 Likes

Yeah LoadGroupFromName was kind of experimental when I was creating the engine, and I guess I didn’t really fix it. I realize now how ugly and inefficient my past code was, and I’m now rewriting the whole thing with full obj file support.

4 Likes

Could you give a basic tutorial on how to import .obj models? Last time I tried to do it the textures weren’t mapping correctly. I think there are export settings that need to be set and im not sure what they need to be for your .obj renderer

2 Likes

I am working on support for more features, but for now this is what you need to do:
Get an object file with only one texture (or merge the textures),
Make sure the object file only includes triangle faces,
Make sure all the uvs and stuff are written (this is probably automatic),
Export it, make a new ModuleScript, and paste the object file data into it. Make sure it is a variable called “obj” and it is wrapped in [[]].
Use your CanvasDraw image importer and create the image.
Put it as a child of the ModuleScript and then set a variable called “texture” to it.

I will write this down and make like a Wiki section in Github. It’s just kind of hard to do all of these things at once and make the module user friendly.

3 Likes

Rewrote the entire module with fixes, optimizations, and support for other things. Also, the object works now! (Using missingtexture.png). If you ever have any other issues, please make a post on the issues tab of the repository so it is easier for me.

7 Likes

New support for transparency! Check the latest releases for the new version and use Model.Transparency to change an object’s transparency!


8 Likes

Absolutely goated update. Keep it up!

I don’t know if that update includes this, but you should implement alpha transparency for the textures as CanvasDraw texture sampling includes Alpha values (since we’re working with PNG images)

local Colour, Alpha = ImageData:GetPixelXY(X, Y) -- Alpha ranges from 0 to 255
6 Likes

LOL brotha went straight to making minecraft. Nice kek

3 Likes

Ah, it’s not just Minecraft. This is Minecraft…with a Bloxy Cola! Their character can drink their soda in the mines. :cool:

4 Likes

Oh I forgot about the textures! Yes I can add those easily by changing the color property to include alpha from your canvasdraw module. I use GetPixelFromImageXY, does that also return the color and alpha too?

Edit: This requires a lot more work than I thought. I have to individually now separate every triangle and render the opaque ones before the transparent ones, which will slow down performance (maybe?). I will add this update, but I will try to find a better way to do this.

2 Likes

It will slow down performance a lil bit, but it’ll be worth it for some of your maps you have here.

Also you might wanna just do a boolean check on a transparent pixel rather than doing alpha blends if you wanna keep your framerate up.

Yes and it’s fine to use, but that function is deprecated as ImageData:GetPixelXY is slightly faster and more efficient as it has direct access to the pixel look-up table.

1 Like

It seems it is impossible for me to use the alpha value on DynamicImage because no matter what it blends with the background from the original image (white). I’ve tried drawing the triangles before others, but it still doesn’t work. This is why I am using alpha blending since it is all I can do. Maybe when DynamicImage comes out and you implement it in CanvasDraw it will work.

Edit: The biggest challenge is sorting the triangles since there are two transparency values for each triangle now. I might have to just make Transparency change the texture’s internal alpha instead.

I’ve been following the whole “Making Roblox Pixelated” quest from the start, and I think it finally is starting to reach its end. You did it. You made Roblox pixelated with astonishing performance compared to any other design. You literally just need DynamicImage, a bunch of updates/fixes, and optionally some documentation. Fantastic work. Pixel Roblox has been a lot harder than it has seemed.

2 Likes

3d engine inside a 3d engine? 3d engineception O_O
i actually have a good use for this so if you want your game to look like its on the playstation 1 then use this and it will make your game look like that

1 Like

You should add some settings and an option to disable the perspective correction on the texture mapping for ps1-like fun