@plastic-software/three 0.181.3 → 0.182.0
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/README.md +3 -4
- package/build/three.cjs +1192 -522
- package/build/three.core.js +345 -219
- package/build/three.core.min.js +1 -1
- package/build/three.module.js +864 -328
- package/build/three.module.min.js +1 -1
- package/build/three.tsl.js +15 -3
- package/build/three.tsl.min.js +1 -1
- package/build/three.webgpu.js +3660 -1545
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +3659 -1544
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/controls/MapControls.js +55 -1
- package/examples/jsm/controls/OrbitControls.js +6 -6
- package/examples/jsm/controls/TrackballControls.js +6 -6
- package/examples/jsm/csm/CSM.js +2 -1
- package/examples/jsm/environments/RoomEnvironment.js +2 -0
- package/examples/jsm/geometries/DecalGeometry.js +1 -1
- package/examples/jsm/helpers/LightProbeHelperGPU.js +1 -1
- package/examples/jsm/helpers/TextureHelperGPU.js +1 -1
- package/examples/jsm/inspector/Inspector.js +53 -9
- package/examples/jsm/inspector/RendererInspector.js +12 -2
- package/examples/jsm/inspector/tabs/Console.js +2 -2
- package/examples/jsm/inspector/tabs/Parameters.js +2 -2
- package/examples/jsm/inspector/tabs/Performance.js +2 -2
- package/examples/jsm/inspector/tabs/Viewer.js +4 -4
- package/examples/jsm/inspector/ui/Profiler.js +1836 -31
- package/examples/jsm/inspector/ui/Style.js +948 -13
- package/examples/jsm/inspector/ui/Tab.js +188 -1
- package/examples/jsm/inspector/ui/Values.js +17 -1
- package/examples/jsm/loaders/3DMLoader.js +5 -4
- package/examples/jsm/loaders/DRACOLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +0 -2
- package/examples/jsm/loaders/HDRLoader.js +0 -1
- package/examples/jsm/loaders/KTX2Loader.js +16 -0
- package/examples/jsm/loaders/LDrawLoader.js +2 -3
- package/examples/jsm/loaders/PCDLoader.js +1 -0
- package/examples/jsm/loaders/SVGLoader.js +1 -1
- package/examples/jsm/loaders/TDSLoader.js +0 -2
- package/examples/jsm/loaders/TGALoader.js +0 -2
- package/examples/jsm/loaders/UltraHDRLoader.js +110 -137
- package/examples/jsm/loaders/VOXLoader.js +660 -117
- package/examples/jsm/loaders/VRMLLoader.js +2 -2
- package/examples/jsm/loaders/usd/USDCParser.js +1 -1
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +1 -1
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -1
- package/examples/jsm/materials/WoodNodeMaterial.js +11 -11
- package/examples/jsm/math/Octree.js +131 -1
- package/examples/jsm/misc/Volume.js +0 -1
- package/examples/jsm/misc/VolumeSlice.js +0 -1
- package/examples/jsm/objects/SkyMesh.js +13 -3
- package/examples/jsm/physics/AmmoPhysics.js +12 -7
- package/examples/jsm/physics/JoltPhysics.js +3 -1
- package/examples/jsm/physics/RapierPhysics.js +3 -1
- package/examples/jsm/postprocessing/OutputPass.js +9 -0
- package/examples/jsm/postprocessing/RenderPass.js +10 -0
- package/examples/jsm/postprocessing/UnrealBloomPass.js +48 -18
- package/examples/jsm/renderers/Projector.js +268 -30
- package/examples/jsm/renderers/SVGRenderer.js +191 -58
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -4
- package/examples/jsm/transpiler/AST.js +44 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +61 -4
- package/examples/jsm/transpiler/ShaderToyDecoder.js +2 -0
- package/examples/jsm/transpiler/TSLEncoder.js +46 -3
- package/examples/jsm/transpiler/TranspilerUtils.js +3 -3
- package/examples/jsm/transpiler/WGSLEncoder.js +27 -0
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +2 -0
- package/examples/jsm/tsl/display/BloomNode.js +11 -1
- package/examples/jsm/tsl/display/GTAONode.js +3 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +2 -1
- package/examples/jsm/tsl/display/SSGINode.js +7 -19
- package/examples/jsm/tsl/display/SSRNode.js +1 -1
- package/examples/jsm/tsl/display/SSSNode.js +4 -2
- package/examples/jsm/tsl/display/StereoCompositePassNode.js +8 -1
- package/examples/jsm/tsl/display/TRAANode.js +265 -114
- package/examples/jsm/tsl/display/radialBlur.js +68 -0
- package/examples/jsm/utils/ShadowMapViewer.js +24 -10
- package/examples/jsm/utils/ShadowMapViewerGPU.js +1 -1
- package/examples/jsm/utils/WebGPUTextureUtils.js +1 -1
- package/package.json +14 -12
- package/src/Three.Core.js +1 -0
- package/src/Three.TSL.js +14 -2
- package/src/animation/AnimationUtils.js +1 -12
- package/src/animation/KeyframeTrack.js +1 -1
- package/src/animation/tracks/BooleanKeyframeTrack.js +1 -1
- package/src/animation/tracks/ColorKeyframeTrack.js +1 -1
- package/src/animation/tracks/NumberKeyframeTrack.js +1 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -1
- package/src/animation/tracks/StringKeyframeTrack.js +1 -1
- package/src/animation/tracks/VectorKeyframeTrack.js +1 -1
- package/src/constants.js +61 -5
- package/src/core/BufferGeometry.js +14 -2
- package/src/core/Raycaster.js +2 -2
- package/src/extras/PMREMGenerator.js +3 -10
- package/src/extras/TextureUtils.js +5 -1
- package/src/geometries/ExtrudeGeometry.js +2 -2
- package/src/geometries/PolyhedronGeometry.js +1 -1
- package/src/helpers/PointLightHelper.js +1 -1
- package/src/lights/DirectionalLight.js +13 -0
- package/src/lights/HemisphereLight.js +10 -0
- package/src/lights/Light.js +1 -11
- package/src/lights/LightProbe.js +0 -15
- package/src/lights/LightShadow.js +0 -3
- package/src/lights/PointLight.js +15 -0
- package/src/lights/PointLightShadow.js +0 -86
- package/src/lights/SpotLight.js +22 -1
- package/src/loaders/MaterialLoader.js +2 -1
- package/src/loaders/ObjectLoader.js +3 -1
- package/src/loaders/nodes/NodeLoader.js +2 -2
- package/src/materials/Material.js +2 -0
- package/src/materials/ShaderMaterial.js +20 -1
- package/src/materials/nodes/Line2NodeMaterial.js +2 -2
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +3 -2
- package/src/materials/nodes/MeshStandardNodeMaterial.js +5 -4
- package/src/materials/nodes/NodeMaterial.js +59 -3
- package/src/materials/nodes/manager/NodeMaterialObserver.js +1 -1
- package/src/math/Matrix4.js +40 -40
- package/src/math/Sphere.js +1 -1
- package/src/math/Vector3.js +0 -2
- package/src/nodes/TSL.js +4 -1
- package/src/nodes/accessors/BatchNode.js +10 -10
- package/src/nodes/accessors/BufferAttributeNode.js +98 -12
- package/src/nodes/accessors/BufferNode.js +29 -2
- package/src/nodes/accessors/ClippingNode.js +4 -4
- package/src/nodes/accessors/CubeTextureNode.js +20 -1
- package/src/nodes/accessors/InstanceNode.js +69 -29
- package/src/nodes/accessors/MaterialNode.js +9 -1
- package/src/nodes/accessors/MaterialReferenceNode.js +1 -2
- package/src/nodes/accessors/ModelNode.js +1 -1
- package/src/nodes/accessors/Normal.js +2 -2
- package/src/nodes/accessors/ReferenceBaseNode.js +4 -4
- package/src/nodes/accessors/ReferenceNode.js +4 -4
- package/src/nodes/accessors/RendererReferenceNode.js +1 -2
- package/src/nodes/accessors/SkinningNode.js +15 -2
- package/src/nodes/accessors/StorageBufferNode.js +4 -2
- package/src/nodes/accessors/Tangent.js +1 -11
- package/src/nodes/accessors/Texture3DNode.js +26 -1
- package/src/nodes/accessors/UniformArrayNode.js +2 -2
- package/src/nodes/accessors/UserDataNode.js +1 -2
- package/src/nodes/accessors/VertexColorNode.js +1 -2
- package/src/nodes/code/FunctionNode.js +1 -2
- package/src/nodes/core/ArrayNode.js +20 -1
- package/src/nodes/core/AssignNode.js +2 -2
- package/src/nodes/core/AttributeNode.js +2 -2
- package/src/nodes/core/ContextNode.js +103 -4
- package/src/nodes/core/NodeBuilder.js +56 -14
- package/src/nodes/core/NodeFrame.js +12 -4
- package/src/nodes/core/NodeUtils.js +5 -5
- package/src/nodes/core/ParameterNode.js +1 -2
- package/src/nodes/core/PropertyNode.js +19 -3
- package/src/nodes/core/StackNode.js +56 -8
- package/src/nodes/core/StructNode.js +1 -2
- package/src/nodes/core/StructTypeNode.js +11 -17
- package/src/nodes/core/UniformNode.js +19 -4
- package/src/nodes/core/VarNode.js +46 -21
- package/src/nodes/display/NormalMapNode.js +37 -2
- package/src/nodes/display/PassNode.js +77 -7
- package/src/nodes/display/ScreenNode.js +1 -0
- package/src/nodes/functions/BSDF/BRDF_GGX_Multiscatter.js +3 -3
- package/src/nodes/functions/BSDF/DFGLUT.js +56 -0
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +1 -1
- package/src/nodes/functions/PhysicalLightingModel.js +102 -43
- package/src/nodes/gpgpu/ComputeBuiltinNode.js +1 -2
- package/src/nodes/gpgpu/SubgroupFunctionNode.js +1 -1
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -3
- package/src/nodes/lighting/AnalyticLightNode.js +53 -0
- package/src/nodes/lighting/LightsNode.js +2 -2
- package/src/nodes/lighting/PointShadowNode.js +141 -140
- package/src/nodes/lighting/ShadowFilterNode.js +53 -37
- package/src/nodes/lighting/ShadowNode.js +53 -19
- package/src/nodes/math/BitcountNode.js +433 -0
- package/src/nodes/math/PackFloatNode.js +98 -0
- package/src/nodes/math/UnpackFloatNode.js +96 -0
- package/src/nodes/pmrem/PMREMNode.js +1 -1
- package/src/nodes/tsl/TSLCore.js +4 -4
- package/src/nodes/utils/ArrayElementNode.js +13 -0
- package/src/nodes/utils/EventNode.js +1 -2
- package/src/nodes/utils/Packing.js +13 -1
- package/src/nodes/utils/PostProcessingUtils.js +33 -1
- package/src/nodes/utils/ReflectorNode.js +1 -1
- package/src/nodes/utils/SampleNode.js +1 -1
- package/src/nodes/utils/UVUtils.js +26 -0
- package/src/objects/BatchedMesh.js +5 -2
- package/src/objects/Line.js +1 -1
- package/src/objects/Mesh.js +1 -1
- package/src/objects/Points.js +1 -1
- package/src/objects/Skeleton.js +9 -0
- package/src/renderers/WebGLRenderer.js +145 -33
- package/src/renderers/common/Backend.js +8 -0
- package/src/renderers/common/Background.js +19 -9
- package/src/renderers/common/Binding.js +11 -0
- package/src/renderers/common/Bindings.js +7 -7
- package/src/renderers/common/Buffer.js +40 -0
- package/src/renderers/common/ChainMap.js +30 -6
- package/src/renderers/common/Geometries.js +12 -0
- package/src/renderers/common/RenderContexts.js +8 -1
- package/src/renderers/common/RenderObject.js +14 -1
- package/src/renderers/common/Renderer.js +53 -35
- package/src/renderers/common/Textures.js +1 -1
- package/src/renderers/common/UniformsGroup.js +1 -0
- package/src/renderers/common/XRManager.js +1 -0
- package/src/renderers/common/extras/PMREMGenerator.js +2 -8
- package/src/renderers/common/nodes/NodeUniformBuffer.js +52 -0
- package/src/renderers/shaders/DFGLUTData.js +19 -34
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +5 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +8 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +90 -51
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +194 -186
- package/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk.js +3 -3
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/{distanceRGBA.glsl.js → distance.glsl.js} +1 -2
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +1 -2
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -9
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +0 -1
- package/src/renderers/shaders/ShaderLib/vsm.glsl.js +4 -6
- package/src/renderers/shaders/ShaderLib.js +3 -3
- package/src/renderers/webgl/WebGLCapabilities.js +3 -4
- package/src/renderers/webgl/WebGLLights.js +18 -1
- package/src/renderers/webgl/WebGLOutput.js +267 -0
- package/src/renderers/webgl/WebGLProgram.js +43 -107
- package/src/renderers/webgl/WebGLPrograms.js +35 -45
- package/src/renderers/webgl/WebGLShadowMap.js +188 -25
- package/src/renderers/webgl/WebGLState.js +20 -20
- package/src/renderers/webgl/WebGLTextures.js +89 -28
- package/src/renderers/webgl/WebGLUniforms.js +40 -3
- package/src/renderers/webgl/WebGLUtils.js +6 -2
- package/src/renderers/webgl-fallback/WebGLBackend.js +79 -13
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +59 -7
- package/src/renderers/webgl-fallback/utils/WebGLState.js +18 -3
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +5 -3
- package/src/renderers/webgl-fallback/utils/WebGLTimestampQueryPool.js +9 -9
- package/src/renderers/webgl-fallback/utils/WebGLUtils.js +6 -2
- package/src/renderers/webgpu/WebGPUBackend.js +61 -4
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +65 -23
- package/src/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -17
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +354 -186
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -0
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +20 -7
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +40 -17
- package/src/renderers/webgpu/utils/WebGPUTimestampQueryPool.js +7 -7
- package/src/renderers/webgpu/utils/WebGPUUtils.js +7 -5
- package/src/textures/CubeDepthTexture.js +76 -0
- package/src/textures/Source.js +1 -1
- package/src/textures/Texture.js +1 -1
- package/src/utils.js +13 -1
- package/src/nodes/functions/BSDF/DFGApprox.js +0 -71
|
@@ -15,7 +15,16 @@ export default /* glsl */`
|
|
|
15
15
|
|
|
16
16
|
#if NUM_DIR_LIGHT_SHADOWS > 0
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
#if defined( SHADOWMAP_TYPE_PCF )
|
|
19
|
+
|
|
20
|
+
uniform sampler2DShadow directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
21
|
+
|
|
22
|
+
#else
|
|
23
|
+
|
|
24
|
+
uniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];
|
|
25
|
+
|
|
26
|
+
#endif
|
|
27
|
+
|
|
19
28
|
varying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];
|
|
20
29
|
|
|
21
30
|
struct DirectionalLightShadow {
|
|
@@ -32,7 +41,15 @@ export default /* glsl */`
|
|
|
32
41
|
|
|
33
42
|
#if NUM_SPOT_LIGHT_SHADOWS > 0
|
|
34
43
|
|
|
35
|
-
|
|
44
|
+
#if defined( SHADOWMAP_TYPE_PCF )
|
|
45
|
+
|
|
46
|
+
uniform sampler2DShadow spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
47
|
+
|
|
48
|
+
#else
|
|
49
|
+
|
|
50
|
+
uniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];
|
|
51
|
+
|
|
52
|
+
#endif
|
|
36
53
|
|
|
37
54
|
struct SpotLightShadow {
|
|
38
55
|
float shadowIntensity;
|
|
@@ -48,7 +65,16 @@ export default /* glsl */`
|
|
|
48
65
|
|
|
49
66
|
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
50
67
|
|
|
51
|
-
|
|
68
|
+
#if defined( SHADOWMAP_TYPE_PCF )
|
|
69
|
+
|
|
70
|
+
uniform samplerCubeShadow pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
71
|
+
|
|
72
|
+
#elif defined( SHADOWMAP_TYPE_BASIC )
|
|
73
|
+
|
|
74
|
+
uniform samplerCube pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];
|
|
75
|
+
|
|
76
|
+
#endif
|
|
77
|
+
|
|
52
78
|
varying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];
|
|
53
79
|
|
|
54
80
|
struct PointLightShadow {
|
|
@@ -65,265 +91,243 @@ export default /* glsl */`
|
|
|
65
91
|
|
|
66
92
|
#endif
|
|
67
93
|
|
|
68
|
-
|
|
94
|
+
#if defined( SHADOWMAP_TYPE_PCF )
|
|
69
95
|
|
|
70
|
-
|
|
96
|
+
// Interleaved Gradient Noise for randomizing sampling patterns
|
|
97
|
+
float interleavedGradientNoise( vec2 position ) {
|
|
71
98
|
|
|
72
|
-
|
|
99
|
+
return fract( 52.9829189 * fract( dot( position, vec2( 0.06711056, 0.00583715 ) ) ) );
|
|
73
100
|
|
|
74
|
-
|
|
101
|
+
}
|
|
75
102
|
|
|
76
|
-
|
|
103
|
+
// Vogel disk sampling for uniform circular distribution
|
|
104
|
+
vec2 vogelDiskSample( int sampleIndex, int samplesCount, float phi ) {
|
|
77
105
|
|
|
78
|
-
|
|
106
|
+
const float goldenAngle = 2.399963229728653;
|
|
107
|
+
float r = sqrt( ( float( sampleIndex ) + 0.5 ) / float( samplesCount ) );
|
|
108
|
+
float theta = float( sampleIndex ) * goldenAngle + phi;
|
|
109
|
+
return vec2( cos( theta ), sin( theta ) ) * r;
|
|
79
110
|
|
|
80
|
-
|
|
111
|
+
}
|
|
81
112
|
|
|
82
|
-
|
|
113
|
+
#endif
|
|
83
114
|
|
|
84
|
-
|
|
115
|
+
#if defined( SHADOWMAP_TYPE_PCF )
|
|
85
116
|
|
|
86
|
-
|
|
117
|
+
float getShadow( sampler2DShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
87
118
|
|
|
88
|
-
|
|
119
|
+
float shadow = 1.0;
|
|
89
120
|
|
|
90
|
-
|
|
121
|
+
shadowCoord.xyz /= shadowCoord.w;
|
|
122
|
+
shadowCoord.z += shadowBias;
|
|
91
123
|
|
|
92
|
-
|
|
124
|
+
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
125
|
+
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
93
126
|
|
|
94
|
-
|
|
127
|
+
if ( frustumTest ) {
|
|
95
128
|
|
|
96
|
-
|
|
129
|
+
// Hardware PCF with LinearFilter gives us 4-tap filtering per sample
|
|
130
|
+
// 5 samples using Vogel disk + IGN = effectively 20 filtered taps with better distribution
|
|
131
|
+
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
132
|
+
float radius = shadowRadius * texelSize.x;
|
|
97
133
|
|
|
98
|
-
|
|
134
|
+
// Use IGN to rotate sampling pattern per pixel
|
|
135
|
+
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718; // 2*PI
|
|
99
136
|
|
|
100
|
-
|
|
137
|
+
shadow = (
|
|
138
|
+
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 0, 5, phi ) * radius, shadowCoord.z ) ) +
|
|
139
|
+
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 1, 5, phi ) * radius, shadowCoord.z ) ) +
|
|
140
|
+
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 2, 5, phi ) * radius, shadowCoord.z ) ) +
|
|
141
|
+
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 3, 5, phi ) * radius, shadowCoord.z ) ) +
|
|
142
|
+
texture( shadowMap, vec3( shadowCoord.xy + vogelDiskSample( 4, 5, phi ) * radius, shadowCoord.z ) )
|
|
143
|
+
) * 0.2;
|
|
101
144
|
|
|
102
|
-
|
|
145
|
+
}
|
|
103
146
|
|
|
104
|
-
|
|
147
|
+
return mix( 1.0, shadow, shadowIntensity );
|
|
105
148
|
|
|
106
|
-
|
|
149
|
+
}
|
|
107
150
|
|
|
108
|
-
|
|
109
|
-
float variance = max( 0.00000, distribution.y * distribution.y );
|
|
110
|
-
float softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality
|
|
111
|
-
softness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed
|
|
112
|
-
occlusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );
|
|
151
|
+
#elif defined( SHADOWMAP_TYPE_VSM )
|
|
113
152
|
|
|
114
|
-
|
|
115
|
-
return occlusion;
|
|
153
|
+
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
116
154
|
|
|
117
|
-
|
|
155
|
+
float shadow = 1.0;
|
|
118
156
|
|
|
119
|
-
|
|
157
|
+
shadowCoord.xyz /= shadowCoord.w;
|
|
158
|
+
shadowCoord.z += shadowBias;
|
|
120
159
|
|
|
121
|
-
|
|
160
|
+
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
161
|
+
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
122
162
|
|
|
123
|
-
|
|
124
|
-
shadowCoord.z += shadowBias;
|
|
163
|
+
if ( frustumTest ) {
|
|
125
164
|
|
|
126
|
-
|
|
127
|
-
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
165
|
+
vec2 distribution = texture2D( shadowMap, shadowCoord.xy ).rg;
|
|
128
166
|
|
|
129
|
-
|
|
167
|
+
float mean = distribution.x;
|
|
168
|
+
float variance = distribution.y * distribution.y;
|
|
130
169
|
|
|
131
|
-
|
|
170
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
132
171
|
|
|
133
|
-
|
|
172
|
+
float hard_shadow = step( mean, shadowCoord.z );
|
|
134
173
|
|
|
135
|
-
|
|
136
|
-
float dy0 = - texelSize.y * shadowRadius;
|
|
137
|
-
float dx1 = + texelSize.x * shadowRadius;
|
|
138
|
-
float dy1 = + texelSize.y * shadowRadius;
|
|
139
|
-
float dx2 = dx0 / 2.0;
|
|
140
|
-
float dy2 = dy0 / 2.0;
|
|
141
|
-
float dx3 = dx1 / 2.0;
|
|
142
|
-
float dy3 = dy1 / 2.0;
|
|
174
|
+
#else
|
|
143
175
|
|
|
144
|
-
|
|
145
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +
|
|
146
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +
|
|
147
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +
|
|
148
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +
|
|
149
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +
|
|
150
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +
|
|
151
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +
|
|
152
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +
|
|
153
|
-
texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +
|
|
154
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +
|
|
155
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +
|
|
156
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +
|
|
157
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +
|
|
158
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +
|
|
159
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +
|
|
160
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +
|
|
161
|
-
texture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )
|
|
162
|
-
) * ( 1.0 / 17.0 );
|
|
163
|
-
|
|
164
|
-
#elif defined( SHADOWMAP_TYPE_PCF_SOFT )
|
|
165
|
-
|
|
166
|
-
vec2 texelSize = vec2( 1.0 ) / shadowMapSize;
|
|
167
|
-
float dx = texelSize.x;
|
|
168
|
-
float dy = texelSize.y;
|
|
169
|
-
|
|
170
|
-
vec2 uv = shadowCoord.xy;
|
|
171
|
-
vec2 f = fract( uv * shadowMapSize + 0.5 );
|
|
172
|
-
uv -= f * texelSize;
|
|
176
|
+
float hard_shadow = step( shadowCoord.z, mean );
|
|
173
177
|
|
|
174
|
-
|
|
175
|
-
texture2DCompare( shadowMap, uv, shadowCoord.z ) +
|
|
176
|
-
texture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +
|
|
177
|
-
texture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +
|
|
178
|
-
texture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +
|
|
179
|
-
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ),
|
|
180
|
-
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),
|
|
181
|
-
f.x ) +
|
|
182
|
-
mix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ),
|
|
183
|
-
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),
|
|
184
|
-
f.x ) +
|
|
185
|
-
mix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ),
|
|
186
|
-
texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),
|
|
187
|
-
f.y ) +
|
|
188
|
-
mix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ),
|
|
189
|
-
texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),
|
|
190
|
-
f.y ) +
|
|
191
|
-
mix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ),
|
|
192
|
-
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),
|
|
193
|
-
f.x ),
|
|
194
|
-
mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ),
|
|
195
|
-
texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),
|
|
196
|
-
f.x ),
|
|
197
|
-
f.y )
|
|
198
|
-
) * ( 1.0 / 9.0 );
|
|
199
|
-
|
|
200
|
-
#elif defined( SHADOWMAP_TYPE_VSM )
|
|
201
|
-
|
|
202
|
-
shadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
203
|
-
|
|
204
|
-
#else // no percentage-closer filtering:
|
|
205
|
-
|
|
206
|
-
shadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );
|
|
178
|
+
#endif
|
|
207
179
|
|
|
208
|
-
|
|
180
|
+
// Early return if fully lit
|
|
181
|
+
if ( hard_shadow == 1.0 ) {
|
|
209
182
|
|
|
210
|
-
|
|
183
|
+
shadow = 1.0;
|
|
211
184
|
|
|
212
|
-
|
|
185
|
+
} else {
|
|
213
186
|
|
|
214
|
-
|
|
187
|
+
// Variance must be non-zero to avoid division by zero
|
|
188
|
+
variance = max( variance, 0.0000001 );
|
|
189
|
+
|
|
190
|
+
// Distance from mean
|
|
191
|
+
float d = shadowCoord.z - mean;
|
|
192
|
+
|
|
193
|
+
// Chebyshev's inequality for upper bound on probability
|
|
194
|
+
float p_max = variance / ( variance + d * d );
|
|
215
195
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
// 2D texture:
|
|
219
|
-
//
|
|
220
|
-
// xzXZ
|
|
221
|
-
// y Y
|
|
222
|
-
//
|
|
223
|
-
// Y - Positive y direction
|
|
224
|
-
// y - Negative y direction
|
|
225
|
-
// X - Positive x direction
|
|
226
|
-
// x - Negative x direction
|
|
227
|
-
// Z - Positive z direction
|
|
228
|
-
// z - Negative z direction
|
|
229
|
-
//
|
|
230
|
-
// Source and test bed:
|
|
231
|
-
// https://gist.github.com/tschw/da10c43c467ce8afd0c4
|
|
196
|
+
// Reduce light bleeding by remapping [amount, 1] to [0, 1]
|
|
197
|
+
p_max = clamp( ( p_max - 0.3 ) / 0.65, 0.0, 1.0 );
|
|
232
198
|
|
|
233
|
-
|
|
199
|
+
shadow = max( hard_shadow, p_max );
|
|
234
200
|
|
|
235
|
-
|
|
201
|
+
}
|
|
236
202
|
|
|
237
|
-
|
|
203
|
+
}
|
|
238
204
|
|
|
239
|
-
|
|
205
|
+
return mix( 1.0, shadow, shadowIntensity );
|
|
240
206
|
|
|
241
|
-
|
|
242
|
-
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
#else // SHADOWMAP_TYPE_BASIC
|
|
210
|
+
|
|
211
|
+
float getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord ) {
|
|
243
212
|
|
|
244
|
-
|
|
213
|
+
float shadow = 1.0;
|
|
245
214
|
|
|
246
|
-
|
|
247
|
-
|
|
215
|
+
shadowCoord.xyz /= shadowCoord.w;
|
|
216
|
+
shadowCoord.z += shadowBias;
|
|
248
217
|
|
|
249
|
-
|
|
218
|
+
bool inFrustum = shadowCoord.x >= 0.0 && shadowCoord.x <= 1.0 && shadowCoord.y >= 0.0 && shadowCoord.y <= 1.0;
|
|
219
|
+
bool frustumTest = inFrustum && shadowCoord.z <= 1.0;
|
|
250
220
|
|
|
251
|
-
|
|
252
|
-
//
|
|
253
|
-
// #X## dim := ( 4 , 2 )
|
|
254
|
-
// # # center := ( 1 , 1 )
|
|
221
|
+
if ( frustumTest ) {
|
|
255
222
|
|
|
256
|
-
|
|
223
|
+
float depth = texture2D( shadowMap, shadowCoord.xy ).r;
|
|
257
224
|
|
|
258
|
-
|
|
259
|
-
float almostOne = 1.0 - almostATexel;
|
|
225
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
260
226
|
|
|
261
|
-
|
|
227
|
+
shadow = step( depth, shadowCoord.z );
|
|
262
228
|
|
|
263
|
-
|
|
264
|
-
planar.x = 4.0 - v.x;
|
|
229
|
+
#else
|
|
265
230
|
|
|
266
|
-
|
|
231
|
+
shadow = step( shadowCoord.z, depth );
|
|
267
232
|
|
|
268
|
-
|
|
269
|
-
planar.x = v.z * signX + 2.0 * signX;
|
|
233
|
+
#endif
|
|
270
234
|
|
|
271
|
-
|
|
235
|
+
}
|
|
272
236
|
|
|
273
|
-
|
|
274
|
-
planar.x = v.x + 2.0 * signY + 2.0;
|
|
275
|
-
planar.y = v.z * signY - 2.0;
|
|
237
|
+
return mix( 1.0, shadow, shadowIntensity );
|
|
276
238
|
|
|
277
239
|
}
|
|
278
240
|
|
|
279
|
-
|
|
241
|
+
#endif
|
|
280
242
|
|
|
281
|
-
|
|
282
|
-
// translate := ( center + 0.5 ) / dim
|
|
283
|
-
return vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );
|
|
243
|
+
#if NUM_POINT_LIGHT_SHADOWS > 0
|
|
284
244
|
|
|
285
|
-
|
|
245
|
+
#if defined( SHADOWMAP_TYPE_PCF )
|
|
286
246
|
|
|
287
|
-
float getPointShadow(
|
|
247
|
+
float getPointShadow( samplerCubeShadow shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
288
248
|
|
|
289
249
|
float shadow = 1.0;
|
|
290
250
|
|
|
291
251
|
// for point lights, the uniform @vShadowCoord is re-purposed to hold
|
|
292
252
|
// the vector from the light to the world-space position of the fragment.
|
|
293
253
|
vec3 lightToPosition = shadowCoord.xyz;
|
|
294
|
-
|
|
295
|
-
float lightToPositionLength = length( lightToPosition );
|
|
296
254
|
|
|
297
|
-
|
|
255
|
+
// Direction from light to fragment
|
|
256
|
+
vec3 bd3D = normalize( lightToPosition );
|
|
257
|
+
|
|
258
|
+
// For cube shadow maps, depth is stored as distance along each face's view axis, not radial distance
|
|
259
|
+
// The view-space depth is the maximum component of the direction vector (which face is sampled)
|
|
260
|
+
vec3 absVec = abs( lightToPosition );
|
|
261
|
+
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
|
|
262
|
+
|
|
263
|
+
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
|
|
298
264
|
|
|
299
|
-
//
|
|
300
|
-
|
|
265
|
+
// Calculate perspective depth for cube shadow map
|
|
266
|
+
// Standard perspective depth formula: depth = (far * (z - near)) / (z * (far - near))
|
|
267
|
+
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
|
|
301
268
|
dp += shadowBias;
|
|
302
269
|
|
|
303
|
-
//
|
|
304
|
-
|
|
270
|
+
// Hardware PCF with LinearFilter gives us 4-tap filtering per sample
|
|
271
|
+
// Use Vogel disk + IGN sampling for better quality
|
|
272
|
+
float texelSize = shadowRadius / shadowMapSize.x;
|
|
305
273
|
|
|
306
|
-
|
|
274
|
+
// Build a tangent-space coordinate system for applying offsets
|
|
275
|
+
vec3 absDir = abs( bd3D );
|
|
276
|
+
vec3 tangent = absDir.x > absDir.z ? vec3( 0.0, 1.0, 0.0 ) : vec3( 1.0, 0.0, 0.0 );
|
|
277
|
+
tangent = normalize( cross( bd3D, tangent ) );
|
|
278
|
+
vec3 bitangent = cross( bd3D, tangent );
|
|
307
279
|
|
|
308
|
-
|
|
280
|
+
// Use IGN to rotate sampling pattern per pixel
|
|
281
|
+
float phi = interleavedGradientNoise( gl_FragCoord.xy ) * 6.28318530718;
|
|
309
282
|
|
|
310
|
-
|
|
283
|
+
shadow = (
|
|
284
|
+
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 0, 5, phi ).x + bitangent * vogelDiskSample( 0, 5, phi ).y ) * texelSize, dp ) ) +
|
|
285
|
+
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 1, 5, phi ).x + bitangent * vogelDiskSample( 1, 5, phi ).y ) * texelSize, dp ) ) +
|
|
286
|
+
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 2, 5, phi ).x + bitangent * vogelDiskSample( 2, 5, phi ).y ) * texelSize, dp ) ) +
|
|
287
|
+
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 3, 5, phi ).x + bitangent * vogelDiskSample( 3, 5, phi ).y ) * texelSize, dp ) ) +
|
|
288
|
+
texture( shadowMap, vec4( bd3D + ( tangent * vogelDiskSample( 4, 5, phi ).x + bitangent * vogelDiskSample( 4, 5, phi ).y ) * texelSize, dp ) )
|
|
289
|
+
) * 0.2;
|
|
311
290
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +
|
|
318
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +
|
|
319
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +
|
|
320
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +
|
|
321
|
-
texture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )
|
|
322
|
-
) * ( 1.0 / 9.0 );
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return mix( 1.0, shadow, shadowIntensity );
|
|
294
|
+
|
|
295
|
+
}
|
|
323
296
|
|
|
324
|
-
|
|
297
|
+
#elif defined( SHADOWMAP_TYPE_BASIC )
|
|
325
298
|
|
|
326
|
-
|
|
299
|
+
float getPointShadow( samplerCube shadowMap, vec2 shadowMapSize, float shadowIntensity, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {
|
|
300
|
+
|
|
301
|
+
float shadow = 1.0;
|
|
302
|
+
|
|
303
|
+
// for point lights, the uniform @vShadowCoord is re-purposed to hold
|
|
304
|
+
// the vector from the light to the world-space position of the fragment.
|
|
305
|
+
vec3 lightToPosition = shadowCoord.xyz;
|
|
306
|
+
|
|
307
|
+
// Direction from light to fragment
|
|
308
|
+
vec3 bd3D = normalize( lightToPosition );
|
|
309
|
+
|
|
310
|
+
// For cube shadow maps, depth is stored as distance along each face's view axis, not radial distance
|
|
311
|
+
// The view-space depth is the maximum component of the direction vector (which face is sampled)
|
|
312
|
+
vec3 absVec = abs( lightToPosition );
|
|
313
|
+
float viewSpaceZ = max( max( absVec.x, absVec.y ), absVec.z );
|
|
314
|
+
|
|
315
|
+
if ( viewSpaceZ - shadowCameraFar <= 0.0 && viewSpaceZ - shadowCameraNear >= 0.0 ) {
|
|
316
|
+
|
|
317
|
+
// Calculate perspective depth for cube shadow map
|
|
318
|
+
// Standard perspective depth formula: depth = (far * (z - near)) / (z * (far - near))
|
|
319
|
+
float dp = ( shadowCameraFar * ( viewSpaceZ - shadowCameraNear ) ) / ( viewSpaceZ * ( shadowCameraFar - shadowCameraNear ) );
|
|
320
|
+
dp += shadowBias;
|
|
321
|
+
|
|
322
|
+
float depth = textureCube( shadowMap, bd3D ).r;
|
|
323
|
+
|
|
324
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
325
|
+
|
|
326
|
+
shadow = step( depth, dp );
|
|
327
|
+
|
|
328
|
+
#else
|
|
329
|
+
|
|
330
|
+
shadow = step( dp, depth );
|
|
327
331
|
|
|
328
332
|
#endif
|
|
329
333
|
|
|
@@ -333,5 +337,9 @@ export default /* glsl */`
|
|
|
333
337
|
|
|
334
338
|
}
|
|
335
339
|
|
|
340
|
+
#endif
|
|
341
|
+
|
|
342
|
+
#endif
|
|
343
|
+
|
|
336
344
|
#endif
|
|
337
345
|
`;
|
|
@@ -24,7 +24,7 @@ export default /* glsl */`
|
|
|
24
24
|
vec3 n = inverseTransformDirection( normal, viewMatrix );
|
|
25
25
|
|
|
26
26
|
vec4 transmitted = getIBLVolumeRefraction(
|
|
27
|
-
n, v, material.roughness, material.
|
|
27
|
+
n, v, material.roughness, material.diffuseContribution, material.specularColorBlended, material.specularF90,
|
|
28
28
|
pos, modelMatrix, viewMatrix, projectionMatrix, material.dispersion, material.ior, material.thickness,
|
|
29
29
|
material.attenuationColor, material.attenuationDistance );
|
|
30
30
|
|
|
@@ -111,7 +111,7 @@ import * as background from './ShaderLib/background.glsl.js';
|
|
|
111
111
|
import * as backgroundCube from './ShaderLib/backgroundCube.glsl.js';
|
|
112
112
|
import * as cube from './ShaderLib/cube.glsl.js';
|
|
113
113
|
import * as depth from './ShaderLib/depth.glsl.js';
|
|
114
|
-
import * as
|
|
114
|
+
import * as distance from './ShaderLib/distance.glsl.js';
|
|
115
115
|
import * as equirect from './ShaderLib/equirect.glsl.js';
|
|
116
116
|
import * as linedashed from './ShaderLib/linedashed.glsl.js';
|
|
117
117
|
import * as meshbasic from './ShaderLib/meshbasic.glsl.js';
|
|
@@ -243,8 +243,8 @@ export const ShaderChunk = {
|
|
|
243
243
|
cube_frag: cube.fragment,
|
|
244
244
|
depth_vert: depth.vertex,
|
|
245
245
|
depth_frag: depth.fragment,
|
|
246
|
-
|
|
247
|
-
|
|
246
|
+
distance_vert: distance.vertex,
|
|
247
|
+
distance_frag: distance.fragment,
|
|
248
248
|
equirect_vert: equirect.vertex,
|
|
249
249
|
equirect_frag: equirect.fragment,
|
|
250
250
|
linedashed_vert: linedashed.vertex,
|
|
@@ -99,14 +99,17 @@ void main() {
|
|
|
99
99
|
|
|
100
100
|
#elif DEPTH_PACKING == 3201
|
|
101
101
|
|
|
102
|
+
// TODO Deprecate
|
|
102
103
|
gl_FragColor = packDepthToRGBA( fragCoordZ );
|
|
103
104
|
|
|
104
105
|
#elif DEPTH_PACKING == 3202
|
|
105
106
|
|
|
107
|
+
// TODO Deprecate
|
|
106
108
|
gl_FragColor = vec4( packDepthToRGB( fragCoordZ ), 1.0 );
|
|
107
109
|
|
|
108
110
|
#elif DEPTH_PACKING == 3203
|
|
109
111
|
|
|
112
|
+
// TODO Deprecate
|
|
110
113
|
gl_FragColor = vec4( packDepthToRG( fragCoordZ ), 0.0, 1.0 );
|
|
111
114
|
|
|
112
115
|
#endif
|
|
@@ -50,7 +50,6 @@ uniform float farDistance;
|
|
|
50
50
|
varying vec3 vWorldPosition;
|
|
51
51
|
|
|
52
52
|
#include <common>
|
|
53
|
-
#include <packing>
|
|
54
53
|
#include <uv_pars_fragment>
|
|
55
54
|
#include <map_pars_fragment>
|
|
56
55
|
#include <alphamap_pars_fragment>
|
|
@@ -72,7 +71,7 @@ void main () {
|
|
|
72
71
|
dist = ( dist - nearDistance ) / ( farDistance - nearDistance );
|
|
73
72
|
dist = saturate( dist ); // clamp to [ 0, 1 ]
|
|
74
73
|
|
|
75
|
-
gl_FragColor =
|
|
74
|
+
gl_FragColor = vec4( dist, 0.0, 0.0, 1.0 );
|
|
76
75
|
|
|
77
76
|
}
|
|
78
77
|
`;
|
|
@@ -58,7 +58,6 @@ uniform float opacity;
|
|
|
58
58
|
|
|
59
59
|
#endif
|
|
60
60
|
|
|
61
|
-
#include <packing>
|
|
62
61
|
#include <uv_pars_fragment>
|
|
63
62
|
#include <normal_pars_fragment>
|
|
64
63
|
#include <bumpmap_pars_fragment>
|
|
@@ -75,7 +74,7 @@ void main() {
|
|
|
75
74
|
#include <normal_fragment_begin>
|
|
76
75
|
#include <normal_fragment_maps>
|
|
77
76
|
|
|
78
|
-
gl_FragColor = vec4(
|
|
77
|
+
gl_FragColor = vec4( normalize( normal ) * 0.5 + 0.5, diffuseColor.a );
|
|
79
78
|
|
|
80
79
|
#ifdef OPAQUE
|
|
81
80
|
|
|
@@ -130,7 +130,6 @@ uniform float opacity;
|
|
|
130
130
|
varying vec3 vViewPosition;
|
|
131
131
|
|
|
132
132
|
#include <common>
|
|
133
|
-
#include <packing>
|
|
134
133
|
#include <dithering_pars_fragment>
|
|
135
134
|
#include <color_pars_fragment>
|
|
136
135
|
#include <uv_pars_fragment>
|
|
@@ -200,14 +199,10 @@ void main() {
|
|
|
200
199
|
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
201
200
|
|
|
202
201
|
#ifdef USE_SHEEN
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
outgoingLight = outgoingLight * sheenEnergyComp + sheenSpecularDirect + sheenSpecularIndirect;
|
|
209
|
-
|
|
210
|
-
#endif
|
|
202
|
+
|
|
203
|
+
outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
|
|
204
|
+
|
|
205
|
+
#endif
|
|
211
206
|
|
|
212
207
|
#ifdef USE_CLEARCOAT
|
|
213
208
|
|