normal_ext Material Type - PrismaticFlower/shaderpatch GitHub Wiki

A material type that works in a very similar way to "normal" materials in the game. It however has an extended feature set, including the ability to receive specular lighting from any light source.

Material Properties

DiffuseColor

Type: vec3

Set the diffuse color to be multiplied with the diffuse map.

UseSpecularLighting

Type: bool

Enable or disable the use of specular lighting on the material.

SpecularColor

Type: vec3

Set the specular color for the material. Has the same effect as the game's specular color parameter.

SpecularExponent

Type: float

Set the specular exponent for the material. The game's default specular exponent is roughly `64.0, so when in doubt use that.

GlossMapWeight

Type: float

Set the weight of the gloss map to a value between 0.0 and 1.0. A value of 1.0 indicates to use the gloss map while a value of 0.0 indicates to not use the gloss map and have the specular be at full intensity across the surface. Any other value mixes between full intensity and the intensity specified by the gloss map. When in doubt set this to 1.0.

UseParallaxOcclusionMapping

Type: bool

Enable or disable the use of Parallax Occlusion Mapping.

HeightScale

Type: float

Height scale for parallax occlusion mapping.

UseDetailMaps

Type: bool

Enable or disable the use of detail maps. See the textures DetailMap and DetailNormalMap.

DetailTextureScale

Type: float

Sets the scale for the detail textures. The model's texture coordinates will be multiplied by this before sampling the texture. Higher values will tile the texture more.

UseOverlayMaps

Type: bool

Enable or disable the use of overlay maps, which can be used to give an illusion of greater depth when using parallax occlusion mapping. Use cases include overlaying things like leaves or wires over top a material. See the textures OverlayDiffuseMap and OverlayNormalMap.

OverlayTextureScale

Type: float

Same as DetailTextureScale but for the overlay textures.

UseAOMap

Type: bool

Enable or disable the use of an AO map. See the texture AOMap.

UseEmissiveMap

Type: bool

Enable or disable the use of an emissive map. It'll be added overtop of the underlying material, letting you easily and selectively add glow to a surface. See the texture EmissiveMap.

EmissiveTextureScale

Type: float

Same as DetailTextureScale but for the emissive texture.

EmissivePower

Type: float

Value determining how much to increase or decrease the brightness of emissive textures. 0.0 is no change.

MultiplyEmissiveByVertexColor

Type: bool

When enabled the emissive map will be multiplied by the vertex color. When enabled the diffuse color will no longer be multiplied by the vertex color.

For optimization the vertex color is also multiplied with the game's material color in the vertex shader. This will usually only be relevant if you have applied something like Blink to the game material.

UseEnvMap

Type: bool

Enable or disable the use of an environment map. Like stock environment maps it'll be affected by the gloss map and specular color. See the texture EnvMap.

EnvMapVisibility

Type: float

An additional factor to affect the envrioment map's visibility. In the range [0.0001, 1.0], 1.0 is no change and lower numbers make the reflections less visible.

IsDynamic

Type: bool

When true marks the material as being for Dynamic Geoemtry.

DynamicNormalSign

Type: float

The sign of normals of dynamic materials. (Only affects dynamic materials.) Foliage billboards can have their normals incorrectly flipped when used with custom materials, setting this to -1.0 puts them around the right way. You should only use values of -1.0 or 1.0 here, although material_munge will take enforce so it isn't something to worry about in practice.

UseInteriorMapping

Type: bool

When true marks activates Interior Mapping.

InteriorRoomSize

Type: vec3

The size of each room interior room, in texture coordinates. Smaller values make more rooms, larger values make less rooms.

InteriorRandomizeWalls

Type: bool

When enabled will cause the walls (but not the ceiling and floor) of a room to be swapped around at random

InteriorRandomnessSeed

Type: uint

An unsigned integer that is added to the room index before it is hashed to get the "randomness" for the room. Affects InteriorRandomizeWalls and the cube map selection if a cube map array is used for the texture.

Texture Properties

  • DiffuseMap - Set the diffuse map, same as the game's normal diffuse texture. Should use BC7 or BC7_ALPHA format. (See here.) The alpha channel is never the gloss map, instead it is (if transparency is enabled in the material flags) transparency If the texture is being used in a transparent material or Interior Mapping then PremultiplyAlpha should be true. If the material will be used with HDR rendering then sRGB should be true, otherwise it should be false.

  • NormalMap - Set the normal map. Unlike pc_TextureMunge sp_texture_munge can not convert height maps to normal maps so the input must be a normal map already. If UseSpecularLighting is true then the format for the texture should be set to BC7_ALPHA and the gloss map for the material should be in the alpha channel. If the material is diffuse only then the format should be BC5.

  • HeightMap - Height map for parallax occlusion mapping. Format should always be BC4.

  • DetailMap - Set the detail map to be blended with the diffuse map by doing Diffuse * (Detail * 2). Format should be BC7.

  • DetailNormalMap - Set the detail map normal map to be blended with the diffuse map at runtime. Format should always be BC5.

  • OverlayDiffuseMap - Set the overlay diffuse map, same as the game's normal diffuse texture. Should use BC7 or BC7_ALPHA format. The overlay diffuse map will be alpha tested with a reference value of 0.5, if it is less than it the overlay will not be visible. If the material will be used with HDR rendering then sRGB should be true, otherwise it should be false.

  • OverlayNormalMap - Normal map for the overlay texture. Follows the same semantics as NormalMap.

  • EmissiveMap - The emissive map. Format Should be BC7 or BC6H_UF16. If the material will be used with HDR rendering then sRGB should be true if the format is BC7, otherwise it should always be false.

  • AOMap - The AO map. Format Should be BC4.

  • EnvMap - The environment map. Format Should be BC7 or BC6H_UF16. If the material will be used with HDR rendering then sRGB should be set to yes if the format is BC7.

  • InteriorMap - The interior map. Format Should be BC7 (or BC6H_UF16 if you're using a HDR interior map). If the material will be used with HDR rendering then sRGB should be set to yes if the format is BC7. Can be an array of cube maps created using texture_array_maker.

Dynamic Geoemtry Support

IsDynamic enables a material to be used with dynamic geometry. This is Shader Patch's way of saying it's intended for use with cloth and foliage billboards. Both of which are fully capable of having custom materials applied to them but are not capable of having their tangent vectors generated beforehand at munge time (a requirement for normal mapping).

The IsDynamic materials solve this by generating the tangents at runtime in the pixel shader. In order for this to work correctly the geometry must follow the following rule.

Each vertex making up a triangle in the geometry must have unique texture coordinates.

Multiple vertices can share the same texture coordinates but they can not be apart of the same face/triangle. Foliage follows this rule and most cloth follows this rule.

Interior Mapping

Interior mapping enables using a cube map (or an array of cube maps) to add rooms to a building without drawing extra geometry.

The InteriorMap can be created and used the same way as the EnvMap. Or texture_array_maker can be used to make an array of cube maps.

When using interior mapping the DiffuseMap should have the format BC7_ALPHA and PremultiplyAlpha should be yes. The sRGB property as always depends on if HDR rendering is being used.

Parallax Occlusion Mapping

Parallax occlusion mapping is a more sophisticated bump mapping method than normal mapping. It uses a height map to offset texture coordinates to give the illusion of depth. It can have some artifacts at sharp height transitions but in general is a very convincing effect, and it is a lot easier to use than tessellation based methods.

The specific algorithm used by Shader Patch displaces downwards from 1.0 in the height map.

Blurry height maps tend to produce better results than sharp height maps. Also if you intend to apply this to a model that isn't just a flat plane for best results bake the normal map and height map from a high detail version of the same model.