@@ -23,6 +23,14 @@ const fragmentShader = /* glsl */ `
2323 #endif
2424
2525 #ifdef SSAO
26+ #define SSAO_TEXTURE
27+ #endif
28+
29+ #if DEBUG_COMPOSE == ssao
30+ #define SSAO_TEXTURE
31+ #endif
32+
33+ #ifdef SSAO_TEXTURE
2634 uniform sampler2D ssaoTexture;
2735 #endif
2836
@@ -146,8 +154,12 @@ const fragmentShader = /* glsl */ `
146154 result = cas(result, uv, sharpness);
147155 #endif
148156
157+ #ifdef SSAO_TEXTURE
158+ mediump float ssao = texture2DLodEXT(ssaoTexture, uv0, 0.0).r;
159+ #endif
160+
149161 #ifdef SSAO
150- result *= texture2DLodEXT(ssaoTexture, uv0, 0.0).r ;
162+ result *= ssao ;
151163 #endif
152164
153165 #ifdef FRINGING
@@ -167,7 +179,31 @@ const fragmentShader = /* glsl */ `
167179 result = toneMap(result);
168180
169181 #ifdef VIGNETTE
170- result *= vignette(uv);
182+ mediump float vig = vignette(uv);
183+ result *= vig;
184+ #endif
185+
186+ // debug output
187+ #ifdef DEBUG_COMPOSE
188+
189+ #ifdef BLOOM
190+ #if DEBUG_COMPOSE == bloom
191+ result = bloom * bloomIntensity;
192+ #endif
193+ #endif
194+
195+ #if DEBUG_COMPOSE == ssao
196+ result = vec3(ssao);
197+ #endif
198+
199+ #if DEBUG_COMPOSE == vignette
200+ result = vec3(vig);
201+ #endif
202+
203+ #if DEBUG_COMPOSE == scene
204+ result = scene.rgb;
205+ #endif
206+
171207 #endif
172208
173209 #ifdef GAMMA_CORRECT_OUTPUT
@@ -229,6 +265,8 @@ class RenderPassCompose extends RenderPassShaderQuad {
229265
230266 _key = '' ;
231267
268+ _debug = null ;
269+
232270 constructor ( graphicsDevice ) {
233271 super ( graphicsDevice ) ;
234272
@@ -246,6 +284,17 @@ class RenderPassCompose extends RenderPassShaderQuad {
246284 this . sharpnessId = scope . resolve ( 'sharpness' ) ;
247285 }
248286
287+ set debug ( value ) {
288+ if ( this . _debug !== value ) {
289+ this . _debug = value ;
290+ this . _shaderDirty = true ;
291+ }
292+ }
293+
294+ get debug ( ) {
295+ return this . _debug ;
296+ }
297+
249298 set bloomTexture ( value ) {
250299 if ( this . _bloomTexture !== value ) {
251300 this . _bloomTexture = value ;
@@ -367,7 +416,8 @@ class RenderPassCompose extends RenderPassShaderQuad {
367416 `-${ this . fringingEnabled ? 'fringing' : 'nofringing' } ` +
368417 `-${ this . taaEnabled ? 'taa' : 'notaa' } ` +
369418 `-${ this . isSharpnessEnabled ? 'cas' : 'nocas' } ` +
370- `-${ this . _srgb ? 'srgb' : 'linear' } ` ;
419+ `-${ this . _srgb ? 'srgb' : 'linear' } ` +
420+ `-${ this . _debug ?? '' } ` ;
371421
372422 if ( this . _key !== key ) {
373423 this . _key = key ;
@@ -380,7 +430,8 @@ class RenderPassCompose extends RenderPassShaderQuad {
380430 ( this . fringingEnabled ? '#define FRINGING\n' : '' ) +
381431 ( this . taaEnabled ? '#define TAA\n' : '' ) +
382432 ( this . isSharpnessEnabled ? '#define CAS\n' : '' ) +
383- ( this . _srgb ? '' : '#define GAMMA_CORRECT_OUTPUT\n' ) ;
433+ ( this . _srgb ? '' : '#define GAMMA_CORRECT_OUTPUT\n' ) +
434+ ( this . _debug ? `#define DEBUG_COMPOSE ${ this . _debug } \n` : '' ) ;
384435
385436 const fsChunks =
386437 shaderChunks . decodePS +
0 commit comments