3

I need to pass both a Texture2D and a TextureCube to my pixel shader at the same time.

I was previously sending an array of texture's but found that I was not able to send a textureCube as well as this.

This question mentions something called binding but I am unable to find any more information on this and was wondering if someone might be able to point me in direction of a solution for this problem.

Thank you.

Edit---- After attempting to implement Caesar's suggestion the following code causes an error. First-chance exception when the shader is attempted to be read, the problem line is simply

Texture2D texture04 : register( t0 );

Which causes a crash after this:

D3DX11CompileFromFile("Data/Shaders/Effects.fx", 0, 0, "VS", "vs_4_0", 0, 0, 0, &VS_Buffer, 0, 0);
D3DX11CompileFromFile("Data/Shaders/Effects.fx", 0, 0, "PS", "ps_4_0", 0, 0, 0, &PS_Buffer, 0, 0);
d3dDevice_->CreateVertexShader(VS_Buffer->GetBufferPointer(), VS_Buffer->GetBufferSize(), NULL, &VS);

ReEdit---- Rewrote the exact code...worked this time, no idea why. Thank you very much.

Community
  • 1
  • 1
Questioning
  • 1,903
  • 1
  • 29
  • 50

1 Answers1

7

You can register multiple textures in your shader file like so

Texture2D texture04 : register( t0 );    
TextureCube myCubeMap : register( t1 );

The t0 and t1 specify the registry number, and so you use that number as the first parameter for the PSSetShaderResources

When you want to set t0 in your C++ Code you do it like so

pImmediateContext->PSSetShaderResources( 0, 1, &(texture) );

And when you want to set t1 you do it like so

pImmediateContext->PSSetShaderResources( 1, 1, &(texture) );
Caesar
  • 9,483
  • 8
  • 40
  • 66
  • The lines to add the register to my pixel shaders are failing. Texture2D texture04 : register( t0 ); – Questioning Apr 10 '13 at 19:29
  • I updated the main post after when I fixed it but forgot to reply to you again / delete the comment above. It's fixed now! Thanks very much for the help. – Questioning Apr 11 '13 at 09:53