Difference between revisions of "EffectShader"

From the CreationKit Wiki
Jump to navigation Jump to search
imported>Tox2ik
(→‎Blending: it's confusing to talk about RGB channels but also use red, green, and blue to mark parts of the equation, so we now instead use teal, purple, and brown for the latter.)
 
(45 intermediate revisions by 6 users not shown)
Line 3: Line 3:
The shader can consist of two components, a Membrane Shader and a Particle Shader.
The shader can consist of two components, a Membrane Shader and a Particle Shader.


[[File:EffectShaderWindow.png|900px]]


==Membrane Shader==
== Membrane Shader ==


The Membrane Shader is applied directly to the mesh of a target object. How the shader interacts with the mesh's base texture is determined in large part by the Source and Dest Blend Modes.
The Membrane Shader is applied directly to the mesh of a target object. How the shader interacts with the mesh's base texture is determined in large part by the Source and Dest Blend Modes.


''Ignore Base Geometry Texture Alpha''
:: Check this box to ?


'''Source and Dest Blend Mode'''
''Affect Skin Only''
 
:: Check this box to make the Membrane Shader only affect NPC's exposed skin and not any apparel that is being worn. E.g. the effectSunDamage shader uses this.
Select the functions for the source and destination pixels here.
 
''Zero''
:: Uses 0 as its pixel value


''One''
=== Blending ===
:: Uses 1 as its pixel value


''Source Alpha''
In computer graphics, color blending is generally talked about in terms of a "source" color that is blended onto a "destination" color by applying a "blend function." Here, the source color is the color that comes from the EffectShader — the shader's color and texture for any given pixel on-screen — and the destination color is the color and texture "underneath" the effect shader. The blend function is controlled through three basic ideas:
:: RGB components of source pixel multiplied by alpha


''Source Inverted Alpha''
* The '''source blend mode''' is something that we multiply by the source color.
:: RGB components of source pixel multiplied by 1 - alpha
* The '''destination blend mode''' is something that we multiply by the destination color.
* The '''blend operation''' is a simple math operation (e.g. addition, subtraction) that is applied to the source and destination colors ''after'' we've multiplied them by something. This operation combines the two colors into a final result, which is used as the color of the pixel that the player sees on-screen.


''Source Color''
Colors are commonly represented as a set of three integers in the range [0, 255] — the red, green, and blue channels — but for the math performed here, they're each treated as decimal values in the range [0, 1].
:: Color of source pixel


''Source Inverse Color''
Let's look at a typical color-blending equation for painting a semi-transparent source color onto an opaque destination color: <math>\definecolor{tealblue}{rgb}{0,0.68,0.7}C_o = \color{tealblue}\alpha_s\color{black} C_s  \color{brown}+\color{black}  \color{purple}(1-\alpha_s)\color{black}C_d</math>. The equation gets applied three times: once for red, once for green, and once for blue. Here, <math>C_o</math> is the output color &mdash; the final result of the whole process &mdash; while <math>C_s</math> and <math>C_d</math> are the source and destination colors, and <math>\alpha_s</math> is the source alpha. The parts of this equation that EffectShaders control have been marked with color: the Source Blend Mode is teal, the Destination Blend Mode is purple, and the Blend Operation is brown.
:: Color of source pixel subtracted per component from white


''Dest Alpha''
* The Source Blend Mode is "Source Alpha:" we're multiplying the source alpha by the source color: <math>\alpha_s C_s</math>.
:: RGB components of destination pixel multiplied by alpha
* The Destination Blend Mode is "Source Inverted Alpha:" we're taking one minus the source alpha, and multiplying it by the destination color: <math>(1 - \alpha_s)C_d</math>.
* The operation is Add: after we've multiplied the source and destination colors by various things, we add them together to get the output color.


''Dest Inverted Alpha''
==== Blend modes ====
:: RGB components of destination pixel multiplied by 1 - alpha
{| class="wikitable"
! style="min-width:11em" | Mode
! style="text-align:left" | What happens to "this color" (the color the mode is applied to)
|-
| Zero || This color's channels are multiplied by zero, producing black.
|-
| One || This color's channels are multiplied by one; the color is unchanged.
|-
| Source Alpha || This color's channels are multiplied by the source's alpha (i.e. the source's opacity).
|-
| Source Inverse Alpha || This color's channels are multiplied by one minus the source's alpha (i.e. the source's transparency).
|-
| Source Color || Each of this color's channels is multiplied by the respective channel of the source color (i.e. This Red &times; Source Red, This Green &times; Source Green, and This Blue &times; Source Blue).
|-
| Source Inverse Color || Each of this color's channels is multiplied by one minus the respective channel of the source color (i.e. This Red &times; (1 - Source Red), and so on).
|-
| Dest Alpha || This color's channels are multiplied by the destination's alpha (i.e. the source's opacity).
|-
| Dest Inverse Alpha || This color's channels are multiplied by one minus the destination's alpha (i.e. the source's transparency).
|-
| Dest Color || Each of this color's channels is multiplied by the respective channel of the destination color (i.e. This Red &times; Destination Red, This Green &times; Destination Green, and This Blue &times; Destination Blue).
|-
| Dest Inverse Color || Each of this color's channels is multiplied by one minus the respective channel of the destination color (i.e. This Red &times; (1 - Destination Red), and so on).
|-
| Source Alpha SAT || This color's color channels are multiplied by either Source Alpha or Destination Inverse Alpha, whichever is smaller. The resulting pixel's alpha value is forced to 1. This can only be used for Source and will override the value set in Destination. (In OpenGL, a common 3D graphics standard, this is called <code>GL_SRC_ALPHA_SATURATE</code>.)
|-
|}


''Dest Color''
==== Blend operations ====
:: Color of destination pixel
This setting determines how the source and destination colors are combined after each is modified by its respective Blend Mode. Options are as follows:


''Dest Inverse Color''
* '''Add:''' Result = Source + Destination. If values cross above 1, white is displayed.
:: Color of destination pixel subtracted per component from white
* '''Subtract:''' Result = Source - Destination. If values cross below zero, black is displayed.
* '''Reverse Subtract:''' Result = Destination - Source. The destination pixel is made darker by the source.
* '''Minimum:''' Result = Min(Source, Destination). Each channel in the result pixel is the darker of the two channels from the source and destination pixel: Result Red is whichever of Source Red and Destination Red is darker, and so on.
* '''Maximum:''' Result = Max(Source, Destination). Each channel in the result pixel is the brighter of the two channels from the source and destination pixel: Result Red is whichever of Source Red and Destination Red is brighter, and so on.


''Source Alpha SAT''
==== Typical blends ====
:: Takes the lesser of the source pixel's alpha or one minus the destination pixel's alpha and places it in the red, green, and blue fields of the specified pixel. This mode sets the specified pixel's alpha to be 1.


'''The default setting should work for most shaders, as it resembles typical alpha blending:'''
* Source Blend Mode: ''Source Alpha''
* Dest Blend Mode: ''Source Inverted Alpha''
* Blend Operation: ''Add''


'''Blend Operation'''
Mathematically, this produces the typical blend used for a semitranslucent source and a fully opaque destination: <math>\alpha_s C_s + (1-\alpha_s)C_d</math>, where <math>C_s</math> and <math>C_d</math> represent the RGB values of the source and destination pixels respectively (i.e. you repeat this equation three times with each of red, green, and blue), and <math>\alpha_s</math> is the source alpha.


This option determines how the source and destination functions are combined.
'''To make something brighter, try these options:'''
* Source Blend Mode: ''One''
* Dest Blend Mode: ''One''
* Blend Operation: ''Add''


The default setting should work for most shaders, as it resembles typical alpha blending;
Mathematically, this produces <math>1C_s + 1C_d</math>, which simplifies to <math>C_s + C_d</math>.
* Source Blend Mode:'' Source Alpha ''
* Dest Blend Mode:'' Source Inverted Alpha ''
* Blend Operation:'' Add ''


To make something brighter, try these options;
'''For modulation i.e. multiplying over the existing texture, try this:'''
* Source Blend Mode:'' One ''
* Source Blend Mode: ''Dest Color''
* Dest Blend Mode:'' One ''
* Dest Blend Mode: ''Zero''
* Blend Operation:'' Add ''
* Blend Operation: ''Add''


For modulation (i.e. multiplying over the existing texture) try this;
Mathematically, this produces <math>C_s C_d + 0 C_d</math>, which simplifies to <math>C_s C_d</math>.
* Source Blend Mode:'' Dest Color ''
* Dest Blend Mode:'' Zero ''
* Blend Operation:'' Add ''


=== Z-Test function ===


'''Z Test Function'''
The Z-test function defaults to Equal To. The "Greater Than" and "Greater Than or Equal To" values are supposed to change the depth of the shader effects, allowing it to show through walls; however, this behavior is broken in Skyrim.


Defaults to Equal To. If changed to Greater Than or Greater Than or Equal To, the membrane shader will be displayed on top of other geometry and will be visible through walls (unconfirmed).
(The Z-buffer, or depth buffer, is used to ensure that objects are displayed according to their depth. During rendering of a triangle, the Z-value of a given pixel is compared to the value stored in the Z-Buffer. Based on the Z-testing function, the triangle either is allowed to overdraw the pixel or not. The default behavior is to accept pixel that have a Z-value that is smaller or the same as the value in the Z-Buffer, making objects which are closer to the camera occlude objects which are farther away.)


==== Fill / Texture Effect ====  
=== Other options ===
==== Fill / Texture Effect ====
Determines the properties of the fill color or texture. All time values in this frame are in seconds.
Determines the properties of the fill color or texture. All time values in this frame are in seconds.
''Affect Skin Only''
:: Check this box to make the Membrane Shader only affect NPC's exposed skin. E.g. the effectSunDamage shader uses this.


''Alpha Fade In Time''
''Alpha Fade In Time''
Line 84: Line 109:


''Alpha Fade Out Time''
''Alpha Fade Out Time''
:: The time the fill effect takes to reach its Persistant Alpha Ratio.
:: The time the fill effect takes to reach its Persistent Alpha Ratio.


''Full Alpha Ratio''
''Full Alpha Ratio''
Line 93: Line 118:


''Alpha Pulse Amplitude''
''Alpha Pulse Amplitude''
:: How noticable the "pulsing" of the shader is.
:: How noticeable the pulsation of the shader is; a multiplier applied to the ''Full'' or ''Persistent Alpha Ratio''. Relevant only when one of the blend modes has been set to Source (inverted) Alpha.


''Alpha Pulse Frequency''
''Alpha Pulse Frequency''
:: How often the shader is "pulsed". It may be easier to consider that the period of any given pulse would be 1 second divided by the frequency of the pulses.
:: How often the shader exhibits a pulse. It may be easier to consider that the period of any given pulse would be 1 second divided by the frequency of the pulses (i.e. larger values give shorter pulses, decimal values below 1 give longer pulses).
 
''Texture Animation Speed (U, V)''
:: If a texture is selected, it can be animated across the U (horizontal) and V (vertical) texture coordinates using these speed values. Make the value negative to get movement in the opposite direction.
 
''Texture Scale (U, V)''
:: A larger value will repeat the texture more frequently on the surface of the target object.
 
{{InDepth|Here's an explanation of the alpha/opacity values for those who find prose easier to understand:
 
When a shader is first applied, it immediately uses ''Full Alpha Ratio'' as its opacity for ''Full Alpha Time''; after that, the shader fades in from ''Full Alpha Ratio'' to ''Persistent Alpha Ratio'' over ''Alpha Fade Out Time''. Over the course of the shader's lifetime (including during fades), the opacity will vary by up to ''Alpha Pulse Ratio'' (multiplied by the ''Full'' or ''Persistent Alpha Ratio'') at a rate of ''Alpha Pulse Frequency'' times per second. When the shader is removed from a reference, it will always fade out from its current opacity to zero over ''Alpha Fade Out Time''.


''Texture Animation Speed''
The fade-in behavior changes if the ''Persistent Alpha Ratio'' is greater than the ''Full Alpha Ratio'': in this case, the shader will instantly switch from ''Full Alpha Ratio'' to ''Persistent Alpha Ratio'' at the end of the ''Full Alpha Time''. This is implied by the names of the settings -- "full," as in "maximum," alpha ratio -- but it's still not necessarily what one might expect, and it's definitely the less useful behavior.}}
:: If a texture is selected, it can be animated across the U and V texture coordinates using these speed values.


''Color''
:: The color of the fill effect if a texture is not selected.


''Texture''
''Fill Texture''
:: Press the Edit button to add a texture instead of using a solid color. To remove an image file, press this button and cancel the dialogue window that appears.
:: Press the Edit button to add a texture instead of using a solid color. To remove an image file, press this button and cancel the dialogue window that appears.
''Palette Texture''
:: Press the Edit button to define a palette texture. The exact function of this texture is unknown, but if one isn't defined, your shader ''may'' not work.
''Ignore Alpha''
:: Check this box to ?
''Projected UVs''
:: Textures appear to be projected behind the membrane instead of sticking the textures onto the membrane.
''Lighting''
:: ?
''No Wpns''
:: Checking this box makes it so the effects are not applied to weapons.
''Grayscale To Palette - Color''
:: Uses the colors from the Palette Texture.
''Grayscale To Palette - Alpha''
:: Texture alpha is ignored when this is off (Palette opaque).
''Color Key 1-3''
:: Only the level of white / black seems relevant when a texture has been selected. The color keys are ignored (true for all blend modes?) when no texture is selected. The scale represents intensity/brightness or in some cases the size/thickness of the effect. Time is given in seconds since the shader started.


==== Edge Effect ====
==== Edge Effect ====
Applies a light rim of sorts to the outer edge of the mesh. Refer to the Fill / Texture Effect section for the majority of the settings.
Applies a light rim of sorts to the outer edge of the mesh. Refer to the Fill / Texture Effect section for the majority of the settings. The pulsation settings in these two sections are independent of each other making it possible to create a shader that pulsates between the (animated) texture membrane and a (pulsating) edge effect.  


''Fall Off''  
''Fall Off''  
::This value represents the bias of the rim lighting. A higher value will cause the rim effect to fall off quicker, giving it a sharper outline.
::This value represents the bias of the rim lighting. Higher values will cause the rim effect to fall off quicker, giving it a sharper outline. A value below one makes the edge (texture) more visible and it will appear "solid" if this value is set to 0.


''Inverse''
''Inverse''
:: Check this box to make the edge effect's blend mode inverted relative to the fill effect. For example, when using additive fill effect, checking this box will cause the edge effect to darken rather than lighten the mesh.
:: Check this box to make the edge effect's blend mode inverted relative to the fill effect. For example, when using additive fill effect, checking this box will cause the edge effect to darken rather than lighten the mesh.
''Color''
:: The color of the edge effect.


==== Holes ====
==== Holes ====
Line 136: Line 194:
:: The black value that is cut off at the end.
:: The black value that is cut off at the end.


==Holes==
== Particle Shader ==
Holes are used to define a dissolve for the object the Effect Shader is on. These were used in Skyrim for when Actors dissolve when killed with Lightning. This is done by animating the alpha cut off on a grayscale image. This is often used in conjunction with a '''Fill/Texture Effect'''.
Use the Particle Shader section to create particles that will emit from the target object. These effects are limited to ObjectReferences that are also Actors; trying to emit particles from a piece of armor or another inanimate object will prove fruitless.
 
The method of particle alpha blending is determined by the Source and Dest Blend Modes. Refer to the Membrane Shader section.
 
{| class="wikitable"
|+ Particle Shader Parameters
 
| width="200px" style="padding:13px;text-align:right"  | ''Z Test Function''
| width="650px" style="padding:13px;                "  |  Default is Normal. When set to Always Show, the particles will draw on top of all other meshes, making particles visible through walls. The Detect Life shader uses this effect.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Particle Birth Ramp Up Time''
| width="650px" style="padding:13px;                "  |  The time for the number of particles to reach the Full Particle Birth Count.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Full Particle Birth Time''
| width="650px" style="padding:13px;                "  |  The duration that particles emit at the Full Particle Birth Count.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Particle Birth Ramp Down Time''
| width="650px" style="padding:13px;                "  |  The time for the particle system to go from the Full Particle Birth Count to the Persistent Particle Birth Count.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Full Particle Birth Count''
| width="650px" style="padding:13px;                "  | The amount of particles that spawn at "Full" rate. A value of 1 will cause 79 particles to spawn (per second?), so each particle is about 0.0127. You can enter values larger than 1.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Persistent Particle Count''
| width="650px" style="padding:13px;                "  | The number of particles that are emitted (per second?) during the persistent effect phase of the effect shader.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Particle Lifetime''
| width="650px" style="padding:13px;                "  | How long a particle will exist in the world (in seconds?). Adjust the +/- value to provide variability to this value.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Initial Speed Along Normal''
| width="650px" style="padding:13px;                "  | The initial speed (in what units?) assigned to a particle when it is spawned. The normal should be considered the mostly random direction that a particle is given when it is spawned. Thus, this value controls the explosiveness of the particle effect.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Acceleration Along Normal''
| width="650px" style="padding:13px;                "  | The amount of acceleration (or deceleration if negative values are used) applied to a particle. The normal is on the shaded object (such as the player) and negative acceleration values will pull the particles towards the object.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Initial Velocity XYZ''
| width="650px" style="padding:13px;                "  | The amount of velocity applied to a particle in world coordinates. To make particles drift upwards, apply a positive velocity to the Z axis.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Acceleration XYZ''
| width="650px" style="padding:13px;                "  | The amount of acceleration applied to a particle in world coordinates. As an example, you can make a particle float back down after a time by making the absolute value of a negative Z acceleration greater than the initial velocity divided by the particle lifetime, or |-ZAcceleration| > ZVelocity / Particle Lifetime.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Initial Rotation (deg)''
| width="650px" style="padding:13px;                "  | The initial rotation assigned to a particle when it is spawned, in degrees.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Rotation Speed (deg/sec)''
| width="650px" style="padding:13px;                "  | How fast the particles will rotate after spawning, in degrees per second.
 
|}
 
The Time component in the following options is not specified in seconds, but rather a value in the 0 - 1 range. This decimal value represents the percentage of a particle's life.
 
{| class="wikitable"
|+ Particle Shader Parameters: Continued
 
| width="200px" style="padding:13px;text-align:right"  |
| width="650px" style="padding:13px;                "  |
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Scale Key 1''
| width="650px" style="padding:13px;                "  | The first value represents the scale of a particle, the Time value determines when that scale is reached. All particles are spawned with a scale of 0 and increase in size until they reach this scale.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Scale Key 2''
| width="650px" style="padding:13px;                "  | Second scale and time component of the particle.
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Texture''
| width="650px" style="padding:13px;                "  | Press the Edit button to determine what texture the particle will use. It will appear as a sprite.
|}
 
{| class="wikitable"
|+ Particle Shader Parameters: Color Keys
 
| width="200px" style="padding:13px;text-align:right"  | ''Color''
| width="650px" style="padding:13px;                "  | The tint of the particle at that time
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Color Alpha''
| width="650px" style="padding:13px;                "  | The alpha amount of the particle
 
|-
 
| width="200px" style="padding:13px;text-align:right"  | ''Color Key Time''
| width="650px" style="padding:13px;                "  | The time that the color and alpha settings occur
|}
 


<br>'''File:''' Select a .dds file to be used for this effect
==== Addon Models ====
<br>
<br>'''Start Time:''' How long after applying the Effect Shader should the dissolve start.
<br>'''End Time:''' How long after applying the Effect Shader should the dissolve end.
<br>'''Start Val:''' The black value that is cut off at the start.
<br>'''End Val:''' The black value that is cut off at the end.


==Particle Shader==
These are [[Debris]] objects that are placed at an Actor's joints when the Effect Shader is applied. This is most clearly seen in the ice chunks that appear on an actor hit by the [http://www.uesp.net/wiki/Skyrim:Ice_Form Ice Form shout].


Use the Particle Shader section to create particles that will emit from the target object.


The method of particle alpha blending is determined by the Source and Dest Blend Modes. Refer to the Membrane Shader's usage of these combo boxes.
''File:'' The debris file used to pick .nif files from


*Z Test Function - default is Normal. When set to Always Show, the particles will draw on top of all other meshes, making particles visible through walls. The Detect Life shader uses this effect.
''Fade In Time:'' The length of time needed to fade in the debris models when applied.


*Particle Birth Ramp Up Time - the time for the particle to reach its Full Particle Birth Ratio
''Fade Out Time:'' The length of time needed to fade out the debris models when removed.
*Full Particle Birth Time - the duration that particles emit at the system's Full Particle Birth Ratio.
*Particle Birth Ramp Down - the time for the particle system to go from the Full Particle Birth Ratio to the Persistent Particle Birth Ratio.
*Full Particle Birth Ratio - the amount of particles that spawn. A value of 1 will cause the maximum amount of particles to spawn.
*Persistent Particle Birth Ratio - the amount of particles that during the persistent effect phase of the effect shader.
*Particle Lifetime - how long a particle will exist in the world. Adjust the +/- value to provide variability to this value.
*Initial Speed Along Normal - the initial speed assigned to a particle when it is spawned. The normal should be considered the mostly random direction that a particle is given when it is spawned. Thus, this value controls the explosiveness of the particle effect.
*Acceleration Along Normal - the amount of acceleration (or deceleration if negative values are used) applied to a particle.
*Initial Velocity XYZ - the amount of velocity applied to a particle in world coordinates. To make particles drift upwards, apply a positive velocity to the Z axis.
*Acceleration XYZ - the amount of acceleration applied to a particle in world coordinates. As an example, you can make a particle float back down after a time by making the absolute value of a negative Z acceleration greater than the initial velocity divided by the particle lifetime, or |-ZAcceleration| > ZVelocity / Particle Lifetime.
*Initial Rotation - the initial rotation assigned to a particle when it is spawned.
*Rotation Speed - how fast the particles will rotate after spawning.  


''Scale Start:'' The starting scale of the debris models when they first appear.


''For the following settings, the Time component is not in seconds, but is a 0 - 1 value that represents the percentage of the particle life.''
''Scale End:'' The ending scale of the debris models when they are fully attached.


*Scale Key 1 - the first value represents the scale of a particle, the Time value determines when that scale is reached. All particles are spawned with a scale of 0 and increase in size until they reach this scale.
''Scale In Time:'' The time it takes for the debris models to scale in (from Start Scale to End Scale).
*Scale Key 2 - second scale and time component of the particle.
*Texture - press the Edit button to determine what texture the particle will use. It will appear as a sprite.


'''Color Keys'''
''Scale Out Time:'' The time it takes for the debris models to scale out (from End Scale to Start Scale).
*Color - the tint of the particle at that time
*Color Alpha - the alpha amount of the particle
*Color Key Time - the time that the color and alpha settings occur
<br>
<br>
'''Addon Models'''
<br>
<br>
Addon Models are [[Debris]] objects that are placed at an actor's joints when the Effect Shader is applied. This is most clearly seen in the ice chunks that appear on an actor hit by the Ice Form shout.


*'''File:''' The debris file used to pick .nif files from
== Notes ==
*'''Fade In Time:''' The length of time needed to fade in the debris models when applied.
* Remember that your shaders are (generally) triggered by spells; those spells can have unintuitive effects on how the shader behaves, breaking the behavior of the various fade options. It's best to test your EffectShaders independently by using the ''PlayMagicShaderVisuals'' (''PMS'') and ''StopMagicShaderVisuals'' (''SMS'') console commands; both run on an actor and take the form ID of a shader.
*'''Fade Out Time:''' The length of time needed to fade out the debris models when removed.
** In some particularly bizarre cases, magic effects that trigger on different conditions can break each other's shaders if they're part of the same spell; yet they and their shaders work perfectly fine if they're separated out into different spells.
*'''Scale Start:''' The starting scale of the debris models when they first appear.
*'''Scale End:''' The ending scale of the debris models when they are fully attached.
*'''Scale In Time:''' The time it takes for the debris models to scale in (from Start Scale to End Scale).
*'''Scale Out Time:''' The time it takes for the debris models to scale out (from End Scale to Start Scale).


[[Category:Object Classes]]
[[Category:Object Classes]]
[[Category:Special Effect]]
[[Category:Special Effect]]

Latest revision as of 22:06, 20 August 2024

An effect shader is a visual effect typically used for spells, enchantments, or other magic effects. In some cases, effect shaders are applied to variant creatures to make them look somewhat different than their relatives.

The shader can consist of two components, a Membrane Shader and a Particle Shader.

EffectShaderWindow.png

Membrane Shader[edit | edit source]

The Membrane Shader is applied directly to the mesh of a target object. How the shader interacts with the mesh's base texture is determined in large part by the Source and Dest Blend Modes.

Ignore Base Geometry Texture Alpha

Check this box to ?

Affect Skin Only

Check this box to make the Membrane Shader only affect NPC's exposed skin and not any apparel that is being worn. E.g. the effectSunDamage shader uses this.

Blending[edit | edit source]

In computer graphics, color blending is generally talked about in terms of a "source" color that is blended onto a "destination" color by applying a "blend function." Here, the source color is the color that comes from the EffectShader — the shader's color and texture for any given pixel on-screen — and the destination color is the color and texture "underneath" the effect shader. The blend function is controlled through three basic ideas:

  • The source blend mode is something that we multiply by the source color.
  • The destination blend mode is something that we multiply by the destination color.
  • The blend operation is a simple math operation (e.g. addition, subtraction) that is applied to the source and destination colors after we've multiplied them by something. This operation combines the two colors into a final result, which is used as the color of the pixel that the player sees on-screen.

Colors are commonly represented as a set of three integers in the range [0, 255] — the red, green, and blue channels — but for the math performed here, they're each treated as decimal values in the range [0, 1].

Let's look at a typical color-blending equation for painting a semi-transparent source color onto an opaque destination color: . The equation gets applied three times: once for red, once for green, and once for blue. Here, is the output color — the final result of the whole process — while and are the source and destination colors, and is the source alpha. The parts of this equation that EffectShaders control have been marked with color: the Source Blend Mode is teal, the Destination Blend Mode is purple, and the Blend Operation is brown.

  • The Source Blend Mode is "Source Alpha:" we're multiplying the source alpha by the source color: .
  • The Destination Blend Mode is "Source Inverted Alpha:" we're taking one minus the source alpha, and multiplying it by the destination color: .
  • The operation is Add: after we've multiplied the source and destination colors by various things, we add them together to get the output color.

Blend modes[edit | edit source]

Mode What happens to "this color" (the color the mode is applied to)
Zero This color's channels are multiplied by zero, producing black.
One This color's channels are multiplied by one; the color is unchanged.
Source Alpha This color's channels are multiplied by the source's alpha (i.e. the source's opacity).
Source Inverse Alpha This color's channels are multiplied by one minus the source's alpha (i.e. the source's transparency).
Source Color Each of this color's channels is multiplied by the respective channel of the source color (i.e. This Red × Source Red, This Green × Source Green, and This Blue × Source Blue).
Source Inverse Color Each of this color's channels is multiplied by one minus the respective channel of the source color (i.e. This Red × (1 - Source Red), and so on).
Dest Alpha This color's channels are multiplied by the destination's alpha (i.e. the source's opacity).
Dest Inverse Alpha This color's channels are multiplied by one minus the destination's alpha (i.e. the source's transparency).
Dest Color Each of this color's channels is multiplied by the respective channel of the destination color (i.e. This Red × Destination Red, This Green × Destination Green, and This Blue × Destination Blue).
Dest Inverse Color Each of this color's channels is multiplied by one minus the respective channel of the destination color (i.e. This Red × (1 - Destination Red), and so on).
Source Alpha SAT This color's color channels are multiplied by either Source Alpha or Destination Inverse Alpha, whichever is smaller. The resulting pixel's alpha value is forced to 1. This can only be used for Source and will override the value set in Destination. (In OpenGL, a common 3D graphics standard, this is called GL_SRC_ALPHA_SATURATE.)

Blend operations[edit | edit source]

This setting determines how the source and destination colors are combined after each is modified by its respective Blend Mode. Options are as follows:

  • Add: Result = Source + Destination. If values cross above 1, white is displayed.
  • Subtract: Result = Source - Destination. If values cross below zero, black is displayed.
  • Reverse Subtract: Result = Destination - Source. The destination pixel is made darker by the source.
  • Minimum: Result = Min(Source, Destination). Each channel in the result pixel is the darker of the two channels from the source and destination pixel: Result Red is whichever of Source Red and Destination Red is darker, and so on.
  • Maximum: Result = Max(Source, Destination). Each channel in the result pixel is the brighter of the two channels from the source and destination pixel: Result Red is whichever of Source Red and Destination Red is brighter, and so on.

Typical blends[edit | edit source]

The default setting should work for most shaders, as it resembles typical alpha blending:

  • Source Blend Mode: Source Alpha
  • Dest Blend Mode: Source Inverted Alpha
  • Blend Operation: Add

Mathematically, this produces the typical blend used for a semitranslucent source and a fully opaque destination: , where and represent the RGB values of the source and destination pixels respectively (i.e. you repeat this equation three times with each of red, green, and blue), and is the source alpha.

To make something brighter, try these options:

  • Source Blend Mode: One
  • Dest Blend Mode: One
  • Blend Operation: Add

Mathematically, this produces , which simplifies to .

For modulation i.e. multiplying over the existing texture, try this:

  • Source Blend Mode: Dest Color
  • Dest Blend Mode: Zero
  • Blend Operation: Add

Mathematically, this produces , which simplifies to .

Z-Test function[edit | edit source]

The Z-test function defaults to Equal To. The "Greater Than" and "Greater Than or Equal To" values are supposed to change the depth of the shader effects, allowing it to show through walls; however, this behavior is broken in Skyrim.

(The Z-buffer, or depth buffer, is used to ensure that objects are displayed according to their depth. During rendering of a triangle, the Z-value of a given pixel is compared to the value stored in the Z-Buffer. Based on the Z-testing function, the triangle either is allowed to overdraw the pixel or not. The default behavior is to accept pixel that have a Z-value that is smaller or the same as the value in the Z-Buffer, making objects which are closer to the camera occlude objects which are farther away.)

Other options[edit | edit source]

Fill / Texture Effect[edit | edit source]

Determines the properties of the fill color or texture. All time values in this frame are in seconds.

Alpha Fade In Time

The time the fill effect takes to reach its Full Alpha Ratio value.

Full Alpha Time

The duration the fill effect stays at the Full Alpha Ratio.

Alpha Fade Out Time

The time the fill effect takes to reach its Persistent Alpha Ratio.

Full Alpha Ratio

The alpha amount of the fill effect. A value of 1 would be completely opaque.

Persistent Alpha Ratio

The alpha amount of the persistent fill effect. The persistent effect will last for as long as the effect shader is active. For a persistent effect to be visible, the FX Persist flag should be checked on in the Magic Effects window.

Alpha Pulse Amplitude

How noticeable the pulsation of the shader is; a multiplier applied to the Full or Persistent Alpha Ratio. Relevant only when one of the blend modes has been set to Source (inverted) Alpha.

Alpha Pulse Frequency

How often the shader exhibits a pulse. It may be easier to consider that the period of any given pulse would be 1 second divided by the frequency of the pulses (i.e. larger values give shorter pulses, decimal values below 1 give longer pulses).

Texture Animation Speed (U, V)

If a texture is selected, it can be animated across the U (horizontal) and V (vertical) texture coordinates using these speed values. Make the value negative to get movement in the opposite direction.

Texture Scale (U, V)

A larger value will repeat the texture more frequently on the surface of the target object.
InDepth.jpg Here's an explanation of the alpha/opacity values for those who find prose easier to understand:

When a shader is first applied, it immediately uses Full Alpha Ratio as its opacity for Full Alpha Time; after that, the shader fades in from Full Alpha Ratio to Persistent Alpha Ratio over Alpha Fade Out Time. Over the course of the shader's lifetime (including during fades), the opacity will vary by up to Alpha Pulse Ratio (multiplied by the Full or Persistent Alpha Ratio) at a rate of Alpha Pulse Frequency times per second. When the shader is removed from a reference, it will always fade out from its current opacity to zero over Alpha Fade Out Time.

The fade-in behavior changes if the Persistent Alpha Ratio is greater than the Full Alpha Ratio: in this case, the shader will instantly switch from Full Alpha Ratio to Persistent Alpha Ratio at the end of the Full Alpha Time. This is implied by the names of the settings -- "full," as in "maximum," alpha ratio -- but it's still not necessarily what one might expect, and it's definitely the less useful behavior.


Fill Texture

Press the Edit button to add a texture instead of using a solid color. To remove an image file, press this button and cancel the dialogue window that appears.

Palette Texture

Press the Edit button to define a palette texture. The exact function of this texture is unknown, but if one isn't defined, your shader may not work.

Ignore Alpha

Check this box to ?

Projected UVs

Textures appear to be projected behind the membrane instead of sticking the textures onto the membrane.

Lighting

?

No Wpns

Checking this box makes it so the effects are not applied to weapons.

Grayscale To Palette - Color

Uses the colors from the Palette Texture.

Grayscale To Palette - Alpha

Texture alpha is ignored when this is off (Palette opaque).

Color Key 1-3

Only the level of white / black seems relevant when a texture has been selected. The color keys are ignored (true for all blend modes?) when no texture is selected. The scale represents intensity/brightness or in some cases the size/thickness of the effect. Time is given in seconds since the shader started.

Edge Effect[edit | edit source]

Applies a light rim of sorts to the outer edge of the mesh. Refer to the Fill / Texture Effect section for the majority of the settings. The pulsation settings in these two sections are independent of each other making it possible to create a shader that pulsates between the (animated) texture membrane and a (pulsating) edge effect.

Fall Off

This value represents the bias of the rim lighting. Higher values will cause the rim effect to fall off quicker, giving it a sharper outline. A value below one makes the edge (texture) more visible and it will appear "solid" if this value is set to 0.

Inverse

Check this box to make the edge effect's blend mode inverted relative to the fill effect. For example, when using additive fill effect, checking this box will cause the edge effect to darken rather than lighten the mesh.

Color

The color of the edge effect.

Holes[edit | edit source]

Holes are used to define a dissolve for the object the Effect Shader is on. These were used in Skyrim for when Actors dissolve when killed with Lightning. This is done by animating the alpha cut off on a grayscale image. This is often used in conjunction with a Fill/Texture Effect.

texture input box

Select a .dds file to be used for this effect

Alpha Test Animation

Start Time

How long after applying the Effect Shader should the dissolve start.

End Time

How long after applying the Effect Shader should the dissolve end.

Start Val

The black value that is cut off at the start.

End Val

The black value that is cut off at the end.

Particle Shader[edit | edit source]

Use the Particle Shader section to create particles that will emit from the target object. These effects are limited to ObjectReferences that are also Actors; trying to emit particles from a piece of armor or another inanimate object will prove fruitless.

The method of particle alpha blending is determined by the Source and Dest Blend Modes. Refer to the Membrane Shader section.

Particle Shader Parameters
Z Test Function Default is Normal. When set to Always Show, the particles will draw on top of all other meshes, making particles visible through walls. The Detect Life shader uses this effect.
Particle Birth Ramp Up Time The time for the number of particles to reach the Full Particle Birth Count.
Full Particle Birth Time The duration that particles emit at the Full Particle Birth Count.
Particle Birth Ramp Down Time The time for the particle system to go from the Full Particle Birth Count to the Persistent Particle Birth Count.
Full Particle Birth Count The amount of particles that spawn at "Full" rate. A value of 1 will cause 79 particles to spawn (per second?), so each particle is about 0.0127. You can enter values larger than 1.
Persistent Particle Count The number of particles that are emitted (per second?) during the persistent effect phase of the effect shader.
Particle Lifetime How long a particle will exist in the world (in seconds?). Adjust the +/- value to provide variability to this value.
Initial Speed Along Normal The initial speed (in what units?) assigned to a particle when it is spawned. The normal should be considered the mostly random direction that a particle is given when it is spawned. Thus, this value controls the explosiveness of the particle effect.
Acceleration Along Normal The amount of acceleration (or deceleration if negative values are used) applied to a particle. The normal is on the shaded object (such as the player) and negative acceleration values will pull the particles towards the object.
Initial Velocity XYZ The amount of velocity applied to a particle in world coordinates. To make particles drift upwards, apply a positive velocity to the Z axis.
Acceleration XYZ The amount of acceleration applied to a particle in world coordinates. As an example, you can make a particle float back down after a time by making the absolute value of a negative Z acceleration greater than the initial velocity divided by the particle lifetime, or |-ZAcceleration| > ZVelocity / Particle Lifetime.
Initial Rotation (deg) The initial rotation assigned to a particle when it is spawned, in degrees.
Rotation Speed (deg/sec) How fast the particles will rotate after spawning, in degrees per second.

The Time component in the following options is not specified in seconds, but rather a value in the 0 - 1 range. This decimal value represents the percentage of a particle's life.

Particle Shader Parameters: Continued
Scale Key 1 The first value represents the scale of a particle, the Time value determines when that scale is reached. All particles are spawned with a scale of 0 and increase in size until they reach this scale.
Scale Key 2 Second scale and time component of the particle.
Texture Press the Edit button to determine what texture the particle will use. It will appear as a sprite.
Particle Shader Parameters: Color Keys
Color The tint of the particle at that time
Color Alpha The alpha amount of the particle
Color Key Time The time that the color and alpha settings occur


Addon Models[edit | edit source]

These are Debris objects that are placed at an Actor's joints when the Effect Shader is applied. This is most clearly seen in the ice chunks that appear on an actor hit by the Ice Form shout.


File: The debris file used to pick .nif files from

Fade In Time: The length of time needed to fade in the debris models when applied.

Fade Out Time: The length of time needed to fade out the debris models when removed.

Scale Start: The starting scale of the debris models when they first appear.

Scale End: The ending scale of the debris models when they are fully attached.

Scale In Time: The time it takes for the debris models to scale in (from Start Scale to End Scale).

Scale Out Time: The time it takes for the debris models to scale out (from End Scale to Start Scale).

Notes[edit | edit source]

  • Remember that your shaders are (generally) triggered by spells; those spells can have unintuitive effects on how the shader behaves, breaking the behavior of the various fade options. It's best to test your EffectShaders independently by using the PlayMagicShaderVisuals (PMS) and StopMagicShaderVisuals (SMS) console commands; both run on an actor and take the form ID of a shader.
    • In some particularly bizarre cases, magic effects that trigger on different conditions can break each other's shaders if they're part of the same spell; yet they and their shaders work perfectly fine if they're separated out into different spells.