Skip to content

Commit 6ce42a4

Browse files
authored
Merge pull request #390 from pmndrs/perf/multisampling-default
perf(EffectComposer): lower default multisampling to 4
2 parents 3fc0987 + 096815e commit 6ce42a4

3 files changed

Lines changed: 30 additions & 1 deletion

File tree

‎docs/effect-composer.mdx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The `EffectComposer` must wrap all your effects. It will manage them for you.
1414
autoClear?: boolean
1515
/** Whether the last pass automatically renders to the screen. Set to `false` when rendering to a target of your own (e.g. via a trailing CopyPass) instead. */
1616
autoRenderToScreen?: boolean
17+
/** MSAA sample count, default 4. Set to 0 to disable it, e.g. when using SMAA or FXAA instead. */
1718
multisampling?: number
1819
frameBufferType?: TextureDataType
1920
/** For effects that support DepthDownsamplingPass */

‎src/EffectComposer.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export const EffectComposer = /* @__PURE__ */ memo(function EffectComposer({
200200
depthBuffer,
201201
enableNormalPass,
202202
stencilBuffer,
203-
multisampling = 8,
203+
multisampling = 4,
204204
frameBufferType = HalfFloatType,
205205
renderPass = defaultRenderPass,
206206
mergeMode = 'auto',

‎src/tests/EffectComposer.test.tsx‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,4 +1529,32 @@ describe('EffectComposer', () => {
15291529
expect(composer.outputBuffer.width).toBe(cssSize.width)
15301530
})
15311531
})
1532+
1533+
describe('defaults', () => {
1534+
it('uses 4 MSAA samples unless multisampling is set', async () => {
1535+
const ref = React.createRef<EffectComposerImpl>()
1536+
1537+
await React.act(async () =>
1538+
root.render(
1539+
<EffectComposer ref={ref}>
1540+
<WrappedEffectA />
1541+
</EffectComposer>
1542+
)
1543+
)
1544+
const composer = await waitForComposer(ref)
1545+
expect(composer.multisampling).toBe(4)
1546+
1547+
await React.act(async () =>
1548+
root.render(
1549+
<EffectComposer ref={ref} multisampling={0}>
1550+
<WrappedEffectA />
1551+
</EffectComposer>
1552+
)
1553+
)
1554+
const next = await waitForNewComposer(ref, composer)
1555+
expect(next.multisampling).toBe(0)
1556+
1557+
await React.act(async () => root.render(null))
1558+
})
1559+
})
15321560
})

0 commit comments

Comments
 (0)