When you’re creating DirectX realtime effects, you can use a number of different shaders for texturing:
• The DX Texture shader, described in the next section, sets up a single 2D texture.
• The DX Cubic Texture shader, described in Cubic Textures, sets up a cubic texture space in which a texture image is used for each face of the cube.
• The DX Texture Transform shader, described in Texture Coordinate Manipulation, allows you to manipulate texture coordinates, and create texture coordinates for tasks like reflection mapping.
You can use a single texture node to texture an object, or use several texture nodes together for more complex effects. This is described in Multi-texturing.
The texture shaders described in this section can be used in a fixed function pipeline or a programmable pipeline.
DX Texture and DX Cubic Texture nodes need to be bound to a texture target. A texture target is a layer in which a texture is set. These layers are then modulated together either by a fixed function pipeline or programmatically via a fragment shader. The number of available texture targets depends on the hardware you are using.
To set up a single 2D texture
• Connect an DX Texture node to your shader network. You can specify an image to be used as well as texture projections.
To change the image or the texture projection used, open the property page of the DX Texture node. Then click the New button next to the texture image to open a menu of options you can use to choose a texture.
You can also set the following properties:
• The target to which the texture is bound.
• A border color, which you should specify if you’re going to clamp the texture to a border in a subsequent DX Texture Transform node.
• If you are using a fixed function pipeline based shader network, then you can specify how this texture is modulated with the object. The order in which the object is shaded and modulated is as follows:
1.The object is shaded either by a fixed function shading node, vertex colors or a programmable vertex shader
2.The texture set in target 0 is then modulated on top of the previous shading
3.The texture set in target 1 is then modulated on top of the texture set in target 0
4.This continues until you reach the maximum number of texture targets available on your hardware
The available texture modulation modes are (f = fragment, t = texture)
- Modulate [ C = Cf*Ct, A = Af * At ]
• You can also control mipmapping on textures using the Filter options.
- Magnification Filter controls how textures are filtered when texels get magnified—that is, when their coverage exceeds the area of one pixel.
- Minification Filter controls how textures are filtered when texels get minified—that is, when their coverage is less than the area of one screen pixel.
- You can use the Mipmap LOD Bias to add an offset to the coverage of texels.
Cubic textures are used to define cubic texture spaces with an image on each face of the cube. Cubic textures are useful for a variety of tasks, but most notably, for reflection/refraction maps and normalization maps.
To set up a cubic texture
• Connect a DX Cubic Texture node to the shader network.
The DX Cubic Texture node needs to connect to six image clips. They are mapped to the left, right, bottom, top, front, and back side of the cube space.
The DX Cubic Texture node has all of the parameters of the DX Texture node except for the Texture Space controls. A cubic texture’s projection must be provided by either a DX Texture Transform node or a vertex shader (see Programmable DirectX Shaders).
Texture Coordinate Manipulation
Texture coordinate manipulations, such as wrapping modes, texture transforms, and fixed function texture coordinate generation can all be done using the DX Texture Transform shader. Fixed function texture coordinate generation is typically used to generate texture coordinates for reflection mapping.
To set up texture coordinate manipulation
• Connect a DX Texture Transform node to the DX Texture or DX Cubic Texture node whose coordinates you wish to manipulate.
You need to specify on which texture target each DX Texture Transform shader operates. To do so, open the DX Texture Transform shader’s property editor and set the Texture Target to the same target used by the affected texture.
You can also set the following parameters:
• The Type of texture coordinates generated. This can be any one of the following:
- Explicit: tells the GPU to let UV coordinates coming from XSI to go through.
- Normal in camera space: UVW coordinates are generated with the XYZ value of the normals in camera space.
- Position in camera space: UVW coordinates are generated with the XYZ value of the position in camera space.
- Reflection vector in camera space: UVW coordinates are generated with the XYZ value of the reflection vector in camera space.
• You can also set wrapping modes which control how texels are sampled when they go out of [0,1] UV space.
- Wrap: texels are repeated if they go out of bounds.
- Mirror: texels are repeated and mirrored if they go out of bounds.
- Clamp: texels are clamped.
- Border: – texels are clamped, but areas that are out of bounds use the border color specified in the DX Texture.
- Mirror one: texels are repeated and mirrored once if they go out of bounds.
• Additional texture transforms can be applied on top of the generated UVs by activating the Transform option and setting the Translation, Rotation and Scaling values.
|
Texture coordinate generation types other than Explicit, and texture transforms are both are part of the fixed function pipeline, and thus are ignored when using a vertex shader. |
• Lastly, you can set the Perturbation and Perturbation-Luminance values for pixel shaders that use texbem style instructions
With DirectX-based realtime shaders, you can set more than one texture in a single draw pass. The number of textures you can set depends on the hardware you are using. Please refer to your hardware specifications.
To set up multi-texturing
• Chain multiple DX Texture nodes together, then set each DX Texture node’s target correctly.
In this case, DXTexture1 uses target 0, DXTexture uses target 1, and DXTextureCoord uses target 1. If two textures are using the same target, the closest texture to the draw node wins. You can also chain together DX Cubic Texture nodes and DX Texture Transform nodes.
SOFTIMAGE|XSI v.6.01