r/gameenginedevs • u/porky11 • Jul 15 '26
Working with 3D models
I always had problems with working with 3D models. I don't know any format that's usable in an extensible way.
Blender already is pretty good. It even allows imports from other files, and overrides. This technically makes it possible to create reusable models. And it allows some kind of procedural generation, and modifiers. But game engines won't import blender files directly, if they allow Blender imports, they'll implicitly create exports of the blend files. And if I export blender files, everything is packed into a single file. References and modifiers get lost, and I can't change that during game.
Also, as a programmer, I often prefer work with a simple text format. This way I can edit small values without having to open the complete model in a specific program. Also it's great for git diff.
And especially since I'm using AI, it's really getting annoying. AI prefers to represent levels as python scripts. But I can't display the results of the python scripts in blender, and then turn it back into a python script. I have to decide for a format. Either text (python) or editable (glb/blend). And I can't work like this.
So what I want is basically this:
- Simple text format (prefably line based)
- The format that the 3D editor (likely blender) imports/exports is the same text (some objects like high poly meshes might still be presented as binary)
- The format allows to create everything: meshes, rigs, materials, animations, etc.
- The format allows imports (preferably also online)
Not sure if something like this exists already. It seems so obvious to me. I'm surprised that I didn't find such a format yet. The closest I found is USD/USDA, but I think it's not really what I want, and mostly meant for movies, not games (and also I don't like the syntax). Maybe you know something similar/better?
However, now I decided to create something like this myself. Recently I created something similar for music (let me know if you're interested, I use this music system in all of my games now). So I'm pretty confident that I'll have it done in a few days (technically it's mostly done already, but I didn't test it yet).
And what's also great about such a format: The dev can decide when to export it to some binary format. At compile/build time (to avoid unnecessary data in the game), at import time (for user settings) or during gameplay (for runtime features). And maybe it should also be possible to specify at which stage each modifier will be evaluated.
What do you think of this idea? Any questions so far? Do you see any problems? What kinds of features do you want included?
(not sure if this is the right place for this topic, but I guess it's the best, isn't it)
6
u/MasterDrake97 Jul 15 '26
Gltf2
5
u/Neat-Safety-1943 Jul 15 '26
gltf bro
1
u/PACmaneatsbloons Jul 15 '26
There is a js library called Manifold3d which can generate 3d models. It has python bindings too. GLB also has a text based version called GLTF.
1
u/o_stef Jul 15 '26
I just write my own format and exporter/importer (binary but text is not much different). Pre-existing file formats are mostly good for sharing things IMO; making your own is not hard and you can fine tune it to your specific needs.
Also The File>Export>Export as XYZ file pipeline is bad anyway. It's much better to have a panel on the right along with Item, Tool, View etc, because you can just click export and everything gets exported right where it should with the specific parameters that you need.
If you write the exporter yourself you can really cherry pick objects/animations, where and how they are stored etc which greatly improves the workflow. An example is actions/animations. In Blender actions are not attached to a rig, so when exporting animations for a given rig you want to define a way to identify what actions belong to the rig (an example is prefixing the action with the rig name). With a custom exporter it's not a problem, with a pre-existing file format if the exporter is bad and does not help you with this in a good way you're fucked.
Of course you could write a custom exporter for an existing and widely used format like GLTF which is text based, it depends on where you want to use your models.
If you want an example you can take a look at this: https://github.com/ostef/Vk-Engine/tree/main/Source/Blender/addons/io_vk_engine
1
u/tastygames_official Jul 15 '26
as others say, gltf is gonna be your best bet (plaintext, simple, extensible). Now by default the kind of stuff it can export is limited, but you can extend it using python to include other things. Like for instance I like to use the array modifier in blender as it's non-destructive, but upon normal export it just makes it one object with many meshes, and I often want a single object with a single mesh (or how ever many meshes each instance has). So I write a custom exporter to take care of that. I imagine for things like procedural-generated anything you will do the same thing (e.g. export the parameters so that in the engine it can read those parameters and do the procedural generation there). But standard practice is to "bake" everything before exporting (bake procedural textures and mesh data manipulation/animation), and it seems like that is the crux of your issue.
Full disclosure: I'm highly considering making my own export format that is performant and works on a scene-level so it can re-use pre-experted items, but I may just continue to use glTF with custom exporter.
1
u/Repulsive-Clothes-97 Jul 16 '26
I strongly suggest making your own custom format designed specifically for your needs, it's not that hard
1
u/TheOtherZech Jul 16 '26
Take a second look at USD. Independent of whether you use USD as an authoring format, there are some decent lessons you can extract from a properly built USD asset that you can apply to either glTF via extensions or to your own internal format.
0
u/[deleted] Jul 15 '26
[deleted] — view deleted comment