Conversation
WalkthroughThe PR refactors the bloom post-processing pipeline by consolidating a multi-pass manual implementation into a new Changes
Sequence DiagramsequenceDiagram
participant Renderer
participant BloomPass
participant Materials as Materials<br/>(Threshold/Down/Up)
participant RTs as Render Targets<br/>(Pool)
participant Tonemap as ToneMappingPass
Renderer->>BloomPass: configure(scene texture from framebuffer)
BloomPass->>Materials: Threshold pass
Materials->>RTs: render to threshold RT
loop Down-sample iterations
BloomPass->>Materials: Horizontal down-sample
Materials->>RTs: render to down-sample H RT
BloomPass->>Materials: Vertical down-sample
Materials->>RTs: render to down-sample V RT
end
loop Up-sample iterations (reverse)
BloomPass->>Materials: Up-sample with accumulated texture
Materials->>RTs: render to up-sample RT
end
BloomPass->>RTs: release intermediate RTs
BloomPass->>Tonemap: pass final bloom texture
Tonemap->>Renderer: complete post-process pipeline
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~60 minutes
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (2)
packages/effects-webgl/src/gl-framebuffer.ts (1)
74-95: Attachment textures now sized from viewport (good), but there’s some redundant workUsing
this.viewport[2/3]to size color/depth textures and callingtex.update({ data })here is correct and helps ensureTexture.getWidth()/getHeight()work for framebuffer-backed textures used in post-process (e.g., bloom).Two small nits you may want to clean up later:
resetColorTexturesalready callstex.update({ data });updateAttachmentTexturesthen callsupdateagain for the same color textures, which is redundant GPU work. You could limitupdateAttachmentTexturesto rebuildingattachmentTexturesor add a flag/parameter to skip the extra updates when the caller already resized textures.- For
depth_24_stencil_8_texture,depthTextureandstencilTexturereference the sameGLTexture, so itstextureBuffergets pushed twice intoattachmentTextures. It’s harmless but unnecessary; an identity check (if (this.depthTexture !== this.stencilTexture)) would avoid duplication.packages/effects-core/src/render/render-frame.ts (1)
12-13: Bloom–ToneMapping wiring looks correct; consider makinggaussianStepconfigurableThe new pipeline:
- DrawObjectPass → BloomPass (using
sceneTextureHandleto capture the pre‑bloom scene texture),- then ToneMappingPass consuming both the scene texture and Bloom’s result,
is wired correctly and matches how
BloomPass.configure/executeandToneMappingPassusesceneTextureHandleandmainTexture.
const gaussianStep = 7hard‑codes a relatively high iteration count, which may be expensive on low‑end/mobile GPUs and can’t be tuned per effect/volume. Consider deriving the iteration count from post-process settings (e.g., volume bloom options) or at least exposing it viaRenderFrameOptionsso applications can adjust quality vs. performance.Also applies to: 121-135
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
packages/effects-core/src/render/post-process-pass.ts(1 hunks)packages/effects-core/src/render/render-frame.ts(2 hunks)packages/effects-core/src/render/render-target-pool.ts(1 hunks)packages/effects-core/src/render/renderer.ts(2 hunks)packages/effects-webgl/src/gl-framebuffer.ts(1 hunks)packages/effects-webgl/src/gl-renderer.ts(5 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2024-10-18T09:15:08.038Z
Learnt from: wumaolinmaoan
Repo: galacean/effects-runtime PR: 691
File: packages/effects-core/src/plugins/timeline/playables/color-property-mixer-playable.ts:39-42
Timestamp: 2024-10-18T09:15:08.038Z
Learning: In `packages/effects-core/src/plugins/timeline/playables/color-property-mixer-playable.ts`, when accumulating color components, avoid using `clone()` methods because it can cause additional garbage collection overhead.
Applied to files:
packages/effects-core/src/render/render-target-pool.tspackages/effects-webgl/src/gl-renderer.tspackages/effects-core/src/render/render-frame.tspackages/effects-core/src/render/post-process-pass.ts
🧬 Code graph analysis (4)
packages/effects-core/src/render/renderer.ts (3)
plugin-packages/editor-gizmo/src/shape.ts (1)
Texture(139-160)packages/effects-core/src/render/framebuffer.ts (1)
Framebuffer(28-82)plugin-packages/model/src/gltf/loader-impl.ts (1)
material(1479-1562)
packages/effects-webgl/src/gl-renderer.ts (1)
packages/effects-core/src/gl/index.ts (1)
glContext(8-8)
packages/effects-core/src/render/render-frame.ts (1)
packages/effects-core/src/render/post-process-pass.ts (1)
BloomPass(18-171)
packages/effects-core/src/render/post-process-pass.ts (4)
packages/effects-core/src/render/render-pass.ts (3)
RenderPass(217-309)RenderTargetHandle(100-176)RenderPassDestroyOptions(206-210)packages/effects-core/src/render/framebuffer.ts (1)
Framebuffer(28-82)packages/effects-core/src/render/renderer.ts (1)
Renderer(14-145)packages/effects-core/src/render/render-frame.ts (1)
getTextureSize(217-219)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (2)
packages/effects-core/src/render/render-target-pool.ts (1)
87-95: No functional change in RT creation blockThe added blank line only separates texture creation from framebuffer creation; behavior and resource handling remain unchanged.
packages/effects-core/src/render/post-process-pass.ts (1)
17-36: BloomPass construction and configuration are consistent with the new pipeline
- Materials for threshold, down-sample H/V, and up-sample are created with the correct screen-space vertex shader and appropriate fragment shaders, and render state (no blending, no depth, no culling) is appropriate for full-screen passes.
sceneTextureHandlewiring inconfigurecorrectly captures the pre-bloom scene texture for ToneMappingPass to use later as_SceneTex.No functional issues here; this setup matches how
RenderFrameandToneMappingPassexpect BloomPass to behave.Also applies to: 48-86, 88-92
Summary by CodeRabbit
Release Notes
New Features
Improvements
✏️ Tip: You can customize this high-level summary in your review settings.