ImsumDave Posted October 30, 2013 Share Posted October 30, 2013 (edited) BSLightingShaderProperty Basics Introductory InformationDiffuseEnvironment/ReflectionSpecular and GlossinessGlow/EmissiveAlpha/Transparency/OpacityNormal MappingRefractionParallaxMultiLayer ParallaxNotes 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. NifskopeNifskope 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 viewerability to view and edit nif data blocks/nodes via an expandable hierarchy viewanimation previewbsa archive browserability to edit data (grouped in related blocks) stored in the nif, via the block list and block details menusgame-accurate viewport shadersa viewport that changes in realtime to changes made in the nif dataability to view and edit collision informationand more.................... ... .. .Get Nifskope - Github Niftools/Niskope Releases Page(a more recent dev build can also be found here: https://github.com/jonwd7/nifskope/releases) Learn about niftools here on the Niftools About ShadersIn 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. BSLightShaderPropertyYou 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. TexturesWhat 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. Digital images come in a variety of forms and formats. In their most basic form they are linear uncompressed grayscale. That is a two-dimensional array of values - a single image channel - each value lying at or between some minimum and maximum. These values will eventually be interpreted and displayed to you as an array of pixels, also know as an image. Typically, the maximum will be displayed as white and the minimum will be displayed as black; any value lying between them will be some shade of gray. In the case of a color image, three separate grayscale images - called image channels - are used to reconstruct the color information. The three image channels store values of red, green, and blue intensity. For this reason, a color image can be called an RGB image, as short-hand. A color image can also have an additional image channel tacked on, called an alpha channel - such an image could be called an RGBA image. This likely first became common place as a means of describing transparent areas of an image, which is how it is sometimes used in 3d graphics, however, this additional information can be used for various purposes, determined by how a particular shader is programmed At their most basic level, computers utilize binary information. Any information that will be interpreted by a computer will exist as ones and zeros, in some form - on the harddrive, ssd, cache, ram, et cetera. This information is stored as bits, each bit representing a one or a zero. However, a single bit of information is not useful for much by itself, so bits are often packaged together in sets of eight, called bytes. When you see an integer value in decimal displayed on your screen, it exists in the computer, at some level, as a set of binary information. For example, the decimal value 255 is 11111111 in binary, which can be stored in one byte. This brings me to the most common image bit-depth you will encounter, which is 8-bit. When an uncompressed image has an 8-bit bit-depth, it means that each image channel value of each pixel is stored as one byte, with some binary value at or between 0 and 11111111, or decimal value 0 to 255. A linear image is one whose image channel values are interpreted and displayed linearly, in a linear color space. That means that, in the case of an 8-bit grayscale image, a value of 127 will be displayed as midway between black and white; it being the mid point (also sometimes 128) between 0 and 255. In the case of an RGB color image, mid gray is red value 127, blue value 127, and green value 127; this can be written as the 8-bit color value 127, 127, 127. Direct Draw Surface Image FormatMany 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 InputsA 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. DIFFUSE What is it?The base color of the models surface. RequirementsBSLightingShaderPropertyShader Flags 2 ~ Vertex_Colors ENABLED *only required if you are using vertex colors Appearance ControllersNiTriShapeData / BSTriShapeVertex ColorsBSShaderTextureSetDiffuse [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. RequirementsBSLightingShaderPropertySkyrim Shader Type ~ 1 or Environment Map SETShader Flags 1 ~ Environment_Mapping ENABLEDShader Flags 2 ~ Glow_Map DISABLEDBSShaderTextureSetCubemap aka Environment Map [RGB] [TEXTURE SLOT 5] Appearance ControllersBSLightingShaderPropertyEnvironmental Map Scale, unclamped float 1.0 is normal intensity0.0 is generally lowest intensity, aka offgreater than 1.0 is higher intensity, brighterBSShaderTextureSetCubemap aka Environment Map [RGB] [TEXTURE SLOT 5]is generally 6 sides of a cubic environment projection stored in one color imagea black pixel is minimum intensity, environment/cube map has no effect in these areasa white pixel is maximum intensityintensity / brightness of cubemap increases as shade approaches whiteEnvironment / Reflection Mask [bC4] [TEXTURE SLOT 6]a black pixel is minimum intensity, environment/cube map has no effect in these areasa white pixel is maximum intensityintensity / brightness of cubemap increases as shade approaches white Environment Map Scale Environment/cube map Environment/reflection mask http://i.imgur.com/RX74xjJ.png SPECULAR AND GLOSSINESSWhat 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. RequirementsBSLightingShaderPropertyShader Flags 1 ~ Specular ENABLED Appearance ControllersBSLightingShaderPropertySpecular Strength1.0 is normal intensity0.0 is minimum intensitygreater than 1.0 is higher than normal intensity, brighterSpecular Colorcolor of the specular highlightGlossinesswidth of the specular highlight10 is a wide specular highlight50 is a thinner specular highlight100 is an even thinner specular highlightvalue ranges from 0 to 999BSShaderTextureSetGrayscale Specular Map [A] [TEXTURE SLOT 2]alpha image channel stored with normal map [RGB]black pixel is minimum intensity, no specular highlightwhite pixel is maximum intensity, maximum defined by BSLightingShaderProporty "Specular Strength"intensity / brightness increases as shade approaches white Specular strength Specular color Specular maphttp://i.imgur.com/ovqWo5F.pngGlossinesshttp://i.imgur.com/UCRj5ih.png GLOW / EMISSIVEWhat is it?Simulates a glowing surface. Does not emit light, simply fakes the look of light emission. RequirementsBSLightingShaderPropertySkyrim Shader Type ~ 2 or Glow Shader SETShader Flags 2 ~ Glow_Map ENABLEDShader Flags 1 ~ Environment_Mapping DISABLED Appearance ControllersBSLightingShaderPropertyEmissive Multiple1.0 is normal intensity0.0 is minimum intensity, no glowgreater than 1.0 is higher than normal intensity, brighterEmissive Colorcolor of glow, color also influenced by emissive / glow map colorBSShaderTextureSetEmissive / Glow Map [RGB] [TEXTURE SLOT 3]glow map is generally a color [RGB] image, or can be grayscaleblack pixel is minimum intensity, no glowwhite pixel is maximum intensity, maximum defined by BSLightingShaderProporty "Emissive Multiple" Emissive multiple Emissive color Emissive/glow maphttp://i.imgur.com/vNOVwrY.png ALPHA / TRANSPARENCY / OPACITYWhat 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. RequirementsNiAlphaPropertyATTACHED to NiTriShapeFlags ~ Enable Blending ENABLED *optional can use testing, blending, or bothSource Blend Mode ~ Src Alpha SETDestination Blend Mode ~ Inv Src Alpha SETFlags ~ Enable Testing ENABLED *optional can use testing, blending, or bothAlpha Test Function ~ Greater or Equal SETAlpha Test Threshold ~ Some Value Between 0 and 255 SETBSLightingShaderPropertyShader Flags 1 ~ Vertex_Alpha ENABLED *only required if you are using vertex color alphasShader Flags 2 ~ Vertex_Colors ENABLED *only required if you are using vertex color alphas Appearance ControllersNiAlphaPropertyFlags ~ Alpha Test Thresholda setting of 0 results in testing not hiding any area of the model's surfacea setting of 127 results in any area of the model's surface that has an alpha value below 127 being invisiblea setting of 255 results in any area of the model's surface that has an alpha value below 255 being invisibleBSLightingShaderPropertyAlpha1.0 is fully visible, opaque0.0 is fully transparent, invisibleBSShaderTextureSetAlpha / Transparency / Opacity [A] [TEXTURE SLOT 1]black is fully transparent, invisiblewhite is fully visible, opaquevisibility decrease as shade approaches blackNiTriShapeDataVertex Colors Alphaonly alpha channel has an effect Alpha Transparency maphttp://i.imgur.com/ZrT7mVO.png Blend Modes and NiAlphaProperty SettingsThe 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 blendinghttp://i.imgur.com/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 FactorsOne - multiply by oneZero - multiply by zeroSrc Color - multiply by "Source" color valueInv Src Color - multiply by inverse "Source" color valueDst Color - multiply by "Destination" color valueInv Dst Color - multiply by inverse "Destination" color valueSrc Alpha - multiply by value of the model's (Source) alpha channels (diffuse and vertex colors) present at that pixelInv Src Alpha - multiply by inverse value of the model's (Source) alpha channels (diffuses and vertex colors) present at that pixelDst Alpha - multiply by value of the background's combined alpha channels (diffuse and vertex colors) present at that pixelInv 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. RequirementsNiTriShapeData / BSTriShapeBS Vector Flags ~ Has_UV *in some versions of nifskope this does not exist, instead set BS Data Flags to 4097BS Vector Flags ~ Has_Tangents *in some versions of nifskope this does not exist, instead set BS Data Flags to 4097Has Normals ~ YESBSShaderTextureSetNormal Map [RGB] [TEXTURE SLOT 2] Appearance ControllersNiTriShapeData / BSTriShapeModel's Surface NormalsBSShaderTextureSetNormal Map [RGB] [TEXTURE SLOT 2] REFRACTIONWhat 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. RequirementsBSLightingShaderPropertyShader Flags 1 ~ Refraction ENABLED Appearance ControllersNiTriShapeData / BSTriShapeModel's Surface NormalsVertex Colors AlphaAlpha channel of vertex colors controls transparency without the need for a NiAlphaPropertyBSLightingShaderPropertyRefraction Strength1.0 is maximum intensity, most extreme distortion0.0 is minimum intensity, no distortionBSShaderTextureSetNormal Map [RGB] [TEXTURE SLOT 2] PARALLAXWhat 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. RequirementsENB required to function properly!BSLightingShaderPropertySkyrim Shader Type ~ 3 or Heightmap SETShader Flags 1 ~ Parallax ENABLED Appearance ControllersBSShaderTextureSetHeight / Parallax [bC4] [TEXTURE SLOT 4]height / parallax map is a grayscale imagemid gray (RGB, 127, 127, 127) is zero depth and heightblack pixel is maximum depthwhite pixel is maximum height MULTILAYER PARALLAXWhat is it?Simulates an inner layer under the model's surface, optionally simulates refraction of that inner layer as well. RequirementsMultiLayer Parallax Shader Does Not Require NiAlphaProperty!BSLightingShaderPropertySkyrim Shader Type ~ 11 or MultiLayer Parallax SETShader Flags 2 ~ Multi_Layer_Parallax ENABLED Appearance ControllersEnvironment map and specular / glossiness have no effect on the inner layer!BSLightingShaderPropertyParallax Inner Layer Thicknesscontrols inner layer max depthdepth increases as value increasesParallax Refraction Scaledeforms the inner layer based on outer layer normal map detail, viewing angle, and inner layer depthrefraction intensity increases as value increases(maybe?) max is 1Parallax Inner Layer Texture Scaleinner layer diffuse tilingdensity of tiling increases as values increase (x and y)x and y control the axis of tilingParallax Envmap Strengthouter layer environment map intensity increases as value increasesBSShaderTextureSetDiffuse [RGB] [TEXTURE SLOT 1]Alpha / Transparency / Opacity [A] [TEXTURE SLOT 1]viewing angle affects transparencyviewing the surface at a steeper angle increases opacityblack is almost completely transparent (see above)white is opaqueSubsurface Color [RGB] [TEXTURE SLOT 3]used to fake subsurface scatteringInner Layer Diffuse [RGB] [TEXTURE SLOT 7]inner layer diffuse is the diffuse texture of the inner layerInner Layer Depth [A] [TEXTURE SLOT 7]inner layer depth is a grayscale imagecontrols the depth of the inner layer from the outer layerblack 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 INFORMATIONDDS image format as it pertains to Skyrim MIP MappingAlways 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 LabelsDXT1, 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 alphaDXT3 – explicit alphaDXT5 – 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 http://i.imgur.com/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 May 28, 2021 by ImsumDave Link to comment Share on other sites More sharing options...
ImsumDave Posted October 30, 2013 Author Share Posted October 30, 2013 Saved for future updates Link to comment Share on other sites More sharing options...
Tamira Posted October 30, 2013 Share Posted October 30, 2013 Very useful informations for everyone! Many thanks for this! :) Link to comment Share on other sites More sharing options...
Celegon Posted October 31, 2013 Share Posted October 31, 2013 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. Link to comment Share on other sites More sharing options...
EnaiSiaion Posted October 31, 2013 Share Posted October 31, 2013 Awesome. :) Link to comment Share on other sites More sharing options...
Terra Nova Posted October 31, 2013 Share Posted October 31, 2013 Thanks for the info, very informative. Link to comment Share on other sites More sharing options...
ImsumDave Posted November 4, 2013 Author Share Posted November 4, 2013 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. Link to comment Share on other sites More sharing options...
Celegon Posted November 4, 2013 Share Posted November 4, 2013 This should be sticked somewhere, as it would be a shame to "lose" this in the ever extending tread list of this forum. Link to comment Share on other sites More sharing options...
BrettM Posted November 10, 2013 Share Posted November 10, 2013 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. Link to comment Share on other sites More sharing options...
ImsumDave Posted November 13, 2013 Author Share Posted November 13, 2013 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. Link to comment Share on other sites More sharing options...
Recommended Posts