IFW Lightwave Textures |
Tutorial One - IFW Texture Basics
|This tutorial gives a basic introduction into the IFW shaders and the way 1D, 2D and 3D textures work.|
|Part 1 - The Basics Of Procedural Textures|
|When using procedural shaders it is important to understand how the patterns for the textures are generated. In the case of Lightwave or Inspire, the IFW procedural shaders are programs that are executed when the renderer wants to know what color a pixel is going to be. The renderer tells the procedural shader program the hit point in 3D (X,Y,Z). That is the point at which the ray currently being traced hit the surface of an object. It is simplest form, imagine a primitive plane object lying so that the Z axis is vertical and the X axis horizontal. When it is rendered a procedural shader would receive changing values for X and Z and a static, non changing, value for Y (as the plane is flat and there will not not change in the value perpedicular to it). Now, to generate a simply pattern the procedural texture program only needs to determine the color at the X and Z co-ordinates given to it and ignore Y. Once the color is returned the renderer takes care of the shading.|
|Part 2 - 1D Procedural Textures|
For a texture such as a linear gradient, the procedural shader program would
generate a value proportional to the axis in which the gradient was running. For
example it could use the X axis and divide it up, say by 2. The color could then be
determined by taking this value and using it to interpolate between two colors.
A texture would then be generated that changed linearly as the X value of the
object increased and would repeat every 2 units. This is an example of a 1D
texture, in other words, a texture that only using one axis to determine the
color or pattern. It is important to understand that the texture will only
appear correctly if viewed facing the axis being used to produce it, in this case X.
This can be seen in the diagram below where the gradient does not work on the face
YZ. In the case of the IFW shaders this concept in developed further. Rather than
having to two color to interpolate four are provided. Along with this four
blend points allow the user to control where along the shader functions the
|Part 3 - 2D Procedural Textures|
The next step is a 2D texture. Here, two of the axes are used to generate the
texture pattern. A good example of a 2D texture is a checker board. Assuming
the checker pattern is to work on a default plane then the procedural shader
simply divides the X and Y axis into squares and colors each one alternately,
say black and white. This is commonly know as planar mapping. Again, the
texture will only work correctly in the two axes in which the plane lies.
This also explains why a 2D texture appears as lines on the sides of objects.It is
because it has not been placed correctly so that the two axes being used lie flat
on the plane. The same is true if the texture is applied to a sphere using planar mapping.
The shader will appear incorrect at the sides. To overcome this two alternative mapping
modes can be used cylindrical and spherical. For cylinderical
mapping the 2D texture is simple wrapped around the cylinder much like rolling wrapping
paper around a tube. For spherical mapping the 2D texture is wrapped around the object
is the same way a map is wrapped around a sphere to create a globe. In addition another
mode of 2D texture mapping is radial. When this mapping mode is applied
to to a flat plane the pattern will radiant from the center in a circular pattern.
|Part 3 - 3D Procedural Textures|
The final kind of texture is a 3D one. This is a texture that uses all three
axes in order to define the pattern. The classic example of a 3D texture is
noise. The pattern will always be correct irrespective of the object its
being applied to or the orientation at which it is applied. An example of
a 3D noise texture is shown below. Notice that even with a section of the
cube cut away the texture still looks correct. You also hear of 4D textures
being mentioned this is simply a time dependant texture the forth axis being
time. This means that the texture will change over time.