NIF Shader Properties

From GECK
Jump to: navigation, search

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.

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 four unique fields.

  • Falloff Start Angle:
  • Falloff Stop Angle:
  • Falloff Start Opacity:
  • Falloff Stop Opacity:

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
    • Texture 2: Normal Map
    • Texture 3: Glow
    • Texture 4: Parallax / Height
    • Texture 5: Cube Map
    • Texture 6: Environment Map
  • 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

Flags 1:

  • Specular: Enables specular lighting on the object.
  • Skinned: Enables skinning.
  • 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, some leftover?
  • Single Pass: For decals, marks the object as single pass?
  • Empty: Unknown?
  • Environment Mapping: Enables environment mapping on the object.
  • Alpha Texture: Set automatically if the diffuse has alpha, removed if the normalmap has specular?
  • ZPrepass: Set automatically for certain alpha combinations (which?), the engine doesn't have a proper Z prepass so its exact purpose is unknown.
  • FaceGen: Enables FaceGen on the object, updates skin textures based on the race, enables fake subsurface scattering.
  • Parallax Shader Index 15: Enables a parallax shader. The effect is pretty weak, combine with Parallax Occlusion for it to be noticeable.
  • Model Space Normals: World 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.
  • 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.
  • Hair: Enables hair shaders. Glowmaps are used as highlight textures?
  • Dynamic Alpha: Does something with NoLightingShader.
  • 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.
  • 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 TreeLOD.
  • Shadow Frustum: Does nothing.
  • Multiple Textures: Not clear, can break textures in some cases.
  • Remappable Textures: Apparently does nothing.
  • Decal: Enables decal shaders?
  • Dynamic Decal: Animated decals?
  • Parallax Occlusion: Enables parallax occlusion.
  • External Emittance: Enables external emittance on the object, needs the BSX flag for External Emit ticked. Will cause the tristrip/shape to only use the emittance settings when it's day time. With placed References you can set an inverted daylight Region which will make the tristrip/shape only emit at night instead.
  • 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: Adds non-landscape LOD geometry to a LOD function.
  • 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. Engine function, not recommended to set manually.
  • 1st Light Is Point Light: Unused, meant for HairShaderProperty.
  • 2nd Light: Unused.
  • 3rd Light: Unused.
  • Vertex Lighting: Used on TallGrassShader, required for proper lighting when combined with all white vertex colors.
  • Uniform Scale: Used on TallGrassShader, presumably makes the game stop randomly scaling grass NIFs with it.
  • Fit Slope: Used on TallGrassShader, makes grass conform to landscape slopes.
  • Billboard Env 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 normalmaps for landscape, never used and looks ugly when enabled.
  • Alpha Decal: Marks a decal of having alpha?
  • No Transparency Multisampling: Disables transparency multisampling on the object.
  • Stinger Prop: Unknown.