@gnsx/three 0.186.5 → 0.186.7
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 +1454 -917
- package/build/three.webgpu.nodes.js +1454 -917
- package/examples/jsm/inspector/tabs/Settings.js +9 -6
- package/package.json +1 -1
- package/src/materials/nodes/NodeMaterial.js +56 -16
- package/src/nodes/display/ComplexityDebug.js +56 -7
- package/src/nodes/display/DoubleSideDebug.js +152 -0
- package/src/nodes/display/DrawCallDebug.js +3 -2
- package/src/nodes/display/FrontBackFaceDebug.js +88 -0
- package/src/nodes/display/LightingDebug.js +3 -2
- package/src/nodes/display/ShadowCasterDebug.js +69 -0
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/RenderObject.js +1 -1
- package/src/renderers/common/RenderPipeline.js +34 -5
- package/src/renderers/common/Renderer.js +90 -8
- package/src/renderers/common/nodes/NodeManager.js +4 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +8 -2
- package/src/renderers/webgl-fallback/utils/WebGLState.js +37 -7
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +16 -6
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, EqualDepth, 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, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, ReversedDepthFuncs, RGB_S3TC_DXT1_Format, RGBA_S3TC_DXT1_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT5_Format, RGB_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGBA_PVRTC_2BPPV1_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, R11_EAC_Format, SIGNED_R11_EAC_Format, SIGNED_RG11_EAC_Format, RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGBA_BPTC_Format, RGB_BPTC_SIGNED_Format, RGB_BPTC_UNSIGNED_Format, RED_RGTC1_Format, SIGNED_RED_RGTC1_Format, SIGNED_RED_GREEN_RGTC2_Format, MirroredRepeatWrapping, RepeatWrapping, NearestMipmapNearestFilter, NotEqualCompare, EqualCompare, AlwaysCompare, NeverCompare, LinearTransfer, getByteLength, isTypedArray, NotEqualStencilFunc, GreaterStencilFunc, GreaterEqualStencilFunc, EqualStencilFunc, LessEqualStencilFunc, LessStencilFunc, AlwaysStencilFunc, NeverStencilFunc, DecrementWrapStencilOp, IncrementWrapStencilOp, DecrementStencilOp, IncrementStencilOp, InvertStencilOp, ReplaceStencilOp, ZeroStencilOp, KeepStencilOp, SpotLight, PointLight, DirectionalLight, RectAreaLight, AmbientLight, HemisphereLight, LightProbe, LinearToneMapping, ReinhardToneMapping, CineonToneMapping, ACESFilmicToneMapping, AgXToneMapping, NeutralToneMapping, Group, Loader, FileLoader, MaterialLoader, ObjectLoader } from './three.core.js';
|
|
7
7
|
export { AdditiveAnimationBlendMode, AnimationAction, AnimationClip, AnimationLoader, AnimationMixer, AnimationObjectGroup, AnimationUtils, ArcCurve, ArrowHelper, AttachedBindMode, Audio, AudioAnalyser, AudioContext, AudioListener, AudioLoader, AxesHelper, BasicDepthPacking, BatchedMesh, BezierInterpolant, Bone, BooleanKeyframeTrack, Box2, Box3, Box3Helper, BoxHelper, BufferGeometryLoader, Cache, Camera, CameraHelper, CanvasTexture, CapsuleGeometry, CatmullRomCurve3, CircleGeometry, Clock, ColorKeyframeTrack, CompressedArrayTexture, CompressedCubeTexture, CompressedTexture, CompressedTextureLoader, ConeGeometry, Controls, CubeTextureLoader, CubicBezierCurve, CubicBezierCurve3, CubicInterpolant, CullFaceFrontBack, Curve, CurvePath, CustomToneMapping, Cylindrical, DataTextureLoader, DataUtils, DefaultLoadingManager, DetachedBindMode, DirectionalLightHelper, DiscreteInterpolant, DodecahedronGeometry, DynamicCopyUsage, DynamicReadUsage, EdgesGeometry, EllipseCurve, Euler, ExternalTexture, ExtrudeGeometry, Fog, FogExp2, GLBufferAttribute, GLSL1, GLSL3, GridHelper, HTMLTexture, HemisphereLightHelper, IcosahedronGeometry, ImageBitmapLoader, ImageLoader, ImageUtils, InstancedBufferGeometry, InstancedMesh, Int16BufferAttribute, Int32BufferAttribute, Int8BufferAttribute, Interpolant, InterpolateBezier, InterpolateDiscrete, InterpolateLinear, InterpolateSmooth, InterpolationSamplingMode, InterpolationSamplingType, KeyframeTrack, LOD, LatheGeometry, Layers, Light, LightShadow, Line, Line3, LineCurve, LineCurve3, LineLoop, LineSegments, LinearInterpolant, LinearMipMapNearestFilter, LoaderUtils, LoadingManager, LoopOnce, LoopPingPong, LoopRepeat, MOUSE, MeshDepthMaterial, MeshDistanceMaterial, NearestMipMapLinearFilter, NearestMipMapNearestFilter, NodePath, NormalAnimationBlendMode, NumberKeyframeTrack, OctahedronGeometry, Path, PlaneHelper, PointLightHelper, Points, PolarGridHelper, PolyhedronGeometry, PositionalAudio, PropertyBinding, PropertyMixer, QuadraticBezierCurve, QuadraticBezierCurve3, QuaternionKeyframeTrack, QuaternionLinearInterpolant, RGBADepthPacking, RGBDepthPacking, RGDepthPacking, RawShaderMaterial, Ray, Raycaster, RenderTarget3D, RingGeometry, ShaderMaterial, Shape, ShapeGeometry, ShapePath, ShapeUtils, Skeleton, SkeletonHelper, SkinnedMesh, Source, Spherical, SphericalHarmonics3, SplineCurve, SpotLightHelper, Sprite, StaticCopyUsage, StaticReadUsage, StereoCamera, StreamCopyUsage, StreamDrawUsage, StreamReadUsage, StringKeyframeTrack, TOUCH, TetrahedronGeometry, TextureLoader, TextureSource, TextureUtils, Timer, TorusGeometry, TorusKnotGeometry, Triangle, TriangleFanDrawMode, TriangleStripDrawMode, TrianglesDrawMode, TubeGeometry, Uint8BufferAttribute, Uint8ClampedBufferAttribute, Uniform, UniformsGroup, VectorKeyframeTrack, VideoFrameTexture, VideoTexture, WebGL3DRenderTarget, WebGLArrayRenderTarget, WebGLRenderTarget, WireframeGeometry, WrapAroundEnding, XorShift32, ZeroCurvatureEnding, ZeroSlopeEnding, allocateNodeId, collectSiblingNodeIds, configureNodeIdSeed, ensureUniqueNodeIdAmongParentChildren, generateNodeId, getConsoleFunction, hashStringToUint32, isValidNodeId, nodeIdFromKey, nodeIdFromString, nodeIdToString, profile, profileClass, randomSeedUint32, setConsoleFunction, xorshift32 } from './three.core.js';
|
|
8
8
|
|
|
9
9
|
const refreshUniforms = [
|
|
@@ -21614,6 +21614,147 @@ class VertexColorNode extends AttributeNode {
|
|
|
21614
21614
|
*/
|
|
21615
21615
|
const vertexColor = ( index = 0 ) => new VertexColorNode( index );
|
|
21616
21616
|
|
|
21617
|
+
// WITH_GENESYS
|
|
21618
|
+
// Buffer visualization. Shows one material channel in place of the shaded color.
|
|
21619
|
+
// !WITH_GENESYS
|
|
21620
|
+
|
|
21621
|
+
|
|
21622
|
+
/**
|
|
21623
|
+
* Buffer visualization. The visible surface wins, and one material channel replaces the shaded color.
|
|
21624
|
+
*
|
|
21625
|
+
* @type {string}
|
|
21626
|
+
*/
|
|
21627
|
+
const DEBUG_VIEW_BUFFER = 'bufferVisualization';
|
|
21628
|
+
|
|
21629
|
+
/**
|
|
21630
|
+
* Albedo before lighting, including maps and vertex colors.
|
|
21631
|
+
*
|
|
21632
|
+
* @type {string}
|
|
21633
|
+
*/
|
|
21634
|
+
const BUFFER_BASE_COLOR = 'baseColor';
|
|
21635
|
+
|
|
21636
|
+
/**
|
|
21637
|
+
* Shading normal in world space, packed to RGB with `n * 0.5 + 0.5`.
|
|
21638
|
+
*
|
|
21639
|
+
* @type {string}
|
|
21640
|
+
*/
|
|
21641
|
+
const BUFFER_WORLD_NORMAL = 'worldNormal';
|
|
21642
|
+
|
|
21643
|
+
/**
|
|
21644
|
+
* Scalar roughness used by the lighting model. Black is smooth.
|
|
21645
|
+
*
|
|
21646
|
+
* @type {string}
|
|
21647
|
+
*/
|
|
21648
|
+
const BUFFER_ROUGHNESS = 'roughness';
|
|
21649
|
+
|
|
21650
|
+
/**
|
|
21651
|
+
* Scalar metalness. White is metal. Unreal calls this buffer Metallic.
|
|
21652
|
+
*
|
|
21653
|
+
* @type {string}
|
|
21654
|
+
*/
|
|
21655
|
+
const BUFFER_METALLIC = 'metallic';
|
|
21656
|
+
|
|
21657
|
+
/**
|
|
21658
|
+
* Material ambient occlusion. White means no occlusion map.
|
|
21659
|
+
*
|
|
21660
|
+
* @type {string}
|
|
21661
|
+
*/
|
|
21662
|
+
const BUFFER_AMBIENT_OCCLUSION = 'ambientOcclusion';
|
|
21663
|
+
|
|
21664
|
+
/**
|
|
21665
|
+
* Emissive color before it is added to the lit result.
|
|
21666
|
+
*
|
|
21667
|
+
* @type {string}
|
|
21668
|
+
*/
|
|
21669
|
+
const BUFFER_EMISSIVE = 'emissive';
|
|
21670
|
+
|
|
21671
|
+
/**
|
|
21672
|
+
* Channel drawn when buffer visualization is first enabled.
|
|
21673
|
+
*
|
|
21674
|
+
* @type {string}
|
|
21675
|
+
*/
|
|
21676
|
+
const DEFAULT_BUFFER = BUFFER_BASE_COLOR;
|
|
21677
|
+
|
|
21678
|
+
/**
|
|
21679
|
+
* Writes a defined value for channels a material may never assign.
|
|
21680
|
+
* Standard and physical materials overwrite roughness and metalness in `setupVariants`,
|
|
21681
|
+
* and emissive is overwritten when the material has one.
|
|
21682
|
+
*
|
|
21683
|
+
* @param {string} buffer - `renderer.debug.buffer`.
|
|
21684
|
+
*/
|
|
21685
|
+
function assignBufferDefaults( buffer ) {
|
|
21686
|
+
|
|
21687
|
+
if ( buffer === BUFFER_ROUGHNESS ) {
|
|
21688
|
+
|
|
21689
|
+
roughness.assign( float( 0 ) );
|
|
21690
|
+
|
|
21691
|
+
} else if ( buffer === BUFFER_METALLIC ) {
|
|
21692
|
+
|
|
21693
|
+
metalness.assign( float( 0 ) );
|
|
21694
|
+
|
|
21695
|
+
} else if ( buffer === BUFFER_EMISSIVE ) {
|
|
21696
|
+
|
|
21697
|
+
emissive.assign( vec3( 0 ) );
|
|
21698
|
+
|
|
21699
|
+
}
|
|
21700
|
+
|
|
21701
|
+
}
|
|
21702
|
+
|
|
21703
|
+
/**
|
|
21704
|
+
* The color for one buffer channel. Scalar channels are copied into RGB.
|
|
21705
|
+
*
|
|
21706
|
+
* @param {string} buffer - `renderer.debug.buffer`.
|
|
21707
|
+
* @return {Node<vec3>} The channel color.
|
|
21708
|
+
*/
|
|
21709
|
+
function bufferVisualizationColor( buffer ) {
|
|
21710
|
+
|
|
21711
|
+
if ( buffer === BUFFER_WORLD_NORMAL ) {
|
|
21712
|
+
|
|
21713
|
+
return normalWorld.mul( 0.5 ).add( 0.5 );
|
|
21714
|
+
|
|
21715
|
+
}
|
|
21716
|
+
|
|
21717
|
+
if ( buffer === BUFFER_ROUGHNESS ) {
|
|
21718
|
+
|
|
21719
|
+
return vec3( roughness );
|
|
21720
|
+
|
|
21721
|
+
}
|
|
21722
|
+
|
|
21723
|
+
if ( buffer === BUFFER_METALLIC ) {
|
|
21724
|
+
|
|
21725
|
+
return vec3( metalness );
|
|
21726
|
+
|
|
21727
|
+
}
|
|
21728
|
+
|
|
21729
|
+
if ( buffer === BUFFER_AMBIENT_OCCLUSION ) {
|
|
21730
|
+
|
|
21731
|
+
return vec3( ambientOcclusion );
|
|
21732
|
+
|
|
21733
|
+
}
|
|
21734
|
+
|
|
21735
|
+
if ( buffer === BUFFER_EMISSIVE ) {
|
|
21736
|
+
|
|
21737
|
+
return emissive;
|
|
21738
|
+
|
|
21739
|
+
}
|
|
21740
|
+
|
|
21741
|
+
return diffuseColor.rgb;
|
|
21742
|
+
|
|
21743
|
+
}
|
|
21744
|
+
|
|
21745
|
+
/**
|
|
21746
|
+
* Replaces the shaded color with the selected buffer. Alpha stays the material's coverage
|
|
21747
|
+
* so masked and transparent surfaces keep their shape.
|
|
21748
|
+
*
|
|
21749
|
+
* @param {string} buffer - `renderer.debug.buffer`.
|
|
21750
|
+
* @return {Node<vec4>} The buffer color.
|
|
21751
|
+
*/
|
|
21752
|
+
function bufferVisualizationOutput( buffer ) {
|
|
21753
|
+
|
|
21754
|
+
return vec4( bufferVisualizationColor( buffer ), diffuseColor.a );
|
|
21755
|
+
|
|
21756
|
+
}
|
|
21757
|
+
|
|
21617
21758
|
// WITH_GENESYS
|
|
21618
21759
|
// Shader and lighting complexity debug views. Costs are a material proxy, not ISA instruction counts.
|
|
21619
21760
|
// !WITH_GENESYS
|
|
@@ -21627,7 +21768,8 @@ const vertexColor = ( index = 0 ) => new VertexColorNode( index );
|
|
|
21627
21768
|
const DEBUG_VIEW_NONE = 'none';
|
|
21628
21769
|
|
|
21629
21770
|
/**
|
|
21630
|
-
* Material-cost heatmap.
|
|
21771
|
+
* Material-cost heatmap. The nearest opaque surface wins, translucent draws add on top,
|
|
21772
|
+
* then a fullscreen pass applies the ramp.
|
|
21631
21773
|
*
|
|
21632
21774
|
* @type {string}
|
|
21633
21775
|
*/
|
|
@@ -21646,16 +21788,16 @@ const DEBUG_VIEW_LIGHTING_COMPLEXITY = 'lightingComplexity';
|
|
|
21646
21788
|
*
|
|
21647
21789
|
* @type {string}
|
|
21648
21790
|
*/
|
|
21649
|
-
const
|
|
21791
|
+
const DEBUG_VIEW_OVERDRAW = 'overdraw';
|
|
21650
21792
|
|
|
21651
21793
|
/**
|
|
21652
21794
|
* Shader cost multiplied by the number of fragments that shaded the pixel, then the shader-complexity ramp.
|
|
21653
|
-
* One opaque surface matches {@link DEBUG_VIEW_SHADER_COMPLEXITY}. Each extra
|
|
21795
|
+
* One opaque surface matches {@link DEBUG_VIEW_SHADER_COMPLEXITY}. Each extra translucent fragment scales the summed cost.
|
|
21654
21796
|
* WebGPU cannot count wasted lanes in a 2×2 quad, so the count is fragments that pass the depth test.
|
|
21655
21797
|
*
|
|
21656
21798
|
* @type {string}
|
|
21657
21799
|
*/
|
|
21658
|
-
const
|
|
21800
|
+
const DEBUG_VIEW_SHADER_COMPLEXITY_AND_OVERDRAW = 'shaderComplexityAndOverdraw';
|
|
21659
21801
|
|
|
21660
21802
|
/**
|
|
21661
21803
|
* Proxy budget that fills the shader-complexity ramp.
|
|
@@ -21675,7 +21817,7 @@ const DEFAULT_SHADER_COMPLEXITY_BUDGET = 800;
|
|
|
21675
21817
|
const DEFAULT_QUAD_OVERDRAW_BUDGET = 10;
|
|
21676
21818
|
|
|
21677
21819
|
/**
|
|
21678
|
-
* Storage scale for the overdraw count in {@link
|
|
21820
|
+
* Storage scale for the overdraw count in {@link DEBUG_VIEW_SHADER_COMPLEXITY_AND_OVERDRAW}.
|
|
21679
21821
|
* Each fragment adds `1 / scale`, so an 8-bit target can hold this many layers.
|
|
21680
21822
|
* The output pass multiplies that channel back to a count. Half-float targets hold the same count exactly.
|
|
21681
21823
|
*
|
|
@@ -21833,7 +21975,54 @@ const colorizeQuadOverdraw = ( cost ) => {
|
|
|
21833
21975
|
*/
|
|
21834
21976
|
function debugViewAccumulates( view ) {
|
|
21835
21977
|
|
|
21836
|
-
return view === DEBUG_VIEW_SHADER_COMPLEXITY || view ===
|
|
21978
|
+
return view === DEBUG_VIEW_SHADER_COMPLEXITY || view === DEBUG_VIEW_OVERDRAW || view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_OVERDRAW;
|
|
21979
|
+
|
|
21980
|
+
}
|
|
21981
|
+
|
|
21982
|
+
/**
|
|
21983
|
+
* Whether a draw adds its scalar to the accumulating target instead of shading normally.
|
|
21984
|
+
* Shadow passes, draws to the screen, and fullscreen quads draw normally. A post-processing
|
|
21985
|
+
* quad copies the accumulated scene target, so its own cost must not replace it.
|
|
21986
|
+
*
|
|
21987
|
+
* @param {Renderer} renderer - The renderer.
|
|
21988
|
+
* @param {Material} material - The material being drawn.
|
|
21989
|
+
* @param {?Object3D} object - The object being drawn.
|
|
21990
|
+
* @return {boolean} `true` when the draw accumulates.
|
|
21991
|
+
*/
|
|
21992
|
+
function debugDrawAccumulates( renderer, material, object ) {
|
|
21993
|
+
|
|
21994
|
+
return debugViewAccumulates( renderer.debug.view ) &&
|
|
21995
|
+
material.isShadowPassMaterial !== true &&
|
|
21996
|
+
renderer.isOutputTarget !== true &&
|
|
21997
|
+
( object === null || object === undefined || object.isQuadMesh !== true );
|
|
21998
|
+
|
|
21999
|
+
}
|
|
22000
|
+
|
|
22001
|
+
/**
|
|
22002
|
+
* Whether an accumulating draw replaces the stored cost instead of adding to it.
|
|
22003
|
+
* Three.js has no depth pre-pass, so adding every opaque fragment counts hidden surfaces
|
|
22004
|
+
* and changes as the camera reorders draws. Replacing, with the material's own depth test
|
|
22005
|
+
* and depth write, leaves the nearest opaque surface. Translucent draws and quad overdraw still add.
|
|
22006
|
+
*
|
|
22007
|
+
* @param {string} view - `renderer.debug.view`.
|
|
22008
|
+
* @param {Material} material - The material being drawn.
|
|
22009
|
+
* @return {boolean} `true` when the draw replaces the stored cost.
|
|
22010
|
+
*/
|
|
22011
|
+
function debugDrawReplacesCost( view, material ) {
|
|
22012
|
+
|
|
22013
|
+
return ( view === DEBUG_VIEW_SHADER_COMPLEXITY || view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_OVERDRAW ) && material.transparent !== true;
|
|
22014
|
+
|
|
22015
|
+
}
|
|
22016
|
+
|
|
22017
|
+
/**
|
|
22018
|
+
* Views that output data or a heatmap, so tone mapping would distort them.
|
|
22019
|
+
*
|
|
22020
|
+
* @param {string} view - `renderer.debug.view`.
|
|
22021
|
+
* @return {boolean} `true` when the view is drawn without tone mapping.
|
|
22022
|
+
*/
|
|
22023
|
+
function debugViewSkipsToneMapping( view ) {
|
|
22024
|
+
|
|
22025
|
+
return debugViewAccumulates( view ) || view === DEBUG_VIEW_LIGHTING_COMPLEXITY || view === DEBUG_VIEW_BUFFER;
|
|
21837
22026
|
|
|
21838
22027
|
}
|
|
21839
22028
|
|
|
@@ -21956,7 +22145,7 @@ function shaderComplexityOutput( resultNode ) {
|
|
|
21956
22145
|
* @param {Node} resultNode - The material's shaded output.
|
|
21957
22146
|
* @return {Node<vec4>} Cost ratio in red, one scaled fragment in green.
|
|
21958
22147
|
*/
|
|
21959
|
-
function
|
|
22148
|
+
function shaderComplexityAndOverdrawOutput( resultNode ) {
|
|
21960
22149
|
|
|
21961
22150
|
const shaded = vec4( resultNode ).toVar();
|
|
21962
22151
|
const ratio = new ShaderComplexityRatioNode();
|
|
@@ -22012,146 +22201,565 @@ function quadOverdrawOutput( resultNode ) {
|
|
|
22012
22201
|
|
|
22013
22202
|
}
|
|
22014
22203
|
|
|
22015
|
-
// WITH_GENESYS
|
|
22016
|
-
// Buffer visualization. Shows one material channel in place of the shaded color.
|
|
22017
|
-
// !WITH_GENESYS
|
|
22018
|
-
|
|
22019
|
-
|
|
22020
22204
|
/**
|
|
22021
|
-
*
|
|
22205
|
+
* This node can be used to define multiple outputs in a shader programs.
|
|
22022
22206
|
*
|
|
22023
|
-
* @
|
|
22207
|
+
* @augments Node
|
|
22024
22208
|
*/
|
|
22025
|
-
|
|
22209
|
+
class OutputStructNode extends Node {
|
|
22026
22210
|
|
|
22027
|
-
|
|
22028
|
-
* Albedo before lighting, including maps and vertex colors.
|
|
22029
|
-
*
|
|
22030
|
-
* @type {string}
|
|
22031
|
-
*/
|
|
22032
|
-
const BUFFER_BASE_COLOR = 'baseColor';
|
|
22211
|
+
static get type() {
|
|
22033
22212
|
|
|
22034
|
-
|
|
22035
|
-
* Shading normal in world space, packed to RGB with `n * 0.5 + 0.5`.
|
|
22036
|
-
*
|
|
22037
|
-
* @type {string}
|
|
22038
|
-
*/
|
|
22039
|
-
const BUFFER_WORLD_NORMAL = 'worldNormal';
|
|
22213
|
+
return 'OutputStructNode';
|
|
22040
22214
|
|
|
22041
|
-
|
|
22042
|
-
|
|
22043
|
-
|
|
22044
|
-
|
|
22045
|
-
|
|
22046
|
-
|
|
22215
|
+
}
|
|
22216
|
+
|
|
22217
|
+
/**
|
|
22218
|
+
* Constructs a new output struct node. The constructor can be invoked with an
|
|
22219
|
+
* arbitrary number of nodes representing the members.
|
|
22220
|
+
*
|
|
22221
|
+
* @param {...Node} members - A parameter list of nodes.
|
|
22222
|
+
*/
|
|
22223
|
+
constructor( ...members ) {
|
|
22224
|
+
|
|
22225
|
+
super();
|
|
22226
|
+
|
|
22227
|
+
/**
|
|
22228
|
+
* An array of nodes which defines the output.
|
|
22229
|
+
*
|
|
22230
|
+
* @type {Array<Node>}
|
|
22231
|
+
*/
|
|
22232
|
+
this.members = members;
|
|
22233
|
+
|
|
22234
|
+
/**
|
|
22235
|
+
* This flag can be used for type testing.
|
|
22236
|
+
*
|
|
22237
|
+
* @type {boolean}
|
|
22238
|
+
* @readonly
|
|
22239
|
+
* @default true
|
|
22240
|
+
*/
|
|
22241
|
+
this.isOutputStructNode = true;
|
|
22242
|
+
|
|
22243
|
+
}
|
|
22244
|
+
|
|
22245
|
+
generateNodeType( /*builder*/ ) {
|
|
22246
|
+
|
|
22247
|
+
return 'OutputType';
|
|
22248
|
+
|
|
22249
|
+
}
|
|
22250
|
+
|
|
22251
|
+
generate( builder ) {
|
|
22252
|
+
|
|
22253
|
+
const nodeData = builder.getDataFromNode( this );
|
|
22254
|
+
|
|
22255
|
+
if ( nodeData.membersLayout === undefined ) {
|
|
22256
|
+
|
|
22257
|
+
const members = this.members;
|
|
22258
|
+
const membersLayout = [];
|
|
22259
|
+
|
|
22260
|
+
for ( let i = 0; i < members.length; i ++ ) {
|
|
22261
|
+
|
|
22262
|
+
const name = 'm' + i;
|
|
22263
|
+
const type = members[ i ].getNodeType( builder );
|
|
22264
|
+
|
|
22265
|
+
membersLayout.push( { name, type, index: i } );
|
|
22266
|
+
|
|
22267
|
+
}
|
|
22268
|
+
|
|
22269
|
+
nodeData.membersLayout = membersLayout;
|
|
22270
|
+
nodeData.structType = builder.getOutputStructTypeFromNode( this, nodeData.membersLayout );
|
|
22271
|
+
|
|
22272
|
+
}
|
|
22273
|
+
|
|
22274
|
+
//
|
|
22275
|
+
|
|
22276
|
+
const propertyName = builder.getOutputStructName();
|
|
22277
|
+
const members = this.members;
|
|
22278
|
+
|
|
22279
|
+
const structPrefix = propertyName !== '' ? propertyName + '.' : '';
|
|
22280
|
+
|
|
22281
|
+
for ( let i = 0; i < members.length; i ++ ) {
|
|
22282
|
+
|
|
22283
|
+
const snippet = members[ i ].build( builder, nodeData.membersLayout[ i ].type );
|
|
22284
|
+
|
|
22285
|
+
builder.addLineFlowCode( `${ structPrefix }m${ i } = ${ snippet }`, this );
|
|
22286
|
+
|
|
22287
|
+
}
|
|
22288
|
+
|
|
22289
|
+
return propertyName;
|
|
22290
|
+
|
|
22291
|
+
}
|
|
22292
|
+
|
|
22293
|
+
}
|
|
22047
22294
|
|
|
22048
22295
|
/**
|
|
22049
|
-
*
|
|
22296
|
+
* TSL function for creating an output struct node.
|
|
22050
22297
|
*
|
|
22051
|
-
* @
|
|
22298
|
+
* @tsl
|
|
22299
|
+
* @function
|
|
22300
|
+
* @param {...Node} members - A parameter list of nodes.
|
|
22301
|
+
* @returns {OutputStructNode}
|
|
22052
22302
|
*/
|
|
22053
|
-
const
|
|
22303
|
+
const outputStruct = /*@__PURE__*/ nodeProxy( OutputStructNode );
|
|
22054
22304
|
|
|
22055
22305
|
/**
|
|
22056
|
-
*
|
|
22306
|
+
* Represents blending configuration.
|
|
22057
22307
|
*
|
|
22058
|
-
*
|
|
22308
|
+
* This class encapsulates all blending-related properties that control how
|
|
22309
|
+
* a material's colors are combined with the colors already in the frame buffer.
|
|
22059
22310
|
*/
|
|
22060
|
-
|
|
22311
|
+
class BlendMode {
|
|
22312
|
+
|
|
22313
|
+
/**
|
|
22314
|
+
* Constructs a new blending configuration.
|
|
22315
|
+
*
|
|
22316
|
+
* @param {(NoBlending|NormalBlending|AdditiveBlending|SubtractiveBlending|MultiplyBlending|CustomBlending|MaterialBlending)} [blending=NormalBlending] - The blending mode.
|
|
22317
|
+
*/
|
|
22318
|
+
constructor( blending = NormalBlending ) {
|
|
22319
|
+
|
|
22320
|
+
/**
|
|
22321
|
+
* Defines the blending type.
|
|
22322
|
+
*
|
|
22323
|
+
* It must be set to `CustomBlending` if custom blending properties like
|
|
22324
|
+
* {@link BlendMode#blendSrc}, {@link BlendMode#blendDst} or {@link BlendMode#blendEquation}
|
|
22325
|
+
* should have any effect.
|
|
22326
|
+
*
|
|
22327
|
+
* @type {(NoBlending|NormalBlending|AdditiveBlending|SubtractiveBlending|MultiplyBlending|CustomBlending|MaterialBlending)}
|
|
22328
|
+
* @default NormalBlending
|
|
22329
|
+
*/
|
|
22330
|
+
this.blending = blending;
|
|
22331
|
+
|
|
22332
|
+
/**
|
|
22333
|
+
* Defines the blending source factor.
|
|
22334
|
+
*
|
|
22335
|
+
* This determines how the source (incoming) fragment color is factored before being added
|
|
22336
|
+
* to the destination (existing) fragment color in the frame buffer.
|
|
22337
|
+
*
|
|
22338
|
+
* @type {(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
|
|
22339
|
+
* @default SrcAlphaFactor
|
|
22340
|
+
*/
|
|
22341
|
+
this.blendSrc = SrcAlphaFactor;
|
|
22342
|
+
|
|
22343
|
+
/**
|
|
22344
|
+
* Defines the blending destination factor.
|
|
22345
|
+
*
|
|
22346
|
+
* This determines how the destination (existing) fragment color in the frame buffer
|
|
22347
|
+
* is factored before being combined with the source (incoming) fragment color.
|
|
22348
|
+
*
|
|
22349
|
+
* @type {(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
|
|
22350
|
+
* @default OneMinusSrcAlphaFactor
|
|
22351
|
+
*/
|
|
22352
|
+
this.blendDst = OneMinusSrcAlphaFactor;
|
|
22353
|
+
|
|
22354
|
+
/**
|
|
22355
|
+
* Defines the blending equation.
|
|
22356
|
+
*
|
|
22357
|
+
* This determines how the source and destination colors are combined.
|
|
22358
|
+
*
|
|
22359
|
+
* @type {(AddEquation|SubtractEquation|ReverseSubtractEquation|MinEquation|MaxEquation)}
|
|
22360
|
+
* @default AddEquation
|
|
22361
|
+
*/
|
|
22362
|
+
this.blendEquation = AddEquation;
|
|
22363
|
+
|
|
22364
|
+
/**
|
|
22365
|
+
* Defines the blending source alpha factor.
|
|
22366
|
+
*
|
|
22367
|
+
* When set, this allows separate control of the alpha channel's source blending factor.
|
|
22368
|
+
* If `null`, {@link BlendMode#blendSrc} is used for the alpha channel as well.
|
|
22369
|
+
*
|
|
22370
|
+
* @type {?(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
|
|
22371
|
+
* @default null
|
|
22372
|
+
*/
|
|
22373
|
+
this.blendSrcAlpha = null;
|
|
22374
|
+
|
|
22375
|
+
/**
|
|
22376
|
+
* Defines the blending destination alpha factor.
|
|
22377
|
+
*
|
|
22378
|
+
* When set, this allows separate control of the alpha channel's destination blending factor.
|
|
22379
|
+
* If `null`, {@link BlendMode#blendDst} is used for the alpha channel as well.
|
|
22380
|
+
*
|
|
22381
|
+
* @type {?(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
|
|
22382
|
+
* @default null
|
|
22383
|
+
*/
|
|
22384
|
+
this.blendDstAlpha = null;
|
|
22385
|
+
|
|
22386
|
+
/**
|
|
22387
|
+
* Defines the blending equation of the alpha channel.
|
|
22388
|
+
*
|
|
22389
|
+
* When set, this allows separate control of the alpha channel's blending equation.
|
|
22390
|
+
* If `null`, {@link BlendMode#blendEquation} is used for the alpha channel as well.
|
|
22391
|
+
*
|
|
22392
|
+
* @type {?(AddEquation|SubtractEquation|ReverseSubtractEquation|MinEquation|MaxEquation)}
|
|
22393
|
+
* @default null
|
|
22394
|
+
*/
|
|
22395
|
+
this.blendEquationAlpha = null;
|
|
22396
|
+
|
|
22397
|
+
/**
|
|
22398
|
+
* Defines whether to premultiply the alpha (transparency) value.
|
|
22399
|
+
*
|
|
22400
|
+
* If `true`, the RGB color of the texture or material is multiplied by its alpha value.
|
|
22401
|
+
* This is useful for transparent textures/materials where the color data
|
|
22402
|
+
* should already include the transparency information.
|
|
22403
|
+
*
|
|
22404
|
+
* @type {boolean}
|
|
22405
|
+
* @default false
|
|
22406
|
+
*/
|
|
22407
|
+
this.premultiplyAlpha = false;
|
|
22408
|
+
|
|
22409
|
+
}
|
|
22410
|
+
|
|
22411
|
+
/**
|
|
22412
|
+
* Copies the blending properties from the given source to this instance.
|
|
22413
|
+
*
|
|
22414
|
+
* @param {BlendMode} source - The blending configuration to copy from.
|
|
22415
|
+
* @return {BlendMode} A reference to this instance.
|
|
22416
|
+
*/
|
|
22417
|
+
copy( source ) {
|
|
22418
|
+
|
|
22419
|
+
this.blending = source.blending;
|
|
22420
|
+
this.blendSrc = source.blendSrc;
|
|
22421
|
+
this.blendDst = source.blendDst;
|
|
22422
|
+
this.blendEquation = source.blendEquation;
|
|
22423
|
+
this.blendSrcAlpha = source.blendSrcAlpha;
|
|
22424
|
+
this.blendDstAlpha = source.blendDstAlpha;
|
|
22425
|
+
this.blendEquationAlpha = source.blendEquationAlpha;
|
|
22426
|
+
this.premultiplyAlpha = source.premultiplyAlpha;
|
|
22427
|
+
|
|
22428
|
+
return this;
|
|
22429
|
+
|
|
22430
|
+
}
|
|
22431
|
+
|
|
22432
|
+
/**
|
|
22433
|
+
* Returns a clone of this blending configuration.
|
|
22434
|
+
*
|
|
22435
|
+
* @return {BlendMode} A new Blending instance with the same properties.
|
|
22436
|
+
*/
|
|
22437
|
+
clone() {
|
|
22438
|
+
|
|
22439
|
+
return new this.constructor().copy( this );
|
|
22440
|
+
|
|
22441
|
+
}
|
|
22442
|
+
|
|
22443
|
+
}
|
|
22061
22444
|
|
|
22062
22445
|
/**
|
|
22063
|
-
*
|
|
22446
|
+
* A four-component version of {@link Color} which is internally
|
|
22447
|
+
* used by the renderer to represents clear color with alpha as
|
|
22448
|
+
* one object.
|
|
22064
22449
|
*
|
|
22065
|
-
* @
|
|
22450
|
+
* @private
|
|
22451
|
+
* @augments Color
|
|
22066
22452
|
*/
|
|
22067
|
-
|
|
22453
|
+
class Color4 extends Color {
|
|
22454
|
+
|
|
22455
|
+
/**
|
|
22456
|
+
* Constructs a new four-component color.
|
|
22457
|
+
* You can also pass a single THREE.Color, hex or
|
|
22458
|
+
* string argument to this constructor.
|
|
22459
|
+
*
|
|
22460
|
+
* @param {number|string} [r=1] - The red value.
|
|
22461
|
+
* @param {number} [g=1] - The green value.
|
|
22462
|
+
* @param {number} [b=1] - The blue value.
|
|
22463
|
+
* @param {number} [a=1] - The alpha value.
|
|
22464
|
+
*/
|
|
22465
|
+
constructor( r, g, b, a = 1 ) {
|
|
22466
|
+
|
|
22467
|
+
super( r, g, b );
|
|
22468
|
+
|
|
22469
|
+
this.a = a;
|
|
22470
|
+
|
|
22471
|
+
}
|
|
22472
|
+
|
|
22473
|
+
/**
|
|
22474
|
+
* Overwrites the default to honor alpha.
|
|
22475
|
+
* You can also pass a single THREE.Color, hex or
|
|
22476
|
+
* string argument to this method.
|
|
22477
|
+
*
|
|
22478
|
+
* @param {number|string|Color} r - The red value.
|
|
22479
|
+
* @param {number} [g] - The green value.
|
|
22480
|
+
* @param {number} [b] - The blue value.
|
|
22481
|
+
* @param {number} [a=1] - The alpha value.
|
|
22482
|
+
* @return {Color4} A reference to this object.
|
|
22483
|
+
*/
|
|
22484
|
+
set( r, g, b, a = 1 ) {
|
|
22485
|
+
|
|
22486
|
+
this.a = a;
|
|
22487
|
+
|
|
22488
|
+
return super.set( r, g, b );
|
|
22489
|
+
|
|
22490
|
+
}
|
|
22491
|
+
|
|
22492
|
+
/**
|
|
22493
|
+
* Overwrites the default to honor alpha.
|
|
22494
|
+
*
|
|
22495
|
+
* @param {Color4} color - The color to copy.
|
|
22496
|
+
* @return {Color4} A reference to this object.
|
|
22497
|
+
*/
|
|
22498
|
+
copy( color ) {
|
|
22499
|
+
|
|
22500
|
+
if ( color.a !== undefined ) this.a = color.a;
|
|
22501
|
+
|
|
22502
|
+
return super.copy( color );
|
|
22503
|
+
|
|
22504
|
+
}
|
|
22505
|
+
|
|
22506
|
+
/**
|
|
22507
|
+
* Overwrites the default to honor alpha.
|
|
22508
|
+
*
|
|
22509
|
+
* @return {Color4} The cloned color.
|
|
22510
|
+
*/
|
|
22511
|
+
clone() {
|
|
22512
|
+
|
|
22513
|
+
return new this.constructor( this.r, this.g, this.b, this.a );
|
|
22514
|
+
|
|
22515
|
+
}
|
|
22516
|
+
|
|
22517
|
+
*[ Symbol.iterator ]() {
|
|
22518
|
+
|
|
22519
|
+
yield this.r;
|
|
22520
|
+
yield this.g;
|
|
22521
|
+
yield this.b;
|
|
22522
|
+
yield this.a;
|
|
22523
|
+
|
|
22524
|
+
}
|
|
22525
|
+
|
|
22526
|
+
}
|
|
22527
|
+
|
|
22528
|
+
// Predefined blend modes for MRT nodes.
|
|
22529
|
+
const _noBlending = /**@__PURE__*/ new BlendMode( NoBlending );
|
|
22530
|
+
const _materialBlending = /**@__PURE__*/ new BlendMode( MaterialBlending );
|
|
22068
22531
|
|
|
22069
22532
|
/**
|
|
22070
|
-
*
|
|
22533
|
+
* Returns the MRT texture index for the given name.
|
|
22071
22534
|
*
|
|
22072
|
-
* @
|
|
22535
|
+
* @param {Array<Texture>} textures - The textures of a MRT-configured render target.
|
|
22536
|
+
* @param {string} name - The name of the MRT texture which index is requested.
|
|
22537
|
+
* @return {number} The texture index.
|
|
22073
22538
|
*/
|
|
22074
|
-
|
|
22539
|
+
function getTextureIndex( textures, name ) {
|
|
22540
|
+
|
|
22541
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
22542
|
+
|
|
22543
|
+
if ( textures[ i ].name === name ) {
|
|
22544
|
+
|
|
22545
|
+
return i;
|
|
22546
|
+
|
|
22547
|
+
}
|
|
22548
|
+
|
|
22549
|
+
}
|
|
22550
|
+
|
|
22551
|
+
return -1;
|
|
22552
|
+
|
|
22553
|
+
}
|
|
22075
22554
|
|
|
22076
22555
|
/**
|
|
22077
|
-
*
|
|
22078
|
-
*
|
|
22079
|
-
*
|
|
22556
|
+
* This node can be used setup a MRT context for rendering. A typical MRT setup for
|
|
22557
|
+
* post-processing is shown below:
|
|
22558
|
+
* ```js
|
|
22559
|
+
* const mrtNode = mrt( {
|
|
22560
|
+
* output: output,
|
|
22561
|
+
* normal: normalView
|
|
22562
|
+
* } ) ;
|
|
22563
|
+
* ```
|
|
22564
|
+
* The MRT output is defined as a dictionary.
|
|
22080
22565
|
*
|
|
22081
|
-
* @
|
|
22566
|
+
* @augments OutputStructNode
|
|
22082
22567
|
*/
|
|
22083
|
-
|
|
22568
|
+
class MRTNode extends OutputStructNode {
|
|
22084
22569
|
|
|
22085
|
-
|
|
22570
|
+
static get type() {
|
|
22086
22571
|
|
|
22087
|
-
|
|
22572
|
+
return 'MRTNode';
|
|
22088
22573
|
|
|
22089
|
-
}
|
|
22574
|
+
}
|
|
22090
22575
|
|
|
22091
|
-
|
|
22576
|
+
/**
|
|
22577
|
+
* Constructs a new output struct node.
|
|
22578
|
+
*
|
|
22579
|
+
* @param {Object<string, Node>} outputNodes - The MRT outputs.
|
|
22580
|
+
*/
|
|
22581
|
+
constructor( outputNodes ) {
|
|
22092
22582
|
|
|
22093
|
-
|
|
22583
|
+
super();
|
|
22094
22584
|
|
|
22095
|
-
|
|
22585
|
+
/**
|
|
22586
|
+
* A dictionary representing the MRT outputs. The key
|
|
22587
|
+
* is the name of the output, the value the node which produces
|
|
22588
|
+
* the output result.
|
|
22589
|
+
*
|
|
22590
|
+
* @type {Object<string, Node>}
|
|
22591
|
+
*/
|
|
22592
|
+
this.outputNodes = outputNodes;
|
|
22593
|
+
|
|
22594
|
+
/**
|
|
22595
|
+
* A dictionary storing the blend modes for each output.
|
|
22596
|
+
*
|
|
22597
|
+
* @type {Object<string, BlendMode>}
|
|
22598
|
+
*/
|
|
22599
|
+
this.blendModes = {
|
|
22600
|
+
output: _materialBlending
|
|
22601
|
+
};
|
|
22602
|
+
|
|
22603
|
+
/**
|
|
22604
|
+
* A dictionary storing the clear colors for each output.
|
|
22605
|
+
*
|
|
22606
|
+
* @type {Object<string, Color4>}
|
|
22607
|
+
*/
|
|
22608
|
+
this.clearColors = {};
|
|
22609
|
+
|
|
22610
|
+
/**
|
|
22611
|
+
* This flag can be used for type testing.
|
|
22612
|
+
*
|
|
22613
|
+
* @type {boolean}
|
|
22614
|
+
* @readonly
|
|
22615
|
+
* @default true
|
|
22616
|
+
*/
|
|
22617
|
+
this.isMRTNode = true;
|
|
22096
22618
|
|
|
22097
22619
|
}
|
|
22098
22620
|
|
|
22099
|
-
|
|
22621
|
+
/**
|
|
22622
|
+
* Sets the blend mode for the given output name.
|
|
22623
|
+
*
|
|
22624
|
+
* @param {string} name - The name of the output.
|
|
22625
|
+
* @param {BlendMode} blend - The blending mode.
|
|
22626
|
+
* @return {MRTNode} The current MRT node.
|
|
22627
|
+
*/
|
|
22628
|
+
setBlendMode( name, blend ) {
|
|
22100
22629
|
|
|
22101
|
-
|
|
22102
|
-
* The color for one buffer channel. Scalar channels are copied into RGB.
|
|
22103
|
-
*
|
|
22104
|
-
* @param {string} buffer - `renderer.debug.buffer`.
|
|
22105
|
-
* @return {Node<vec3>} The channel color.
|
|
22106
|
-
*/
|
|
22107
|
-
function bufferVisualizationColor( buffer ) {
|
|
22630
|
+
this.blendModes[ name ] = blend;
|
|
22108
22631
|
|
|
22109
|
-
|
|
22632
|
+
return this;
|
|
22110
22633
|
|
|
22111
|
-
|
|
22634
|
+
}
|
|
22635
|
+
|
|
22636
|
+
/**
|
|
22637
|
+
* Returns the blend mode for the given output name.
|
|
22638
|
+
*
|
|
22639
|
+
* @param {string} name - The name of the output.
|
|
22640
|
+
* @return {BlendMode} The blend mode.
|
|
22641
|
+
*/
|
|
22642
|
+
getBlendMode( name ) {
|
|
22643
|
+
|
|
22644
|
+
return this.blendModes[ name ] || _noBlending;
|
|
22112
22645
|
|
|
22113
22646
|
}
|
|
22114
22647
|
|
|
22115
|
-
|
|
22648
|
+
/**
|
|
22649
|
+
* Sets the clear color for the given output name.
|
|
22650
|
+
*
|
|
22651
|
+
* @param {string} name - The name of the output.
|
|
22652
|
+
* @param {number|string|Color} color - The clear color.
|
|
22653
|
+
* @param {number} [alpha=1] - The clear alpha.
|
|
22654
|
+
* @return {MRTNode} The current MRT node.
|
|
22655
|
+
*/
|
|
22656
|
+
setClearColor( name, color, alpha = 1 ) {
|
|
22116
22657
|
|
|
22117
|
-
|
|
22658
|
+
const clearColor = this.clearColors[ name ] || ( this.clearColors[ name ] = new Color4() );
|
|
22659
|
+
|
|
22660
|
+
clearColor.set( color );
|
|
22661
|
+
clearColor.a = alpha;
|
|
22662
|
+
|
|
22663
|
+
return this;
|
|
22118
22664
|
|
|
22119
22665
|
}
|
|
22120
22666
|
|
|
22121
|
-
|
|
22667
|
+
/**
|
|
22668
|
+
* Returns the clear color for the given output name.
|
|
22669
|
+
*
|
|
22670
|
+
* @param {string} name - The name of the output.
|
|
22671
|
+
* @return {?Color4} The clear color. Returns `null` if no clear color is defined
|
|
22672
|
+
* which means the renderer's default clear policy is applied.
|
|
22673
|
+
*/
|
|
22674
|
+
getClearColor( name ) {
|
|
22122
22675
|
|
|
22123
|
-
return
|
|
22676
|
+
return this.clearColors[ name ] || null;
|
|
22124
22677
|
|
|
22125
22678
|
}
|
|
22126
22679
|
|
|
22127
|
-
|
|
22680
|
+
/**
|
|
22681
|
+
* Returns `true` if the MRT node has an output with the given name.
|
|
22682
|
+
*
|
|
22683
|
+
* @param {string} name - The name of the output.
|
|
22684
|
+
* @return {NodeBuilder} Whether the MRT node has an output for the given name or not.
|
|
22685
|
+
*/
|
|
22686
|
+
has( name ) {
|
|
22128
22687
|
|
|
22129
|
-
return
|
|
22688
|
+
return this.outputNodes[ name ] !== undefined;
|
|
22130
22689
|
|
|
22131
22690
|
}
|
|
22132
22691
|
|
|
22133
|
-
|
|
22692
|
+
/**
|
|
22693
|
+
* Returns the output node for the given name.
|
|
22694
|
+
*
|
|
22695
|
+
* @param {string} name - The name of the output.
|
|
22696
|
+
* @return {Node} The output node.
|
|
22697
|
+
*/
|
|
22698
|
+
get( name ) {
|
|
22134
22699
|
|
|
22135
|
-
return
|
|
22700
|
+
return this.outputNodes[ name ];
|
|
22136
22701
|
|
|
22137
22702
|
}
|
|
22138
22703
|
|
|
22139
|
-
|
|
22704
|
+
/**
|
|
22705
|
+
* Merges the outputs of the given MRT node with the outputs of this node.
|
|
22706
|
+
*
|
|
22707
|
+
* @param {MRTNode} mrtNode - The MRT to merge.
|
|
22708
|
+
* @return {MRTNode} A new MRT node with merged outputs..
|
|
22709
|
+
*/
|
|
22710
|
+
merge( mrtNode ) {
|
|
22711
|
+
|
|
22712
|
+
const outputs = { ...this.outputNodes, ...mrtNode.outputNodes };
|
|
22713
|
+
const blendModes = { ...this.blendModes, ...mrtNode.blendModes };
|
|
22714
|
+
const clearColors = { ...this.clearColors, ...mrtNode.clearColors };
|
|
22715
|
+
|
|
22716
|
+
const mrtTarget = mrt( outputs );
|
|
22717
|
+
mrtTarget.blendModes = blendModes;
|
|
22718
|
+
mrtTarget.clearColors = clearColors;
|
|
22719
|
+
|
|
22720
|
+
return mrtTarget;
|
|
22721
|
+
|
|
22722
|
+
}
|
|
22723
|
+
|
|
22724
|
+
setup( builder ) {
|
|
22725
|
+
|
|
22726
|
+
const outputNodes = this.outputNodes;
|
|
22727
|
+
const mrt = builder.renderer.getRenderTarget();
|
|
22728
|
+
|
|
22729
|
+
const members = [];
|
|
22730
|
+
|
|
22731
|
+
const textures = mrt.textures;
|
|
22732
|
+
|
|
22733
|
+
for ( const name in outputNodes ) {
|
|
22734
|
+
|
|
22735
|
+
const index = getTextureIndex( textures, name );
|
|
22736
|
+
|
|
22737
|
+
// Ignore if the output exists in the MRT but has never been used.
|
|
22738
|
+
if ( index === -1 ) continue;
|
|
22739
|
+
|
|
22740
|
+
const type = builder.getOutputType( index );
|
|
22741
|
+
|
|
22742
|
+
members[ index ] = outputNodes[ name ].convert( type );
|
|
22743
|
+
|
|
22744
|
+
}
|
|
22745
|
+
|
|
22746
|
+
this.members = members;
|
|
22747
|
+
|
|
22748
|
+
return super.setup( builder );
|
|
22749
|
+
|
|
22750
|
+
}
|
|
22140
22751
|
|
|
22141
22752
|
}
|
|
22142
22753
|
|
|
22143
22754
|
/**
|
|
22144
|
-
*
|
|
22145
|
-
* so masked and transparent surfaces keep their shape.
|
|
22755
|
+
* TSL function for creating a MRT node.
|
|
22146
22756
|
*
|
|
22147
|
-
* @
|
|
22148
|
-
* @
|
|
22757
|
+
* @tsl
|
|
22758
|
+
* @function
|
|
22759
|
+
* @param {Object<string, Node>} outputNodes - The MRT outputs.
|
|
22760
|
+
* @returns {MRTNode}
|
|
22149
22761
|
*/
|
|
22150
|
-
|
|
22151
|
-
|
|
22152
|
-
return vec4( bufferVisualizationColor( buffer ), diffuseColor.a );
|
|
22153
|
-
|
|
22154
|
-
}
|
|
22762
|
+
const mrt = /*@__PURE__*/ nodeProxy( MRTNode );
|
|
22155
22763
|
|
|
22156
22764
|
// WITH_GENESYS
|
|
22157
22765
|
// Lighting only and detail lighting. Both replace the shaded albedo with a flat gray.
|
|
@@ -22210,11 +22818,12 @@ const lightingOnlyNormal = /*@__PURE__*/ Fn( ( builder ) => {
|
|
|
22210
22818
|
* Lit materials become a dielectric gray. Unlit materials become flat gray.
|
|
22211
22819
|
*
|
|
22212
22820
|
* @param {NodeBuilder} builder - The current node builder.
|
|
22821
|
+
* @param {NodeMaterial} material - The node material being set up. `builder.material` can be the
|
|
22822
|
+
* source material of a converted one, such as a glTF `MeshStandardMaterial`.
|
|
22213
22823
|
* @param {string} view - `renderer.debug.view`.
|
|
22214
22824
|
*/
|
|
22215
|
-
function applyLightingDebug( builder, view ) {
|
|
22825
|
+
function applyLightingDebug( builder, material, view ) {
|
|
22216
22826
|
|
|
22217
|
-
const material = builder.material;
|
|
22218
22827
|
const gray = vec3( LIGHTING_ONLY_BRIGHTNESS );
|
|
22219
22828
|
|
|
22220
22829
|
diffuseColor.rgb.assign( gray );
|
|
@@ -22333,10 +22942,11 @@ function writeDrawCallColor( color, object, material ) {
|
|
|
22333
22942
|
* The color is an object uniform, so meshes that share a material still differ.
|
|
22334
22943
|
*
|
|
22335
22944
|
* @param {NodeBuilder} builder - The current node builder.
|
|
22945
|
+
* @param {NodeMaterial} material - The node material being set up. `builder.material` can be the
|
|
22946
|
+
* source material of a converted one, such as a glTF `MeshStandardMaterial`.
|
|
22336
22947
|
*/
|
|
22337
|
-
function applyDrawCallDebug( builder ) {
|
|
22948
|
+
function applyDrawCallDebug( builder, material ) {
|
|
22338
22949
|
|
|
22339
|
-
const material = builder.material;
|
|
22340
22950
|
const colorNode = uniform( new Color() ).onObjectUpdate( ( { object, material: drawnMaterial }, self ) => {
|
|
22341
22951
|
|
|
22342
22952
|
if ( object === null || drawnMaterial === null ) return;
|
|
@@ -22373,6 +22983,321 @@ function applyDrawCallDebug( builder ) {
|
|
|
22373
22983
|
|
|
22374
22984
|
}
|
|
22375
22985
|
|
|
22986
|
+
// WITH_GENESYS
|
|
22987
|
+
// Front/back face. Both windings are drawn. The side facing the camera uses one color, the other side another.
|
|
22988
|
+
// !WITH_GENESYS
|
|
22989
|
+
|
|
22990
|
+
|
|
22991
|
+
/**
|
|
22992
|
+
* Front/back face. Culling is off. A fragment whose winding faces the camera is one color.
|
|
22993
|
+
* The opposite winding is another. Depth still hides a face behind the shell.
|
|
22994
|
+
*
|
|
22995
|
+
* @type {string}
|
|
22996
|
+
*/
|
|
22997
|
+
const DEBUG_VIEW_FRONT_BACK_FACE = 'frontBackFace';
|
|
22998
|
+
|
|
22999
|
+
/**
|
|
23000
|
+
* Rasterizer front face, ignoring the material side shortcut in {@link frontFacing}.
|
|
23001
|
+
* `BackSide` materials otherwise report every fragment as back facing.
|
|
23002
|
+
*/
|
|
23003
|
+
let GeometricFrontFacingNode$1 = class GeometricFrontFacingNode extends Node {
|
|
23004
|
+
|
|
23005
|
+
static get type() {
|
|
23006
|
+
|
|
23007
|
+
return 'GeometricFrontFacingNode';
|
|
23008
|
+
|
|
23009
|
+
}
|
|
23010
|
+
|
|
23011
|
+
constructor() {
|
|
23012
|
+
|
|
23013
|
+
super( 'bool' );
|
|
23014
|
+
|
|
23015
|
+
}
|
|
23016
|
+
|
|
23017
|
+
generate( builder ) {
|
|
23018
|
+
|
|
23019
|
+
if ( builder.shaderStage !== 'fragment' ) return 'true';
|
|
23020
|
+
|
|
23021
|
+
return builder.getFrontFacing();
|
|
23022
|
+
|
|
23023
|
+
}
|
|
23024
|
+
|
|
23025
|
+
};
|
|
23026
|
+
|
|
23027
|
+
const geometricFrontFacing$1 = /*@__PURE__*/ nodeImmutable( GeometricFrontFacingNode$1 );
|
|
23028
|
+
|
|
23029
|
+
const FRONT_COLOR$1 = /*@__PURE__*/ vec3( 0.72, 0.70, 0.66 );
|
|
23030
|
+
const BACK_COLOR$1 = /*@__PURE__*/ vec3( 0.25, 0.45, 0.85 );
|
|
23031
|
+
|
|
23032
|
+
/**
|
|
23033
|
+
* Replaces albedo with the front or back color after the material has written its channels.
|
|
23034
|
+
* Lit materials become a matte dielectric. Unlit materials become flat.
|
|
23035
|
+
*
|
|
23036
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
23037
|
+
* @param {NodeMaterial} material - The node material being set up.
|
|
23038
|
+
*/
|
|
23039
|
+
function applyFrontBackFaceDebug( builder, material ) {
|
|
23040
|
+
|
|
23041
|
+
const colorNode = select( geometricFrontFacing$1, FRONT_COLOR$1, BACK_COLOR$1 );
|
|
23042
|
+
|
|
23043
|
+
diffuseColor.rgb.assign( colorNode );
|
|
23044
|
+
|
|
23045
|
+
if ( material.lights !== true ) return;
|
|
23046
|
+
|
|
23047
|
+
metalness.assign( float( 0 ) );
|
|
23048
|
+
diffuseContribution.assign( colorNode );
|
|
23049
|
+
roughness.assign( float( 1 ) );
|
|
23050
|
+
specularColor.assign( vec3( 0 ) );
|
|
23051
|
+
specularColorBlended.assign( vec3( 0 ) );
|
|
23052
|
+
specularF90.assign( float( 0 ) );
|
|
23053
|
+
|
|
23054
|
+
builder.context.ambientOcclusion = null;
|
|
23055
|
+
|
|
23056
|
+
if ( material.useClearcoat === true ) clearcoat.assign( float( 0 ) );
|
|
23057
|
+
|
|
23058
|
+
if ( material.useSheen === true ) sheen.assign( vec3( 0 ) );
|
|
23059
|
+
|
|
23060
|
+
if ( material.useIridescence === true ) iridescence.assign( float( 0 ) );
|
|
23061
|
+
|
|
23062
|
+
if ( material.useAnisotropy === true ) anisotropy.assign( float( 0 ) );
|
|
23063
|
+
|
|
23064
|
+
if ( material.useTransmission === true ) transmission.assign( float( 0 ) );
|
|
23065
|
+
|
|
23066
|
+
if ( material.useRetroreflection === true ) retroreflectivity.assign( float( 0 ) );
|
|
23067
|
+
|
|
23068
|
+
}
|
|
23069
|
+
|
|
23070
|
+
// WITH_GENESYS
|
|
23071
|
+
// Shadow casters. Green when the object casts a shadow, gray when it does not.
|
|
23072
|
+
// !WITH_GENESYS
|
|
23073
|
+
|
|
23074
|
+
|
|
23075
|
+
/**
|
|
23076
|
+
* Shadow casters. A mesh that casts shadows is green. One that does not is gray.
|
|
23077
|
+
* The color is lit, so form stays readable.
|
|
23078
|
+
*
|
|
23079
|
+
* Matches Unreal's simplified shadow-caster view (`GetCachedShadowCasterColorSimplified`):
|
|
23080
|
+
* green `(0, 1, 0)` casts, gray `(0.5, 0.5, 0.5)` does not. Contact-shadow yellow is omitted;
|
|
23081
|
+
* Three.js has no per-object contact-shadow flag.
|
|
23082
|
+
*
|
|
23083
|
+
* @type {string}
|
|
23084
|
+
*/
|
|
23085
|
+
const DEBUG_VIEW_SHADOW_CASTER = 'shadowCaster';
|
|
23086
|
+
|
|
23087
|
+
const CASTS_COLOR = new Color( 0, 1, 0 );
|
|
23088
|
+
const NONE_COLOR = new Color( 0.5, 0.5, 0.5 );
|
|
23089
|
+
|
|
23090
|
+
/**
|
|
23091
|
+
* Replaces albedo with the caster color after the material has written its channels.
|
|
23092
|
+
* Lit materials become a matte dielectric. Unlit materials become flat.
|
|
23093
|
+
* The color is an object uniform, so meshes that share a material still differ.
|
|
23094
|
+
*
|
|
23095
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
23096
|
+
* @param {NodeMaterial} material - The node material being set up. `builder.material` can be the
|
|
23097
|
+
* source material of a converted one, such as a glTF `MeshStandardMaterial`.
|
|
23098
|
+
*/
|
|
23099
|
+
function applyShadowCasterDebug( builder, material ) {
|
|
23100
|
+
|
|
23101
|
+
const colorNode = uniform( new Color() ).onObjectUpdate( ( { object }, self ) => {
|
|
23102
|
+
|
|
23103
|
+
if ( object === null ) return;
|
|
23104
|
+
|
|
23105
|
+
return self.value.copy( object.castShadow === true ? CASTS_COLOR : NONE_COLOR );
|
|
23106
|
+
|
|
23107
|
+
} );
|
|
23108
|
+
|
|
23109
|
+
diffuseColor.rgb.assign( colorNode );
|
|
23110
|
+
|
|
23111
|
+
if ( material.lights !== true ) return;
|
|
23112
|
+
|
|
23113
|
+
metalness.assign( float( 0 ) );
|
|
23114
|
+
diffuseContribution.assign( colorNode );
|
|
23115
|
+
roughness.assign( float( 1 ) );
|
|
23116
|
+
specularColor.assign( vec3( 0 ) );
|
|
23117
|
+
specularColorBlended.assign( vec3( 0 ) );
|
|
23118
|
+
specularF90.assign( float( 0 ) );
|
|
23119
|
+
|
|
23120
|
+
builder.context.ambientOcclusion = null;
|
|
23121
|
+
|
|
23122
|
+
if ( material.useClearcoat === true ) clearcoat.assign( float( 0 ) );
|
|
23123
|
+
|
|
23124
|
+
if ( material.useSheen === true ) sheen.assign( vec3( 0 ) );
|
|
23125
|
+
|
|
23126
|
+
if ( material.useIridescence === true ) iridescence.assign( float( 0 ) );
|
|
23127
|
+
|
|
23128
|
+
if ( material.useAnisotropy === true ) anisotropy.assign( float( 0 ) );
|
|
23129
|
+
|
|
23130
|
+
if ( material.useTransmission === true ) transmission.assign( float( 0 ) );
|
|
23131
|
+
|
|
23132
|
+
if ( material.useRetroreflection === true ) retroreflectivity.assign( float( 0 ) );
|
|
23133
|
+
|
|
23134
|
+
}
|
|
23135
|
+
|
|
23136
|
+
// WITH_GENESYS
|
|
23137
|
+
// Double sided. Gray is a single-sided surface or the front of a double-sided one.
|
|
23138
|
+
// Blue is a double-sided back face you can see. Red is a double-sided back face hidden behind the front.
|
|
23139
|
+
// !WITH_GENESYS
|
|
23140
|
+
|
|
23141
|
+
|
|
23142
|
+
/**
|
|
23143
|
+
* Double sided. A single-sided material is gray. A double-sided front face is gray.
|
|
23144
|
+
* A double-sided back face that is the nearest surface is blue. A later pass paints
|
|
23145
|
+
* a hidden double-sided back face red over the front.
|
|
23146
|
+
*
|
|
23147
|
+
* @type {string}
|
|
23148
|
+
*/
|
|
23149
|
+
const DEBUG_VIEW_DOUBLE_SIDE = 'doubleSide';
|
|
23150
|
+
|
|
23151
|
+
/**
|
|
23152
|
+
* Rasterizer front face, ignoring the material side shortcut in {@link frontFacing}.
|
|
23153
|
+
*/
|
|
23154
|
+
class GeometricFrontFacingNode extends Node {
|
|
23155
|
+
|
|
23156
|
+
static get type() {
|
|
23157
|
+
|
|
23158
|
+
return 'GeometricFrontFacingNode';
|
|
23159
|
+
|
|
23160
|
+
}
|
|
23161
|
+
|
|
23162
|
+
constructor() {
|
|
23163
|
+
|
|
23164
|
+
super( 'bool' );
|
|
23165
|
+
|
|
23166
|
+
}
|
|
23167
|
+
|
|
23168
|
+
generate( builder ) {
|
|
23169
|
+
|
|
23170
|
+
if ( builder.shaderStage !== 'fragment' ) return 'true';
|
|
23171
|
+
|
|
23172
|
+
return builder.getFrontFacing();
|
|
23173
|
+
|
|
23174
|
+
}
|
|
23175
|
+
|
|
23176
|
+
}
|
|
23177
|
+
|
|
23178
|
+
const geometricFrontFacing = /*@__PURE__*/ nodeImmutable( GeometricFrontFacingNode );
|
|
23179
|
+
|
|
23180
|
+
const hideCache = new WeakMap();
|
|
23181
|
+
|
|
23182
|
+
/**
|
|
23183
|
+
* A flat card or wall has normals that all point the same way, so its back face is the same
|
|
23184
|
+
* surface. A box or a closed shell has normals that face each other, so one side can hide the other.
|
|
23185
|
+
*
|
|
23186
|
+
* @param {BufferGeometry} geometry - The mesh geometry.
|
|
23187
|
+
* @return {boolean} `true` when some normals oppose the first one.
|
|
23188
|
+
*/
|
|
23189
|
+
function meshCanHideOwnBack( geometry ) {
|
|
23190
|
+
|
|
23191
|
+
const normal = geometry.getAttribute( 'normal' );
|
|
23192
|
+
const cached = hideCache.get( geometry );
|
|
23193
|
+
|
|
23194
|
+
if ( cached !== undefined && cached.version === geometry.version ) return cached.hides;
|
|
23195
|
+
|
|
23196
|
+
let hides = false;
|
|
23197
|
+
|
|
23198
|
+
if ( normal !== undefined && normal.count > 1 ) {
|
|
23199
|
+
|
|
23200
|
+
const ax = normal.getX( 0 );
|
|
23201
|
+
const ay = normal.getY( 0 );
|
|
23202
|
+
const az = normal.getZ( 0 );
|
|
23203
|
+
const step = Math.max( 1, Math.floor( normal.count / 64 ) );
|
|
23204
|
+
|
|
23205
|
+
for ( let i = step; i < normal.count; i += step ) {
|
|
23206
|
+
|
|
23207
|
+
if ( ax * normal.getX( i ) + ay * normal.getY( i ) + az * normal.getZ( i ) < 0.25 ) {
|
|
23208
|
+
|
|
23209
|
+
hides = true;
|
|
23210
|
+
break;
|
|
23211
|
+
|
|
23212
|
+
}
|
|
23213
|
+
|
|
23214
|
+
}
|
|
23215
|
+
|
|
23216
|
+
}
|
|
23217
|
+
|
|
23218
|
+
hideCache.set( geometry, { version: geometry.version, hides } );
|
|
23219
|
+
|
|
23220
|
+
return hides;
|
|
23221
|
+
|
|
23222
|
+
}
|
|
23223
|
+
|
|
23224
|
+
const FRONT_COLOR = /*@__PURE__*/ vec3( 0.5, 0.5, 0.5 );
|
|
23225
|
+
const BACK_COLOR = /*@__PURE__*/ vec3( 0.25, 0.45, 0.85 );
|
|
23226
|
+
const HIDDEN_COLOR = /*@__PURE__*/ vec3( 0.85, 0.12, 0.1 );
|
|
23227
|
+
|
|
23228
|
+
/**
|
|
23229
|
+
* Makes a lit material a matte dielectric in the debug color. An unlit material stays flat.
|
|
23230
|
+
*
|
|
23231
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
23232
|
+
* @param {NodeMaterial} material - The node material being set up.
|
|
23233
|
+
* @param {Node} colorNode - The albedo written for this fragment.
|
|
23234
|
+
*/
|
|
23235
|
+
function assignLitColor( builder, material, colorNode ) {
|
|
23236
|
+
|
|
23237
|
+
diffuseColor.rgb.assign( colorNode );
|
|
23238
|
+
|
|
23239
|
+
if ( material.lights !== true ) return;
|
|
23240
|
+
|
|
23241
|
+
metalness.assign( float( 0 ) );
|
|
23242
|
+
diffuseContribution.assign( colorNode );
|
|
23243
|
+
roughness.assign( float( 1 ) );
|
|
23244
|
+
specularColor.assign( vec3( 0 ) );
|
|
23245
|
+
specularColorBlended.assign( vec3( 0 ) );
|
|
23246
|
+
specularF90.assign( float( 0 ) );
|
|
23247
|
+
|
|
23248
|
+
builder.context.ambientOcclusion = null;
|
|
23249
|
+
|
|
23250
|
+
if ( material.useClearcoat === true ) clearcoat.assign( float( 0 ) );
|
|
23251
|
+
|
|
23252
|
+
if ( material.useSheen === true ) sheen.assign( vec3( 0 ) );
|
|
23253
|
+
|
|
23254
|
+
if ( material.useIridescence === true ) iridescence.assign( float( 0 ) );
|
|
23255
|
+
|
|
23256
|
+
if ( material.useAnisotropy === true ) anisotropy.assign( float( 0 ) );
|
|
23257
|
+
|
|
23258
|
+
if ( material.useTransmission === true ) transmission.assign( float( 0 ) );
|
|
23259
|
+
|
|
23260
|
+
if ( material.useRetroreflection === true ) retroreflectivity.assign( float( 0 ) );
|
|
23261
|
+
|
|
23262
|
+
}
|
|
23263
|
+
|
|
23264
|
+
/**
|
|
23265
|
+
* Replaces albedo after the material has written its channels.
|
|
23266
|
+
* The hidden pass forces red. The first pass uses gray, or blue on a visible double-sided back face.
|
|
23267
|
+
*
|
|
23268
|
+
* @param {NodeBuilder} builder - The current node builder.
|
|
23269
|
+
* @param {NodeMaterial} material - The node material being set up. `builder.material` can be the
|
|
23270
|
+
* source material of a converted one, such as a glTF `MeshStandardMaterial`.
|
|
23271
|
+
*/
|
|
23272
|
+
function applyDoubleSideDebug( builder, material ) {
|
|
23273
|
+
|
|
23274
|
+
const hidden = builder.renderer.debug.doubleSideHidden === true;
|
|
23275
|
+
const visibleBack = builder.renderer.debug.doubleSideBack === true;
|
|
23276
|
+
const doubleSided = material.side === DoubleSide;
|
|
23277
|
+
const colorNode = hidden ? HIDDEN_COLOR : ( visibleBack ? BACK_COLOR : ( doubleSided ? select( geometricFrontFacing, FRONT_COLOR, BACK_COLOR ) : FRONT_COLOR ) );
|
|
23278
|
+
|
|
23279
|
+
assignLitColor( builder, material, colorNode );
|
|
23280
|
+
|
|
23281
|
+
}
|
|
23282
|
+
|
|
23283
|
+
/**
|
|
23284
|
+
* Replaces the color a material writes with a debug output. With MRT, only the `output`
|
|
23285
|
+
* attachment is replaced so the other attachments keep their members. Converting the
|
|
23286
|
+
* whole MRT struct to a color leaves WGSL with an empty output struct.
|
|
23287
|
+
*
|
|
23288
|
+
* @param {Node} resultNode - The material's fragment result, possibly an MRT node.
|
|
23289
|
+
* @param {function(Node): Node} createOutput - Builds the debug color from the shaded color.
|
|
23290
|
+
* @return {Node} The fragment result with the debug color in place.
|
|
23291
|
+
*/
|
|
23292
|
+
function replaceColorOutput( resultNode, createOutput ) {
|
|
23293
|
+
|
|
23294
|
+
if ( resultNode.isMRTNode !== true ) return createOutput( resultNode );
|
|
23295
|
+
|
|
23296
|
+
if ( resultNode.has( 'output' ) !== true ) return resultNode;
|
|
23297
|
+
|
|
23298
|
+
return resultNode.merge( mrt( { output: createOutput( resultNode.get( 'output' ) ) } ) );
|
|
23299
|
+
|
|
23300
|
+
}
|
|
22376
23301
|
// !WITH_GENESYS
|
|
22377
23302
|
|
|
22378
23303
|
/**
|
|
@@ -22891,11 +23816,23 @@ class NodeMaterial extends Material {
|
|
|
22891
23816
|
// for detail lighting and can be replaced for lighting only.
|
|
22892
23817
|
if ( ( renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || renderer.debug.view === DEBUG_VIEW_DETAIL_LIGHTING ) && this.isShadowPassMaterial !== true ) {
|
|
22893
23818
|
|
|
22894
|
-
applyLightingDebug( builder, renderer.debug.view );
|
|
23819
|
+
applyLightingDebug( builder, this, renderer.debug.view );
|
|
22895
23820
|
|
|
22896
23821
|
} else if ( renderer.debug.view === DEBUG_VIEW_DRAW_CALL && this.isShadowPassMaterial !== true ) {
|
|
22897
23822
|
|
|
22898
|
-
applyDrawCallDebug( builder );
|
|
23823
|
+
applyDrawCallDebug( builder, this );
|
|
23824
|
+
|
|
23825
|
+
} else if ( renderer.debug.view === DEBUG_VIEW_FRONT_BACK_FACE && this.isShadowPassMaterial !== true ) {
|
|
23826
|
+
|
|
23827
|
+
applyFrontBackFaceDebug( builder, this );
|
|
23828
|
+
|
|
23829
|
+
} else if ( renderer.debug.view === DEBUG_VIEW_SHADOW_CASTER && this.isShadowPassMaterial !== true ) {
|
|
23830
|
+
|
|
23831
|
+
applyShadowCasterDebug( builder, this );
|
|
23832
|
+
|
|
23833
|
+
} else if ( renderer.debug.view === DEBUG_VIEW_DOUBLE_SIDE && this.isShadowPassMaterial !== true ) {
|
|
23834
|
+
|
|
23835
|
+
applyDoubleSideDebug( builder, this );
|
|
22899
23836
|
|
|
22900
23837
|
}
|
|
22901
23838
|
// !WITH_GENESYS
|
|
@@ -22970,27 +23907,32 @@ class NodeMaterial extends Material {
|
|
|
22970
23907
|
}
|
|
22971
23908
|
|
|
22972
23909
|
// WITH_GENESYS
|
|
22973
|
-
// The screen output pass colorizes the accumulated ratio. Wrapping that pass
|
|
22974
|
-
//
|
|
22975
|
-
|
|
23910
|
+
// The screen output pass colorizes the accumulated ratio. Wrapping that pass, or a
|
|
23911
|
+
// post-processing quad that copies the scene target, would replace the heatmap with
|
|
23912
|
+
// that quad's own constant cost.
|
|
23913
|
+
if ( debugDrawAccumulates( renderer, this, builder.object ) ) {
|
|
23914
|
+
|
|
23915
|
+
if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY ) {
|
|
23916
|
+
|
|
23917
|
+
builder.shaderComplexityBase = this.getShaderComplexity();
|
|
23918
|
+
resultNode = replaceColorOutput( resultNode, shaderComplexityOutput );
|
|
22976
23919
|
|
|
22977
|
-
|
|
22978
|
-
resultNode = shaderComplexityOutput( resultNode );
|
|
23920
|
+
} else if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_OVERDRAW ) {
|
|
22979
23921
|
|
|
22980
|
-
|
|
23922
|
+
builder.shaderComplexityBase = this.getShaderComplexity();
|
|
23923
|
+
resultNode = replaceColorOutput( resultNode, shaderComplexityAndOverdrawOutput );
|
|
22981
23924
|
|
|
22982
|
-
|
|
22983
|
-
resultNode = shaderComplexityAndQuadsOutput( resultNode );
|
|
23925
|
+
} else {
|
|
22984
23926
|
|
|
22985
|
-
|
|
23927
|
+
resultNode = replaceColorOutput( resultNode, quadOverdrawOutput );
|
|
22986
23928
|
|
|
22987
|
-
|
|
23929
|
+
}
|
|
22988
23930
|
|
|
22989
23931
|
} else if ( renderer.debug.view === DEBUG_VIEW_BUFFER && this.isShadowPassMaterial !== true && this.fragmentNode === null ) {
|
|
22990
23932
|
|
|
22991
23933
|
// The fullscreen output pass sets fragmentNode. Scene materials do not, including
|
|
22992
23934
|
// when the scene is drawn straight to the canvas.
|
|
22993
|
-
resultNode = bufferVisualizationOutput( renderer.debug.buffer );
|
|
23935
|
+
resultNode = replaceColorOutput( resultNode, () => bufferVisualizationOutput( renderer.debug.buffer ) );
|
|
22994
23936
|
|
|
22995
23937
|
}
|
|
22996
23938
|
// !WITH_GENESYS
|
|
@@ -23350,7 +24292,7 @@ class NodeMaterial extends Material {
|
|
|
23350
24292
|
setupNormal( builder ) {
|
|
23351
24293
|
|
|
23352
24294
|
// WITH_GENESYS
|
|
23353
|
-
if ( ( builder.renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || builder.renderer.debug.view === DEBUG_VIEW_DRAW_CALL ) && this.isShadowPassMaterial !== true && this.fragmentNode === null ) {
|
|
24295
|
+
if ( ( builder.renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || builder.renderer.debug.view === DEBUG_VIEW_DRAW_CALL || builder.renderer.debug.view === DEBUG_VIEW_FRONT_BACK_FACE || builder.renderer.debug.view === DEBUG_VIEW_SHADOW_CASTER || builder.renderer.debug.view === DEBUG_VIEW_DOUBLE_SIDE ) && this.isShadowPassMaterial !== true && this.fragmentNode === null ) {
|
|
23354
24296
|
|
|
23355
24297
|
return lightingOnlyNormal();
|
|
23356
24298
|
|
|
@@ -23555,7 +24497,7 @@ class NodeMaterial extends Material {
|
|
|
23555
24497
|
// WITH_GENESYS
|
|
23556
24498
|
// Lighting only and draw call substitute a plain lit material, so emissive is dropped.
|
|
23557
24499
|
// Detail lighting keeps it.
|
|
23558
|
-
if ( ( builder.renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || builder.renderer.debug.view === DEBUG_VIEW_DRAW_CALL ) && this.isShadowPassMaterial !== true ) {
|
|
24500
|
+
if ( ( builder.renderer.debug.view === DEBUG_VIEW_LIGHTING_ONLY || builder.renderer.debug.view === DEBUG_VIEW_DRAW_CALL || builder.renderer.debug.view === DEBUG_VIEW_FRONT_BACK_FACE || builder.renderer.debug.view === DEBUG_VIEW_SHADOW_CASTER || builder.renderer.debug.view === DEBUG_VIEW_DOUBLE_SIDE ) && this.isShadowPassMaterial !== true ) {
|
|
23559
24501
|
|
|
23560
24502
|
return outgoingLightNode;
|
|
23561
24503
|
|
|
@@ -32466,7 +33408,7 @@ class RenderObject {
|
|
|
32466
33408
|
|
|
32467
33409
|
// WITH_GENESYS
|
|
32468
33410
|
// hash() xors each argument as a number, so a view name has to be hashed first.
|
|
32469
|
-
cacheKey = hash$1( cacheKey, hashString( this.renderer.debug.view ), hashString( this.renderer.debug.buffer ), this.renderer.debug.shaderComplexityBudget, this.renderer.debug.quadOverdrawBudget );
|
|
33411
|
+
cacheKey = hash$1( cacheKey, hashString( this.renderer.debug.view ), hashString( this.renderer.debug.buffer ), this.renderer.debug.shaderComplexityBudget, this.renderer.debug.quadOverdrawBudget, this.renderer.debug.doubleSideHidden === true ? 1 : 0, this.renderer.debug.doubleSideBack === true ? 1 : 0 );
|
|
32470
33412
|
// !WITH_GENESYS
|
|
32471
33413
|
|
|
32472
33414
|
return cacheKey;
|
|
@@ -36857,130 +37799,47 @@ class Textures extends DataMap {
|
|
|
36857
37799
|
|
|
36858
37800
|
this.info.destroyTexture( texture );
|
|
36859
37801
|
|
|
36860
|
-
}
|
|
36861
|
-
|
|
36862
|
-
}
|
|
36863
|
-
|
|
36864
|
-
// WITH_GENESYS
|
|
36865
|
-
/**
|
|
36866
|
-
* Frees internal resources. Destroys every tracked render target and
|
|
36867
|
-
* texture so the `'dispose'` listeners installed by {@link updateTexture}
|
|
36868
|
-
* and {@link updateRenderTarget} are removed; without this, listeners on
|
|
36869
|
-
* shared textures (PMREM, environment maps, etc.) would retain this
|
|
36870
|
-
* `Textures` instance (and its renderer) across renderer teardown.
|
|
36871
|
-
*
|
|
36872
|
-
* @override
|
|
36873
|
-
*/
|
|
36874
|
-
dispose() {
|
|
36875
|
-
|
|
36876
|
-
// Snapshot first: `_destroy*` mutates the sets.
|
|
36877
|
-
const renderTargets = Array.from( this._renderTargets );
|
|
36878
|
-
this._renderTargets.clear();
|
|
36879
|
-
|
|
36880
|
-
for ( const renderTarget of renderTargets ) {
|
|
36881
|
-
|
|
36882
|
-
this._destroyRenderTarget( renderTarget );
|
|
36883
|
-
|
|
36884
|
-
}
|
|
36885
|
-
|
|
36886
|
-
const textures = Array.from( this._textures );
|
|
36887
|
-
this._textures.clear();
|
|
36888
|
-
|
|
36889
|
-
for ( const texture of textures ) {
|
|
36890
|
-
|
|
36891
|
-
this._destroyTexture( texture );
|
|
36892
|
-
|
|
36893
|
-
}
|
|
36894
|
-
|
|
36895
|
-
this._htmlTextures.clear();
|
|
36896
|
-
|
|
36897
|
-
super.dispose();
|
|
36898
|
-
|
|
36899
|
-
}
|
|
36900
|
-
// !WITH_GENESYS
|
|
36901
|
-
|
|
36902
|
-
}
|
|
36903
|
-
|
|
36904
|
-
/**
|
|
36905
|
-
* A four-component version of {@link Color} which is internally
|
|
36906
|
-
* used by the renderer to represents clear color with alpha as
|
|
36907
|
-
* one object.
|
|
36908
|
-
*
|
|
36909
|
-
* @private
|
|
36910
|
-
* @augments Color
|
|
36911
|
-
*/
|
|
36912
|
-
class Color4 extends Color {
|
|
36913
|
-
|
|
36914
|
-
/**
|
|
36915
|
-
* Constructs a new four-component color.
|
|
36916
|
-
* You can also pass a single THREE.Color, hex or
|
|
36917
|
-
* string argument to this constructor.
|
|
36918
|
-
*
|
|
36919
|
-
* @param {number|string} [r=1] - The red value.
|
|
36920
|
-
* @param {number} [g=1] - The green value.
|
|
36921
|
-
* @param {number} [b=1] - The blue value.
|
|
36922
|
-
* @param {number} [a=1] - The alpha value.
|
|
36923
|
-
*/
|
|
36924
|
-
constructor( r, g, b, a = 1 ) {
|
|
36925
|
-
|
|
36926
|
-
super( r, g, b );
|
|
36927
|
-
|
|
36928
|
-
this.a = a;
|
|
37802
|
+
}
|
|
36929
37803
|
|
|
36930
37804
|
}
|
|
36931
37805
|
|
|
37806
|
+
// WITH_GENESYS
|
|
36932
37807
|
/**
|
|
36933
|
-
*
|
|
36934
|
-
*
|
|
36935
|
-
*
|
|
37808
|
+
* Frees internal resources. Destroys every tracked render target and
|
|
37809
|
+
* texture so the `'dispose'` listeners installed by {@link updateTexture}
|
|
37810
|
+
* and {@link updateRenderTarget} are removed; without this, listeners on
|
|
37811
|
+
* shared textures (PMREM, environment maps, etc.) would retain this
|
|
37812
|
+
* `Textures` instance (and its renderer) across renderer teardown.
|
|
36936
37813
|
*
|
|
36937
|
-
* @
|
|
36938
|
-
* @param {number} [g] - The green value.
|
|
36939
|
-
* @param {number} [b] - The blue value.
|
|
36940
|
-
* @param {number} [a=1] - The alpha value.
|
|
36941
|
-
* @return {Color4} A reference to this object.
|
|
37814
|
+
* @override
|
|
36942
37815
|
*/
|
|
36943
|
-
|
|
36944
|
-
|
|
36945
|
-
this.a = a;
|
|
36946
|
-
|
|
36947
|
-
return super.set( r, g, b );
|
|
37816
|
+
dispose() {
|
|
36948
37817
|
|
|
36949
|
-
|
|
37818
|
+
// Snapshot first: `_destroy*` mutates the sets.
|
|
37819
|
+
const renderTargets = Array.from( this._renderTargets );
|
|
37820
|
+
this._renderTargets.clear();
|
|
36950
37821
|
|
|
36951
|
-
|
|
36952
|
-
* Overwrites the default to honor alpha.
|
|
36953
|
-
*
|
|
36954
|
-
* @param {Color4} color - The color to copy.
|
|
36955
|
-
* @return {Color4} A reference to this object.
|
|
36956
|
-
*/
|
|
36957
|
-
copy( color ) {
|
|
37822
|
+
for ( const renderTarget of renderTargets ) {
|
|
36958
37823
|
|
|
36959
|
-
|
|
37824
|
+
this._destroyRenderTarget( renderTarget );
|
|
36960
37825
|
|
|
36961
|
-
|
|
37826
|
+
}
|
|
36962
37827
|
|
|
36963
|
-
|
|
37828
|
+
const textures = Array.from( this._textures );
|
|
37829
|
+
this._textures.clear();
|
|
36964
37830
|
|
|
36965
|
-
|
|
36966
|
-
* Overwrites the default to honor alpha.
|
|
36967
|
-
*
|
|
36968
|
-
* @return {Color4} The cloned color.
|
|
36969
|
-
*/
|
|
36970
|
-
clone() {
|
|
37831
|
+
for ( const texture of textures ) {
|
|
36971
37832
|
|
|
36972
|
-
|
|
37833
|
+
this._destroyTexture( texture );
|
|
36973
37834
|
|
|
36974
|
-
|
|
37835
|
+
}
|
|
36975
37836
|
|
|
36976
|
-
|
|
37837
|
+
this._htmlTextures.clear();
|
|
36977
37838
|
|
|
36978
|
-
|
|
36979
|
-
yield this.g;
|
|
36980
|
-
yield this.b;
|
|
36981
|
-
yield this.a;
|
|
37839
|
+
super.dispose();
|
|
36982
37840
|
|
|
36983
37841
|
}
|
|
37842
|
+
// !WITH_GENESYS
|
|
36984
37843
|
|
|
36985
37844
|
}
|
|
36986
37845
|
|
|
@@ -37608,652 +38467,124 @@ class StackNode extends Node {
|
|
|
37608
38467
|
const stages = builder.getDataFromNode( node, 'any' ).stages;
|
|
37609
38468
|
const parents = stages && stages[ builder.shaderStage ];
|
|
37610
38469
|
|
|
37611
|
-
if ( node.isVarNode && parents && parents.length === 1 && parents[ 0 ] && parents[ 0 ].isStackNode ) {
|
|
37612
|
-
|
|
37613
|
-
continue; // skip var nodes that are only used in .toVarying()
|
|
37614
|
-
|
|
37615
|
-
}
|
|
37616
|
-
|
|
37617
|
-
node.build( builder, 'void' );
|
|
37618
|
-
|
|
37619
|
-
}
|
|
37620
|
-
|
|
37621
|
-
this._currentNode = previousNode;
|
|
37622
|
-
|
|
37623
|
-
}
|
|
37624
|
-
|
|
37625
|
-
//
|
|
37626
|
-
|
|
37627
|
-
let result;
|
|
37628
|
-
|
|
37629
|
-
if ( this.outputNode ) {
|
|
37630
|
-
|
|
37631
|
-
const buildResult = this.outputNode.build( builder, ...params );
|
|
37632
|
-
|
|
37633
|
-
if ( builder.buildStage !== 'generate' || this.outputNode.getNodeType( builder ) !== 'void' ) {
|
|
37634
|
-
|
|
37635
|
-
result = buildResult;
|
|
37636
|
-
|
|
37637
|
-
}
|
|
37638
|
-
|
|
37639
|
-
} else {
|
|
37640
|
-
|
|
37641
|
-
result = super.build( builder, ...params );
|
|
37642
|
-
|
|
37643
|
-
}
|
|
37644
|
-
|
|
37645
|
-
setCurrentStack( previousStack );
|
|
37646
|
-
|
|
37647
|
-
builder.removeActiveStack( this );
|
|
37648
|
-
|
|
37649
|
-
return result;
|
|
37650
|
-
|
|
37651
|
-
}
|
|
37652
|
-
|
|
37653
|
-
}
|
|
37654
|
-
|
|
37655
|
-
/**
|
|
37656
|
-
* TSL function for creating a stack node.
|
|
37657
|
-
*
|
|
37658
|
-
* @tsl
|
|
37659
|
-
* @function
|
|
37660
|
-
* @param {?StackNode} [parent=null] - The parent stack node.
|
|
37661
|
-
* @returns {StackNode}
|
|
37662
|
-
*/
|
|
37663
|
-
const stack = /*@__PURE__*/ nodeProxy( StackNode ).setParameterLength( 0, 1 );
|
|
37664
|
-
|
|
37665
|
-
/**
|
|
37666
|
-
* Generates a layout for struct members.
|
|
37667
|
-
* This function takes an object representing struct members and returns an array of member layouts.
|
|
37668
|
-
* Each member layout includes the member's name, type, and whether it is atomic.
|
|
37669
|
-
*
|
|
37670
|
-
* @param {Object.<string, string|Object>} members - An object where keys are member names and values are either types (as strings) or objects with type and atomic properties.
|
|
37671
|
-
* @returns {Array.<{name: string, type: string, atomic: boolean}>} An array of member layouts.
|
|
37672
|
-
*/
|
|
37673
|
-
function getMembersLayout( members ) {
|
|
37674
|
-
|
|
37675
|
-
return Object.entries( members ).map( ( [ name, value ] ) => {
|
|
37676
|
-
|
|
37677
|
-
if ( typeof value === 'string' ) {
|
|
37678
|
-
|
|
37679
|
-
return { name, type: value, atomic: false };
|
|
37680
|
-
|
|
37681
|
-
}
|
|
37682
|
-
|
|
37683
|
-
return { name, type: value.type, atomic: value.atomic || false };
|
|
37684
|
-
|
|
37685
|
-
} );
|
|
37686
|
-
|
|
37687
|
-
}
|
|
37688
|
-
|
|
37689
|
-
/**
|
|
37690
|
-
* Represents a struct type node in the node-based system.
|
|
37691
|
-
* This class is used to define and manage the layout and types of struct members.
|
|
37692
|
-
* It extends the base Node class and provides methods to get the length of the struct,
|
|
37693
|
-
* retrieve member types, and generate the struct type for a builder.
|
|
37694
|
-
*
|
|
37695
|
-
* @augments Node
|
|
37696
|
-
*/
|
|
37697
|
-
class StructTypeNode extends Node {
|
|
37698
|
-
|
|
37699
|
-
static get type() {
|
|
37700
|
-
|
|
37701
|
-
return 'StructTypeNode';
|
|
37702
|
-
|
|
37703
|
-
}
|
|
37704
|
-
|
|
37705
|
-
/**
|
|
37706
|
-
* Creates an instance of StructTypeNode.
|
|
37707
|
-
*
|
|
37708
|
-
* @param {Object} membersLayout - The layout of the members for the struct.
|
|
37709
|
-
* @param {?string} [name=null] - The optional name of the struct.
|
|
37710
|
-
*/
|
|
37711
|
-
constructor( membersLayout, name = null ) {
|
|
37712
|
-
|
|
37713
|
-
super( 'struct' );
|
|
37714
|
-
|
|
37715
|
-
/**
|
|
37716
|
-
* The layout of the members for the struct
|
|
37717
|
-
*
|
|
37718
|
-
* @type {Array.<{name: string, type: string, atomic: boolean}>}
|
|
37719
|
-
*/
|
|
37720
|
-
this.membersLayout = getMembersLayout( membersLayout );
|
|
37721
|
-
|
|
37722
|
-
/**
|
|
37723
|
-
* The name of the struct.
|
|
37724
|
-
*
|
|
37725
|
-
* @type {?string}
|
|
37726
|
-
* @default null
|
|
37727
|
-
*/
|
|
37728
|
-
this.name = name;
|
|
37729
|
-
|
|
37730
|
-
/**
|
|
37731
|
-
* This flag can be used for type testing.
|
|
37732
|
-
*
|
|
37733
|
-
* @type {boolean}
|
|
37734
|
-
* @readonly
|
|
37735
|
-
* @default true
|
|
37736
|
-
*/
|
|
37737
|
-
this.isStructTypeNode = true;
|
|
37738
|
-
|
|
37739
|
-
}
|
|
37740
|
-
|
|
37741
|
-
/**
|
|
37742
|
-
* Returns the length of the struct in 4-byte elements (e.g. float or int components).
|
|
37743
|
-
* The length is calculated by summing the lengths of the struct's members, accounting for memory alignment.
|
|
37744
|
-
* To get the size in bytes, multiply the returned value by 4.
|
|
37745
|
-
*
|
|
37746
|
-
* @returns {number} The length of the struct in 4-byte elements.
|
|
37747
|
-
*/
|
|
37748
|
-
getLength() {
|
|
37749
|
-
|
|
37750
|
-
let maxAlignment = 1; // maximum alignment value in this struct
|
|
37751
|
-
let offset = 0; // global buffer offset in 4 byte elements
|
|
37752
|
-
|
|
37753
|
-
for ( const member of this.membersLayout ) {
|
|
37754
|
-
|
|
37755
|
-
const type = member.type;
|
|
37756
|
-
|
|
37757
|
-
const itemSize = getMemoryLengthFromType( type );
|
|
37758
|
-
const alignment = getAlignmentFromType( type );
|
|
37759
|
-
maxAlignment = Math.max( maxAlignment, alignment );
|
|
37760
|
-
|
|
37761
|
-
const chunkOffset = offset % maxAlignment; // offset in the current chunk of maxAlignment elements
|
|
37762
|
-
const overhang = chunkOffset % alignment; // distance from the last aligned offset
|
|
37763
|
-
if ( overhang !== 0 ) {
|
|
37764
|
-
|
|
37765
|
-
offset += alignment - overhang; // move to next aligned offset
|
|
37766
|
-
|
|
37767
|
-
}
|
|
37768
|
-
|
|
37769
|
-
offset += itemSize;
|
|
37770
|
-
|
|
37771
|
-
}
|
|
37772
|
-
|
|
37773
|
-
return ( Math.ceil( offset / maxAlignment ) * maxAlignment ); // ensure length is a multiple of maxAlignment
|
|
37774
|
-
|
|
37775
|
-
}
|
|
37776
|
-
|
|
37777
|
-
getMemberType( builder, name ) {
|
|
37778
|
-
|
|
37779
|
-
const member = this.membersLayout.find( m => m.name === name );
|
|
37780
|
-
|
|
37781
|
-
return member ? member.type : 'void';
|
|
37782
|
-
|
|
37783
|
-
}
|
|
37784
|
-
|
|
37785
|
-
generateNodeType( builder ) {
|
|
37786
|
-
|
|
37787
|
-
const structType = builder.getStructTypeFromNode( this, this.membersLayout, this.name );
|
|
37788
|
-
|
|
37789
|
-
return structType.name;
|
|
37790
|
-
|
|
37791
|
-
}
|
|
37792
|
-
|
|
37793
|
-
setup( builder ) {
|
|
37794
|
-
|
|
37795
|
-
builder.getStructTypeFromNode( this, this.membersLayout, this.name );
|
|
37796
|
-
builder.addInclude( this );
|
|
37797
|
-
|
|
37798
|
-
}
|
|
37799
|
-
|
|
37800
|
-
generate( builder ) {
|
|
37801
|
-
|
|
37802
|
-
return this.getNodeType( builder );
|
|
37803
|
-
|
|
37804
|
-
}
|
|
37805
|
-
|
|
37806
|
-
}
|
|
37807
|
-
|
|
37808
|
-
/**
|
|
37809
|
-
* StructNode allows to create custom structures with multiple members.
|
|
37810
|
-
* This can also be used to define structures in attribute and uniform data.
|
|
37811
|
-
*
|
|
37812
|
-
* ```js
|
|
37813
|
-
* // Define a custom struct
|
|
37814
|
-
* const BoundingBox = struct( { min: 'vec3', max: 'vec3' } );
|
|
37815
|
-
*
|
|
37816
|
-
* // Create a new instance of the struct
|
|
37817
|
-
* const bb = BoundingBox( vec3( 0 ), vec3( 1 ) ); // style 1
|
|
37818
|
-
* const bb = BoundingBox( { min: vec3( 0 ), max: vec3( 1 ) } ); // style 2
|
|
37819
|
-
*
|
|
37820
|
-
* // Access the struct members
|
|
37821
|
-
* const min = bb.get( 'min' );
|
|
37822
|
-
*
|
|
37823
|
-
* // Assign a new value to a member
|
|
37824
|
-
* min.assign( vec3() );
|
|
37825
|
-
* ```
|
|
37826
|
-
* @augments Node
|
|
37827
|
-
*/
|
|
37828
|
-
class StructNode extends Node {
|
|
37829
|
-
|
|
37830
|
-
static get type() {
|
|
37831
|
-
|
|
37832
|
-
return 'StructNode';
|
|
37833
|
-
|
|
37834
|
-
}
|
|
37835
|
-
|
|
37836
|
-
constructor( structTypeNode, values ) {
|
|
37837
|
-
|
|
37838
|
-
super( 'vec3' );
|
|
37839
|
-
|
|
37840
|
-
this.structTypeNode = structTypeNode;
|
|
37841
|
-
this.values = values;
|
|
37842
|
-
|
|
37843
|
-
this.isStructNode = true;
|
|
37844
|
-
|
|
37845
|
-
}
|
|
37846
|
-
|
|
37847
|
-
generateNodeType( builder ) {
|
|
37848
|
-
|
|
37849
|
-
return this.structTypeNode.getNodeType( builder );
|
|
37850
|
-
|
|
37851
|
-
}
|
|
37852
|
-
|
|
37853
|
-
getMemberType( builder, name ) {
|
|
37854
|
-
|
|
37855
|
-
return this.structTypeNode.getMemberType( builder, name );
|
|
37856
|
-
|
|
37857
|
-
}
|
|
37858
|
-
|
|
37859
|
-
_getChildren() {
|
|
37860
|
-
|
|
37861
|
-
// Ensure struct type is the last child for correct code generation order
|
|
37862
|
-
|
|
37863
|
-
const children = super._getChildren();
|
|
37864
|
-
|
|
37865
|
-
const structTypeProperty = children.find( child => child.childNode === this.structTypeNode );
|
|
37866
|
-
|
|
37867
|
-
children.splice( children.indexOf( structTypeProperty ), 1 );
|
|
37868
|
-
children.push( structTypeProperty );
|
|
37869
|
-
|
|
37870
|
-
return children;
|
|
37871
|
-
|
|
37872
|
-
}
|
|
37873
|
-
|
|
37874
|
-
generate( builder ) {
|
|
37875
|
-
|
|
37876
|
-
const nodeVar = builder.getVarFromNode( this );
|
|
37877
|
-
const structType = nodeVar.type;
|
|
37878
|
-
const propertyName = builder.getPropertyName( nodeVar );
|
|
37879
|
-
|
|
37880
|
-
builder.addLineFlowCode( `${ propertyName } = ${ builder.generateStruct( structType, this.structTypeNode.membersLayout, this.values ) }`, this );
|
|
37881
|
-
|
|
37882
|
-
return nodeVar.name;
|
|
37883
|
-
|
|
37884
|
-
}
|
|
37885
|
-
|
|
37886
|
-
}
|
|
37887
|
-
|
|
37888
|
-
/**
|
|
37889
|
-
* TSL function for creating a struct node.
|
|
37890
|
-
*
|
|
37891
|
-
* @tsl
|
|
37892
|
-
* @function
|
|
37893
|
-
* @param {Object} membersLayout - The layout of the struct members.
|
|
37894
|
-
* @param {?string} [name=null] - The name of the struct.
|
|
37895
|
-
* @returns {Function} The struct function.
|
|
37896
|
-
*/
|
|
37897
|
-
const struct = ( membersLayout, name = null ) => {
|
|
37898
|
-
|
|
37899
|
-
const structType = new StructTypeNode( membersLayout, name );
|
|
37900
|
-
|
|
37901
|
-
const struct = ( ...params ) => {
|
|
37902
|
-
|
|
37903
|
-
let values = null;
|
|
37904
|
-
|
|
37905
|
-
if ( params.length > 0 ) {
|
|
37906
|
-
|
|
37907
|
-
if ( isArrayAsParameter( params ) ) {
|
|
37908
|
-
|
|
37909
|
-
values = {};
|
|
37910
|
-
|
|
37911
|
-
const names = Object.keys( membersLayout );
|
|
37912
|
-
|
|
37913
|
-
for ( let i = 0; i < params.length; i ++ ) {
|
|
37914
|
-
|
|
37915
|
-
values[ names[ i ] ] = nodeObject( params[ i ] );
|
|
37916
|
-
|
|
37917
|
-
}
|
|
37918
|
-
|
|
37919
|
-
} else {
|
|
37920
|
-
|
|
37921
|
-
values = params[ 0 ];
|
|
37922
|
-
|
|
37923
|
-
}
|
|
37924
|
-
|
|
37925
|
-
}
|
|
37926
|
-
|
|
37927
|
-
return new StructNode( structType, values );
|
|
37928
|
-
|
|
37929
|
-
};
|
|
37930
|
-
|
|
37931
|
-
return nodeProxyConstructor( struct, structType );
|
|
37932
|
-
|
|
37933
|
-
};
|
|
37934
|
-
|
|
37935
|
-
/**
|
|
37936
|
-
* This node can be used to define multiple outputs in a shader programs.
|
|
37937
|
-
*
|
|
37938
|
-
* @augments Node
|
|
37939
|
-
*/
|
|
37940
|
-
class OutputStructNode extends Node {
|
|
37941
|
-
|
|
37942
|
-
static get type() {
|
|
37943
|
-
|
|
37944
|
-
return 'OutputStructNode';
|
|
37945
|
-
|
|
37946
|
-
}
|
|
37947
|
-
|
|
37948
|
-
/**
|
|
37949
|
-
* Constructs a new output struct node. The constructor can be invoked with an
|
|
37950
|
-
* arbitrary number of nodes representing the members.
|
|
37951
|
-
*
|
|
37952
|
-
* @param {...Node} members - A parameter list of nodes.
|
|
37953
|
-
*/
|
|
37954
|
-
constructor( ...members ) {
|
|
37955
|
-
|
|
37956
|
-
super();
|
|
37957
|
-
|
|
37958
|
-
/**
|
|
37959
|
-
* An array of nodes which defines the output.
|
|
37960
|
-
*
|
|
37961
|
-
* @type {Array<Node>}
|
|
37962
|
-
*/
|
|
37963
|
-
this.members = members;
|
|
37964
|
-
|
|
37965
|
-
/**
|
|
37966
|
-
* This flag can be used for type testing.
|
|
37967
|
-
*
|
|
37968
|
-
* @type {boolean}
|
|
37969
|
-
* @readonly
|
|
37970
|
-
* @default true
|
|
37971
|
-
*/
|
|
37972
|
-
this.isOutputStructNode = true;
|
|
37973
|
-
|
|
37974
|
-
}
|
|
37975
|
-
|
|
37976
|
-
generateNodeType( /*builder*/ ) {
|
|
37977
|
-
|
|
37978
|
-
return 'OutputType';
|
|
37979
|
-
|
|
37980
|
-
}
|
|
37981
|
-
|
|
37982
|
-
generate( builder ) {
|
|
37983
|
-
|
|
37984
|
-
const nodeData = builder.getDataFromNode( this );
|
|
37985
|
-
|
|
37986
|
-
if ( nodeData.membersLayout === undefined ) {
|
|
37987
|
-
|
|
37988
|
-
const members = this.members;
|
|
37989
|
-
const membersLayout = [];
|
|
37990
|
-
|
|
37991
|
-
for ( let i = 0; i < members.length; i ++ ) {
|
|
37992
|
-
|
|
37993
|
-
const name = 'm' + i;
|
|
37994
|
-
const type = members[ i ].getNodeType( builder );
|
|
37995
|
-
|
|
37996
|
-
membersLayout.push( { name, type, index: i } );
|
|
37997
|
-
|
|
37998
|
-
}
|
|
37999
|
-
|
|
38000
|
-
nodeData.membersLayout = membersLayout;
|
|
38001
|
-
nodeData.structType = builder.getOutputStructTypeFromNode( this, nodeData.membersLayout );
|
|
38002
|
-
|
|
38003
|
-
}
|
|
38004
|
-
|
|
38005
|
-
//
|
|
38006
|
-
|
|
38007
|
-
const propertyName = builder.getOutputStructName();
|
|
38008
|
-
const members = this.members;
|
|
38009
|
-
|
|
38010
|
-
const structPrefix = propertyName !== '' ? propertyName + '.' : '';
|
|
38011
|
-
|
|
38012
|
-
for ( let i = 0; i < members.length; i ++ ) {
|
|
38013
|
-
|
|
38014
|
-
const snippet = members[ i ].build( builder, nodeData.membersLayout[ i ].type );
|
|
38015
|
-
|
|
38016
|
-
builder.addLineFlowCode( `${ structPrefix }m${ i } = ${ snippet }`, this );
|
|
38017
|
-
|
|
38018
|
-
}
|
|
38019
|
-
|
|
38020
|
-
return propertyName;
|
|
38021
|
-
|
|
38022
|
-
}
|
|
38023
|
-
|
|
38024
|
-
}
|
|
38025
|
-
|
|
38026
|
-
/**
|
|
38027
|
-
* TSL function for creating an output struct node.
|
|
38028
|
-
*
|
|
38029
|
-
* @tsl
|
|
38030
|
-
* @function
|
|
38031
|
-
* @param {...Node} members - A parameter list of nodes.
|
|
38032
|
-
* @returns {OutputStructNode}
|
|
38033
|
-
*/
|
|
38034
|
-
const outputStruct = /*@__PURE__*/ nodeProxy( OutputStructNode );
|
|
38035
|
-
|
|
38036
|
-
/**
|
|
38037
|
-
* Represents blending configuration.
|
|
38038
|
-
*
|
|
38039
|
-
* This class encapsulates all blending-related properties that control how
|
|
38040
|
-
* a material's colors are combined with the colors already in the frame buffer.
|
|
38041
|
-
*/
|
|
38042
|
-
class BlendMode {
|
|
38043
|
-
|
|
38044
|
-
/**
|
|
38045
|
-
* Constructs a new blending configuration.
|
|
38046
|
-
*
|
|
38047
|
-
* @param {(NoBlending|NormalBlending|AdditiveBlending|SubtractiveBlending|MultiplyBlending|CustomBlending|MaterialBlending)} [blending=NormalBlending] - The blending mode.
|
|
38048
|
-
*/
|
|
38049
|
-
constructor( blending = NormalBlending ) {
|
|
38050
|
-
|
|
38051
|
-
/**
|
|
38052
|
-
* Defines the blending type.
|
|
38053
|
-
*
|
|
38054
|
-
* It must be set to `CustomBlending` if custom blending properties like
|
|
38055
|
-
* {@link BlendMode#blendSrc}, {@link BlendMode#blendDst} or {@link BlendMode#blendEquation}
|
|
38056
|
-
* should have any effect.
|
|
38057
|
-
*
|
|
38058
|
-
* @type {(NoBlending|NormalBlending|AdditiveBlending|SubtractiveBlending|MultiplyBlending|CustomBlending|MaterialBlending)}
|
|
38059
|
-
* @default NormalBlending
|
|
38060
|
-
*/
|
|
38061
|
-
this.blending = blending;
|
|
38470
|
+
if ( node.isVarNode && parents && parents.length === 1 && parents[ 0 ] && parents[ 0 ].isStackNode ) {
|
|
38062
38471
|
|
|
38063
|
-
|
|
38064
|
-
* Defines the blending source factor.
|
|
38065
|
-
*
|
|
38066
|
-
* This determines how the source (incoming) fragment color is factored before being added
|
|
38067
|
-
* to the destination (existing) fragment color in the frame buffer.
|
|
38068
|
-
*
|
|
38069
|
-
* @type {(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
|
|
38070
|
-
* @default SrcAlphaFactor
|
|
38071
|
-
*/
|
|
38072
|
-
this.blendSrc = SrcAlphaFactor;
|
|
38472
|
+
continue; // skip var nodes that are only used in .toVarying()
|
|
38073
38473
|
|
|
38074
|
-
|
|
38075
|
-
* Defines the blending destination factor.
|
|
38076
|
-
*
|
|
38077
|
-
* This determines how the destination (existing) fragment color in the frame buffer
|
|
38078
|
-
* is factored before being combined with the source (incoming) fragment color.
|
|
38079
|
-
*
|
|
38080
|
-
* @type {(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
|
|
38081
|
-
* @default OneMinusSrcAlphaFactor
|
|
38082
|
-
*/
|
|
38083
|
-
this.blendDst = OneMinusSrcAlphaFactor;
|
|
38474
|
+
}
|
|
38084
38475
|
|
|
38085
|
-
|
|
38086
|
-
* Defines the blending equation.
|
|
38087
|
-
*
|
|
38088
|
-
* This determines how the source and destination colors are combined.
|
|
38089
|
-
*
|
|
38090
|
-
* @type {(AddEquation|SubtractEquation|ReverseSubtractEquation|MinEquation|MaxEquation)}
|
|
38091
|
-
* @default AddEquation
|
|
38092
|
-
*/
|
|
38093
|
-
this.blendEquation = AddEquation;
|
|
38476
|
+
node.build( builder, 'void' );
|
|
38094
38477
|
|
|
38095
|
-
|
|
38096
|
-
* Defines the blending source alpha factor.
|
|
38097
|
-
*
|
|
38098
|
-
* When set, this allows separate control of the alpha channel's source blending factor.
|
|
38099
|
-
* If `null`, {@link BlendMode#blendSrc} is used for the alpha channel as well.
|
|
38100
|
-
*
|
|
38101
|
-
* @type {?(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
|
|
38102
|
-
* @default null
|
|
38103
|
-
*/
|
|
38104
|
-
this.blendSrcAlpha = null;
|
|
38478
|
+
}
|
|
38105
38479
|
|
|
38106
|
-
|
|
38107
|
-
* Defines the blending destination alpha factor.
|
|
38108
|
-
*
|
|
38109
|
-
* When set, this allows separate control of the alpha channel's destination blending factor.
|
|
38110
|
-
* If `null`, {@link BlendMode#blendDst} is used for the alpha channel as well.
|
|
38111
|
-
*
|
|
38112
|
-
* @type {?(ZeroFactor|OneFactor|SrcColorFactor|OneMinusSrcColorFactor|SrcAlphaFactor|OneMinusSrcAlphaFactor|DstAlphaFactor|OneMinusDstAlphaFactor|DstColorFactor|OneMinusDstColorFactor|SrcAlphaSaturateFactor|ConstantColorFactor|OneMinusConstantColorFactor|ConstantAlphaFactor|OneMinusConstantAlphaFactor)}
|
|
38113
|
-
* @default null
|
|
38114
|
-
*/
|
|
38115
|
-
this.blendDstAlpha = null;
|
|
38480
|
+
this._currentNode = previousNode;
|
|
38116
38481
|
|
|
38117
|
-
|
|
38118
|
-
* Defines the blending equation of the alpha channel.
|
|
38119
|
-
*
|
|
38120
|
-
* When set, this allows separate control of the alpha channel's blending equation.
|
|
38121
|
-
* If `null`, {@link BlendMode#blendEquation} is used for the alpha channel as well.
|
|
38122
|
-
*
|
|
38123
|
-
* @type {?(AddEquation|SubtractEquation|ReverseSubtractEquation|MinEquation|MaxEquation)}
|
|
38124
|
-
* @default null
|
|
38125
|
-
*/
|
|
38126
|
-
this.blendEquationAlpha = null;
|
|
38482
|
+
}
|
|
38127
38483
|
|
|
38128
|
-
|
|
38129
|
-
* Defines whether to premultiply the alpha (transparency) value.
|
|
38130
|
-
*
|
|
38131
|
-
* If `true`, the RGB color of the texture or material is multiplied by its alpha value.
|
|
38132
|
-
* This is useful for transparent textures/materials where the color data
|
|
38133
|
-
* should already include the transparency information.
|
|
38134
|
-
*
|
|
38135
|
-
* @type {boolean}
|
|
38136
|
-
* @default false
|
|
38137
|
-
*/
|
|
38138
|
-
this.premultiplyAlpha = false;
|
|
38484
|
+
//
|
|
38139
38485
|
|
|
38140
|
-
|
|
38486
|
+
let result;
|
|
38141
38487
|
|
|
38142
|
-
|
|
38143
|
-
* Copies the blending properties from the given source to this instance.
|
|
38144
|
-
*
|
|
38145
|
-
* @param {BlendMode} source - The blending configuration to copy from.
|
|
38146
|
-
* @return {BlendMode} A reference to this instance.
|
|
38147
|
-
*/
|
|
38148
|
-
copy( source ) {
|
|
38488
|
+
if ( this.outputNode ) {
|
|
38149
38489
|
|
|
38150
|
-
|
|
38151
|
-
this.blendSrc = source.blendSrc;
|
|
38152
|
-
this.blendDst = source.blendDst;
|
|
38153
|
-
this.blendEquation = source.blendEquation;
|
|
38154
|
-
this.blendSrcAlpha = source.blendSrcAlpha;
|
|
38155
|
-
this.blendDstAlpha = source.blendDstAlpha;
|
|
38156
|
-
this.blendEquationAlpha = source.blendEquationAlpha;
|
|
38157
|
-
this.premultiplyAlpha = source.premultiplyAlpha;
|
|
38490
|
+
const buildResult = this.outputNode.build( builder, ...params );
|
|
38158
38491
|
|
|
38159
|
-
|
|
38492
|
+
if ( builder.buildStage !== 'generate' || this.outputNode.getNodeType( builder ) !== 'void' ) {
|
|
38160
38493
|
|
|
38161
|
-
|
|
38494
|
+
result = buildResult;
|
|
38162
38495
|
|
|
38163
|
-
|
|
38164
|
-
* Returns a clone of this blending configuration.
|
|
38165
|
-
*
|
|
38166
|
-
* @return {BlendMode} A new Blending instance with the same properties.
|
|
38167
|
-
*/
|
|
38168
|
-
clone() {
|
|
38496
|
+
}
|
|
38169
38497
|
|
|
38170
|
-
|
|
38498
|
+
} else {
|
|
38499
|
+
|
|
38500
|
+
result = super.build( builder, ...params );
|
|
38501
|
+
|
|
38502
|
+
}
|
|
38503
|
+
|
|
38504
|
+
setCurrentStack( previousStack );
|
|
38505
|
+
|
|
38506
|
+
builder.removeActiveStack( this );
|
|
38507
|
+
|
|
38508
|
+
return result;
|
|
38171
38509
|
|
|
38172
38510
|
}
|
|
38173
38511
|
|
|
38174
38512
|
}
|
|
38175
38513
|
|
|
38176
|
-
|
|
38177
|
-
|
|
38178
|
-
|
|
38514
|
+
/**
|
|
38515
|
+
* TSL function for creating a stack node.
|
|
38516
|
+
*
|
|
38517
|
+
* @tsl
|
|
38518
|
+
* @function
|
|
38519
|
+
* @param {?StackNode} [parent=null] - The parent stack node.
|
|
38520
|
+
* @returns {StackNode}
|
|
38521
|
+
*/
|
|
38522
|
+
const stack = /*@__PURE__*/ nodeProxy( StackNode ).setParameterLength( 0, 1 );
|
|
38179
38523
|
|
|
38180
38524
|
/**
|
|
38181
|
-
*
|
|
38525
|
+
* Generates a layout for struct members.
|
|
38526
|
+
* This function takes an object representing struct members and returns an array of member layouts.
|
|
38527
|
+
* Each member layout includes the member's name, type, and whether it is atomic.
|
|
38182
38528
|
*
|
|
38183
|
-
* @param {
|
|
38184
|
-
* @
|
|
38185
|
-
* @return {number} The texture index.
|
|
38529
|
+
* @param {Object.<string, string|Object>} members - An object where keys are member names and values are either types (as strings) or objects with type and atomic properties.
|
|
38530
|
+
* @returns {Array.<{name: string, type: string, atomic: boolean}>} An array of member layouts.
|
|
38186
38531
|
*/
|
|
38187
|
-
function
|
|
38532
|
+
function getMembersLayout( members ) {
|
|
38188
38533
|
|
|
38189
|
-
|
|
38534
|
+
return Object.entries( members ).map( ( [ name, value ] ) => {
|
|
38190
38535
|
|
|
38191
|
-
if (
|
|
38536
|
+
if ( typeof value === 'string' ) {
|
|
38192
38537
|
|
|
38193
|
-
return
|
|
38538
|
+
return { name, type: value, atomic: false };
|
|
38194
38539
|
|
|
38195
38540
|
}
|
|
38196
38541
|
|
|
38197
|
-
|
|
38542
|
+
return { name, type: value.type, atomic: value.atomic || false };
|
|
38198
38543
|
|
|
38199
|
-
|
|
38544
|
+
} );
|
|
38200
38545
|
|
|
38201
38546
|
}
|
|
38202
38547
|
|
|
38203
38548
|
/**
|
|
38204
|
-
*
|
|
38205
|
-
*
|
|
38206
|
-
*
|
|
38207
|
-
*
|
|
38208
|
-
* output: output,
|
|
38209
|
-
* normal: normalView
|
|
38210
|
-
* } ) ;
|
|
38211
|
-
* ```
|
|
38212
|
-
* The MRT output is defined as a dictionary.
|
|
38549
|
+
* Represents a struct type node in the node-based system.
|
|
38550
|
+
* This class is used to define and manage the layout and types of struct members.
|
|
38551
|
+
* It extends the base Node class and provides methods to get the length of the struct,
|
|
38552
|
+
* retrieve member types, and generate the struct type for a builder.
|
|
38213
38553
|
*
|
|
38214
|
-
* @augments
|
|
38554
|
+
* @augments Node
|
|
38215
38555
|
*/
|
|
38216
|
-
class
|
|
38556
|
+
class StructTypeNode extends Node {
|
|
38217
38557
|
|
|
38218
38558
|
static get type() {
|
|
38219
38559
|
|
|
38220
|
-
return '
|
|
38560
|
+
return 'StructTypeNode';
|
|
38221
38561
|
|
|
38222
38562
|
}
|
|
38223
38563
|
|
|
38224
38564
|
/**
|
|
38225
|
-
*
|
|
38565
|
+
* Creates an instance of StructTypeNode.
|
|
38226
38566
|
*
|
|
38227
|
-
* @param {Object
|
|
38567
|
+
* @param {Object} membersLayout - The layout of the members for the struct.
|
|
38568
|
+
* @param {?string} [name=null] - The optional name of the struct.
|
|
38228
38569
|
*/
|
|
38229
|
-
constructor(
|
|
38230
|
-
|
|
38231
|
-
super();
|
|
38570
|
+
constructor( membersLayout, name = null ) {
|
|
38232
38571
|
|
|
38233
|
-
|
|
38234
|
-
* A dictionary representing the MRT outputs. The key
|
|
38235
|
-
* is the name of the output, the value the node which produces
|
|
38236
|
-
* the output result.
|
|
38237
|
-
*
|
|
38238
|
-
* @type {Object<string, Node>}
|
|
38239
|
-
*/
|
|
38240
|
-
this.outputNodes = outputNodes;
|
|
38572
|
+
super( 'struct' );
|
|
38241
38573
|
|
|
38242
38574
|
/**
|
|
38243
|
-
*
|
|
38575
|
+
* The layout of the members for the struct
|
|
38244
38576
|
*
|
|
38245
|
-
* @type {
|
|
38577
|
+
* @type {Array.<{name: string, type: string, atomic: boolean}>}
|
|
38246
38578
|
*/
|
|
38247
|
-
this.
|
|
38248
|
-
output: _materialBlending
|
|
38249
|
-
};
|
|
38579
|
+
this.membersLayout = getMembersLayout( membersLayout );
|
|
38250
38580
|
|
|
38251
38581
|
/**
|
|
38252
|
-
*
|
|
38582
|
+
* The name of the struct.
|
|
38253
38583
|
*
|
|
38254
|
-
* @type {
|
|
38584
|
+
* @type {?string}
|
|
38585
|
+
* @default null
|
|
38255
38586
|
*/
|
|
38256
|
-
this.
|
|
38587
|
+
this.name = name;
|
|
38257
38588
|
|
|
38258
38589
|
/**
|
|
38259
38590
|
* This flag can be used for type testing.
|
|
@@ -38262,152 +38593,203 @@ class MRTNode extends OutputStructNode {
|
|
|
38262
38593
|
* @readonly
|
|
38263
38594
|
* @default true
|
|
38264
38595
|
*/
|
|
38265
|
-
this.
|
|
38596
|
+
this.isStructTypeNode = true;
|
|
38266
38597
|
|
|
38267
38598
|
}
|
|
38268
38599
|
|
|
38269
38600
|
/**
|
|
38270
|
-
*
|
|
38601
|
+
* Returns the length of the struct in 4-byte elements (e.g. float or int components).
|
|
38602
|
+
* The length is calculated by summing the lengths of the struct's members, accounting for memory alignment.
|
|
38603
|
+
* To get the size in bytes, multiply the returned value by 4.
|
|
38271
38604
|
*
|
|
38272
|
-
* @
|
|
38273
|
-
* @param {BlendMode} blend - The blending mode.
|
|
38274
|
-
* @return {MRTNode} The current MRT node.
|
|
38605
|
+
* @returns {number} The length of the struct in 4-byte elements.
|
|
38275
38606
|
*/
|
|
38276
|
-
|
|
38607
|
+
getLength() {
|
|
38277
38608
|
|
|
38278
|
-
|
|
38609
|
+
let maxAlignment = 1; // maximum alignment value in this struct
|
|
38610
|
+
let offset = 0; // global buffer offset in 4 byte elements
|
|
38279
38611
|
|
|
38280
|
-
|
|
38612
|
+
for ( const member of this.membersLayout ) {
|
|
38281
38613
|
|
|
38282
|
-
|
|
38614
|
+
const type = member.type;
|
|
38283
38615
|
|
|
38284
|
-
|
|
38285
|
-
|
|
38286
|
-
|
|
38287
|
-
* @param {string} name - The name of the output.
|
|
38288
|
-
* @return {BlendMode} The blend mode.
|
|
38289
|
-
*/
|
|
38290
|
-
getBlendMode( name ) {
|
|
38616
|
+
const itemSize = getMemoryLengthFromType( type );
|
|
38617
|
+
const alignment = getAlignmentFromType( type );
|
|
38618
|
+
maxAlignment = Math.max( maxAlignment, alignment );
|
|
38291
38619
|
|
|
38292
|
-
|
|
38620
|
+
const chunkOffset = offset % maxAlignment; // offset in the current chunk of maxAlignment elements
|
|
38621
|
+
const overhang = chunkOffset % alignment; // distance from the last aligned offset
|
|
38622
|
+
if ( overhang !== 0 ) {
|
|
38623
|
+
|
|
38624
|
+
offset += alignment - overhang; // move to next aligned offset
|
|
38625
|
+
|
|
38626
|
+
}
|
|
38627
|
+
|
|
38628
|
+
offset += itemSize;
|
|
38629
|
+
|
|
38630
|
+
}
|
|
38631
|
+
|
|
38632
|
+
return ( Math.ceil( offset / maxAlignment ) * maxAlignment ); // ensure length is a multiple of maxAlignment
|
|
38293
38633
|
|
|
38294
38634
|
}
|
|
38295
38635
|
|
|
38296
|
-
|
|
38297
|
-
* Sets the clear color for the given output name.
|
|
38298
|
-
*
|
|
38299
|
-
* @param {string} name - The name of the output.
|
|
38300
|
-
* @param {number|string|Color} color - The clear color.
|
|
38301
|
-
* @param {number} [alpha=1] - The clear alpha.
|
|
38302
|
-
* @return {MRTNode} The current MRT node.
|
|
38303
|
-
*/
|
|
38304
|
-
setClearColor( name, color, alpha = 1 ) {
|
|
38636
|
+
getMemberType( builder, name ) {
|
|
38305
38637
|
|
|
38306
|
-
const
|
|
38638
|
+
const member = this.membersLayout.find( m => m.name === name );
|
|
38307
38639
|
|
|
38308
|
-
|
|
38309
|
-
clearColor.a = alpha;
|
|
38640
|
+
return member ? member.type : 'void';
|
|
38310
38641
|
|
|
38311
|
-
|
|
38642
|
+
}
|
|
38643
|
+
|
|
38644
|
+
generateNodeType( builder ) {
|
|
38645
|
+
|
|
38646
|
+
const structType = builder.getStructTypeFromNode( this, this.membersLayout, this.name );
|
|
38647
|
+
|
|
38648
|
+
return structType.name;
|
|
38312
38649
|
|
|
38313
38650
|
}
|
|
38314
38651
|
|
|
38315
|
-
|
|
38316
|
-
* Returns the clear color for the given output name.
|
|
38317
|
-
*
|
|
38318
|
-
* @param {string} name - The name of the output.
|
|
38319
|
-
* @return {?Color4} The clear color. Returns `null` if no clear color is defined
|
|
38320
|
-
* which means the renderer's default clear policy is applied.
|
|
38321
|
-
*/
|
|
38322
|
-
getClearColor( name ) {
|
|
38652
|
+
setup( builder ) {
|
|
38323
38653
|
|
|
38324
|
-
|
|
38654
|
+
builder.getStructTypeFromNode( this, this.membersLayout, this.name );
|
|
38655
|
+
builder.addInclude( this );
|
|
38325
38656
|
|
|
38326
38657
|
}
|
|
38327
38658
|
|
|
38328
|
-
|
|
38329
|
-
* Returns `true` if the MRT node has an output with the given name.
|
|
38330
|
-
*
|
|
38331
|
-
* @param {string} name - The name of the output.
|
|
38332
|
-
* @return {NodeBuilder} Whether the MRT node has an output for the given name or not.
|
|
38333
|
-
*/
|
|
38334
|
-
has( name ) {
|
|
38659
|
+
generate( builder ) {
|
|
38335
38660
|
|
|
38336
|
-
return this.
|
|
38661
|
+
return this.getNodeType( builder );
|
|
38337
38662
|
|
|
38338
38663
|
}
|
|
38339
38664
|
|
|
38340
|
-
|
|
38341
|
-
* Returns the output node for the given name.
|
|
38342
|
-
*
|
|
38343
|
-
* @param {string} name - The name of the output.
|
|
38344
|
-
* @return {Node} The output node.
|
|
38345
|
-
*/
|
|
38346
|
-
get( name ) {
|
|
38665
|
+
}
|
|
38347
38666
|
|
|
38348
|
-
|
|
38667
|
+
/**
|
|
38668
|
+
* StructNode allows to create custom structures with multiple members.
|
|
38669
|
+
* This can also be used to define structures in attribute and uniform data.
|
|
38670
|
+
*
|
|
38671
|
+
* ```js
|
|
38672
|
+
* // Define a custom struct
|
|
38673
|
+
* const BoundingBox = struct( { min: 'vec3', max: 'vec3' } );
|
|
38674
|
+
*
|
|
38675
|
+
* // Create a new instance of the struct
|
|
38676
|
+
* const bb = BoundingBox( vec3( 0 ), vec3( 1 ) ); // style 1
|
|
38677
|
+
* const bb = BoundingBox( { min: vec3( 0 ), max: vec3( 1 ) } ); // style 2
|
|
38678
|
+
*
|
|
38679
|
+
* // Access the struct members
|
|
38680
|
+
* const min = bb.get( 'min' );
|
|
38681
|
+
*
|
|
38682
|
+
* // Assign a new value to a member
|
|
38683
|
+
* min.assign( vec3() );
|
|
38684
|
+
* ```
|
|
38685
|
+
* @augments Node
|
|
38686
|
+
*/
|
|
38687
|
+
class StructNode extends Node {
|
|
38688
|
+
|
|
38689
|
+
static get type() {
|
|
38690
|
+
|
|
38691
|
+
return 'StructNode';
|
|
38349
38692
|
|
|
38350
38693
|
}
|
|
38351
38694
|
|
|
38352
|
-
|
|
38353
|
-
* Merges the outputs of the given MRT node with the outputs of this node.
|
|
38354
|
-
*
|
|
38355
|
-
* @param {MRTNode} mrtNode - The MRT to merge.
|
|
38356
|
-
* @return {MRTNode} A new MRT node with merged outputs..
|
|
38357
|
-
*/
|
|
38358
|
-
merge( mrtNode ) {
|
|
38695
|
+
constructor( structTypeNode, values ) {
|
|
38359
38696
|
|
|
38360
|
-
|
|
38361
|
-
const blendModes = { ...this.blendModes, ...mrtNode.blendModes };
|
|
38362
|
-
const clearColors = { ...this.clearColors, ...mrtNode.clearColors };
|
|
38697
|
+
super( 'vec3' );
|
|
38363
38698
|
|
|
38364
|
-
|
|
38365
|
-
|
|
38366
|
-
mrtTarget.clearColors = clearColors;
|
|
38699
|
+
this.structTypeNode = structTypeNode;
|
|
38700
|
+
this.values = values;
|
|
38367
38701
|
|
|
38368
|
-
|
|
38702
|
+
this.isStructNode = true;
|
|
38369
38703
|
|
|
38370
38704
|
}
|
|
38371
38705
|
|
|
38372
|
-
|
|
38706
|
+
generateNodeType( builder ) {
|
|
38373
38707
|
|
|
38374
|
-
|
|
38375
|
-
const mrt = builder.renderer.getRenderTarget();
|
|
38708
|
+
return this.structTypeNode.getNodeType( builder );
|
|
38376
38709
|
|
|
38377
|
-
|
|
38710
|
+
}
|
|
38378
38711
|
|
|
38379
|
-
|
|
38712
|
+
getMemberType( builder, name ) {
|
|
38380
38713
|
|
|
38381
|
-
|
|
38714
|
+
return this.structTypeNode.getMemberType( builder, name );
|
|
38382
38715
|
|
|
38383
|
-
|
|
38716
|
+
}
|
|
38384
38717
|
|
|
38385
|
-
|
|
38386
|
-
if ( index === -1 ) continue;
|
|
38718
|
+
_getChildren() {
|
|
38387
38719
|
|
|
38388
|
-
|
|
38720
|
+
// Ensure struct type is the last child for correct code generation order
|
|
38389
38721
|
|
|
38390
|
-
|
|
38722
|
+
const children = super._getChildren();
|
|
38391
38723
|
|
|
38392
|
-
|
|
38724
|
+
const structTypeProperty = children.find( child => child.childNode === this.structTypeNode );
|
|
38393
38725
|
|
|
38394
|
-
|
|
38726
|
+
children.splice( children.indexOf( structTypeProperty ), 1 );
|
|
38727
|
+
children.push( structTypeProperty );
|
|
38395
38728
|
|
|
38396
|
-
return
|
|
38729
|
+
return children;
|
|
38730
|
+
|
|
38731
|
+
}
|
|
38732
|
+
|
|
38733
|
+
generate( builder ) {
|
|
38734
|
+
|
|
38735
|
+
const nodeVar = builder.getVarFromNode( this );
|
|
38736
|
+
const structType = nodeVar.type;
|
|
38737
|
+
const propertyName = builder.getPropertyName( nodeVar );
|
|
38738
|
+
|
|
38739
|
+
builder.addLineFlowCode( `${ propertyName } = ${ builder.generateStruct( structType, this.structTypeNode.membersLayout, this.values ) }`, this );
|
|
38740
|
+
|
|
38741
|
+
return nodeVar.name;
|
|
38397
38742
|
|
|
38398
38743
|
}
|
|
38399
38744
|
|
|
38400
38745
|
}
|
|
38401
38746
|
|
|
38402
38747
|
/**
|
|
38403
|
-
* TSL function for creating a
|
|
38748
|
+
* TSL function for creating a struct node.
|
|
38404
38749
|
*
|
|
38405
38750
|
* @tsl
|
|
38406
38751
|
* @function
|
|
38407
|
-
* @param {Object
|
|
38408
|
-
* @
|
|
38752
|
+
* @param {Object} membersLayout - The layout of the struct members.
|
|
38753
|
+
* @param {?string} [name=null] - The name of the struct.
|
|
38754
|
+
* @returns {Function} The struct function.
|
|
38409
38755
|
*/
|
|
38410
|
-
const
|
|
38756
|
+
const struct = ( membersLayout, name = null ) => {
|
|
38757
|
+
|
|
38758
|
+
const structType = new StructTypeNode( membersLayout, name );
|
|
38759
|
+
|
|
38760
|
+
const struct = ( ...params ) => {
|
|
38761
|
+
|
|
38762
|
+
let values = null;
|
|
38763
|
+
|
|
38764
|
+
if ( params.length > 0 ) {
|
|
38765
|
+
|
|
38766
|
+
if ( isArrayAsParameter( params ) ) {
|
|
38767
|
+
|
|
38768
|
+
values = {};
|
|
38769
|
+
|
|
38770
|
+
const names = Object.keys( membersLayout );
|
|
38771
|
+
|
|
38772
|
+
for ( let i = 0; i < params.length; i ++ ) {
|
|
38773
|
+
|
|
38774
|
+
values[ names[ i ] ] = nodeObject( params[ i ] );
|
|
38775
|
+
|
|
38776
|
+
}
|
|
38777
|
+
|
|
38778
|
+
} else {
|
|
38779
|
+
|
|
38780
|
+
values = params[ 0 ];
|
|
38781
|
+
|
|
38782
|
+
}
|
|
38783
|
+
|
|
38784
|
+
}
|
|
38785
|
+
|
|
38786
|
+
return new StructNode( structType, values );
|
|
38787
|
+
|
|
38788
|
+
};
|
|
38789
|
+
|
|
38790
|
+
return nodeProxyConstructor( struct, structType );
|
|
38791
|
+
|
|
38792
|
+
};
|
|
38411
38793
|
|
|
38412
38794
|
/**
|
|
38413
38795
|
* This node represents an operation that reinterprets the bit representation of a value
|
|
@@ -53138,9 +53520,11 @@ class Background extends DataMap {
|
|
|
53138
53520
|
//
|
|
53139
53521
|
|
|
53140
53522
|
// WITH_GENESYS
|
|
53523
|
+
// Accumulating views start from zero cost. Alpha keeps the shaded pass coverage, so an
|
|
53524
|
+
// overlay pass such as a HUD stays transparent where it draws nothing when composited.
|
|
53141
53525
|
if ( debugViewAccumulates( renderer.debug.view ) ) {
|
|
53142
53526
|
|
|
53143
|
-
_clearColor.set( 0, 0, 0, 1 );
|
|
53527
|
+
_clearColor.set( 0, 0, 0, background !== null ? 1 : _clearColor.a );
|
|
53144
53528
|
|
|
53145
53529
|
}
|
|
53146
53530
|
// !WITH_GENESYS
|
|
@@ -60428,9 +60812,9 @@ class NodeManager extends DataMap {
|
|
|
60428
60812
|
}
|
|
60429
60813
|
|
|
60430
60814
|
// WITH_GENESYS
|
|
60431
|
-
if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY || renderer.debug.view ===
|
|
60815
|
+
if ( renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY || renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_OVERDRAW ) {
|
|
60432
60816
|
|
|
60433
|
-
const complexity = renderer.debug.view ===
|
|
60817
|
+
const complexity = renderer.debug.view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_OVERDRAW
|
|
60434
60818
|
? sampled.r.mul( sampled.g ).mul( SHADER_COMPLEXITY_QUAD_COUNT_SCALE )
|
|
60435
60819
|
: sampled.r;
|
|
60436
60820
|
|
|
@@ -60438,7 +60822,7 @@ class NodeManager extends DataMap {
|
|
|
60438
60822
|
|
|
60439
60823
|
}
|
|
60440
60824
|
|
|
60441
|
-
if ( renderer.debug.view ===
|
|
60825
|
+
if ( renderer.debug.view === DEBUG_VIEW_OVERDRAW ) {
|
|
60442
60826
|
|
|
60443
60827
|
return vec4( colorizeQuadOverdraw( sampled.r ), 1 ).renderOutput( NoToneMapping, renderer.currentColorSpace );
|
|
60444
60828
|
|
|
@@ -64403,7 +64787,7 @@ class Renderer {
|
|
|
64403
64787
|
* @property {?Function} onNodeBuilderCreated - A callback function that is executed after a node builder has been created and before it is built.
|
|
64404
64788
|
* @property {?Function} onShaderError - A callback function that is executed when a shader error happens. Only supported with WebGL 2 right now.
|
|
64405
64789
|
* @property {Function} getShaderAsync - Allows the get the raw shader code for the given scene, camera and 3D object.
|
|
64406
|
-
* @property {string} view - Debug view. `shaderComplexity`, `lightingComplexity`, `
|
|
64790
|
+
* @property {string} view - Debug view. `shaderComplexity`, `lightingComplexity`, `overdraw`, and `shaderComplexityAndOverdraw` replace the shaded color with a heatmap. `shaderComplexityAndOverdraw` 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. `frontBackFace` draws both windings and tints the side facing the camera. `shadowCaster` lights a mesh green when it casts shadows and gray when it does not. `doubleSide` lights a single-sided surface gray, a visible double-sided back face blue, and a hidden double-sided back face red.
|
|
64407
64791
|
* @property {string} buffer - Channel drawn by `bufferVisualization`: `baseColor`, `worldNormal`, `roughness`, `metallic`, `ambientOcclusion`, or `emissive`.
|
|
64408
64792
|
* @property {number} shaderComplexityBudget - Proxy budget that fills the shader-complexity ramp.
|
|
64409
64793
|
* @property {number} quadOverdrawBudget - Overlapping fragments that fill the quad-overdraw ramp.
|
|
@@ -64426,6 +64810,8 @@ class Renderer {
|
|
|
64426
64810
|
buffer: DEFAULT_BUFFER,
|
|
64427
64811
|
shaderComplexityBudget: DEFAULT_SHADER_COMPLEXITY_BUDGET,
|
|
64428
64812
|
quadOverdrawBudget: DEFAULT_QUAD_OVERDRAW_BUDGET,
|
|
64813
|
+
doubleSideHidden: false,
|
|
64814
|
+
doubleSideBack: false,
|
|
64429
64815
|
// !WITH_GENESYS
|
|
64430
64816
|
getShaderAsync: async ( scene, camera, object ) => {
|
|
64431
64817
|
|
|
@@ -65646,6 +66032,10 @@ class Renderer {
|
|
|
65646
66032
|
if ( this.opaque === true && opaqueObjects.length > 0 ) this._renderObjects( opaqueObjects, camera, sceneRef, lightsNode );
|
|
65647
66033
|
if ( this.transparent === true && transparentObjects.length > 0 ) this._renderTransparents( transparentObjects, transparentDoublePassObjects, camera, sceneRef, lightsNode );
|
|
65648
66034
|
|
|
66035
|
+
// WITH_GENESYS
|
|
66036
|
+
this._renderDoubleSideHidden( opaqueObjects, transparentObjects, camera, sceneRef, lightsNode );
|
|
66037
|
+
// !WITH_GENESYS
|
|
66038
|
+
|
|
65649
66039
|
// finish render pass
|
|
65650
66040
|
|
|
65651
66041
|
this.backend.finishRender( renderContext );
|
|
@@ -66363,7 +66753,8 @@ class Renderer {
|
|
|
66363
66753
|
|
|
66364
66754
|
// WITH_GENESYS
|
|
66365
66755
|
// Accumulating views write a scalar into an intermediate target, then the output pass colorizes it.
|
|
66366
|
-
|
|
66756
|
+
// Only screen output needs one. An off-screen target, such as a scene pass, already is the target.
|
|
66757
|
+
return useToneMapping || useColorSpace || ( debugViewAccumulates( this.debug.view ) && this.isOutputTarget );
|
|
66367
66758
|
// !WITH_GENESYS
|
|
66368
66759
|
// return useToneMapping || useColorSpace;
|
|
66369
66760
|
|
|
@@ -66417,9 +66808,7 @@ class Renderer {
|
|
|
66417
66808
|
get currentToneMapping() {
|
|
66418
66809
|
|
|
66419
66810
|
// WITH_GENESYS
|
|
66420
|
-
|
|
66421
|
-
|
|
66422
|
-
if ( view === DEBUG_VIEW_SHADER_COMPLEXITY || view === DEBUG_VIEW_SHADER_COMPLEXITY_AND_QUADS || view === DEBUG_VIEW_LIGHTING_COMPLEXITY || view === DEBUG_VIEW_QUAD_OVERDRAW || view === DEBUG_VIEW_BUFFER ) {
|
|
66811
|
+
if ( debugViewSkipsToneMapping( this.debug.view ) ) {
|
|
66423
66812
|
|
|
66424
66813
|
return NoToneMapping;
|
|
66425
66814
|
|
|
@@ -67217,6 +67606,82 @@ class Renderer {
|
|
|
67217
67606
|
|
|
67218
67607
|
}
|
|
67219
67608
|
|
|
67609
|
+
// WITH_GENESYS
|
|
67610
|
+
/**
|
|
67611
|
+
* Paints a double-sided mesh red where its own front face is the nearest surface and the
|
|
67612
|
+
* mesh has faces pointing the other way. A different mesh in front keeps its own color.
|
|
67613
|
+
* A flat card has no opposing faces, so it stays gray or blue. A shadow pass is left alone.
|
|
67614
|
+
*
|
|
67615
|
+
* @private
|
|
67616
|
+
* @param {Array<Object>} opaqueObjects - The opaque render list.
|
|
67617
|
+
* @param {Array<Object>} transparentObjects - The transparent render list.
|
|
67618
|
+
* @param {Camera} camera - The camera.
|
|
67619
|
+
* @param {Scene} scene - The scene.
|
|
67620
|
+
* @param {LightsNode} lightsNode - The current lights node.
|
|
67621
|
+
*/
|
|
67622
|
+
_renderDoubleSideHidden( opaqueObjects, transparentObjects, camera, scene, lightsNode ) {
|
|
67623
|
+
|
|
67624
|
+
if ( this.debug.view !== DEBUG_VIEW_DOUBLE_SIDE ) return;
|
|
67625
|
+
|
|
67626
|
+
if ( scene.overrideMaterial !== null && scene.overrideMaterial.isShadowPassMaterial === true ) return;
|
|
67627
|
+
|
|
67628
|
+
const list = [];
|
|
67629
|
+
const saved = new Map();
|
|
67630
|
+
|
|
67631
|
+
const collect = ( objects ) => {
|
|
67632
|
+
|
|
67633
|
+
for ( let i = 0, l = objects.length; i < l; i ++ ) {
|
|
67634
|
+
|
|
67635
|
+
const entry = objects[ i ];
|
|
67636
|
+
const material = entry.material;
|
|
67637
|
+
const geometry = entry.object.geometry;
|
|
67638
|
+
|
|
67639
|
+
if ( entry.object.isMesh !== true || material.side !== DoubleSide || material.isShadowPassMaterial === true ) continue;
|
|
67640
|
+
|
|
67641
|
+
if ( geometry === undefined || meshCanHideOwnBack( geometry ) !== true ) continue;
|
|
67642
|
+
|
|
67643
|
+
list.push( entry );
|
|
67644
|
+
|
|
67645
|
+
if ( saved.has( material ) ) continue;
|
|
67646
|
+
|
|
67647
|
+
saved.set( material, {
|
|
67648
|
+
side: material.side,
|
|
67649
|
+
depthFunc: material.depthFunc,
|
|
67650
|
+
depthWrite: material.depthWrite
|
|
67651
|
+
} );
|
|
67652
|
+
|
|
67653
|
+
}
|
|
67654
|
+
|
|
67655
|
+
};
|
|
67656
|
+
|
|
67657
|
+
collect( opaqueObjects );
|
|
67658
|
+
collect( transparentObjects );
|
|
67659
|
+
|
|
67660
|
+
if ( list.length === 0 ) return;
|
|
67661
|
+
|
|
67662
|
+
for ( const material of saved.keys() ) {
|
|
67663
|
+
|
|
67664
|
+
material.side = FrontSide;
|
|
67665
|
+
material.depthFunc = EqualDepth;
|
|
67666
|
+
material.depthWrite = false;
|
|
67667
|
+
|
|
67668
|
+
}
|
|
67669
|
+
|
|
67670
|
+
this.debug.doubleSideHidden = true;
|
|
67671
|
+
this._renderObjects( list, camera, scene, lightsNode, 'doubleSideHidden' );
|
|
67672
|
+
this.debug.doubleSideHidden = false;
|
|
67673
|
+
|
|
67674
|
+
for ( const [ material, state ] of saved ) {
|
|
67675
|
+
|
|
67676
|
+
material.side = state.side;
|
|
67677
|
+
material.depthFunc = state.depthFunc;
|
|
67678
|
+
material.depthWrite = state.depthWrite;
|
|
67679
|
+
|
|
67680
|
+
}
|
|
67681
|
+
|
|
67682
|
+
}
|
|
67683
|
+
// !WITH_GENESYS
|
|
67684
|
+
|
|
67220
67685
|
/**
|
|
67221
67686
|
* Renders the transparent objects from the given render lists.
|
|
67222
67687
|
*
|
|
@@ -72498,7 +72963,7 @@ class WebGLState {
|
|
|
72498
72963
|
|
|
72499
72964
|
}
|
|
72500
72965
|
|
|
72501
|
-
setMRTBlending( textures, mrt, material ) {
|
|
72966
|
+
setMRTBlending( textures, mrt, material, object = null ) {
|
|
72502
72967
|
|
|
72503
72968
|
const gl = this.gl;
|
|
72504
72969
|
const drawBuffersIndexedExt = this.backend.drawBuffersIndexedExt;
|
|
@@ -72511,6 +72976,24 @@ class WebGLState {
|
|
|
72511
72976
|
|
|
72512
72977
|
}
|
|
72513
72978
|
|
|
72979
|
+
// WITH_GENESYS
|
|
72980
|
+
// Every attachment matches the single-target path. Opaque material blending would replace a sum that should add.
|
|
72981
|
+
if ( debugDrawAccumulates( this.backend.renderer, material, object ) ) {
|
|
72982
|
+
|
|
72983
|
+
const dst = debugDrawReplacesCost( this.backend.renderer.debug.view, material ) ? gl.ZERO : gl.ONE;
|
|
72984
|
+
|
|
72985
|
+
for ( let i = 0; i < textures.length; i ++ ) {
|
|
72986
|
+
|
|
72987
|
+
drawBuffersIndexedExt.blendEquationSeparateiOES( i, gl.FUNC_ADD, gl.FUNC_ADD );
|
|
72988
|
+
drawBuffersIndexedExt.blendFuncSeparateiOES( i, gl.ONE, dst, gl.ONE, gl.ZERO );
|
|
72989
|
+
|
|
72990
|
+
}
|
|
72991
|
+
|
|
72992
|
+
return;
|
|
72993
|
+
|
|
72994
|
+
}
|
|
72995
|
+
// !WITH_GENESYS
|
|
72996
|
+
|
|
72514
72997
|
for ( let i = 0; i < textures.length; i ++ ) {
|
|
72515
72998
|
|
|
72516
72999
|
const texture = textures[ i ];
|
|
@@ -73133,14 +73616,22 @@ class WebGLState {
|
|
|
73133
73616
|
* @param {Material} material - The material to configure the state for.
|
|
73134
73617
|
* @param {number} frontFaceCW - Whether the front faces are counter-clockwise or not.
|
|
73135
73618
|
* @param {number} hardwareClippingPlanes - The number of hardware clipping planes.
|
|
73619
|
+
* @param {?Object3D} [object=null] - The object being drawn. Used by the accumulating debug views.
|
|
73136
73620
|
*/
|
|
73137
|
-
setMaterial( material, frontFaceCW, hardwareClippingPlanes ) {
|
|
73621
|
+
setMaterial( material, frontFaceCW, hardwareClippingPlanes, object = null ) {
|
|
73138
73622
|
|
|
73139
73623
|
const { gl } = this;
|
|
73140
73624
|
|
|
73141
|
-
|
|
73625
|
+
// WITH_GENESYS
|
|
73626
|
+
const drawBothSides = material.side === DoubleSide || ( this.backend.renderer.debug.view === DEBUG_VIEW_FRONT_BACK_FACE && material.isShadowPassMaterial !== true );
|
|
73627
|
+
|
|
73628
|
+
drawBothSides
|
|
73142
73629
|
? this.disable( gl.CULL_FACE )
|
|
73143
73630
|
: this.enable( gl.CULL_FACE );
|
|
73631
|
+
// !WITH_GENESYS
|
|
73632
|
+
// material.side === DoubleSide
|
|
73633
|
+
// ? this.disable( gl.CULL_FACE )
|
|
73634
|
+
// : this.enable( gl.CULL_FACE );
|
|
73144
73635
|
|
|
73145
73636
|
let flipSided = ( material.side === BackSide );
|
|
73146
73637
|
if ( frontFaceCW ) flipSided = ! flipSided;
|
|
@@ -73148,10 +73639,13 @@ class WebGLState {
|
|
|
73148
73639
|
this.setFlipSided( flipSided );
|
|
73149
73640
|
|
|
73150
73641
|
// WITH_GENESYS
|
|
73151
|
-
// WebGL has no cached render pipeline.
|
|
73152
|
-
|
|
73642
|
+
// WebGL has no cached render pipeline. The accumulate blend is applied on each draw instead.
|
|
73643
|
+
// Alpha is replaced so it stays coverage, as in a shaded pass, for later compositing.
|
|
73644
|
+
if ( debugDrawAccumulates( this.backend.renderer, material, object ) ) {
|
|
73645
|
+
|
|
73646
|
+
const dstFactor = debugDrawReplacesCost( this.backend.renderer.debug.view, material ) ? ZeroFactor : OneFactor;
|
|
73153
73647
|
|
|
73154
|
-
this.setBlending(
|
|
73648
|
+
this.setBlending( CustomBlending, AddEquation, OneFactor, dstFactor, AddEquation, OneFactor, ZeroFactor, material.blendColor, material.blendAlpha, true );
|
|
73155
73649
|
|
|
73156
73650
|
} else if ( material.blending === NormalBlending && material.transparent === false ) {
|
|
73157
73651
|
|
|
@@ -77399,11 +77893,17 @@ class WebGLBackend extends Backend {
|
|
|
77399
77893
|
|
|
77400
77894
|
const frontFaceCW = ( object.isMesh && object.matrixWorld.determinantAffine() < 0 );
|
|
77401
77895
|
|
|
77402
|
-
|
|
77896
|
+
// WITH_GENESYS
|
|
77897
|
+
state.setMaterial( material, frontFaceCW, hardwareClippingPlanes, object );
|
|
77898
|
+
// !WITH_GENESYS
|
|
77899
|
+
// state.setMaterial( material, frontFaceCW, hardwareClippingPlanes );
|
|
77403
77900
|
|
|
77404
77901
|
if ( context.mrt !== null && context.textures !== null ) {
|
|
77405
77902
|
|
|
77406
|
-
|
|
77903
|
+
// WITH_GENESYS
|
|
77904
|
+
state.setMRTBlending( context.textures, context.mrt, material, object );
|
|
77905
|
+
// !WITH_GENESYS
|
|
77906
|
+
// state.setMRTBlending( context.textures, context.mrt, material );
|
|
77407
77907
|
|
|
77408
77908
|
}
|
|
77409
77909
|
|
|
@@ -87853,18 +88353,22 @@ class WebGPUPipelineUtils {
|
|
|
87853
88353
|
}
|
|
87854
88354
|
|
|
87855
88355
|
// WITH_GENESYS
|
|
87856
|
-
//
|
|
87857
|
-
|
|
88356
|
+
// Quad overdraw and translucent shader complexity add. Opaque shader complexity replaces
|
|
88357
|
+
// the stored cost, so the nearest surface wins without a depth pre-pass.
|
|
88358
|
+
// Alpha is replaced so it stays coverage, as in a shaded pass, for later compositing.
|
|
88359
|
+
if ( debugDrawAccumulates( backend.renderer, material, object ) ) {
|
|
88360
|
+
|
|
88361
|
+
const replaceCost = debugDrawReplacesCost( backend.renderer.debug.view, material );
|
|
87858
88362
|
|
|
87859
88363
|
materialBlending = {
|
|
87860
88364
|
color: {
|
|
87861
88365
|
srcFactor: GPUBlendFactor.One,
|
|
87862
|
-
dstFactor: GPUBlendFactor.One,
|
|
88366
|
+
dstFactor: replaceCost ? GPUBlendFactor.Zero : GPUBlendFactor.One,
|
|
87863
88367
|
operation: GPUBlendOperation.Add
|
|
87864
88368
|
},
|
|
87865
88369
|
alpha: {
|
|
87866
88370
|
srcFactor: GPUBlendFactor.One,
|
|
87867
|
-
dstFactor: GPUBlendFactor.
|
|
88371
|
+
dstFactor: GPUBlendFactor.Zero,
|
|
87868
88372
|
operation: GPUBlendOperation.Add
|
|
87869
88373
|
}
|
|
87870
88374
|
};
|
|
@@ -88685,7 +89189,12 @@ class WebGPUPipelineUtils {
|
|
|
88685
89189
|
|
|
88686
89190
|
//
|
|
88687
89191
|
|
|
88688
|
-
|
|
89192
|
+
// WITH_GENESYS
|
|
89193
|
+
// Front/back face draws both windings. Depth still hides a face behind the shell.
|
|
89194
|
+
const drawBothSides = material.side === DoubleSide || ( this.backend.renderer.debug.view === DEBUG_VIEW_FRONT_BACK_FACE && material.isShadowPassMaterial !== true );
|
|
89195
|
+
descriptor.cullMode = drawBothSides ? GPUCullMode.None : GPUCullMode.Back;
|
|
89196
|
+
// !WITH_GENESYS
|
|
89197
|
+
// descriptor.cullMode = ( material.side === DoubleSide ) ? GPUCullMode.None : GPUCullMode.Back;
|
|
88689
89198
|
|
|
88690
89199
|
return descriptor;
|
|
88691
89200
|
|
|
@@ -92932,6 +93441,8 @@ class BundleGroup extends Group {
|
|
|
92932
93441
|
|
|
92933
93442
|
}
|
|
92934
93443
|
|
|
93444
|
+
// !WITH_GENESYS
|
|
93445
|
+
|
|
92935
93446
|
/**
|
|
92936
93447
|
* This module is responsible to manage the rendering pipeline setups in apps.
|
|
92937
93448
|
* You usually create a single instance of this class and use it to define
|
|
@@ -93066,7 +93577,12 @@ class RenderPipeline {
|
|
|
93066
93577
|
const outputColorSpace = renderer.outputColorSpace;
|
|
93067
93578
|
|
|
93068
93579
|
renderer.toneMapping = NoToneMapping;
|
|
93069
|
-
|
|
93580
|
+
|
|
93581
|
+
// WITH_GENESYS
|
|
93582
|
+
// Accumulating views colorize in the renderer's output pass, which must still encode the color space.
|
|
93583
|
+
if ( debugViewAccumulates( renderer.debug.view ) !== true ) renderer.outputColorSpace = ColorManagement.workingColorSpace;
|
|
93584
|
+
// !WITH_GENESYS
|
|
93585
|
+
// renderer.outputColorSpace = ColorManagement.workingColorSpace;
|
|
93070
93586
|
|
|
93071
93587
|
//
|
|
93072
93588
|
|
|
@@ -93142,19 +93658,40 @@ class RenderPipeline {
|
|
|
93142
93658
|
*/
|
|
93143
93659
|
_update() {
|
|
93144
93660
|
|
|
93145
|
-
|
|
93661
|
+
// WITH_GENESYS
|
|
93662
|
+
// Debug views drawn without tone mapping must match the direct path. An accumulating
|
|
93663
|
+
// view copies the raw ratio here, and the renderer's output pass colorizes it.
|
|
93664
|
+
const view = this.renderer.debug.view;
|
|
93665
|
+
const toneMapping = debugViewSkipsToneMapping( view ) ? NoToneMapping : this.renderer.toneMapping;
|
|
93666
|
+
const outputColorSpace = debugViewAccumulates( view ) ? ColorManagement.workingColorSpace : this.renderer.outputColorSpace;
|
|
93667
|
+
|
|
93668
|
+
if ( this._toneMapping !== toneMapping ) {
|
|
93146
93669
|
|
|
93147
|
-
this._toneMapping =
|
|
93670
|
+
this._toneMapping = toneMapping;
|
|
93148
93671
|
this.needsUpdate = true;
|
|
93149
93672
|
|
|
93150
93673
|
}
|
|
93151
93674
|
|
|
93152
|
-
if ( this._outputColorSpace !==
|
|
93675
|
+
if ( this._outputColorSpace !== outputColorSpace ) {
|
|
93153
93676
|
|
|
93154
|
-
this._outputColorSpace =
|
|
93677
|
+
this._outputColorSpace = outputColorSpace;
|
|
93155
93678
|
this.needsUpdate = true;
|
|
93156
93679
|
|
|
93157
93680
|
}
|
|
93681
|
+
// !WITH_GENESYS
|
|
93682
|
+
// if ( this._toneMapping !== this.renderer.toneMapping ) {
|
|
93683
|
+
//
|
|
93684
|
+
// this._toneMapping = this.renderer.toneMapping;
|
|
93685
|
+
// this.needsUpdate = true;
|
|
93686
|
+
//
|
|
93687
|
+
// }
|
|
93688
|
+
//
|
|
93689
|
+
// if ( this._outputColorSpace !== this.renderer.outputColorSpace ) {
|
|
93690
|
+
//
|
|
93691
|
+
// this._outputColorSpace = this.renderer.outputColorSpace;
|
|
93692
|
+
// this.needsUpdate = true;
|
|
93693
|
+
//
|
|
93694
|
+
// }
|
|
93158
93695
|
|
|
93159
93696
|
if ( this.needsUpdate === true ) {
|
|
93160
93697
|
|