@@ -133,10 +133,12 @@ class Viewer {
133133
134134 origChunks : {
135135 glsl : {
136- gsplatOutputVS : string
136+ gsplatOutputVS : string ,
137+ skyboxPS : string
137138 } ,
138139 wgsl : {
139- gsplatOutputVS : string
140+ gsplatOutputVS : string ,
141+ skyboxPS : string
140142 }
141143 } ;
142144
@@ -149,22 +151,24 @@ class Viewer {
149151 // enable anonymous CORS for image loading in safari
150152 ( app . loader . getHandler ( 'texture' ) as TextureHandler ) . imgParser . crossOrigin = 'anonymous' ;
151153
152- this . origChunks = {
153- glsl : {
154- gsplatOutputVS : ShaderChunks . get ( graphicsDevice , 'glsl' ) . get ( 'gsplatOutputVS' )
155- } ,
156- wgsl : {
157- gsplatOutputVS : ShaderChunks . get ( graphicsDevice , 'wgsl' ) . get ( 'gsplatOutputVS' )
158- }
159- } ;
160-
161154 // render skybox as plain equirect
162155 const glsl = ShaderChunks . get ( graphicsDevice , 'glsl' ) ;
163156 glsl . set ( 'skyboxPS' , glsl . get ( 'skyboxPS' ) . replace ( 'mapRoughnessUv(uv, mipLevel)' , 'uv' ) ) ;
164157
165158 const wgsl = ShaderChunks . get ( graphicsDevice , 'wgsl' ) ;
166159 wgsl . set ( 'skyboxPS' , wgsl . get ( 'skyboxPS' ) . replace ( 'mapRoughnessUv(uv, uniform.mipLevel)' , 'uv' ) ) ;
167160
161+ this . origChunks = {
162+ glsl : {
163+ gsplatOutputVS : glsl . get ( 'gsplatOutputVS' ) ,
164+ skyboxPS : glsl . get ( 'skyboxPS' )
165+ } ,
166+ wgsl : {
167+ gsplatOutputVS : wgsl . get ( 'gsplatOutputVS' ) ,
168+ skyboxPS : wgsl . get ( 'skyboxPS' )
169+ }
170+ } ;
171+
168172 // disable auto render, we'll render only when camera changes
169173 app . autoRender = false ;
170174
@@ -476,6 +480,21 @@ class Viewer {
476480 ShaderChunks . get ( app . graphicsDevice , 'glsl' ) . set ( 'gsplatOutputVS' , gammaChunkGlsl ) ;
477481 ShaderChunks . get ( app . graphicsDevice , 'wgsl' ) . set ( 'gsplatOutputVS' , gammaChunkWgsl ) ;
478482
483+ // force skybox shader to write gamma-space colors (inline pow replaces the
484+ // gammaCorrectOutput call which is a no-op under CameraFrame's GAMMA_NONE)
485+ ShaderChunks . get ( app . graphicsDevice , 'glsl' ) . set ( 'skyboxPS' ,
486+ this . origChunks . glsl . skyboxPS . replace (
487+ 'gammaCorrectOutput(toneMap(processEnvironment(linear)))' ,
488+ 'pow(toneMap(processEnvironment(linear)) + 0.0000001, vec3(1.0 / 2.2))'
489+ )
490+ ) ;
491+ ShaderChunks . get ( app . graphicsDevice , 'wgsl' ) . set ( 'skyboxPS' ,
492+ this . origChunks . wgsl . skyboxPS . replace (
493+ 'gammaCorrectOutput(toneMap(processEnvironment(linear)))' ,
494+ 'pow(toneMap(processEnvironment(linear)) + 0.0000001, vec3f(1.0 / 2.2))'
495+ )
496+ ) ;
497+
479498 // ensure the final compose blit doesn't perform linear->gamma conversion.
480499 RenderTarget . prototype . isColorBufferSrgb = function ( index ) {
481500 return this === app . graphicsDevice . backBuffer ? true : origIsColorBufferSrgb . call ( this , index ) ;
@@ -489,9 +508,11 @@ class Viewer {
489508 this . cameraFrame = null ;
490509 }
491510
492- // restore gsplat output shader chunks to engine defaults
511+ // restore shader chunks to engine defaults
493512 ShaderChunks . get ( app . graphicsDevice , 'glsl' ) . set ( 'gsplatOutputVS' , this . origChunks . glsl . gsplatOutputVS ) ;
494513 ShaderChunks . get ( app . graphicsDevice , 'wgsl' ) . set ( 'gsplatOutputVS' , this . origChunks . wgsl . gsplatOutputVS ) ;
514+ ShaderChunks . get ( app . graphicsDevice , 'glsl' ) . set ( 'skyboxPS' , this . origChunks . glsl . skyboxPS ) ;
515+ ShaderChunks . get ( app . graphicsDevice , 'wgsl' ) . set ( 'skyboxPS' , this . origChunks . wgsl . skyboxPS ) ;
495516
496517 // restore original isColorBufferSrgb behavior
497518 RenderTarget . prototype . isColorBufferSrgb = origIsColorBufferSrgb ;
0 commit comments