mo3d: 3D library for Mojo

Hello wonderful Mojicians, I thought I would share my (very immature) side project! Introducing https://github.com/thomas-gale/mo3d "mo3d is aiming to be a 3d graphics library built from the ground up in Mojo, with minimal external dependencies. It utilizes only a basic subset of SDL2 for rendering, employing parallelized copying of Mojo-rendered scenes directly to texture data. Unlike traditional shader pipelines, mo3d aims to rethink rendering by consolidating shaders into Mojo code, while planning for future support of Mojo’s hardware accelerators." I'm a full stack developer in my day job at a computer aided design company. However, I'm new to Mojo and not an expert in any of these fields. Just driven by natural curiosity! I'm building this on the foundation of various good starting points (which I've tried to correctly attribute throughout the codebase) such as https://github.com/msteele/mojo-sdl for the sdl2 window. Any feedback and ideas are welcome!
14 Replies
Helehex
Helehex2w ago
Very cool We started a group for game dev related things in mojo if you're interested
Ryulord
Ryulord2w ago
Nice! You may also want to check out these sdl bindings as they're a little bit more up to date than msteele's (I also found theirs very helpful for getting started) https://github.com/Ryul0rd/sdl-bindings
GitHub
GitHub - Ryul0rd/sdl-bindings
Contribute to Ryul0rd/sdl-bindings development by creating an account on GitHub.
Tom Gale
Tom Gale2w ago
Oh sure, that would be great!
btokarzewski
btokarzewski2w ago
Awesome! I am working on a geometry kernel for creating 3D geometry and all kinda of geo operations. Will definitly try your project to display the geometry. 🙂
Tom Gale
Tom Gale7d ago
Oh nice, right now it's in a very basic/exploratory stage while I slowly learn things. It's just rendering basic signed distance fields, and that's limited to just spheres! I'm assuming you'd want a height map / mesh renderer for your geo data? I've played a bit with this sort of thing in the past, you can do nice things like accelerating hit calculations on those triangles by placing them in a bvh/octree structure. Thanks for the interest!
ModularBot
ModularBot7d ago
Congrats @Tom Gale, you just advanced to level 1!
btokarzewski
btokarzewski7d ago
@Tom Gale Ohh, spheres only, you say. Rendering meshes would be probably a preffered method. My geo library will be for modelling BREPs and I will add Mesher at some point. @Tom Gale bvh and octree sounds like https://github.com/AcademySoftwareFoundation/openvdb to me.
Tom Gale
Tom Gale7d ago
Great shout, the sparse stuff in openvdb is very interesting. I definitely need to add it to my reading list. Thanks. I also like the way sparse concepts are handled in taichi https://docs.taichi-lang.org/docs/sparse
Spatially Sparse Data Structures | Taichi Docs
Prerequisite: please read the Fields, Fields (advanced), and SNodes first.
btokarzewski
btokarzewski7d ago
@Tom Gale heard about taichi, but never learned or used it. Didn't want to be locked in a framework. The article itself is quite nice. Thanks 🙂
Tom Gale
Tom Gale6d ago
Had some time this evening to work a bit more on the ray tracing basics! I enjoyed and finished off the Ray Tracing in a Weekend tutorial and I'm moving on to the Ray Tracing the Next Week tutorial (I'm looking forward to experimenting with how to get a rudimentary ECS working with AABB/BVH acceleration structure). I'm also keen to starting to think about performance profiling - the naïve/brute force monte-carlo sampling is now sub 1fps (CPU) on this more complex scene with motion blur.
No description
Hammad Ali
Hammad Ali5d ago
Amazing work man I honestly thought this was OpenGL/Vulkan in mojo though😅
btokarzewski
btokarzewski11h ago
@Tom Gale May I create a feature request on your GitHub repo about displaying polygons? I could then "subscribe" to the issue, which will help me monitor the functionality and eventually start using your repo.
ModularBot
ModularBot11h ago
Congrats @btokarzewski, you just advanced to level 2!
Tom Gale
Tom Gale10h ago
Sure, go for it! It might take a while as I'm a bit slow! However, thank you for your interest! Can you roughly outline what you're trying to achieve? I'm assuming you might want something like direct lighting to ensure you get interactive/real-time performance? The indirect lighting solution is still naïve and slow, I'm planning on attempting to speed it up with MIS/Metropolis in the future. Long term (multi-year goals), we have powerful enough hardware and a good enough renderer implementation that we can always use indirect lighting. Ah right, yeah I'm afraid this project is a bit more primitive at the moment. I'm just learning and building a scene representation (ECS) and renderer (Path Tracer) from the ground up in mojo. I think folks are working on bindings to libraries like wgpu if you look around in #community-showcase . I guess in that case you could write a more conventional shader pipeline.
Want results from more Discord servers?
Add your server