| Introduction to Ramps & Gradients |
| What This Section Is For Many of the shaders in this collection use Ramps and Gradients to control their processing, and rather than repeat details for each shader, it’s easier to explain the ideas in general, as they apply equally to all the shaders. First, some definitions (as used within TG Pack 3 - I take no responsibility for these definitions matching exactly their use in other packages or contexts!) : Ramps A Ramp is a greyscale image, which controls the value of a variable within the shader. The value is read in from the greyscale image, with the position along the Ramp being controlled by such factors as distance from camera or angle of view. This is in place of having a slider or value in the shader itself. Gradients A Gradient is a colour image, which controls the colour value of something within the shader (diffuse colour, specular colour, etc). The colour value is read in from the Gradient, with the position along the Gradient being controlled by such factors as distance from camera or angle of view (often modified through accessing a Ramp). This is in place of having colour values set in the shader itself. |
| Why Use Ramps & Gradients? Advantages 1) Using a Ramp or Gradient to read in a value often cuts down on the processing that a shader needs to do. For instance, it has no need to calculate the blend between two colours, as that is “hard coded” into the Gradient. 2) When the shader itself controls a parameter, you are limited in what you can create. You can only have as much variation as there are variables in the shader - for example, the TG Slope Bands shader only allows the blending of 3 colours, since that’s the number of colour parameters provided in the shader interface. By using a Gradient, you can then move the blend between as many (or as few) colours as you wish, allowing for much finer control over the result. Using a Ramp to control a variable brings a similar benefit - for instance, the TG Glow Transparency shader only allows for 3 transparency “points”, these being for the inner value, a moveable middle value, and an outer value. With a Ramp, though, you can have as many transparency points as you wish, with the rise and fall of the intensity of the pixels in the Ramp controlling the transparency value and the positions that those effects occur at. Not only that, but you can vary the value in a non-linear way, or with sudden breaks and changes, with as many repeats as you like, or with randomisation in the Ramp too. Disadvantages The world is never perfect, and there are is a disadvantage to using Ramps and Gradients too, that being that you need to create the Ramp or Gradient image separately, and if you want to “tweak” an effect, then you need to generate a new Ramp or Gradient to do so. For instance, if you want a fade in colour from orange to blue, you’ll need to have a Gradient that fades from orange to blue - you can’t just adjust the colour within the shader. Of course, over time, you can build up a library of Ramps and Gradients, which will always be to hand. |
| Where do I find Ramps & Gradients? There are sample Ramps and Gradients provided along with the shaders. These can be found in the following folders (these assume you are using trueSpace 5, and that you installed it to the default directories - if not, simply look in your trueSpace 5 folder and follow the path from there!) : C:\trueSpace5\ShaderLab2\Shaders\TG Pack 3 SL2\Ramps\ C:\trueSpace5\ShaderLab2\Shaders\TG Pack 3 SL2\Gradients\ You can store your own Ramps and Gradients wherever you like, but you might like to keep them in these folders for ease of use in future! |
| How do I create my own Ramps & Gradients? The simple answer is, any way you like! There are several more obvious ways though. First, you can use an art package, and use linear or Gradient fills to make a Ramp or Gradient. A quick and easy way to produce suitable images is to use trueSpace itself - the free Axion Simple Gradient colour shader can be used to produce either Ramps or Gradients quite easily, by painting a plane using the shader in the colour channel, and the Constant reflectance shader (although you are limited to as many sweeps and changes across the image as there are parameters in that shader, naturally). Technical Note 1 : In order to save on processing, the shaders actually take a little shortcut when reading from a Ramp, and ONLY read the red channel colour information. This means that a Ramp that runs from black to full red will work exactly the same as one that runs from black to full white. There’s no advantage to using Ramps that only contain red channel information, though, and I find it easier to visualise and see details when working with greyscale Ramps, so I’ve stayed with using greyscale images for the Ramps. Technical Note 2 : The height of the Ramp image is irrelevant - the shaders always read across the top line of the image. Make your Ramp images as tall or as short as you like, whatever makes them easier to work with. Technical Note 3 : In width of the Ramp image isn’t critical either - the shaders read by a “percentage” along the image width, so they can be as long as or as wide as you like. To some extent, wider images will allow for smoother graduations in values (although how smoothly the shader reads from that image is dependent upon other factors - eg, if based on distance, and the range of distances set is very short, there’d be little need for a particularly long and smooth Ramp or Gradient). |
| Introduction to Ramps and Gradients |
| Understanding Ramps and Gradients |
| TG Pack 3 Index |