OpenGL Texture Setup

When you’re creating OpenGL realtime effects, you can use a number of different shaders for texturing. The texture shaders described in this section can be used in a fixed-function pipeline or a programmable pipeline.

• The OGL13Texture shader, described in 2D Textures, sets up a single 2D texture. The OGL13Texture shader is the most flexible and fully-featured of the texture shaders.

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 OGL 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 OGL Texture Transform shader, described in Texture Coordinate Manipulation, allows you to manipulate texture coordinates and create texture coordinates for tasks like reflection mapping.

About Texture Targets

OGL Texture and OGL 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.

2D Textures

To set up a single 2D texture

1. Connect an OGL13Texture node to your shader network. You can specify an image to be used as well as texture projections.

 

2. To change the image used, open the OGL13Texture node’s property editor and click the New button next to the Image option to open a menu of options you can use to retrieve an image clip.

3. To change the texture projection used, open the OGL13Texture node’s property editor and click the New button next to the Texture Space option to choose a new texture projection.

 

4. 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 OGL13Texture node.

• You can specify the texture environment modulation mode.

• If texture quality is less important (for example, the texture is far away or has a lot of noise already), then you can activate Compression to save texture memory. This transforms your texture to S3TC format which allows it to compress about 4:1 on video memory.

• You can specify a format. This is used when you need to change the format to DSDT if you need a texture to be converted to DSDT format for the purpose of using bump reflection instructions on NV2x based video cards.

• You can also control mipmapping or anisotropic filtering 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.

- Finally, you can use anisotropic filtering to get a crisper minification filter. To do so, set the Minification Filter to Linear and increase the Anisotropic Filtering Level.

Cubic Textures

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

1. Connect an OGL13CubicTexture node to the shader network.

 

2. The OGL 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.

3. The OGL Cubic Texture node has all of the parameters of the OGL Texture node except for the Texture Space controls. A cubic texture’s projection must be provided by either an OGL Texture Transform node or a vertex shader (see Programmable OpenGL Shading).

Texture Coordinate Manipulation

Texture coordinate manipulations, such as wrapping modes, texture transforms, and fixed function texture coordinate generation can all be done using the OGL Texture Transform shader. Fixed function texture coordinate generation is typically used to generate texture coordinates for reflection mapping.

To set up texture coordinate manipulation

1. Connect an OGL13TexCoord node to the OGL Texture or OGL Cubic Texture node whose coordinates you wish to manipulate.

 

2. You need to specify on which texture target each OGL Texture Transform shader operates. To do so, open the OGL Texture Transform shader’s property editor and set the Texture Target to the same target used by the affected texture.

 

3. 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 Softimage to go through.

- Object Linear: UVW coordinates are generated with the XYZ position of the vertex in object space.

- Eye Linear: UVW coordinates are generated with the XYZ position of the vertex in eye space.

- Sphere Map: UV coordinates are generated as a spherical map.

- Reflection Map: UVW coordinates are generated as a reflection map.

- Normal Map: UVW coordinates are generated with the XYZ value of the normals in object 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.

- Clamp: texels are clamped.

- Border: texels are clamped, but areas that are out of bounds use the border color specified in the OGL Texture.

- Mirror: texels are repeated and mirrored if they go out of bounds.

- Mirror one: texels are repeated and mirrored once if they go out of bounds.

- Clamp to edge: texels are clamped to edges.

• 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.

Multi-texturing

With OpenGL-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

1. Chain multiple OGL13Texture nodes together, then set each OGL Texture node’s target correctly.

 

2. In this case, OGL13Texture2 uses target 0, OGL13Texture1 uses target 1, and OGL13Texture uses target 2. If two textures are using the same target, the closest texture to the draw node wins.

You can also chain together OGL13CubicTexture nodes and OGL13TexCoord nodes.



Autodesk Softimage v.7.5