Jump to content
  • Advertisement
Sign in to follow this  
Itca_bemes

DX11 Skymap Problem

This topic is 1275 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

[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.

Edited by itseemstobeme

Share this post


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

Share this post


Link to post
Share on other sites

[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.

Edited by itseemstobeme

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!