# DirectX 11 - Skybox Texture messed up

I'm attempting to create a skybox and I'm currently having some issues with the texture where it looks like this:

It seems the textures are not really "sticking to their sides" correctly as it looks like different sides are blending with each other. I'm guessing this at least but it's basically a jumbled mess of textures and I'm honestly not sure why. I feel like I may of messed up my code as it's been a pain to get this working, so I'd love to know if I have.

Firstly I load in a basic cube model and as well load in the skybox texture using CreateDDSTextureFromFileEx from DirectXTK.

hr = CreateDDSTextureFromFileEx(Graphics::GetGraphics()->GetD3DDevice(), L"Skybox.dds", 0, D3D11_USAGE_DEFAULT, D3D11_BIND_SHADER_RESOURCE, 0, D3D11_RESOURCE_MISC_TEXTURECUBE, false, nullptr, &texture);


I then as well create the samplerLinear

    D3D11_SAMPLER_DESC sampDesc;
ZeroMemory(&sampDesc, sizeof(sampDesc));
sampDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
sampDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
sampDesc.MinLOD = 0;
sampDesc.MaxLOD = D3D11_FLOAT32_MAX;

Graphics::GetGraphics()->GetD3DDevice()->CreateSamplerState(&sampDesc, &samplerLinear);


I then just render everything using this:

// Set the input layout
Graphics::GetGraphics()->GetImmediateContext()->IASetInputLayout(newVertexLayout);

Graphics::GetGraphics()->GetImmediateContext()->IASetVertexBuffers(0, 1, &mesh->GetMeshData()->VertexBuffer, &mesh->GetMeshData()->VBStride, &mesh->GetMeshData()->VBOffset);
Graphics::GetGraphics()->GetImmediateContext()->IASetIndexBuffer(mesh->GetMeshData()->IndexBuffer, DXGI_FORMAT_R16_UINT, 0);

Graphics::GetGraphics()->GetImmediateContext()->PSSetSamplers(0, 1, &samplerLinear);

Graphics::GetGraphics()->GetImmediateContext()->OMSetDepthStencilState(depthStencil, 0);

Graphics::GetGraphics()->GetImmediateContext()->DrawIndexed(mesh->GetMeshData()->IndexCount, 0, 0); //If you change the number of indices, you've got to change the 6 as well to the new number of indices

Graphics::GetGraphics()->GetImmediateContext()->OMSetDepthStencilState(NULL, 0);


The shader object I doesn't really have much that I imagine is worth noting. It pretty much just holds the constantbuffer, vertex and pixel shaders. Updating it then just updates the constant buffer.

I am also setting a new input layer as I found some sources when attempting to get my skybox working that I needed a different inputlayout to the one I had originally but I wasn't sure what exactly I needed so I just have this:

HRESULT hr;

D3D11_INPUT_ELEMENT_DESC newLayout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, D3D11_APPEND_ALIGNED_ELEMENT, D3D11_INPUT_PER_VERTEX_DATA, 0 },
};

UINT numElements = ARRAYSIZE(newLayout);

// Create the input layout

if (FAILED(hr))
return hr;

return hr;


The skybox shader itself is nothing special:

TextureCube skyMap : register(t0);
SamplerState samLinear : register(s0);

//--------------------------------------------------------------------------------------
// Constant Buffer Variables
//--------------------------------------------------------------------------------------
cbuffer ConstantBuffer : register(b0)
{
matrix World;
matrix View;
matrix Projection;
}

//--------------------------------------------------------------------------------------
struct VS_OUTPUT
{
float4 Pos : SV_POSITION;
float3 Normal : NORMAL;
float3 Tex : TEXCOORD0;
};

//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
VS_OUTPUT VS(float4 Pos : POSITION, float3 Normal : NORMAL, float3 Tex : TEXCOORD) //The variables passed in need to be in the same layout as the input layout within Application.cpp
{
VS_OUTPUT output = (VS_OUTPUT)0;

// Convert from local space to world space
output.Pos = mul(Pos, World);
output.Pos = mul(output.Pos, View);
output.Pos = mul(output.Pos, Projection);
//output.Pos.z = -1.0f;

output.Tex = Tex;

return output;
}

//--------------------------------------------------------------------------------------