NIF Shader Properties
Shader properties are a subgroup of NiProperties meant to define and control the shader used by the geometry.
While there are eleven Shader Properties defined in the code, only seven are directly usable.
Contents
They have several common fields:
- Name: Block name, only needed for animation.
- Num Extra Data List: Total number of Extra Data blocks.
- Extra Data List: A number of Extra Data blocks can go here.
- Controller: Only applicable for BSShaderPPLightingProperty or Lighting30ShaderProperty. Either a BSRefractionFirePeriodController or a BSRefractionStrengthController.
- Flags: Unused, safe to leave at 0 or 1.
- Shader Type: Needs to match the Shader Property or things including crashes can occur.
- Shader Flags: See table below.
- Shader Flags 2: See table below.
- Environment Map Scale: Only used by BSShaderPPLightingProperty and Lighting30ShaderProperty if environment mapping is enabled. Controls the brightness multiplier of the cubemap.
- Texture Clamp Mode: Determines how off-atlas UVs are managed. Clamp stretches the edge pixels infinitely, Wrap tiles the texture continuously.
- File Name: The displayed texture on geometry. Only used by NoLighting, TallGrass, Tile, and SkyShader Properties. It alone is enough to display a texture on non-animated objects, however NiTexturingProperty with NiSourceTexture is necessary if you are animating the texture.
BSShaderNoLightingProperty
Marks a mesh as not being affected by lights from the scene, including the sun. It has five unique fields.
- Flags: Supposedly controls whether or not smooth shading is enabled on the attached geometry, defaults to 1.
- Falloff Start Angle: At this cosine of angle falloff will be equal to Falloff Start Opacity.
- Falloff Start Opacity: Alpha falloff multiplier at Start Angle.
- Falloff Stop Angle: At this cosine of angle falloff will be equal to Falloff Stop Opacity.
- Falloff Stop Opacity: Alpha falloff multiplier at Stop Angle.
The latter four mostly used to control when and by which angle an object with a NoLightingProperty fades out independently of the entire NIF, but can also be used to pull off lenticular effects.
BSShaderPPLightingProperty
Shader Property for per-pixel lighting shaders. It shares five unique fields with Lighting30ShaderProperty.
- Texture Set: A BSShaderTextureSet. What the textures are used for is determined by certain Shader Flags. By default, it's:
- Texture 1: Diffuse Map/Alpha Map
- Texture 2: Normal Map (Gloss / Specular as alpha channel)
- Texture 3: Glow Map/Highlight Map (when assigned to hair meshes)
- Texture 4: Height Map (Parallax) (Needs "Parallax Shader Index 15" shader flag set)
- Texture 5: Environment Map (Cubemap) (Needs "Environment Mapping" shader flag set)
- Texture 6: Environment Mask (Needs "Environment Mapping" shader flag set)
- Refraction Strength: A 0-1 value that sets the level of refractive distortion when certain Shader Flags are set. Isn't based on a physically accurate refractive index.
- Refraction Fire Period: The rate in which the texture is animated when Fire_Refraction is set.
- Parallax Max Passes: The total number of parallax passes the mesh can have every frame. Results start looking decent around 60.
- Parallax Scale: A multiplier for the strength of the parallax effect.
Lighting30ShaderProperty
Property for a pixel shader 3.0 upgrade to BSShaderPPLightingProperty. Changes are minimal, cubemap orientation is flipped and blackened decals on very large by volume NIFs display as normal. Trades CPU for GPU usage. Used by the engine for decals, hair and advanced effect combinations (e.g. parallax + cube mapping).
Despite the name, the actual shader model version is 2.0 since 3.0 shader package is unobtainable in vanilla. Cubemap lighting breaks on weather transition.
Shader Flags modify how the Shader Property works. While there is overlap, not all flags are usable with every Shader Property.
Flags used by each Shader Property (WIP) Properties not mentioned here don't have any flags at all.
Shader Property | Flags Used 1 | Flags Used 2 |
---|---|---|
PPLighting/30Lighting | Specular*, Skinned, Single Pass, Environment Mapping, ZPrepass*, FaceGen, Parallax, Landscape*, Refraction, Fire Refraction, Eye Environment Mapping, Hair, Dynamic Alpha, Local Map Hide Secret, Window Environment Mapping, Tree Billboard, Multiple Textures, Remappable Textures, Decal, Dynamic Decal, Parallax Occlusion, External Emittance | LOD Landscape*, LOD Building*, NoFade, Refraction Tint, Vertex Colors*, No LOD Land Blend*, Env Map Light Fade, Wireframe, Show In Local Map, Skip Normal Maps*, Alpha Decal, No Transparency Multisampling, Stinger Prop |
NoLighting | Skinned*, Vertex Alpha, Empty, ZPrepass*, Dynamic Alpha, Local Map Hide Secret, Remappable Textures, Decal, Dynamic Decal, External Emittance*, ZBuffer Test | ZBuffer Write, LOD Landscape*, LOD Building*, NoFade, Vertex Colors*, Wireframe, Show In Local Map, PreMult Alpha*, No Transparency Multisampling |
Tall Grass | Low Detail* | Vertex Lighting*, Uniform Scale*, Fit Slope*, Billboard Env Fade* |
* is set automatically by the engine
Flag Descriptions
Shader Flags 1:
- Specular: Enables specular lighting on the object.
- Skinned: Enables skinning. Required or else lighting breaks on skinned objects.
- Low Detail: Does nothing, was supposed to do something for grass.
- Vertex Alpha: Enables vertex alpha. Like colors, but with alpha values. Not set automatically, unlike Vertex Colors.
- Motion Blur: Does nothing. Leftover from unfinished per object motion blur shader.
- Single Pass: Limits geometry rendering to a single shader pass - limits the number of lights hitting the geometry to 3.
- Empty: Enables the "Falloff" settings on NoLighting shaders, can allow shading to fade when viewed from different angles.
- Environment Mapping: Enables environment mapping on the object.
- Alpha Texture: Used in NoLightingShaders and removed by the engine at runtime in BSShaderPPLightingProperty shaders.
- ZPrepass: Set automatically for certain alpha combinations (which?).
- FaceGen: Enables FaceGen on the object, updates skin textures based on the race, enables fake subsurface scattering. (Makes skin have a slight red glow near lights.)
- Parallax Shader Index 15: Enables parallax shading. The effect is pretty weak, combine with Parallax Occlusion for it to be noticeable. Will force single pass limiting the amount of lighting passes and will cause bugged lighting if too many lights hit the object.
- Model Space Normals: Aka world space normals. Uses the normal map exclusively for lighting information instead of mesh normals and tangents. Used solely for Landscape LOD. See object space normals.
- Non-Projective Shadows: Not used.
- Landscape: Enables landscape texturing support, engine only.
- Refraction: Enables static refraction, uses RBG from the normalmap to determine the pattern. If used, other textures are unnecessary.
- Fire Refraction: Enables animated refraction, scrolls through the normalmap?
- Eye Environment Mapping: Different form of environment mapping, light doesn't fade and the cubemap is set automatically to the default eye cubemap. Specular lighting is also disabled.
- Hair: Enables hair shaders. Glowmaps are used as highlight textures.
- Dynamic Alpha: Will dynamically create a NiAlphaProperty at runtime if the current strip does not have NiAlphaProperty. The property created does not function (No testing or blending flags are set) and serves no useful purpose. For this reason it's best to avoid using this flag.
- Local Map Hide Secret: Marks the object as being ignored by the local map shader and it doesn't show up in the local map in the Pip-Boy.
- Window Environment Mapping: Broken from how it worked in Oblivion, simply flips the cubemap orientation in Fallout 3 and New Vegas.
- Tree Billboard: Engine only, used for Tree LOD.
- Shadow Frustum: Does nothing.
- Multiple Textures: Tells the game to skip loading textures listed under the Shader Prop's BSTextureSet. This is intended to be used with Texture Sets and is supposed to skip redundant texture loading. If the object doesn't have a Texture Set applied, the mesh will behave like it has a missing texture.
- Remappable Textures: Does nothing.
- Decal Single Pass: Enables unique behavior meant only for decals. Limits amount of lighting passes for performance and will cause bugged lighting if more then 2 lights hit the same object. Helps prevent Z fighting for decals. Geometry with this flag will fade sooner then normal meshes, fade distance is determined by the fDecalLOD INI Settings in falloutprefs.ini.
- Dynamic Decal Single Pass: Same as above.
- Parallax Occlusion: Enables parallax occlusion.
- External Emittance: Enables external emittance on the object. Requires External Emittance to be set up in the Reference using a model with such flag.
- Shadow Map: Does nothing.
- ZBuffer Test: Enables depth testing for NoLightingShaders.
Shader Flags 2:
- ZBuffer Write: Enables depth writing for NoLightingShaders.
- LOD Landscape: Enables the landscape LOD shader.
- LOD Building: Marks geometry as object LOD - impacts draw order of the geometry.
- No Fade: Disables geometry fading if the root Node is BSFadeNode.
- Refraction Tint: Tints refraction?
- Vertex Colors: Enables vertex coloring. Added automatically if the NiGeometryData block has vertex colors.
- 1st Person: Marks an object as being in 1st person for viewmodel purposes. Engine function - can't be set manually.
- 1st Light Is Point Light: Unused, meant for HairShaderProperty.
- 2nd Light: Unused, meant for HairShaderProperty.
- 3rd Light: Unused, meant for HairShaderProperty.
- Vertex Lighting: Used on TallGrassShader, required for proper lighting when combined with all white vertex colors.
- Uniform Scale: Used on TallGrassShader, disables random grass size scaling.
- Fit Slope: Used on TallGrassShader, makes grass conform to landscape slopes.
- Billboard and Env Light Fade: Used for TallGrassShader, exact effect is unknown.
- No LOD Land Blend: Prevents landscape from using a LOD shader, engine only.
- Env Map Fade: Fades the cubemap's brightness based on the distance to the nearest light. Makes environment mapped objects not "glow" at all times.
- Wireframe: Toggles wireframe rendering?
- VATS Selection: Engine only, possibly only for thrown weapons + destructible objects?
- Show In Local Map: Forces an object to render in the local map?
- PreMult Alpha: Unknown, possibly related to NoLightingShader?
- Skip Normal Maps: Disables rendering normal maps for landscape, never used and looks ugly when enabled.
- Alpha Decal: Automatically managed by engine.
- No Transparency Multisampling: Disables transparency multisampling on the object.
- Stinger Prop: Disables distance related limitations (specular, env mapping fades), allowing them to always render. Leftover from the Stinger LOD system.
Notes
- Vertex_Alpha will turn geometry invisible if it has vertex colors disabled.
- When External Emittance is flagged, the game will not use the color set in the material property in the NIF and will instead have emittance color that is influenced by both the daylight region set on the Reference and the diffuse texture of the geometry flagged.
- If External Emittance is flagged and a reference using that NIF does not have external emittance enabled, it will adopt the region the player was last in as the emittance color.