Home Artists Posts Import Register

Content

A lot of people have been asking for a proper model exporter for Pragma recently, so I've decided to implement support for exporting models in the glTF file format. It's standardized and specifically tailored for PBR assets, which makes the import into other PBR Engines/Blender particularly easy. Textures (including normal maps, metalness/roughness textures, etc.) are automatically assigned as well.


The export-function includes:

• Automatic generation of ambient occlusion maps (if they don't exist)

• Automatic re-scaling of the models to meters

• Conversion to match Blender's coordinate system

• Includes the rig and all of the animations of the model

• Conversion to standard normal maps (e.g. if self-shadowed bumpmaps are used)

• Automatic conversion of the textures to png, bmp, tga, jpg, hdr, dds or ktx. I can also add vtf support if there's demand

• Works with maps / level geometry

• Can be used to export Source Engine and Source 2 Engine assets

• Conversion of Source 2 textures to a standardized metallic-roughness PBR model

• Since Pragma already converts Source Engine assets to PBR, the exporter can take advantage of that fact as well

The last two points are still a work-in-progress, and there's still one or two issues with Source 2 textures I have to fix, but everything else is ready. I've released the update earlier today, for now the export function is command-line only, but I will integrate it into the Filmmaker interface soon as well.

To use it, start Pragma and load a map (any map will do, you can load an empty map by typing "map empty" into the console). Once loading is complete, you can use the following console command:

util_export_model -model <modelName> [-verbose 1/0] [-binary 1/0] [-export_animations 1/0] [-export_skinned_mesh_data 1/0] [-export_images 1/0] [-image_format png/bmp/tga/jpg/hdr/dds/ktx] [-enable_extended_dds 1/0] [-generate_ao 1/0] [-ao_samples 32/64/128/256/512] [-ao_resolution 512/1024/2084/4096] [-scale <scale>]

For example, if you wanted to export the model "models/props_2fort/tank001.mdl" from TF2, you could simply run:

util_export_model -model "props_2fort/tank001.wmd" -verbose -image_format png -generate_ao -ao_resolution 1024 -ao_samples 40

(Make sure to remove the "models/" prefix and replace the ".mdl" postfix with ".wmd".)

If you want to export a map, you can use:

util_export_model -model "maps/ctf_2fort/world_1.wmd" -verbose -image_format dds -generate_ao 0

(Replace "ctf_2fort" with the name of the map.)

Models will automatically get ported to Pragma if they haven't been already, but if you're exporting a map, you will have to make sure to have loaded it in Pragma at least once before executing the command.

The principle is the same for Source 2 assets:

util_export_model -model "characters/gman/gman.wmd" -verbose -image_format png -generate_ao -ao_resolution 1024 -ao_samples 40

Good news is that Source 2 now uses standard eyeball meshes with bones, so the eyes should work properly in Blender as well! Bad news is, I haven't quite figured out how the morph targets in Source 2 models are stored yet, so those are not yet included. I can confirm, however, that Source 2 still uses the same facial animation system with no major changes, so it should be compatible in theory.


Anyway, here's an explanation for each of the parameters:

  • verbose: Prints out debug information during the export process - Disabled by default
  • binary: Exports as a binary glTF file (may be useful for very large models, should decrease the file size) - Disabled by default
  • export_animations: Includes the model animations in the export - Enabled by default
  • export_skinned_mesh_data: Exports the model's rig/skeleton/vertex weights - Enabled by default
  • export_images: Exports the textures used by the model (including normal maps, etc.) - Enabled by default
  • image_format: Specifies the image format for the exported images. Currently supported are png, bmp, tga, jpg, hdr, dds and ktx. Default is png.
  • enable_extended_dds: Optional flag to enable export of DDS images with the DX10 header extension. If dds is chosen as image format, this allows the use of BC4, BC5, BC6 and BC7 S3TC compression, however this is very poorly supported and will not work with Blender or most other programs. - Disabled by default
  • generate_ao: Generates an ambient occlusion map for all of the materials used by the model, unless they already exist - Enabled by default
  • ao_samples: If ao generation is enabled, this specifies the sample count used to generate them. Higher values will create more accurate ao maps, but also increase the generation time. Default is 40.
  • ao_resolution: The resolution for the generated ao maps. Higher resolution will increase the generation time.
  • scale: All meshes (and animations) will be scaled by this value. Default is 0.025 (which will convert to meters).


Another thing that I've had a few requests for is the ability to load multiple maps at once. That's not quite possible yet per se, however since map geometry is now stored as models, they can now be imported as such:

https://youtu.be/YQocJCDBuYA 


Here's the changelog for the latest update:

Version: v0.9.3
- Added support for Source 2 Engine assets (models, materials, textures and maps)
- Added `util_export_model` console command for exporting model assets to glTF format
- Map geometry is now stored as models (which means you can place maps as models)

- Fixed issue where some displacements would be rendered with incorrect colors
- Fixed various crash instances

Patreon preview version:
- Added model catalog (wip)
- Added actor catalog (wip)
- Added panorama and orthographic Cycles render options

Files

Comments

No comments found for this post.