Issue rendering texture in C++ DirectX Tool Kit

140 Views Asked by At

I'm trying to load texture from .jpg file with function CreateWICtextureFromFile from DirectX Tool kit. My image gets loaded as texture but the output has jitter and missing information. This are my code snpshots

    D3D11_SAMPLER_DESC samplerdesc;
    samplerdesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
    samplerdesc.AddressU = D3D11_TEXTURE_ADDRESS_WRAP;
    samplerdesc.AddressV = D3D11_TEXTURE_ADDRESS_WRAP;
    samplerdesc.AddressW = D3D11_TEXTURE_ADDRESS_WRAP;
    samplerdesc.MipLODBias = 0.0f;
    samplerdesc.MaxAnisotropy = 1;
    samplerdesc.ComparisonFunc = D3D11_COMPARISON_ALWAYS;
    samplerdesc.BorderColor[0] = 0.5;
    samplerdesc.BorderColor[1] = 0.5;
    samplerdesc.BorderColor[2] = 0.5;
    samplerdesc.BorderColor[3] = 0.5;
    samplerdesc.MinLOD = 0;
    samplerdesc.MaxLOD = D3D11_FLOAT32_MAX;

    Device->CreateSamplerState(&samplerdesc, &samplestate);

===================================

DirectX::CreateWICTextureFromFile(Device, L"xyz.jpg", nullptr, &resourceview);

===================================

Pixel shader file

    texcolor = shader.Sample(Sample, tex);
    texcolor.w=0;
    return  textureColor;

===============================

    texDesc.Width = width;
    texDesc.Height = height;
    texDesc.MipLevels = 1;
    texDesc.ArraySize = 1;
    texDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
    texDesc.SampleDesc.Count = 1;
    texDesc.Usage = D3D11_USAGE_DEFAULT;
    texDesc.BindFlags = D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE;
    texDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED; 
0

There are 0 best solutions below