我目前正在实现延迟渲染管道,但我仍然坚持使用阴影贴图。我已经成功地将其实施到前向管道中。
我所做的步骤是:
编辑:使用新结果图像更新代码:
float checkShadow(vec3 position) {
// get position in light view
mat4 invView = inverse(cameraView);
vec4 pEyeDir = sunBias * sunProjection * sunView * invView * vec4(position, 1.0);
// light view clip space
pEyeDir = pEyeDir / pEyeDir.w;
// get uv coordinates
vec2 sTexCoords = pEyeDir.xy * 0.5 + 0.5;
float bias = 0.0001;
float depth = texture(sunDepthTex, sTexCoords).r - bias;
float shadow = 1.0f;
if(pEyeDir.z * 0.5 + …
Run Code Online (Sandbox Code Playgroud) 目前通过microsofts示例,值得注意的是,每个命令列表只使用一个cbv_srv_uav堆(+可能在其他采样器堆上).
每个CommandList可以使用多个堆吗?
所以我设置堆和范围
this->mRSVHeap = new urd::DescriptorHeap(
*this->mDevice,
urd::DescriptorHeapType::CBV_SRV_UAV,
1, // shader visible
2); // space for 2 descriptors (2 textures)
this->mConstHeap = new urd::DescriptorHeap(
*this->mDevice,
urd::DescriptorHeapType::CBV_SRV_UAV,
1, // shader visible
1); // space for 1 descriptor
urd::DescriptorRange ranges[3];
ranges[0].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 2, 0); // first and second descriptor in rsv heap (t0, t1)
ranges[1].Init(D3D12_DESCRIPTOR_RANGE_TYPE_CBV, 1, 0); // first descriptor in cbv heap (b0)
ranges[2].Init(D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 1, 2); // same texture used as first range (again first descriptor in rsv, accessable by t2) …
Run Code Online (Sandbox Code Playgroud) c++ ×1
deferred ×1
descriptor ×1
direct3d ×1
directx-12 ×1
glsl ×1
heap ×1
mapping ×1
opengl ×1
shadow ×1