[英]Bind Texture2D and TextureCube
I need to pass both a Texture2D and a TextureCube to my pixel shader at the same time. 我需要同时将Texture2D和TextureCube传递给我的像素着色器。
I was previously sending an array of texture's but found that I was not able to send a textureCube as well as this. 我之前发送了一系列纹理,但发现我无法发送一个textureCube。
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. 编辑----尝试实施Caesar的建议后,以下代码会导致错误。 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. ReEdit ----重写了确切的代码......这次工作,不明白为什么。 Thank you very much. 非常感谢你。
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
t0
和t1
指定注册表编号,因此您使用该编号作为PSSetShaderResources
的第一个参数
When you want to set t0
in your C++ Code you do it like so 如果要在C ++代码中设置t0
,可以这样做
pImmediateContext->PSSetShaderResources( 0, 1, &(texture) );
And when you want to set t1
you do it like so 当你想设置t1
你会这样做
pImmediateContext->PSSetShaderResources( 1, 1, &(texture) );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.