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
GRASrecord type - [Plugin] Mesh does not have single pass
MATO - [Mesh] Mesh does not have attached havok (
BSBehaviorGraphExtraDatablock cannot exist) - [Mesh] Shape is not skinned
- [Mesh] Shape does not have alpha property (
NiAlphaPropertycannot be attached to shape) - [Mesh] Shader property is of
default,parallax, orenvironment mappingshader type before patching - [Mesh] Shader property is not a decal (No
decalordynamic_decalshader flags) - [Mesh] Shader property does not have
soft lighting,rim lighting, orback lightingflags
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, orunused01(pbr) shader flags if they exist - [Mesh] Sets
parallaxshader 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
GRASrecord type - [Mesh] Shader property is of
default,parallax, orenvironment mappingshader type before patching - [Mesh] Shader property flags
anisotropic lightingcannot be combined with any ofsoft lighting,rim lighting, orback lighting - [Mesh] Shader property flags
soft lighting,rim lighting, andback lightingcannot all be enabled - [Plugin/Mesh] Single-pass MATO and shader property flags
soft lighting,rim lighting, orback lightingcannot 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_cubemapisfalsein matching CM meta json. - [Mesh] Sets environment map scale to
1.0, unlessenvironment_map_scaleis defined in CM meta json, in which case it uses that value. - [Mesh] Sets specular strength to
1.0, unlessspecular_strengthis 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). Ifspecular_colorexists in CM meta json, those values are used instead. - [Mesh] If CM meta json contains
glossinessfield, that value is set to theglossinessshader property. Otherwise it is unchanged. - [Mesh] Clears
parallax,mult-layer parallax, orunused01(pbr) shader flags if set - [Mesh] Sets
environment mappingshader flag - [Mesh] Sets
specularshader flag if complex material texture contains glossiness (green channel). Ifspecular_enabledis 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
GRASrecord type - [Mesh] Shader property flag
facegen rgb tintis 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
- Parallax requirements are NOT met, and Complex Material requirements ARE met
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 lightingis 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
backlighttexture 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_scaleis not already set - [Mesh] Shader property flags
effect_lightingIS set
What it Does
- [Mesh] Sets lighting influence to
255 - [Mesh] Sets shader property
uniform_scale