How to sample a R8_UINT texture in hlsl/direct12?

pixelhistory 0 信誉分
2024-12-01T03:24:36.96+00:00

I'm a newbie in DX12 and trying to visualize Stencil buffer onto screen. I've been copied stencil plane slice into a DXGI_FORMAT_R8_UINT texture, but when HLSL samples this texture it just returns 0, and finally my render result is a black screen.

Here is the texture2d info from PIX:

5acf2e9d8619442d8bf22e4833828f90.image

the sampling code is very straightforward, but when I debug pixel history at uv coordinate (0.398125, 0.534167), it just return a very small value from Sample expression:

 Texture2D gDiffuseMap : register(t0);  
 SamplerState gsamAnisotropicWrap : register(s4);   
 float4 PS_PixelOverdraw(VertexOut pin) : SV_TARGET 
 {     
     float4 diffuseAlbedo = gDiffuseMap.Sample(gsamAnisotropicWrap, pin.TexC);     
     return float4(diffuseAlbedo.xyz, 1.0f); 
 }  

dbc06791fc4742a0a792627fe39ce3f6.image

Finally, the whole output is a black screen.

Windows API - Win32
Windows API - Win32
一组适用于桌面和服务器应用程序的核心 Windows 应用程序编程接口 (API)。 以前称为 Win32 API。
116 个问题
{count} 票

你的答案

问题作者可以将答案标记为“接受的答案”,这有助于用户了解已解决作者问题的答案。