Jump to content
  • Advertisement
Sign in to follow this  

How to render a cube texture?

Recommended Posts

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);
}
	

Share this post


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

Share this post


Link to post
Share on other sites

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

Edited by lucky6969b

Share this post


Link to post
Share on other sites

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

 

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  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!