@gnsx/three 0.186.5 → 0.186.6

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.
@@ -3,7 +3,7 @@
3
3
  * Copyright 2010-2026 Three.js Authors
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
- import { DynamicDrawUsage, RenderObjectRefreshType, Color, Vector2, Vector3, Vector4, Matrix2, Matrix3, Matrix4, error, UnsignedIntType, IntType, RedFormat, RedIntegerFormat, DepthFormat, DepthStencilFormat, AlphaFormat, RGFormat, RGIntegerFormat, RGBFormat, RGBIntegerFormat, EventDispatcher, MathUtils, warn, WebGLCoordinateSystem, WebGPUCoordinateSystem, ColorManagement, SRGBTransfer, NoToneMapping, StaticDrawUsage, InterleavedBufferAttribute, InterleavedBuffer, NoColorSpace, log as log$1, warnOnce, Texture, Compatibility, LessCompare, LessEqualCompare, GreaterCompare, GreaterEqualCompare, NearestFilter, Sphere, BackSide, DoubleSide, CubeTexture, CubeReflectionMapping, CubeRefractionMapping, TangentSpaceNormalMap, NoNormalPacking, NormalRGPacking, NormalGAPacking, ObjectSpaceNormalMap, RED_GREEN_RGTC2_Format, RG11_EAC_Format, InstancedBufferAttribute, InstancedInterleavedBuffer, DataTexture, RGBAFormat, FloatType, DataArrayTexture, FramebufferTexture, LinearMipmapLinearFilter, DepthTexture, Material, LineBasicMaterial, LineDashedMaterial, NoBlending, MeshNormalMaterial, SRGBColorSpace, RenderTarget, BoxGeometry, Mesh, Scene, LinearFilter, CubeCamera, EquirectangularReflectionMapping, EquirectangularRefractionMapping, AddOperation, MixOperation, MultiplyOperation, MeshBasicMaterial, MeshLambertMaterial, MeshPhongMaterial, HalfFloatType, ClampToEdgeWrapping, BufferGeometry, OrthographicCamera, PerspectiveCamera, LinearSRGBColorSpace, CubeUVReflectionMapping, BufferAttribute, MeshStandardMaterial, MeshPhysicalMaterial, MeshToonMaterial, MeshMatcapMaterial, SpriteMaterial, PointsMaterial, ShadowMaterial, Uint32BufferAttribute, Uint16BufferAttribute, ByteType, UnsignedByteType, ShortType, UnsignedShortType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedInt248Type, UnsignedInt5999Type, UnsignedInt101111Type, NormalBlending, SrcAlphaFactor, OneMinusSrcAlphaFactor, AddEquation, MaterialBlending, Object3D, LinearMipMapLinearFilter, Plane, Float32BufferAttribute, UVMapping, Data3DTexture, VSMShadowMap, PCFShadowMap, ProfilerService, BasicShadowMap, CubeDepthTexture, SphereGeometry, LinearMipmapNearestFilter, NearestMipmapLinearFilter, Float16BufferAttribute, yieldToMain, REVISION, ArrayCamera, PlaneGeometry, FrontSide, CustomBlending, ZeroFactor, CylinderGeometry, Quaternion, WebXRController, RAD2DEG, PCFSoftShadowMap, FrustumArray, Frustum, RGBAIntegerFormat, TimestampQuery, createCanvasElement, MaxEquation, MinEquation, ReverseSubtractEquation, SubtractEquation, OneMinusConstantAlphaFactor, ConstantAlphaFactor, OneMinusConstantColorFactor, ConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcColorFactor, DstAlphaFactor, DstColorFactor, SrcAlphaSaturateFactor, SrcColorFactor, OneFactor, CullFaceNone, CullFaceBack, CullFaceFront, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, ReversedDepthFuncs, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, R11_EAC_Format, SIGNED_R11_EAC_Format, SIGNED_RG11_EAC_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, SIGNED_RED_GREEN_RGTC2_Format, MirroredRepeatWrapping, RepeatWrapping, NearestMipmapNearestFilter, NotEqualCompare, EqualCompare, AlwaysCompare, NeverCompare, LinearTransfer, getByteLength, isTypedArray, NotEqualStencilFunc, GreaterStencilFunc, GreaterEqualStencilFunc, EqualStencilFunc, LessEqualStencilFunc, LessStencilFunc, AlwaysStencilFunc, NeverStencilFunc, DecrementWrapStencilOp, IncrementWrapStencilOp, DecrementStencilOp, IncrementStencilOp, InvertStencilOp, ReplaceStencilOp, ZeroStencilOp, KeepStencilOp, SpotLight, PointLight, DirectionalLight, RectAreaLight, AmbientLight, HemisphereLight, LightProbe, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping, NeutralToneMapping, Group, Loader, FileLoader, MaterialLoader, ObjectLoader } from './three.core.js';
6
+ import { DynamicDrawUsage, RenderObjectRefreshType, Color, Vector2, Vector3, Vector4, Matrix2, Matrix3, Matrix4, error, UnsignedIntType, IntType, RedFormat, RedIntegerFormat, DepthFormat, DepthStencilFormat, AlphaFormat, RGFormat, RGIntegerFormat, RGBFormat, RGBIntegerFormat, EventDispatcher, MathUtils, warn, WebGLCoordinateSystem, WebGPUCoordinateSystem, ColorManagement, SRGBTransfer, NoToneMapping, StaticDrawUsage, InterleavedBufferAttribute, InterleavedBuffer, NoColorSpace, log as log$1, warnOnce, Texture, Compatibility, LessCompare, LessEqualCompare, GreaterCompare, GreaterEqualCompare, NearestFilter, Sphere, BackSide, DoubleSide, CubeTexture, CubeReflectionMapping, CubeRefractionMapping, TangentSpaceNormalMap, NoNormalPacking, NormalRGPacking, NormalGAPacking, ObjectSpaceNormalMap, RED_GREEN_RGTC2_Format, RG11_EAC_Format, InstancedBufferAttribute, InstancedInterleavedBuffer, DataTexture, RGBAFormat, FloatType, DataArrayTexture, FramebufferTexture, LinearMipmapLinearFilter, DepthTexture, NormalBlending, SrcAlphaFactor, OneMinusSrcAlphaFactor, AddEquation, MaterialBlending, NoBlending, Material, LineBasicMaterial, LineDashedMaterial, MeshNormalMaterial, SRGBColorSpace, RenderTarget, BoxGeometry, Mesh, Scene, LinearFilter, CubeCamera, EquirectangularReflectionMapping, EquirectangularRefractionMapping, AddOperation, MixOperation, MultiplyOperation, MeshBasicMaterial, MeshLambertMaterial, MeshPhongMaterial, HalfFloatType, ClampToEdgeWrapping, BufferGeometry, OrthographicCamera, PerspectiveCamera, LinearSRGBColorSpace, CubeUVReflectionMapping, BufferAttribute, MeshStandardMaterial, MeshPhysicalMaterial, MeshToonMaterial, MeshMatcapMaterial, SpriteMaterial, PointsMaterial, ShadowMaterial, Uint32BufferAttribute, Uint16BufferAttribute, ByteType, UnsignedByteType, ShortType, UnsignedShortType, UnsignedShort4444Type, UnsignedShort5551Type, UnsignedInt248Type, UnsignedInt5999Type, UnsignedInt101111Type, Object3D, LinearMipMapLinearFilter, Plane, Float32BufferAttribute, UVMapping, Data3DTexture, VSMShadowMap, PCFShadowMap, ProfilerService, BasicShadowMap, CubeDepthTexture, SphereGeometry, LinearMipmapNearestFilter, NearestMipmapLinearFilter, Float16BufferAttribute, yieldToMain, REVISION, ArrayCamera, PlaneGeometry, FrontSide, CustomBlending, ZeroFactor, CylinderGeometry, Quaternion, WebXRController, RAD2DEG, PCFSoftShadowMap, FrustumArray, Frustum, RGBAIntegerFormat, TimestampQuery, createCanvasElement, MaxEquation, MinEquation, ReverseSubtractEquation, SubtractEquation, OneMinusConstantAlphaFactor, ConstantAlphaFactor, OneMinusConstantColorFactor, ConstantColorFactor, OneMinusDstAlphaFactor, OneMinusDstColorFactor, OneMinusSrcColorFactor, DstAlphaFactor, DstColorFactor, SrcAlphaSaturateFactor, SrcColorFactor, OneFactor, CullFaceNone, CullFaceBack, CullFaceFront, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, ReversedDepthFuncs, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, R11_EAC_Format, SIGNED_R11_EAC_Format, SIGNED_RG11_EAC_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, SIGNED_RED_GREEN_RGTC2_Format, MirroredRepeatWrapping, RepeatWrapping, NearestMipmapNearestFilter, NotEqualCompare, EqualCompare, AlwaysCompare, NeverCompare, LinearTransfer, getByteLength, isTypedArray, NotEqualStencilFunc, GreaterStencilFunc, GreaterEqualStencilFunc, EqualStencilFunc, LessEqualStencilFunc, LessStencilFunc, AlwaysStencilFunc, NeverStencilFunc, DecrementWrapStencilOp, IncrementWrapStencilOp, DecrementStencilOp, IncrementStencilOp, InvertStencilOp, ReplaceStencilOp, ZeroStencilOp, KeepStencilOp, SpotLight, PointLight, DirectionalLight, RectAreaLight, AmbientLight, HemisphereLight, LightProbe, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping, NeutralToneMapping, Group, Loader, FileLoader, MaterialLoader, ObjectLoader } from './three.core.js';
7
7
  export { AdditiveAnimationBlendMode, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BasicDepthPacking, BatchedMesh, BezierInterpolant, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxHelper, BufferGeometryLoader, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CircleGeometry, Clock, ColorKeyframeTrack, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, Controls, CubeTextureLoader, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceFrontBack, Curve, CurvePath, CustomToneMapping, Cylindrical, DataTextureLoader, DataUtils, DefaultLoadingManager, DetachedBindMode, DirectionalLightHelper, DiscreteInterpolant, DodecahedronGeometry, DynamicCopyUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, Euler, ExternalTexture, ExtrudeGeometry, Fog, FogExp2, GLBufferAttribute, GLSL1, GLSL3, GridHelper, HTMLTexture, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, InstancedBufferGeometry, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, Interpolant, InterpolateBezier, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InterpolationSamplingMode, InterpolationSamplingType, KeyframeTrack, LOD, LatheGeometry, Layers, Light, LightShadow, Line, Line3, LineCurve, LineCurve3, LineLoop, LineSegments, LinearInterpolant, LinearMipMapNearestFilter, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, MOUSE, MeshDepthMaterial, MeshDistanceMaterial, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NodePath, NormalAnimationBlendMode, NumberKeyframeTrack, OctahedronGeometry, Path, PlaneHelper, PointLightHelper, Points, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RGBADepthPacking, RGBDepthPacking, RGDepthPacking, RawShaderMaterial, Ray, Raycaster, RenderTarget3D, RingGeometry, ShaderMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, Skeleton, SkeletonHelper, SkinnedMesh, Source, Spherical, SphericalHarmonics3, SplineCurve, SpotLightHelper, Sprite, StaticCopyUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, TOUCH, TetrahedronGeometry, TextureLoader, TextureSource, TextureUtils, Timer, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, VectorKeyframeTrack, VideoFrameTexture, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLRenderTarget, WireframeGeometry, WrapAroundEnding, XorShift32, ZeroCurvatureEnding, ZeroSlopeEnding, allocateNodeId, collectSiblingNodeIds, configureNodeIdSeed, ensureUniqueNodeIdAmongParentChildren, generateNodeId, getConsoleFunction, hashStringToUint32, isValidNodeId, nodeIdFromKey, nodeIdFromString, nodeIdToString, profile, profileClass, randomSeedUint32, setConsoleFunction, xorshift32 } from './three.core.js';
8
8
 
9
9
  const refreshUniforms = [
@@ -21614,6 +21614,147 @@ class VertexColorNode extends AttributeNode {
21614
21614
  */
21615
21615
  const vertexColor = ( index = 0 ) => new VertexColorNode( index );
21616
21616
 
21617
+ // WITH_GENESYS
21618
+ // Buffer visualization. Shows one material channel in place of the shaded color.
21619
+ // !WITH_GENESYS
21620
+
21621
+
21622
+ /**
21623
+ * Buffer visualization. The visible surface wins, and one material channel replaces the shaded color.
21624
+ *
21625
+ * @type {string}
21626
+ */
21627
+ const DEBUG_VIEW_BUFFER = 'bufferVisualization';
21628
+
21629
+ /**
21630
+ * Albedo before lighting, including maps and vertex colors.
21631
+ *
21632
+ * @type {string}
21633
+ */
21634
+ const BUFFER_BASE_COLOR = 'baseColor';
21635
+
21636
+ /**
21637
+ * Shading normal in world space, packed to RGB with `n * 0.5 + 0.5`.
21638
+ *
21639
+ * @type {string}
21640
+ */
21641
+ const BUFFER_WORLD_NORMAL = 'worldNormal';
21642
+
21643
+ /**
21644
+ * Scalar roughness used by the lighting model. Black is smooth.
21645
+ *
21646
+ * @type {string}
21647
+ */
21648
+ const BUFFER_ROUGHNESS = 'roughness';
21649
+
21650
+ /**
21651
+ * Scalar metalness. White is metal. Unreal calls this buffer Metallic.
21652
+ *
21653
+ * @type {string}
21654
+ */
21655
+ const BUFFER_METALLIC = 'metallic';
21656
+
21657
+ /**
21658
+ * Material ambient occlusion. White means no occlusion map.
21659
+ *
21660
+ * @type {string}
21661
+ */
21662
+ const BUFFER_AMBIENT_OCCLUSION = 'ambientOcclusion';
21663
+
21664
+ /**
21665
+ * Emissive color before it is added to the lit result.
21666
+ *
21667
+ * @type {string}
21668
+ */
21669
+ const BUFFER_EMISSIVE = 'emissive';
21670
+
21671
+ /**
21672
+ * Channel drawn when buffer visualization is first enabled.
21673
+ *
21674
+ * @type {string}
21675
+ */
21676
+ const DEFAULT_BUFFER = BUFFER_BASE_COLOR;
21677
+
21678
+ /**
21679
+ * Writes a defined value for channels a material may never assign.
21680
+ * Standard and physical materials overwrite roughness and metalness in `setupVariants`,
21681
+ * and emissive is overwritten when the material has one.
21682
+ *
21683
+ * @param {string} buffer - `renderer.debug.buffer`.
21684
+ */
21685
+ function assignBufferDefaults( buffer ) {
21686
+
21687
+ if ( buffer === BUFFER_ROUGHNESS ) {
21688
+
21689
+ roughness.assign( float( 0 ) );
21690
+
21691
+ } else if ( buffer === BUFFER_METALLIC ) {
21692
+
21693
+ metalness.assign( float( 0 ) );
21694
+
21695
+ } else if ( buffer === BUFFER_EMISSIVE ) {
21696
+
21697
+ emissive.assign( vec3( 0 ) );
21698
+
21699
+ }
21700
+
21701
+ }
21702
+
21703
+ /**
21704
+ * The color for one buffer channel. Scalar channels are copied into RGB.
21705
+ *
21706
+ * @param {string} buffer - `renderer.debug.buffer`.
21707
+ * @return {Node<vec3>} The channel color.
21708
+ */
21709
+ function bufferVisualizationColor( buffer ) {
21710
+
21711
+ if ( buffer === BUFFER_WORLD_NORMAL ) {
21712
+
21713
+ return normalWorld.mul( 0.5 ).add( 0.5 );
21714
+
21715
+ }
21716
+
21717
+ if ( buffer === BUFFER_ROUGHNESS ) {
21718
+
21719
+ return vec3( roughness );
21720
+
21721
+ }
21722
+
21723
+ if ( buffer === BUFFER_METALLIC ) {
21724
+
21725
+ return vec3( metalness );
21726
+
21727
+ }
21728
+
21729
+ if ( buffer === BUFFER_AMBIENT_OCCLUSION ) {
21730
+
21731
+ return vec3( ambientOcclusion );
21732
+
21733
+ }
21734
+
21735
+ if ( buffer === BUFFER_EMISSIVE ) {
21736
+
21737
+ return emissive;
21738
+
21739
+ }
21740
+
21741
+ return diffuseColor.rgb;
21742
+
21743
+ }
21744
+
21745
+ /**
21746
+ * Replaces the shaded color with the selected buffer. Alpha stays the material's coverage
21747
+ * so masked and transparent surfaces keep their shape.
21748
+ *
21749
+ * @param {string} buffer - `renderer.debug.buffer`.
21750
+ * @return {Node<vec4>} The buffer color.
21751
+ */
21752
+ function bufferVisualizationOutput( buffer ) {
21753
+
21754
+ return vec4( bufferVisualizationColor( buffer ), diffuseColor.a );
21755
+
21756
+ }
21757
+
21617
21758
  // WITH_GENESYS
21618
21759
  // Shader and lighting complexity debug views. Costs are a material proxy, not ISA instruction counts.
21619
21760
  // !WITH_GENESYS
@@ -21837,6 +21978,37 @@ function debugViewAccumulates( view ) {
21837
21978
 
21838
21979
  }
21839
21980
 
21981
+ /**
21982
+ * Whether a draw adds its scalar to the accumulating target instead of shading normally.
21983
+ * Shadow passes, draws to the screen, and fullscreen quads draw normally. A post-processing
21984
+ * quad copies the accumulated scene target, so its own cost must not replace it.
21985
+ *
21986
+ * @param {Renderer} renderer - The renderer.
21987
+ * @param {Material} material - The material being drawn.
21988
+ * @param {?Object3D} object - The object being drawn.
21989
+ * @return {boolean} `true` when the draw accumulates.
21990
+ */
21991
+ function debugDrawAccumulates( renderer, material, object ) {
21992
+
21993
+ return debugViewAccumulates( renderer.debug.view ) &&
21994
+ material.isShadowPassMaterial !== true &&
21995
+ renderer.isOutputTarget !== true &&
21996
+ ( object === null || object === undefined || object.isQuadMesh !== true );
21997
+
21998
+ }
21999
+
22000
+ /**
22001
+ * Views that output data or a heatmap, so tone mapping would distort them.
22002
+ *
22003
+ * @param {string} view - `renderer.debug.view`.
22004
+ * @return {boolean} `true` when the view is drawn without tone mapping.
22005
+ */
22006
+ function debugViewSkipsToneMapping( view ) {
22007
+
22008
+ return debugViewAccumulates( view ) || view === DEBUG_VIEW_LIGHTING_COMPLEXITY || view === DEBUG_VIEW_BUFFER;
22009
+
22010
+ }
22011
+
21840
22012
  /**
21841
22013
  * Unreal's nonlinear shader-complexity ramp (`ColorizeComplexity`).
21842
22014
  * The first third of the normalized cost spreads across the first seven stops.
@@ -22012,146 +22184,565 @@ function quadOverdrawOutput( resultNode ) {
22012
22184
 
22013
22185
  }
22014
22186
 
22015
- // WITH_GENESYS
22016
- // Buffer visualization. Shows one material channel in place of the shaded color.
22017
- // !WITH_GENESYS
22018
-
22019
-
22020
22187
  /**
22021
- * Buffer visualization. The visible surface wins, and one material channel replaces the shaded color.
22188
+ * This node can be used to define multiple outputs in a shader programs.
22022
22189
  *
22023
- * @type {string}
22190
+ * @augments Node
22024
22191
  */
22025
- const DEBUG_VIEW_BUFFER = 'bufferVisualization';
22192
+ class OutputStructNode extends Node {
22026
22193
 
22027
- /**
22028
- * Albedo before lighting, including maps and vertex colors.
22029
- *
22030
- * @type {string}
22031
- */
22032
- const BUFFER_BASE_COLOR = 'baseColor';
22194
+ static get type() {
22033
22195
 
22034
- /**
22035
- * Shading normal in world space, packed to RGB with `n * 0.5 + 0.5`.
22036
- *
22037
- * @type {string}
22038
- */
22039
- const BUFFER_WORLD_NORMAL = 'worldNormal';
22196
+ return 'OutputStructNode';
22040
22197
 
22041
- /**
22042
- * Scalar roughness used by the lighting model. Black is smooth.
22043
- *
22044
- * @type {string}
22045
- */
22046
- const BUFFER_ROUGHNESS = 'roughness';
22198
+ }
22199
+
22200
+ /**
22201
+ * Constructs a new output struct node. The constructor can be invoked with an
22202
+ * arbitrary number of nodes representing the members.
22203
+ *
22204
+ * @param {...Node} members - A parameter list of nodes.
22205
+ */
22206
+ constructor( ...members ) {
22207
+
22208
+ super();
22209
+
22210
+ /**
22211
+ * An array of nodes which defines the output.
22212
+ *
22213
+ * @type {Array<Node>}
22214
+ */
22215
+ this.members = members;
22216
+
22217
+ /**
22218
+ * This flag can be used for type testing.
22219
+ *
22220
+ * @type {boolean}
22221
+ * @readonly
22222
+ * @default true
22223
+ */
22224
+ this.isOutputStructNode = true;
22225
+
22226
+ }
22227
+
22228
+ generateNodeType( /*builder*/ ) {
22229
+
22230
+ return 'OutputType';
22231
+
22232
+ }
22233
+
22234
+ generate( builder ) {
22235
+
22236
+ const nodeData = builder.getDataFromNode( this );
22237
+
22238
+ if ( nodeData.membersLayout === undefined ) {
22239
+
22240
+ const members = this.members;
22241
+ const membersLayout = [];
22242
+
22243
+ for ( let i = 0; i < members.length; i ++ ) {
22244
+
22245
+ const name = 'm' + i;
22246
+ const type = members[ i ].getNodeType( builder );
22247
+
22248
+ membersLayout.push( { name, type, index: i } );
22249
+
22250
+ }
22251
+
22252
+ nodeData.membersLayout = membersLayout;
22253
+ nodeData.structType = builder.getOutputStructTypeFromNode( this, nodeData.membersLayout );
22254
+
22255
+ }
22256
+
22257
+ //
22258
+
22259
+ const propertyName = builder.getOutputStructName();
22260
+ const members = this.members;
22261
+
22262
+ const structPrefix = propertyName !== '' ? propertyName + '.' : '';
22263
+
22264
+ for ( let i = 0; i < members.length; i ++ ) {
22265
+
22266
+ const snippet = members[ i ].build( builder, nodeData.membersLayout[ i ].type );
22267
+
22268
+ builder.addLineFlowCode( `${ structPrefix }m${ i } = ${ snippet }`, this );
22269
+
22270
+ }
22271
+
22272
+ return propertyName;
22273
+
22274
+ }
22275
+
22276
+ }
22047
22277
 
22048
22278
  /**
22049
- * Scalar metalness. White is metal. Unreal calls this buffer Metallic.
22279
+ * TSL function for creating an output struct node.
22050
22280
  *
22051
- * @type {string}
22281
+ * @tsl
22282
+ * @function
22283
+ * @param {...Node} members - A parameter list of nodes.
22284
+ * @returns {OutputStructNode}
22052
22285
  */
22053
- const BUFFER_METALLIC = 'metallic';
22286
+ const outputStruct = /*@__PURE__*/ nodeProxy( OutputStructNode );
22054
22287
 
22055
22288
  /**
22056
- * Material ambient occlusion. White means no occlusion map.
22289
+ * Represents blending configuration.
22057
22290
  *
22058
- * @type {string}
22291
+ * This class encapsulates all blending-related properties that control how
22292
+ * a material's colors are combined with the colors already in the frame buffer.
22059
22293
  */
22060
- const BUFFER_AMBIENT_OCCLUSION = 'ambientOcclusion';
22294
+ class BlendMode {
22295
+
22296
+ /**
22297
+ * Constructs a new blending configuration.
22298
+ *
22299
+ * @param {(NoBlending|NormalBlending|AdditiveBlending|SubtractiveBlending|MultiplyBlending|CustomBlending|MaterialBlending)} [blending=NormalBlending] - The blending mode.
22300
+ */
22301
+ constructor( blending = NormalBlending ) {
22302
+
22303
+ /**
22304
+ * Defines the blending type.
22305
+ *
22306
+ * It must be set to `CustomBlending` if custom blending properties like
22307
+ * {@link BlendMode#blendSrc}, {@link BlendMode#blendDst} or {@link BlendMode#blendEquation}
22308
+ * should have any effect.
22309
+ *
22310
+ * @type {(NoBlending|NormalBlending|AdditiveBlending|SubtractiveBlending|MultiplyBlending|CustomBlending|MaterialBlending)}
22311
+ * @default NormalBlending
22312
+ */
22313
+ this.blending = blending;
22314
+
22315
+ /**
22316
+ * Defines the blending source factor.
22317
+ *
22318
+ * This determines how the source (incoming) fragment color is factored before being added
22319
+ * to the destination (existing) fragment color in the frame buffer.
22320
+ *
22321
+ * @type {(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
22322
+ * @default SrcAlphaFactor
22323
+ */
22324
+ this.blendSrc = SrcAlphaFactor;
22325
+
22326
+ /**
22327
+ * Defines the blending destination factor.
22328
+ *
22329
+ * This determines how the destination (existing) fragment color in the frame buffer
22330
+ * is factored before being combined with the source (incoming) fragment color.
22331
+ *
22332
+ * @type {(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
22333
+ * @default OneMinusSrcAlphaFactor
22334
+ */
22335
+ this.blendDst = OneMinusSrcAlphaFactor;
22336
+
22337
+ /**
22338
+ * Defines the blending equation.
22339
+ *
22340
+ * This determines how the source and destination colors are combined.
22341
+ *
22342
+ * @type {(AddEquation|SubtractEquation|ReverseSubtractEquation|MinEquation|MaxEquation)}
22343
+ * @default AddEquation
22344
+ */
22345
+ this.blendEquation = AddEquation;
22346
+
22347
+ /**
22348
+ * Defines the blending source alpha factor.
22349
+ *
22350
+ * When set, this allows separate control of the alpha channel's source blending factor.
22351
+ * If `null`, {@link BlendMode#blendSrc} is used for the alpha channel as well.
22352
+ *
22353
+ * @type {?(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
22354
+ * @default null
22355
+ */
22356
+ this.blendSrcAlpha = null;
22357
+
22358
+ /**
22359
+ * Defines the blending destination alpha factor.
22360
+ *
22361
+ * When set, this allows separate control of the alpha channel's destination blending factor.
22362
+ * If `null`, {@link BlendMode#blendDst} is used for the alpha channel as well.
22363
+ *
22364
+ * @type {?(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
22365
+ * @default null
22366
+ */
22367
+ this.blendDstAlpha = null;
22368
+
22369
+ /**
22370
+ * Defines the blending equation of the alpha channel.
22371
+ *
22372
+ * When set, this allows separate control of the alpha channel's blending equation.
22373
+ * If `null`, {@link BlendMode#blendEquation} is used for the alpha channel as well.
22374
+ *
22375
+ * @type {?(AddEquation|SubtractEquation|ReverseSubtractEquation|MinEquation|MaxEquation)}
22376
+ * @default null
22377
+ */
22378
+ this.blendEquationAlpha = null;
22379
+
22380
+ /**
22381
+ * Defines whether to premultiply the alpha (transparency) value.
22382
+ *
22383
+ * If `true`, the RGB color of the texture or material is multiplied by its alpha value.
22384
+ * This is useful for transparent textures/materials where the color data
22385
+ * should already include the transparency information.
22386
+ *
22387
+ * @type {boolean}
22388
+ * @default false
22389
+ */
22390
+ this.premultiplyAlpha = false;
22391
+
22392
+ }
22393
+
22394
+ /**
22395
+ * Copies the blending properties from the given source to this instance.
22396
+ *
22397
+ * @param {BlendMode} source - The blending configuration to copy from.
22398
+ * @return {BlendMode} A reference to this instance.
22399
+ */
22400
+ copy( source ) {
22401
+
22402
+ this.blending = source.blending;
22403
+ this.blendSrc = source.blendSrc;
22404
+ this.blendDst = source.blendDst;
22405
+ this.blendEquation = source.blendEquation;
22406
+ this.blendSrcAlpha = source.blendSrcAlpha;
22407
+ this.blendDstAlpha = source.blendDstAlpha;
22408
+ this.blendEquationAlpha = source.blendEquationAlpha;
22409
+ this.premultiplyAlpha = source.premultiplyAlpha;
22410
+
22411
+ return this;
22412
+
22413
+ }
22414
+
22415
+ /**
22416
+ * Returns a clone of this blending configuration.
22417
+ *
22418
+ * @return {BlendMode} A new Blending instance with the same properties.
22419
+ */
22420
+ clone() {
22421
+
22422
+ return new this.constructor().copy( this );
22423
+
22424
+ }
22425
+
22426
+ }
22061
22427
 
22062
22428
  /**
22063
- * Emissive color before it is added to the lit result.
22429
+ * A four-component version of {@link Color} which is internally
22430
+ * used by the renderer to represents clear color with alpha as
22431
+ * one object.
22064
22432
  *
22065
- * @type {string}
22433
+ * @private
22434
+ * @augments Color
22066
22435
  */
22067
- const BUFFER_EMISSIVE = 'emissive';
22436
+ class Color4 extends Color {
22437
+
22438
+ /**
22439
+ * Constructs a new four-component color.
22440
+ * You can also pass a single THREE.Color, hex or
22441
+ * string argument to this constructor.
22442
+ *
22443
+ * @param {number|string} [r=1] - The red value.
22444
+ * @param {number} [g=1] - The green value.
22445
+ * @param {number} [b=1] - The blue value.
22446
+ * @param {number} [a=1] - The alpha value.
22447
+ */
22448
+ constructor( r, g, b, a = 1 ) {
22449
+
22450
+ super( r, g, b );
22451
+
22452
+ this.a = a;
22453
+
22454
+ }
22455
+
22456
+ /**
22457
+ * Overwrites the default to honor alpha.
22458
+ * You can also pass a single THREE.Color, hex or
22459
+ * string argument to this method.
22460
+ *
22461
+ * @param {number|string|Color} r - The red value.
22462
+ * @param {number} [g] - The green value.
22463
+ * @param {number} [b] - The blue value.
22464
+ * @param {number} [a=1] - The alpha value.
22465
+ * @return {Color4} A reference to this object.
22466
+ */
22467
+ set( r, g, b, a = 1 ) {
22468
+
22469
+ this.a = a;
22470
+
22471
+ return super.set( r, g, b );
22472
+
22473
+ }
22474
+
22475
+ /**
22476
+ * Overwrites the default to honor alpha.
22477
+ *
22478
+ * @param {Color4} color - The color to copy.
22479
+ * @return {Color4} A reference to this object.
22480
+ */
22481
+ copy( color ) {
22482
+
22483
+ if ( color.a !== undefined ) this.a = color.a;
22484
+
22485
+ return super.copy( color );
22486
+
22487
+ }
22488
+
22489
+ /**
22490
+ * Overwrites the default to honor alpha.
22491
+ *
22492
+ * @return {Color4} The cloned color.
22493
+ */
22494
+ clone() {
22495
+
22496
+ return new this.constructor( this.r, this.g, this.b, this.a );
22497
+
22498
+ }
22499
+
22500
+ *[ Symbol.iterator ]() {
22501
+
22502
+ yield this.r;
22503
+ yield this.g;
22504
+ yield this.b;
22505
+ yield this.a;
22506
+
22507
+ }
22508
+
22509
+ }
22510
+
22511
+ // Predefined blend modes for MRT nodes.
22512
+ const _noBlending = /**@__PURE__*/ new BlendMode( NoBlending );
22513
+ const _materialBlending = /**@__PURE__*/ new BlendMode( MaterialBlending );
22068
22514
 
22069
22515
  /**
22070
- * Channel drawn when buffer visualization is first enabled.
22516
+ * Returns the MRT texture index for the given name.
22071
22517
  *
22072
- * @type {string}
22518
+ * @param {Array<Texture>} textures - The textures of a MRT-configured render target.
22519
+ * @param {string} name - The name of the MRT texture which index is requested.
22520
+ * @return {number} The texture index.
22073
22521
  */
22074
- const DEFAULT_BUFFER = BUFFER_BASE_COLOR;
22522
+ function getTextureIndex( textures, name ) {
22523
+
22524
+ for ( let i = 0; i < textures.length; i ++ ) {
22525
+
22526
+ if ( textures[ i ].name === name ) {
22527
+
22528
+ return i;
22529
+
22530
+ }
22531
+
22532
+ }
22533
+
22534
+ return -1;
22535
+
22536
+ }
22075
22537
 
22076
22538
  /**
22077
- * Writes a defined value for channels a material may never assign.
22078
- * Standard and physical materials overwrite roughness and metalness in `setupVariants`,
22079
- * and emissive is overwritten when the material has one.
22539
+ * This node can be used setup a MRT context for rendering. A typical MRT setup for
22540
+ * post-processing is shown below:
22541
+ * ```js
22542
+ * const mrtNode = mrt( {
22543
+ * output: output,
22544
+ * normal: normalView
22545
+ * } ) ;
22546
+ * ```
22547
+ * The MRT output is defined as a dictionary.
22080
22548
  *
22081
- * @param {string} buffer - `renderer.debug.buffer`.
22549
+ * @augments OutputStructNode
22082
22550
  */
22083
- function assignBufferDefaults( buffer ) {
22551
+ class MRTNode extends OutputStructNode {
22084
22552
 
22085
- if ( buffer === BUFFER_ROUGHNESS ) {
22553
+ static get type() {
22086
22554
 
22087
- roughness.assign( float( 0 ) );
22555
+ return 'MRTNode';
22088
22556
 
22089
- } else if ( buffer === BUFFER_METALLIC ) {
22557
+ }
22090
22558
 
22091
- metalness.assign( float( 0 ) );
22559
+ /**
22560
+ * Constructs a new output struct node.
22561
+ *
22562
+ * @param {Object<string, Node>} outputNodes - The MRT outputs.
22563
+ */
22564
+ constructor( outputNodes ) {
22092
22565
 
22093
- } else if ( buffer === BUFFER_EMISSIVE ) {
22566
+ super();
22094
22567
 
22095
- emissive.assign( vec3( 0 ) );
22568
+ /**
22569
+ * A dictionary representing the MRT outputs. The key
22570
+ * is the name of the output, the value the node which produces
22571
+ * the output result.
22572
+ *
22573
+ * @type {Object<string, Node>}
22574
+ */
22575
+ this.outputNodes = outputNodes;
22576
+
22577
+ /**
22578
+ * A dictionary storing the blend modes for each output.
22579
+ *
22580
+ * @type {Object<string, BlendMode>}
22581
+ */
22582
+ this.blendModes = {
22583
+ output: _materialBlending
22584
+ };
22585
+
22586
+ /**
22587
+ * A dictionary storing the clear colors for each output.
22588
+ *
22589
+ * @type {Object<string, Color4>}
22590
+ */
22591
+ this.clearColors = {};
22592
+
22593
+ /**
22594
+ * This flag can be used for type testing.
22595
+ *
22596
+ * @type {boolean}
22597
+ * @readonly
22598
+ * @default true
22599
+ */
22600
+ this.isMRTNode = true;
22096
22601
 
22097
22602
  }
22098
22603
 
22099
- }
22604
+ /**
22605
+ * Sets the blend mode for the given output name.
22606
+ *
22607
+ * @param {string} name - The name of the output.
22608
+ * @param {BlendMode} blend - The blending mode.
22609
+ * @return {MRTNode} The current MRT node.
22610
+ */
22611
+ setBlendMode( name, blend ) {
22100
22612
 
22101
- /**
22102
- * The color for one buffer channel. Scalar channels are copied into RGB.
22103
- *
22104
- * @param {string} buffer - `renderer.debug.buffer`.
22105
- * @return {Node<vec3>} The channel color.
22106
- */
22107
- function bufferVisualizationColor( buffer ) {
22613
+ this.blendModes[ name ] = blend;
22108
22614
 
22109
- if ( buffer === BUFFER_WORLD_NORMAL ) {
22615
+ return this;
22110
22616
 
22111
- return normalWorld.mul( 0.5 ).add( 0.5 );
22617
+ }
22618
+
22619
+ /**
22620
+ * Returns the blend mode for the given output name.
22621
+ *
22622
+ * @param {string} name - The name of the output.
22623
+ * @return {BlendMode} The blend mode.
22624
+ */
22625
+ getBlendMode( name ) {
22626
+
22627
+ return this.blendModes[ name ] || _noBlending;
22112
22628
 
22113
22629
  }
22114
22630
 
22115
- if ( buffer === BUFFER_ROUGHNESS ) {
22631
+ /**
22632
+ * Sets the clear color for the given output name.
22633
+ *
22634
+ * @param {string} name - The name of the output.
22635
+ * @param {number|string|Color} color - The clear color.
22636
+ * @param {number} [alpha=1] - The clear alpha.
22637
+ * @return {MRTNode} The current MRT node.
22638
+ */
22639
+ setClearColor( name, color, alpha = 1 ) {
22116
22640
 
22117
- return vec3( roughness );
22641
+ const clearColor = this.clearColors[ name ] || ( this.clearColors[ name ] = new Color4() );
22642
+
22643
+ clearColor.set( color );
22644
+ clearColor.a = alpha;
22645
+
22646
+ return this;
22118
22647
 
22119
22648
  }
22120
22649
 
22121
- if ( buffer === BUFFER_METALLIC ) {
22650
+ /**
22651
+ * Returns the clear color for the given output name.
22652
+ *
22653
+ * @param {string} name - The name of the output.
22654
+ * @return {?Color4} The clear color. Returns `null` if no clear color is defined
22655
+ * which means the renderer's default clear policy is applied.
22656
+ */
22657
+ getClearColor( name ) {
22122
22658
 
22123
- return vec3( metalness );
22659
+ return this.clearColors[ name ] || null;
22124
22660
 
22125
22661
  }
22126
22662
 
22127
- if ( buffer === BUFFER_AMBIENT_OCCLUSION ) {
22663
+ /**
22664
+ * Returns `true` if the MRT node has an output with the given name.
22665
+ *
22666
+ * @param {string} name - The name of the output.
22667
+ * @return {NodeBuilder} Whether the MRT node has an output for the given name or not.
22668
+ */
22669
+ has( name ) {
22128
22670
 
22129
- return vec3( ambientOcclusion );
22671
+ return this.outputNodes[ name ] !== undefined;
22130
22672
 
22131
22673
  }
22132
22674
 
22133
- if ( buffer === BUFFER_EMISSIVE ) {
22675
+ /**
22676
+ * Returns the output node for the given name.
22677
+ *
22678
+ * @param {string} name - The name of the output.
22679
+ * @return {Node} The output node.
22680
+ */
22681
+ get( name ) {
22134
22682
 
22135
- return emissive;
22683
+ return this.outputNodes[ name ];
22136
22684
 
22137
22685
  }
22138
22686
 
22139
- return diffuseColor.rgb;
22687
+ /**
22688
+ * Merges the outputs of the given MRT node with the outputs of this node.
22689
+ *
22690
+ * @param {MRTNode} mrtNode - The MRT to merge.
22691
+ * @return {MRTNode} A new MRT node with merged outputs..
22692
+ */
22693
+ merge( mrtNode ) {
22694
+
22695
+ const outputs = { ...this.outputNodes, ...mrtNode.outputNodes };
22696
+ const blendModes = { ...this.blendModes, ...mrtNode.blendModes };
22697
+ const clearColors = { ...this.clearColors, ...mrtNode.clearColors };
22698
+
22699
+ const mrtTarget = mrt( outputs );
22700
+ mrtTarget.blendModes = blendModes;
22701
+ mrtTarget.clearColors = clearColors;
22702
+
22703
+ return mrtTarget;
22704
+
22705
+ }
22706
+
22707
+ setup( builder ) {
22708
+
22709
+ const outputNodes = this.outputNodes;
22710
+ const mrt = builder.renderer.getRenderTarget();
22711
+
22712
+ const members = [];
22713
+
22714
+ const textures = mrt.textures;
22715
+
22716
+ for ( const name in outputNodes ) {
22717
+
22718
+ const index = getTextureIndex( textures, name );
22719
+
22720
+ // Ignore if the output exists in the MRT but has never been used.
22721
+ if ( index === -1 ) continue;
22722
+
22723
+ const type = builder.getOutputType( index );
22724
+
22725
+ members[ index ] = outputNodes[ name ].convert( type );
22726
+
22727
+ }
22728
+
22729
+ this.members = members;
22730
+
22731
+ return super.setup( builder );
22732
+
22733
+ }
22140
22734
 
22141
22735
  }
22142
22736
 
22143
22737
  /**
22144
- * Replaces the shaded color with the selected buffer. Alpha stays the material's coverage
22145
- * so masked and transparent surfaces keep their shape.
22738
+ * TSL function for creating a MRT node.
22146
22739
  *
22147
- * @param {string} buffer - `renderer.debug.buffer`.
22148
- * @return {Node<vec4>} The buffer color.
22740
+ * @tsl
22741
+ * @function
22742
+ * @param {Object<string, Node>} outputNodes - The MRT outputs.
22743
+ * @returns {MRTNode}
22149
22744
  */
22150
- function bufferVisualizationOutput( buffer ) {
22151
-
22152
- return vec4( bufferVisualizationColor( buffer ), diffuseColor.a );
22153
-
22154
- }
22745
+ const mrt = /*@__PURE__*/ nodeProxy( MRTNode );
22155
22746
 
22156
22747
  // WITH_GENESYS
22157
22748
  // Lighting only and detail lighting. Both replace the shaded albedo with a flat gray.
@@ -22210,11 +22801,12 @@ const lightingOnlyNormal = /*@__PURE__*/ Fn( ( builder ) => {
22210
22801
  * Lit materials become a dielectric gray. Unlit materials become flat gray.
22211
22802
  *
22212
22803
  * @param {NodeBuilder} builder - The current node builder.
22804
+ * @param {NodeMaterial} material - The node material being set up. `builder.material` can be the
22805
+ * source material of a converted one, such as a glTF `MeshStandardMaterial`.
22213
22806
  * @param {string} view - `renderer.debug.view`.
22214
22807
  */
22215
- function applyLightingDebug( builder, view ) {
22808
+ function applyLightingDebug( builder, material, view ) {
22216
22809
 
22217
- const material = builder.material;
22218
22810
  const gray = vec3( LIGHTING_ONLY_BRIGHTNESS );
22219
22811
 
22220
22812
  diffuseColor.rgb.assign( gray );
@@ -22333,10 +22925,11 @@ function writeDrawCallColor( color, object, material ) {
22333
22925
  * The color is an object uniform, so meshes that share a material still differ.
22334
22926
  *
22335
22927
  * @param {NodeBuilder} builder - The current node builder.
22928
+ * @param {NodeMaterial} material - The node material being set up. `builder.material` can be the
22929
+ * source material of a converted one, such as a glTF `MeshStandardMaterial`.
22336
22930
  */
22337
- function applyDrawCallDebug( builder ) {
22931
+ function applyDrawCallDebug( builder, material ) {
22338
22932
 
22339
- const material = builder.material;
22340
22933
  const colorNode = uniform( new Color() ).onObjectUpdate( ( { object, material: drawnMaterial }, self ) => {
22341
22934
 
22342
22935
  if ( object === null || drawnMaterial === null ) return;
@@ -22373,6 +22966,24 @@ function applyDrawCallDebug( builder ) {
22373
22966
 
22374
22967
  }
22375
22968
 
22969
+ /**
22970
+ * Replaces the color a material writes with a debug output. With MRT, only the `output`
22971
+ * attachment is replaced so the other attachments keep their members. Converting the
22972
+ * whole MRT struct to a color leaves WGSL with an empty output struct.
22973
+ *
22974
+ * @param {Node} resultNode - The material's fragment result, possibly an MRT node.
22975
+ * @param {function(Node): Node} createOutput - Builds the debug color from the shaded color.
22976
+ * @return {Node} The fragment result with the debug color in place.
22977
+ */
22978
+ function replaceColorOutput( resultNode, createOutput ) {
22979
+
22980
+ if ( resultNode.isMRTNode !== true ) return createOutput( resultNode );
22981
+
22982
+ if ( resultNode.has( 'output' ) !== true ) return resultNode;
22983
+
22984
+ return resultNode.merge( mrt( { output: createOutput( resultNode.get( 'output' ) ) } ) );
22985
+
22986
+ }
22376
22987
  // !WITH_GENESYS
22377
22988
 
22378
22989
  /**
@@ -22891,11 +23502,11 @@ class NodeMaterial extends Material {
22891
23502
  // for detail lighting and can be replaced for lighting only.
22892
23503
  if ( ( renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || renderer.debug.view === DEBUG_VIEW_DETAIL_LIGHTING ) && this.isShadowPassMaterial !== true ) {
22893
23504
 
22894
- applyLightingDebug( builder, renderer.debug.view );
23505
+ applyLightingDebug( builder, this, renderer.debug.view );
22895
23506
 
22896
23507
  } else if ( renderer.debug.view === DEBUG_VIEW_DRAW_CALL && this.isShadowPassMaterial !== true ) {
22897
23508
 
22898
- applyDrawCallDebug( builder );
23509
+ applyDrawCallDebug( builder, this );
22899
23510
 
22900
23511
  }
22901
23512
  // !WITH_GENESYS
@@ -22970,27 +23581,32 @@ class NodeMaterial extends Material {
22970
23581
  }
22971
23582
 
22972
23583
  // WITH_GENESYS
22973
- // The screen output pass colorizes the accumulated ratio. Wrapping that pass
22974
- // would replace the heatmap with this material's own constant cost.
22975
- if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY && this.isShadowPassMaterial !== true && renderer.isOutputTarget !== true ) {
23584
+ // The screen output pass colorizes the accumulated ratio. Wrapping that pass, or a
23585
+ // post-processing quad that copies the scene target, would replace the heatmap with
23586
+ // that quad's own constant cost.
23587
+ if ( debugDrawAccumulates( renderer, this, builder.object ) ) {
22976
23588
 
22977
- builder.shaderComplexityBase = this.getShaderComplexity();
22978
- resultNode = shaderComplexityOutput( resultNode );
23589
+ if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY ) {
22979
23590
 
22980
- } else if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS && this.isShadowPassMaterial !== true && renderer.isOutputTarget !== true ) {
23591
+ builder.shaderComplexityBase = this.getShaderComplexity();
23592
+ resultNode = replaceColorOutput( resultNode, shaderComplexityOutput );
22981
23593
 
22982
- builder.shaderComplexityBase = this.getShaderComplexity();
22983
- resultNode = shaderComplexityAndQuadsOutput( resultNode );
23594
+ } else if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS ) {
22984
23595
 
22985
- } else if ( renderer.debug.view === DEBUG_VIEW_QUAD_OVERDRAW && this.isShadowPassMaterial !== true && renderer.isOutputTarget !== true ) {
23596
+ builder.shaderComplexityBase = this.getShaderComplexity();
23597
+ resultNode = replaceColorOutput( resultNode, shaderComplexityAndQuadsOutput );
22986
23598
 
22987
- resultNode = quadOverdrawOutput( resultNode );
23599
+ } else {
23600
+
23601
+ resultNode = replaceColorOutput( resultNode, quadOverdrawOutput );
23602
+
23603
+ }
22988
23604
 
22989
23605
  } else if ( renderer.debug.view === DEBUG_VIEW_BUFFER && this.isShadowPassMaterial !== true && this.fragmentNode === null ) {
22990
23606
 
22991
23607
  // The fullscreen output pass sets fragmentNode. Scene materials do not, including
22992
23608
  // when the scene is drawn straight to the canvas.
22993
- resultNode = bufferVisualizationOutput( renderer.debug.buffer );
23609
+ resultNode = replaceColorOutput( resultNode, () => bufferVisualizationOutput( renderer.debug.buffer ) );
22994
23610
 
22995
23611
  }
22996
23612
  // !WITH_GENESYS
@@ -36901,89 +37517,6 @@ class Textures extends DataMap {
36901
37517
 
36902
37518
  }
36903
37519
 
36904
- /**
36905
- * A four-component version of {@link Color} which is internally
36906
- * used by the renderer to represents clear color with alpha as
36907
- * one object.
36908
- *
36909
- * @private
36910
- * @augments Color
36911
- */
36912
- class Color4 extends Color {
36913
-
36914
- /**
36915
- * Constructs a new four-component color.
36916
- * You can also pass a single THREE.Color, hex or
36917
- * string argument to this constructor.
36918
- *
36919
- * @param {number|string} [r=1] - The red value.
36920
- * @param {number} [g=1] - The green value.
36921
- * @param {number} [b=1] - The blue value.
36922
- * @param {number} [a=1] - The alpha value.
36923
- */
36924
- constructor( r, g, b, a = 1 ) {
36925
-
36926
- super( r, g, b );
36927
-
36928
- this.a = a;
36929
-
36930
- }
36931
-
36932
- /**
36933
- * Overwrites the default to honor alpha.
36934
- * You can also pass a single THREE.Color, hex or
36935
- * string argument to this method.
36936
- *
36937
- * @param {number|string|Color} r - The red value.
36938
- * @param {number} [g] - The green value.
36939
- * @param {number} [b] - The blue value.
36940
- * @param {number} [a=1] - The alpha value.
36941
- * @return {Color4} A reference to this object.
36942
- */
36943
- set( r, g, b, a = 1 ) {
36944
-
36945
- this.a = a;
36946
-
36947
- return super.set( r, g, b );
36948
-
36949
- }
36950
-
36951
- /**
36952
- * Overwrites the default to honor alpha.
36953
- *
36954
- * @param {Color4} color - The color to copy.
36955
- * @return {Color4} A reference to this object.
36956
- */
36957
- copy( color ) {
36958
-
36959
- if ( color.a !== undefined ) this.a = color.a;
36960
-
36961
- return super.copy( color );
36962
-
36963
- }
36964
-
36965
- /**
36966
- * Overwrites the default to honor alpha.
36967
- *
36968
- * @return {Color4} The cloned color.
36969
- */
36970
- clone() {
36971
-
36972
- return new this.constructor( this.r, this.g, this.b, this.a );
36973
-
36974
- }
36975
-
36976
- *[ Symbol.iterator ]() {
36977
-
36978
- yield this.r;
36979
- yield this.g;
36980
- yield this.b;
36981
- yield this.a;
36982
-
36983
- }
36984
-
36985
- }
36986
-
36987
37520
  /**
36988
37521
  * A specialized context node designed to override specific target nodes within a
36989
37522
  * node sub-graph or flow. This allows replacing specific inputs (e.g., normal
@@ -37932,483 +38465,6 @@ const struct = ( membersLayout, name = null ) => {
37932
38465
 
37933
38466
  };
37934
38467
 
37935
- /**
37936
- * This node can be used to define multiple outputs in a shader programs.
37937
- *
37938
- * @augments Node
37939
- */
37940
- class OutputStructNode extends Node {
37941
-
37942
- static get type() {
37943
-
37944
- return 'OutputStructNode';
37945
-
37946
- }
37947
-
37948
- /**
37949
- * Constructs a new output struct node. The constructor can be invoked with an
37950
- * arbitrary number of nodes representing the members.
37951
- *
37952
- * @param {...Node} members - A parameter list of nodes.
37953
- */
37954
- constructor( ...members ) {
37955
-
37956
- super();
37957
-
37958
- /**
37959
- * An array of nodes which defines the output.
37960
- *
37961
- * @type {Array<Node>}
37962
- */
37963
- this.members = members;
37964
-
37965
- /**
37966
- * This flag can be used for type testing.
37967
- *
37968
- * @type {boolean}
37969
- * @readonly
37970
- * @default true
37971
- */
37972
- this.isOutputStructNode = true;
37973
-
37974
- }
37975
-
37976
- generateNodeType( /*builder*/ ) {
37977
-
37978
- return 'OutputType';
37979
-
37980
- }
37981
-
37982
- generate( builder ) {
37983
-
37984
- const nodeData = builder.getDataFromNode( this );
37985
-
37986
- if ( nodeData.membersLayout === undefined ) {
37987
-
37988
- const members = this.members;
37989
- const membersLayout = [];
37990
-
37991
- for ( let i = 0; i < members.length; i ++ ) {
37992
-
37993
- const name = 'm' + i;
37994
- const type = members[ i ].getNodeType( builder );
37995
-
37996
- membersLayout.push( { name, type, index: i } );
37997
-
37998
- }
37999
-
38000
- nodeData.membersLayout = membersLayout;
38001
- nodeData.structType = builder.getOutputStructTypeFromNode( this, nodeData.membersLayout );
38002
-
38003
- }
38004
-
38005
- //
38006
-
38007
- const propertyName = builder.getOutputStructName();
38008
- const members = this.members;
38009
-
38010
- const structPrefix = propertyName !== '' ? propertyName + '.' : '';
38011
-
38012
- for ( let i = 0; i < members.length; i ++ ) {
38013
-
38014
- const snippet = members[ i ].build( builder, nodeData.membersLayout[ i ].type );
38015
-
38016
- builder.addLineFlowCode( `${ structPrefix }m${ i } = ${ snippet }`, this );
38017
-
38018
- }
38019
-
38020
- return propertyName;
38021
-
38022
- }
38023
-
38024
- }
38025
-
38026
- /**
38027
- * TSL function for creating an output struct node.
38028
- *
38029
- * @tsl
38030
- * @function
38031
- * @param {...Node} members - A parameter list of nodes.
38032
- * @returns {OutputStructNode}
38033
- */
38034
- const outputStruct = /*@__PURE__*/ nodeProxy( OutputStructNode );
38035
-
38036
- /**
38037
- * Represents blending configuration.
38038
- *
38039
- * This class encapsulates all blending-related properties that control how
38040
- * a material's colors are combined with the colors already in the frame buffer.
38041
- */
38042
- class BlendMode {
38043
-
38044
- /**
38045
- * Constructs a new blending configuration.
38046
- *
38047
- * @param {(NoBlending|NormalBlending|AdditiveBlending|SubtractiveBlending|MultiplyBlending|CustomBlending|MaterialBlending)} [blending=NormalBlending] - The blending mode.
38048
- */
38049
- constructor( blending = NormalBlending ) {
38050
-
38051
- /**
38052
- * Defines the blending type.
38053
- *
38054
- * It must be set to `CustomBlending` if custom blending properties like
38055
- * {@link BlendMode#blendSrc}, {@link BlendMode#blendDst} or {@link BlendMode#blendEquation}
38056
- * should have any effect.
38057
- *
38058
- * @type {(NoBlending|NormalBlending|AdditiveBlending|SubtractiveBlending|MultiplyBlending|CustomBlending|MaterialBlending)}
38059
- * @default NormalBlending
38060
- */
38061
- this.blending = blending;
38062
-
38063
- /**
38064
- * Defines the blending source factor.
38065
- *
38066
- * This determines how the source (incoming) fragment color is factored before being added
38067
- * to the destination (existing) fragment color in the frame buffer.
38068
- *
38069
- * @type {(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
38070
- * @default SrcAlphaFactor
38071
- */
38072
- this.blendSrc = SrcAlphaFactor;
38073
-
38074
- /**
38075
- * Defines the blending destination factor.
38076
- *
38077
- * This determines how the destination (existing) fragment color in the frame buffer
38078
- * is factored before being combined with the source (incoming) fragment color.
38079
- *
38080
- * @type {(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
38081
- * @default OneMinusSrcAlphaFactor
38082
- */
38083
- this.blendDst = OneMinusSrcAlphaFactor;
38084
-
38085
- /**
38086
- * Defines the blending equation.
38087
- *
38088
- * This determines how the source and destination colors are combined.
38089
- *
38090
- * @type {(AddEquation|SubtractEquation|ReverseSubtractEquation|MinEquation|MaxEquation)}
38091
- * @default AddEquation
38092
- */
38093
- this.blendEquation = AddEquation;
38094
-
38095
- /**
38096
- * Defines the blending source alpha factor.
38097
- *
38098
- * When set, this allows separate control of the alpha channel's source blending factor.
38099
- * If `null`, {@link BlendMode#blendSrc} is used for the alpha channel as well.
38100
- *
38101
- * @type {?(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
38102
- * @default null
38103
- */
38104
- this.blendSrcAlpha = null;
38105
-
38106
- /**
38107
- * Defines the blending destination alpha factor.
38108
- *
38109
- * When set, this allows separate control of the alpha channel's destination blending factor.
38110
- * If `null`, {@link BlendMode#blendDst} is used for the alpha channel as well.
38111
- *
38112
- * @type {?(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
38113
- * @default null
38114
- */
38115
- this.blendDstAlpha = null;
38116
-
38117
- /**
38118
- * Defines the blending equation of the alpha channel.
38119
- *
38120
- * When set, this allows separate control of the alpha channel's blending equation.
38121
- * If `null`, {@link BlendMode#blendEquation} is used for the alpha channel as well.
38122
- *
38123
- * @type {?(AddEquation|SubtractEquation|ReverseSubtractEquation|MinEquation|MaxEquation)}
38124
- * @default null
38125
- */
38126
- this.blendEquationAlpha = null;
38127
-
38128
- /**
38129
- * Defines whether to premultiply the alpha (transparency) value.
38130
- *
38131
- * If `true`, the RGB color of the texture or material is multiplied by its alpha value.
38132
- * This is useful for transparent textures/materials where the color data
38133
- * should already include the transparency information.
38134
- *
38135
- * @type {boolean}
38136
- * @default false
38137
- */
38138
- this.premultiplyAlpha = false;
38139
-
38140
- }
38141
-
38142
- /**
38143
- * Copies the blending properties from the given source to this instance.
38144
- *
38145
- * @param {BlendMode} source - The blending configuration to copy from.
38146
- * @return {BlendMode} A reference to this instance.
38147
- */
38148
- copy( source ) {
38149
-
38150
- this.blending = source.blending;
38151
- this.blendSrc = source.blendSrc;
38152
- this.blendDst = source.blendDst;
38153
- this.blendEquation = source.blendEquation;
38154
- this.blendSrcAlpha = source.blendSrcAlpha;
38155
- this.blendDstAlpha = source.blendDstAlpha;
38156
- this.blendEquationAlpha = source.blendEquationAlpha;
38157
- this.premultiplyAlpha = source.premultiplyAlpha;
38158
-
38159
- return this;
38160
-
38161
- }
38162
-
38163
- /**
38164
- * Returns a clone of this blending configuration.
38165
- *
38166
- * @return {BlendMode} A new Blending instance with the same properties.
38167
- */
38168
- clone() {
38169
-
38170
- return new this.constructor().copy( this );
38171
-
38172
- }
38173
-
38174
- }
38175
-
38176
- // Predefined blend modes for MRT nodes.
38177
- const _noBlending = /**@__PURE__*/ new BlendMode( NoBlending );
38178
- const _materialBlending = /**@__PURE__*/ new BlendMode( MaterialBlending );
38179
-
38180
- /**
38181
- * Returns the MRT texture index for the given name.
38182
- *
38183
- * @param {Array<Texture>} textures - The textures of a MRT-configured render target.
38184
- * @param {string} name - The name of the MRT texture which index is requested.
38185
- * @return {number} The texture index.
38186
- */
38187
- function getTextureIndex( textures, name ) {
38188
-
38189
- for ( let i = 0; i < textures.length; i ++ ) {
38190
-
38191
- if ( textures[ i ].name === name ) {
38192
-
38193
- return i;
38194
-
38195
- }
38196
-
38197
- }
38198
-
38199
- return -1;
38200
-
38201
- }
38202
-
38203
- /**
38204
- * This node can be used setup a MRT context for rendering. A typical MRT setup for
38205
- * post-processing is shown below:
38206
- * ```js
38207
- * const mrtNode = mrt( {
38208
- * output: output,
38209
- * normal: normalView
38210
- * } ) ;
38211
- * ```
38212
- * The MRT output is defined as a dictionary.
38213
- *
38214
- * @augments OutputStructNode
38215
- */
38216
- class MRTNode extends OutputStructNode {
38217
-
38218
- static get type() {
38219
-
38220
- return 'MRTNode';
38221
-
38222
- }
38223
-
38224
- /**
38225
- * Constructs a new output struct node.
38226
- *
38227
- * @param {Object<string, Node>} outputNodes - The MRT outputs.
38228
- */
38229
- constructor( outputNodes ) {
38230
-
38231
- super();
38232
-
38233
- /**
38234
- * A dictionary representing the MRT outputs. The key
38235
- * is the name of the output, the value the node which produces
38236
- * the output result.
38237
- *
38238
- * @type {Object<string, Node>}
38239
- */
38240
- this.outputNodes = outputNodes;
38241
-
38242
- /**
38243
- * A dictionary storing the blend modes for each output.
38244
- *
38245
- * @type {Object<string, BlendMode>}
38246
- */
38247
- this.blendModes = {
38248
- output: _materialBlending
38249
- };
38250
-
38251
- /**
38252
- * A dictionary storing the clear colors for each output.
38253
- *
38254
- * @type {Object<string, Color4>}
38255
- */
38256
- this.clearColors = {};
38257
-
38258
- /**
38259
- * This flag can be used for type testing.
38260
- *
38261
- * @type {boolean}
38262
- * @readonly
38263
- * @default true
38264
- */
38265
- this.isMRTNode = true;
38266
-
38267
- }
38268
-
38269
- /**
38270
- * Sets the blend mode for the given output name.
38271
- *
38272
- * @param {string} name - The name of the output.
38273
- * @param {BlendMode} blend - The blending mode.
38274
- * @return {MRTNode} The current MRT node.
38275
- */
38276
- setBlendMode( name, blend ) {
38277
-
38278
- this.blendModes[ name ] = blend;
38279
-
38280
- return this;
38281
-
38282
- }
38283
-
38284
- /**
38285
- * Returns the blend mode for the given output name.
38286
- *
38287
- * @param {string} name - The name of the output.
38288
- * @return {BlendMode} The blend mode.
38289
- */
38290
- getBlendMode( name ) {
38291
-
38292
- return this.blendModes[ name ] || _noBlending;
38293
-
38294
- }
38295
-
38296
- /**
38297
- * Sets the clear color for the given output name.
38298
- *
38299
- * @param {string} name - The name of the output.
38300
- * @param {number|string|Color} color - The clear color.
38301
- * @param {number} [alpha=1] - The clear alpha.
38302
- * @return {MRTNode} The current MRT node.
38303
- */
38304
- setClearColor( name, color, alpha = 1 ) {
38305
-
38306
- const clearColor = this.clearColors[ name ] || ( this.clearColors[ name ] = new Color4() );
38307
-
38308
- clearColor.set( color );
38309
- clearColor.a = alpha;
38310
-
38311
- return this;
38312
-
38313
- }
38314
-
38315
- /**
38316
- * Returns the clear color for the given output name.
38317
- *
38318
- * @param {string} name - The name of the output.
38319
- * @return {?Color4} The clear color. Returns `null` if no clear color is defined
38320
- * which means the renderer's default clear policy is applied.
38321
- */
38322
- getClearColor( name ) {
38323
-
38324
- return this.clearColors[ name ] || null;
38325
-
38326
- }
38327
-
38328
- /**
38329
- * Returns `true` if the MRT node has an output with the given name.
38330
- *
38331
- * @param {string} name - The name of the output.
38332
- * @return {NodeBuilder} Whether the MRT node has an output for the given name or not.
38333
- */
38334
- has( name ) {
38335
-
38336
- return this.outputNodes[ name ] !== undefined;
38337
-
38338
- }
38339
-
38340
- /**
38341
- * Returns the output node for the given name.
38342
- *
38343
- * @param {string} name - The name of the output.
38344
- * @return {Node} The output node.
38345
- */
38346
- get( name ) {
38347
-
38348
- return this.outputNodes[ name ];
38349
-
38350
- }
38351
-
38352
- /**
38353
- * Merges the outputs of the given MRT node with the outputs of this node.
38354
- *
38355
- * @param {MRTNode} mrtNode - The MRT to merge.
38356
- * @return {MRTNode} A new MRT node with merged outputs..
38357
- */
38358
- merge( mrtNode ) {
38359
-
38360
- const outputs = { ...this.outputNodes, ...mrtNode.outputNodes };
38361
- const blendModes = { ...this.blendModes, ...mrtNode.blendModes };
38362
- const clearColors = { ...this.clearColors, ...mrtNode.clearColors };
38363
-
38364
- const mrtTarget = mrt( outputs );
38365
- mrtTarget.blendModes = blendModes;
38366
- mrtTarget.clearColors = clearColors;
38367
-
38368
- return mrtTarget;
38369
-
38370
- }
38371
-
38372
- setup( builder ) {
38373
-
38374
- const outputNodes = this.outputNodes;
38375
- const mrt = builder.renderer.getRenderTarget();
38376
-
38377
- const members = [];
38378
-
38379
- const textures = mrt.textures;
38380
-
38381
- for ( const name in outputNodes ) {
38382
-
38383
- const index = getTextureIndex( textures, name );
38384
-
38385
- // Ignore if the output exists in the MRT but has never been used.
38386
- if ( index === -1 ) continue;
38387
-
38388
- const type = builder.getOutputType( index );
38389
-
38390
- members[ index ] = outputNodes[ name ].convert( type );
38391
-
38392
- }
38393
-
38394
- this.members = members;
38395
-
38396
- return super.setup( builder );
38397
-
38398
- }
38399
-
38400
- }
38401
-
38402
- /**
38403
- * TSL function for creating a MRT node.
38404
- *
38405
- * @tsl
38406
- * @function
38407
- * @param {Object<string, Node>} outputNodes - The MRT outputs.
38408
- * @returns {MRTNode}
38409
- */
38410
- const mrt = /*@__PURE__*/ nodeProxy( MRTNode );
38411
-
38412
38468
  /**
38413
38469
  * This node represents an operation that reinterprets the bit representation of a value
38414
38470
  * in one type as a value in another type.
@@ -66363,7 +66419,8 @@ class Renderer {
66363
66419
 
66364
66420
  // WITH_GENESYS
66365
66421
  // Accumulating views write a scalar into an intermediate target, then the output pass colorizes it.
66366
- return useToneMapping || useColorSpace || debugViewAccumulates( this.debug.view );
66422
+ // Only screen output needs one. An off-screen target, such as a scene pass, already is the target.
66423
+ return useToneMapping || useColorSpace || ( debugViewAccumulates( this.debug.view ) && this.isOutputTarget );
66367
66424
  // !WITH_GENESYS
66368
66425
  // return useToneMapping || useColorSpace;
66369
66426
 
@@ -66417,9 +66474,7 @@ class Renderer {
66417
66474
  get currentToneMapping() {
66418
66475
 
66419
66476
  // WITH_GENESYS
66420
- const view = this.debug.view;
66421
-
66422
- if ( view === DEBUG_VIEW_SHADER_COMPLEXITY || view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS || view === DEBUG_VIEW_LIGHTING_COMPLEXITY || view === DEBUG_VIEW_QUAD_OVERDRAW || view === DEBUG_VIEW_BUFFER ) {
66477
+ if ( debugViewSkipsToneMapping( this.debug.view ) ) {
66423
66478
 
66424
66479
  return NoToneMapping;
66425
66480
 
@@ -73133,8 +73188,9 @@ class WebGLState {
73133
73188
  * @param {Material} material - The material to configure the state for.
73134
73189
  * @param {number} frontFaceCW - Whether the front faces are counter-clockwise or not.
73135
73190
  * @param {number} hardwareClippingPlanes - The number of hardware clipping planes.
73191
+ * @param {?Object3D} [object=null] - The object being drawn. Used by the accumulating debug views.
73136
73192
  */
73137
- setMaterial( material, frontFaceCW, hardwareClippingPlanes ) {
73193
+ setMaterial( material, frontFaceCW, hardwareClippingPlanes, object = null ) {
73138
73194
 
73139
73195
  const { gl } = this;
73140
73196
 
@@ -73149,7 +73205,7 @@ class WebGLState {
73149
73205
 
73150
73206
  // WITH_GENESYS
73151
73207
  // WebGL has no cached render pipeline. One+One is applied on each draw instead.
73152
- if ( debugViewAccumulates( this.backend.renderer.debug.view ) && material.isShadowPassMaterial !== true && this.backend.renderer.isOutputTarget !== true ) {
73208
+ if ( debugDrawAccumulates( this.backend.renderer, material, object ) ) {
73153
73209
 
73154
73210
  this.setBlending( AdditiveBlending, AddEquation, OneFactor, OneFactor, AddEquation, OneFactor, OneFactor, material.blendColor, material.blendAlpha, true );
73155
73211
 
@@ -77399,7 +77455,10 @@ class WebGLBackend extends Backend {
77399
77455
 
77400
77456
  const frontFaceCW = ( object.isMesh && object.matrixWorld.determinantAffine() < 0 );
77401
77457
 
77402
- state.setMaterial( material, frontFaceCW, hardwareClippingPlanes );
77458
+ // WITH_GENESYS
77459
+ state.setMaterial( material, frontFaceCW, hardwareClippingPlanes, object );
77460
+ // !WITH_GENESYS
77461
+ // state.setMaterial( material, frontFaceCW, hardwareClippingPlanes );
77403
77462
 
77404
77463
  if ( context.mrt !== null && context.textures !== null ) {
77405
77464
 
@@ -87854,7 +87913,7 @@ class WebGPUPipelineUtils {
87854
87913
 
87855
87914
  // WITH_GENESYS
87856
87915
  // Accumulate shader cost with One+One. Opaque materials normally disable blending.
87857
- if ( debugViewAccumulates( backend.renderer.debug.view ) && material.isShadowPassMaterial !== true && backend.renderer.isOutputTarget !== true ) {
87916
+ if ( debugDrawAccumulates( backend.renderer, material, object ) ) {
87858
87917
 
87859
87918
  materialBlending = {
87860
87919
  color: {
@@ -92879,6 +92938,8 @@ class BundleGroup extends Group {
92879
92938
 
92880
92939
  }
92881
92940
 
92941
+ // !WITH_GENESYS
92942
+
92882
92943
  /**
92883
92944
  * This module is responsible to manage the rendering pipeline setups in apps.
92884
92945
  * You usually create a single instance of this class and use it to define
@@ -93013,7 +93074,12 @@ class RenderPipeline {
93013
93074
  const outputColorSpace = renderer.outputColorSpace;
93014
93075
 
93015
93076
  renderer.toneMapping = NoToneMapping;
93016
- renderer.outputColorSpace = ColorManagement.workingColorSpace;
93077
+
93078
+ // WITH_GENESYS
93079
+ // Accumulating views colorize in the renderer's output pass, which must still encode the color space.
93080
+ if ( debugViewAccumulates( renderer.debug.view ) !== true ) renderer.outputColorSpace = ColorManagement.workingColorSpace;
93081
+ // !WITH_GENESYS
93082
+ // renderer.outputColorSpace = ColorManagement.workingColorSpace;
93017
93083
 
93018
93084
  //
93019
93085
 
@@ -93089,19 +93155,40 @@ class RenderPipeline {
93089
93155
  */
93090
93156
  _update() {
93091
93157
 
93092
- if ( this._toneMapping !== this.renderer.toneMapping ) {
93158
+ // WITH_GENESYS
93159
+ // Debug views drawn without tone mapping must match the direct path. An accumulating
93160
+ // view copies the raw ratio here, and the renderer's output pass colorizes it.
93161
+ const view = this.renderer.debug.view;
93162
+ const toneMapping = debugViewSkipsToneMapping( view ) ? NoToneMapping : this.renderer.toneMapping;
93163
+ const outputColorSpace = debugViewAccumulates( view ) ? ColorManagement.workingColorSpace : this.renderer.outputColorSpace;
93093
93164
 
93094
- this._toneMapping = this.renderer.toneMapping;
93165
+ if ( this._toneMapping !== toneMapping ) {
93166
+
93167
+ this._toneMapping = toneMapping;
93095
93168
  this.needsUpdate = true;
93096
93169
 
93097
93170
  }
93098
93171
 
93099
- if ( this._outputColorSpace !== this.renderer.outputColorSpace ) {
93172
+ if ( this._outputColorSpace !== outputColorSpace ) {
93100
93173
 
93101
- this._outputColorSpace = this.renderer.outputColorSpace;
93174
+ this._outputColorSpace = outputColorSpace;
93102
93175
  this.needsUpdate = true;
93103
93176
 
93104
93177
  }
93178
+ // !WITH_GENESYS
93179
+ // if ( this._toneMapping !== this.renderer.toneMapping ) {
93180
+ //
93181
+ // this._toneMapping = this.renderer.toneMapping;
93182
+ // this.needsUpdate = true;
93183
+ //
93184
+ // }
93185
+ //
93186
+ // if ( this._outputColorSpace !== this.renderer.outputColorSpace ) {
93187
+ //
93188
+ // this._outputColorSpace = this.renderer.outputColorSpace;
93189
+ // this.needsUpdate = true;
93190
+ //
93191
+ // }
93105
93192
 
93106
93193
  if ( this.needsUpdate === true ) {
93107
93194