How to render a cube texture?

Started by
3 comments, last by BBeck 6 years, 4 months ago

When in 2D mode, I create a quad as the mesh and create a 2D texture, that works fine, when in 3D mode, I create a cube as the mesh and create a cube texture, but I can't see anything in the scene?

Why is that?

any clues?

Thanks

Jack

 


	void TestProceduralTexture::Render()
{
    d3d::GetInstance().GetDevice()->SetTransform(D3DTS_WORLD, &m_World);
	    D3DMATERIAL9 mat;
    mat.Ambient = D3DXCOLOR(1.0, 1.0, 1.0, 1.0);
    mat.Diffuse = mat.Ambient;
    mat.Emissive = mat.Ambient;
    mat.Specular = mat.Ambient;
    mat.Power = 5.0f;
	    d3d::GetInstance().GetDevice()->SetMaterial(&mat);
    if (m_2D)
    {
        d3d::GetInstance().GetDevice()->SetTexture(0, m_2DTex);
    }
    else
    {
        d3d::GetInstance().GetDevice()->SetTexture(0, m_3DTex);
    }
	
    m_mesh->DrawSubset(0);
}
	

Advertisement

I don't know for Direct3D, but in OpenGL when using cubemap textures, you need 3d texture coordinates too. These 3D texture coordinates are in fact the direction vector pointing to the pixels of the texture cube.

Seems to be working now. The frame rate really suffers when I update the cubemap texture at runtime, the cubemap size beyond 16 pixels is unacceptable... Originally, I had a frame rate of about 170fps, after using a 16-pixel runtime cubemap, it drops to 70fps.. with 64 pixels, it is about 3fps... can't use anymore.

 

Update:

Maybe I consider generating cubemap textures offline over a time range..

Thanks

Jack

You didn't say what you are using to do it. From the code, it looks to be DX, probably DX9. It's been forever since I've done any DX11 and I've forgotten most of it. I skipped DX9, which is substantially different. But if you want I have working basic engine code as a Visual Studio project on my website available for download. That's a working code example. I re-coded it in OpenGL and there is a video link there where you can see what the engine basically looks like when the code is running to see if it's code you are interested in before bothering to download.

http://virtuallyprogramming.com/DirectX11/Tutorials/Tutorials.html

 

This topic is closed to new replies.

Advertisement