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.

Shared Fields

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 are seemingly only usable for lenticular effects, where the appearance of an object changes based on the angle in which its being viewed.

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
    • Texture 2: Normal Map (Gloss / Specular as alpha channel)
    • Texture 3: Glow Map
    • 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, some leftover?
  • Single Pass: For normal geometry, will cause bugged lighting if more then 2 lights hit the same object.
  • 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: Set automatically if the diffuse has alpha, removed if the normalmap has specular?
  • 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.
  • Model Space Normals: Aka world space normals. Uses the normal map exclusively for lighting information instead of mesh normals and tangents. Might be terrain only, unknown if they have to be colored differently as with other games. 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.
  • 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 TreeLOD.
  • Shadow Frustum: Does nothing.
  • Multiple Textures: Not clear, can break textures in some cases.
  • Remappable Textures: Apparently 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 settings in falloutprefs.ini.
  • Dynamic Decal Single Pass: Animated decals? 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 settings in falloutprefs.ini.
  • 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.

See Also