The X-Particles Distance Shader
This shader can be used in any material channel which has a shader link. Although written for X-Particles, it can be used on any polygon object or object primitive.
What this shader does is affect the shading according to the distance of the point to be shaded from some other location. Typically, this would be the active scene camera, but you can use any object or the 3D world centre instead. You can use it to change colour with distance, or fade an object out (or in) depending on the distance from the chosen point.
This is the shader's interface:
For the buttons at the bottom of the interface, please see the 'Common interface elements' page.
This is the reference point from which the distance to the point to be rendered is calculated. The drop-down menu has three options:
The distance is from the active scene camera.
The distance is from any scene object. The object to use must be dragged into the 'Object' field.
The distance is from the centre of the 3D world.
The object to use when 'Distance From' is set to 'Object'. Note that the distance is calculated from the centre of object's axis, not from the closest polygon or vertex.
Min. Distance & Max. Distance
Shaded points which are less than 'Min. Distance' from the reference point will use the colour at the left hand end of the color or alpha gradient. Points which are further than 'Max. Distance' from the reference point will use the colour at the right hand end of the gradient. Points in between these limits will use a colour from somewhere along the gradient.
You can choose from two types of gradient, colour or alpha. This is really just for convenience. You can use the colour gradient in an alpha channel or the alpha gradient in a colour channel, it doesn't make any difference. Typically though you would use a colour gradient in a material's Color channel for example, and a black/white alpha gradient in the Alpha channel.
Select this option if you need a coloured gradient. Note that you can edit a coloured gradient to be monochrome if you like, or you can switch to the alpha gradient instead.
Select this option for use in any channel where you need a monochrome gradient (e.g. the Alpha channel of a material). Note that you cannot edit such a gradient to change it to a coloured gradient.
Color Gradient/Alpha Gradient
Either a coloured gradient or an alpha gradient is shown, depending on the 'Gradient Mode' setting.