Sprite Shader Modifier
Summary
This modifier works in conjunction with the Sprite Shader to produce effects such as fading out sprites over time (or fading them back in again!). You can use it to alter any channel which has a 'Texture' field in it, including Color, Bump, Reflection, Alpha, etc.
Before using the modifier for the first time, please read the section 'How to use the modifier' below. In particular, please read the note headed 'Rendering cached sprites'.
Interface
This is the modifier's interface:
For the 'Groups Affected', 'Mapping', and 'Falloff' tabs, and for the buttons at the bottom of the interface, please see the 'Common interface elements' page.
Parameters
Enabled
Uncheck this switch to disable the modifier.
Mode
Independent [default setting]
In this mode, particles will be affected if they come into the field of effect of the modifier. X-Particle Actions have no effect on the modifier in this mode.
Action-Controlled
In this mode, the modifier will only act on a particle when told to do so by an Action. Until that point, the particle will not be affected, but once activated for a particular particle, the modifier will continue to influence it as long as it is in the field of effect of the modifier. The modifier's effect on a particle can be halted by means of another Action, if desired.
Color Mode
This drop-down list has two settings:
Greyscale, Greyscale Rate of Change
The colour value returned by the Sprite Shader will be increased or decreased by the same amount in the red, green, and blue components of the color. This is most useful when you need a greyscale value to affect something like transparency or reflection. The change in value each frame is given in the 'Greyscale Rate of Change' parameter.
RGB, Red/Green/Blue Rate of Change
The red, green, and blue components of the returned colour will be altered independently of one another; the change in values each frame are given in the Red/Green/Blue 'Rate of Change' parameters. This is used when you want to alter a real colour value such as in the Color channel of a material.
Clamp To
The colour set by the modifier will be clamped to this colour value. By default this is 100% white.
How to use the modifier
To use this modifier is a little complex. It has the following requirements:
- a material with a Sprite Shader in at least one channel
- the Sprite Shader 'Mode' setting must be set to 'Modifier Sets Value'
- a Sprite object, with the above material applied to it
As a particle passes through the modifier, the modifier changes an internal color value held by the particle; the rate of change depends on the settings in the modifier - the higher the values, the more rapid the change. This value is then used by the Sprite Shader at render time to alter the color returned by the material channel.
An example may make this clearer. Suppose we have a scene with a Sprite object generating cubes. A plain red material has been applied to the sprites. We would like the particles to fade out when they enter the field of effect of the Sprite Shader modifier. To do this we will use the Alpha channel, so we add a Sprite Shader to the alpha channel of the material:
At this point the sprites will always be visible, since the shader always returns white. What we need is for it to change to black to make the sprites invisible.
In the Sprite Shader (not the modifier), we make one change: 'Mode' is set to 'Modifier Sets Value':
What this means is that in the Sprite Shader, and recall that the shader is in the alpha channel of the material, the colour will be set by a Sprite Shader modifier.
Next, we add a Sprite Shader Modifier to the scene. Change the 'Greyscale Rate of Change' value to -2% and (very importantly) change the 'Clamp To' colour to black. Now, as each particle passes through the modifier, the colour returned from the alpha channel of the material applied to the sprite is gradually changed to black, which causes the object to fade and eventually disappear. The results are as follows:
Before the modifier is used | After the modifier is used |
You could reverse this process and fade the particles back in again by using another modifier with the delta set to a positive value and 'Clamp To' set to white.
Rendering cached sprites
If you cache a scene with a Sprite object and a Sprite shader, you will find that you can render any frame to the viewport and it will render correctly. However, if you render a frame to the picture viewer, it will appear that the sprite shader has no effect. This is inherent in the way modifiers work in X-Particles; once cached, internal modifier values are not updated if you render a single frame to the picture viewer partway through the animation.
There are two possible solutions to this. Firstly, to render a frame to the picture viewer in this case, you can render all preceding frames as well, so the modifier can update the required values in the particle. If you are using internal caching, this is the only available solution, but it may be slow if you need to render many frames which you don't need.
If you are using external caching, there is a better solution: in the Cache object, turn off the switch 'Skip Render Pre-Roll'. This will force X-Particles to run through all frames before the one you want to render, thereby updating the modifier values, but it will not render those frames. This can be much faster than rendering all the preceding frames.