How does D3DXFillCubeTexture work?

Started by
4 comments, last by rpsathe 17 years, 12 months ago
Folks, can anybody explain how D3DXFillCubeTexture works? msdn sample gives this example // Define a function that matches the prototype of LPD3DXFILL3D VOID WINAPI ColorCubeFill (D3DXVECTOR4* pOut, const D3DXVECTOR3* pTexCoord, const D3DXVECTOR3* pTexelSize, LPVOID pData) { *pOut = D3DXVECTOR4(pTexCoord->x, pTexCoord->y, pTexCoord->z, 0.0f); } // Create volume texture using D3DXFillCubeTexture if (FAILED (hr = D3DXFillCubeTexture (m_pTexture, ColorCubeFill, NULL))) { return hr; } Does this mean for every direction *pTexCoord, a value of direction itself gets stored in each pixel of faces of cube map? In other words, if I just wanted to save x coordinate of the direction in all rgba components of the pixel in cube-map, would my ColorCubeFill look something like this? VOID WINAPI ColorCubeFill (D3DXVECTOR4* pOut, const D3DXVECTOR3* pTexCoord, const D3DXVECTOR3* pTexelSize, LPVOID pData) { *pOut = D3DXVECTOR4(pTexCoord->x, pTexCoord->x, pTexCoord->x, pTexCoord->x); } How does this work internally? Does DX takes this function and depending on the size of each face of cube-map (lets say 16x16), it generates 256 directions and iterates over these directions and calls ColorCubeFill for each one of the those directions and evaluates what gets stored in that particular location on the face of a cube-map? Any pointers to examples (other than PRTDemo that comes along with Dx) will be appreciated too. Thanks -Rahul
Advertisement
Quote:Original post by rpsathe
In other words, if I just wanted to save x coordinate of the direction in all rgba components of the pixel in cube-map, would my ColorCubeFill look something like this?
Yes, that's correct.
Quote:How does this work internally? Does DX takes this function and depending on the size of each face of cube-map (lets say 16x16), it generates 256 directions and iterates over these directions and calls ColorCubeFill for each one of the those directions and evaluates what gets stored in that particular location on the face of a cube-map?
That's probably more or less what happens.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Does this work with Cube-maps or volume-textures. I just realized the comment
in the sample code.

// Create volume texture using D3DXFillCubeTexture
if (FAILED (hr = D3DXFillCubeTexture (m_pTexture, ColorCubeFill, NULL)))
{
return hr;
}

"Cube texture" is the term the D3DX functions use for what is often known as cube map. "Volume texture" is an actual 3D texture. The D3DX API has Fill function for both (D3DXFillCubeTexture and D3DXFillVolumeTexture).
Agh, I completely missed that.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Thanks guys. I was confused because of the comment

// Create volume texture using D3DXFillCubeTexture

Will give it a whirl now.
-Rahul

This topic is closed to new replies.

Advertisement