Skip to content

fix: preserve portal SDF render target state - #2892

Open
gakialter wants to merge 1 commit into
pmndrs:v11-workingfrom
gakialter:fix/2876-portal-sdf-state
Open

gakialter wants to merge 1 commit into
pmndrs:v11-workingfrom
gakialter:fix/2876-portal-sdf-state

Conversation

@gakialter

Copy link
Copy Markdown

Summary

Initializing blurred portal edges can discard a render target retained by the caller during the React commit. Legacy MeshPortalMaterial resets to the canvas after its SDF passes and skips restoration on errors. The WebGPU implementation already restores target identity and clear state, but resets the caller's active cube face and mip level to zero. Refs #2876.

 SDF initialization layout effect
-  reset to canvas / restore target without its active subresource
+  finally restore caller target, cube face and mip level

The change is limited to the two SDF effects. Fullscreen blend rendering keeps its canvas output: an intermediate blend owns the render loop, renders both scenes into buffers, then presents the mixed quad to the canvas. It is a different responsibility from initializing an offscreen SDF texture.

Evidence

  • Before: 9 of 12 real Chromium cases fail. Legacy loses bound targets and retains its temporary target after mask/SDF render errors. Both implementations reset nonzero cube faces and mip levels. The legacy continuation/post-processing readback is red [255,0,0,255].
    After: All 12 pass; bound-target continuation readback is green [0,255,0,255] on WebGL and native WebGPU. Default targets, cube face 3, mip level 1, clear color/alpha and errors during mask rendering / the first SDF pass are checked. Errors still propagate.
  • node test/portal-sdf-state/run.mjs brackets the actual SDF effect with sibling layout effects. It stops the Canvas frame loop because this initialization runs during a commit, without a frame callback. Continuation is read through WebGL EffectComposer/ShaderPass and WebGPU RenderPipeline. The GPU lane requires backend.isWebGPUBackend, so WebGL fallback cannot count as native WebGPU validation.
  • Targeted ESLint, changed-file Prettier and git diff --check pass. No full repository build/test run. SDF image quality and async readback normalization are outside this regression.

Merge Danger

Door: Two-way. No API or data migration.

Blast Radius: Rendering. Only SDF initialization target restoration changes; blending and the SDF algorithm are preserved.

Checklist

  • Focused browser regression and changelog included.
  • Ready to be merged.

AI disclosure: OpenAI Codex inspected the render paths, reproduced the failures in WebGL/native WebGPU, implemented the fix and focused regression, and executed the reported checks.

@vercel

vercel Bot commented Oct 21, 2026

Copy link
Copy Markdown

@gakialter is attempting to deploy a commit to the Poimandres Team on Vercel.

A member of the Team first needs to authorize it.

This branch has not been deployed

No deployments
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