Effect Shader
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.
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.
- Blend Mode - enter the function for the source and destination pixels here.
- Zero - uses 0 as its pixel value
- One - uses 1 as its pixel value
- Source Alpha - RGB components of source pixel multiplied by alpha
- Source Inverted Alpha - RGB components of source pixel multiplied by 1 - alpha
- Source Color - Color of source pixel
- Source Inverse Color - Color of source pixel subtracted per component from white
- Dest Alpha - RGB components of destination pixel multiplied by alpha
- Dest Inverted Alpha - RGB components of destination pixel multiplied by 1 - alpha
- Dest Color - Color of destination pixel
- Dest Inverse Color - Color of destination pixel subtracted per component from white
- Source Alpha SAT - 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.
- Blend Operation - determines how the source and destination functions are combined
- The default setting (Src = Source Alpha, Dst = Source Inverted Alpha, Op = Add) should work for most shaders, as it resembles typical alpha blending.
- For brightening try this setting: Src = One, Dst = One, Op = Add
- For modulation (i.e. multiplying over the existing texture) try this: Src = Dest Color, Dst = Zero, Op = Add
- Z Test Funtion - 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.
The Fill/Texture Effect section determines the properties of the Fill color or texture.
All time values 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 - 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 Persistant 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 noticable the "pulsing" of the shader is.
- 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.
- Texture Animation Speed - 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.
- Add Image File - press this 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.
The Edge Effect is an effect that applies a kind of rim lighting to the mesh.
Refer to the Fill/Texture Effect section for the majority of the settings.
- 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.
- 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.
nVidia provides an interesting tool that may help testing the blend modes easier, albeit it was made for DirectX 7. You'll find it on their developer site here.
Particle Shader[edit | edit source]
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.
- 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 particle to reach its Full Particle Birth Ratio
- 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.
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.
- Particles below a certain combined threshold of scale, texture coverage and alpha will fade with distance, dimming or vanishing completely. This appears to be a deliberate LOD optimization and not merely the particles becoming too small to render: particles only slightly above the threshold remain visible at distances disproportionate to their size. Worse, the exact threshold varies among hardware configurations; if you want your particles visible from more than a few yards away, find a number that works for you and then bump it up a little more to be safe.
- 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. If this is less than 1.0, particles will scale back down to 0 before dying.
- Add Image File - select this button to determine what texture the particle will use. It will appear as a sprite. If you do not select a DDS file, the particle will not display; simply setting color values is not sufficient.
- Note that the preview of the texture is distorted to a wide horizontal aspect ratio. This ratio is SQRT(3) : 1, and the same distortion will be seen in-game. If you are editing your own textures and wish to see them as they will actually appear, use a canvas with a similar ratio, e.g. 222 x 128 pixels, then scale it to a square when you're done.
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
These work similar to the scale keys above. If the first color key has a time value greater than zero, the particle will begin with the raw color of the texture file, and if the last key's time value is less than 1.0 it will return to the raw color before dying.