fix(postproduction): keep MSAA when postproduction is enabled - #794
Open
rihokirss wants to merge 1 commit into
Open
fix(postproduction): keep MSAA when postproduction is enabled#794rihokirss wants to merge 1 commit into
rihokirss wants to merge 1 commit into
Conversation
EffectComposer allocates its ping-pong render targets with samples = 0, so enabling PostproductionRenderer dropped the hardware MSAA of the default framebuffer and every geometry edge came out aliased (SMAA only partly recovers it). Give the composer targets a sample count, exposed as Postproduction.samples (default 4, clamped to capabilities.maxSamples, 0 restores the previous behaviour), and add a slider to the example. Fixes ThatOpen#793
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #793.
Postproduction.initialize()creates theEffectComposerwithout a render target, so three.js allocates the ping-pong targets withsamples = 0. The moment postproduction is enabled, the hardware MSAA of the default framebuffer is gone and every geometry edge is aliased; SMAA only partly recovers it, which is why the postproduction image looks "noisier" than the plain render.This PR gives the composer targets a sample count:
Postproduction.samples(default4, clamped torenderer.capabilities.maxSamples;0restores the previous behaviour), applied right after the composer is created and re-applied by the setter (sampleschange +dispose(), so the framebuffer is re-created on next use);setSize()needs no change —WebGLRenderTarget.setSize()keepssamples;Measured on an office-building model, fixed exterior view, Chrome / AMD Radeon 8060S, 1665×1123 ("hard edges" = share of neighbouring pixel pairs whose luma differs by more than 60):
samples = 0(before)samples = 4(this PR)samples = 0, pixel ratio 2i.e. the same edge quality as pixel ratio 2 for ~0.6 ms per frame instead of 4× the fill rate.
Additional context
depthTexture; the AO / edge-detection passes keep their own single-sample targets, so nothing else changes.yarn build-librariescurrently fails onmaininpackages/coreagainst the published@thatopen/fragments@3.4.7(FragmentsModels.getWorker,getLocalIdsFromItemIdsare not released yet) — unrelated to this change;tscforpackages/frontreports no errors inPostproductionRenderer, and the front Vite build succeeds.fragPathsline, extraneous-deps in the example) are left as they are to keep the diff minimal.What is the purpose of this pull request?
Before submitting the PR, please make sure you do the following:
fixes #793).