Jump to content

Photo

BSLightingShaderProperty Basics


  • Please log in to reply
35 replies to this topic

#1
ImsumDave

ImsumDave

    Old hand

  • Supporter
  • PipPipPip
  • 545 posts

 BSLightingShaderProperty Basics

 
 
Introductory Information
Diffuse

Environment/Reflection
Specular and Glossiness
Glow/Emissive
Alpha/Transparency/Opacity

Normal Mapping

Refraction
Parallax
MultiLayer Parallax

Notes and Miscellaneous Information
 

INTRODUCTORY INFORMATION
 

I've uploaded some files that may be helpful, including a shader showcase nif, and blending and testing nif. They can be found at this link.

 

Nifskope
Nifskope is a program that can open, view, and save nif files. The nif file format is the model, or mesh, data storage format used in games that utilize the Gamebryo Engine, formerly Netimmerse, and spin-offs of that, which include all games made by Bethesda Game Studios (BGS), Morrowind on - starting with Skyrim, BGS redubbed their engine Creation Engine. Nif files also commonly contain animation data in various forms, shader and material data, collision information, and other miscellaneous data, such as inventory model preview rotation and zoom.
 
Nifskope includes:

  • an interactive model viewer
  • ability to view and edit nif data blocks/nodes via an expandable hierarchy view
  • animation preview
  • bsa archive browser
  • ability to edit data (grouped in related blocks) stored in the nif, via the block list and block details menus
  • game-accurate viewport shaders
  • a viewport that changes in realtime to changes made in the nif data
  • ability to view and edit collision information
  • and more....................   ... .. .​

Get Nifskope - Github Niftools/Niskope Releases Page
(a more recent dev build can also be found here: https://github.com/j...fskope/releases)
 
Learn about niftools here on the Niftools About
 
Shaders
In the context of 3d graphics, a shader is a set or sets of predetermined calculations that utilize multiple inputs to generate specific visual outputs to aid in rendering a desired image. The term is general and can cover a range of things. Specific to the case at hand, shaders are used to aid rendering by simulating various materials upon the surfaces of 3d models.
 
BSLightShaderProperty
You might be asking what a BSLightingShaderProperty is. It is a data block, or grouping of related data, that exists within a nif file. It contains data that the in-game shaders use to define how the surfaces of a model are rendered (shaded). It is used in Skyrim LE and Skyrim SE. The niftools team, as well as other contributors from the community, have decoded and translated that data so that it can be displayed, understood, and edited in Nifskope, and elsewhere.
 
A quick tip: It is not necessary to build your own BSLightingShaderProperty from scratch. Things are made much easier by copying and pasting a BSLightingShaderProperty from elsewhere before modifying it for your needs.
 
Textures
What is a texture?
In the context of 3D art, a texture is an image stored in some digital format. These images are a means of storing information that is used in calculations related to a models surface shading. They are inputs to a shader.

Spoiler

 

Direct Draw Surface Image Format

Many games utilize the direct draw surface (dds) image format as their texture image format of choice - Skyrim is among those games. The dds format supports storing images in both compressed or uncompressed forms, of which there are various types. Supported types depend on the graphics hardware and its supported DirectX version, as well as the games supported DirectX version. The compressed form uses BCn compression of some type, which type is denoted by the labels BC1 through BC7. More infomation about BCn compression can be found here, in this well written article by Nathan Reed.
 
Shader Inputs
A shader will typically utilize more than one texture, as well as other more simply defined inputs, in order to control the resulting output. Utilizing nifskope, we can see and edit these inputs, both in the block details of the BSLightShaderProperty (more simply defined inputs), and by changing the texture paths in the BSShaderTexture set block - which point to textures that can be edited using some other software.
 
The following image shows the block details of a BSLightingShaderProperty, in this case with an Environment Map shader setup, and BSShaderTextureSet, with labeled texture slots. The [RGB] label means red, green, and blue color image channels. The [A] label means alpha image channel. The [BC4] label means high quality grayscale BCn compression type, grayscale image.
qk5tcMx.jpg

 

 

 

 

 

DIFFUSE

 

What is it?

The base color of the models surface.

 

Requirements

BSLightingShaderProperty

Shader Flags 2 ~ Vertex_Colors ENABLED *only required if you are using vertex colors

 

Appearance Controllers
NiTriShapeData / BSTriShape

Vertex Colors

BSShaderTextureSet

Diffuse [RGB] [TEXTURE SLOT 1]

 

 

 

 

ENVIRONMENT / REFLECTION

 

What is it?
Simulates the general reflection of the surrounding environment on the models surface. The simulated environment reflections are not necessarily mirror like, although they can be with the right settings and cubemap (environment map). Cubemaps are bre-baked images, 
six sides of a cubic environment projection stored in one color image. Another common environment map type is a spherical environment map, although I do not believe it is supported in Skyrim. Some games have dynamic cubemap switching, in combination with in-editor area-based auto-baked cubemaps, to enable better accuracy of the reflections to actual in-game environments. Skyrim does not support such a thing, as far as I am aware.
 
Requirements
BSLightingShaderProperty

Skyrim Shader Type ~ 1 or Environment Map SET

Shader Flags 1 ~ Environment_Mapping ENABLED

Shader Flags 2 ~ Glow_Map DISABLED

​BSShaderTextureSet

Cubemap aka Environment Map [RGB] [TEXTURE SLOT 5]

 
Appearance Controllers
BSLightingShaderProperty

Environmental Map Scale, unclamped float ​

1.0 is normal intensity

0.0 is generally lowest intensity, aka off
greater than 1.0 is higher intensity, brighter

​BSShaderTextureSet

Cubemap aka Environment Map [RGB] [TEXTURE SLOT 5]

is generally 6 sides of a cubic environment projection stored in one color image

a black pixel is minimum intensity, environment/cube map has no effect in these areas

a white pixel is maximum intensity

intensity / brightness of cubemap increases as shade approaches white

Environment / Reflection Mask [BC4] [TEXTURE SLOT 6]

a black pixel is minimum intensity, environment/cube map has no effect in these areas

a white pixel is maximum intensity

intensity / brightness of cubemap increases as shade approaches white

   
Environment Map Scale                                  Environment/cube map                                 Environment/reflection mask  
RX74xjJ.png

 

 

 

 

SPECULAR AND GLOSSINESS

What is it?
Dynamically simulates highlights from in-game light sources on the models surface. Specular is not required for your model to receive lighting, only (specular) highlights. In Skyrim's case, in-game lights include: the sun, moonlight, torches, fires, lanterns, magical auras, and natural light sources in interiors - in some cases, things that seem like they should emit light do not and are actually just visual effect fakery.
 
Requirements
BSLightingShaderProperty

Shader Flags 1 ~ Specular ENABLED

 

Appearance Controllers
BSLightingShaderProperty

Specular Strength

1.0 is normal intensity

0.0 is minimum intensity
greater than 1.0 is higher than normal intensity, brighter

Specular Color

color of the specular highlight

Glossiness

width of the specular highlight

10 is a wide specular highlight

50 is a thinner specular highlight
100 is an even thinner specular highlight

value ranges from 0 to 999

BSShaderTextureSet

Grayscale Specular Map [A] [TEXTURE SLOT 2]

alpha image channel stored with normal map [RGB]

black pixel is minimum intensity, no specular highlight

white pixel is maximum intensity, maximum defined by BSLightingShaderProporty "Specular Strength"
intensity / brightness increases as shade approaches white

 
Specular strength                                          Specular color                                               Specular map
ovqWo5F.png

Glossiness
UCRj5ih.png


 

 

 

GLOW / EMISSIVE

What is it?
Simulates a glowing surface. Does not emit light, simply fakes the look of light emission.
 
Requirements
BSLightingShaderProperty

Skyrim Shader Type ~ 2 or Glow Shader SET
Shader Flags 2 ~ Glow_Map ENABLED
Shader Flags 1 ~ Environment_Mapping DISABLED

 

Appearance Controllers
BSLightingShaderProperty

Emissive Multiple

1.0 is normal intensity

0.0 is minimum intensity, no glow
greater than 1.0 is higher than normal intensity, brighter

Emissive Color

color of glow, color also influenced by emissive / glow map color

BSShaderTextureSet

Emissive / Glow Map [RGB] [TEXTURE SLOT 3]

glow map is generally a color [RGB] image, or can be grayscale

black pixel is minimum intensity, no glow

white pixel is maximum intensity, maximum defined by BSLightingShaderProporty "Emissive Multiple"

 
Emissive multiple                                           Emissive color                                              Emissive/glow map
vNOVwrY.png

 

 

 

 

ALPHA / TRANSPARENCY / OPACITY

What is it?

Simulates model surface opacity or transparency - either via on off testing or blending. Testing and blending can be used together or alone. Testing is used in situations where the model's surface is either fully visible or invisible, with no in-between. Blending is most commonly used for surfaces requiring transparency or semi-opacity.

 

Requirements
NiAlphaProperty

ATTACHED to NiTriShape

Flags ~ Enable Blending ENABLED *optional can use testing, blending, or both

Source Blend Mode ~ Src Alpha SET

Destination Blend Mode ~ Inv Src Alpha SET

Flags ~ Enable Testing ENABLED *optional can use testing, blending, or both

Alpha Test Function ~ Greater or Equal SET

Alpha Test Threshold ~ Some Value Between 0 and 255 SET

BSLightingShaderProperty

Shader Flags 1 ~ Vertex_Alpha ENABLED *only required if you are using vertex color alphas

Shader Flags 2 ~ Vertex_Colors ENABLED *only required if you are using vertex color alphas

 

Appearance Controllers
NiAlphaProperty

Flags ~ Alpha Test Threshold

a setting of results in testing not hiding any area of the model's surface

a setting of 127 results in any area of the model's surface that has an alpha value below 127 being invisible

a setting of 255 results in any area of the model's surface that has an alpha value below 255 being invisible

BSLightingShaderProperty

Alpha

1.0 is fully visible, opaque

0.0 is fully transparent, invisible

BSShaderTextureSet

Alpha / Transparency / Opacity [A] [TEXTURE SLOT 1]

black is fully transparent, invisible

white is fully visible, opaque
visibility decrease as shade approaches black

NiTriShapeData

Vertex Colors Alpha

only alpha channel has an effect

 

Alpha                                                           Transparency map
ZrT7mVO.png

 

 

Blend Modes and NiAlphaProperty Settings

The NiAlphaProperty node allows for more blending techniques than just transparency, such as additive, multiplicative, and overlay (combination of additive multiplicative). These blend modes may or may not make use of the alpha channel of the model. Some use the destination (background) alpha. Some use the destination color. Some use the source (model's surface) alpha. Some use the source color. 

 

NiAlphaProperty Settings - in the below image "2x Multiplicative" is the term used for overlay blending
QlE7LgX.png
 
 
Color Blending
 
Color Blending Equation
(Source * SourceBlendFactor) + (Destination * DestinationBlendFactor)  ::  
applied per channel (red, green, blue), per pixel
 
for each channel (red, green, blue)
"Source" is the normalized channel value of the model surface materials in that pixel
"SourceBlendFactor" is the normalized multiplication factor applied to the source value
 
"Destination" 
is the normalized channel value of the background in that pixel
"DestinationBlendFactor" is the normalized multiplication factor applied to the destination value
 
Blend Factors
One - multiply by one
Zero - multiply by zero
Src Color - multiply by "Source" color value
Inv Src Color - multiply by inverse "Source" 
color value
Dst Color - multiply by "Destination" color value
Inv Dst Color - multiply by inverse "Destination" color value
Src Alpha - multiply by value of the model's (Source) alpha channels (diffuse and vertex colors) present at that pixel
Inv Src Alpha - multiply by inverse value of the model's 
(Source) alpha channels (diffuses and vertex colors) present at that pixel
Dst Alpha - multiply by value of the background's combined alpha channels (diffuse and vertex colors) present at that pixel
Inv Dst Alpha - multiply by inverse value of the background's combined alpha channels (diffuse and vertex colors) present at that pixel

 

 

 

 

NORMAL MAP

 

What is it?

A texture in which data is encoded that is used to bias the lighting on, or shading of, the model's surface. It is used to fake the shape and complexity of a models surface. There are a few types, the type used in Skyrim is tangent-space normal mapping.

 

Requirements

NiTriShapeData / BSTriShape

BS Vector Flags ~ Has_UV *in some versions of nifskope this does not exist, instead set BS Data Flags to 4097

BS Vector Flags ~ Has_Tangents *in some versions of nifskope this does not exist, instead set BS Data Flags to 4097

Has Normals ~ YES

BSShaderTextureSet

Normal Map [RGB] [TEXTURE SLOT 2]

 

Appearance Controllers
NiTriShapeData / BSTriShape

Model's Surface Normals

BSShaderTextureSet

Normal Map [RGB] [TEXTURE SLOT 2]

 

 

 

 
REFRACTION

What is it?
Simulates image distortion due to refraction of light through a surface. Objects behind the model will be distorted depending on the shader settings used.
 
Requirements
BSLightingShaderProperty

Shader Flags 1 ~ Refraction ENABLED

 
Appearance Controllers
NiTriShapeData / BSTriShape

Model's Surface Normals

Vertex Colors Alpha

Alpha channel of vertex colors controls transparency without the need for a NiAlphaProperty

BSLightingShaderProperty

Refraction Strength

1.0 is maximum intensity, most extreme distortion

0.0 is minimum intensity, no distortion

BSShaderTextureSet

Normal Map [RGB] [TEXTURE SLOT 2]

 

 

 

PARALLAX

What is it?

Simulates height variation on the model's surface. Fairly resource intensive, but also more realistic than normal mapping. Parallax mapping fakes surface deformation.
 
Requirements
ENB required to function properly!
BSLightingShaderProperty

Skyrim Shader Type ~ 3 or Heightmap SET
Shader Flags 1 ~ Parallax ENABLED

 

Appearance Controllers
BSShaderTextureSet

Height / Parallax [BC4] [TEXTURE SLOT 4]

height / parallax map is a grayscale image

mid gray (RGB, 127, 127, 127) is zero depth and height
black pixel is maximum depth
white pixel is maximum height

 

 

 

 

MULTILAYER PARALLAX

What is it?
Simulates an inner layer under the model's surface, optionally simulates refraction of that inner layer as well.

 
Requirements

MultiLayer Parallax Shader Does Not Require NiAlphaProperty!

BSLightingShaderProperty

Skyrim Shader Type ~ 11 or MultiLayer Parallax SET
Shader Flags 2 ~ Multi_Layer_Parallax ENABLED

 

Appearance Controllers
Environment map and specular / glossiness have no effect on the inner layer!
BSLightingShaderProperty

Parallax Inner Layer Thickness

controls inner layer max depth

depth increases as value increases

Parallax Refraction Scale

deforms the inner layer based on outer layer normal map detail, viewing angle, and inner layer depth

refraction intensity increases as value increases
(maybe?) max is 1

Parallax Inner Layer Texture Scale

inner layer diffuse tiling

density of tiling increases as values increase (x and y)
x and y control the axis of tiling

Parallax Envmap Strength

outer layer environment map intensity increases as value increases

BSShaderTextureSet

Diffuse [RGB] [TEXTURE SLOT 1]

Alpha / Transparency / Opacity [A] [TEXTURE SLOT 1]

viewing angle affects transparency

viewing the surface at a steeper angle increases opacity
black is almost completely transparent (see above)
white is opaque

Subsurface Color [RGB] [TEXTURE SLOT 3]

used to fake subsurface scattering

Inner Layer Diffuse [RGB] [TEXTURE SLOT 7]

inner layer diffuse is the diffuse texture of the inner layer

Inner Layer Depth [A] [TEXTURE SLOT 7]

inner layer depth is a grayscale image

controls the depth of the inner layer from the outer layer
black is minimum depth (inner layer distance from outer layer is 0)
white is maximum depth (inner layer distance from outer layer is max)

 

 

 

 
NOTES AND MISCELANEOUS INFORMATION

DDS image format as it pertains to Skyrim
 
MIP Mapping
Always generate MIP maps when saving a DDS image for use in Skyrim. Saving a DDS image without MIP maps has been known to cause lag on asset load (ex. pause when swapping weapons). Google MIP mapping if you'd like the details about what it is and what it does.
 
DXT compression (DXT1, DXT3, DXT5)  -  Alternate BCn Compression Labels
DXT1, DXT3, and DXT5 all use the same compression method for the RGB image channels. The difference between them comes from how the alpha image channel is compressed. DXT compression can (will) cause artifacts in the texture, especially in areas with gradients. The benefit of compressed textures is the smaller size on disk and in RAM.
 
DXT1 – no alpha
DXT3 – explicit alpha
DXT5 – interpolated alpha
 
Uncompressed (8.8.8.8 ARGB, 8.8.8 RGB)
Uncompressed dds images are quite large (space on disk and in RAM) compared to those saved with DXT compression. The benefit of uncompressed textures is the lack of compression artifacts. This can be important when artifacts are noticeable in-game.
 
**if textures are too large, this can cause lag on asset load, especially with slower computers
 
9i73dwu.gif
(ignore gif compression, small specks in RGB images)
 
 
Layering
 
Incompatibility between some effects can be worked around by layering meshes (NiTriShape). For example, for glow shader and environment map, one NiTriShape will have a BSLightingShaderProperty set up for environment mapping, while another will be set up for glow. The glow NiTriShape will use alpha transparency to hide all areas that do not have the glow effect. The glow map can be used for the transparency map in diffuse alpha image channel. This workaround can be used in many different ways, be creative.


Edited by ImsumDave, 28 May 2021 - 11:00 PM.


#2
ImsumDave

ImsumDave

    Old hand

  • Supporter
  • PipPipPip
  • 545 posts

Saved for future updates



#3
Tamira

Tamira

    Faithful poster

  • Supporter
  • PipPipPipPip
  • 1,489 posts

Very useful informations for everyone! Many thanks for this! :)



#4
Celegon

Celegon

    Regular

  • Members
  • PipPip
  • 66 posts

Seconded.

You should add a link to this thread in your sign. I'm sure it will help a lot of prospective modders in the future.



#5
EnaiSiaion

EnaiSiaion

    Endorsement Geisha

  • Premium Member
  • 30,940 posts

Awesome. :)



#6
Terra Nova

Terra Nova

    Old hand

  • Account closed
  • PipPipPip
  • 610 posts

Thanks for the info, very informative.



#7
ImsumDave

ImsumDave

    Old hand

  • Supporter
  • PipPipPip
  • 545 posts

No problem. I made this quite a while ago. I posted it with an incorrect name. This information can be quite hard to find and even harder to figure out for a beginner. I made this as a quick reference. There is quite a bit of information missing. I only included what I know to be correct (ignoring the height map slot). I might add refraction, normal mapping, and parallax mapping information in the future.



#8
Celegon

Celegon

    Regular

  • Members
  • PipPip
  • 66 posts

This should be sticked somewhere, as it would be a shame to "lose" this in the ever extending tread list of this forum.



#9
BrettM

BrettM

    Old hand

  • Premium Member
  • 525 posts

Fantastic! Ummm ... you wouldn't happen to have the same kind of rundown for the BSEffectsShaderProperty, would you?  Or any information on the shader property controllers? :D

 

Truly, this tutorial deserves to be spread widely.



#10
ImsumDave

ImsumDave

    Old hand

  • Supporter
  • PipPipPip
  • 545 posts

No, I haven't used BSEffectShaderProperty at all up to this point. As for shader property controllers, I was playing around with them a bit in the past. I was trying to make a pulsing glow effect. In fact, the head in my Longclaw mod uses that exact effect. You could take a look at that if you need an example. I can't really explain any of it off the top of my head atm. It's been quite a while since I played around with them. This niftools thread has some useful info.






IPB skins by Skinbox
Page loaded in: 1.050 seconds