Skip to content

PlanarShadowMap: clear the shadow map as a depth texture - #55

Open
ASDAlexander77 wants to merge 1 commit into
NVIDIA-RTX:mainfrom
ASDAlexander77:planar-shadow-map-clear
Open

ASDAlexander77 wants to merge 1 commit into
NVIDIA-RTX:mainfrom
ASDAlexander77:planar-shadow-map-clear

Conversation

@ASDAlexander77

Copy link
Copy Markdown

Problem

PlanarShadowMap::Clear clears the shadow map with clearTextureFloat, but the texture has a depth format, and NVRHI refuses that:

Texture ShadowMap cannot be cleared with clearTextureFloat because it's a depth-stencil texture. Use clearDepthStencilTexture instead.

So a standalone PlanarShadowMap (created with a resolution, not as a cascade of a CascadedShadowMap) never gets cleared, on any API.

Change

Clear depth to 1 with clearDepthStencilTexture over the view's subresources (stencil too if the format has one), as CascadedShadowMap::Clear does.

Found with a standalone planar shadow map on D3D11, D3D12 and Vulkan; after the change the error is gone and the shadow map is cleared each time it's re-rendered.

🤖 Generated with Claude Code

PlanarShadowMap::Clear cleared its depth texture with clearTextureFloat, which
NVRHI refuses for depth-stencil textures ("Use clearDepthStencilTexture
instead"), so standalone planar shadow maps were never cleared. Clear depth to
1 with clearDepthStencilTexture over the view's subresources, as
CascadedShadowMap::Clear does.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ASDAlexander77 added a commit to ASDAlexander77/native_ts_graphics that referenced this pull request Oct 10, 2026
Two Donut patches, also NVIDIA-RTX/Donut#55 and #56:
- Donut-planar-shadow-map-clear: PlanarShadowMap::Clear cleared its depth
  texture with clearTextureFloat, which NVRHI refuses for depth textures;
  clear it with clearDepthStencilTexture, as CascadedShadowMap::Clear does.
- Donut-planar-shadow-map-whole-scene-depth-range:
  SetupWholeSceneDirectionalLightView gave the projection the scene's depth
  range along the light negated, right only for scenes centered on the
  light's node (D3D clamps the rest to the near or far plane, Vulkan clips
  it away).

The interop's planar shadow maps now clear and fit with these functions; the
scene bounds still grow by 1% first, so that geometry on them isn't on the
light's near or far plane, which Vulkan clips at.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant