Your Ad Here

OpenGL Texture Setup

When you’re creating OpenGL realtime effects, you can use a number of different shaders for texturing:

• The OGL Texture shader, described in the next section, sets up a single 2D texture.

• 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 Cubic Textures, 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.

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

• Connect an OGL 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 OGL 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 OGL Texture Transform node.

• If you are using a fixed function pipeline based shader network, then you can specify how the texture is being 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,
c = GL_TEXTURE_ENV_COLOR)

- Modulate: [ C = Cf*Ct, A = Af * At ]

- Decal: [ C = Cf(1-At) + CtAt, A = Af ]

- Blend: [ C = Cf(1-Ct) + CcCt, A = AfAt ]

- Replace: [ C = Ct, A = At ]

- Add: [ C = Cf+Ct, A = Af + At ]

• 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

• Connect an OGL Cubic Texture node to the shader network.

 

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.

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

• Connect an OGL Texture Transform node to the OGL Texture or OGL Cubic Texture node whose coordinates you wish to manipulate.

 

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.

 

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.

- 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

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

 

In this case, OGL13Texture2 uses target 0, OGL13Texture1uses 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 OGL Cubic Texture nodes and OGL Texture Transform nodes.



SOFTIMAGE|XSI v.6.01     

Return to Softimage XSI Index


Your Ad Here