Released BBMOD - Bring 3D animated PBR models into your GMS2 games!

kraifpatrik

Member
BBMOD

BBMOD is a 3D model and animation format specially crafted for GameMaker Studio 2. It is accompanied by a conversion tool (BBMOD CLI), as well as GML library that allows you to load, animate and render BBMOD files without any hassle.

BBMOD CLI utilizes Assimp to load third-party model formats, so any model that Assimp can load can be converted to BBMOD. A few examples of such model formats are OBJ, COLLADA or the industry standard FBX.

BBMOD also comes with PBR shaders, fully supporting metallic workflow. This makes it compatible with assets that you would use in professional 3D game engines.

Links
 
Last edited:

kraifpatrik

Member
EDIT: This post contains outdated information about project BBAC, which later evolved into BBMOD.

Hey everyone, when this thread is in the WIP section, I realized I maybe could write some development logs between releasing new versions of the tool, so here it is, my first devlog!

Porting code base over to C++
Throughout the many years I've been working with GM, I've always been writing everything in pure GML, without using any DLLs (except for the 39dll in those times :D), as I felt like it was a part of pushing the boundaries of GM. But recently, while working on BBAC, I realized how beneficial it could be to write specific code in C++ instead and that avoiding it just for sake of "being pure GML" does not really help anything. BBAC is a Windows only tool anyways, not a cutting edge game or a tech demo. And so I decided that I will port some of the code base over to C++ (like D3D / MOD and BBMOD loading), as well as create some new libraries that will allow us to do things that are impossible with pure GML.

Job system
One of the biggest GM's disadvantages is that it does not support multithreading. Right now, If you have a lot of bigger models in your BBAC project, the entire application freezes until they are all loaded. To address this, I've been working on a multithreaded job system in C++. The system is pretty simple, first there are created as many threads as there are CPU cores. Each thread takes a job from a shared queue, executes it and then puts it into another queue, which is then accessed from GML (to know that the job has been finished and to get it's result). The jobs themselves are also written in C++ and they are spawned from GML. Here is a little example of a SleepJob, that just makes the thread that is executing it sleep for given number of seconds.

JobsCpp.PNG
The job's definition in C++, alongside a function that allows for it to be spawned from GML.

JobsGML.png
A little test in GML.

SleepJobs.gif
The output of the test. The application window remains being fully interactive throughout the entire time.

In BBAC, this job system will be mainly used for import and export of models.

Using Assimp to load third party model formats
Until now, all BBAC was able to import was OBJ models, and only in a limited form (they had to be triangulated, had to have normals, etc.). Fortunately, there is an amazing open source library called Assimp, which allows to load practically any format ever, including the industry standard FBX (you can see the whole list in the link). Part of the DLL that I'm working on is a wrapper for this library. As I'm writing this, I already have a working version of a loader of mesh hierarchies, including their transformation matrices.

Next up will be loading materials, skeletons and animations. BBAC will then of course also support to export the loaded models into a custom binary format, which will be more suitable for in-game use and will be loadable without the DLL. Since rendering of objects consisting of multiple meshes and / or animated models is a bit more complicated and requires more scripts, you can also expect that there will be an example GM:S1.4 and GMS2 project with the scripts included.

I think that's all I have for now! Thanks for comming by and speding your time by reading my first little devlog. It's already kinda too late for me and I'm sleepy, so it's hopefully not too poop :D
 
Last edited:

kraifpatrik

Member
EDIT: This post contains outdated information about project BBAC, which later evolved into BBMOD.

A new version EA 2019.10.2 EA 2019.10.3 (there was an error in the list of supported files, please download again!) has been released! BBAC now utilizes Assimp to load 3rd-party file formats like OBJ, FBX, COLLADA and many more! Animations, materials etc. are not yet supported. If a loaded file consists of multiple meshes, they are all joined into one.

unknown.png
Doomguy from Quake 3 Arena (*.md3)

  • *.3d
  • *.3ds
  • *.3mf
  • *.ac
  • *.ac3d
  • *.acc
  • *.amf
  • *.ase
  • *.ask
  • *.assbin
  • *.b3d
  • *.blend
  • *.bvh
  • *.cob
  • *.csm
  • *.dae
  • *.dxf
  • *.enff
  • *.fbx
  • *.glb
  • *.gltf
  • *.hmp
  • *.ifc
  • *.ifczip
  • *.irr
  • *.irrmesh
  • *.lwo
  • *.lws
  • *.lxo
  • *.md2
  • *.md3
  • *.md5anim
  • *.md5camera
  • *.md5mesh
  • *.mdc
  • *.mdl
  • *.mesh
  • *.mesh.xml
  • *.mot
  • *.ms3d
  • *.ndo
  • *.nff
  • *.obj
  • *.off
  • *.ogex
  • *.pk3
  • *.ply
  • *.pmx
  • *.prj
  • *.q3o
  • *.q3s
  • *.raw
  • *.scn
  • *.sib
  • *.smd
  • *.stl
  • *.stp
  • *.ter
  • *.uc
  • *.vta
  • *.x
  • *.x3d
  • *.x3db
  • *.xgl
  • *.xml
  • *.zae
  • *.zgl
 
Last edited:

kraifpatrik

Member
EDIT: This post contains outdated information about project BBAC, which later evolved into BBMOD.

Alright, since the last post I've been focused on loading of scene-graphs (models consisting of multiple meshes, each with their own transformation) as well as animations and I can happily say that I got them working! It took a few fights with Assimp's confusing data structures and row-major vs column-major matices and their multiplication order issues in GM, but it was worth it.


Bob with lamp (MD5), available from here: https://www.katsbits.com/download/models/md5-example.php
Currently it's all in a very rought state and I still have a lot of work to do till the next release, but you can expect that when it comes out, you will be able to load your animated fbx, collada, md5, you-name-it models into your GM games. There will be some GM-imposed limitations like maximum number of bones per model, but since I'm making this to work on any target platform, using only GML + GLSL ES, I can't do any workarounds for that. Hope you like the progress so far, see you next time! Cheers!
 
Last edited:

kraifpatrik

Member
Updates: As we are continuously moving all of our projects to GMS2, we have discontinued distribution of scripts and shaders for loading and rendering BBMOD files in GMS1.4. The resources now have their own GitHub repository here https://github.com/blueburn-cz/BBMOD and they can be added into your GMS2 project using Catalyst. The resources are released under the MIT license, so their backport for GMS1.4 and redistribution is possible, but won't be done officially by the BlueBurn team.
 

kraifpatrik

Member
Updates: A new version 2.0.0 of BBMOD was just released! This version introduces a completely new file format, a completely rewritten GML library and materials and animations support! All source code, including source of a C++ conversion tool, is available for free on GitHub. Unfortunately, with this relese we are also removing the BlueBurn AssetCreator (BBAC) from here. Writing the GUI was a lot of additional work, which was holding us back from actually adding new features to the BBMOD file format. The first post has been updated accordingly, please check it out for new info and links! Cheers!
 

kraifpatrik

Member
EDIT: This post contains outdated info about a demo project for BBMOD, which was never finished due to time constraints.

I'm currently working on a little demo project that will showcase BBMOD in practice. Its full source code will be released for free of course!
 
Last edited:

kraifpatrik

Member
The latest documentation is now available online on our website - https://blueburn.cz/bbmod/docs/ - so you can check it out without downloading anything! Please, help us improve the docs by letting us know whether you find the docs helpful or not. You can do so using the "Yes" / "No" buttons at the bottom of each page. Cheers!

Screenshot from 2020-04-14 11-59-09.png
 

kraifpatrik

Member
A new version 2.0.4 was just released! I've hit up @TheSnidr on Discord for some tips and tricks regarding speed, and after the chat we had I was able to make the animation script run 2x faster! The character that I'm using for tests is the Ybot from mixamo.com, which has 52 bones. Before the optimizations, the animation script took around 2ms in VM, now it runs in 0.9ms. In YYC it is 0.3ms. I think that's pretty good improvement, especially considering that models which I'm going to use in my games may have 12 bones at max maybe? :D Anyways, make sure to download the update if you're using BBMOD! And once again, thank you @TheSnidr for helping out :)
 

kraifpatrik

Member
Updates: If you have been following my work, you may have noticed that I have multiple ongoing GM3D projects. One of them being Push3d, a 3D level editor for GameMaker Studio 2, where I was also implementing a physically based deferred rendering pipeline. Well, I thought that maybe it would be a lot more helpful if BBMOD already came with some cool shaders, and so I've decided to implement PBR here. Once this update comes out, anyone using BBMOD will be able to use models textured in Substance Painter or Megascans from Quixel in their GM3D projects. Right now I have support only for HDR image based lighting (think Marmoset Skyshop for Unity), but further down the road I would also like to add support for dynamic lights. Stay tuned for more info!

Following images have been rendered in real-time (5000 fps_real on my PC lol) in 4K and then downscaled to 720p.




PBR model by Andrew Maximov: https://artisaverb.info/PBT.html
HDR sky by Greg Zaal: https://hdrihaven.com/hdri/?c=sunrise-sunset&h=kiara_1_dawn
 
Last edited:

kraifpatrik

Member
Updates: Yeah, It's been a long time, I know... The dev doesn't take that long, I just take weeks or months long breaks and then work for a few hours, I'm sorry :D Now for the good stuff:

Static & dynamic batching
We are planning to use BBMOD in our 3D online FPS - BBP - which is currently in pre-alpha, and though it already runs pretty good even on old laptops, a lot of performance issues come from its rendering system, especially number of draw calls. For this reason I've decided to implement two variants of batching into BBMOD. The first one is static batching, which allows you to put multiple models with the same vertex format and the same single material into a single vertex buffer. Using this batching you can render hundreds of pre-transformed models in a single draw call.

cars_100.jpg

The image above contains a 100 rougly 25,000-poly cars, all placed into a single static batch. As you can see, my PC could render this 2,500,000-poly vertex buffer at 6000-7000 fps.

The second kind of batching I call dynamic batching, which is a kind of "fake instancing". It allows you to put many copies of a single model into a single vertex buffer, with each copy having its own id in the vertex format. You can then pass position, scale and rotation (or any kind of data really) for each instance through uniforms to a shader.



The image above shows 64 cars rendered using dynamic batching - they are all in a single vertex buffer and they are all rendered in a single draw call. This ran a bit slower than static batching, at 5000+ fps, which was mostly because of the update of each car's transformation in the step event. Without the update in the step event, the rendering itself is still blazing fast (same as static batching), but since the entire point of dynamic batching is the possibility to transform the models, I think that having the update is a more representative example.

BBMOD GUI
While developing the PBR shaders and testing them on models created for engines like UE4 and Unity, I've found out that it's pretty tedious to edit the PBR textures so they fit the layout required by BBMOD (e.g. it needs to have normals in RGB and roughness in A, but I had two different textures for each, and so I had to combine them manually in GIMP). For this reason I've decided to revive the GUI tool, except its new version will serve a different purpose - convert a model into BBMOD, preview it with textures defined through a graph and then export the textures in the required layout. Here are some vids from a super early development version of the new GUI tool:



The whole PBR update for BBMOD will be released when the GUI tool is finished, since I find it essential for work. Cheers!
 
Last edited:

JaimitoEs

Member
Sorry but I couldn't find this answer ... Is this content listed as open source? I am very curious to create a 3D character and test it in my editor. Amazing work!:):):):):)
 

kraifpatrik

Member
Sorry but I couldn't find this answer ... Is this content listed as open source? I am very curious to create a 3D character and test it in my editor. Amazing work!:):):):):)
Oh, it's not explicitly noted here, but when you check out the GitHub repo, you can see that it is all available under the MIT license. So yeah, it is free & open source, though we are the only ones developing it :D Thanks for the praise :)
 

IGameArt

Member
Hey, I'm working on a scene capturing tool for a light probe system in GM that would work swimmingly with this!

1594254164887.png

This uses CMFT and ImageMagick to capture renders from any scene in GM, then converts them to radiance and irradiance maps in an equirectangular projection. I was about to start implementing an asset editor for defining meshes and materials but since you're working on one for the BBMOD format I suppose all I really need to do is work on the probes system instead. :p
 

kraifpatrik

Member
Little updates: I'm currently working on upgrade from 2.2 to 2.3, using the new GML features! The library is still 100% compatible with previous versions, but there is additionally a new object oriented API, wrapping the legacy array+enum structs and adding some new functionality. For example check out this BBMOD_AnimationPlayer (at the end of the script), which wraps the bbmod_animation_player_* functions, plus enables you to pause, resume, set animation playback speed and jump between animation frames without any additional work (previously you had to write code for that yourself)! I've also changed my mind and I will be releasing the update before the GUI tools is finished, as it will actually make its development easier. All the update is missing right now is some final polish and documentation, so it shouldn't take too long. Cheers!
 

kraifpatrik

Member
Updates: As I've said the last time, one of the things missing for the next release is a documentation. As you know, BBMOD has an online HTML documentation available at https://blueburn.cz/bbmod/docs/. This documentation is generated from comments in BBMOD's source code by a tool that I've created - GMDoc (available for free at https://github.com/kraifpatrik/gmdoc). I definitely still wanted to use GMDoc for the next release, but it didn't support the new GMS2.3 GML features, like functions and structs, so I had to first upgrade it. I've written from scratch a completely new tokenizer and a parser of GML, using which can now GMDoc gather documentation for macros, enums, global variables, functions, structs and their properties and methods. I've also added support for some new tags like @private, which disables printing out the documentation, @deprecated and @obsolete, which marks an API as deprecated or obsolete respectively, or @readonly, which marks a variable as read-only and tells you that you shouldn't modify it. It took me a few days to implement this, but I think the result is worth it! Here is a little sneak peek into a WIP documentation for the next release of BBMOD. Cheers!

docs.png

EDIT: I forgot to mention that the next release will come with the model conversion tool compiled as a DLL, so you will be able to create BBMOD files directly from GML! So yeah, now you know :D
 
Last edited:

kraifpatrik

Member
BBMOD 2.4.0 is OUT!

Does it render Quixel Megascans?

Hell yeah, it does! (This image has cost me $22.99. You're welcome... :D)

Does it handle motion captured animations from Mixamo.com?

Hell yeah, it does! (Check out this though!)

Does the batching work?

Hell yeah, it does! (See this and this.)

Now go grab it from the Marketplace and create something amazing with it! It's FREE! And don't forget to see the documentation when you're at it. If have any issues using it, then either join the Discord or ask me here. Cheers! :)
 

Elodman

Member
I'm currently working on a little demo project that will showcase BBMOD in practice. Its full source code will be released for free of course!
...
Someone said DEMO, huh ??? -- Now come I !!!

Feel yourself invited to the fabulous, extremely popular & evergreen Demoscene thread - like Dr. @TheSnidr !

Anyway congrats on & thanx for creating, releasing your 3D thingies, already seeing much use for them in da phuture !

(Much more interesting than the CRUD related job, I did in your capital 20 years ago. But at least there I began to like Knödel & Velkopopovicky Kozel - in spite of being an abstinent, until then..) :cool:
 
Is that possible to use 3d models with 2d backgrounds? For example the model is 3d from side view but in a 2d side scrolling background. I want to make a game like that.
 
Last edited:

kraifpatrik

Member
Updates: I'm currently working on the next update for BBMOD. Alongside some convenience API changes, it will also come with new improved HDR rendering and a new set of sky textures! Check out the following screenshots, they both use the same HDRI, but the first one has a high camera exposure value and the second one has a low one. Notice how the sun is still very bright in both images.


High exposure


Low exposure

The character model used in the screenshots is Brute from Mixamo.com. Extension Physical Starlight And Atmosphere for Blender was used to generate the HDRI.
 
Last edited:

Sybok

Member
Nice man! Looking awesome!

Could be just this crappy old iPad 4 I’m on, that is stuck in iOS 10 or something.
 

peterpan

Member
Absolute newby here when it comes to 3D in GameMaker.
I would really love to implement 3D Models in my top-down 2D Game and I have been fiddling around with BBMOD to get that to work.
Unfortunately, all my 3D Models are ratheropaque / transparent in itself (I can see the legs when watching through the head).
I know that this is happening when I don't apply the camera that is set up in the example project, but I don't really want to use a 3D Camera, as it will mess with the Layer System and it's probably not the easiest to get the camera to look at the Game like it does when it's just a plain 2D Camera.
Is there any solution for this which I am not seeing?
 

kraifpatrik

Member
Absolute newby here when it comes to 3D in GameMaker.
I would really love to implement 3D Models in my top-down 2D Game and I have been fiddling around with BBMOD to get that to work.
Unfortunately, all my 3D Models are ratheropaque / transparent in itself (I can see the legs when watching through the head).
I know that this is happening when I don't apply the camera that is set up in the example project, but I don't really want to use a 3D Camera, as it will mess with the Layer System and it's probably not the easiest to get the camera to look at the Game like it does when it's just a plain 2D Camera.
Is there any solution for this which I am not seeing?
You actually don't need a 3D camera to use BBMOD, @Chreech Okash was also using BBMOD in a sidescrolling game without it. It's likely also not a z-buffer issue, because BBMOD by default enables in when rendering models. It's hard to tell what's actually going on without seeing what it looks like, so I guess that you either need to use parameters -lh or -iw when converting models. Try different combinations of BBMOD.exe model -lh=true/false -iw=true/false and see what happens. Please hop onto the Discord if it doesn't work out. It's easier for me to help you there.
 

peterpan

Member
You actually don't need a 3D camera to use BBMOD, @Chreech Okash was also using BBMOD in a sidescrolling game without it. It's likely also not a z-buffer issue, because BBMOD by default enables in when rendering models. It's hard to tell what's actually going on without seeing what it looks like, so I guess that you either need to use parameters -lh or -iw when converting models. Try different combinations of BBMOD.exe model -lh=true/false -iw=true/false and see what happens. Please hop onto the Discord if it doesn't work out. It's easier for me to help you there.
Thanks a bunch! Inverting the winding order of the vertices is what fixed it :)
 

kraifpatrik

Member
Damn, I always forget to post updates here! So here you go - these are some pics from BBMOD GUI, which I'm currently working on. It is still very much WIP, but as you can already see, the visual style is inspired by GMS2 itself. This is to make BBMOD GUI feel like a natural extension of GMS2, to make you feel like home when working with it :) Hopefully YoYo won't have any objections 🙏

import.jpg
Model import dialog. There's a little spoiler in there - next version of BBMOD will allow you to configure x,y,z axis on import, so you won't have to re-export models from Blender etc.

color-picker.png
This is not the original GMS2 color picker - this is its reimplementation in BBMOD GUI! You will be using this when defining material colors.

material-editor.png
Material editor nodes. Still very rough. I would like to add some previews for textures etc.
 

Mert

Member
Hi @kraifpatrik I keep getting the following error
GML:
___________________________________________
############################################################################################
ERROR in
action number 1
of Create Event
for object <undefined>:

Trying to get texture from non-existing sprite.
at gml_Script_bbmod_set_ibl_sprite (line 105) -        bbmod_set_ibl_texture(sprite_get_texture(_sprite, _subimage), _texel);
############################################################################################
gml_Script_bbmod_set_ibl_sprite (line 105)
gml_GlobalScript_bbmod_shader (line 134) - bbmod_set_ibl_sprite(_spr_ibl, 0);
Here's my code : CREATE
GML:
modelData = new BBMOD_Model("heart.bbmod");
matData = new BBMOD_Material(BBMOD_ShDefault);
matData.BaseOpacity = sprite_get_texture(sp_Heartstopper, 0);
DRAW
GML:
bbmod_material_reset();
modelData.render(
    [matData], undefined);
bbmod_material_reset();
Only these. What could be the problem?
 

kraifpatrik

Member
@Mert Only thing that comes to my mind is the included files - please check if you have a BBMOD/Skies folder with two PNGs in your included files.
 

Mert

Member
@Mert Only thing that comes to my mind is the included files - please check if you have a BBMOD/Skies folder with two PNGs in your included files.
Yess that solved it. But now I have another issue:
GML:
Could not generate input layout (is there a mismatch between your shader and vertex format?)
Draw failed due to invalid input layout
Draw failed due to invalid input layout
Draw failed due to invalid input layout
Draw failed due to invalid input layout
Draw failed due to invalid input layout
Draw failed due to invalid input layout
(and goes on like this)
 

kraifpatrik

Member
@Mert There could be a few reasons for that, let's see.
1) Have you modified vertex format settings when converting your models? The default shaders are compatible only with the default settings. You can check the created _log.txt file to see the vertex format of the converted model. It should be position, normal, texture coords, tangent and bitangent sign(, bone indices and weights for animated models).
2) If you haven't changed the settings, are you using a correct shader? Regular models should use BBMOD_ShDefault, models with bones BBMOD_ShDefaultAnimated.
 

Mert

Member
@Mert There could be a few reasons for that, let's see.
1) Have you modified vertex format settings when converting your models? The default shaders are compatible only with the default settings. You can check the created _log.txt file to see the vertex format of the converted model. It should be position, normal, texture coords, tangent and bitangent sign(, bone indices and weights for animated models).
2) If you haven't changed the settings, are you using a correct shader? Regular models should use BBMOD_ShDefault, models with bones BBMOD_ShDefaultAnimated.
Oh thanks for noticing me that. Sorry to take up your time.
The models I got from Sketchfab didn't work, but they do not work in Blender neither. So I tried other models.
Also, set up materials and feed them in order(as it is logged on .txt file)

Everything works perfectly!
Thanks again
 

kraifpatrik

Member
BBMOD GUI Early Access has been released!

BBMOD GUI is a tool using which you can convert models and animations from common formats to the BBMOD format, similarly to what BBMOD CLI (command line interface) does, except here you get a live preview of what your model is going to look like when you render it in your game! BBMOD GUI additionally allows you to create, preview and export textures for each material of your model, as well as create custom textures for image based lighting from cubemaps or equirectangular maps (supports RGB, RGBM, LogLUV and HDR)!

We are releasing BBMOD GUI under two licenses - one for both non-commercial and commercial use, which is available from the Marketplace, and another one for non-commercial projects only, which is available for free on our official website (requires a registered account).

Cheers!

0.jpg
1.jpg
2.jpg
3.jpg
 
Last edited:
Top