Advertisement

How to make a SkyBox/Cubemap in Direct3D11?

Started by May 18, 2015 04:21 PM
19 comments, last by InfoGeek 9 years, 8 months ago

hi,

all the stuff on the internet is showing its age. i've been following a tutorial on skybox here -> http://www.braynzarsoft.net/index.php?p=D3D11CUBEMAP

it has deprecated and removed stuff like:


D3DX11_IMAGE_LOAD_INFO loadSMInfo;
D3DX11CreateTextureFromFile(...);

and much else...

i found no proper tutorials explaining how to do it in an updated way. i also don't know anything but loading textures using WICTextureLoader from DirectXTex -> https://directxtex.codeplex.com/ , so i have no idea how you would map a map.dds onto the sphere that gets created using a function in that tutorial.

could anyone save me please?

I don't use the WIC texture loader but the stand alone DDSTextureLoader which is just a header and a cpp file available from directXTk sdk. Works like a charm for me.
Advertisement

I don't use the WIC texture loader but the stand alone DDSTextureLoader which is just a header and a cpp file available from directXTk sdk. Works like a charm for me.

i am just using:


DirectX::CreateWICTextureFromFile(d3d->device, texture_file, 0, &texture);

to load texture it works fine, but like i said, i got no idea how to load and map it for a 6 piece map for a skybox. the example from tutorial has a function from what it constructs the sphere(i think)... and uses some weird special structures and methods to load and map it.

I have never used the WIC loader but the loader I mentioned has the ability to load cube maps from a dds.
Take a look at it and experiment with it.

https://directxtex.codeplex.com/wikipage?title=DDSTextureLoader

I have never used the WIC loader but the loader I mentioned has the ability to load cube maps from a dds.
Take a look at it and experiment with it.

https://directxtex.codeplex.com/wikipage?title=DDSTextureLoader

thanks for the tip. it seems i have already tried it while randomly trying all combinations...

vooqrc.png

this appears when using the i am using:


DirectX::CreateDDSTextureFromFile(d3dDevice, L"poop/texture/skymap.dds", &skymaptexture, &skymapSRV);

i am using windows7 and visual studio ultimate 2013 and i think it uses windows sdk 8 or 8.1

any idea why it doesn't work?

Oh I had a similar problem under windows 7. Apparently there's a bug in the way it tries to tell W7 from W8. I fixed it by force defining a macro but I'm on my phone in bed now. I will tell you what it was once I'm on my PC as I can't remember what it was by heart.
Advertisement

i have no idea... i tried using:


#define WINVER 0x0601
#define _WIN32_WINNT 0x0601

all around the place with nothing happening...

i'll wait for you in hopes you know how to make this work.

i tried defining


_WIN32_WINNT=0x0601

under Configuration Properties>C/C++>Proporcessor

as said here -> http://stackoverflow.com/questions/3000231/d-win32-winnt-compiler-warning-with-boost

3) Go in to your project's settings (ALT-F7 on my machine). Under the Configuration Properties>C/C++>Proporcessor heading, add ;_WIN32_WINNT = 0x0501.

i am not sure but i think that works because i don't get errors and it compiles and launches. i cannot say if it works correctly because i have yet to configure lots of stuff to make the skymap work.

howerver, i really don't like it being under some field as an option in some menu tab. i would much prefer it being a simple


#define _WIN32_WINNT 0x0601

why does that not work? is there another way?

Use the DDSTextureLoader to load the cube map.

Build your cube map using texassemble.exe which can put six images together into the same dds file. When you load them into an ID3DShaderResourceView, directx will know how to handle them and you just pass them to your pixel shader and use texture.sample() to select pixels from the cubrmap as shown in the tutorial.

Here is the define I used, as promised.

I put it right before the #if

(not sure why I used 600 rather than 601 but it works so meh.)

#define _WIN32_WINNT 0x0600
// open the file
#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)
ScopedHandle hFile( safe_handle( CreateFile2( fileName,
GENERIC_READ,
FILE_SHARE_READ,
OPEN_EXISTING,
nullptr ) ) );
#else
ScopedHandle hFile( safe_handle( CreateFileW( fileName,
GENERIC_READ,
FILE_SHARE_READ,
nullptr,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr ) ) );
#endif

This topic is closed to new replies.

Advertisement