Jump to content
  • Advertisement

GovardhanDGosavi

Member
  • Content Count

    9
  • Joined

  • Last visited

Community Reputation

121 Neutral

About GovardhanDGosavi

  • Rank
    Newbie
  1. There is a fourth option available of using the DirectX toolkit library. It contains utilities for text rendering, 2d drawing, dds texture loading etc
  2. GovardhanDGosavi

    (SOLVED) Having problem setting the mipmap level

    That was the problem all along! The linear sampler state could sample correctly from the different mip levels but the anisotropic state could not. After reading your post I passed the correct sampler state and now it works. Thanks a lot! :)
  3. GovardhanDGosavi

    (SOLVED) Having problem setting the mipmap level

    Ok. Here is the vertex shader: // sky vertex shader // data types struct VertexShaderInput { float3 position : POSITION; }; struct VertexShaderOutput { float4 position : SV_POSITION; float3 texCoord : TEXCOORD; }; // things to set in application code cbuffer PerFrame { matrix wvp; } // shader logic VertexShaderOutput main( VertexShaderInput IN ) { VertexShaderOutput OUT; OUT.position = mul( wvp, float4( IN.position, 1.0f ) ).xyww; OUT.texCoord = IN.position; return OUT; } The pixel shader: // sky pixel shader // data types struct PixelShaderInput { float4 position : SV_POSITION; float3 texCoord : TEXCOORD; }; // things to set in application code SamplerState samplerState : register(s0); TextureCube SkyMap : register( t0 ); // shader logic half4 main( PixelShaderInput IN ) : SV_TARGET { return SkyMap.SampleLevel(samplerState, IN.texCoord, 0); } The c++ draw code: immediateContext->UpdateSubresource( mWVPConstantBuffer, 0, nullptr, &constantBuffer, 0, 0 ); immediateContext->IASetInputLayout(mInputLayout); immediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); UINT stride = sizeof(MinimumVertex); UINT offset = 0; immediateContext->IASetVertexBuffers(0, 1, &mVertexBuffer, &stride, &offset); immediateContext->IASetIndexBuffer(mIndexBuffer,DXGI_FORMAT_R16_UINT, 0); immediateContext->VSSetShader( mVertexShader, nullptr, 0 ); immediateContext->VSSetConstantBuffers(0, 1, &mWVPConstantBuffer ); immediateContext->PSSetShader( mPixelShader, nullptr, 0 ); immediateContext->PSSetSamplers( 0, 1, &mLinearSamplerState); immediateContext->PSSetShaderResources( 0, 1, &mShaderResourceView); immediateContext->RSSetState( mRSNoCull ); immediateContext->OMSetDepthStencilState(mDSSLast, 0); immediateContext->DrawIndexed( mNumIndices, 0, 0 ); immediateContext->OMSetDepthStencilState(nullptr, 0); Yeah I think you are right about the default texture loading but I did it separately just to be sure
  4. GovardhanDGosavi

    (SOLVED) Having problem setting the mipmap level

    It seems the various mip levels are loaded correctly because I can set which one to use in the sampler state that I set in c++ using samplerDesc.MipLODBias = 0.0f;
  5. GovardhanDGosavi

    (SOLVED) Having problem setting the mipmap level

    I did it separately in order to do D3D11_SRV_DIMENSION_TEXTURECUBE in the description. If I was creating the SRV at the same time as creating the texture I dont get to specify D3D11_SHADER_RESOURCE_VIEW_DESC    
  6. GovardhanDGosavi

    (SOLVED) Having problem setting the mipmap level

    Sure: D3D11_TEXTURE2D_DESC SMTextureDesc; cubeMapTexture->GetDesc(&SMTextureDesc); D3D11_SHADER_RESOURCE_VIEW_DESC SMViewDesc; SMViewDesc.Format = SMTextureDesc.Format; SMViewDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE; SMViewDesc.TextureCube.MipLevels = SMTextureDesc.MipLevels; SMViewDesc.TextureCube.MostDetailedMip = 0; hr = device->CreateShaderResourceView(cubeMapTexture, &SMViewDesc, &mShaderResourceView); Edit: Yeah went through that earlier. So if I specify 0 then all the mip levels should be loaded which should allow  SampleLevel to work but it does not in this case :( 
  7. GovardhanDGosavi

    (SOLVED) Having problem setting the mipmap level

    So I have managed to track the problem to how the textures were created.  hr = DirectX::CreateDDSTextureFromFile( device, L"..\\data\\Cubemaps\\sunsetcube1024.dds", (ID3D11Resource**)&cubeMapTexture, nullptr, 0 ); By specifying the last parameter as 0 I can get the highest mip level but I am still not able to access the different mip levels in hlsl using SampleLevel. Changing the last parameter in SampleLevel does not seem to have any effect and specifying 10 as the last parameter in CreateDDSTextureFromFile gives only the 10th mip level
  8. GovardhanDGosavi

    (SOLVED) Having problem setting the mipmap level

    I have tried Albedo.Sample(samplerState, IN.texCoord); as well and sampler is bound correctly. I am getting the correct output if I edit the dds texture file to contain only the highest mip level. I just want to be able to access the different mip levels in shader
  9. I have been trying to get the highest mipmap level to show for a long time now but nothing seems to work and the output always shows one of the lower mipmap levels. I tried creating a sampler state like this: D3D11_SAMPLER_DESC samplerDesc; ZeroMemory(&samplerDesc, sizeof(D3D11_SAMPLER_DESC)); 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.ComparisonFunc = D3D11_COMPARISON_NEVER; samplerDesc.MipLODBias = 0.0f; samplerDesc.MinLOD = 0.0f; samplerDesc.MaxLOD = 0.0f; HRESULT HR = device->CreateSamplerState(&samplerDesc, &anisotropicSamplerState); if(FAILED(HR)) { MessageBox( nullptr, TEXT("Failed to create rasterizer state"), TEXT("Error"), MB_OK ); return false; }   but changing that seems to toggle between the last two mip levels. I have also tried to  do it in the shader float4 baseColor = Albedo.SampleLevel(samplerState, IN.texCoord, 0); This also does not have any effect. Am I doing it the right way or is there another method?
  10. bought new phone. galaxy note. five point three inches of awesomeness.
  11. Thanks for this, I was having the same problem following the tutorials at rastertek.com and your solution worked fine!
  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!