File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -105,7 +105,24 @@ export class ShockWaveDemo extends PostProcessingDemo {
105105 ndc . x = ( event . clientX / window . innerWidth ) * 2.0 - 1.0 ;
106106 ndc . y = - ( event . clientY / window . innerHeight ) * 2.0 + 1.0 ;
107107
108- ndc . z = await this . depthPickingPass . readDepth ( ndc ) ;
108+ const renderer = this . composer . getRenderer ( ) ;
109+ let depth = await this . depthPickingPass . readDepth ( ndc ) ;
110+
111+ if ( renderer . capabilities . reversedDepthBuffer ) {
112+
113+ depth = 1.0 - depth ;
114+
115+ } else if ( renderer . capabilities . logarithmicDepthBuffer ) {
116+
117+ const camera = this . camera ;
118+ const d = Math . pow ( 2.0 , depth * Math . log2 ( camera . far + 1.0 ) ) - 1.0 ;
119+ const a = camera . far / ( camera . far - camera . near ) ;
120+ const b = camera . far * camera . near / ( camera . near - camera . far ) ;
121+ depth = a + b / d ;
122+
123+ }
124+
125+ ndc . z = depth ;
109126 ndc . z = ndc . z * 2.0 - 1.0 ;
110127
111128 // Convert from NDC to world position.
You can’t perform that action at this time.
0 commit comments