Patchers - hakasapl/PGPatcher GitHub Wiki

This page will outline descriptions of each patcher available in PGPatcher, their requirements, and what they do. Note that if requirements are not met for a particular mesh/record combination, this does not disqualify the patcher from patching the mesh, it only does for that record. PGPatcher will duplicate meshes where necessary to ensure combinations that do meet requirements still are patched successfully.

Pre-Patchers

Pre-patchers are run on meshes prior to shader patchers.

Fix Mesh Lighting (ENB Only)

This patcher will apply the techniques described in Catnyss's article to fix glowing meshes. This is for ENB only as CS fixes this at an engine level. When using this patcher fixed mesh lighting is no longer required.

Requirements

  • [Mesh] Shader property type is default
  • [Mesh] lighting effect 1 (soft lighting) field is higher than 0.6

What it Does

  • [Mesh] Sets lighting effect 1 (soft lighting) field to 0.6

Shader Patchers

This is the core of PGPatcher and the reason it exists. Shader patchers are what defines the material types on any given shapes in a mesh. Note that you will likely have different mods able to patch a single shape in a mesh. This is where the conflict viewer is useful to tell PGPatcher which mod you want to win if there is a conflict.

Parallax

Also called Complex Parallax sometimes (They are the same thing). Parallax is the most basic shader type PGPatcher patches for. There are no special shader properties and it only requires a parallax height map texture (usually _p.dds suffix).

Requirements

  • [Plugin/Mesh] Parallax map must exist with prefix which matches the diffuse or normal texture
  • [Plugin] Mesh is not used as GRAS record type
  • [Plugin] Mesh does not have single pass MATO
  • [Mesh] Mesh does not have attached havok (BSBehaviorGraphExtraData block cannot exist)
  • [Mesh] Shape is not skinned
  • [Mesh] Shape does not have alpha property (NiAlphaProperty cannot be attached to shape)
  • [Mesh] Shader property is of default, parallax, or environment mapping shader type before patching
  • [Mesh] Shader property is not a decal (No decal or dynamic_decal shader flags)
  • [Mesh] Shader property does not have soft lighting, rim lighting, or back lighting flags

What it Does

  • [Plugin/Mesh] Adds matching parallax height map texture to parallax slot of texture set
  • [Mesh] Sets shader property type to parallax
  • [Mesh] Clears environment mapping, multi-layer parallax, or unused01 (pbr) shader flags if they exist
  • [Mesh] Sets parallax shader property flag
  • [Mesh] Enables vertex colors in both shape and shader

Complex Material

Also called Complex Parallax Materials sometimes (They are the same thing). Complex material allows mod authors to add environment mapping, glossiness, metalness, and parallax all in one texture. It is also far more compatible than parallax, as can be seen in the requirements below.

Requirements

  • [Plugin/Mesh] Complex material map must exist with prefix which matches the diffuse or normal texture. PGPatcher considers an environment mask file complex material if the alpha channel has 50% or more non-white (255) pixels.
  • [Plugin] Mesh is not used as GRAS record type
  • [Mesh] Shader property is of default, parallax, or environment mapping shader type before patching
  • [Mesh] Shader property flags anisotropic lighting cannot be combined with any of soft lighting, rim lighting, or back lighting
  • [Mesh] Shader property flags soft lighting, rim lighting, and back lighting cannot all be enabled
  • [Plugin/Mesh] Single-pass MATO and shader property flags soft lighting, rim lighting, or back lighting cannot exist together

What it Does

  • [Plugin/Mesh] Sets matching complex material texture to environment mask slot of texture set
  • [Plugin/Mesh] Sets dynamic cubemap on environment/cubemap slot of texture set, unless dynamic_cubemap is false in matching CM meta json.
  • [Mesh] Sets environment map scale to 1.0, unless environment_map_scale is defined in CM meta json, in which case it uses that value.
  • [Mesh] Sets specular strength to 1.0, unless specular_strength is defined in CM meta json, in which case it uses that value.
  • [Mesh] Sets specular color to white (1.0,1.0,1.0) if complex material texture contains metalness (blue channel). If specular_color exists in CM meta json, those values are used instead.
  • [Mesh] If CM meta json contains glossiness field, that value is set to the glossiness shader property. Otherwise it is unchanged.
  • [Mesh] Clears parallax, mult-layer parallax, or unused01 (pbr) shader flags if set
  • [Mesh] Sets environment mapping shader flag
  • [Mesh] Sets specular shader flag if complex material texture contains glossiness (green channel). If specular_enabled is defined in CM meta json, that is used instead.

TruePBR (CS Only)

TruePBR is a community shaders only material specification that allows for a lot more flexibility than the others on this page. Because of this, PGPatcher handles patching somewhat differently using mod-author defines JSON files instead of looking at the PBR textures. PBR allows for everything complex material covers, in addition to a lot of extra options.

Requirements

  • [Plugin/Mesh] PBR JSON that matches the texture set / mesh being queried. See PBR Matching Fields
  • [Plugin] Mesh is not used as GRAS record type
  • [Mesh] Shader property flag facegen rgb tint is not set

What it Does

See Mod Authors PBR Page as PBR uses a custom json schema that does far more than the other shader patchers.

Shader Transforms

Transform patchers are able to, where possible, transform a base shader type to a better variant.

Upgrade Parallax to Complex Material

This patcher will dynamically upgrade parallax maps to complex material. This is important for cases where parallax cannot apply because of its compatibility requirements. The visuals will otherwise look the same. The performance should be very similar as well. PGPatcher will upgrade only when required, not everything, in order to save on performance as much as possible.

Requirements

What it Does

  • Generates a new environment mask texture, where the R, G, and B channels are full black. The alpha channel is set to the R (single channel) of the matching parallax height map. This texture is saved BC3.
  • Patches for Complex Material using the generated texture

Post-Patchers

Post patchers are run on meshes after shader patchers have set the material for the shape.

Disable Pre-Patched Materials

This patcher will unpatch prepatched meshes where needed. Essentially the same functionality as auto parallax, but offline, and it works for both parallax and complex material, not just parallax. You don't need this if you are confident you don't have any prepatched meshes installed, though it won't hurt to have enabled even if you don't.

Requirements

  • [Plugin/Mesh] If parallax shader type is set, the parallax slot texture does not exist
  • [Plugin/Mesh] If environment mapping shader type is set, and the environment mask and environment slots are not empty, the environment mask or environment textures do not exist

What it Does

Essentially just does the inverse of the shader patchers and restores the shader type to default, while removing relevant flags and texture slots.

Fix Vanilla Subsurface Scattering

In a lot of cases, especially on foliage, vanilla subsurface lighting can make them appear too dark. This patcher aims to solve this issue. It will use a little bit more VRAM because of the added texture, but performance should otherwise be unchanged.

Requirements

  • [Plugin/Mesh] Diffuse and 3rd slot (Glow) are the same texture
  • [Mesh] The shader property flag soft lighting is set

What it does

  • Generates a new subsurface map that is a delighted version of the diffuse map. Saves as BC2.
  • [Plugin/Mesh] Replaces the 3rd slot (Glow) texture slot with the generated texture.

Add Hair Flow Map (CS Only)

Requires hair specular. This patcher will apply flow maps from your load order to texture sets in meshes and plugins.

Requirements

  • [Plugin/Mesh] A flow map (_flow.dds) that matches prefix with the normal map in the texture set

What it Does

  • Sets backlight texture slot to the matched flow map texture

Global Patchers

Global patchers apply on the mesh as a whole rather than an individual shape, which the other patchers above do.

Fix Effect Lighting (CS Only) - Experimental

This patcher enables effects to receive ambient lighting (things like waterfalls and mountain fog, etc.). The technique is the same as the one used in CS Particle Patch, however, that mod would still be useful as the mod author makes some changes by-hand which an automated tool would not be able to replicate.

Requirements

  • [Mesh] Shader property is an effect shader
  • [Mesh] Shader property flag uniform_scale is not already set
  • [Mesh] Shader property flags effect_lighting IS set

What it Does

  • [Mesh] Sets lighting influence to 255
  • [Mesh] Sets shader property uniform_scale