Gradient textures for coloring with two variables

EnSight has the ability to color a single part by 2 different variables by using a bitmap texture. Each axis of the texture is assigned to one variable. A sample image is included with EnSight (dual_gradient.png in the cube data directory) which has one axis as color and the other axis as transparency. Sometimes the user may want to use different colors for each axis instead of transparency, but this requires having the texture to use.

This script uses EnVe to create a custom image for this purpose, by letting the user define the colors of the 4 corners of a 256×256 square, and interpolating the color values between them. It is a barebones script with little documentation, but is also short and simple to use. In this post is also an archive with a few images created with the script.



Below is a screenshot of the textures dialog, with the settings changed to the optimal settings for using gradient textures (in most cases).

Texture Mode: Decal or Replace

Repeat Mode: Clamp or Clamp to Texture

Interpolation: Nearest

Compute Texture Coordinates by: Variables

S Variable and T Variable: select 2 scalar variables. Ideally the range of these variables are between 0 and 1. Read the How To manual for more information.

Note that if your variable values var1 + var2 <= 1 (for example mass, volume, or mole fraction) then you will only use the bottom-left triangle half of the square.


Leave a Reply