super-three 0.167.0 → 0.168.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/build/three.cjs +165 -44
- package/build/three.module.js +165 -45
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +23600 -21931
- package/build/three.webgpu.min.js +1 -1
- package/examples/jsm/Addons.js +3 -1
- package/examples/jsm/animation/AnimationClipCreator.js +1 -1
- package/examples/jsm/capabilities/WebGL.js +27 -21
- package/examples/jsm/controls/ArcballControls.js +174 -158
- package/examples/jsm/controls/DragControls.js +260 -132
- package/examples/jsm/controls/FirstPersonControls.js +175 -163
- package/examples/jsm/controls/FlyControls.js +194 -188
- package/examples/jsm/controls/OrbitControls.js +777 -786
- package/examples/jsm/controls/PointerLockControls.js +24 -15
- package/examples/jsm/controls/TrackballControls.js +453 -452
- package/examples/jsm/effects/AnaglyphEffect.js +6 -13
- package/examples/jsm/effects/ParallaxBarrierEffect.js +17 -11
- package/examples/jsm/effects/StereoEffect.js +6 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -1
- package/examples/jsm/exporters/GLTFExporter.js +6 -1
- package/examples/jsm/exporters/USDZExporter.js +29 -8
- package/examples/jsm/helpers/LightProbeHelper.js +42 -43
- package/examples/jsm/loaders/KTX2Loader.js +19 -7
- package/examples/jsm/loaders/MaterialXLoader.js +11 -4
- package/examples/jsm/loaders/PCDLoader.js +9 -9
- package/examples/jsm/objects/SkyMesh.js +188 -0
- package/examples/jsm/objects/Water2Mesh.js +159 -0
- package/examples/jsm/objects/WaterMesh.js +102 -0
- package/examples/jsm/physics/RapierPhysics.js +20 -0
- package/examples/jsm/postprocessing/OutlinePass.js +31 -46
- package/examples/jsm/postprocessing/SSAARenderPass.js +3 -1
- package/examples/jsm/shaders/BleachBypassShader.js +1 -2
- package/examples/jsm/shaders/OutputShader.js +1 -1
- package/examples/jsm/transpiler/TSLEncoder.js +8 -8
- package/examples/jsm/utils/TextureUtils.js +1 -1
- package/package.json +2 -1
- package/src/Three.WebGPU.js +6 -0
- package/src/Three.js +1 -0
- package/src/constants.js +1 -1
- package/src/extras/Controls.js +32 -0
- package/src/loaders/ObjectLoader.js +3 -3
- package/src/{nodes/loaders → loaders/nodes}/NodeLoader.js +4 -4
- package/src/{nodes/loaders → loaders/nodes}/NodeMaterialLoader.js +1 -2
- package/src/materials/Material.js +4 -7
- package/src/{nodes/materials → materials/nodes}/InstancedPointsNodeMaterial.js +33 -24
- package/src/{nodes/materials → materials/nodes}/Line2NodeMaterial.js +34 -37
- package/src/{nodes/materials → materials/nodes}/LineBasicNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/LineDashedNodeMaterial.js +7 -9
- package/src/{nodes/materials → materials/nodes}/MeshBasicNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/MeshLambertNodeMaterial.js +5 -5
- package/src/{nodes/materials → materials/nodes}/MeshMatcapNodeMaterial.js +8 -8
- package/src/materials/nodes/MeshNormalNodeMaterial.js +40 -0
- package/src/{nodes/materials → materials/nodes}/MeshPhongNodeMaterial.js +9 -8
- package/src/{nodes/materials → materials/nodes}/MeshPhysicalNodeMaterial.js +18 -17
- package/src/{nodes/materials → materials/nodes}/MeshSSSNodeMaterial.js +6 -6
- package/src/{nodes/materials → materials/nodes}/MeshStandardNodeMaterial.js +17 -11
- package/src/{nodes/materials → materials/nodes}/MeshToonNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/NodeMaterial.js +67 -86
- package/src/{nodes/materials/Materials.js → materials/nodes/NodeMaterials.js} +1 -1
- package/src/{nodes/materials → materials/nodes}/PointsNodeMaterial.js +3 -4
- package/src/{nodes/materials → materials/nodes}/ShadowNodeMaterial.js +4 -4
- package/src/{nodes/materials → materials/nodes}/SpriteNodeMaterial.js +11 -11
- package/src/{nodes/materials → materials/nodes}/VolumeNodeMaterial.js +14 -16
- package/src/nodes/Nodes.js +103 -159
- package/src/nodes/TSL.js +176 -0
- package/src/nodes/accessors/AccessorsUtils.js +8 -8
- package/src/nodes/accessors/BatchNode.js +48 -20
- package/src/nodes/accessors/{BitangentNode.js → Bitangent.js} +9 -9
- package/src/nodes/accessors/BufferAttributeNode.js +5 -5
- package/src/nodes/accessors/BufferNode.js +4 -4
- package/src/nodes/accessors/{CameraNode.js → Camera.js} +10 -10
- package/src/nodes/accessors/ClippingNode.js +16 -14
- package/src/nodes/accessors/CubeTextureNode.js +5 -7
- package/src/nodes/accessors/InstanceNode.js +17 -13
- package/src/nodes/accessors/InstancedPointsMaterialNode.js +4 -4
- package/src/nodes/accessors/MaterialNode.js +52 -55
- package/src/nodes/accessors/MaterialProperties.js +3 -0
- package/src/nodes/accessors/MaterialReferenceNode.js +6 -4
- package/src/nodes/accessors/ModelNode.js +11 -11
- package/src/nodes/accessors/ModelViewProjectionNode.js +6 -7
- package/src/nodes/accessors/MorphNode.js +12 -12
- package/src/nodes/accessors/Normal.js +62 -0
- package/src/nodes/accessors/Object3DNode.js +10 -10
- package/src/nodes/accessors/PointUVNode.js +4 -4
- package/src/nodes/accessors/Position.js +10 -0
- package/src/nodes/accessors/ReferenceBaseNode.js +143 -0
- package/src/nodes/accessors/ReferenceNode.js +13 -7
- package/src/nodes/accessors/ReflectVector.js +10 -0
- package/src/nodes/accessors/RendererReferenceNode.js +6 -6
- package/src/nodes/accessors/SceneNode.js +5 -6
- package/src/nodes/accessors/SkinningNode.js +84 -21
- package/src/nodes/accessors/StorageBufferNode.js +4 -5
- package/src/nodes/accessors/StorageTextureNode.js +5 -5
- package/src/nodes/accessors/Tangent.js +22 -0
- package/src/nodes/accessors/Texture3DNode.js +11 -11
- package/src/nodes/accessors/{TextureBicubicNode.js → TextureBicubic.js} +3 -32
- package/src/nodes/accessors/TextureNode.js +16 -21
- package/src/nodes/accessors/TextureSizeNode.js +4 -6
- package/src/nodes/accessors/{UniformsNode.js → UniformArrayNode.js} +17 -8
- package/src/nodes/accessors/UserDataNode.js +4 -4
- package/src/nodes/accessors/VelocityNode.js +83 -0
- package/src/nodes/accessors/VertexColorNode.js +4 -4
- package/src/nodes/code/CodeNode.js +5 -5
- package/src/nodes/code/ExpressionNode.js +4 -4
- package/src/nodes/code/FunctionCallNode.js +5 -5
- package/src/nodes/code/FunctionNode.js +5 -23
- package/src/nodes/code/ScriptableNode.js +4 -6
- package/src/nodes/code/ScriptableValueNode.js +4 -6
- package/src/nodes/core/AssignNode.js +5 -5
- package/src/nodes/core/AttributeNode.js +7 -20
- package/src/nodes/core/BypassNode.js +5 -5
- package/src/nodes/core/CacheNode.js +5 -5
- package/src/nodes/core/ConstNode.js +2 -2
- package/src/nodes/core/ContextNode.js +17 -11
- package/src/nodes/core/IndexNode.js +12 -7
- package/src/nodes/core/InputNode.js +2 -2
- package/src/nodes/core/MRTNode.js +12 -6
- package/src/nodes/core/Node.js +39 -19
- package/src/nodes/core/NodeBuilder.js +46 -33
- package/src/nodes/core/NodeUtils.js +1 -0
- package/src/nodes/core/OutputStructNode.js +4 -4
- package/src/nodes/core/ParameterNode.js +4 -4
- package/src/nodes/core/PropertyNode.js +32 -32
- package/src/nodes/core/StackNode.js +26 -10
- package/src/nodes/core/StructTypeNode.js +2 -2
- package/src/nodes/core/TempNode.js +2 -2
- package/src/nodes/core/UniformGroupNode.js +8 -9
- package/src/nodes/core/UniformNode.js +4 -4
- package/src/nodes/core/VarNode.js +6 -6
- package/src/nodes/core/VaryingNode.js +5 -5
- package/src/nodes/display/AfterImageNode.js +9 -9
- package/src/nodes/display/AnaglyphPassNode.js +61 -0
- package/src/nodes/display/AnamorphicNode.js +11 -11
- package/src/nodes/display/BleachBypass.js +26 -0
- package/src/nodes/display/BlendMode.js +54 -0
- package/src/nodes/display/BloomNode.js +21 -19
- package/src/nodes/display/BumpMapNode.js +7 -12
- package/src/nodes/display/ColorAdjustment.js +46 -0
- package/src/nodes/display/ColorSpaceFunctions.js +38 -0
- package/src/nodes/display/ColorSpaceNode.js +40 -63
- package/src/nodes/display/DenoiseNode.js +20 -17
- package/src/nodes/display/DepthOfFieldNode.js +8 -6
- package/src/nodes/display/DotScreenNode.js +10 -22
- package/src/nodes/display/FXAANode.js +17 -15
- package/src/nodes/display/FilmNode.js +7 -6
- package/src/nodes/display/FrontFacingNode.js +5 -5
- package/src/nodes/display/GTAONode.js +19 -15
- package/src/nodes/display/GaussianBlurNode.js +11 -8
- package/src/nodes/display/Lut3DNode.js +6 -5
- package/src/nodes/display/MotionBlur.js +25 -0
- package/src/nodes/display/NormalMapNode.js +8 -10
- package/src/nodes/display/ParallaxBarrierPassNode.js +55 -0
- package/src/nodes/display/PassNode.js +84 -8
- package/src/nodes/display/PixelationPassNode.js +12 -7
- package/src/nodes/display/PosterizeNode.js +4 -6
- package/src/nodes/display/RGBShiftNode.js +8 -7
- package/src/nodes/display/RenderOutputNode.js +9 -9
- package/src/nodes/display/SSAAPassNode.js +284 -0
- package/src/nodes/display/Sepia.js +17 -0
- package/src/nodes/display/SobelOperatorNode.js +9 -7
- package/src/nodes/display/StereoCompositePassNode.js +107 -0
- package/src/nodes/display/StereoPassNode.js +80 -0
- package/src/nodes/display/ToneMappingFunctions.js +190 -0
- package/src/nodes/display/ToneMappingNode.js +12 -173
- package/src/nodes/display/TransitionNode.js +9 -8
- package/src/nodes/display/ViewportDepthNode.js +30 -29
- package/src/nodes/display/ViewportDepthTextureNode.js +6 -8
- package/src/nodes/display/ViewportNode.js +26 -25
- package/src/nodes/display/ViewportSharedTextureNode.js +6 -8
- package/src/nodes/display/ViewportTextureNode.js +7 -10
- package/src/nodes/fog/FogExp2Node.js +4 -6
- package/src/nodes/fog/FogNode.js +5 -7
- package/src/nodes/fog/FogRangeNode.js +4 -6
- package/src/nodes/functions/BSDF/BRDF_GGX.js +4 -4
- package/src/nodes/functions/BSDF/BRDF_Lambert.js +2 -2
- package/src/nodes/functions/BSDF/BRDF_Sheen.js +6 -6
- package/src/nodes/functions/BSDF/DFGApprox.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX.js +2 -2
- package/src/nodes/functions/BSDF/D_GGX_Anisotropic.js +3 -3
- package/src/nodes/functions/BSDF/EnvironmentBRDF.js +2 -2
- package/src/nodes/functions/BSDF/F_Schlick.js +2 -2
- package/src/nodes/functions/BSDF/LTC.js +6 -6
- package/src/nodes/functions/BSDF/Schlick_to_F0.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +2 -2
- package/src/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +2 -2
- package/src/nodes/functions/BasicLightingModel.js +1 -1
- package/src/nodes/functions/PhongLightingModel.js +5 -5
- package/src/nodes/functions/PhysicalLightingModel.js +32 -31
- package/src/nodes/functions/ShadowMaskModel.js +1 -1
- package/src/nodes/functions/ToonLightingModel.js +3 -3
- package/src/nodes/functions/material/getGeometryRoughness.js +4 -4
- package/src/nodes/functions/material/getRoughness.js +2 -2
- package/src/nodes/geometry/RangeNode.js +4 -4
- package/src/nodes/gpgpu/ComputeNode.js +5 -5
- package/src/nodes/lighting/AONode.js +2 -2
- package/src/nodes/lighting/AmbientLightNode.js +2 -7
- package/src/nodes/lighting/AnalyticLightNode.js +34 -13
- package/src/nodes/lighting/BasicEnvironmentNode.js +4 -3
- package/src/nodes/lighting/BasicLightMapNode.js +3 -3
- package/src/nodes/lighting/DirectionalLightNode.js +2 -7
- package/src/nodes/lighting/EnvironmentNode.js +20 -19
- package/src/nodes/lighting/HemisphereLightNode.js +3 -7
- package/src/nodes/lighting/IESSpotLightNode.js +3 -8
- package/src/nodes/lighting/IrradianceNode.js +2 -2
- package/src/nodes/lighting/LightNode.js +5 -5
- package/src/nodes/lighting/LightProbeNode.js +76 -0
- package/src/nodes/lighting/LightUtils.js +3 -3
- package/src/nodes/lighting/LightingContextNode.js +15 -17
- package/src/nodes/lighting/LightingNode.js +2 -2
- package/src/nodes/lighting/LightsNode.js +94 -76
- package/src/nodes/lighting/PointLightNode.js +3 -8
- package/src/nodes/lighting/RectAreaLightNode.js +2 -6
- package/src/nodes/lighting/SpotLightNode.js +3 -8
- package/src/nodes/materialx/MaterialXNodes.js +2 -2
- package/src/nodes/materialx/lib/mx_hsv.js +36 -31
- package/src/nodes/materialx/lib/mx_noise.js +96 -96
- package/src/nodes/materialx/lib/mx_transform_color.js +2 -2
- package/src/nodes/math/{CondNode.js → ConditionalNode.js} +18 -7
- package/src/nodes/math/Hash.js +13 -0
- package/src/nodes/math/MathNode.js +124 -124
- package/src/nodes/math/MathUtils.js +0 -7
- package/src/nodes/math/OperatorNode.js +94 -52
- package/src/nodes/math/TriNoise3D.js +19 -29
- package/src/nodes/pmrem/PMREMNode.js +58 -15
- package/src/nodes/pmrem/PMREMUtils.js +46 -46
- package/src/nodes/procedural/Checker.js +14 -0
- package/src/nodes/tsl/TSLBase.js +30 -0
- package/src/nodes/{shadernode/ShaderNode.js → tsl/TSLCore.js} +105 -97
- package/src/nodes/utils/ArrayElementNode.js +2 -2
- package/src/nodes/utils/ConvertNode.js +2 -2
- package/src/nodes/utils/CubeMapNode.js +157 -0
- package/src/nodes/utils/Discard.js +8 -0
- package/src/nodes/utils/EquirectUVNode.js +5 -5
- package/src/nodes/utils/FlipNode.js +65 -0
- package/src/nodes/utils/FunctionOverloadingNode.js +5 -5
- package/src/nodes/utils/JoinNode.js +2 -2
- package/src/nodes/utils/LoopNode.js +12 -6
- package/src/nodes/utils/MatcapUVNode.js +6 -6
- package/src/nodes/utils/MaxMipLevelNode.js +4 -4
- package/src/nodes/utils/OscNode.js +7 -7
- package/src/nodes/utils/Packing.js +4 -0
- package/src/nodes/utils/RTTNode.js +8 -8
- package/src/nodes/utils/ReflectorNode.js +8 -3
- package/src/nodes/utils/RemapNode.js +7 -7
- package/src/nodes/utils/RotateNode.js +4 -12
- package/src/nodes/utils/SetNode.js +2 -2
- package/src/nodes/utils/SplitNode.js +2 -2
- package/src/nodes/utils/SpriteSheetUVNode.js +5 -5
- package/src/nodes/utils/SpriteUtils.js +47 -0
- package/src/nodes/utils/StorageArrayElementNode.js +4 -6
- package/src/nodes/utils/TimerNode.js +5 -5
- package/src/nodes/utils/TriplanarTexturesNode.js +7 -9
- package/src/nodes/utils/UVUtils.js +19 -0
- package/src/nodes/utils/ViewportUtils.js +14 -0
- package/src/objects/BatchedMesh.js +2 -3
- package/src/renderers/WebGLRenderer.js +24 -0
- package/src/renderers/common/Backend.js +2 -2
- package/src/renderers/common/Background.js +3 -1
- package/src/renderers/common/BindGroup.js +3 -1
- package/src/renderers/common/Bindings.js +13 -15
- package/src/renderers/common/ClippingContext.js +14 -5
- package/src/renderers/common/CubeRenderTarget.js +9 -3
- package/src/renderers/common/PostProcessing.js +4 -1
- package/src/renderers/common/QuadMesh.js +2 -0
- package/src/renderers/common/RenderContext.js +24 -0
- package/src/renderers/common/RenderList.js +1 -1
- package/src/renderers/common/RenderObject.js +2 -2
- package/src/renderers/common/Renderer.js +75 -49
- package/src/renderers/common/SampledTexture.js +12 -3
- package/src/renderers/common/StandardRenderer.js +18 -0
- package/src/renderers/common/Textures.js +8 -12
- package/src/renderers/common/extras/PMREMGenerator.js +12 -13
- package/src/renderers/common/nodes/NodeBuilderState.js +1 -1
- package/src/renderers/common/nodes/NodeLibrary.js +118 -0
- package/src/renderers/common/nodes/NodeSampledTexture.js +2 -2
- package/src/renderers/common/nodes/Nodes.js +36 -9
- package/src/renderers/common/nodes/StandardNodeLibrary.js +105 -0
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLProgram.js +1 -1
- package/src/renderers/webgl/WebGLProperties.js +7 -0
- package/src/renderers/webgl/WebGLTextures.js +61 -4
- package/src/renderers/webgl-fallback/WebGLBackend.js +88 -68
- package/src/renderers/webgl-fallback/nodes/GLSLNodeBuilder.js +57 -9
- package/src/renderers/webgl-fallback/utils/WebGLState.js +21 -0
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +28 -21
- package/src/renderers/webgpu/WebGPUBackend.js +86 -68
- package/src/renderers/webgpu/WebGPURenderer.js +8 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +99 -63
- package/src/renderers/webgpu/utils/WebGPUBindingUtils.js +45 -21
- package/src/renderers/webgpu/utils/WebGPUConstants.js +2 -1
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +6 -15
- package/src/renderers/webgpu/utils/WebGPUTexturePassUtils.js +62 -5
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +36 -21
- package/src/renderers/webgpu/utils/WebGPUUtils.js +18 -1
- package/src/renderers/webxr/WebXRManager.js +32 -25
- package/examples/jsm/loaders/LogLuvLoader.js +0 -606
- package/src/nodes/accessors/NormalNode.js +0 -14
- package/src/nodes/accessors/PositionNode.js +0 -10
- package/src/nodes/accessors/ReflectVectorNode.js +0 -10
- package/src/nodes/accessors/TangentNode.js +0 -23
- package/src/nodes/core/NodeKeywords.js +0 -80
- package/src/nodes/display/BlendModeNode.js +0 -128
- package/src/nodes/display/ColorAdjustmentNode.js +0 -104
- package/src/nodes/materials/MeshNormalNodeMaterial.js +0 -40
- package/src/nodes/math/HashNode.js +0 -34
- package/src/nodes/procedural/CheckerNode.js +0 -42
- package/src/nodes/utils/DiscardNode.js +0 -28
- package/src/nodes/utils/PackingNode.js +0 -55
- package/src/nodes/utils/RotateUVNode.js +0 -35
- /package/src/{nodes/loaders → loaders/nodes}/NodeObjectLoader.js +0 -0
- /package/src/nodes/accessors/{UVNode.js → UV.js} +0 -0
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LinearFilter,
|
|
3
3
|
Matrix3,
|
|
4
|
-
Mesh,
|
|
5
4
|
NearestFilter,
|
|
6
|
-
OrthographicCamera,
|
|
7
|
-
PlaneGeometry,
|
|
8
5
|
RGBAFormat,
|
|
9
|
-
Scene,
|
|
10
6
|
ShaderMaterial,
|
|
11
7
|
StereoCamera,
|
|
12
8
|
WebGLRenderTarget
|
|
13
9
|
} from 'three';
|
|
10
|
+
import { FullScreenQuad } from '../postprocessing/Pass.js';
|
|
14
11
|
|
|
15
12
|
class AnaglyphEffect {
|
|
16
13
|
|
|
@@ -30,10 +27,6 @@ class AnaglyphEffect {
|
|
|
30
27
|
- 0.00155529, - 0.0184503, 1.2264
|
|
31
28
|
] );
|
|
32
29
|
|
|
33
|
-
const _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
|
|
34
|
-
|
|
35
|
-
const _scene = new Scene();
|
|
36
|
-
|
|
37
30
|
const _stereo = new StereoCamera();
|
|
38
31
|
|
|
39
32
|
const _params = { minFilter: LinearFilter, magFilter: NearestFilter, format: RGBAFormat };
|
|
@@ -99,8 +92,7 @@ class AnaglyphEffect {
|
|
|
99
92
|
|
|
100
93
|
} );
|
|
101
94
|
|
|
102
|
-
const
|
|
103
|
-
_scene.add( _mesh );
|
|
95
|
+
const _quad = new FullScreenQuad( _material );
|
|
104
96
|
|
|
105
97
|
this.setSize = function ( width, height ) {
|
|
106
98
|
|
|
@@ -132,7 +124,7 @@ class AnaglyphEffect {
|
|
|
132
124
|
renderer.render( scene, _stereo.cameraR );
|
|
133
125
|
|
|
134
126
|
renderer.setRenderTarget( null );
|
|
135
|
-
|
|
127
|
+
_quad.render( renderer );
|
|
136
128
|
|
|
137
129
|
renderer.setRenderTarget( currentRenderTarget );
|
|
138
130
|
|
|
@@ -142,8 +134,9 @@ class AnaglyphEffect {
|
|
|
142
134
|
|
|
143
135
|
_renderTargetL.dispose();
|
|
144
136
|
_renderTargetR.dispose();
|
|
145
|
-
|
|
146
|
-
|
|
137
|
+
|
|
138
|
+
_material.dispose();
|
|
139
|
+
_quad.dispose();
|
|
147
140
|
|
|
148
141
|
};
|
|
149
142
|
|
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LinearFilter,
|
|
3
|
-
Mesh,
|
|
4
3
|
NearestFilter,
|
|
5
|
-
OrthographicCamera,
|
|
6
|
-
PlaneGeometry,
|
|
7
4
|
RGBAFormat,
|
|
8
|
-
Scene,
|
|
9
5
|
ShaderMaterial,
|
|
10
6
|
StereoCamera,
|
|
11
7
|
WebGLRenderTarget
|
|
12
8
|
} from 'three';
|
|
9
|
+
import { FullScreenQuad } from '../postprocessing/Pass.js';
|
|
13
10
|
|
|
14
11
|
class ParallaxBarrierEffect {
|
|
15
12
|
|
|
16
13
|
constructor( renderer ) {
|
|
17
14
|
|
|
18
|
-
const _camera = new OrthographicCamera( - 1, 1, 1, - 1, 0, 1 );
|
|
19
|
-
|
|
20
|
-
const _scene = new Scene();
|
|
21
|
-
|
|
22
15
|
const _stereo = new StereoCamera();
|
|
23
16
|
|
|
24
17
|
const _params = { minFilter: LinearFilter, magFilter: NearestFilter, format: RGBAFormat };
|
|
@@ -77,8 +70,7 @@ class ParallaxBarrierEffect {
|
|
|
77
70
|
|
|
78
71
|
} );
|
|
79
72
|
|
|
80
|
-
const
|
|
81
|
-
_scene.add( mesh );
|
|
73
|
+
const _quad = new FullScreenQuad( _material );
|
|
82
74
|
|
|
83
75
|
this.setSize = function ( width, height ) {
|
|
84
76
|
|
|
@@ -93,6 +85,8 @@ class ParallaxBarrierEffect {
|
|
|
93
85
|
|
|
94
86
|
this.render = function ( scene, camera ) {
|
|
95
87
|
|
|
88
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
89
|
+
|
|
96
90
|
if ( scene.matrixWorldAutoUpdate === true ) scene.updateMatrixWorld();
|
|
97
91
|
|
|
98
92
|
if ( camera.parent === null && camera.matrixWorldAutoUpdate === true ) camera.updateMatrixWorld();
|
|
@@ -108,7 +102,19 @@ class ParallaxBarrierEffect {
|
|
|
108
102
|
renderer.render( scene, _stereo.cameraR );
|
|
109
103
|
|
|
110
104
|
renderer.setRenderTarget( null );
|
|
111
|
-
|
|
105
|
+
_quad.render( renderer );
|
|
106
|
+
|
|
107
|
+
renderer.setRenderTarget( currentRenderTarget );
|
|
108
|
+
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
this.dispose = function () {
|
|
112
|
+
|
|
113
|
+
_renderTargetL.dispose();
|
|
114
|
+
_renderTargetR.dispose();
|
|
115
|
+
|
|
116
|
+
_material.dispose();
|
|
117
|
+
_quad.dispose();
|
|
112
118
|
|
|
113
119
|
};
|
|
114
120
|
|
|
@@ -31,9 +31,12 @@ class StereoEffect {
|
|
|
31
31
|
|
|
32
32
|
_stereo.update( camera );
|
|
33
33
|
|
|
34
|
+
const currentAutoClear = renderer.autoClear;
|
|
34
35
|
renderer.getSize( size );
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
renderer.autoClear = false;
|
|
38
|
+
renderer.clear();
|
|
39
|
+
|
|
37
40
|
renderer.setScissorTest( true );
|
|
38
41
|
|
|
39
42
|
renderer.setScissor( 0, 0, size.width / 2, size.height );
|
|
@@ -46,6 +49,8 @@ class StereoEffect {
|
|
|
46
49
|
|
|
47
50
|
renderer.setScissorTest( false );
|
|
48
51
|
|
|
52
|
+
renderer.autoClear = currentAutoClear;
|
|
53
|
+
|
|
49
54
|
};
|
|
50
55
|
|
|
51
56
|
}
|
|
@@ -2837,7 +2837,12 @@ class GLTFMaterialsVolumeExtension {
|
|
|
2837
2837
|
|
|
2838
2838
|
}
|
|
2839
2839
|
|
|
2840
|
-
|
|
2840
|
+
if ( material.attenuationDistance !== Infinity ) {
|
|
2841
|
+
|
|
2842
|
+
extensionDef.attenuationDistance = material.attenuationDistance;
|
|
2843
|
+
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2841
2846
|
extensionDef.attenuationColor = material.attenuationColor.toArray();
|
|
2842
2847
|
|
|
2843
2848
|
materialDef.extensions = materialDef.extensions || {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NoColorSpace,
|
|
3
3
|
DoubleSide,
|
|
4
|
+
Color,
|
|
4
5
|
} from 'three';
|
|
5
6
|
|
|
6
7
|
import {
|
|
@@ -584,7 +585,7 @@ function buildMaterial( material, textures, quickLookCompatible = false ) {
|
|
|
584
585
|
|
|
585
586
|
inputs.push( `${ pad }color3f inputs:emissiveColor.connect = </Materials/Material_${ material.id }/Texture_${ material.emissiveMap.id }_emissive.outputs:rgb>` );
|
|
586
587
|
|
|
587
|
-
samplers.push( buildTexture( material.emissiveMap, 'emissive' ) );
|
|
588
|
+
samplers.push( buildTexture( material.emissiveMap, 'emissive', new Color( material.emissive.r * material.emissiveIntensity, material.emissive.g * material.emissiveIntensity, material.emissive.b * material.emissiveIntensity ) ) );
|
|
588
589
|
|
|
589
590
|
} else if ( material.emissive.getHex() > 0 ) {
|
|
590
591
|
|
|
@@ -604,15 +605,15 @@ function buildMaterial( material, textures, quickLookCompatible = false ) {
|
|
|
604
605
|
|
|
605
606
|
inputs.push( `${ pad }float inputs:occlusion.connect = </Materials/Material_${ material.id }/Texture_${ material.aoMap.id }_occlusion.outputs:r>` );
|
|
606
607
|
|
|
607
|
-
samplers.push( buildTexture( material.aoMap, 'occlusion' ) );
|
|
608
|
+
samplers.push( buildTexture( material.aoMap, 'occlusion', new Color( material.aoMapIntensity, material.aoMapIntensity, material.aoMapIntensity ) ) );
|
|
608
609
|
|
|
609
610
|
}
|
|
610
611
|
|
|
611
|
-
if ( material.roughnessMap !== null
|
|
612
|
+
if ( material.roughnessMap !== null ) {
|
|
612
613
|
|
|
613
614
|
inputs.push( `${ pad }float inputs:roughness.connect = </Materials/Material_${ material.id }/Texture_${ material.roughnessMap.id }_roughness.outputs:g>` );
|
|
614
615
|
|
|
615
|
-
samplers.push( buildTexture( material.roughnessMap, 'roughness' ) );
|
|
616
|
+
samplers.push( buildTexture( material.roughnessMap, 'roughness', new Color( material.roughness, material.roughness, material.roughness ) ) );
|
|
616
617
|
|
|
617
618
|
} else {
|
|
618
619
|
|
|
@@ -620,11 +621,11 @@ function buildMaterial( material, textures, quickLookCompatible = false ) {
|
|
|
620
621
|
|
|
621
622
|
}
|
|
622
623
|
|
|
623
|
-
if ( material.metalnessMap !== null
|
|
624
|
+
if ( material.metalnessMap !== null ) {
|
|
624
625
|
|
|
625
626
|
inputs.push( `${ pad }float inputs:metallic.connect = </Materials/Material_${ material.id }/Texture_${ material.metalnessMap.id }_metallic.outputs:b>` );
|
|
626
627
|
|
|
627
|
-
samplers.push( buildTexture( material.metalnessMap, 'metallic' ) );
|
|
628
|
+
samplers.push( buildTexture( material.metalnessMap, 'metallic', new Color( material.metalness, material.metalness, material.metalness ) ) );
|
|
628
629
|
|
|
629
630
|
} else {
|
|
630
631
|
|
|
@@ -647,8 +648,28 @@ function buildMaterial( material, textures, quickLookCompatible = false ) {
|
|
|
647
648
|
|
|
648
649
|
if ( material.isMeshPhysicalMaterial ) {
|
|
649
650
|
|
|
650
|
-
|
|
651
|
-
|
|
651
|
+
if ( material.clearcoatMap !== null ) {
|
|
652
|
+
|
|
653
|
+
inputs.push( `${pad}float inputs:clearcoat.connect = </Materials/Material_${material.id}/Texture_${material.clearcoatMap.id}_clearcoat.outputs:r>` );
|
|
654
|
+
samplers.push( buildTexture( material.clearcoatMap, 'clearcoat', new Color( material.clearcoat, material.clearcoat, material.clearcoat ) ) );
|
|
655
|
+
|
|
656
|
+
} else {
|
|
657
|
+
|
|
658
|
+
inputs.push( `${pad}float inputs:clearcoat = ${material.clearcoat}` );
|
|
659
|
+
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
if ( material.clearcoatRoughnessMap !== null ) {
|
|
663
|
+
|
|
664
|
+
inputs.push( `${pad}float inputs:clearcoatRoughness.connect = </Materials/Material_${material.id}/Texture_${material.clearcoatRoughnessMap.id}_clearcoatRoughness.outputs:g>` );
|
|
665
|
+
samplers.push( buildTexture( material.clearcoatRoughnessMap, 'clearcoatRoughness', new Color( material.clearcoatRoughness, material.clearcoatRoughness, material.clearcoatRoughness ) ) );
|
|
666
|
+
|
|
667
|
+
} else {
|
|
668
|
+
|
|
669
|
+
inputs.push( `${pad}float inputs:clearcoatRoughness = ${material.clearcoatRoughness}` );
|
|
670
|
+
|
|
671
|
+
}
|
|
672
|
+
|
|
652
673
|
inputs.push( `${ pad }float inputs:ior = ${ material.ior }` );
|
|
653
674
|
|
|
654
675
|
}
|
|
@@ -20,79 +20,78 @@ class LightProbeHelper extends Mesh {
|
|
|
20
20
|
|
|
21
21
|
},
|
|
22
22
|
|
|
23
|
-
vertexShader:
|
|
23
|
+
vertexShader: /* glsl */`
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
varying vec3 vNormal;
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
void main() {
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
vNormal = normalize( normalMatrix * normal );
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
}
|
|
34
34
|
|
|
35
|
-
|
|
35
|
+
`,
|
|
36
36
|
|
|
37
|
-
fragmentShader:
|
|
37
|
+
fragmentShader: /* glsl */`
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
#define RECIPROCAL_PI 0.318309886
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
vec3 inverseTransformDirection( in vec3 normal, in mat4 matrix ) {
|
|
42
42
|
|
|
43
|
-
|
|
43
|
+
// matrix is assumed to be orthogonal
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
return normalize( ( vec4( normal, 0.0 ) * matrix ).xyz );
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf,
|
|
50
|
+
vec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
// normal is assumed to have unit length,
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
float x = normal.x, y = normal.y, z = normal.z;
|
|
55
55
|
|
|
56
|
-
|
|
57
|
-
|
|
56
|
+
// band 0,
|
|
57
|
+
vec3 result = shCoefficients[ 0 ] * 0.886227;
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
59
|
+
// band 1,
|
|
60
|
+
result += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;
|
|
61
|
+
result += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;
|
|
62
|
+
result += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
// band 2,
|
|
65
|
+
result += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;
|
|
66
|
+
result += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;
|
|
67
|
+
result += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );
|
|
68
|
+
result += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;
|
|
69
|
+
result += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );
|
|
70
|
+
return result;
|
|
70
71
|
|
|
71
|
-
|
|
72
|
+
}
|
|
72
73
|
|
|
73
|
-
|
|
74
|
+
uniform vec3 sh[ 9 ]; // sh coefficients
|
|
74
75
|
|
|
75
|
-
|
|
76
|
+
uniform float intensity; // light probe intensity
|
|
76
77
|
|
|
77
|
-
|
|
78
|
+
varying vec3 vNormal;
|
|
78
79
|
|
|
79
|
-
|
|
80
|
+
void main() {
|
|
80
81
|
|
|
81
|
-
|
|
82
|
+
vec3 normal = normalize( vNormal );
|
|
82
83
|
|
|
83
|
-
|
|
84
|
+
vec3 worldNormal = inverseTransformDirection( normal, viewMatrix );
|
|
84
85
|
|
|
85
|
-
|
|
86
|
+
vec3 irradiance = shGetIrradianceAt( worldNormal, sh );
|
|
86
87
|
|
|
87
|
-
|
|
88
|
+
vec3 outgoingLight = RECIPROCAL_PI * irradiance * intensity;
|
|
88
89
|
|
|
89
|
-
|
|
90
|
+
gl_FragColor = linearToOutputTexel( vec4( outgoingLight, 1.0 ) );
|
|
90
91
|
|
|
91
|
-
|
|
92
|
+
}
|
|
92
93
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
].join( '\n' )
|
|
94
|
+
`,
|
|
96
95
|
|
|
97
96
|
} );
|
|
98
97
|
|
|
@@ -251,22 +251,34 @@ class KTX2Loader extends Loader {
|
|
|
251
251
|
|
|
252
252
|
loader.load( url, ( buffer ) => {
|
|
253
253
|
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
254
|
+
this.parse( buffer, onLoad, onError);
|
|
255
|
+
|
|
256
|
+
}, onProgress, onError );
|
|
257
|
+
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
parse( buffer, onLoad, onError ) {
|
|
261
|
+
|
|
262
|
+
if ( this.workerConfig === null ) {
|
|
263
|
+
|
|
264
|
+
throw new Error( 'THREE.KTX2Loader: Missing initialization with `.detectSupport( renderer )`.' );
|
|
265
|
+
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Check for an existing task using this buffer. A transferred buffer cannot be transferred
|
|
269
|
+
// again from this thread.
|
|
270
|
+
if ( _taskCache.has( buffer ) ) {
|
|
257
271
|
|
|
258
272
|
const cachedTask = _taskCache.get( buffer );
|
|
259
273
|
|
|
260
274
|
return cachedTask.promise.then( onLoad ).catch( onError );
|
|
261
275
|
|
|
262
|
-
|
|
276
|
+
}
|
|
263
277
|
|
|
264
|
-
|
|
278
|
+
this._createTexture( buffer )
|
|
265
279
|
.then( ( texture ) => onLoad ? onLoad( texture ) : null )
|
|
266
280
|
.catch( onError );
|
|
267
281
|
|
|
268
|
-
}, onProgress, onError );
|
|
269
|
-
|
|
270
282
|
}
|
|
271
283
|
|
|
272
284
|
_createTextureFrom( transcodeResult, container ) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { FileLoader, Loader, TextureLoader, MeshBasicNodeMaterial, MeshPhysicalNodeMaterial, RepeatWrapping } from 'three';
|
|
2
|
+
|
|
1
3
|
import {
|
|
2
|
-
FileLoader, Loader, TextureLoader, MeshBasicNodeMaterial, MeshPhysicalNodeMaterial, RepeatWrapping,
|
|
3
4
|
float, bool, int, vec2, vec3, vec4, color, texture,
|
|
4
5
|
positionLocal, positionWorld, uv, vertexColor,
|
|
5
6
|
normalLocal, normalWorld, tangentLocal, tangentWorld,
|
|
@@ -12,8 +13,9 @@ import {
|
|
|
12
13
|
mx_transform_uv,
|
|
13
14
|
mx_safepower, mx_contrast,
|
|
14
15
|
mx_srgb_texture_to_lin_rec709,
|
|
15
|
-
saturation
|
|
16
|
-
|
|
16
|
+
saturation,
|
|
17
|
+
timerLocal, frameId
|
|
18
|
+
} from 'three/tsl';
|
|
17
19
|
|
|
18
20
|
const colorSpaceLib = {
|
|
19
21
|
mx_srgb_texture_to_lin_rec709
|
|
@@ -21,7 +23,7 @@ const colorSpaceLib = {
|
|
|
21
23
|
|
|
22
24
|
class MXElement {
|
|
23
25
|
|
|
24
|
-
constructor( name, nodeFunc, params =
|
|
26
|
+
constructor( name, nodeFunc, params = [] ) {
|
|
25
27
|
|
|
26
28
|
this.name = name;
|
|
27
29
|
this.nodeFunc = nodeFunc;
|
|
@@ -40,6 +42,8 @@ const mx_divide = ( in1, in2 = float( 1 ) ) => div( in1, in2 );
|
|
|
40
42
|
const mx_modulo = ( in1, in2 = float( 1 ) ) => mod( in1, in2 );
|
|
41
43
|
const mx_power = ( in1, in2 = float( 1 ) ) => pow( in1, in2 );
|
|
42
44
|
const mx_atan2 = ( in1 = float( 0 ), in2 = float( 1 ) ) => atan2( in1, in2 );
|
|
45
|
+
const mx_timer = () => timerLocal();
|
|
46
|
+
const mx_frame = () => frameId;
|
|
43
47
|
|
|
44
48
|
const MXElements = [
|
|
45
49
|
|
|
@@ -128,6 +132,9 @@ const MXElements = [
|
|
|
128
132
|
//new MtlXElement( 'separate3', ... ),
|
|
129
133
|
//new MtlXElement( 'separate4', ... )
|
|
130
134
|
|
|
135
|
+
new MXElement( 'time', mx_timer ),
|
|
136
|
+
new MXElement( 'frame', mx_frame )
|
|
137
|
+
|
|
131
138
|
];
|
|
132
139
|
|
|
133
140
|
const MtlXLibrary = {};
|
|
@@ -127,15 +127,15 @@ class PCDLoader extends Loader {
|
|
|
127
127
|
|
|
128
128
|
// parse
|
|
129
129
|
|
|
130
|
-
PCDheader.version =
|
|
131
|
-
PCDheader.fields =
|
|
132
|
-
PCDheader.size =
|
|
133
|
-
PCDheader.type =
|
|
134
|
-
PCDheader.count =
|
|
135
|
-
PCDheader.width =
|
|
136
|
-
PCDheader.height =
|
|
137
|
-
PCDheader.viewpoint =
|
|
138
|
-
PCDheader.points =
|
|
130
|
+
PCDheader.version = /^VERSION (.*)/im.exec( PCDheader.str );
|
|
131
|
+
PCDheader.fields = /^FIELDS (.*)/im.exec( PCDheader.str );
|
|
132
|
+
PCDheader.size = /^SIZE (.*)/im.exec( PCDheader.str );
|
|
133
|
+
PCDheader.type = /^TYPE (.*)/im.exec( PCDheader.str );
|
|
134
|
+
PCDheader.count = /^COUNT (.*)/im.exec( PCDheader.str );
|
|
135
|
+
PCDheader.width = /^WIDTH (.*)/im.exec( PCDheader.str );
|
|
136
|
+
PCDheader.height = /^HEIGHT (.*)/im.exec( PCDheader.str );
|
|
137
|
+
PCDheader.viewpoint = /^VIEWPOINT (.*)/im.exec( PCDheader.str );
|
|
138
|
+
PCDheader.points = /^POINTS (.*)/im.exec( PCDheader.str );
|
|
139
139
|
|
|
140
140
|
// evaluate
|
|
141
141
|
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BackSide,
|
|
3
|
+
BoxGeometry,
|
|
4
|
+
Mesh,
|
|
5
|
+
NodeMaterial,
|
|
6
|
+
Vector3
|
|
7
|
+
} from 'three';
|
|
8
|
+
import { float, Fn, vec3, acos, add, mul, clamp, cos, dot, exp, max, mix, modelViewProjection, normalize, positionWorld, pow, smoothstep, sub, varying, varyingProperty, vec4, uniform, cameraPosition } from 'three/tsl';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Based on "A Practical Analytic Model for Daylight"
|
|
12
|
+
* aka The Preetham Model, the de facto standard analytic skydome model
|
|
13
|
+
* https://www.researchgate.net/publication/220720443_A_Practical_Analytic_Model_for_Daylight
|
|
14
|
+
*
|
|
15
|
+
* First implemented by Simon Wallner
|
|
16
|
+
* http://simonwallner.at/project/atmospheric-scattering/
|
|
17
|
+
*
|
|
18
|
+
* Improved by Martin Upitis
|
|
19
|
+
* http://blenderartists.org/forum/showthread.php?245954-preethams-sky-impementation-HDR
|
|
20
|
+
*
|
|
21
|
+
* Three.js integration by zz85 http://twitter.com/blurspline
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
class SkyMesh extends Mesh {
|
|
25
|
+
|
|
26
|
+
constructor() {
|
|
27
|
+
|
|
28
|
+
const material = new NodeMaterial();
|
|
29
|
+
|
|
30
|
+
super( new BoxGeometry( 1, 1, 1 ), material );
|
|
31
|
+
|
|
32
|
+
this.turbidity = uniform( 2 );
|
|
33
|
+
this.rayleigh = uniform( 1 );
|
|
34
|
+
this.mieCoefficient = uniform( 0.005 );
|
|
35
|
+
this.mieDirectionalG = uniform( 0.8 );
|
|
36
|
+
this.sunPosition = uniform( new Vector3() );
|
|
37
|
+
this.upUniform = uniform( new Vector3( 0, 1, 0 ) );
|
|
38
|
+
|
|
39
|
+
this.isSky = true;
|
|
40
|
+
|
|
41
|
+
const vertexNode = /*@__PURE__*/ Fn( () => {
|
|
42
|
+
|
|
43
|
+
// constants for atmospheric scattering
|
|
44
|
+
const e = float( 2.71828182845904523536028747135266249775724709369995957 );
|
|
45
|
+
// const pi = float( 3.141592653589793238462643383279502884197169 );
|
|
46
|
+
|
|
47
|
+
// wavelength of used primaries, according to preetham
|
|
48
|
+
// const lambda = vec3( 680E-9, 550E-9, 450E-9 );
|
|
49
|
+
// this pre-calcuation replaces older TotalRayleigh(vec3 lambda) function:
|
|
50
|
+
// (8.0 * pow(pi, 3.0) * pow(pow(n, 2.0) - 1.0, 2.0) * (6.0 + 3.0 * pn)) / (3.0 * N * pow(lambda, vec3(4.0)) * (6.0 - 7.0 * pn))
|
|
51
|
+
const totalRayleigh = vec3( 5.804542996261093E-6, 1.3562911419845635E-5, 3.0265902468824876E-5 );
|
|
52
|
+
|
|
53
|
+
// mie stuff
|
|
54
|
+
// K coefficient for the primaries
|
|
55
|
+
// const v = float( 4.0 );
|
|
56
|
+
// const K = vec3( 0.686, 0.678, 0.666 );
|
|
57
|
+
// MieConst = pi * pow( ( 2.0 * pi ) / lambda, vec3( v - 2.0 ) ) * K
|
|
58
|
+
const MieConst = vec3( 1.8399918514433978E14, 2.7798023919660528E14, 4.0790479543861094E14 );
|
|
59
|
+
|
|
60
|
+
// earth shadow hack
|
|
61
|
+
// cutoffAngle = pi / 1.95;
|
|
62
|
+
const cutoffAngle = float( 1.6110731556870734 );
|
|
63
|
+
const steepness = float( 1.5 );
|
|
64
|
+
const EE = float( 1000.0 );
|
|
65
|
+
|
|
66
|
+
// varying sun position
|
|
67
|
+
|
|
68
|
+
const vSunDirection = normalize( this.sunPosition );
|
|
69
|
+
varyingProperty( 'vec3', 'vSunDirection' ).assign( vSunDirection );
|
|
70
|
+
|
|
71
|
+
// varying sun intensity
|
|
72
|
+
|
|
73
|
+
const angle = dot( vSunDirection, this.upUniform );
|
|
74
|
+
const zenithAngleCos = clamp( angle, - 1, 1 );
|
|
75
|
+
const sunIntensity = EE.mul( max( 0.0, float( 1.0 ).sub( pow( e, cutoffAngle.sub( acos( zenithAngleCos ) ).div( steepness ).negate() ) ) ) );
|
|
76
|
+
varyingProperty( 'float', 'vSunE' ).assign( sunIntensity );
|
|
77
|
+
|
|
78
|
+
// varying sun fade
|
|
79
|
+
|
|
80
|
+
const vSunfade = float( 1.0 ).sub( clamp( float( 1.0 ).sub( exp( this.sunPosition.y.div( 450000.0 ) ) ), 0, 1 ) );
|
|
81
|
+
varyingProperty( 'float', 'vSunfade' ).assign( vSunfade );
|
|
82
|
+
|
|
83
|
+
// varying vBetaR
|
|
84
|
+
|
|
85
|
+
const rayleighCoefficient = this.rayleigh.sub( float( 1.0 ).mul( float( 1.0 ).sub( vSunfade ) ) );
|
|
86
|
+
|
|
87
|
+
// extinction (absorbtion + out scattering)
|
|
88
|
+
// rayleigh coefficients
|
|
89
|
+
varyingProperty( 'vec3', 'vBetaR' ).assign( totalRayleigh.mul( rayleighCoefficient ) );
|
|
90
|
+
|
|
91
|
+
// varying vBetaM
|
|
92
|
+
|
|
93
|
+
const c = float( 0.2 ).mul( this.turbidity ).mul( 10E-18 );
|
|
94
|
+
const totalMie = float( 0.434 ).mul( c ).mul( MieConst );
|
|
95
|
+
|
|
96
|
+
varyingProperty( 'vec3', 'vBetaM' ).assign( totalMie.mul( this.mieCoefficient ) );
|
|
97
|
+
|
|
98
|
+
// position
|
|
99
|
+
|
|
100
|
+
const position = modelViewProjection();
|
|
101
|
+
position.z.assign( position.w ); // set z to camera.far
|
|
102
|
+
|
|
103
|
+
return position;
|
|
104
|
+
|
|
105
|
+
} )();
|
|
106
|
+
|
|
107
|
+
const fragmentNode = /*@__PURE__*/ Fn( () => {
|
|
108
|
+
|
|
109
|
+
const vSunDirection = varying( vec3(), 'vSunDirection' );
|
|
110
|
+
const vSunE = varying( float(), 'vSunE' );
|
|
111
|
+
const vSunfade = varying( float(), 'vSunfade' );
|
|
112
|
+
const vBetaR = varying( vec3(), 'vBetaR' );
|
|
113
|
+
const vBetaM = varying( vec3(), 'vBetaM' );
|
|
114
|
+
|
|
115
|
+
// constants for atmospheric scattering
|
|
116
|
+
const pi = float( 3.141592653589793238462643383279502884197169 );
|
|
117
|
+
|
|
118
|
+
// optical length at zenith for molecules
|
|
119
|
+
const rayleighZenithLength = float( 8.4E3 );
|
|
120
|
+
const mieZenithLength = float( 1.25E3 );
|
|
121
|
+
// 66 arc seconds -> degrees, and the cosine of that
|
|
122
|
+
const sunAngularDiameterCos = float( 0.999956676946448443553574619906976478926848692873900859324 );
|
|
123
|
+
|
|
124
|
+
// 3.0 / ( 16.0 * pi )
|
|
125
|
+
const THREE_OVER_SIXTEENPI = float( 0.05968310365946075 );
|
|
126
|
+
// 1.0 / ( 4.0 * pi )
|
|
127
|
+
const ONE_OVER_FOURPI = float( 0.07957747154594767 );
|
|
128
|
+
|
|
129
|
+
//
|
|
130
|
+
|
|
131
|
+
const direction = normalize( positionWorld.sub( cameraPosition ) );
|
|
132
|
+
|
|
133
|
+
// optical length
|
|
134
|
+
// cutoff angle at 90 to avoid singularity in next formula.
|
|
135
|
+
const zenithAngle = acos( max( 0.0, dot( this.upUniform, direction ) ) );
|
|
136
|
+
const inverse = float( 1.0 ).div( cos( zenithAngle ).add( float( 0.15 ).mul( pow( float( 93.885 ).sub( zenithAngle.mul( 180.0 ).div( pi ) ), - 1.253 ) ) ) );
|
|
137
|
+
const sR = rayleighZenithLength.mul( inverse );
|
|
138
|
+
const sM = mieZenithLength.mul( inverse );
|
|
139
|
+
|
|
140
|
+
// combined extinction factor
|
|
141
|
+
const Fex = exp( mul( vBetaR, sR ).add( mul( vBetaM, sM ) ).negate() );
|
|
142
|
+
|
|
143
|
+
// in scattering
|
|
144
|
+
const cosTheta = dot( direction, vSunDirection );
|
|
145
|
+
|
|
146
|
+
// betaRTheta
|
|
147
|
+
|
|
148
|
+
const c = cosTheta.mul( 0.5 ).add( 0.5 );
|
|
149
|
+
const rPhase = THREE_OVER_SIXTEENPI.mul( float( 1.0 ).add( pow( c, 2.0 ) ) );
|
|
150
|
+
const betaRTheta = vBetaR.mul( rPhase );
|
|
151
|
+
|
|
152
|
+
// betaMTheta
|
|
153
|
+
|
|
154
|
+
const g2 = pow( this.mieDirectionalG, 2.0 );
|
|
155
|
+
const inv = float( 1.0 ).div( pow( float( 1.0 ).sub( float( 2.0 ).mul( this.mieDirectionalG ).mul( cosTheta ) ).add( g2 ), 1.5 ) );
|
|
156
|
+
const mPhase = ONE_OVER_FOURPI.mul( float( 1.0 ).sub( g2 ) ).mul( inv );
|
|
157
|
+
const betaMTheta = vBetaM.mul( mPhase );
|
|
158
|
+
|
|
159
|
+
const Lin = pow( vSunE.mul( add( betaRTheta, betaMTheta ).div( add( vBetaR, vBetaM ) ) ).mul( sub( 1.0, Fex ) ), vec3( 1.5 ) );
|
|
160
|
+
Lin.mulAssign( mix( vec3( 1.0 ), pow( vSunE.mul( add( betaRTheta, betaMTheta ).div( add( vBetaR, vBetaM ) ) ).mul( Fex ), vec3( 1.0 / 2.0 ) ), clamp( pow( sub( 1.0, dot( this.upUniform, vSunDirection ) ), 5.0 ), 0.0, 1.0 ) ) );
|
|
161
|
+
|
|
162
|
+
// nightsky
|
|
163
|
+
|
|
164
|
+
const L0 = vec3( 0.1 ).mul( Fex );
|
|
165
|
+
|
|
166
|
+
// composition + solar disc
|
|
167
|
+
const sundisk = smoothstep( sunAngularDiameterCos, sunAngularDiameterCos.add( 0.00002 ), cosTheta );
|
|
168
|
+
L0.addAssign( vSunE.mul( 19000.0 ).mul( Fex ).mul( sundisk ) );
|
|
169
|
+
|
|
170
|
+
const texColor = add( Lin, L0 ).mul( 0.04 ).add( vec3( 0.0, 0.0003, 0.00075 ) );
|
|
171
|
+
|
|
172
|
+
const retColor = pow( texColor, vec3( float( 1.0 ).div( float( 1.2 ).add( vSunfade.mul( 1.2 ) ) ) ) );
|
|
173
|
+
|
|
174
|
+
return vec4( retColor, 1.0 );
|
|
175
|
+
|
|
176
|
+
} )();
|
|
177
|
+
|
|
178
|
+
material.side = BackSide;
|
|
179
|
+
material.depthWrite = false;
|
|
180
|
+
|
|
181
|
+
material.vertexNode = vertexNode;
|
|
182
|
+
material.fragmentNode = fragmentNode;
|
|
183
|
+
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { SkyMesh };
|