dx11 入门 Tutorial 07: shader中纹理的简单运算 ;dx中多个ConstantBuffer的使用 DirectXSampleBrowser(June 2010)
1.首先是dx中 textureView , 用于告知shader我有一个texture资源
A texture and sampler state are objects like the constant buffers。
纹理资源和采样状态类似于先前的constantBuffer,所以在draw前,需要进行set纹理Buffer和samplerState:
g_pImmediateContext->PSSetShaderResources( 0, 1, &g_pTextureRV );
g_pImmediateContext->PSSetSamplers( 0, 1, &g_pSamplerLinear );
2.texture坐标左上角为(0,0) 右下角为(1,1) 和dx的屏幕坐标系(即经过viewport变换后)类似
3.texture语句的解读:
Texture2D txDiffuse : register(t0);
- txDiffuse is the object storing our texture that we passed in from the code above, when we bound the resource view g_pTextureRV to it.
一: txDiffuse 存储我们在dx code内与resourceView关联的资源: g_pImmediateContext->PSSetShaderResources( 0, 1, &g_pTextureRV );
return txDiffuse.Sample( samLinear, input.Tex ) * vMeshColor;
- input.Tex is the coordinates of the texture that we have specified in the source.
二:input.Tex是vs传入的,经过线性插值的每个pixel纹理坐标
最后将texture颜色值和color值结合。

浙公网安备 33010602011771号