@plastic-software/three 0.182.0 → 0.183.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/LICENSE +1 -1
- package/build/three.cjs +11520 -10877
- package/build/three.core.js +11732 -11340
- package/build/three.core.min.js +2 -2
- package/build/three.module.js +509 -262
- package/build/three.module.min.js +2 -2
- package/build/three.tsl.js +7 -11
- package/build/three.tsl.min.js +2 -2
- package/build/three.webgpu.js +3072 -2607
- package/build/three.webgpu.min.js +2 -2
- package/build/three.webgpu.nodes.js +3071 -2607
- package/build/three.webgpu.nodes.min.js +2 -2
- package/examples/jsm/Addons.js +0 -3
- package/examples/jsm/animation/CCDIKSolver.js +2 -2
- package/examples/jsm/controls/ArcballControls.js +3 -3
- package/examples/jsm/controls/OrbitControls.js +103 -0
- package/examples/jsm/effects/AnaglyphEffect.js +102 -7
- package/examples/jsm/environments/ColorEnvironment.js +59 -0
- package/examples/jsm/environments/RoomEnvironment.js +1 -0
- package/examples/jsm/exporters/EXRExporter.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +131 -4
- package/examples/jsm/exporters/USDZExporter.js +22 -3
- package/examples/jsm/helpers/AnimationPathHelper.js +302 -0
- package/examples/jsm/helpers/ViewHelper.js +67 -8
- package/examples/jsm/inspector/Inspector.js +21 -5
- package/examples/jsm/inspector/tabs/Console.js +39 -5
- package/examples/jsm/inspector/tabs/Parameters.js +16 -0
- package/examples/jsm/inspector/ui/Style.js +25 -1
- package/examples/jsm/libs/meshopt_decoder.module.js +6 -5
- package/examples/jsm/lines/LineMaterial.js +6 -0
- package/examples/jsm/loaders/3MFLoader.js +2 -2
- package/examples/jsm/loaders/AMFLoader.js +2 -2
- package/examples/jsm/loaders/ColladaLoader.js +24 -4026
- package/examples/jsm/loaders/EXRLoader.js +5 -5
- package/examples/jsm/loaders/FBXLoader.js +2 -2
- package/examples/jsm/loaders/GCodeLoader.js +34 -8
- package/examples/jsm/loaders/GLTFLoader.js +122 -171
- package/examples/jsm/loaders/KMZLoader.js +5 -5
- package/examples/jsm/loaders/KTX2Loader.js +5 -5
- package/examples/jsm/loaders/LWOLoader.js +7 -39
- package/examples/jsm/loaders/NRRDLoader.js +2 -2
- package/examples/jsm/loaders/PCDLoader.js +3 -2
- package/examples/jsm/loaders/USDLoader.js +100 -40
- package/examples/jsm/loaders/UltraHDRLoader.js +182 -30
- package/examples/jsm/loaders/VRMLLoader.js +77 -0
- package/examples/jsm/loaders/VTKLoader.js +37 -24
- package/examples/jsm/loaders/collada/ColladaComposer.js +2950 -0
- package/examples/jsm/loaders/collada/ColladaParser.js +1962 -0
- package/examples/jsm/loaders/usd/USDAParser.js +447 -366
- package/examples/jsm/loaders/usd/USDCParser.js +1841 -6
- package/examples/jsm/loaders/usd/USDComposer.js +4041 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +2 -2
- package/examples/jsm/objects/LensflareMesh.js +1 -1
- package/examples/jsm/objects/Sky.js +76 -4
- package/examples/jsm/objects/SkyMesh.js +114 -7
- package/examples/jsm/objects/Water.js +4 -3
- package/examples/jsm/objects/Water2.js +5 -3
- package/examples/jsm/objects/WaterMesh.js +5 -7
- package/examples/jsm/physics/JoltPhysics.js +7 -5
- package/examples/jsm/physics/RapierPhysics.js +6 -4
- package/examples/jsm/postprocessing/EffectComposer.js +7 -5
- package/examples/jsm/postprocessing/RenderTransitionPass.js +1 -1
- package/examples/jsm/renderers/CSS3DRenderer.js +1 -1
- package/examples/jsm/renderers/SVGRenderer.js +2 -2
- package/examples/jsm/shaders/GTAOShader.js +19 -6
- package/examples/jsm/shaders/HalftoneShader.js +12 -1
- package/examples/jsm/shaders/PoissonDenoiseShader.js +6 -2
- package/examples/jsm/shaders/SAOShader.js +17 -4
- package/examples/jsm/shaders/SSAOShader.js +11 -1
- package/examples/jsm/shaders/SSRShader.js +6 -5
- package/examples/jsm/shaders/VignetteShader.js +1 -1
- package/examples/jsm/tsl/display/AfterImageNode.js +1 -1
- package/examples/jsm/tsl/display/AnaglyphPassNode.js +456 -16
- package/examples/jsm/tsl/display/AnamorphicNode.js +1 -1
- package/examples/jsm/tsl/display/BilateralBlurNode.js +364 -0
- package/examples/jsm/tsl/display/BloomNode.js +5 -5
- package/examples/jsm/tsl/display/CRT.js +150 -0
- package/examples/jsm/tsl/display/DenoiseNode.js +1 -1
- package/examples/jsm/tsl/display/DepthOfFieldNode.js +1 -1
- package/examples/jsm/tsl/display/DotScreenNode.js +1 -1
- package/examples/jsm/tsl/display/FXAANode.js +2 -2
- package/examples/jsm/tsl/display/GTAONode.js +2 -2
- package/examples/jsm/tsl/display/GaussianBlurNode.js +11 -2
- package/examples/jsm/tsl/display/GodraysNode.js +624 -0
- package/examples/jsm/tsl/display/LensflareNode.js +1 -1
- package/examples/jsm/tsl/display/Lut3DNode.js +1 -1
- package/examples/jsm/tsl/display/OutlineNode.js +3 -3
- package/examples/jsm/tsl/display/ParallaxBarrierPassNode.js +2 -2
- package/examples/jsm/tsl/display/PixelationPassNode.js +5 -5
- package/examples/jsm/tsl/display/RGBShiftNode.js +2 -2
- package/examples/jsm/tsl/display/RetroPassNode.js +263 -0
- package/examples/jsm/tsl/display/SMAANode.js +2 -2
- package/examples/jsm/tsl/display/SSAAPassNode.js +2 -2
- package/examples/jsm/tsl/display/SSGINode.js +2 -2
- package/examples/jsm/tsl/display/SSRNode.js +7 -7
- package/examples/jsm/tsl/display/SSSNode.js +2 -2
- package/examples/jsm/tsl/display/Shape.js +29 -0
- package/examples/jsm/tsl/display/SobelOperatorNode.js +2 -2
- package/examples/jsm/tsl/display/StereoPassNode.js +1 -2
- package/examples/jsm/tsl/display/TRAANode.js +9 -12
- package/examples/jsm/tsl/display/TransitionNode.js +1 -1
- package/examples/jsm/tsl/display/depthAwareBlend.js +80 -0
- package/examples/jsm/tsl/math/Bayer.js +40 -1
- package/examples/jsm/utils/LDrawUtils.js +1 -1
- package/package.json +11 -19
- package/src/Three.Core.js +1 -1
- package/src/Three.TSL.js +5 -9
- package/src/Three.WebGPU.Nodes.js +2 -0
- package/src/Three.WebGPU.js +3 -0
- package/src/Three.js +1 -0
- package/src/animation/AnimationAction.js +1 -1
- package/src/animation/AnimationClip.js +1 -1
- package/src/animation/AnimationMixer.js +6 -0
- package/src/animation/KeyframeTrack.js +46 -7
- package/src/animation/PropertyMixer.js +4 -4
- package/src/audio/Audio.js +1 -1
- package/src/audio/AudioListener.js +5 -3
- package/src/cameras/Camera.js +32 -2
- package/src/cameras/CubeCamera.js +20 -0
- package/src/constants.js +30 -1
- package/src/core/Clock.js +7 -0
- package/src/core/Object3D.js +56 -4
- package/src/core/RenderTarget.js +3 -4
- package/src/extras/PMREMGenerator.js +4 -8
- package/src/geometries/TorusGeometry.js +8 -3
- package/src/helpers/CameraHelper.js +3 -0
- package/src/helpers/DirectionalLightHelper.js +4 -1
- package/src/helpers/HemisphereLightHelper.js +3 -0
- package/src/helpers/PointLightHelper.js +0 -24
- package/src/helpers/SpotLightHelper.js +3 -0
- package/src/lights/LightShadow.js +15 -3
- package/src/lights/webgpu/IESSpotLight.js +2 -1
- package/src/loaders/Cache.js +28 -0
- package/src/loaders/FileLoader.js +1 -1
- package/src/loaders/ImageBitmapLoader.js +8 -3
- package/src/loaders/Loader.js +6 -0
- package/src/loaders/ObjectLoader.js +18 -1
- package/src/materials/MeshLambertMaterial.js +9 -0
- package/src/materials/MeshPhongMaterial.js +9 -0
- package/src/materials/nodes/Line2NodeMaterial.js +5 -5
- package/src/materials/nodes/MeshPhysicalNodeMaterial.js +2 -0
- package/src/materials/nodes/NodeMaterial.js +15 -24
- package/src/materials/nodes/manager/NodeMaterialObserver.js +9 -3
- package/src/math/Line3.js +3 -5
- package/src/math/MathUtils.js +10 -10
- package/src/math/Matrix4.js +35 -26
- package/src/math/Quaternion.js +3 -29
- package/src/math/Vector3.js +3 -3
- package/src/math/interpolants/BezierInterpolant.js +108 -0
- package/src/nodes/Nodes.js +87 -68
- package/src/nodes/TSL.js +2 -5
- package/src/nodes/accessors/Arrays.js +1 -1
- package/src/nodes/accessors/Bitangent.js +5 -5
- package/src/nodes/accessors/BufferAttributeNode.js +1 -1
- package/src/nodes/accessors/Camera.js +149 -28
- package/src/nodes/accessors/InstanceNode.js +105 -40
- package/src/nodes/accessors/Normal.js +9 -9
- package/src/nodes/accessors/Position.js +34 -2
- package/src/nodes/accessors/SceneProperties.js +53 -0
- package/src/nodes/accessors/SkinningNode.js +12 -24
- package/src/nodes/accessors/StorageBufferNode.js +0 -19
- package/src/nodes/accessors/StorageTextureNode.js +37 -1
- package/src/nodes/accessors/Tangent.js +3 -3
- package/src/nodes/accessors/Texture3DNode.js +6 -34
- package/src/nodes/accessors/TextureNode.js +58 -22
- package/src/nodes/accessors/UniformArrayNode.js +2 -0
- package/src/nodes/core/MRTNode.js +48 -2
- package/src/nodes/core/Node.js +29 -3
- package/src/nodes/core/NodeBuilder.js +115 -40
- package/src/nodes/core/NodeError.js +28 -0
- package/src/nodes/core/NodeUtils.js +5 -3
- package/src/nodes/core/OutputStructNode.js +12 -10
- package/src/nodes/core/ParameterNode.js +2 -1
- package/src/nodes/core/StackNode.js +9 -8
- package/src/nodes/core/StackTrace.js +139 -0
- package/src/nodes/core/StructNode.js +15 -0
- package/src/nodes/core/SubBuildNode.js +1 -1
- package/src/nodes/core/UniformNode.js +2 -1
- package/src/nodes/core/VarNode.js +1 -1
- package/src/nodes/core/VaryingNode.js +1 -18
- package/src/nodes/display/BlendModes.js +0 -64
- package/src/nodes/display/ColorAdjustment.js +17 -0
- package/src/nodes/display/ColorSpaceNode.js +3 -3
- package/src/nodes/display/NormalMapNode.js +2 -2
- package/src/nodes/display/PassNode.js +21 -2
- package/src/nodes/display/RenderOutputNode.js +3 -3
- package/src/nodes/display/ScreenNode.js +2 -1
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ToonOutlinePassNode.js +2 -2
- package/src/nodes/display/ViewportDepthNode.js +52 -4
- package/src/nodes/display/ViewportTextureNode.js +21 -4
- package/src/nodes/fog/Fog.js +18 -35
- package/src/nodes/functions/PhysicalLightingModel.js +25 -3
- package/src/nodes/geometry/RangeNode.js +4 -2
- package/src/nodes/gpgpu/ComputeNode.js +5 -4
- package/src/nodes/gpgpu/WorkgroupInfoNode.js +2 -1
- package/src/nodes/lighting/EnvironmentNode.js +28 -3
- package/src/nodes/lighting/PointShadowNode.js +24 -12
- package/src/nodes/lighting/ShadowFilterNode.js +15 -43
- package/src/nodes/lighting/ShadowNode.js +54 -32
- package/src/nodes/math/ConditionalNode.js +2 -2
- package/src/nodes/math/MathNode.js +3 -40
- package/src/nodes/math/OperatorNode.js +2 -1
- package/src/nodes/pmrem/PMREMUtils.js +9 -15
- package/src/nodes/tsl/TSLCore.js +13 -10
- package/src/nodes/utils/DebugNode.js +11 -11
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +1 -1
- package/src/nodes/utils/MemberNode.js +1 -1
- package/src/nodes/utils/RTTNode.js +1 -1
- package/src/nodes/utils/ReflectorNode.js +2 -3
- package/src/nodes/utils/SpriteSheetUV.js +35 -0
- package/src/nodes/utils/UVUtils.js +4 -2
- package/src/objects/BatchedMesh.js +22 -12
- package/src/objects/InstancedMesh.js +11 -0
- package/src/renderers/WebGLRenderer.js +34 -60
- package/src/renderers/common/Backend.js +21 -0
- package/src/renderers/common/Background.js +7 -4
- package/src/renderers/common/BindGroup.js +1 -9
- package/src/renderers/common/Bindings.js +20 -5
- package/src/renderers/common/BlendMode.js +143 -0
- package/src/renderers/common/BundleGroup.js +1 -1
- package/src/renderers/common/CubeRenderTarget.js +50 -6
- package/src/renderers/common/Geometries.js +17 -3
- package/src/renderers/common/Lighting.js +5 -21
- package/src/renderers/common/Pipelines.js +4 -4
- package/src/renderers/common/PostProcessing.js +8 -206
- package/src/renderers/common/RenderBundles.js +2 -1
- package/src/renderers/common/RenderContext.js +16 -0
- package/src/renderers/common/RenderContexts.js +33 -56
- package/src/renderers/common/RenderLists.js +2 -1
- package/src/renderers/common/RenderObject.js +2 -3
- package/src/renderers/common/RenderObjectPipeline.js +40 -0
- package/src/renderers/common/RenderObjects.js +18 -2
- package/src/renderers/common/RenderPipeline.js +203 -17
- package/src/renderers/common/Renderer.js +207 -40
- package/src/renderers/common/Sampler.js +4 -4
- package/src/renderers/common/StorageBuffer.js +13 -1
- package/src/renderers/common/Textures.js +16 -0
- package/src/renderers/common/TimestampQueryPool.js +5 -3
- package/src/renderers/common/Uniform.js +8 -0
- package/src/renderers/common/UniformsGroup.js +60 -0
- package/src/renderers/common/XRManager.js +2 -2
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/{Nodes.js → NodeManager.js} +18 -6
- package/src/renderers/common/nodes/NodeStorageBuffer.js +13 -2
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +2 -2
- package/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -5
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +8 -10
- package/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js +7 -11
- package/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js +6 -2
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +23 -1
- package/src/renderers/shaders/ShaderChunk/packing.glsl.js +20 -4
- package/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js +55 -24
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +1 -0
- package/src/renderers/shaders/ShaderLib.js +4 -2
- package/src/renderers/shaders/UniformsLib.js +0 -3
- package/src/renderers/webgl/WebGLBackground.js +2 -2
- package/src/renderers/webgl/WebGLBindingStates.js +99 -27
- package/src/renderers/webgl/WebGLEnvironments.js +228 -0
- package/src/renderers/webgl/WebGLGeometries.js +10 -7
- package/src/renderers/webgl/WebGLMaterials.js +12 -0
- package/src/renderers/webgl/WebGLObjects.js +3 -1
- package/src/renderers/webgl/WebGLProgram.js +2 -2
- package/src/renderers/webgl/WebGLPrograms.js +10 -4
- package/src/renderers/webgl/WebGLRenderLists.js +15 -0
- package/src/renderers/webgl/WebGLShadowMap.js +5 -4
- package/src/renderers/webgl/WebGLState.js +12 -17
- package/src/renderers/webgl-fallback/WebGLBackend.js +71 -7
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +98 -29
- package/src/renderers/webgl-fallback/utils/WebGLState.js +168 -7
- package/src/renderers/webgpu/WebGPUBackend.js +58 -9
- package/src/renderers/webgpu/WebGPURenderer.js +1 -0
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +257 -45
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +8 -19
- package/src/renderers/webgpu/utils/WebGPUConstants.js +1 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +56 -31
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +152 -200
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +25 -25
- package/src/renderers/webgpu/utils/WebGPUUtils.js +10 -6
- package/src/renderers/webxr/WebXRManager.js +2 -2
- package/src/textures/Texture.js +2 -2
- package/src/utils.js +246 -3
- package/examples/jsm/materials/MeshGouraudMaterial.js +0 -433
- package/examples/jsm/materials/MeshPostProcessingMaterial.js +0 -167
- package/examples/jsm/shaders/GodRaysShader.js +0 -333
- package/src/nodes/accessors/SceneNode.js +0 -145
- package/src/nodes/code/ScriptableNode.js +0 -726
- package/src/nodes/code/ScriptableValueNode.js +0 -253
- package/src/nodes/display/PosterizeNode.js +0 -65
- package/src/nodes/utils/SpriteSheetUVNode.js +0 -90
- package/src/renderers/webgl/WebGLCubeMaps.js +0 -99
- package/src/renderers/webgl/WebGLCubeUVMaps.js +0 -134
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Color } from 'three/webgpu';
|
|
2
|
-
import { attribute, cameraProjectionMatrix, dot, float, Fn, modelViewMatrix, modelViewProjection,
|
|
1
|
+
import { Color, NodeMaterial } from 'three/webgpu';
|
|
2
|
+
import { attribute, cameraProjectionMatrix, dot, float, Fn, modelViewMatrix, modelViewProjection, normalize, positionGeometry, sign, uniform, varyingProperty, vec2, vec4 } from 'three/tsl';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* A special line material for meshes loaded via {@link LDrawLoader}.
|
|
@@ -215,7 +215,7 @@ class LensflareMesh extends Mesh {
|
|
|
215
215
|
|
|
216
216
|
renderer.getViewport( viewport );
|
|
217
217
|
|
|
218
|
-
viewport.multiplyScalar(
|
|
218
|
+
viewport.multiplyScalar( renderer.getPixelRatio() ).floor();
|
|
219
219
|
|
|
220
220
|
const renderTarget = renderer.getRenderTarget();
|
|
221
221
|
const type = ( renderTarget !== null ) ? renderTarget.texture.type : UnsignedByteType;
|
|
@@ -72,7 +72,13 @@ Sky.SkyShader = {
|
|
|
72
72
|
'mieCoefficient': { value: 0.005 },
|
|
73
73
|
'mieDirectionalG': { value: 0.8 },
|
|
74
74
|
'sunPosition': { value: new Vector3() },
|
|
75
|
-
'up': { value: new Vector3( 0, 1, 0 ) }
|
|
75
|
+
'up': { value: new Vector3( 0, 1, 0 ) },
|
|
76
|
+
'cloudScale': { value: 0.0002 },
|
|
77
|
+
'cloudSpeed': { value: 0.0001 },
|
|
78
|
+
'cloudCoverage': { value: 0.4 },
|
|
79
|
+
'cloudDensity': { value: 0.4 },
|
|
80
|
+
'cloudElevation': { value: 0.5 },
|
|
81
|
+
'time': { value: 0.0 }
|
|
76
82
|
},
|
|
77
83
|
|
|
78
84
|
vertexShader: /* glsl */`
|
|
@@ -150,13 +156,45 @@ Sky.SkyShader = {
|
|
|
150
156
|
fragmentShader: /* glsl */`
|
|
151
157
|
varying vec3 vWorldPosition;
|
|
152
158
|
varying vec3 vSunDirection;
|
|
153
|
-
varying float vSunfade;
|
|
154
159
|
varying vec3 vBetaR;
|
|
155
160
|
varying vec3 vBetaM;
|
|
156
161
|
varying float vSunE;
|
|
157
162
|
|
|
158
163
|
uniform float mieDirectionalG;
|
|
159
164
|
uniform vec3 up;
|
|
165
|
+
uniform float cloudScale;
|
|
166
|
+
uniform float cloudSpeed;
|
|
167
|
+
uniform float cloudCoverage;
|
|
168
|
+
uniform float cloudDensity;
|
|
169
|
+
uniform float cloudElevation;
|
|
170
|
+
uniform float time;
|
|
171
|
+
|
|
172
|
+
// Cloud noise functions
|
|
173
|
+
float hash( vec2 p ) {
|
|
174
|
+
return fract( sin( dot( p, vec2( 127.1, 311.7 ) ) ) * 43758.5453123 );
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
float noise( vec2 p ) {
|
|
178
|
+
vec2 i = floor( p );
|
|
179
|
+
vec2 f = fract( p );
|
|
180
|
+
f = f * f * ( 3.0 - 2.0 * f );
|
|
181
|
+
float a = hash( i );
|
|
182
|
+
float b = hash( i + vec2( 1.0, 0.0 ) );
|
|
183
|
+
float c = hash( i + vec2( 0.0, 1.0 ) );
|
|
184
|
+
float d = hash( i + vec2( 1.0, 1.0 ) );
|
|
185
|
+
return mix( mix( a, b, f.x ), mix( c, d, f.x ), f.y );
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
float fbm( vec2 p ) {
|
|
189
|
+
float value = 0.0;
|
|
190
|
+
float amplitude = 0.5;
|
|
191
|
+
for ( int i = 0; i < 5; i ++ ) {
|
|
192
|
+
value += amplitude * noise( p );
|
|
193
|
+
p *= 2.0;
|
|
194
|
+
amplitude *= 0.5;
|
|
195
|
+
}
|
|
196
|
+
return value;
|
|
197
|
+
}
|
|
160
198
|
|
|
161
199
|
// constants for atmospheric scattering
|
|
162
200
|
const float pi = 3.141592653589793238462643383279502884197169;
|
|
@@ -223,9 +261,43 @@ Sky.SkyShader = {
|
|
|
223
261
|
|
|
224
262
|
vec3 texColor = ( Lin + L0 ) * 0.04 + vec3( 0.0, 0.0003, 0.00075 );
|
|
225
263
|
|
|
226
|
-
|
|
264
|
+
// Clouds
|
|
265
|
+
if ( direction.y > 0.0 && cloudCoverage > 0.0 ) {
|
|
266
|
+
|
|
267
|
+
// Project to cloud plane (higher elevation = clouds appear lower/closer)
|
|
268
|
+
float elevation = mix( 1.0, 0.1, cloudElevation );
|
|
269
|
+
vec2 cloudUV = direction.xz / ( direction.y * elevation );
|
|
270
|
+
cloudUV *= cloudScale;
|
|
271
|
+
cloudUV += time * cloudSpeed;
|
|
272
|
+
|
|
273
|
+
// Multi-octave noise for fluffy clouds
|
|
274
|
+
float cloudNoise = fbm( cloudUV * 1000.0 );
|
|
275
|
+
cloudNoise += 0.5 * fbm( cloudUV * 2000.0 + 3.7 );
|
|
276
|
+
cloudNoise = cloudNoise * 0.5 + 0.5;
|
|
277
|
+
|
|
278
|
+
// Apply coverage threshold
|
|
279
|
+
float cloudMask = smoothstep( 1.0 - cloudCoverage, 1.0 - cloudCoverage + 0.3, cloudNoise );
|
|
280
|
+
|
|
281
|
+
// Fade clouds near horizon (adjusted by elevation)
|
|
282
|
+
float horizonFade = smoothstep( 0.0, 0.1 + 0.2 * cloudElevation, direction.y );
|
|
283
|
+
cloudMask *= horizonFade;
|
|
284
|
+
|
|
285
|
+
// Cloud lighting based on sun position
|
|
286
|
+
float sunInfluence = dot( direction, vSunDirection ) * 0.5 + 0.5;
|
|
287
|
+
float daylight = max( 0.0, vSunDirection.y * 2.0 );
|
|
288
|
+
|
|
289
|
+
// Base cloud color affected by atmosphere
|
|
290
|
+
vec3 atmosphereColor = Lin * 0.04;
|
|
291
|
+
vec3 cloudColor = mix( vec3( 0.3 ), vec3( 1.0 ), daylight );
|
|
292
|
+
cloudColor = mix( cloudColor, atmosphereColor + vec3( 1.0 ), sunInfluence * 0.5 );
|
|
293
|
+
cloudColor *= vSunE * 0.00002;
|
|
294
|
+
|
|
295
|
+
// Blend clouds with sky
|
|
296
|
+
texColor = mix( texColor, cloudColor, cloudMask * cloudDensity );
|
|
297
|
+
|
|
298
|
+
}
|
|
227
299
|
|
|
228
|
-
gl_FragColor = vec4(
|
|
300
|
+
gl_FragColor = vec4( texColor, 1.0 );
|
|
229
301
|
|
|
230
302
|
#include <tonemapping_fragment>
|
|
231
303
|
#include <colorspace_fragment>
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
NodeMaterial
|
|
7
7
|
} from 'three/webgpu';
|
|
8
8
|
|
|
9
|
-
import { Fn, float, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix, modelViewProjection, normalize, positionWorld, pow, smoothstep, sub, varyingProperty, vec4, uniform, cameraPosition } from 'three/tsl';
|
|
9
|
+
import { Fn, float, vec2, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix, modelViewProjection, normalize, positionWorld, pow, smoothstep, sub, varyingProperty, vec4, uniform, cameraPosition, fract, floor, sin, time, Loop, If } from 'three/tsl';
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Represents a skydome for scene backgrounds. Based on [A Practical Analytic Model for Daylight](https://www.researchgate.net/publication/220720443_A_Practical_Analytic_Model_for_Daylight)
|
|
@@ -82,6 +82,41 @@ class SkyMesh extends Mesh {
|
|
|
82
82
|
*/
|
|
83
83
|
this.upUniform = uniform( new Vector3( 0, 1, 0 ) );
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* The cloud scale uniform.
|
|
87
|
+
*
|
|
88
|
+
* @type {UniformNode<float>}
|
|
89
|
+
*/
|
|
90
|
+
this.cloudScale = uniform( 0.0002 );
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The cloud speed uniform.
|
|
94
|
+
*
|
|
95
|
+
* @type {UniformNode<float>}
|
|
96
|
+
*/
|
|
97
|
+
this.cloudSpeed = uniform( 0.0001 );
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The cloud coverage uniform.
|
|
101
|
+
*
|
|
102
|
+
* @type {UniformNode<float>}
|
|
103
|
+
*/
|
|
104
|
+
this.cloudCoverage = uniform( 0.4 );
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The cloud density uniform.
|
|
108
|
+
*
|
|
109
|
+
* @type {UniformNode<float>}
|
|
110
|
+
*/
|
|
111
|
+
this.cloudDensity = uniform( 0.4 );
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* The cloud elevation uniform.
|
|
115
|
+
*
|
|
116
|
+
* @type {UniformNode<float>}
|
|
117
|
+
*/
|
|
118
|
+
this.cloudElevation = uniform( 0.5 );
|
|
119
|
+
|
|
85
120
|
/**
|
|
86
121
|
* This flag can be used for type testing.
|
|
87
122
|
*
|
|
@@ -105,7 +140,6 @@ class SkyMesh extends Mesh {
|
|
|
105
140
|
|
|
106
141
|
const vSunDirection = varyingProperty( 'vec3' );
|
|
107
142
|
const vSunE = varyingProperty( 'float' );
|
|
108
|
-
const vSunfade = varyingProperty( 'float' );
|
|
109
143
|
const vBetaR = varyingProperty( 'vec3' );
|
|
110
144
|
const vBetaM = varyingProperty( 'vec3' );
|
|
111
145
|
|
|
@@ -146,10 +180,9 @@ class SkyMesh extends Mesh {
|
|
|
146
180
|
const sunIntensity = EE.mul( max( 0.0, float( 1.0 ).sub( pow( e, cutoffAngle.sub( acos( zenithAngleCos ) ).div( steepness ).negate() ) ) ) );
|
|
147
181
|
vSunE.assign( sunIntensity );
|
|
148
182
|
|
|
149
|
-
//
|
|
183
|
+
// sun fade
|
|
150
184
|
|
|
151
185
|
const sunfade = float( 1.0 ).sub( clamp( float( 1.0 ).sub( exp( this.sunPosition.y.div( 450000.0 ) ) ), 0, 1 ) );
|
|
152
|
-
vSunfade.assign( sunfade );
|
|
153
186
|
|
|
154
187
|
// varying vBetaR
|
|
155
188
|
|
|
@@ -232,11 +265,85 @@ class SkyMesh extends Mesh {
|
|
|
232
265
|
const sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos.add( 0.00002 ), cosTheta );
|
|
233
266
|
L0.addAssign( vSunE.mul( 19000.0 ).mul( Fex ).mul( sundisk ) );
|
|
234
267
|
|
|
235
|
-
const texColor = add( Lin, L0 ).mul( 0.04 ).add( vec3( 0.0, 0.0003, 0.00075 ) );
|
|
268
|
+
const texColor = add( Lin, L0 ).mul( 0.04 ).add( vec3( 0.0, 0.0003, 0.00075 ) ).toVar();
|
|
269
|
+
|
|
270
|
+
// Cloud noise functions
|
|
271
|
+
const hash = Fn( ( [ p ] ) => {
|
|
272
|
+
|
|
273
|
+
return fract( sin( dot( p, vec2( 127.1, 311.7 ) ) ).mul( 43758.5453123 ) );
|
|
274
|
+
|
|
275
|
+
} );
|
|
276
|
+
|
|
277
|
+
const noise = Fn( ( [ p_immutable ] ) => {
|
|
278
|
+
|
|
279
|
+
const p = vec2( p_immutable ).toVar();
|
|
280
|
+
const i = floor( p );
|
|
281
|
+
const f = fract( p );
|
|
282
|
+
const ff = f.mul( f ).mul( sub( 3.0, f.mul( 2.0 ) ) );
|
|
283
|
+
|
|
284
|
+
const a = hash( i );
|
|
285
|
+
const b = hash( add( i, vec2( 1.0, 0.0 ) ) );
|
|
286
|
+
const c = hash( add( i, vec2( 0.0, 1.0 ) ) );
|
|
287
|
+
const d = hash( add( i, vec2( 1.0, 1.0 ) ) );
|
|
288
|
+
|
|
289
|
+
return mix( mix( a, b, ff.x ), mix( c, d, ff.x ), ff.y );
|
|
290
|
+
|
|
291
|
+
} );
|
|
292
|
+
|
|
293
|
+
const fbm = Fn( ( [ p_immutable ] ) => {
|
|
294
|
+
|
|
295
|
+
const p = vec2( p_immutable ).toVar();
|
|
296
|
+
const value = float( 0.0 ).toVar();
|
|
297
|
+
const amplitude = float( 0.5 ).toVar();
|
|
298
|
+
|
|
299
|
+
Loop( 5, () => {
|
|
300
|
+
|
|
301
|
+
value.addAssign( amplitude.mul( noise( p ) ) );
|
|
302
|
+
p.mulAssign( 2.0 );
|
|
303
|
+
amplitude.mulAssign( 0.5 );
|
|
304
|
+
|
|
305
|
+
} );
|
|
306
|
+
|
|
307
|
+
return value;
|
|
308
|
+
|
|
309
|
+
} );
|
|
310
|
+
|
|
311
|
+
// Clouds
|
|
312
|
+
If( direction.y.greaterThan( 0.0 ).and( this.cloudCoverage.greaterThan( 0.0 ) ), () => {
|
|
313
|
+
|
|
314
|
+
// Project to cloud plane (higher elevation = clouds appear lower/closer)
|
|
315
|
+
const elevation = mix( 1.0, 0.1, this.cloudElevation );
|
|
316
|
+
const cloudUV = direction.xz.div( direction.y.mul( elevation ) ).toVar();
|
|
317
|
+
cloudUV.mulAssign( this.cloudScale );
|
|
318
|
+
cloudUV.addAssign( time.mul( this.cloudSpeed ) );
|
|
319
|
+
|
|
320
|
+
// Multi-octave noise for fluffy clouds
|
|
321
|
+
const cloudNoise = fbm( cloudUV.mul( 1000.0 ) ).add( fbm( cloudUV.mul( 2000.0 ).add( 3.7 ) ).mul( 0.5 ) ).toVar();
|
|
322
|
+
cloudNoise.assign( cloudNoise.mul( 0.5 ).add( 0.5 ) );
|
|
323
|
+
|
|
324
|
+
// Apply coverage threshold
|
|
325
|
+
const cloudMask = smoothstep( sub( 1.0, this.cloudCoverage ), sub( 1.0, this.cloudCoverage ).add( 0.3 ), cloudNoise ).toVar();
|
|
326
|
+
|
|
327
|
+
// Fade clouds near horizon (adjusted by elevation)
|
|
328
|
+
const horizonFade = smoothstep( 0.0, add( 0.1, mul( 0.2, this.cloudElevation ) ), direction.y );
|
|
329
|
+
cloudMask.mulAssign( horizonFade );
|
|
330
|
+
|
|
331
|
+
// Cloud lighting based on sun position
|
|
332
|
+
const sunInfluence = dot( direction, vSunDirection ).mul( 0.5 ).add( 0.5 );
|
|
333
|
+
const daylight = max( 0.0, vSunDirection.y.mul( 2.0 ) );
|
|
334
|
+
|
|
335
|
+
// Base cloud color affected by atmosphere
|
|
336
|
+
const atmosphereColor = Lin.mul( 0.04 );
|
|
337
|
+
const cloudColor = mix( vec3( 0.3 ), vec3( 1.0 ), daylight ).toVar();
|
|
338
|
+
cloudColor.assign( mix( cloudColor, atmosphereColor.add( vec3( 1.0 ) ), sunInfluence.mul( 0.5 ) ) );
|
|
339
|
+
cloudColor.mulAssign( vSunE.mul( 0.00002 ) );
|
|
340
|
+
|
|
341
|
+
// Blend clouds with sky
|
|
342
|
+
texColor.assign( mix( texColor, cloudColor, cloudMask.mul( this.cloudDensity ) ) );
|
|
236
343
|
|
|
237
|
-
|
|
344
|
+
} );
|
|
238
345
|
|
|
239
|
-
return vec4(
|
|
346
|
+
return vec4( texColor, 1.0 );
|
|
240
347
|
|
|
241
348
|
} )();
|
|
242
349
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Color,
|
|
3
3
|
FrontSide,
|
|
4
|
+
HalfFloatType,
|
|
4
5
|
Matrix4,
|
|
5
6
|
Mesh,
|
|
6
7
|
PerspectiveCamera,
|
|
@@ -84,7 +85,7 @@ class Water extends Mesh {
|
|
|
84
85
|
|
|
85
86
|
const mirrorCamera = new PerspectiveCamera();
|
|
86
87
|
|
|
87
|
-
const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight );
|
|
88
|
+
const renderTarget = new WebGLRenderTarget( textureWidth, textureHeight, { type: HalfFloatType } );
|
|
88
89
|
|
|
89
90
|
const mirrorShader = {
|
|
90
91
|
|
|
@@ -196,10 +197,10 @@ class Water extends Mesh {
|
|
|
196
197
|
vec3 reflectionSample = vec3( texture2D( mirrorSampler, mirrorCoord.xy / mirrorCoord.w + distortion ) );
|
|
197
198
|
|
|
198
199
|
float theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );
|
|
199
|
-
float rf0 = 0.
|
|
200
|
+
float rf0 = 0.02;
|
|
200
201
|
float reflectance = rf0 + ( 1.0 - rf0 ) * pow( ( 1.0 - theta ), 5.0 );
|
|
201
202
|
vec3 scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ) * waterColor;
|
|
202
|
-
vec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(),
|
|
203
|
+
vec3 albedo = mix( ( sunColor * diffuseLight * 0.3 + scatter ) * getShadowMask(), reflectionSample + specularLight, reflectance );
|
|
203
204
|
vec3 outgoingLight = albedo;
|
|
204
205
|
gl_FragColor = vec4( outgoingLight, alpha );
|
|
205
206
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
Timer,
|
|
3
3
|
Color,
|
|
4
4
|
Matrix4,
|
|
5
5
|
Mesh,
|
|
@@ -74,7 +74,7 @@ class Water extends Mesh {
|
|
|
74
74
|
const cycle = 0.15; // a cycle of a flow map phase
|
|
75
75
|
const halfCycle = cycle * 0.5;
|
|
76
76
|
const textureMatrix = new Matrix4();
|
|
77
|
-
const
|
|
77
|
+
const timer = new Timer();
|
|
78
78
|
|
|
79
79
|
// internal components
|
|
80
80
|
|
|
@@ -180,7 +180,7 @@ class Water extends Mesh {
|
|
|
180
180
|
|
|
181
181
|
function updateFlow() {
|
|
182
182
|
|
|
183
|
-
const delta =
|
|
183
|
+
const delta = timer.getDelta();
|
|
184
184
|
const config = scope.material.uniforms[ 'config' ];
|
|
185
185
|
|
|
186
186
|
config.value.x += flowSpeed * delta; // flowMapOffset0
|
|
@@ -207,6 +207,8 @@ class Water extends Mesh {
|
|
|
207
207
|
|
|
208
208
|
this.onBeforeRender = function ( renderer, scene, camera ) {
|
|
209
209
|
|
|
210
|
+
timer.update();
|
|
211
|
+
|
|
210
212
|
updateTextureMatrix( camera );
|
|
211
213
|
updateFlow();
|
|
212
214
|
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
Color,
|
|
3
3
|
Mesh,
|
|
4
4
|
Vector3,
|
|
5
|
-
|
|
5
|
+
NodeMaterial
|
|
6
6
|
} from 'three/webgpu';
|
|
7
7
|
|
|
8
|
-
import { Fn, add, cameraPosition, div, normalize, positionWorld, sub, time, texture, vec2,
|
|
8
|
+
import { Fn, add, cameraPosition, div, normalize, positionWorld, sub, time, texture, vec2, max, dot, reflect, pow, length, float, uniform, reflector, mul, mix } from 'three/tsl';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* A basic flat, reflective water effect.
|
|
@@ -32,7 +32,7 @@ class WaterMesh extends Mesh {
|
|
|
32
32
|
*/
|
|
33
33
|
constructor( geometry, options ) {
|
|
34
34
|
|
|
35
|
-
const material = new
|
|
35
|
+
const material = new NodeMaterial();
|
|
36
36
|
|
|
37
37
|
super( geometry, material );
|
|
38
38
|
|
|
@@ -155,8 +155,6 @@ class WaterMesh extends Mesh {
|
|
|
155
155
|
|
|
156
156
|
material.receivedShadowPositionNode = positionWorld.add( distortion );
|
|
157
157
|
|
|
158
|
-
material.setupOutgoingLight = () => diffuseColor.rgb; // backwards compatibility
|
|
159
|
-
|
|
160
158
|
material.colorNode = Fn( () => {
|
|
161
159
|
|
|
162
160
|
const mirrorSampler = reflector();
|
|
@@ -166,10 +164,10 @@ class WaterMesh extends Mesh {
|
|
|
166
164
|
this.add( mirrorSampler.target );
|
|
167
165
|
|
|
168
166
|
const theta = max( dot( eyeDirection, surfaceNormal ), 0.0 );
|
|
169
|
-
const rf0 = float( 0.
|
|
167
|
+
const rf0 = float( 0.02 );
|
|
170
168
|
const reflectance = mul( pow( float( 1.0 ).sub( theta ), 5.0 ), float( 1.0 ).sub( rf0 ) ).add( rf0 );
|
|
171
169
|
const scatter = max( 0.0, dot( surfaceNormal, eyeDirection ) ).mul( this.waterColor );
|
|
172
|
-
const albedo = mix( this.sunColor.mul( diffuseLight ).mul( 0.3 ).add( scatter ), mirrorSampler.rgb.
|
|
170
|
+
const albedo = mix( this.sunColor.mul( diffuseLight ).mul( 0.3 ).add( scatter ), mirrorSampler.rgb.add( specularLight ), reflectance );
|
|
173
171
|
|
|
174
172
|
return albedo;
|
|
175
173
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Timer, Vector3, Quaternion, Matrix4 } from 'three';
|
|
2
2
|
|
|
3
|
-
const JOLT_PATH = 'https://cdn.jsdelivr.net/npm/jolt-physics@0.
|
|
3
|
+
const JOLT_PATH = 'https://cdn.jsdelivr.net/npm/jolt-physics@1.0.0/dist/jolt-physics.wasm-compat.js';
|
|
4
4
|
|
|
5
5
|
const frameRate = 60;
|
|
6
6
|
|
|
@@ -77,7 +77,7 @@ async function JoltPhysics() {
|
|
|
77
77
|
|
|
78
78
|
if ( Jolt === null ) {
|
|
79
79
|
|
|
80
|
-
const { default: initJolt } = await import(
|
|
80
|
+
const { default: initJolt } = await import( JOLT_PATH /* @vite-ignore */ );
|
|
81
81
|
Jolt = await initJolt();
|
|
82
82
|
|
|
83
83
|
}
|
|
@@ -222,11 +222,13 @@ async function JoltPhysics() {
|
|
|
222
222
|
|
|
223
223
|
//
|
|
224
224
|
|
|
225
|
-
const
|
|
225
|
+
const timer = new Timer();
|
|
226
226
|
|
|
227
227
|
function step() {
|
|
228
228
|
|
|
229
|
-
|
|
229
|
+
timer.update();
|
|
230
|
+
|
|
231
|
+
let deltaTime = timer.getDelta();
|
|
230
232
|
|
|
231
233
|
// Don't go below 30 Hz to prevent spiral of death
|
|
232
234
|
deltaTime = Math.min( deltaTime, 1.0 / 30.0 );
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Timer, Vector3, Quaternion, Matrix4 } from 'three';
|
|
2
2
|
|
|
3
3
|
const RAPIER_PATH = 'https://cdn.skypack.dev/@dimforge/rapier3d-compat@0.17.3';
|
|
4
4
|
|
|
@@ -97,7 +97,7 @@ async function RapierPhysics() {
|
|
|
97
97
|
|
|
98
98
|
if ( RAPIER === null ) {
|
|
99
99
|
|
|
100
|
-
RAPIER = await import(
|
|
100
|
+
RAPIER = await import( RAPIER_PATH /* @vite-ignore */ );
|
|
101
101
|
await RAPIER.init();
|
|
102
102
|
|
|
103
103
|
}
|
|
@@ -301,11 +301,13 @@ async function RapierPhysics() {
|
|
|
301
301
|
|
|
302
302
|
//
|
|
303
303
|
|
|
304
|
-
const
|
|
304
|
+
const timer = new Timer();
|
|
305
305
|
|
|
306
306
|
function step() {
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
timer.update();
|
|
309
|
+
|
|
310
|
+
world.timestep = timer.getDelta();
|
|
309
311
|
world.step();
|
|
310
312
|
|
|
311
313
|
//
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Clock,
|
|
3
2
|
HalfFloatType,
|
|
4
3
|
NoBlending,
|
|
4
|
+
Timer,
|
|
5
5
|
Vector2,
|
|
6
6
|
WebGLRenderTarget
|
|
7
7
|
} from 'three';
|
|
@@ -121,12 +121,12 @@ class EffectComposer {
|
|
|
121
121
|
this.copyPass.material.blending = NoBlending;
|
|
122
122
|
|
|
123
123
|
/**
|
|
124
|
-
* The internal
|
|
124
|
+
* The internal timer for managing time data.
|
|
125
125
|
*
|
|
126
126
|
* @private
|
|
127
|
-
* @type {
|
|
127
|
+
* @type {Timer}
|
|
128
128
|
*/
|
|
129
|
-
this.
|
|
129
|
+
this.timer = new Timer();
|
|
130
130
|
|
|
131
131
|
}
|
|
132
132
|
|
|
@@ -215,9 +215,11 @@ class EffectComposer {
|
|
|
215
215
|
|
|
216
216
|
// deltaTime value is in seconds
|
|
217
217
|
|
|
218
|
+
this.timer.update();
|
|
219
|
+
|
|
218
220
|
if ( deltaTime === undefined ) {
|
|
219
221
|
|
|
220
|
-
deltaTime = this.
|
|
222
|
+
deltaTime = this.timer.getDelta();
|
|
221
223
|
|
|
222
224
|
}
|
|
223
225
|
|
|
@@ -114,7 +114,7 @@ class RenderTransitionPass extends Pass {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
/**
|
|
117
|
-
* Sets the texture threshold. This value
|
|
117
|
+
* Sets the texture threshold. This value defines how strong the texture effects
|
|
118
118
|
* the transition. Must be in the range `[0,1]` (0 means full effect, 1 means no effect).
|
|
119
119
|
*
|
|
120
120
|
* @param {boolean|number} value - The threshold value.
|
|
@@ -141,7 +141,7 @@ const _matrix2 = new Matrix4();
|
|
|
141
141
|
* This renderer can be used to apply hierarchical 3D transformations to DOM elements
|
|
142
142
|
* via the CSS3 [transform](https://www.w3schools.com/cssref/css3_pr_transform.asp) property.
|
|
143
143
|
* `CSS3DRenderer` is particularly interesting if you want to apply 3D effects to a website without
|
|
144
|
-
* canvas based rendering. It can also be used in order to combine DOM elements with
|
|
144
|
+
* canvas based rendering. It can also be used in order to combine DOM elements with WebGL content.
|
|
145
145
|
*
|
|
146
146
|
* There are, however, some important limitations:
|
|
147
147
|
*
|
|
@@ -188,8 +188,8 @@ class SVGRenderer {
|
|
|
188
188
|
};
|
|
189
189
|
|
|
190
190
|
/**
|
|
191
|
-
* Sets the render quality. Setting to `high`
|
|
192
|
-
*
|
|
191
|
+
* Sets the render quality. Setting to `high` makes the browser improve SVG quality
|
|
192
|
+
* over rendering speed and geometric precision.
|
|
193
193
|
*
|
|
194
194
|
* @param {('low'|'high')} quality - The quality.
|
|
195
195
|
*/
|
|
@@ -91,8 +91,12 @@ const GTAOShader = {
|
|
|
91
91
|
#define FRAGMENT_OUTPUT vec4(vec3(ao), 1.)
|
|
92
92
|
#endif
|
|
93
93
|
|
|
94
|
-
vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {
|
|
95
|
-
|
|
94
|
+
vec3 getViewPosition( const in vec2 screenPosition, const in float depth ) {
|
|
95
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
96
|
+
vec4 clipSpacePosition = vec4( vec2( screenPosition ) * 2.0 - 1.0, depth, 1.0 );
|
|
97
|
+
#else
|
|
98
|
+
vec4 clipSpacePosition = vec4( vec3( screenPosition, depth ) * 2.0 - 1.0, 1.0 );
|
|
99
|
+
#endif
|
|
96
100
|
vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
|
|
97
101
|
return viewSpacePosition.xyz / viewSpacePosition.w;
|
|
98
102
|
}
|
|
@@ -154,10 +158,19 @@ const GTAOShader = {
|
|
|
154
158
|
|
|
155
159
|
void main() {
|
|
156
160
|
float depth = getDepth(vUv.xy);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
+
|
|
162
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
163
|
+
if (depth <= 0.0) {
|
|
164
|
+
discard;
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
#else
|
|
168
|
+
if (depth >= 1.0) {
|
|
169
|
+
discard;
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
#endif
|
|
173
|
+
|
|
161
174
|
vec3 viewPos = getViewPosition(vUv, depth);
|
|
162
175
|
vec3 viewNormal = getViewNormal(vUv);
|
|
163
176
|
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*
|
|
9
9
|
* Used by {@link HalftonePass}.
|
|
10
10
|
*
|
|
11
|
-
* Shape (1 = Dot, 2 = Ellipse, 3 = Line, 4 = Square)
|
|
11
|
+
* Shape (1 = Dot, 2 = Ellipse, 3 = Line, 4 = Square, 5 = Diamond)
|
|
12
12
|
* Blending Mode (1 = Linear, 2 = Multiply, 3 = Add, 4 = Lighter, 5 = Darker)
|
|
13
13
|
*
|
|
14
14
|
* @constant
|
|
@@ -49,11 +49,13 @@ const HalftoneShader = {
|
|
|
49
49
|
|
|
50
50
|
#define SQRT2_MINUS_ONE 0.41421356
|
|
51
51
|
#define SQRT2_HALF_MINUS_ONE 0.20710678
|
|
52
|
+
#define PI 3.14159265
|
|
52
53
|
#define PI2 6.28318531
|
|
53
54
|
#define SHAPE_DOT 1
|
|
54
55
|
#define SHAPE_ELLIPSE 2
|
|
55
56
|
#define SHAPE_LINE 3
|
|
56
57
|
#define SHAPE_SQUARE 4
|
|
58
|
+
#define SHAPE_DIAMOND 5
|
|
57
59
|
#define BLENDING_LINEAR 1
|
|
58
60
|
#define BLENDING_MULTIPLY 2
|
|
59
61
|
#define BLENDING_ADD 3
|
|
@@ -129,6 +131,15 @@ const HalftoneShader = {
|
|
|
129
131
|
rad = pow( abs( rad ), 1.4 );
|
|
130
132
|
rad = rad_max * ( rad + ( ( sin_t > cos_t ) ? rad - sin_t * rad : rad - cos_t * rad ) );
|
|
131
133
|
|
|
134
|
+
} else if ( shape == SHAPE_DIAMOND ) {
|
|
135
|
+
|
|
136
|
+
float angle45 = PI / 4.0;
|
|
137
|
+
float theta = atan( p.y - coord.y, p.x - coord.x ) - angle - angle45;
|
|
138
|
+
float sin_t = abs( sin( theta ) );
|
|
139
|
+
float cos_t = abs( cos( theta ) );
|
|
140
|
+
rad = pow( abs( rad ), 1.4 );
|
|
141
|
+
rad = rad_max * ( rad + ( ( sin_t > cos_t ) ? rad - sin_t * rad : rad - cos_t * rad ) );
|
|
142
|
+
|
|
132
143
|
}
|
|
133
144
|
|
|
134
145
|
return rad - dist;
|
|
@@ -86,8 +86,12 @@ const PoissonDenoiseShader = {
|
|
|
86
86
|
|
|
87
87
|
const vec3 poissonDisk[SAMPLES] = SAMPLE_VECTORS;
|
|
88
88
|
|
|
89
|
-
vec3 getViewPosition(const in vec2 screenPosition, const in float depth) {
|
|
90
|
-
|
|
89
|
+
vec3 getViewPosition( const in vec2 screenPosition, const in float depth ) {
|
|
90
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
91
|
+
vec4 clipSpacePosition = vec4( vec2( screenPosition ) * 2.0 - 1.0, depth, 1.0 );
|
|
92
|
+
#else
|
|
93
|
+
vec4 clipSpacePosition = vec4( vec3( screenPosition, depth ) * 2.0 - 1.0, 1.0 );
|
|
94
|
+
#endif
|
|
91
95
|
vec4 viewSpacePosition = cameraProjectionMatrixInverse * clipSpacePosition;
|
|
92
96
|
return viewSpacePosition.xyz / viewSpacePosition.w;
|
|
93
97
|
}
|
|
@@ -153,9 +153,15 @@ const SAOShader = {
|
|
|
153
153
|
angle += ANGLE_STEP;
|
|
154
154
|
|
|
155
155
|
float sampleDepth = getDepth( sampleUv );
|
|
156
|
-
|
|
156
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
157
|
+
if( sampleDepth <= 0.0 + EPSILON ) {
|
|
157
158
|
continue;
|
|
158
159
|
}
|
|
160
|
+
#else
|
|
161
|
+
if( sampleDepth >= 1.0 - EPSILON ) {
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
#endif
|
|
159
165
|
|
|
160
166
|
float sampleViewZ = getViewZ( sampleDepth );
|
|
161
167
|
vec3 sampleViewPosition = getViewPosition( sampleUv, sampleDepth, sampleViewZ );
|
|
@@ -170,9 +176,16 @@ const SAOShader = {
|
|
|
170
176
|
|
|
171
177
|
void main() {
|
|
172
178
|
float centerDepth = getDepth( vUv );
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
179
|
+
|
|
180
|
+
#ifdef USE_REVERSED_DEPTH_BUFFER
|
|
181
|
+
if( centerDepth <= 0.0 + EPSILON ) {
|
|
182
|
+
discard;
|
|
183
|
+
}
|
|
184
|
+
#else
|
|
185
|
+
if( centerDepth >= 1.0 - EPSILON ) {
|
|
186
|
+
discard;
|
|
187
|
+
}
|
|
188
|
+
#endif
|
|
176
189
|
|
|
177
190
|
float centerViewZ = getViewZ( centerDepth );
|
|
178
191
|
vec3 viewPosition = getViewPosition( vUv, centerDepth, centerViewZ );
|