Jump to content
  • Advertisement
Sign in to follow this  

Shader Error

This topic is 3964 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

Hello, Im trying to render a skybox with 8 vertices and a Texture2D which contains six Textures (dstex.ArraySize = 6;) - dont know if this is called a Texture2DArray. I try to render the first face of the cube with this code:
for(int i=0; i < 1; i++) {		
   skyBoxFaceIndexSC->SetFloat( (float)i);
   d3d10device->Draw(4, 4*i);

envMapShaderView is a view onto the Texture2D(Array) and skyBoxFaceIndex is the index of the face, that should be chosen from the array (0=front, 1=back etc.) But if I run this code I get this error all the time the app is running:
D3D10: ERROR: ID3D10Device::Draw: The view dimension declared in the shader code does not match the view type bound to slot 0 of the Pixel Shader unit. [ EXECUTION ERROR #354: DEVICE_DRAW_VIEW_DIMENSION_MISMATCH ]
My Pixelshader looks like this:
Texture2DArray skyBoxTextures;
SamplerState samSkyBoxTexture {
    Filter = MIN_MAG_MIP_LINEAR;
    AddressU = Clamp;
    AddressV = Clamp; 
float skyBoxFaceIndex;

float4 SkyBox_Render_PS(SKYBOX_VS_OUTPUT input) : SV_Target {
//return starTexture.Sample( samLinear, input.starTexCoord );
return skyBoxTextures.Sample(samSkyBoxTexture, float3(input.starTexCoord, skyBoxFaceIndex));
All I do is using the float2 texture coordinates input.starTexCoord and skyBoxFaceIndex as the index into the Texture2DArray to sample my Texture2DArray. If I comment the line out and use the line above with the sampling of a simple Texture (starTexture.Sample(...) then I DONT get the error. Anyone has an idea what this error means and how to fix it? Thanks!

Share this post

Link to post
Share on other sites
How are you creating your shader resource view? It should be something like this:


viewDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
viewDesc.ViewDimension = D3D10_SRV_DIMENSION_TEXTURE2DARRAY;
viewDesc.Texture2DArray.MostDetailedMip = 0;
viewDesc.Texture2DArray.MipLevels = desc.MipLevels;
viewDesc.Texture2DArray.FirstArraySlice = 0
viewDesc.Texture2DArray.ArraySize = desc.ArraySize;
pDevice->CreateShaderResourceView(pSkyboxTexture, &viewDesc, &envMapShaderView);

Another way to do it would be to load the texture and create the shader resource view for it in one call, using D3DX10CreateShaderResourceViewFromFile. Make sure to fill in the D3DX10_IMAGE_INFO parameter of the D3DX10_IMAGE_LOAD_INFO structure.


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!