Call to Arms - Gates of Hell: Ostfront

Call to Arms - Gates of Hell: Ostfront

Total Graphics Conversion: PBR Shader for Gate of Hell
 This topic has been pinned, so it's probably important
FNSOIDATHQ  [developer] 14 Aug @ 7:03pm
3. Development Guide for Modders


If you want to use this shader in your mod, do not simply copy and paste all the files, because
  • The launcher uses a hash based on load order and size/modification date of shader files to determine whether shaders are the same as last run. This means that meaningless duplicate files will still be treated as different shader results, causing launcher to delete cache files that are supposed to optimize game performance.
  • Different shader codes are basically incompatible with each other. If someone uses your mod together with other mods, it may easily lead to unnecessary compilation errors.

Please only include the shader files you actually modified, or better yet, create a separate mod specifically for your shader changes!
If you did not modify the shader code at all, simply declare this mod as a dependency.

*Checking whether the shader logic is identical after load order resolution is not practical.



If you want to import a model using pure PBR textures (metallic, roughness, AO and emissive),

New MTL and texture samples for previews and testing can be found in "mod/resource/entity/misc/materials/pbr" folder.

3.1 mtl Structure
When both
  • {height "xxx"}
  • {lightmap "xxx"}
exist in mtl, shader will activate pure PBR mapping mode.

Among them:
The height entry, originally used for parallax mapping of ground texture, is now used to index indirect specular cube map.
The lightmap entry, originally used for pre-baked lightmap, is now used to store a four-channel mask texture.

In addition, additional parameters=
{parallax_scale 10000}: is used to enable automatic Phong to PBR conversion including indirect specular reflections.
{full_specular}: is used to enable support for emssive texture in pure PBR mode.

3.2 Indirect Specular Map
The indirect specular map is a texture that stores pre-filtered environment light information. We sample it to calculate the indirect specular reflections in PBR rendering.
The pre-made indirect specular map is stored in "mod/resource/texture/common/envmap".
This is not a mipmapped environment map! Textures stored in mipmaps are calculated using a special method, which is completely different from pure mipmaps.
These textures are obtained from Poly Haven under a CC0 license. Thanks to artist and website for their generosity!

You can simply access our pre-made indirect specular map using {height "$/envmap/env"}.

3.3 Texture Mapping for Pure PBR Rendering
After enabling pure PBR texture mode with changes in section 3.1. Textures in MTL will be mapped to PBR according to following logic:
Original Texture
Target Texture
diffuse.rgb
base color.rgb
diffuse.a
alpha
specular.r
metallic
specular.gba
emssive.rgb
height.rgb
Indirect Light Specular Cube Map
lightmap.r
roughness
lightmap.g
empty
lightmap.b
ambient occlusion(AO)
lightmap.a
parallax occlusion mapping (have not implemented)
*Note: rgba= rad,green,blue,alpha= red,green,blue,alpha four texture channels

3.5 Shader Development Guide
I will (sooooon!) be writing about this on my website and github.
Last edited by FNSOIDATHQ; 26 Aug @ 4:30pm