Skymap Problem

Started by
2 comments, last by Itca_bemes 9 years, 3 months ago

[newbie question]
Hello guys,
I'm having a problem with texturing my skybox. I'm trying to load a cube map (.dds format) on top of a box (loaded from .obj).

The picture probably will indicate more advanced users what could be possibly wrong.

My guess is that texture coords have to be fixed.

Vertex Shader


struct VertexType
{
    float4 position : POSITION;
    float2 texcoord : TEXCOORD0;
    float3 normal : NORMAL;
};

struct SkymapVertexType    //output structure for skymap vertex shader
{
    float4 position : SV_POSITION;
    float3 texcoord : TEXCOORD0;
};

SkymapVertexType SKYMAP_VS(VertexType input)
{
    input.position.w = 1.0f;
    SkymapVertexType output = (SkymapVertexType)0;

    output.position = mul(input.position, world_matrix);
    output.position = mul(output.position, view_matrix);
    output.position = mul(output.position, projection_matrix);

    output.texcoord = input.position;

    return output;
}

Pixel Shader


SamplerState sample_type;
TextureCube skymap;
float4 SKYMAP_PS(SkymapVertexType input) : SV_TARGET
{
    return skymap.Sample(sample_type, input.texcoord);
}

Loading Texture


    D3DX11_IMAGE_LOAD_INFO load_info;
    load_info.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE;

    ID3D11Texture2D* texture{ nullptr };
    HRESULT hr = D3DX11CreateTextureFromFile(device, filename, &load_info, nullptr,
                                     (ID3D11Resource**)&texture, nullptr);
    if(FAILED(hr)) return false;

    D3D11_TEXTURE2D_DESC texture_desc;
    texture->GetDesc(&texture_desc);

    // Create Resource Shader View

    D3D11_SHADER_RESOURCE_VIEW_DESC resview_desc;
    resview_desc.Format = texture_desc.Format;
    resview_desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
    resview_desc.TextureCube.MipLevels = texture_desc.MipLevels;
    resview_desc.TextureCube.MostDetailedMip = 0;

    hr = device->CreateShaderResourceView(texture, &resview_desc, &m_texture);

Thanks.

Advertisement

What color is your clear color? if it's that darkish blue, then it looks to me that the winding order on that triangle is wrong. otherwise it's likely that the texcoords are not mapped correctly along that triangle.

nvm

[SOLVED]

Hi again,

Suprisingly I forgot to set the proper shaders before drawing it. It's the little things that makes your head spinning the whole day smile.png I need to be more careful. Thanks for your time.

edit.

Btw. I had also noticed that in my .obj file the box is moved Y:+10, that's why we see empty blue space below.

This topic is closed to new replies.

Advertisement