Released BBMOD - Bring (animated) 3D models into your GMS2 games! (support for FBX, COLLADA, OBJ and much more)

kraifpatrik

Member
BBMOD

BBMOD is a 3D model and animation format specially crafted for GameMaker Studio 2. It is accompanied by a conversion tool written in C++, as well as GML library that allows you to load, animate and render BBMOD files without any hassle. The conversion tool utilizes Assimp to load third-party model formats, so any model that Assimp can load can be loaded into GMS2 using BBMOD. A few examples of such model formats are OBJ, COLLADA or the industry standard FBX.

Pictures


MD5 from https://www.katsbits.com/download/models/md5-example.php

Motion captured FBX from mixamo.com

Example code
GML:
/// @desc Create
gpu_set_zwriteenable(true);
gpu_set_ztestenable(true);

mod_character = bbmod_load("Character.bbmod");
mat_head = bbmod_material_create(BBMOD_ShDefaultAnimated, sprite_get_texture(SprHead, 0));
mat_body = bbmod_material_create(BBMOD_ShDefaultAnimated, sprite_get_texture(SprBody, 0));
anim_idle = bbmod_load("Idle.bbanim");
animation_player = bbmod_animation_player_create(mod_character);

bbmod_play(animation_player, anim_idle, true);

/// @desc Step
bbmod_animation_player_update(animation_player, current_time * 0.001);

/// @desc Draw
var _aspect = window_get_width() / window_get_height();

matrix_set(matrix_view, matrix_build_lookat(5, 5, 5, 0, 0, 0, 0, 0, 1));
matrix_set(matrix_projection, matrix_build_projection_perspective_fov(60, _aspect, 0.1, 8192));

bbmod_material_reset();
bbmod_render(mod_character, [mat_head, mat_body], bbmod_get_transform(animation_player));
bbmod_material_reset();

/// @desc Clean Up
bbmod_animation_player_destroy(animation_player);
Installation
To add resources required for loading and rendering of BBMOD files into your project, use Catalyst, the open-source package manager for GameMaker Studio 2:
Code:
catalyst install blueburn-cz/bbmod
NEW For those who don't use Catalyst, there's also a complete yymp bundle available to download from GitHub. This information is not yet available in the documentation, so when using this instead of Catalyst, just skip the Installation part. We will make sure to update the docs as soon as possible :)

Documentation and help
NEW The latest documentation is now available online at https://blueburn.cz/bbmod/docs/

An HTLM documentation can be found alongside releases in the GitHub repo (click the "free download" button down below). Its source is also available on GitHub in the docs_src folder. You can also build it into an HTML format yourself using GMDoc. If you need any additional help, feel free to contacs us here on the forums, or you can join our Discord server.

Links

 
Last edited:

kraifpatrik

Member
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
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
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!
 

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
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
 
Top