1
1
import type { TextureDataType } from 'three'
2
- import { HalfFloatType } from 'three'
2
+ import { HalfFloatType , NoToneMapping } from 'three'
3
3
import React , {
4
4
forwardRef ,
5
5
useMemo ,
@@ -32,11 +32,12 @@ export const EffectComposerContext = createContext<{
32
32
resolutionScale ?: number
33
33
} > ( null ! )
34
34
35
- export type EffectComposerProps = {
35
+ export type EffectComposerProps = {
36
36
enabled ?: boolean
37
37
children : JSX . Element | JSX . Element [ ]
38
38
depthBuffer ?: boolean
39
- disableNormalPass ?: boolean
39
+ /** Only used for SSGI currently, leave it disabled for everything else unless it's needed */
40
+ enableNormalPass ?: boolean
40
41
stencilBuffer ?: boolean
41
42
autoClear ?: boolean
42
43
resolutionScale ?: number
@@ -62,7 +63,7 @@ export const EffectComposer = React.memo(
62
63
renderPriority = 1 ,
63
64
autoClear = true ,
64
65
depthBuffer,
65
- disableNormalPass ,
66
+ enableNormalPass ,
66
67
stencilBuffer,
67
68
multisampling = 8 ,
68
69
frameBufferType = HalfFloatType ,
@@ -89,7 +90,7 @@ export const EffectComposer = React.memo(
89
90
// Create normal pass
90
91
let downSamplingPass = null
91
92
let normalPass = null
92
- if ( ! disableNormalPass ) {
93
+ if ( enableNormalPass ) {
93
94
normalPass = new NormalPass ( scene , camera )
94
95
normalPass . enabled = false
95
96
effectComposer . addPass ( normalPass )
@@ -109,7 +110,7 @@ export const EffectComposer = React.memo(
109
110
multisampling ,
110
111
frameBufferType ,
111
112
scene ,
112
- disableNormalPass ,
113
+ enableNormalPass ,
113
114
resolutionScale ,
114
115
] )
115
116
@@ -170,6 +171,15 @@ export const EffectComposer = React.memo(
170
171
}
171
172
} , [ composer , children , camera , normalPass , downSamplingPass , instance ] )
172
173
174
+ // Disable tone mapping because threejs disallows tonemapping on render targets
175
+ useEffect ( ( ) => {
176
+ const currentTonemapping = gl . toneMapping
177
+ gl . toneMapping = NoToneMapping
178
+ return ( ) => {
179
+ gl . toneMapping = currentTonemapping
180
+ }
181
+ } , [ ] )
182
+
173
183
// Memoize state, otherwise it would trigger all consumers on every render
174
184
const state = useMemo (
175
185
( ) => ( { composer, normalPass, downSamplingPass, resolutionScale, camera, scene } ) ,
0 commit comments