@gnsx/three 0.186.4 → 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.
- package/build/three.webgpu.js +1563 -761
- package/build/three.webgpu.nodes.js +1563 -761
- package/examples/jsm/inspector/tabs/Settings.js +64 -3
- package/package.json +1 -1
- package/src/materials/nodes/MeshBasicNodeMaterial.js +13 -0
- package/src/materials/nodes/MeshLambertNodeMaterial.js +13 -0
- package/src/materials/nodes/MeshMatcapNodeMaterial.js +13 -0
- package/src/materials/nodes/MeshPhongNodeMaterial.js +13 -0
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +25 -0
- package/src/materials/nodes/MeshSSSNodeMaterial.js +15 -0
- package/src/materials/nodes/MeshStandardNodeMaterial.js +13 -0
- package/src/materials/nodes/MeshToonNodeMaterial.js +13 -0
- package/src/materials/nodes/NodeMaterial.js +107 -7
- package/src/materials/nodes/ShadowNodeMaterial.js +13 -0
- package/src/materials/nodes/VolumeNodeMaterial.js +13 -0
- package/src/nodes/display/BufferDebug.js +143 -0
- package/src/nodes/display/ComplexityDebug.js +188 -34
- package/src/nodes/display/DrawCallDebug.js +119 -0
- package/src/nodes/display/LightingDebug.js +109 -0
- package/src/renderers/common/Background.js +5 -2
- package/src/renderers/common/RenderObject.js +1 -1
- package/src/renderers/common/RenderPipeline.js +34 -5
- package/src/renderers/common/Renderer.js +11 -9
- package/src/renderers/common/nodes/NodeManager.js +13 -3
- package/src/renderers/webgl-fallback/WebGLBackend.js +4 -1
- package/src/renderers/webgl-fallback/utils/WebGLState.js +6 -2
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +4 -1
package/build/three.webgpu.js
CHANGED
|
@@ -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,
|
|
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,282 +21614,1376 @@ 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
|
|
21620
21761
|
|
|
21621
21762
|
|
|
21622
|
-
/**
|
|
21623
|
-
* Shaded output. No complexity debug view.
|
|
21624
|
-
*
|
|
21625
|
-
* @type {string}
|
|
21626
|
-
*/
|
|
21627
|
-
const DEBUG_VIEW_NONE = 'none';
|
|
21763
|
+
/**
|
|
21764
|
+
* Shaded output. No complexity debug view.
|
|
21765
|
+
*
|
|
21766
|
+
* @type {string}
|
|
21767
|
+
*/
|
|
21768
|
+
const DEBUG_VIEW_NONE = 'none';
|
|
21769
|
+
|
|
21770
|
+
/**
|
|
21771
|
+
* Material-cost heatmap. Overlapping draws accumulate, then a fullscreen pass applies the ramp.
|
|
21772
|
+
*
|
|
21773
|
+
* @type {string}
|
|
21774
|
+
*/
|
|
21775
|
+
const DEBUG_VIEW_SHADER_COMPLEXITY = 'shaderComplexity';
|
|
21776
|
+
|
|
21777
|
+
/**
|
|
21778
|
+
* Direct-light count heatmap. The visible surface wins.
|
|
21779
|
+
*
|
|
21780
|
+
* @type {string}
|
|
21781
|
+
*/
|
|
21782
|
+
const DEBUG_VIEW_LIGHTING_COMPLEXITY = 'lightingComplexity';
|
|
21783
|
+
|
|
21784
|
+
/**
|
|
21785
|
+
* Per-pixel overdraw heatmap. Each fragment that passes the depth test adds one.
|
|
21786
|
+
* This is the portable stand-in for Unreal's 2×2 quad-coverage count.
|
|
21787
|
+
*
|
|
21788
|
+
* @type {string}
|
|
21789
|
+
*/
|
|
21790
|
+
const DEBUG_VIEW_QUAD_OVERDRAW = 'quadOverdraw';
|
|
21791
|
+
|
|
21792
|
+
/**
|
|
21793
|
+
* Shader cost multiplied by the number of fragments that shaded the pixel, then the shader-complexity ramp.
|
|
21794
|
+
* One opaque surface matches {@link DEBUG_VIEW_SHADER_COMPLEXITY}. Each extra overlapping fragment scales the summed cost.
|
|
21795
|
+
* WebGPU cannot count wasted lanes in a 2×2 quad, so the count is fragments that pass the depth test.
|
|
21796
|
+
*
|
|
21797
|
+
* @type {string}
|
|
21798
|
+
*/
|
|
21799
|
+
const DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS = 'shaderComplexityAndQuads';
|
|
21800
|
+
|
|
21801
|
+
/**
|
|
21802
|
+
* Proxy budget that fills the shader-complexity ramp.
|
|
21803
|
+
* Unlit and basic stay green. Phong and standard move through yellow into red.
|
|
21804
|
+
* Transmission plus several texture samples climbs toward white.
|
|
21805
|
+
*
|
|
21806
|
+
* @type {number}
|
|
21807
|
+
*/
|
|
21808
|
+
const DEFAULT_SHADER_COMPLEXITY_BUDGET = 800;
|
|
21809
|
+
|
|
21810
|
+
/**
|
|
21811
|
+
* Overlapping fragments that fill the quad-overdraw ramp.
|
|
21812
|
+
* Unreal's stair reaches white at ten layers (`1 / 16` stored, then scaled by 1.6).
|
|
21813
|
+
*
|
|
21814
|
+
* @type {number}
|
|
21815
|
+
*/
|
|
21816
|
+
const DEFAULT_QUAD_OVERDRAW_BUDGET = 10;
|
|
21817
|
+
|
|
21818
|
+
/**
|
|
21819
|
+
* Storage scale for the overdraw count in {@link DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS}.
|
|
21820
|
+
* Each fragment adds `1 / scale`, so an 8-bit target can hold this many layers.
|
|
21821
|
+
* The output pass multiplies that channel back to a count. Half-float targets hold the same count exactly.
|
|
21822
|
+
*
|
|
21823
|
+
* @type {number}
|
|
21824
|
+
*/
|
|
21825
|
+
const SHADER_COMPLEXITY_QUAD_COUNT_SCALE = 16;
|
|
21826
|
+
|
|
21827
|
+
/**
|
|
21828
|
+
* Added for each fragment texture sample. Lighting-model costs are returned
|
|
21829
|
+
* directly by {@link NodeMaterial#getShaderComplexity}.
|
|
21830
|
+
*
|
|
21831
|
+
* @type {number}
|
|
21832
|
+
*/
|
|
21833
|
+
const SHADER_COMPLEXITY_TEXTURE_COST = 16;
|
|
21834
|
+
|
|
21835
|
+
/**
|
|
21836
|
+
* Attenuation above this counts as a light that shades the pixel.
|
|
21837
|
+
*
|
|
21838
|
+
* @type {number}
|
|
21839
|
+
*/
|
|
21840
|
+
const LIGHTING_COMPLEXITY_EPSILON = 0.001;
|
|
21841
|
+
|
|
21842
|
+
/**
|
|
21843
|
+
* Added on top of 1 when a received light casts a shadow.
|
|
21844
|
+
* Applied even where the shadow map is black.
|
|
21845
|
+
*
|
|
21846
|
+
* @type {number}
|
|
21847
|
+
*/
|
|
21848
|
+
const LIGHTING_COMPLEXITY_SHADOW_WEIGHT = 0.5;
|
|
21849
|
+
|
|
21850
|
+
/**
|
|
21851
|
+
* Unreal `ShaderComplexityColors` from `BaseEngine.ini`.
|
|
21852
|
+
*
|
|
21853
|
+
* @type {Array<Array<number>>}
|
|
21854
|
+
*/
|
|
21855
|
+
const SHADER_COMPLEXITY_COLORS = [
|
|
21856
|
+
[ 0.0, 1.0, 0.127 ],
|
|
21857
|
+
[ 0.0, 1.0, 0.0 ],
|
|
21858
|
+
[ 0.046, 0.52, 0.0 ],
|
|
21859
|
+
[ 0.215, 0.215, 0.0 ],
|
|
21860
|
+
[ 0.52, 0.046, 0.0 ],
|
|
21861
|
+
[ 0.7, 0.0, 0.0 ],
|
|
21862
|
+
[ 1.0, 0.0, 0.0 ],
|
|
21863
|
+
[ 1.0, 0.0, 0.5 ],
|
|
21864
|
+
[ 1.0, 0.9, 0.9 ]
|
|
21865
|
+
];
|
|
21866
|
+
|
|
21867
|
+
/**
|
|
21868
|
+
* Unreal `QuadComplexityColors` from `BaseEngine.ini`.
|
|
21869
|
+
* Sampled as a stair: one overlapping fragment is one stop.
|
|
21870
|
+
*
|
|
21871
|
+
* @type {Array<Array<number>>}
|
|
21872
|
+
*/
|
|
21873
|
+
const QUAD_COMPLEXITY_COLORS = [
|
|
21874
|
+
[ 0.0, 0.0, 0.0 ],
|
|
21875
|
+
[ 0.0, 0.0, 0.4 ],
|
|
21876
|
+
[ 0.0, 0.3, 1.0 ],
|
|
21877
|
+
[ 0.0, 0.7, 0.4 ],
|
|
21878
|
+
[ 0.0, 1.0, 0.0 ],
|
|
21879
|
+
[ 0.8, 0.8, 0.0 ],
|
|
21880
|
+
[ 1.0, 0.3, 0.0 ],
|
|
21881
|
+
[ 0.7, 0.0, 0.0 ],
|
|
21882
|
+
[ 0.5, 0.0, 0.5 ],
|
|
21883
|
+
[ 0.7, 0.3, 0.7 ],
|
|
21884
|
+
[ 1.0, 0.9, 0.9 ]
|
|
21885
|
+
];
|
|
21886
|
+
|
|
21887
|
+
/**
|
|
21888
|
+
* Unreal `LightComplexityColors` from `BaseEngine.ini`.
|
|
21889
|
+
*
|
|
21890
|
+
* @type {Array<Array<number>>}
|
|
21891
|
+
*/
|
|
21892
|
+
const LIGHT_COMPLEXITY_COLORS = [
|
|
21893
|
+
[ 0.0, 0.0, 0.0 ],
|
|
21894
|
+
[ 0.0, 0.0, 0.4 ],
|
|
21895
|
+
[ 0.0, 0.3, 1.0 ],
|
|
21896
|
+
[ 0.0, 0.7, 0.4 ],
|
|
21897
|
+
[ 0.0, 1.0, 0.0 ],
|
|
21898
|
+
[ 0.8, 0.8, 0.0 ],
|
|
21899
|
+
[ 1.0, 0.3, 0.0 ],
|
|
21900
|
+
[ 0.7, 0.0, 0.0 ],
|
|
21901
|
+
[ 0.5, 0.0, 0.5 ],
|
|
21902
|
+
[ 0.7, 0.3, 0.7 ],
|
|
21903
|
+
[ 1.0, 0.9, 0.9 ]
|
|
21904
|
+
];
|
|
21905
|
+
|
|
21906
|
+
const rgb = ( colors, index ) => vec3( colors[ index ][ 0 ], colors[ index ][ 1 ], colors[ index ][ 2 ] );
|
|
21907
|
+
|
|
21908
|
+
/**
|
|
21909
|
+
* Linear sample of a fixed RGB ramp. `cost` is in steps, and one step is one light.
|
|
21910
|
+
*
|
|
21911
|
+
* @param {Node<float>} cost - Complexity in ramp steps.
|
|
21912
|
+
* @param {Array<Array<number>>} colors - Ramp stops.
|
|
21913
|
+
* @return {Node<vec3>} The ramp color.
|
|
21914
|
+
*/
|
|
21915
|
+
const colorizeLinear = ( cost, colors ) => {
|
|
21916
|
+
|
|
21917
|
+
const steps = colors.length - 1;
|
|
21918
|
+
const expanded = cost.div( steps ).clamp( 0, 0.999 ).mul( steps );
|
|
21919
|
+
const index = expanded.floor();
|
|
21920
|
+
const frac = fract( expanded );
|
|
21921
|
+
|
|
21922
|
+
let color = rgb( colors, 0 );
|
|
21923
|
+
|
|
21924
|
+
for ( let i = 0; i < steps; i ++ ) {
|
|
21925
|
+
|
|
21926
|
+
const sample = mix( rgb( colors, i ), rgb( colors, i + 1 ), frac );
|
|
21927
|
+
|
|
21928
|
+
color = index.greaterThanEqual( float( i ) ).and( index.lessThan( float( i + 1 ) ) ).select( sample, color );
|
|
21929
|
+
|
|
21930
|
+
}
|
|
21931
|
+
|
|
21932
|
+
return color;
|
|
21933
|
+
|
|
21934
|
+
};
|
|
21935
|
+
|
|
21936
|
+
/**
|
|
21937
|
+
* Maps a direct-light cost through Unreal's light-complexity ramp.
|
|
21938
|
+
* Ten lights saturate at white.
|
|
21939
|
+
*
|
|
21940
|
+
* @param {Node<float>} cost - Accumulated light weight.
|
|
21941
|
+
* @return {Node<vec3>} The ramp color.
|
|
21942
|
+
*/
|
|
21943
|
+
const colorizeLightComplexity = ( cost ) => colorizeLinear( cost, LIGHT_COMPLEXITY_COLORS );
|
|
21944
|
+
|
|
21945
|
+
/**
|
|
21946
|
+
* Unreal's stair sample for quad overdraw (`CS_STAIR`).
|
|
21947
|
+
* `cost` is the accumulated fragment count divided by the budget.
|
|
21948
|
+
*
|
|
21949
|
+
* @param {Node<float>} cost - Overdraw count divided by the budget.
|
|
21950
|
+
* @return {Node<vec3>} The ramp color.
|
|
21951
|
+
*/
|
|
21952
|
+
const colorizeQuadOverdraw = ( cost ) => {
|
|
21953
|
+
|
|
21954
|
+
const steps = QUAD_COMPLEXITY_COLORS.length - 1;
|
|
21955
|
+
const index = round( cost.clamp( 0, 1 ).mul( steps ) );
|
|
21956
|
+
|
|
21957
|
+
let color = rgb( QUAD_COMPLEXITY_COLORS, 0 );
|
|
21958
|
+
|
|
21959
|
+
for ( let i = 0; i <= steps; i ++ ) {
|
|
21960
|
+
|
|
21961
|
+
color = index.equal( float( i ) ).select( rgb( QUAD_COMPLEXITY_COLORS, i ), color );
|
|
21962
|
+
|
|
21963
|
+
}
|
|
21964
|
+
|
|
21965
|
+
return color;
|
|
21966
|
+
|
|
21967
|
+
};
|
|
21968
|
+
|
|
21969
|
+
/**
|
|
21970
|
+
* Views that add a scalar per fragment, then colorize that sum in the output pass.
|
|
21971
|
+
*
|
|
21972
|
+
* @param {string} view - `renderer.debug.view`.
|
|
21973
|
+
* @return {boolean} `true` when the view accumulates.
|
|
21974
|
+
*/
|
|
21975
|
+
function debugViewAccumulates( view ) {
|
|
21976
|
+
|
|
21977
|
+
return view === DEBUG_VIEW_SHADER_COMPLEXITY || view === DEBUG_VIEW_QUAD_OVERDRAW || view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS;
|
|
21978
|
+
|
|
21979
|
+
}
|
|
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
|
+
|
|
22012
|
+
/**
|
|
22013
|
+
* Unreal's nonlinear shader-complexity ramp (`ColorizeComplexity`).
|
|
22014
|
+
* The first third of the normalized cost spreads across the first seven stops.
|
|
22015
|
+
*
|
|
22016
|
+
* @param {Node<float>} complexity - Accumulated cost divided by the budget.
|
|
22017
|
+
* @return {Node<vec3>} The ramp color.
|
|
22018
|
+
*/
|
|
22019
|
+
const colorizeShaderComplexity = /*@__PURE__*/ Fn( ( [ complexity ] ) => {
|
|
22020
|
+
|
|
22021
|
+
const c = complexity.clamp( 0, 0.999 );
|
|
22022
|
+
const expanded = min$1( float( SHADER_COMPLEXITY_COLORS.length - 2 ), c.mul( 18 ) );
|
|
22023
|
+
const color = vec3( 0 ).toVar();
|
|
22024
|
+
const frac = fract( expanded );
|
|
22025
|
+
|
|
22026
|
+
If( expanded.lessThan( 1 ), () => {
|
|
22027
|
+
|
|
22028
|
+
color.assign( mix( rgb( SHADER_COMPLEXITY_COLORS, 0 ), rgb( SHADER_COMPLEXITY_COLORS, 1 ), frac ) );
|
|
22029
|
+
|
|
22030
|
+
} ).ElseIf( expanded.lessThan( 2 ), () => {
|
|
22031
|
+
|
|
22032
|
+
color.assign( mix( rgb( SHADER_COMPLEXITY_COLORS, 1 ), rgb( SHADER_COMPLEXITY_COLORS, 2 ), frac ) );
|
|
22033
|
+
|
|
22034
|
+
} ).ElseIf( expanded.lessThan( 3 ), () => {
|
|
22035
|
+
|
|
22036
|
+
color.assign( mix( rgb( SHADER_COMPLEXITY_COLORS, 2 ), rgb( SHADER_COMPLEXITY_COLORS, 3 ), frac ) );
|
|
22037
|
+
|
|
22038
|
+
} ).ElseIf( expanded.lessThan( 4 ), () => {
|
|
22039
|
+
|
|
22040
|
+
color.assign( mix( rgb( SHADER_COMPLEXITY_COLORS, 3 ), rgb( SHADER_COMPLEXITY_COLORS, 4 ), frac ) );
|
|
22041
|
+
|
|
22042
|
+
} ).ElseIf( expanded.lessThan( 5 ), () => {
|
|
22043
|
+
|
|
22044
|
+
color.assign( mix( rgb( SHADER_COMPLEXITY_COLORS, 4 ), rgb( SHADER_COMPLEXITY_COLORS, 5 ), frac ) );
|
|
22045
|
+
|
|
22046
|
+
} ).ElseIf( expanded.lessThan( 6 ), () => {
|
|
22047
|
+
|
|
22048
|
+
color.assign( mix( rgb( SHADER_COMPLEXITY_COLORS, 5 ), rgb( SHADER_COMPLEXITY_COLORS, 6 ), frac ) );
|
|
22049
|
+
|
|
22050
|
+
} ).Else( () => {
|
|
22051
|
+
|
|
22052
|
+
// Nine stops, so the upper range uses the `count > 8` scale of 3.
|
|
22053
|
+
const upper = c.sub( 0.33333333 ).mul( 3.0 );
|
|
22054
|
+
const upperFrac = fract( upper );
|
|
22055
|
+
|
|
22056
|
+
If( upper.lessThanEqual( 1 ), () => {
|
|
22057
|
+
|
|
22058
|
+
color.assign( mix( rgb( SHADER_COMPLEXITY_COLORS, 6 ), rgb( SHADER_COMPLEXITY_COLORS, 7 ), upperFrac ) );
|
|
22059
|
+
|
|
22060
|
+
} ).Else( () => {
|
|
22061
|
+
|
|
22062
|
+
color.assign( mix( rgb( SHADER_COMPLEXITY_COLORS, 7 ), rgb( SHADER_COMPLEXITY_COLORS, 8 ), upperFrac ) );
|
|
22063
|
+
|
|
22064
|
+
} );
|
|
22065
|
+
|
|
22066
|
+
} );
|
|
22067
|
+
|
|
22068
|
+
return color;
|
|
22069
|
+
|
|
22070
|
+
} );
|
|
22071
|
+
|
|
22072
|
+
/**
|
|
22073
|
+
* Reads the builder's shader-complexity proxy at code-generation time,
|
|
22074
|
+
* after the real material graph has been generated and texture samples counted.
|
|
22075
|
+
*
|
|
22076
|
+
* @augments Node
|
|
22077
|
+
*/
|
|
22078
|
+
class ShaderComplexityRatioNode extends Node {
|
|
22079
|
+
|
|
22080
|
+
static get type() {
|
|
22081
|
+
|
|
22082
|
+
return 'ShaderComplexityRatioNode';
|
|
22083
|
+
|
|
22084
|
+
}
|
|
22085
|
+
|
|
22086
|
+
constructor() {
|
|
22087
|
+
|
|
22088
|
+
super( 'float' );
|
|
22089
|
+
|
|
22090
|
+
}
|
|
22091
|
+
|
|
22092
|
+
generate( builder ) {
|
|
22093
|
+
|
|
22094
|
+
const budget = builder.renderer.debug.shaderComplexityBudget;
|
|
22095
|
+
const safeBudget = ( typeof budget === 'number' && budget > 0 ) ? budget : 1;
|
|
22096
|
+
const ratio = builder.getShaderComplexityCost() / safeBudget;
|
|
22097
|
+
|
|
22098
|
+
return ratio.toFixed( 6 );
|
|
22099
|
+
|
|
22100
|
+
}
|
|
22101
|
+
|
|
22102
|
+
}
|
|
22103
|
+
|
|
22104
|
+
/**
|
|
22105
|
+
* Replaces the shaded color with `vec4(cost / budget, 0, 0, 1)`.
|
|
22106
|
+
* The real graph is still generated so texture samples are counted first.
|
|
22107
|
+
*
|
|
22108
|
+
* @param {Node} resultNode - The material's shaded output.
|
|
22109
|
+
* @return {Node<vec4>} The complexity ratio in the red channel.
|
|
22110
|
+
*/
|
|
22111
|
+
function shaderComplexityOutput( resultNode ) {
|
|
22112
|
+
|
|
22113
|
+
// Generate the shaded graph first so texture samples are counted, then
|
|
22114
|
+
// replace the color. A bypass of a value node emits a bare expression
|
|
22115
|
+
// statement, which WGSL rejects.
|
|
22116
|
+
const shaded = vec4( resultNode ).toVar();
|
|
22117
|
+
|
|
22118
|
+
const ratio = new ShaderComplexityRatioNode();
|
|
22119
|
+
|
|
22120
|
+
return vec4( ratio, 0, 0, 1 ).add( shaded.mul( 0 ) );
|
|
22121
|
+
|
|
22122
|
+
}
|
|
22123
|
+
|
|
22124
|
+
/**
|
|
22125
|
+
* Same cost as {@link shaderComplexityOutput}, plus one overdraw step in green.
|
|
22126
|
+
* The output pass multiplies red by the accumulated green count.
|
|
22127
|
+
*
|
|
22128
|
+
* @param {Node} resultNode - The material's shaded output.
|
|
22129
|
+
* @return {Node<vec4>} Cost ratio in red, one scaled fragment in green.
|
|
22130
|
+
*/
|
|
22131
|
+
function shaderComplexityAndQuadsOutput( resultNode ) {
|
|
22132
|
+
|
|
22133
|
+
const shaded = vec4( resultNode ).toVar();
|
|
22134
|
+
const ratio = new ShaderComplexityRatioNode();
|
|
22135
|
+
const step = float( 1 / SHADER_COMPLEXITY_QUAD_COUNT_SCALE );
|
|
22136
|
+
|
|
22137
|
+
return vec4( ratio, step, 0, 1 ).add( shaded.mul( 0 ) );
|
|
22138
|
+
|
|
22139
|
+
}
|
|
22140
|
+
|
|
22141
|
+
/**
|
|
22142
|
+
* Reads `1 / quadOverdrawBudget` at code-generation time.
|
|
22143
|
+
*
|
|
22144
|
+
* @augments Node
|
|
22145
|
+
*/
|
|
22146
|
+
class QuadOverdrawRatioNode extends Node {
|
|
22147
|
+
|
|
22148
|
+
static get type() {
|
|
22149
|
+
|
|
22150
|
+
return 'QuadOverdrawRatioNode';
|
|
22151
|
+
|
|
22152
|
+
}
|
|
22153
|
+
|
|
22154
|
+
constructor() {
|
|
22155
|
+
|
|
22156
|
+
super( 'float' );
|
|
22157
|
+
|
|
22158
|
+
}
|
|
22159
|
+
|
|
22160
|
+
generate( builder ) {
|
|
22161
|
+
|
|
22162
|
+
const budget = builder.renderer.debug.quadOverdrawBudget;
|
|
22163
|
+
const safeBudget = ( typeof budget === 'number' && budget > 0 ) ? budget : 1;
|
|
22164
|
+
|
|
22165
|
+
return ( 1 / safeBudget ).toFixed( 6 );
|
|
22166
|
+
|
|
22167
|
+
}
|
|
22168
|
+
|
|
22169
|
+
}
|
|
22170
|
+
|
|
22171
|
+
/**
|
|
22172
|
+
* Replaces the shaded color with `vec4(1 / budget, 0, 0, 1)`.
|
|
22173
|
+
* The real graph is still generated so clipped fragments are not counted.
|
|
22174
|
+
*
|
|
22175
|
+
* @param {Node} resultNode - The material's shaded output.
|
|
22176
|
+
* @return {Node<vec4>} One overdraw step in the red channel.
|
|
22177
|
+
*/
|
|
22178
|
+
function quadOverdrawOutput( resultNode ) {
|
|
22179
|
+
|
|
22180
|
+
const shaded = vec4( resultNode ).toVar();
|
|
22181
|
+
const ratio = new QuadOverdrawRatioNode();
|
|
22182
|
+
|
|
22183
|
+
return vec4( ratio, 0, 0, 1 ).add( shaded.mul( 0 ) );
|
|
22184
|
+
|
|
22185
|
+
}
|
|
22186
|
+
|
|
22187
|
+
/**
|
|
22188
|
+
* This node can be used to define multiple outputs in a shader programs.
|
|
22189
|
+
*
|
|
22190
|
+
* @augments Node
|
|
22191
|
+
*/
|
|
22192
|
+
class OutputStructNode extends Node {
|
|
22193
|
+
|
|
22194
|
+
static get type() {
|
|
22195
|
+
|
|
22196
|
+
return 'OutputStructNode';
|
|
22197
|
+
|
|
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
|
+
}
|
|
22277
|
+
|
|
22278
|
+
/**
|
|
22279
|
+
* TSL function for creating an output struct node.
|
|
22280
|
+
*
|
|
22281
|
+
* @tsl
|
|
22282
|
+
* @function
|
|
22283
|
+
* @param {...Node} members - A parameter list of nodes.
|
|
22284
|
+
* @returns {OutputStructNode}
|
|
22285
|
+
*/
|
|
22286
|
+
const outputStruct = /*@__PURE__*/ nodeProxy( OutputStructNode );
|
|
22287
|
+
|
|
22288
|
+
/**
|
|
22289
|
+
* Represents blending configuration.
|
|
22290
|
+
*
|
|
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.
|
|
22293
|
+
*/
|
|
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
|
+
}
|
|
22427
|
+
|
|
22428
|
+
/**
|
|
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.
|
|
22432
|
+
*
|
|
22433
|
+
* @private
|
|
22434
|
+
* @augments Color
|
|
22435
|
+
*/
|
|
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 );
|
|
22514
|
+
|
|
22515
|
+
/**
|
|
22516
|
+
* Returns the MRT texture index for the given name.
|
|
22517
|
+
*
|
|
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.
|
|
22521
|
+
*/
|
|
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
|
+
}
|
|
22537
|
+
|
|
22538
|
+
/**
|
|
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.
|
|
22548
|
+
*
|
|
22549
|
+
* @augments OutputStructNode
|
|
22550
|
+
*/
|
|
22551
|
+
class MRTNode extends OutputStructNode {
|
|
22552
|
+
|
|
22553
|
+
static get type() {
|
|
22554
|
+
|
|
22555
|
+
return 'MRTNode';
|
|
22556
|
+
|
|
22557
|
+
}
|
|
22558
|
+
|
|
22559
|
+
/**
|
|
22560
|
+
* Constructs a new output struct node.
|
|
22561
|
+
*
|
|
22562
|
+
* @param {Object<string, Node>} outputNodes - The MRT outputs.
|
|
22563
|
+
*/
|
|
22564
|
+
constructor( outputNodes ) {
|
|
22565
|
+
|
|
22566
|
+
super();
|
|
22567
|
+
|
|
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;
|
|
22601
|
+
|
|
22602
|
+
}
|
|
22603
|
+
|
|
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 ) {
|
|
22612
|
+
|
|
22613
|
+
this.blendModes[ name ] = blend;
|
|
22614
|
+
|
|
22615
|
+
return this;
|
|
22616
|
+
|
|
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;
|
|
22628
|
+
|
|
22629
|
+
}
|
|
22630
|
+
|
|
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 ) {
|
|
22640
|
+
|
|
22641
|
+
const clearColor = this.clearColors[ name ] || ( this.clearColors[ name ] = new Color4() );
|
|
22642
|
+
|
|
22643
|
+
clearColor.set( color );
|
|
22644
|
+
clearColor.a = alpha;
|
|
22645
|
+
|
|
22646
|
+
return this;
|
|
21628
22647
|
|
|
21629
|
-
|
|
21630
|
-
* Material-cost heatmap. Overlapping draws accumulate, then a fullscreen pass applies the ramp.
|
|
21631
|
-
*
|
|
21632
|
-
* @type {string}
|
|
21633
|
-
*/
|
|
21634
|
-
const DEBUG_VIEW_SHADER_COMPLEXITY = 'shaderComplexity';
|
|
22648
|
+
}
|
|
21635
22649
|
|
|
21636
|
-
/**
|
|
21637
|
-
|
|
21638
|
-
|
|
21639
|
-
|
|
21640
|
-
|
|
21641
|
-
|
|
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 ) {
|
|
21642
22658
|
|
|
21643
|
-
|
|
21644
|
-
* Proxy budget that fills the shader-complexity ramp.
|
|
21645
|
-
* A plain lit material stays in the green stops. Transmission plus several
|
|
21646
|
-
* texture samples climbs toward red.
|
|
21647
|
-
*
|
|
21648
|
-
* @type {number}
|
|
21649
|
-
*/
|
|
21650
|
-
const DEFAULT_SHADER_COMPLEXITY_BUDGET = 800;
|
|
22659
|
+
return this.clearColors[ name ] || null;
|
|
21651
22660
|
|
|
21652
|
-
|
|
21653
|
-
const SHADER_COMPLEXITY_BASE_UNLIT = 20;
|
|
22661
|
+
}
|
|
21654
22662
|
|
|
21655
|
-
/**
|
|
21656
|
-
|
|
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 ) {
|
|
21657
22670
|
|
|
21658
|
-
|
|
21659
|
-
|
|
22671
|
+
return this.outputNodes[ name ] !== undefined;
|
|
22672
|
+
|
|
22673
|
+
}
|
|
22674
|
+
|
|
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 ) {
|
|
22682
|
+
|
|
22683
|
+
return this.outputNodes[ name ];
|
|
22684
|
+
|
|
22685
|
+
}
|
|
22686
|
+
|
|
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
|
+
}
|
|
21660
22728
|
|
|
21661
|
-
|
|
21662
|
-
|
|
22729
|
+
this.members = members;
|
|
22730
|
+
|
|
22731
|
+
return super.setup( builder );
|
|
22732
|
+
|
|
22733
|
+
}
|
|
21663
22734
|
|
|
21664
|
-
|
|
21665
|
-
const SHADER_COMPLEXITY_TRANSMISSION_COST = 60;
|
|
22735
|
+
}
|
|
21666
22736
|
|
|
21667
22737
|
/**
|
|
21668
|
-
*
|
|
22738
|
+
* TSL function for creating a MRT node.
|
|
21669
22739
|
*
|
|
21670
|
-
* @
|
|
22740
|
+
* @tsl
|
|
22741
|
+
* @function
|
|
22742
|
+
* @param {Object<string, Node>} outputNodes - The MRT outputs.
|
|
22743
|
+
* @returns {MRTNode}
|
|
21671
22744
|
*/
|
|
21672
|
-
const
|
|
22745
|
+
const mrt = /*@__PURE__*/ nodeProxy( MRTNode );
|
|
22746
|
+
|
|
22747
|
+
// WITH_GENESYS
|
|
22748
|
+
// Lighting only and detail lighting. Both replace the shaded albedo with a flat gray.
|
|
22749
|
+
// !WITH_GENESYS
|
|
22750
|
+
|
|
21673
22751
|
|
|
21674
22752
|
/**
|
|
21675
|
-
*
|
|
21676
|
-
* Applied even where the shadow map is black.
|
|
22753
|
+
* Lighting only. Flat gray, no specular, geometry normals. Material detail is dropped.
|
|
21677
22754
|
*
|
|
21678
|
-
* @type {
|
|
22755
|
+
* @type {string}
|
|
21679
22756
|
*/
|
|
21680
|
-
const
|
|
22757
|
+
const DEBUG_VIEW_LIGHTING_ONLY = 'lightingOnly';
|
|
21681
22758
|
|
|
21682
22759
|
/**
|
|
21683
|
-
*
|
|
22760
|
+
* Detail lighting. Flat gray and a constant specular, with normal maps and roughness kept.
|
|
21684
22761
|
*
|
|
21685
|
-
* @type {
|
|
22762
|
+
* @type {string}
|
|
21686
22763
|
*/
|
|
21687
|
-
const
|
|
21688
|
-
[ 0.0, 1.0, 0.127 ],
|
|
21689
|
-
[ 0.0, 1.0, 0.0 ],
|
|
21690
|
-
[ 0.046, 0.52, 0.0 ],
|
|
21691
|
-
[ 0.215, 0.215, 0.0 ],
|
|
21692
|
-
[ 0.52, 0.046, 0.0 ],
|
|
21693
|
-
[ 0.7, 0.0, 0.0 ],
|
|
21694
|
-
[ 1.0, 0.0, 0.0 ],
|
|
21695
|
-
[ 1.0, 0.0, 0.5 ],
|
|
21696
|
-
[ 1.0, 0.9, 0.9 ]
|
|
21697
|
-
];
|
|
22764
|
+
const DEBUG_VIEW_DETAIL_LIGHTING = 'detailLighting';
|
|
21698
22765
|
|
|
21699
22766
|
/**
|
|
21700
|
-
*
|
|
22767
|
+
* Neutral albedo shared by both views. Matches Unreal's `LightingOnlyBrightness`.
|
|
21701
22768
|
*
|
|
21702
|
-
* @type {
|
|
22769
|
+
* @type {number}
|
|
21703
22770
|
*/
|
|
21704
|
-
const
|
|
21705
|
-
[ 0.0, 0.0, 0.0 ],
|
|
21706
|
-
[ 0.0, 0.0, 0.4 ],
|
|
21707
|
-
[ 0.0, 0.3, 1.0 ],
|
|
21708
|
-
[ 0.0, 0.7, 0.4 ],
|
|
21709
|
-
[ 0.0, 1.0, 0.0 ],
|
|
21710
|
-
[ 0.8, 0.8, 0.0 ],
|
|
21711
|
-
[ 1.0, 0.3, 0.0 ],
|
|
21712
|
-
[ 0.7, 0.0, 0.0 ],
|
|
21713
|
-
[ 0.5, 0.0, 0.5 ],
|
|
21714
|
-
[ 0.7, 0.3, 0.7 ],
|
|
21715
|
-
[ 1.0, 0.9, 0.9 ]
|
|
21716
|
-
];
|
|
21717
|
-
|
|
21718
|
-
const rgb = ( colors, index ) => vec3( colors[ index ][ 0 ], colors[ index ][ 1 ], colors[ index ][ 2 ] );
|
|
22771
|
+
const LIGHTING_ONLY_BRIGHTNESS = 0.3;
|
|
21719
22772
|
|
|
21720
22773
|
/**
|
|
21721
|
-
*
|
|
22774
|
+
* Specular color used by detail lighting. Unreal writes `0.1` into the specular override.
|
|
21722
22775
|
*
|
|
21723
|
-
* @
|
|
21724
|
-
* @param {Array<Array<number>>} colors - Ramp stops.
|
|
21725
|
-
* @return {Node<vec3>} The ramp color.
|
|
22776
|
+
* @type {number}
|
|
21726
22777
|
*/
|
|
21727
|
-
const
|
|
21728
|
-
|
|
21729
|
-
const steps = colors.length - 1;
|
|
21730
|
-
const expanded = cost.div( steps ).clamp( 0, 0.999 ).mul( steps );
|
|
21731
|
-
const index = expanded.floor();
|
|
21732
|
-
const frac = fract( expanded );
|
|
22778
|
+
const DETAIL_LIGHTING_SPECULAR = 0.1;
|
|
21733
22779
|
|
|
21734
|
-
|
|
22780
|
+
/**
|
|
22781
|
+
* Geometry normal for lighting only, so normal maps and `normalNode` do not shade the surface.
|
|
22782
|
+
*
|
|
22783
|
+
* @type {Node<vec3>}
|
|
22784
|
+
*/
|
|
22785
|
+
const lightingOnlyNormal = /*@__PURE__*/ Fn( ( builder ) => {
|
|
21735
22786
|
|
|
21736
|
-
|
|
22787
|
+
let node = normalViewGeometry;
|
|
21737
22788
|
|
|
21738
|
-
|
|
22789
|
+
if ( builder.isFlatShading() !== true ) {
|
|
21739
22790
|
|
|
21740
|
-
|
|
22791
|
+
node = negateOnBackSide( node );
|
|
21741
22792
|
|
|
21742
22793
|
}
|
|
21743
22794
|
|
|
21744
|
-
return
|
|
22795
|
+
return node;
|
|
21745
22796
|
|
|
21746
|
-
};
|
|
22797
|
+
}, 'vec3' );
|
|
21747
22798
|
|
|
21748
22799
|
/**
|
|
21749
|
-
*
|
|
21750
|
-
*
|
|
22800
|
+
* Replaces albedo and specular after the material has written its channels.
|
|
22801
|
+
* Lit materials become a dielectric gray. Unlit materials become flat gray.
|
|
21751
22802
|
*
|
|
21752
|
-
* @param {
|
|
21753
|
-
* @
|
|
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`.
|
|
22806
|
+
* @param {string} view - `renderer.debug.view`.
|
|
21754
22807
|
*/
|
|
21755
|
-
|
|
22808
|
+
function applyLightingDebug( builder, material, view ) {
|
|
21756
22809
|
|
|
21757
|
-
|
|
21758
|
-
* Unreal's nonlinear shader-complexity ramp (`ColorizeComplexity`).
|
|
21759
|
-
* The first third of the normalized cost spreads across the first seven stops.
|
|
21760
|
-
*
|
|
21761
|
-
* @param {Node<float>} complexity - Accumulated cost divided by the budget.
|
|
21762
|
-
* @return {Node<vec3>} The ramp color.
|
|
21763
|
-
*/
|
|
21764
|
-
const colorizeShaderComplexity = /*@__PURE__*/ Fn( ( [ complexity ] ) => {
|
|
22810
|
+
const gray = vec3( LIGHTING_ONLY_BRIGHTNESS );
|
|
21765
22811
|
|
|
21766
|
-
|
|
21767
|
-
const expanded = min$1( float( SHADER_COMPLEXITY_COLORS.length - 2 ), c.mul( 18 ) );
|
|
21768
|
-
const color = vec3( 0 ).toVar();
|
|
21769
|
-
const frac = fract( expanded );
|
|
22812
|
+
diffuseColor.rgb.assign( gray );
|
|
21770
22813
|
|
|
21771
|
-
|
|
22814
|
+
if ( material.lights !== true ) return;
|
|
21772
22815
|
|
|
21773
|
-
|
|
22816
|
+
metalness.assign( float( 0 ) );
|
|
22817
|
+
diffuseContribution.assign( gray );
|
|
21774
22818
|
|
|
21775
|
-
|
|
22819
|
+
if ( view === DEBUG_VIEW_LIGHTING_ONLY ) {
|
|
21776
22820
|
|
|
21777
|
-
|
|
22821
|
+
roughness.assign( float( 1 ) );
|
|
22822
|
+
specularColor.assign( vec3( 0 ) );
|
|
22823
|
+
specularColorBlended.assign( vec3( 0 ) );
|
|
22824
|
+
specularF90.assign( float( 0 ) );
|
|
21778
22825
|
|
|
21779
|
-
|
|
22826
|
+
// Ambient occlusion was stored for the lighting model. Lighting only has no material.
|
|
22827
|
+
builder.context.ambientOcclusion = null;
|
|
21780
22828
|
|
|
21781
|
-
|
|
22829
|
+
if ( material.useClearcoat === true ) clearcoat.assign( float( 0 ) );
|
|
21782
22830
|
|
|
21783
|
-
|
|
22831
|
+
if ( material.useSheen === true ) sheen.assign( vec3( 0 ) );
|
|
21784
22832
|
|
|
21785
|
-
|
|
22833
|
+
if ( material.useIridescence === true ) iridescence.assign( float( 0 ) );
|
|
21786
22834
|
|
|
21787
|
-
|
|
22835
|
+
if ( material.useAnisotropy === true ) anisotropy.assign( float( 0 ) );
|
|
21788
22836
|
|
|
21789
|
-
|
|
22837
|
+
if ( material.useTransmission === true ) transmission.assign( float( 0 ) );
|
|
21790
22838
|
|
|
21791
|
-
|
|
22839
|
+
if ( material.useRetroreflection === true ) retroreflectivity.assign( float( 0 ) );
|
|
21792
22840
|
|
|
21793
|
-
|
|
22841
|
+
} else {
|
|
21794
22842
|
|
|
21795
|
-
|
|
22843
|
+
const specular = vec3( DETAIL_LIGHTING_SPECULAR );
|
|
21796
22844
|
|
|
21797
|
-
|
|
21798
|
-
|
|
21799
|
-
|
|
22845
|
+
specularColor.assign( specular );
|
|
22846
|
+
specularColorBlended.assign( specular );
|
|
22847
|
+
specularF90.assign( float( 1 ) );
|
|
21800
22848
|
|
|
21801
|
-
|
|
22849
|
+
}
|
|
21802
22850
|
|
|
21803
|
-
|
|
22851
|
+
}
|
|
21804
22852
|
|
|
21805
|
-
|
|
22853
|
+
// WITH_GENESYS
|
|
22854
|
+
// Draw call coloration. One stable diffuse color per submitted draw, then lit.
|
|
22855
|
+
// !WITH_GENESYS
|
|
21806
22856
|
|
|
21807
|
-
color.assign( mix( rgb( SHADER_COMPLEXITY_COLORS, 7 ), rgb( SHADER_COMPLEXITY_COLORS, 8 ), upperFrac ) );
|
|
21808
22857
|
|
|
21809
|
-
|
|
22858
|
+
/**
|
|
22859
|
+
* Draw call coloration. Each submitted draw gets one diffuse color. An instanced mesh is one draw.
|
|
22860
|
+
* The color is lit, so lights and shadows still show. Unlit materials stay flat.
|
|
22861
|
+
*
|
|
22862
|
+
* @type {string}
|
|
22863
|
+
*/
|
|
22864
|
+
const DEBUG_VIEW_DRAW_CALL = 'drawCall';
|
|
21810
22865
|
|
|
21811
|
-
|
|
22866
|
+
/**
|
|
22867
|
+
* Golden-ratio step. Sequential object ids land on opposite sides of the hue wheel.
|
|
22868
|
+
*
|
|
22869
|
+
* @type {number}
|
|
22870
|
+
*/
|
|
22871
|
+
const DRAW_CALL_HUE_STEP = 0.618033988749895;
|
|
21812
22872
|
|
|
21813
|
-
|
|
22873
|
+
/**
|
|
22874
|
+
* Saturation of a draw color. High enough that neighboring hues stay apart after lighting.
|
|
22875
|
+
*
|
|
22876
|
+
* @type {number}
|
|
22877
|
+
*/
|
|
22878
|
+
const DRAW_CALL_SATURATION = 0.85;
|
|
21814
22879
|
|
|
21815
|
-
|
|
22880
|
+
/**
|
|
22881
|
+
* Value of a draw color. Lighting and shadows darken it from here.
|
|
22882
|
+
*
|
|
22883
|
+
* @type {number}
|
|
22884
|
+
*/
|
|
22885
|
+
const DRAW_CALL_VALUE = 0.92;
|
|
21816
22886
|
|
|
21817
22887
|
/**
|
|
21818
|
-
*
|
|
21819
|
-
*
|
|
22888
|
+
* Writes a saturated color for this draw into `color`.
|
|
22889
|
+
* Hue walks the wheel by the golden ratio, so consecutive objects do not share a tint.
|
|
22890
|
+
* Instances of one mesh share the object id, so they share the color.
|
|
21820
22891
|
*
|
|
21821
|
-
* @
|
|
22892
|
+
* @param {Color} color - The uniform color, updated in place.
|
|
22893
|
+
* @param {Object3D} object - The drawn object.
|
|
22894
|
+
* @param {Material} material - The drawn material. A multi-material group is its own draw.
|
|
22895
|
+
* @return {Color} `color`.
|
|
21822
22896
|
*/
|
|
21823
|
-
|
|
22897
|
+
function writeDrawCallColor( color, object, material ) {
|
|
21824
22898
|
|
|
21825
|
-
|
|
22899
|
+
const hue = ( ( object.id + material.id * 64 ) * DRAW_CALL_HUE_STEP ) % 1;
|
|
22900
|
+
const s = DRAW_CALL_SATURATION;
|
|
22901
|
+
const v = DRAW_CALL_VALUE;
|
|
22902
|
+
const sector = hue * 6;
|
|
22903
|
+
const i = Math.floor( sector );
|
|
22904
|
+
const f = sector - i;
|
|
22905
|
+
const p = v * ( 1 - s );
|
|
22906
|
+
const q = v * ( 1 - f * s );
|
|
22907
|
+
const t = v * ( 1 - ( 1 - f ) * s );
|
|
21826
22908
|
|
|
21827
|
-
|
|
22909
|
+
switch ( i % 6 ) {
|
|
22910
|
+
|
|
22911
|
+
case 0: return color.setRGB( v, t, p );
|
|
22912
|
+
case 1: return color.setRGB( q, v, p );
|
|
22913
|
+
case 2: return color.setRGB( p, v, t );
|
|
22914
|
+
case 3: return color.setRGB( p, q, v );
|
|
22915
|
+
case 4: return color.setRGB( t, p, v );
|
|
22916
|
+
default: return color.setRGB( v, p, q );
|
|
21828
22917
|
|
|
21829
22918
|
}
|
|
21830
22919
|
|
|
21831
|
-
|
|
22920
|
+
}
|
|
21832
22921
|
|
|
21833
|
-
|
|
22922
|
+
/**
|
|
22923
|
+
* Replaces albedo with the draw color after the material has written its channels.
|
|
22924
|
+
* Lit materials become a matte dielectric in that color. Unlit materials become flat.
|
|
22925
|
+
* The color is an object uniform, so meshes that share a material still differ.
|
|
22926
|
+
*
|
|
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`.
|
|
22930
|
+
*/
|
|
22931
|
+
function applyDrawCallDebug( builder, material ) {
|
|
21834
22932
|
|
|
21835
|
-
}
|
|
22933
|
+
const colorNode = uniform( new Color() ).onObjectUpdate( ( { object, material: drawnMaterial }, self ) => {
|
|
21836
22934
|
|
|
21837
|
-
|
|
22935
|
+
if ( object === null || drawnMaterial === null ) return;
|
|
21838
22936
|
|
|
21839
|
-
|
|
21840
|
-
const safeBudget = ( typeof budget === 'number' && budget > 0 ) ? budget : 1;
|
|
21841
|
-
const ratio = builder.getShaderComplexityCost() / safeBudget;
|
|
22937
|
+
return writeDrawCallColor( self.value, object, drawnMaterial );
|
|
21842
22938
|
|
|
21843
|
-
|
|
22939
|
+
} );
|
|
21844
22940
|
|
|
21845
|
-
|
|
22941
|
+
diffuseColor.rgb.assign( colorNode );
|
|
21846
22942
|
|
|
21847
|
-
|
|
22943
|
+
if ( material.lights !== true ) return;
|
|
21848
22944
|
|
|
21849
|
-
|
|
21850
|
-
|
|
21851
|
-
|
|
21852
|
-
|
|
21853
|
-
|
|
21854
|
-
|
|
21855
|
-
function getShaderComplexityBase( material ) {
|
|
22945
|
+
metalness.assign( float( 0 ) );
|
|
22946
|
+
diffuseContribution.assign( colorNode );
|
|
22947
|
+
roughness.assign( float( 1 ) );
|
|
22948
|
+
specularColor.assign( vec3( 0 ) );
|
|
22949
|
+
specularColorBlended.assign( vec3( 0 ) );
|
|
22950
|
+
specularF90.assign( float( 0 ) );
|
|
21856
22951
|
|
|
21857
|
-
|
|
22952
|
+
// Ambient occlusion belonged to the original material.
|
|
22953
|
+
builder.context.ambientOcclusion = null;
|
|
21858
22954
|
|
|
21859
|
-
if ( material.useClearcoat === true )
|
|
22955
|
+
if ( material.useClearcoat === true ) clearcoat.assign( float( 0 ) );
|
|
21860
22956
|
|
|
21861
|
-
if ( material.useSheen === true )
|
|
22957
|
+
if ( material.useSheen === true ) sheen.assign( vec3( 0 ) );
|
|
21862
22958
|
|
|
21863
|
-
if ( material.useIridescence === true )
|
|
22959
|
+
if ( material.useIridescence === true ) iridescence.assign( float( 0 ) );
|
|
21864
22960
|
|
|
21865
|
-
if ( material.useAnisotropy === true )
|
|
22961
|
+
if ( material.useAnisotropy === true ) anisotropy.assign( float( 0 ) );
|
|
21866
22962
|
|
|
21867
|
-
if ( material.useTransmission === true )
|
|
22963
|
+
if ( material.useTransmission === true ) transmission.assign( float( 0 ) );
|
|
21868
22964
|
|
|
21869
|
-
|
|
22965
|
+
if ( material.useRetroreflection === true ) retroreflectivity.assign( float( 0 ) );
|
|
21870
22966
|
|
|
21871
22967
|
}
|
|
21872
22968
|
|
|
21873
22969
|
/**
|
|
21874
|
-
* Replaces the
|
|
21875
|
-
*
|
|
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.
|
|
21876
22973
|
*
|
|
21877
|
-
* @param {Node} resultNode - The material's
|
|
21878
|
-
* @
|
|
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.
|
|
21879
22977
|
*/
|
|
21880
|
-
function
|
|
22978
|
+
function replaceColorOutput( resultNode, createOutput ) {
|
|
21881
22979
|
|
|
21882
|
-
|
|
21883
|
-
// replace the color. A bypass of a value node emits a bare expression
|
|
21884
|
-
// statement, which WGSL rejects.
|
|
21885
|
-
const shaded = vec4( resultNode ).toVar();
|
|
22980
|
+
if ( resultNode.isMRTNode !== true ) return createOutput( resultNode );
|
|
21886
22981
|
|
|
21887
|
-
|
|
22982
|
+
if ( resultNode.has( 'output' ) !== true ) return resultNode;
|
|
21888
22983
|
|
|
21889
|
-
return
|
|
22984
|
+
return resultNode.merge( mrt( { output: createOutput( resultNode.get( 'output' ) ) } ) );
|
|
21890
22985
|
|
|
21891
22986
|
}
|
|
21892
|
-
|
|
21893
22987
|
// !WITH_GENESYS
|
|
21894
22988
|
|
|
21895
22989
|
/**
|
|
@@ -22390,10 +23484,33 @@ class NodeMaterial extends Material {
|
|
|
22390
23484
|
|
|
22391
23485
|
if ( this.fragmentNode === null ) {
|
|
22392
23486
|
|
|
23487
|
+
// WITH_GENESYS
|
|
23488
|
+
// Fallback for materials that never write the channel. Lit materials overwrite these.
|
|
23489
|
+
if ( renderer.debug.view === DEBUG_VIEW_BUFFER && this.isShadowPassMaterial !== true ) {
|
|
23490
|
+
|
|
23491
|
+
assignBufferDefaults( renderer.debug.buffer );
|
|
23492
|
+
|
|
23493
|
+
}
|
|
23494
|
+
// !WITH_GENESYS
|
|
23495
|
+
|
|
22393
23496
|
this.setupDiffuseColor( builder );
|
|
22394
23497
|
this.setupAmbientOcclusion( builder );
|
|
22395
23498
|
this.setupVariants( builder );
|
|
22396
23499
|
|
|
23500
|
+
// WITH_GENESYS
|
|
23501
|
+
// After the material writes its channels, so roughness and normals already exist
|
|
23502
|
+
// for detail lighting and can be replaced for lighting only.
|
|
23503
|
+
if ( ( renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || renderer.debug.view === DEBUG_VIEW_DETAIL_LIGHTING ) && this.isShadowPassMaterial !== true ) {
|
|
23504
|
+
|
|
23505
|
+
applyLightingDebug( builder, this, renderer.debug.view );
|
|
23506
|
+
|
|
23507
|
+
} else if ( renderer.debug.view === DEBUG_VIEW_DRAW_CALL && this.isShadowPassMaterial !== true ) {
|
|
23508
|
+
|
|
23509
|
+
applyDrawCallDebug( builder, this );
|
|
23510
|
+
|
|
23511
|
+
}
|
|
23512
|
+
// !WITH_GENESYS
|
|
23513
|
+
|
|
22397
23514
|
const outgoingLightNode = this.setupLighting( builder );
|
|
22398
23515
|
|
|
22399
23516
|
if ( clippingNode !== null ) builder.stack.addToStack( clippingNode );
|
|
@@ -22464,12 +23581,32 @@ class NodeMaterial extends Material {
|
|
|
22464
23581
|
}
|
|
22465
23582
|
|
|
22466
23583
|
// WITH_GENESYS
|
|
22467
|
-
// The screen output pass colorizes the accumulated ratio. Wrapping that pass
|
|
22468
|
-
//
|
|
22469
|
-
|
|
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 ) ) {
|
|
23588
|
+
|
|
23589
|
+
if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY ) {
|
|
23590
|
+
|
|
23591
|
+
builder.shaderComplexityBase = this.getShaderComplexity();
|
|
23592
|
+
resultNode = replaceColorOutput( resultNode, shaderComplexityOutput );
|
|
23593
|
+
|
|
23594
|
+
} else if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS ) {
|
|
23595
|
+
|
|
23596
|
+
builder.shaderComplexityBase = this.getShaderComplexity();
|
|
23597
|
+
resultNode = replaceColorOutput( resultNode, shaderComplexityAndQuadsOutput );
|
|
23598
|
+
|
|
23599
|
+
} else {
|
|
23600
|
+
|
|
23601
|
+
resultNode = replaceColorOutput( resultNode, quadOverdrawOutput );
|
|
23602
|
+
|
|
23603
|
+
}
|
|
22470
23604
|
|
|
22471
|
-
|
|
22472
|
-
|
|
23605
|
+
} else if ( renderer.debug.view === DEBUG_VIEW_BUFFER && this.isShadowPassMaterial !== true && this.fragmentNode === null ) {
|
|
23606
|
+
|
|
23607
|
+
// The fullscreen output pass sets fragmentNode. Scene materials do not, including
|
|
23608
|
+
// when the scene is drawn straight to the canvas.
|
|
23609
|
+
resultNode = replaceColorOutput( resultNode, () => bufferVisualizationOutput( renderer.debug.buffer ) );
|
|
22473
23610
|
|
|
22474
23611
|
}
|
|
22475
23612
|
// !WITH_GENESYS
|
|
@@ -22484,6 +23621,21 @@ class NodeMaterial extends Material {
|
|
|
22484
23621
|
|
|
22485
23622
|
}
|
|
22486
23623
|
|
|
23624
|
+
// WITH_GENESYS
|
|
23625
|
+
/**
|
|
23626
|
+
* Static shader-complexity proxy for this material's lighting model.
|
|
23627
|
+
* Fragment texture samples are counted later, while the shader is generated.
|
|
23628
|
+
* Derived materials override this instead of registering a type flag.
|
|
23629
|
+
*
|
|
23630
|
+
* @return {number} The base cost, excluding texture samples.
|
|
23631
|
+
*/
|
|
23632
|
+
getShaderComplexity() {
|
|
23633
|
+
|
|
23634
|
+
return this.lights === true ? 40 : 20;
|
|
23635
|
+
|
|
23636
|
+
}
|
|
23637
|
+
// !WITH_GENESYS
|
|
23638
|
+
|
|
22487
23639
|
/**
|
|
22488
23640
|
* Setups the clipping node.
|
|
22489
23641
|
*
|
|
@@ -22808,9 +23960,18 @@ class NodeMaterial extends Material {
|
|
|
22808
23960
|
/**
|
|
22809
23961
|
* Setups the normal node from the material.
|
|
22810
23962
|
*
|
|
23963
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
22811
23964
|
* @return {Node<vec3>} The normal node.
|
|
22812
23965
|
*/
|
|
22813
|
-
setupNormal() {
|
|
23966
|
+
setupNormal( builder ) {
|
|
23967
|
+
|
|
23968
|
+
// WITH_GENESYS
|
|
23969
|
+
if ( ( builder.renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || builder.renderer.debug.view === DEBUG_VIEW_DRAW_CALL ) && this.isShadowPassMaterial !== true && this.fragmentNode === null ) {
|
|
23970
|
+
|
|
23971
|
+
return lightingOnlyNormal();
|
|
23972
|
+
|
|
23973
|
+
}
|
|
23974
|
+
// !WITH_GENESYS
|
|
22814
23975
|
|
|
22815
23976
|
return this.normalNode ? vec3( this.normalNode ) : materialNormal;
|
|
22816
23977
|
|
|
@@ -23007,6 +24168,16 @@ class NodeMaterial extends Material {
|
|
|
23007
24168
|
|
|
23008
24169
|
if ( ( emissiveNode && emissiveNode.isNode === true ) || ( material.emissive && material.emissive.isColor === true ) ) {
|
|
23009
24170
|
|
|
24171
|
+
// WITH_GENESYS
|
|
24172
|
+
// Lighting only and draw call substitute a plain lit material, so emissive is dropped.
|
|
24173
|
+
// Detail lighting keeps it.
|
|
24174
|
+
if ( ( builder.renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || builder.renderer.debug.view === DEBUG_VIEW_DRAW_CALL ) && this.isShadowPassMaterial !== true ) {
|
|
24175
|
+
|
|
24176
|
+
return outgoingLightNode;
|
|
24177
|
+
|
|
24178
|
+
}
|
|
24179
|
+
// !WITH_GENESYS
|
|
24180
|
+
|
|
23010
24181
|
emissive.assign( vec3( emissiveNode ? emissiveNode : materialEmissive ) );
|
|
23011
24182
|
|
|
23012
24183
|
outgoingLightNode = outgoingLightNode.add( emissive );
|
|
@@ -24881,6 +26052,19 @@ class MeshBasicNodeMaterial extends NodeMaterial {
|
|
|
24881
26052
|
|
|
24882
26053
|
}
|
|
24883
26054
|
|
|
26055
|
+
// WITH_GENESYS
|
|
26056
|
+
/**
|
|
26057
|
+
* Shader-complexity proxy for {@link BasicLightingModel}.
|
|
26058
|
+
*
|
|
26059
|
+
* @return {number} The base cost, excluding texture samples.
|
|
26060
|
+
*/
|
|
26061
|
+
getShaderComplexity() {
|
|
26062
|
+
|
|
26063
|
+
return 80;
|
|
26064
|
+
|
|
26065
|
+
}
|
|
26066
|
+
// !WITH_GENESYS
|
|
26067
|
+
|
|
24884
26068
|
/**
|
|
24885
26069
|
* Setups the lighting model.
|
|
24886
26070
|
*
|
|
@@ -25064,6 +26248,19 @@ class MeshLambertNodeMaterial extends NodeMaterial {
|
|
|
25064
26248
|
|
|
25065
26249
|
}
|
|
25066
26250
|
|
|
26251
|
+
// WITH_GENESYS
|
|
26252
|
+
/**
|
|
26253
|
+
* Shader-complexity proxy for Lambert. Specular is forced off.
|
|
26254
|
+
*
|
|
26255
|
+
* @return {number} The base cost, excluding texture samples.
|
|
26256
|
+
*/
|
|
26257
|
+
getShaderComplexity() {
|
|
26258
|
+
|
|
26259
|
+
return 140;
|
|
26260
|
+
|
|
26261
|
+
}
|
|
26262
|
+
// !WITH_GENESYS
|
|
26263
|
+
|
|
25067
26264
|
/**
|
|
25068
26265
|
* Setups the lighting model.
|
|
25069
26266
|
*
|
|
@@ -25165,6 +26362,19 @@ class MeshPhongNodeMaterial extends NodeMaterial {
|
|
|
25165
26362
|
|
|
25166
26363
|
}
|
|
25167
26364
|
|
|
26365
|
+
// WITH_GENESYS
|
|
26366
|
+
/**
|
|
26367
|
+
* Shader-complexity proxy for Blinn-Phong.
|
|
26368
|
+
*
|
|
26369
|
+
* @return {number} The base cost, excluding texture samples.
|
|
26370
|
+
*/
|
|
26371
|
+
getShaderComplexity() {
|
|
26372
|
+
|
|
26373
|
+
return 200;
|
|
26374
|
+
|
|
26375
|
+
}
|
|
26376
|
+
// !WITH_GENESYS
|
|
26377
|
+
|
|
25168
26378
|
/**
|
|
25169
26379
|
* Setups the lighting model.
|
|
25170
26380
|
*
|
|
@@ -28653,6 +29863,19 @@ class MeshStandardNodeMaterial extends NodeMaterial {
|
|
|
28653
29863
|
|
|
28654
29864
|
}
|
|
28655
29865
|
|
|
29866
|
+
// WITH_GENESYS
|
|
29867
|
+
/**
|
|
29868
|
+
* Shader-complexity proxy for the Cook-Torrance GGX model.
|
|
29869
|
+
*
|
|
29870
|
+
* @return {number} The base cost, excluding texture samples.
|
|
29871
|
+
*/
|
|
29872
|
+
getShaderComplexity() {
|
|
29873
|
+
|
|
29874
|
+
return 240;
|
|
29875
|
+
|
|
29876
|
+
}
|
|
29877
|
+
// !WITH_GENESYS
|
|
29878
|
+
|
|
28656
29879
|
/**
|
|
28657
29880
|
* Setups the lighting model.
|
|
28658
29881
|
*
|
|
@@ -29082,6 +30305,31 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
29082
30305
|
|
|
29083
30306
|
}
|
|
29084
30307
|
|
|
30308
|
+
// WITH_GENESYS
|
|
30309
|
+
/**
|
|
30310
|
+
* GGX base from {@link MeshStandardNodeMaterial}, plus each enabled physical feature.
|
|
30311
|
+
*
|
|
30312
|
+
* @return {number} The base cost, excluding texture samples.
|
|
30313
|
+
*/
|
|
30314
|
+
getShaderComplexity() {
|
|
30315
|
+
|
|
30316
|
+
let cost = super.getShaderComplexity();
|
|
30317
|
+
|
|
30318
|
+
if ( this.useClearcoat === true ) cost += 30;
|
|
30319
|
+
|
|
30320
|
+
if ( this.useSheen === true ) cost += 30;
|
|
30321
|
+
|
|
30322
|
+
if ( this.useIridescence === true ) cost += 30;
|
|
30323
|
+
|
|
30324
|
+
if ( this.useAnisotropy === true ) cost += 30;
|
|
30325
|
+
|
|
30326
|
+
if ( this.useTransmission === true ) cost += 60;
|
|
30327
|
+
|
|
30328
|
+
return cost;
|
|
30329
|
+
|
|
30330
|
+
}
|
|
30331
|
+
// !WITH_GENESYS
|
|
30332
|
+
|
|
29085
30333
|
/**
|
|
29086
30334
|
* Setups the lighting model.
|
|
29087
30335
|
*
|
|
@@ -29366,6 +30614,21 @@ class MeshSSSNodeMaterial extends MeshPhysicalNodeMaterial {
|
|
|
29366
30614
|
|
|
29367
30615
|
}
|
|
29368
30616
|
|
|
30617
|
+
// WITH_GENESYS
|
|
30618
|
+
/**
|
|
30619
|
+
* Physical complexity, plus the subsurface term when it is evaluated.
|
|
30620
|
+
*
|
|
30621
|
+
* @return {number} The base cost, excluding texture samples.
|
|
30622
|
+
*/
|
|
30623
|
+
getShaderComplexity() {
|
|
30624
|
+
|
|
30625
|
+
const cost = super.getShaderComplexity();
|
|
30626
|
+
|
|
30627
|
+
return this.useSSS === true ? cost + 40 : cost;
|
|
30628
|
+
|
|
30629
|
+
}
|
|
30630
|
+
// !WITH_GENESYS
|
|
30631
|
+
|
|
29369
30632
|
/**
|
|
29370
30633
|
* Setups the lighting model.
|
|
29371
30634
|
*
|
|
@@ -29487,6 +30750,19 @@ class MeshToonNodeMaterial extends NodeMaterial {
|
|
|
29487
30750
|
|
|
29488
30751
|
}
|
|
29489
30752
|
|
|
30753
|
+
// WITH_GENESYS
|
|
30754
|
+
/**
|
|
30755
|
+
* Shader-complexity proxy for toon banding.
|
|
30756
|
+
*
|
|
30757
|
+
* @return {number} The base cost, excluding texture samples.
|
|
30758
|
+
*/
|
|
30759
|
+
getShaderComplexity() {
|
|
30760
|
+
|
|
30761
|
+
return 170;
|
|
30762
|
+
|
|
30763
|
+
}
|
|
30764
|
+
// !WITH_GENESYS
|
|
30765
|
+
|
|
29490
30766
|
/**
|
|
29491
30767
|
* Setups the lighting model.
|
|
29492
30768
|
*
|
|
@@ -29558,6 +30834,19 @@ class MeshMatcapNodeMaterial extends NodeMaterial {
|
|
|
29558
30834
|
|
|
29559
30835
|
}
|
|
29560
30836
|
|
|
30837
|
+
// WITH_GENESYS
|
|
30838
|
+
/**
|
|
30839
|
+
* Shader-complexity proxy for matcap UV shading.
|
|
30840
|
+
*
|
|
30841
|
+
* @return {number} The base cost, excluding texture samples.
|
|
30842
|
+
*/
|
|
30843
|
+
getShaderComplexity() {
|
|
30844
|
+
|
|
30845
|
+
return 50;
|
|
30846
|
+
|
|
30847
|
+
}
|
|
30848
|
+
// !WITH_GENESYS
|
|
30849
|
+
|
|
29561
30850
|
/**
|
|
29562
30851
|
* Setups the matcap specific node variables.
|
|
29563
30852
|
*
|
|
@@ -30233,6 +31522,19 @@ class ShadowNodeMaterial extends NodeMaterial {
|
|
|
30233
31522
|
|
|
30234
31523
|
}
|
|
30235
31524
|
|
|
31525
|
+
// WITH_GENESYS
|
|
31526
|
+
/**
|
|
31527
|
+
* Shader-complexity proxy for the shadow mask.
|
|
31528
|
+
*
|
|
31529
|
+
* @return {number} The base cost, excluding texture samples.
|
|
31530
|
+
*/
|
|
31531
|
+
getShaderComplexity() {
|
|
31532
|
+
|
|
31533
|
+
return 110;
|
|
31534
|
+
|
|
31535
|
+
}
|
|
31536
|
+
// !WITH_GENESYS
|
|
31537
|
+
|
|
30236
31538
|
/**
|
|
30237
31539
|
* Setups the lighting model.
|
|
30238
31540
|
*
|
|
@@ -30519,6 +31821,19 @@ class VolumeNodeMaterial extends NodeMaterial {
|
|
|
30519
31821
|
|
|
30520
31822
|
}
|
|
30521
31823
|
|
|
31824
|
+
// WITH_GENESYS
|
|
31825
|
+
/**
|
|
31826
|
+
* Shader-complexity proxy for volumetric ray integration.
|
|
31827
|
+
*
|
|
31828
|
+
* @return {number} The base cost, excluding texture samples.
|
|
31829
|
+
*/
|
|
31830
|
+
getShaderComplexity() {
|
|
31831
|
+
|
|
31832
|
+
return 280;
|
|
31833
|
+
|
|
31834
|
+
}
|
|
31835
|
+
// !WITH_GENESYS
|
|
31836
|
+
|
|
30522
31837
|
setupLightingModel() {
|
|
30523
31838
|
|
|
30524
31839
|
return new VolumetricLightingModel();
|
|
@@ -31767,7 +33082,7 @@ class RenderObject {
|
|
|
31767
33082
|
|
|
31768
33083
|
// WITH_GENESYS
|
|
31769
33084
|
// hash() xors each argument as a number, so a view name has to be hashed first.
|
|
31770
|
-
cacheKey = hash$1( cacheKey, hashString( this.renderer.debug.view ), this.renderer.debug.shaderComplexityBudget );
|
|
33085
|
+
cacheKey = hash$1( cacheKey, hashString( this.renderer.debug.view ), hashString( this.renderer.debug.buffer ), this.renderer.debug.shaderComplexityBudget, this.renderer.debug.quadOverdrawBudget );
|
|
31771
33086
|
// !WITH_GENESYS
|
|
31772
33087
|
|
|
31773
33088
|
return cacheKey;
|
|
@@ -36202,89 +37517,6 @@ class Textures extends DataMap {
|
|
|
36202
37517
|
|
|
36203
37518
|
}
|
|
36204
37519
|
|
|
36205
|
-
/**
|
|
36206
|
-
* A four-component version of {@link Color} which is internally
|
|
36207
|
-
* used by the renderer to represents clear color with alpha as
|
|
36208
|
-
* one object.
|
|
36209
|
-
*
|
|
36210
|
-
* @private
|
|
36211
|
-
* @augments Color
|
|
36212
|
-
*/
|
|
36213
|
-
class Color4 extends Color {
|
|
36214
|
-
|
|
36215
|
-
/**
|
|
36216
|
-
* Constructs a new four-component color.
|
|
36217
|
-
* You can also pass a single THREE.Color, hex or
|
|
36218
|
-
* string argument to this constructor.
|
|
36219
|
-
*
|
|
36220
|
-
* @param {number|string} [r=1] - The red value.
|
|
36221
|
-
* @param {number} [g=1] - The green value.
|
|
36222
|
-
* @param {number} [b=1] - The blue value.
|
|
36223
|
-
* @param {number} [a=1] - The alpha value.
|
|
36224
|
-
*/
|
|
36225
|
-
constructor( r, g, b, a = 1 ) {
|
|
36226
|
-
|
|
36227
|
-
super( r, g, b );
|
|
36228
|
-
|
|
36229
|
-
this.a = a;
|
|
36230
|
-
|
|
36231
|
-
}
|
|
36232
|
-
|
|
36233
|
-
/**
|
|
36234
|
-
* Overwrites the default to honor alpha.
|
|
36235
|
-
* You can also pass a single THREE.Color, hex or
|
|
36236
|
-
* string argument to this method.
|
|
36237
|
-
*
|
|
36238
|
-
* @param {number|string|Color} r - The red value.
|
|
36239
|
-
* @param {number} [g] - The green value.
|
|
36240
|
-
* @param {number} [b] - The blue value.
|
|
36241
|
-
* @param {number} [a=1] - The alpha value.
|
|
36242
|
-
* @return {Color4} A reference to this object.
|
|
36243
|
-
*/
|
|
36244
|
-
set( r, g, b, a = 1 ) {
|
|
36245
|
-
|
|
36246
|
-
this.a = a;
|
|
36247
|
-
|
|
36248
|
-
return super.set( r, g, b );
|
|
36249
|
-
|
|
36250
|
-
}
|
|
36251
|
-
|
|
36252
|
-
/**
|
|
36253
|
-
* Overwrites the default to honor alpha.
|
|
36254
|
-
*
|
|
36255
|
-
* @param {Color4} color - The color to copy.
|
|
36256
|
-
* @return {Color4} A reference to this object.
|
|
36257
|
-
*/
|
|
36258
|
-
copy( color ) {
|
|
36259
|
-
|
|
36260
|
-
if ( color.a !== undefined ) this.a = color.a;
|
|
36261
|
-
|
|
36262
|
-
return super.copy( color );
|
|
36263
|
-
|
|
36264
|
-
}
|
|
36265
|
-
|
|
36266
|
-
/**
|
|
36267
|
-
* Overwrites the default to honor alpha.
|
|
36268
|
-
*
|
|
36269
|
-
* @return {Color4} The cloned color.
|
|
36270
|
-
*/
|
|
36271
|
-
clone() {
|
|
36272
|
-
|
|
36273
|
-
return new this.constructor( this.r, this.g, this.b, this.a );
|
|
36274
|
-
|
|
36275
|
-
}
|
|
36276
|
-
|
|
36277
|
-
*[ Symbol.iterator ]() {
|
|
36278
|
-
|
|
36279
|
-
yield this.r;
|
|
36280
|
-
yield this.g;
|
|
36281
|
-
yield this.b;
|
|
36282
|
-
yield this.a;
|
|
36283
|
-
|
|
36284
|
-
}
|
|
36285
|
-
|
|
36286
|
-
}
|
|
36287
|
-
|
|
36288
37520
|
/**
|
|
36289
37521
|
* A specialized context node designed to override specific target nodes within a
|
|
36290
37522
|
* node sub-graph or flow. This allows replacing specific inputs (e.g., normal
|
|
@@ -37233,483 +38465,6 @@ const struct = ( membersLayout, name = null ) => {
|
|
|
37233
38465
|
|
|
37234
38466
|
};
|
|
37235
38467
|
|
|
37236
|
-
/**
|
|
37237
|
-
* This node can be used to define multiple outputs in a shader programs.
|
|
37238
|
-
*
|
|
37239
|
-
* @augments Node
|
|
37240
|
-
*/
|
|
37241
|
-
class OutputStructNode extends Node {
|
|
37242
|
-
|
|
37243
|
-
static get type() {
|
|
37244
|
-
|
|
37245
|
-
return 'OutputStructNode';
|
|
37246
|
-
|
|
37247
|
-
}
|
|
37248
|
-
|
|
37249
|
-
/**
|
|
37250
|
-
* Constructs a new output struct node. The constructor can be invoked with an
|
|
37251
|
-
* arbitrary number of nodes representing the members.
|
|
37252
|
-
*
|
|
37253
|
-
* @param {...Node} members - A parameter list of nodes.
|
|
37254
|
-
*/
|
|
37255
|
-
constructor( ...members ) {
|
|
37256
|
-
|
|
37257
|
-
super();
|
|
37258
|
-
|
|
37259
|
-
/**
|
|
37260
|
-
* An array of nodes which defines the output.
|
|
37261
|
-
*
|
|
37262
|
-
* @type {Array<Node>}
|
|
37263
|
-
*/
|
|
37264
|
-
this.members = members;
|
|
37265
|
-
|
|
37266
|
-
/**
|
|
37267
|
-
* This flag can be used for type testing.
|
|
37268
|
-
*
|
|
37269
|
-
* @type {boolean}
|
|
37270
|
-
* @readonly
|
|
37271
|
-
* @default true
|
|
37272
|
-
*/
|
|
37273
|
-
this.isOutputStructNode = true;
|
|
37274
|
-
|
|
37275
|
-
}
|
|
37276
|
-
|
|
37277
|
-
generateNodeType( /*builder*/ ) {
|
|
37278
|
-
|
|
37279
|
-
return 'OutputType';
|
|
37280
|
-
|
|
37281
|
-
}
|
|
37282
|
-
|
|
37283
|
-
generate( builder ) {
|
|
37284
|
-
|
|
37285
|
-
const nodeData = builder.getDataFromNode( this );
|
|
37286
|
-
|
|
37287
|
-
if ( nodeData.membersLayout === undefined ) {
|
|
37288
|
-
|
|
37289
|
-
const members = this.members;
|
|
37290
|
-
const membersLayout = [];
|
|
37291
|
-
|
|
37292
|
-
for ( let i = 0; i < members.length; i ++ ) {
|
|
37293
|
-
|
|
37294
|
-
const name = 'm' + i;
|
|
37295
|
-
const type = members[ i ].getNodeType( builder );
|
|
37296
|
-
|
|
37297
|
-
membersLayout.push( { name, type, index: i } );
|
|
37298
|
-
|
|
37299
|
-
}
|
|
37300
|
-
|
|
37301
|
-
nodeData.membersLayout = membersLayout;
|
|
37302
|
-
nodeData.structType = builder.getOutputStructTypeFromNode( this, nodeData.membersLayout );
|
|
37303
|
-
|
|
37304
|
-
}
|
|
37305
|
-
|
|
37306
|
-
//
|
|
37307
|
-
|
|
37308
|
-
const propertyName = builder.getOutputStructName();
|
|
37309
|
-
const members = this.members;
|
|
37310
|
-
|
|
37311
|
-
const structPrefix = propertyName !== '' ? propertyName + '.' : '';
|
|
37312
|
-
|
|
37313
|
-
for ( let i = 0; i < members.length; i ++ ) {
|
|
37314
|
-
|
|
37315
|
-
const snippet = members[ i ].build( builder, nodeData.membersLayout[ i ].type );
|
|
37316
|
-
|
|
37317
|
-
builder.addLineFlowCode( `${ structPrefix }m${ i } = ${ snippet }`, this );
|
|
37318
|
-
|
|
37319
|
-
}
|
|
37320
|
-
|
|
37321
|
-
return propertyName;
|
|
37322
|
-
|
|
37323
|
-
}
|
|
37324
|
-
|
|
37325
|
-
}
|
|
37326
|
-
|
|
37327
|
-
/**
|
|
37328
|
-
* TSL function for creating an output struct node.
|
|
37329
|
-
*
|
|
37330
|
-
* @tsl
|
|
37331
|
-
* @function
|
|
37332
|
-
* @param {...Node} members - A parameter list of nodes.
|
|
37333
|
-
* @returns {OutputStructNode}
|
|
37334
|
-
*/
|
|
37335
|
-
const outputStruct = /*@__PURE__*/ nodeProxy( OutputStructNode );
|
|
37336
|
-
|
|
37337
|
-
/**
|
|
37338
|
-
* Represents blending configuration.
|
|
37339
|
-
*
|
|
37340
|
-
* This class encapsulates all blending-related properties that control how
|
|
37341
|
-
* a material's colors are combined with the colors already in the frame buffer.
|
|
37342
|
-
*/
|
|
37343
|
-
class BlendMode {
|
|
37344
|
-
|
|
37345
|
-
/**
|
|
37346
|
-
* Constructs a new blending configuration.
|
|
37347
|
-
*
|
|
37348
|
-
* @param {(NoBlending|NormalBlending|AdditiveBlending|SubtractiveBlending|MultiplyBlending|CustomBlending|MaterialBlending)} [blending=NormalBlending] - The blending mode.
|
|
37349
|
-
*/
|
|
37350
|
-
constructor( blending = NormalBlending ) {
|
|
37351
|
-
|
|
37352
|
-
/**
|
|
37353
|
-
* Defines the blending type.
|
|
37354
|
-
*
|
|
37355
|
-
* It must be set to `CustomBlending` if custom blending properties like
|
|
37356
|
-
* {@link BlendMode#blendSrc}, {@link BlendMode#blendDst} or {@link BlendMode#blendEquation}
|
|
37357
|
-
* should have any effect.
|
|
37358
|
-
*
|
|
37359
|
-
* @type {(NoBlending|NormalBlending|AdditiveBlending|SubtractiveBlending|MultiplyBlending|CustomBlending|MaterialBlending)}
|
|
37360
|
-
* @default NormalBlending
|
|
37361
|
-
*/
|
|
37362
|
-
this.blending = blending;
|
|
37363
|
-
|
|
37364
|
-
/**
|
|
37365
|
-
* Defines the blending source factor.
|
|
37366
|
-
*
|
|
37367
|
-
* This determines how the source (incoming) fragment color is factored before being added
|
|
37368
|
-
* to the destination (existing) fragment color in the frame buffer.
|
|
37369
|
-
*
|
|
37370
|
-
* @type {(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
|
|
37371
|
-
* @default SrcAlphaFactor
|
|
37372
|
-
*/
|
|
37373
|
-
this.blendSrc = SrcAlphaFactor;
|
|
37374
|
-
|
|
37375
|
-
/**
|
|
37376
|
-
* Defines the blending destination factor.
|
|
37377
|
-
*
|
|
37378
|
-
* This determines how the destination (existing) fragment color in the frame buffer
|
|
37379
|
-
* is factored before being combined with the source (incoming) fragment color.
|
|
37380
|
-
*
|
|
37381
|
-
* @type {(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
|
|
37382
|
-
* @default OneMinusSrcAlphaFactor
|
|
37383
|
-
*/
|
|
37384
|
-
this.blendDst = OneMinusSrcAlphaFactor;
|
|
37385
|
-
|
|
37386
|
-
/**
|
|
37387
|
-
* Defines the blending equation.
|
|
37388
|
-
*
|
|
37389
|
-
* This determines how the source and destination colors are combined.
|
|
37390
|
-
*
|
|
37391
|
-
* @type {(AddEquation|SubtractEquation|ReverseSubtractEquation|MinEquation|MaxEquation)}
|
|
37392
|
-
* @default AddEquation
|
|
37393
|
-
*/
|
|
37394
|
-
this.blendEquation = AddEquation;
|
|
37395
|
-
|
|
37396
|
-
/**
|
|
37397
|
-
* Defines the blending source alpha factor.
|
|
37398
|
-
*
|
|
37399
|
-
* When set, this allows separate control of the alpha channel's source blending factor.
|
|
37400
|
-
* If `null`, {@link BlendMode#blendSrc} is used for the alpha channel as well.
|
|
37401
|
-
*
|
|
37402
|
-
* @type {?(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
|
|
37403
|
-
* @default null
|
|
37404
|
-
*/
|
|
37405
|
-
this.blendSrcAlpha = null;
|
|
37406
|
-
|
|
37407
|
-
/**
|
|
37408
|
-
* Defines the blending destination alpha factor.
|
|
37409
|
-
*
|
|
37410
|
-
* When set, this allows separate control of the alpha channel's destination blending factor.
|
|
37411
|
-
* If `null`, {@link BlendMode#blendDst} is used for the alpha channel as well.
|
|
37412
|
-
*
|
|
37413
|
-
* @type {?(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
|
|
37414
|
-
* @default null
|
|
37415
|
-
*/
|
|
37416
|
-
this.blendDstAlpha = null;
|
|
37417
|
-
|
|
37418
|
-
/**
|
|
37419
|
-
* Defines the blending equation of the alpha channel.
|
|
37420
|
-
*
|
|
37421
|
-
* When set, this allows separate control of the alpha channel's blending equation.
|
|
37422
|
-
* If `null`, {@link BlendMode#blendEquation} is used for the alpha channel as well.
|
|
37423
|
-
*
|
|
37424
|
-
* @type {?(AddEquation|SubtractEquation|ReverseSubtractEquation|MinEquation|MaxEquation)}
|
|
37425
|
-
* @default null
|
|
37426
|
-
*/
|
|
37427
|
-
this.blendEquationAlpha = null;
|
|
37428
|
-
|
|
37429
|
-
/**
|
|
37430
|
-
* Defines whether to premultiply the alpha (transparency) value.
|
|
37431
|
-
*
|
|
37432
|
-
* If `true`, the RGB color of the texture or material is multiplied by its alpha value.
|
|
37433
|
-
* This is useful for transparent textures/materials where the color data
|
|
37434
|
-
* should already include the transparency information.
|
|
37435
|
-
*
|
|
37436
|
-
* @type {boolean}
|
|
37437
|
-
* @default false
|
|
37438
|
-
*/
|
|
37439
|
-
this.premultiplyAlpha = false;
|
|
37440
|
-
|
|
37441
|
-
}
|
|
37442
|
-
|
|
37443
|
-
/**
|
|
37444
|
-
* Copies the blending properties from the given source to this instance.
|
|
37445
|
-
*
|
|
37446
|
-
* @param {BlendMode} source - The blending configuration to copy from.
|
|
37447
|
-
* @return {BlendMode} A reference to this instance.
|
|
37448
|
-
*/
|
|
37449
|
-
copy( source ) {
|
|
37450
|
-
|
|
37451
|
-
this.blending = source.blending;
|
|
37452
|
-
this.blendSrc = source.blendSrc;
|
|
37453
|
-
this.blendDst = source.blendDst;
|
|
37454
|
-
this.blendEquation = source.blendEquation;
|
|
37455
|
-
this.blendSrcAlpha = source.blendSrcAlpha;
|
|
37456
|
-
this.blendDstAlpha = source.blendDstAlpha;
|
|
37457
|
-
this.blendEquationAlpha = source.blendEquationAlpha;
|
|
37458
|
-
this.premultiplyAlpha = source.premultiplyAlpha;
|
|
37459
|
-
|
|
37460
|
-
return this;
|
|
37461
|
-
|
|
37462
|
-
}
|
|
37463
|
-
|
|
37464
|
-
/**
|
|
37465
|
-
* Returns a clone of this blending configuration.
|
|
37466
|
-
*
|
|
37467
|
-
* @return {BlendMode} A new Blending instance with the same properties.
|
|
37468
|
-
*/
|
|
37469
|
-
clone() {
|
|
37470
|
-
|
|
37471
|
-
return new this.constructor().copy( this );
|
|
37472
|
-
|
|
37473
|
-
}
|
|
37474
|
-
|
|
37475
|
-
}
|
|
37476
|
-
|
|
37477
|
-
// Predefined blend modes for MRT nodes.
|
|
37478
|
-
const _noBlending = /**@__PURE__*/ new BlendMode( NoBlending );
|
|
37479
|
-
const _materialBlending = /**@__PURE__*/ new BlendMode( MaterialBlending );
|
|
37480
|
-
|
|
37481
|
-
/**
|
|
37482
|
-
* Returns the MRT texture index for the given name.
|
|
37483
|
-
*
|
|
37484
|
-
* @param {Array<Texture>} textures - The textures of a MRT-configured render target.
|
|
37485
|
-
* @param {string} name - The name of the MRT texture which index is requested.
|
|
37486
|
-
* @return {number} The texture index.
|
|
37487
|
-
*/
|
|
37488
|
-
function getTextureIndex( textures, name ) {
|
|
37489
|
-
|
|
37490
|
-
for ( let i = 0; i < textures.length; i ++ ) {
|
|
37491
|
-
|
|
37492
|
-
if ( textures[ i ].name === name ) {
|
|
37493
|
-
|
|
37494
|
-
return i;
|
|
37495
|
-
|
|
37496
|
-
}
|
|
37497
|
-
|
|
37498
|
-
}
|
|
37499
|
-
|
|
37500
|
-
return -1;
|
|
37501
|
-
|
|
37502
|
-
}
|
|
37503
|
-
|
|
37504
|
-
/**
|
|
37505
|
-
* This node can be used setup a MRT context for rendering. A typical MRT setup for
|
|
37506
|
-
* post-processing is shown below:
|
|
37507
|
-
* ```js
|
|
37508
|
-
* const mrtNode = mrt( {
|
|
37509
|
-
* output: output,
|
|
37510
|
-
* normal: normalView
|
|
37511
|
-
* } ) ;
|
|
37512
|
-
* ```
|
|
37513
|
-
* The MRT output is defined as a dictionary.
|
|
37514
|
-
*
|
|
37515
|
-
* @augments OutputStructNode
|
|
37516
|
-
*/
|
|
37517
|
-
class MRTNode extends OutputStructNode {
|
|
37518
|
-
|
|
37519
|
-
static get type() {
|
|
37520
|
-
|
|
37521
|
-
return 'MRTNode';
|
|
37522
|
-
|
|
37523
|
-
}
|
|
37524
|
-
|
|
37525
|
-
/**
|
|
37526
|
-
* Constructs a new output struct node.
|
|
37527
|
-
*
|
|
37528
|
-
* @param {Object<string, Node>} outputNodes - The MRT outputs.
|
|
37529
|
-
*/
|
|
37530
|
-
constructor( outputNodes ) {
|
|
37531
|
-
|
|
37532
|
-
super();
|
|
37533
|
-
|
|
37534
|
-
/**
|
|
37535
|
-
* A dictionary representing the MRT outputs. The key
|
|
37536
|
-
* is the name of the output, the value the node which produces
|
|
37537
|
-
* the output result.
|
|
37538
|
-
*
|
|
37539
|
-
* @type {Object<string, Node>}
|
|
37540
|
-
*/
|
|
37541
|
-
this.outputNodes = outputNodes;
|
|
37542
|
-
|
|
37543
|
-
/**
|
|
37544
|
-
* A dictionary storing the blend modes for each output.
|
|
37545
|
-
*
|
|
37546
|
-
* @type {Object<string, BlendMode>}
|
|
37547
|
-
*/
|
|
37548
|
-
this.blendModes = {
|
|
37549
|
-
output: _materialBlending
|
|
37550
|
-
};
|
|
37551
|
-
|
|
37552
|
-
/**
|
|
37553
|
-
* A dictionary storing the clear colors for each output.
|
|
37554
|
-
*
|
|
37555
|
-
* @type {Object<string, Color4>}
|
|
37556
|
-
*/
|
|
37557
|
-
this.clearColors = {};
|
|
37558
|
-
|
|
37559
|
-
/**
|
|
37560
|
-
* This flag can be used for type testing.
|
|
37561
|
-
*
|
|
37562
|
-
* @type {boolean}
|
|
37563
|
-
* @readonly
|
|
37564
|
-
* @default true
|
|
37565
|
-
*/
|
|
37566
|
-
this.isMRTNode = true;
|
|
37567
|
-
|
|
37568
|
-
}
|
|
37569
|
-
|
|
37570
|
-
/**
|
|
37571
|
-
* Sets the blend mode for the given output name.
|
|
37572
|
-
*
|
|
37573
|
-
* @param {string} name - The name of the output.
|
|
37574
|
-
* @param {BlendMode} blend - The blending mode.
|
|
37575
|
-
* @return {MRTNode} The current MRT node.
|
|
37576
|
-
*/
|
|
37577
|
-
setBlendMode( name, blend ) {
|
|
37578
|
-
|
|
37579
|
-
this.blendModes[ name ] = blend;
|
|
37580
|
-
|
|
37581
|
-
return this;
|
|
37582
|
-
|
|
37583
|
-
}
|
|
37584
|
-
|
|
37585
|
-
/**
|
|
37586
|
-
* Returns the blend mode for the given output name.
|
|
37587
|
-
*
|
|
37588
|
-
* @param {string} name - The name of the output.
|
|
37589
|
-
* @return {BlendMode} The blend mode.
|
|
37590
|
-
*/
|
|
37591
|
-
getBlendMode( name ) {
|
|
37592
|
-
|
|
37593
|
-
return this.blendModes[ name ] || _noBlending;
|
|
37594
|
-
|
|
37595
|
-
}
|
|
37596
|
-
|
|
37597
|
-
/**
|
|
37598
|
-
* Sets the clear color for the given output name.
|
|
37599
|
-
*
|
|
37600
|
-
* @param {string} name - The name of the output.
|
|
37601
|
-
* @param {number|string|Color} color - The clear color.
|
|
37602
|
-
* @param {number} [alpha=1] - The clear alpha.
|
|
37603
|
-
* @return {MRTNode} The current MRT node.
|
|
37604
|
-
*/
|
|
37605
|
-
setClearColor( name, color, alpha = 1 ) {
|
|
37606
|
-
|
|
37607
|
-
const clearColor = this.clearColors[ name ] || ( this.clearColors[ name ] = new Color4() );
|
|
37608
|
-
|
|
37609
|
-
clearColor.set( color );
|
|
37610
|
-
clearColor.a = alpha;
|
|
37611
|
-
|
|
37612
|
-
return this;
|
|
37613
|
-
|
|
37614
|
-
}
|
|
37615
|
-
|
|
37616
|
-
/**
|
|
37617
|
-
* Returns the clear color for the given output name.
|
|
37618
|
-
*
|
|
37619
|
-
* @param {string} name - The name of the output.
|
|
37620
|
-
* @return {?Color4} The clear color. Returns `null` if no clear color is defined
|
|
37621
|
-
* which means the renderer's default clear policy is applied.
|
|
37622
|
-
*/
|
|
37623
|
-
getClearColor( name ) {
|
|
37624
|
-
|
|
37625
|
-
return this.clearColors[ name ] || null;
|
|
37626
|
-
|
|
37627
|
-
}
|
|
37628
|
-
|
|
37629
|
-
/**
|
|
37630
|
-
* Returns `true` if the MRT node has an output with the given name.
|
|
37631
|
-
*
|
|
37632
|
-
* @param {string} name - The name of the output.
|
|
37633
|
-
* @return {NodeBuilder} Whether the MRT node has an output for the given name or not.
|
|
37634
|
-
*/
|
|
37635
|
-
has( name ) {
|
|
37636
|
-
|
|
37637
|
-
return this.outputNodes[ name ] !== undefined;
|
|
37638
|
-
|
|
37639
|
-
}
|
|
37640
|
-
|
|
37641
|
-
/**
|
|
37642
|
-
* Returns the output node for the given name.
|
|
37643
|
-
*
|
|
37644
|
-
* @param {string} name - The name of the output.
|
|
37645
|
-
* @return {Node} The output node.
|
|
37646
|
-
*/
|
|
37647
|
-
get( name ) {
|
|
37648
|
-
|
|
37649
|
-
return this.outputNodes[ name ];
|
|
37650
|
-
|
|
37651
|
-
}
|
|
37652
|
-
|
|
37653
|
-
/**
|
|
37654
|
-
* Merges the outputs of the given MRT node with the outputs of this node.
|
|
37655
|
-
*
|
|
37656
|
-
* @param {MRTNode} mrtNode - The MRT to merge.
|
|
37657
|
-
* @return {MRTNode} A new MRT node with merged outputs..
|
|
37658
|
-
*/
|
|
37659
|
-
merge( mrtNode ) {
|
|
37660
|
-
|
|
37661
|
-
const outputs = { ...this.outputNodes, ...mrtNode.outputNodes };
|
|
37662
|
-
const blendModes = { ...this.blendModes, ...mrtNode.blendModes };
|
|
37663
|
-
const clearColors = { ...this.clearColors, ...mrtNode.clearColors };
|
|
37664
|
-
|
|
37665
|
-
const mrtTarget = mrt( outputs );
|
|
37666
|
-
mrtTarget.blendModes = blendModes;
|
|
37667
|
-
mrtTarget.clearColors = clearColors;
|
|
37668
|
-
|
|
37669
|
-
return mrtTarget;
|
|
37670
|
-
|
|
37671
|
-
}
|
|
37672
|
-
|
|
37673
|
-
setup( builder ) {
|
|
37674
|
-
|
|
37675
|
-
const outputNodes = this.outputNodes;
|
|
37676
|
-
const mrt = builder.renderer.getRenderTarget();
|
|
37677
|
-
|
|
37678
|
-
const members = [];
|
|
37679
|
-
|
|
37680
|
-
const textures = mrt.textures;
|
|
37681
|
-
|
|
37682
|
-
for ( const name in outputNodes ) {
|
|
37683
|
-
|
|
37684
|
-
const index = getTextureIndex( textures, name );
|
|
37685
|
-
|
|
37686
|
-
// Ignore if the output exists in the MRT but has never been used.
|
|
37687
|
-
if ( index === -1 ) continue;
|
|
37688
|
-
|
|
37689
|
-
const type = builder.getOutputType( index );
|
|
37690
|
-
|
|
37691
|
-
members[ index ] = outputNodes[ name ].convert( type );
|
|
37692
|
-
|
|
37693
|
-
}
|
|
37694
|
-
|
|
37695
|
-
this.members = members;
|
|
37696
|
-
|
|
37697
|
-
return super.setup( builder );
|
|
37698
|
-
|
|
37699
|
-
}
|
|
37700
|
-
|
|
37701
|
-
}
|
|
37702
|
-
|
|
37703
|
-
/**
|
|
37704
|
-
* TSL function for creating a MRT node.
|
|
37705
|
-
*
|
|
37706
|
-
* @tsl
|
|
37707
|
-
* @function
|
|
37708
|
-
* @param {Object<string, Node>} outputNodes - The MRT outputs.
|
|
37709
|
-
* @returns {MRTNode}
|
|
37710
|
-
*/
|
|
37711
|
-
const mrt = /*@__PURE__*/ nodeProxy( MRTNode );
|
|
37712
|
-
|
|
37713
38468
|
/**
|
|
37714
38469
|
* This node represents an operation that reinterprets the bit representation of a value
|
|
37715
38470
|
* in one type as a value in another type.
|
|
@@ -52221,6 +52976,8 @@ var TSL = /*#__PURE__*/Object.freeze({
|
|
|
52221
52976
|
xor: xor
|
|
52222
52977
|
});
|
|
52223
52978
|
|
|
52979
|
+
// !WITH_GENESYS
|
|
52980
|
+
|
|
52224
52981
|
const _clearColor = /*@__PURE__*/ new Color4();
|
|
52225
52982
|
|
|
52226
52983
|
/**
|
|
@@ -52406,7 +53163,7 @@ class Background extends DataMap {
|
|
|
52406
53163
|
|
|
52407
53164
|
// WITH_GENESYS
|
|
52408
53165
|
// The background is depth-tested off, so additive shader complexity would add it to every pixel.
|
|
52409
|
-
if ( renderer.debug.view !==
|
|
53166
|
+
if ( debugViewAccumulates( renderer.debug.view ) !== true ) {
|
|
52410
53167
|
|
|
52411
53168
|
renderList.unshift( backgroundMesh, backgroundMesh.geometry, backgroundMesh.material, 0, 0, null, null );
|
|
52412
53169
|
|
|
@@ -52437,7 +53194,7 @@ class Background extends DataMap {
|
|
|
52437
53194
|
//
|
|
52438
53195
|
|
|
52439
53196
|
// WITH_GENESYS
|
|
52440
|
-
if ( renderer.debug.view
|
|
53197
|
+
if ( debugViewAccumulates( renderer.debug.view ) ) {
|
|
52441
53198
|
|
|
52442
53199
|
_clearColor.set( 0, 0, 0, 1 );
|
|
52443
53200
|
|
|
@@ -59727,9 +60484,19 @@ class NodeManager extends DataMap {
|
|
|
59727
60484
|
}
|
|
59728
60485
|
|
|
59729
60486
|
// WITH_GENESYS
|
|
59730
|
-
if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY ) {
|
|
60487
|
+
if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY || renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS ) {
|
|
60488
|
+
|
|
60489
|
+
const complexity = renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS
|
|
60490
|
+
? sampled.r.mul( sampled.g ).mul( SHADER_COMPLEXITY_QUAD_COUNT_SCALE )
|
|
60491
|
+
: sampled.r;
|
|
59731
60492
|
|
|
59732
|
-
return vec4( colorizeShaderComplexity(
|
|
60493
|
+
return vec4( colorizeShaderComplexity( complexity ), 1 ).renderOutput( NoToneMapping, renderer.currentColorSpace );
|
|
60494
|
+
|
|
60495
|
+
}
|
|
60496
|
+
|
|
60497
|
+
if ( renderer.debug.view === DEBUG_VIEW_QUAD_OVERDRAW ) {
|
|
60498
|
+
|
|
60499
|
+
return vec4( colorizeQuadOverdraw( sampled.r ), 1 ).renderOutput( NoToneMapping, renderer.currentColorSpace );
|
|
59733
60500
|
|
|
59734
60501
|
}
|
|
59735
60502
|
// !WITH_GENESYS
|
|
@@ -63692,8 +64459,10 @@ class Renderer {
|
|
|
63692
64459
|
* @property {?Function} onNodeBuilderCreated - A callback function that is executed after a node builder has been created and before it is built.
|
|
63693
64460
|
* @property {?Function} onShaderError - A callback function that is executed when a shader error happens. Only supported with WebGL 2 right now.
|
|
63694
64461
|
* @property {Function} getShaderAsync - Allows the get the raw shader code for the given scene, camera and 3D object.
|
|
63695
|
-
* @property {string} view - Debug view. `shaderComplexity` and `
|
|
64462
|
+
* @property {string} view - Debug view. `shaderComplexity`, `lightingComplexity`, `quadOverdraw`, and `shaderComplexityAndQuads` replace the shaded color with a heatmap. `shaderComplexityAndQuads` multiplies the shader cost by the overdraw count. `bufferVisualization` shows one material channel. `lightingOnly` and `detailLighting` light a flat gray surface. `drawCall` lights each submitted draw with its own diffuse color.
|
|
64463
|
+
* @property {string} buffer - Channel drawn by `bufferVisualization`: `baseColor`, `worldNormal`, `roughness`, `metallic`, `ambientOcclusion`, or `emissive`.
|
|
63696
64464
|
* @property {number} shaderComplexityBudget - Proxy budget that fills the shader-complexity ramp.
|
|
64465
|
+
* @property {number} quadOverdrawBudget - Overlapping fragments that fill the quad-overdraw ramp.
|
|
63697
64466
|
*/
|
|
63698
64467
|
|
|
63699
64468
|
/**
|
|
@@ -63710,7 +64479,9 @@ class Renderer {
|
|
|
63710
64479
|
onShaderError: null,
|
|
63711
64480
|
// WITH_GENESYS
|
|
63712
64481
|
view: DEBUG_VIEW_NONE,
|
|
64482
|
+
buffer: DEFAULT_BUFFER,
|
|
63713
64483
|
shaderComplexityBudget: DEFAULT_SHADER_COMPLEXITY_BUDGET,
|
|
64484
|
+
quadOverdrawBudget: DEFAULT_QUAD_OVERDRAW_BUDGET,
|
|
63714
64485
|
// !WITH_GENESYS
|
|
63715
64486
|
getShaderAsync: async ( scene, camera, object ) => {
|
|
63716
64487
|
|
|
@@ -65647,10 +66418,9 @@ class Renderer {
|
|
|
65647
66418
|
const useColorSpace = this.currentColorSpace !== ColorManagement.workingColorSpace;
|
|
65648
66419
|
|
|
65649
66420
|
// WITH_GENESYS
|
|
65650
|
-
//
|
|
65651
|
-
|
|
65652
|
-
|
|
65653
|
-
return useToneMapping || useColorSpace || shaderComplexity;
|
|
66421
|
+
// Accumulating views write a scalar into an intermediate target, then the output pass colorizes it.
|
|
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 );
|
|
65654
66424
|
// !WITH_GENESYS
|
|
65655
66425
|
// return useToneMapping || useColorSpace;
|
|
65656
66426
|
|
|
@@ -65704,9 +66474,7 @@ class Renderer {
|
|
|
65704
66474
|
get currentToneMapping() {
|
|
65705
66475
|
|
|
65706
66476
|
// WITH_GENESYS
|
|
65707
|
-
|
|
65708
|
-
|
|
65709
|
-
if ( view === DEBUG_VIEW_SHADER_COMPLEXITY || view === DEBUG_VIEW_LIGHTING_COMPLEXITY ) {
|
|
66477
|
+
if ( debugViewSkipsToneMapping( this.debug.view ) ) {
|
|
65710
66478
|
|
|
65711
66479
|
return NoToneMapping;
|
|
65712
66480
|
|
|
@@ -71510,6 +72278,8 @@ class WebGLAttributeUtils {
|
|
|
71510
72278
|
|
|
71511
72279
|
}
|
|
71512
72280
|
|
|
72281
|
+
// !WITH_GENESYS
|
|
72282
|
+
|
|
71513
72283
|
let equationToGL, factorToGL;
|
|
71514
72284
|
|
|
71515
72285
|
/**
|
|
@@ -72418,8 +73188,9 @@ class WebGLState {
|
|
|
72418
73188
|
* @param {Material} material - The material to configure the state for.
|
|
72419
73189
|
* @param {number} frontFaceCW - Whether the front faces are counter-clockwise or not.
|
|
72420
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.
|
|
72421
73192
|
*/
|
|
72422
|
-
setMaterial( material, frontFaceCW, hardwareClippingPlanes ) {
|
|
73193
|
+
setMaterial( material, frontFaceCW, hardwareClippingPlanes, object = null ) {
|
|
72423
73194
|
|
|
72424
73195
|
const { gl } = this;
|
|
72425
73196
|
|
|
@@ -72434,7 +73205,7 @@ class WebGLState {
|
|
|
72434
73205
|
|
|
72435
73206
|
// WITH_GENESYS
|
|
72436
73207
|
// WebGL has no cached render pipeline. One+One is applied on each draw instead.
|
|
72437
|
-
if ( this.backend.renderer
|
|
73208
|
+
if ( debugDrawAccumulates( this.backend.renderer, material, object ) ) {
|
|
72438
73209
|
|
|
72439
73210
|
this.setBlending( AdditiveBlending, AddEquation, OneFactor, OneFactor, AddEquation, OneFactor, OneFactor, material.blendColor, material.blendAlpha, true );
|
|
72440
73211
|
|
|
@@ -76684,7 +77455,10 @@ class WebGLBackend extends Backend {
|
|
|
76684
77455
|
|
|
76685
77456
|
const frontFaceCW = ( object.isMesh && object.matrixWorld.determinantAffine() < 0 );
|
|
76686
77457
|
|
|
76687
|
-
|
|
77458
|
+
// WITH_GENESYS
|
|
77459
|
+
state.setMaterial( material, frontFaceCW, hardwareClippingPlanes, object );
|
|
77460
|
+
// !WITH_GENESYS
|
|
77461
|
+
// state.setMaterial( material, frontFaceCW, hardwareClippingPlanes );
|
|
76688
77462
|
|
|
76689
77463
|
if ( context.mrt !== null && context.textures !== null ) {
|
|
76690
77464
|
|
|
@@ -87139,7 +87913,7 @@ class WebGPUPipelineUtils {
|
|
|
87139
87913
|
|
|
87140
87914
|
// WITH_GENESYS
|
|
87141
87915
|
// Accumulate shader cost with One+One. Opaque materials normally disable blending.
|
|
87142
|
-
if ( backend.renderer
|
|
87916
|
+
if ( debugDrawAccumulates( backend.renderer, material, object ) ) {
|
|
87143
87917
|
|
|
87144
87918
|
materialBlending = {
|
|
87145
87919
|
color: {
|
|
@@ -92217,6 +92991,8 @@ class BundleGroup extends Group {
|
|
|
92217
92991
|
|
|
92218
92992
|
}
|
|
92219
92993
|
|
|
92994
|
+
// !WITH_GENESYS
|
|
92995
|
+
|
|
92220
92996
|
/**
|
|
92221
92997
|
* This module is responsible to manage the rendering pipeline setups in apps.
|
|
92222
92998
|
* You usually create a single instance of this class and use it to define
|
|
@@ -92351,7 +93127,12 @@ class RenderPipeline {
|
|
|
92351
93127
|
const outputColorSpace = renderer.outputColorSpace;
|
|
92352
93128
|
|
|
92353
93129
|
renderer.toneMapping = NoToneMapping;
|
|
92354
|
-
|
|
93130
|
+
|
|
93131
|
+
// WITH_GENESYS
|
|
93132
|
+
// Accumulating views colorize in the renderer's output pass, which must still encode the color space.
|
|
93133
|
+
if ( debugViewAccumulates( renderer.debug.view ) !== true ) renderer.outputColorSpace = ColorManagement.workingColorSpace;
|
|
93134
|
+
// !WITH_GENESYS
|
|
93135
|
+
// renderer.outputColorSpace = ColorManagement.workingColorSpace;
|
|
92355
93136
|
|
|
92356
93137
|
//
|
|
92357
93138
|
|
|
@@ -92427,19 +93208,40 @@ class RenderPipeline {
|
|
|
92427
93208
|
*/
|
|
92428
93209
|
_update() {
|
|
92429
93210
|
|
|
92430
|
-
|
|
93211
|
+
// WITH_GENESYS
|
|
93212
|
+
// Debug views drawn without tone mapping must match the direct path. An accumulating
|
|
93213
|
+
// view copies the raw ratio here, and the renderer's output pass colorizes it.
|
|
93214
|
+
const view = this.renderer.debug.view;
|
|
93215
|
+
const toneMapping = debugViewSkipsToneMapping( view ) ? NoToneMapping : this.renderer.toneMapping;
|
|
93216
|
+
const outputColorSpace = debugViewAccumulates( view ) ? ColorManagement.workingColorSpace : this.renderer.outputColorSpace;
|
|
92431
93217
|
|
|
92432
|
-
|
|
93218
|
+
if ( this._toneMapping !== toneMapping ) {
|
|
93219
|
+
|
|
93220
|
+
this._toneMapping = toneMapping;
|
|
92433
93221
|
this.needsUpdate = true;
|
|
92434
93222
|
|
|
92435
93223
|
}
|
|
92436
93224
|
|
|
92437
|
-
if ( this._outputColorSpace !==
|
|
93225
|
+
if ( this._outputColorSpace !== outputColorSpace ) {
|
|
92438
93226
|
|
|
92439
|
-
this._outputColorSpace =
|
|
93227
|
+
this._outputColorSpace = outputColorSpace;
|
|
92440
93228
|
this.needsUpdate = true;
|
|
92441
93229
|
|
|
92442
93230
|
}
|
|
93231
|
+
// !WITH_GENESYS
|
|
93232
|
+
// if ( this._toneMapping !== this.renderer.toneMapping ) {
|
|
93233
|
+
//
|
|
93234
|
+
// this._toneMapping = this.renderer.toneMapping;
|
|
93235
|
+
// this.needsUpdate = true;
|
|
93236
|
+
//
|
|
93237
|
+
// }
|
|
93238
|
+
//
|
|
93239
|
+
// if ( this._outputColorSpace !== this.renderer.outputColorSpace ) {
|
|
93240
|
+
//
|
|
93241
|
+
// this._outputColorSpace = this.renderer.outputColorSpace;
|
|
93242
|
+
// this.needsUpdate = true;
|
|
93243
|
+
//
|
|
93244
|
+
// }
|
|
92443
93245
|
|
|
92444
93246
|
if ( this.needsUpdate === true ) {
|
|
92445
93247
|
|