Sign in to follow this  
rpsathe

How does D3DXFillCubeTexture work?

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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;
}

Share this post


Link to post
Share on other sites
"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).

Share this post


Link to post
Share on other sites
Thanks guys. I was confused because of the comment

// Create volume texture using D3DXFillCubeTexture

Will give it a whirl now.
-Rahul

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this