Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
89 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

  Contents

 Preface
 Texture Replaces
 Light

 Tecture Operation
 Unit

 Dark Mapping
 Alpha Operations

 Source code
 Printable version

 


  The Series

 The Basics
 First Steps to
 Animation

 Multitexturing
 Building Worlds
 With X Files


 

The Texture Operation Unit

Before Direct3D 6 the pipeline stages determined the texel color and blended this color with the color of the primitive interpolated from the vertices (multipass texturing). From Direct3D 6 up to 8 texture operation units can be cascaded together to apply multiple textures to a common primitive in a single pass (multitexturing). The results of each stage carry over to the next one, and the result of the final stage is rasterized on the polygon. This process is called "texture blending cascade".

Each texture operation unit has six associated render states, which control the flow of pixels through the unit, as well as additional render states associated with filtering, clamping and so on.

Most 3D hardware will only support applying two textures at the same time to a common primitive. Newer hardware handles three texture operations at once, but a lot of existing 3D hardware won't support multitexturing at all. The demo for this tutorial won't run on these cards (you'll see an informative message box :-) ).

Three of the render states in each texture operation unit are associated with RGB (color), and another three are associated with alpha.

You can find the best article on multitexturing in DirectX in Game Developer September 1998, page 33 ff. from Mitchell, Tatro and Bullard. The online version can be found at Gamasutra. They have developed a tool to visualize the texture operations ... try it. NVIDIA has also developed a tool to visualize the texture operations. Another intersting article is "Multipass Rendering and the Magic of Alpha Rendering" by Brian Hook. You can find it in Game Developer August 1997, page 12 ff. The book Real-time Rendering from Thomas Möller and Eric Haines gives you an overview on texturing methods. You will find a perfect explanation of the Direct3D IM texturing methods in 3D Game Programming with C++ from John De Goes. Another good book comes from Peter Kovach: Inside Direct3D from Microsoft Press. In addition, I've found the examples from ATI very interesting. They're using the Direct3D 7 framework to show a few nice effects.

Multitexturing Support

First, you have to check your 3D hardware's multitexturing support in the framework call ConfirmDevice():


...
HRESULT CMyD3DApplication::ConfirmDevice
  (DDCAPS* pddDriverCaps, D3DDEVICEDESC7* d3dDeviceDesc )
{
  // Accept devices that really support multiple textures.
  if( pd3dDeviceDesc->wMaxTextureBlendStages > 1 )
    if( pd3dDeviceDesc->wMaxSimultaneousTextures > 1 )
      if( pd3dDeviceDesc->dwTextureOpCaps & D3DTEXOPCAPS_MODULATE )
        return S_OK;
  
  return E_FAIL;
}
...

The following examples are not optimized in any way. They are for instructional purposes only.




Next : Dark Mapping