Skip to main content

cfg.toml

GLFX configuration in TOML format (https://github.com/toml-lang/toml)

This file describes how the frame is rendered. The most important part is draw_order, a sequence of materials and special drawing operations. Each material is a combination of vertex, fragment shaders, and rendering pipeline state.

There are 2 kinds of materials:

  1. Materials for geometry from .bsm2 files where the material name corresponds to the material name in the input FBX file. Such geometry has UV, tangent space and bone skinning.

  2. Materials for face mesh geometry. Only vertex positions and UVs are available. The material name can be arbitrary and is defined only in cfg.toml. For optimization purposes, such material can draw only a subset of face mesh polygons.

Global settings#

  • warp_mesh - .bsm2 file with face mesh for morphing. By default, it's placed at the end of draw_order (described further).

  • warp_hair - hair compaction morphing parametres (for example warp_hair={inner=100,outer=200,mid=0.001,strength=0.4}), inner and outer radius in mm, mid point fraction in [0,1] range, strength in [0,1] range.

  • msaa - MSAA samples for effect framebuffer, 1, 2 or 4, default 1 (no AA)

  • shadowmap_size - size of dynamic shadow texture used by !glf_FACE_SHADOW material, default 256

  • adjust_znear - move z-near projection plane closer to the camera by this value in mm, default 150. Regular projection matrix from FRX includes z range just for the detected head. To draw anything in 3D in front of the face we need to adjust it. The recommended value is 500.

  • adjust_zfar - move z-far projection plane away from the camera with this value in mm, default 0. The recommended value is 1500.

  • bg_mips - true = glfx_BACKGROUND texture should include mipmaps, by default it's false.

  • debug_draw_frx - true = draw FRX mesh wireframe and landmarks

  • debug_draw_landmarks - true = draw FRX landmarks only

  • beauty_morphs - load beautification morph from the array of 7 morph mesh .bsm2 files: base mesh, and 6 blends. All meshes must have the same topology.

  • beauty_morph_deltas - load beautification morph from single .mdeltas file

  • face_subsets - array of .bsm2 files with face geometry subsets, for use by onface=true materials

  • beauty_lut - if true, beautify morph performs frame LUT post-processing, by default it's false

  • light_streaks - enables light streaks post-processing and allows to configure its parameters: threshold (0.0-1.0 range), color (RGB array in 0.0-1.0 range), and blend mode (add, screen, alpha)

  • draw_order - array of material names to be drawn in this order each frame

  • passes - array of render passes configuration filenames. See Render passes configuration for more information.

  • no_preload_textures - array of textures that are not preloaded while the effect is loading. If texture is passed to Api.meshfxmsg("tex") (see Api.meshfxmsg description for more information) in this array it will be lazy loaded.

Materials#

Each material is defined as TOML table inside the global materials table. The name of this table = the name of the material in the draw order. Each material has the following parametres:

  • vs - vertex shader file
  • fs - fragment shader file
  • blend - blendig mode ("off", "alpha", "premul_alpha", "screen", "add", "multiply", "coverage", "min", "max")
  • ztest - enable/disable depth test, default true
  • zwrite - enable/disable depth write, default true
  • colorwrite - enable/disable color write, default true
  • backfaces - if false will cull backfaces, default false
  • facelink - set to false to draw this material even if no faces are found, default true
  • shadow - geometry with this material will cast dynamic shadow on face (rendered by !glfx_FACE_SHADOW)
  • onface - materail will be drawn with FRX face mesh geometry instead of .bsm2, default false
  • mouth - if true the onface material has mouth-filling polygon, default false
  • face_subset - name of the face subset .bsm2 file, listed in global face_subsets array
  • samplers - table of shader sampler name = texture filename (or shader selectable texture index) pairs. Maximum number of samplers per material is 8.

Built-in materials#

Can be included in draw_order just as it is:

  • !glfx_FACE_Z - draw face mesh into depth buffer, no color changes
  • !glfx_FACE_MOUTH_Z - same as above but also draws polygons to cover the mouth
  • !glfx_FACE_SHADOW - draw face mesh with the blended dark shadow from dynamic objects
  • !glfx_UPDATE_BG - update glfx_BACKGROUND texture with current contents of the color framebuffer
  • !glfx_WARP_IMAGE - apply morph warping, depth buffer is cleared. Place it after the material(s) which you want to morph. By default, it's placed at the end of draw_order and applied to all materials.
  • !glfx_BEAUTY_MORPH - special optimized case of the morph warping for beautification

Example#

The Spider effect has a scene with two geometry instances:

  • !glfx_FACE for face mesh
  • tarantula.bsm2 for animated spider, geometry in this file has some polygons marked as "Spider" material and "Fur"

And cfg.toml defines draw_order as ["retouch","Spider","!glfx_FACE_SHADOW","Fur"]

  • "retouch" is a face mesh material which performs skin beautification and fills depth buffer with the face depth to hide the spider while it sits in the mouth.
  • "Spider" is an opaque material for the spider body and legs. It has shadow=true flag and this geometry will cast shadow on the face.
  • "!glfx_FACE_SHADOW" blends the spider shadow over the face.
  • "Fur" is a transparent material for the spider fur. It's drawn with alpha-blending, without backfaces culling and with depth writes disabled.
Last updated on