@gnsx/three 0.186.6 → 0.186.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,7 +10,7 @@ import { builtin } from '../../../nodes/accessors/BuiltinNode.js';
10
10
  import { CubeUVReflectionMapping, EquirectangularReflectionMapping, EquirectangularRefractionMapping, NoToneMapping } from '../../../constants.js';
11
11
  // WITH_GENESYS
12
12
  import { vec4 } from '../../../nodes/tsl/TSLCore.js';
13
- import { colorizeQuadOverdraw, colorizeShaderComplexity, DEBUG_VIEW_QUAD_OVERDRAW, DEBUG_VIEW_SHADER_COMPLEXITY, DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS, SHADER_COMPLEXITY_QUAD_COUNT_SCALE } from '../../../nodes/display/ComplexityDebug.js';
13
+ import { colorizeQuadOverdraw, colorizeShaderComplexity, DEBUG_VIEW_OVERDRAW, DEBUG_VIEW_SHADER_COMPLEXITY, DEBUG_VIEW_SHADER_COMPLEXITY_AND_OVERDRAW, SHADER_COMPLEXITY_QUAD_COUNT_SCALE } from '../../../nodes/display/ComplexityDebug.js';
14
14
  // !WITH_GENESYS
15
15
  import { hashArray } from '../../../nodes/core/NodeUtils.js';
16
16
  import { error } from '../../../utils.js';
@@ -1035,9 +1035,9 @@ class NodeManager extends DataMap {
1035
1035
  }
1036
1036
 
1037
1037
  // WITH_GENESYS
1038
- if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY || renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS ) {
1038
+ if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY || renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_OVERDRAW ) {
1039
1039
 
1040
- const complexity = renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS
1040
+ const complexity = renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_OVERDRAW
1041
1041
  ? sampled.r.mul( sampled.g ).mul( SHADER_COMPLEXITY_QUAD_COUNT_SCALE )
1042
1042
  : sampled.r;
1043
1043
 
@@ -1045,7 +1045,7 @@ class NodeManager extends DataMap {
1045
1045
 
1046
1046
  }
1047
1047
 
1048
- if ( renderer.debug.view === DEBUG_VIEW_QUAD_OVERDRAW ) {
1048
+ if ( renderer.debug.view === DEBUG_VIEW_OVERDRAW ) {
1049
1049
 
1050
1050
  return vec4( colorizeQuadOverdraw( sampled.r ), 1 ).renderOutput( NoToneMapping, renderer.currentColorSpace );
1051
1051
 
@@ -1131,7 +1131,10 @@ class WebGLBackend extends Backend {
1131
1131
 
1132
1132
  if ( context.mrt !== null && context.textures !== null ) {
1133
1133
 
1134
- state.setMRTBlending( context.textures, context.mrt, material );
1134
+ // WITH_GENESYS
1135
+ state.setMRTBlending( context.textures, context.mrt, material, object );
1136
+ // !WITH_GENESYS
1137
+ // state.setMRTBlending( context.textures, context.mrt, material );
1135
1138
 
1136
1139
  }
1137
1140
 
@@ -12,7 +12,8 @@ import { Color } from '../../../math/Color.js';
12
12
  import { Vector4 } from '../../../math/Vector4.js';
13
13
  import { error, ReversedDepthFuncs, warnOnce } from '../../../utils.js';
14
14
  // WITH_GENESYS
15
- import { debugDrawAccumulates } from '../../../nodes/display/ComplexityDebug.js';
15
+ import { debugDrawAccumulates, debugDrawReplacesCost } from '../../../nodes/display/ComplexityDebug.js';
16
+ import { DEBUG_VIEW_FRONT_BACK_FACE } from '../../../nodes/display/FrontBackFaceDebug.js';
16
17
  // !WITH_GENESYS
17
18
 
18
19
  let equationToGL, factorToGL;
@@ -288,7 +289,7 @@ class WebGLState {
288
289
 
289
290
  }
290
291
 
291
- setMRTBlending( textures, mrt, material ) {
292
+ setMRTBlending( textures, mrt, material, object = null ) {
292
293
 
293
294
  const gl = this.gl;
294
295
  const drawBuffersIndexedExt = this.backend.drawBuffersIndexedExt;
@@ -301,6 +302,24 @@ class WebGLState {
301
302
 
302
303
  }
303
304
 
305
+ // WITH_GENESYS
306
+ // Every attachment matches the single-target path. Opaque material blending would replace a sum that should add.
307
+ if ( debugDrawAccumulates( this.backend.renderer, material, object ) ) {
308
+
309
+ const dst = debugDrawReplacesCost( this.backend.renderer.debug.view, material ) ? gl.ZERO : gl.ONE;
310
+
311
+ for ( let i = 0; i < textures.length; i ++ ) {
312
+
313
+ drawBuffersIndexedExt.blendEquationSeparateiOES( i, gl.FUNC_ADD, gl.FUNC_ADD );
314
+ drawBuffersIndexedExt.blendFuncSeparateiOES( i, gl.ONE, dst, gl.ONE, gl.ZERO );
315
+
316
+ }
317
+
318
+ return;
319
+
320
+ }
321
+ // !WITH_GENESYS
322
+
304
323
  for ( let i = 0; i < textures.length; i ++ ) {
305
324
 
306
325
  const texture = textures[ i ];
@@ -929,9 +948,16 @@ class WebGLState {
929
948
 
930
949
  const { gl } = this;
931
950
 
932
- material.side === DoubleSide
951
+ // WITH_GENESYS
952
+ const drawBothSides = material.side === DoubleSide || ( this.backend.renderer.debug.view === DEBUG_VIEW_FRONT_BACK_FACE && material.isShadowPassMaterial !== true );
953
+
954
+ drawBothSides
933
955
  ? this.disable( gl.CULL_FACE )
934
956
  : this.enable( gl.CULL_FACE );
957
+ // !WITH_GENESYS
958
+ // material.side === DoubleSide
959
+ // ? this.disable( gl.CULL_FACE )
960
+ // : this.enable( gl.CULL_FACE );
935
961
 
936
962
  let flipSided = ( material.side === BackSide );
937
963
  if ( frontFaceCW ) flipSided = ! flipSided;
@@ -939,10 +965,13 @@ class WebGLState {
939
965
  this.setFlipSided( flipSided );
940
966
 
941
967
  // WITH_GENESYS
942
- // WebGL has no cached render pipeline. One+One is applied on each draw instead.
968
+ // WebGL has no cached render pipeline. The accumulate blend is applied on each draw instead.
969
+ // Alpha is replaced so it stays coverage, as in a shaded pass, for later compositing.
943
970
  if ( debugDrawAccumulates( this.backend.renderer, material, object ) ) {
944
971
 
945
- this.setBlending( AdditiveBlending, AddEquation, OneFactor, OneFactor, AddEquation, OneFactor, OneFactor, material.blendColor, material.blendAlpha, true );
972
+ const dstFactor = debugDrawReplacesCost( this.backend.renderer.debug.view, material ) ? ZeroFactor : OneFactor;
973
+
974
+ this.setBlending( CustomBlending, AddEquation, OneFactor, dstFactor, AddEquation, OneFactor, ZeroFactor, material.blendColor, material.blendAlpha, true );
946
975
 
947
976
  } else if ( material.blending === NormalBlending && material.transparent === false ) {
948
977
 
@@ -16,7 +16,8 @@ import {
16
16
 
17
17
  import { error, ReversedDepthFuncs, warn, warnOnce } from '../../../utils.js';
18
18
  // WITH_GENESYS
19
- import { debugDrawAccumulates } from '../../../nodes/display/ComplexityDebug.js';
19
+ import { debugDrawAccumulates, debugDrawReplacesCost } from '../../../nodes/display/ComplexityDebug.js';
20
+ import { DEBUG_VIEW_FRONT_BACK_FACE } from '../../../nodes/display/FrontBackFaceDebug.js';
20
21
  // !WITH_GENESYS
21
22
 
22
23
  import GPUComputePipelineDescriptor from '../descriptors/GPUComputePipelineDescriptor.js';
@@ -110,18 +111,22 @@ class WebGPUPipelineUtils {
110
111
  }
111
112
 
112
113
  // WITH_GENESYS
113
- // Accumulate shader cost with One+One. Opaque materials normally disable blending.
114
+ // Quad overdraw and translucent shader complexity add. Opaque shader complexity replaces
115
+ // the stored cost, so the nearest surface wins without a depth pre-pass.
116
+ // Alpha is replaced so it stays coverage, as in a shaded pass, for later compositing.
114
117
  if ( debugDrawAccumulates( backend.renderer, material, object ) ) {
115
118
 
119
+ const replaceCost = debugDrawReplacesCost( backend.renderer.debug.view, material );
120
+
116
121
  materialBlending = {
117
122
  color: {
118
123
  srcFactor: GPUBlendFactor.One,
119
- dstFactor: GPUBlendFactor.One,
124
+ dstFactor: replaceCost ? GPUBlendFactor.Zero : GPUBlendFactor.One,
120
125
  operation: GPUBlendOperation.Add
121
126
  },
122
127
  alpha: {
123
128
  srcFactor: GPUBlendFactor.One,
124
- dstFactor: GPUBlendFactor.One,
129
+ dstFactor: GPUBlendFactor.Zero,
125
130
  operation: GPUBlendOperation.Add
126
131
  }
127
132
  };
@@ -942,7 +947,12 @@ class WebGPUPipelineUtils {
942
947
 
943
948
  //
944
949
 
945
- descriptor.cullMode = ( material.side === DoubleSide ) ? GPUCullMode.None : GPUCullMode.Back;
950
+ // WITH_GENESYS
951
+ // Front/back face draws both windings. Depth still hides a face behind the shell.
952
+ const drawBothSides = material.side === DoubleSide || ( this.backend.renderer.debug.view === DEBUG_VIEW_FRONT_BACK_FACE && material.isShadowPassMaterial !== true );
953
+ descriptor.cullMode = drawBothSides ? GPUCullMode.None : GPUCullMode.Back;
954
+ // !WITH_GENESYS
955
+ // descriptor.cullMode = ( material.side === DoubleSide ) ? GPUCullMode.None : GPUCullMode.Back;
946
956
 
947
957
  return descriptor;
948
958