super-three 0.163.0 → 0.165.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 -3
- package/build/three.cjs +1127 -452
- package/build/three.module.js +1127 -452
- package/build/three.module.min.js +2 -2
- package/examples/jsm/animation/CCDIKSolver.js +4 -2
- package/examples/jsm/controls/TransformControls.js +1 -1
- package/examples/jsm/environments/RoomEnvironment.js +1 -5
- package/examples/jsm/exporters/GLTFExporter.js +45 -1
- package/examples/jsm/exporters/USDZExporter.js +13 -5
- package/examples/jsm/helpers/ViewHelper.js +32 -67
- package/examples/jsm/libs/draco/README.md +2 -2
- package/examples/jsm/libs/tween.module.js +75 -64
- package/examples/jsm/lines/LineMaterial.js +1 -15
- package/examples/jsm/lines/LineSegments2.js +15 -0
- package/examples/jsm/lines/Wireframe.js +16 -1
- package/examples/jsm/loaders/DRACOLoader.js +1 -1
- package/examples/jsm/loaders/EXRLoader.js +283 -99
- package/examples/jsm/loaders/FBXLoader.js +24 -13
- package/examples/jsm/loaders/GLTFLoader.js +55 -0
- package/examples/jsm/loaders/KTX2Loader.js +3 -6
- package/examples/jsm/loaders/LDrawLoader.js +3 -2
- package/examples/jsm/loaders/MMDLoader.js +31 -12
- package/examples/jsm/loaders/VRMLLoader.js +1 -1
- package/examples/jsm/loaders/lwo/IFFParser.js +8 -5
- package/examples/jsm/materials/MeshGouraudMaterial.js +7 -1
- package/examples/jsm/math/Octree.js +26 -20
- package/examples/jsm/modifiers/CurveModifier.js +11 -9
- package/examples/jsm/nodes/Nodes.js +15 -13
- package/examples/jsm/nodes/accessors/AccessorsUtils.js +16 -1
- package/examples/jsm/nodes/accessors/BitangentNode.js +7 -83
- package/examples/jsm/nodes/accessors/BufferNode.js +6 -0
- package/examples/jsm/nodes/accessors/CameraNode.js +12 -119
- package/examples/jsm/nodes/accessors/ClippingNode.js +3 -2
- package/examples/jsm/nodes/accessors/MaterialNode.js +109 -3
- package/examples/jsm/nodes/accessors/ModelNode.js +3 -0
- package/examples/jsm/nodes/accessors/NormalNode.js +9 -101
- package/examples/jsm/nodes/accessors/PositionNode.js +6 -100
- package/examples/jsm/nodes/accessors/ReferenceNode.js +6 -0
- package/examples/jsm/nodes/accessors/ReflectVectorNode.js +2 -31
- package/examples/jsm/nodes/accessors/StorageBufferNode.js +9 -0
- package/examples/jsm/nodes/accessors/{TextureStoreNode.js → StorageTextureNode.js} +19 -6
- package/examples/jsm/nodes/accessors/TangentNode.js +11 -97
- package/examples/jsm/nodes/accessors/Texture3DNode.js +100 -0
- package/examples/jsm/nodes/accessors/TextureNode.js +21 -3
- package/examples/jsm/nodes/accessors/TextureSizeNode.js +1 -1
- package/examples/jsm/nodes/accessors/UVNode.js +2 -46
- package/examples/jsm/nodes/code/FunctionNode.js +0 -8
- package/examples/jsm/nodes/core/AttributeNode.js +15 -3
- package/examples/jsm/nodes/core/ContextNode.js +6 -0
- package/examples/jsm/nodes/core/Node.js +23 -2
- package/examples/jsm/nodes/core/NodeBuilder.js +25 -18
- package/examples/jsm/nodes/core/NodeKeywords.js +1 -1
- package/examples/jsm/nodes/core/OutputStructNode.js +3 -6
- package/examples/jsm/nodes/core/PropertyNode.js +11 -0
- package/examples/jsm/nodes/core/VaryingNode.js +40 -9
- package/examples/jsm/nodes/display/AfterImageNode.js +14 -2
- package/examples/jsm/nodes/display/BumpMapNode.js +7 -26
- package/examples/jsm/nodes/display/FrontFacingNode.js +13 -0
- package/examples/jsm/nodes/display/PassNode.js +3 -1
- package/examples/jsm/nodes/display/ViewportDepthNode.js +1 -1
- package/examples/jsm/nodes/display/ViewportNode.js +5 -3
- package/examples/jsm/nodes/display/ViewportTextureNode.js +4 -1
- package/examples/jsm/nodes/functions/BSDF/BRDF_GGX.js +26 -7
- package/examples/jsm/nodes/functions/BSDF/D_GGX_Anisotropic.js +28 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +1 -3
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated_Anisotropic.js +29 -0
- package/examples/jsm/nodes/functions/PhongLightingModel.js +1 -1
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +210 -12
- package/examples/jsm/nodes/functions/ShadowMaskModel.js +31 -0
- package/examples/jsm/nodes/functions/ToonLightingModel.js +49 -0
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +20 -5
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +11 -2
- package/examples/jsm/nodes/lighting/IrradianceNode.js +24 -0
- package/examples/jsm/nodes/lighting/LightsNode.js +28 -1
- package/examples/jsm/nodes/lighting/PointLightNode.js +2 -1
- package/examples/jsm/nodes/lighting/SpotLightNode.js +2 -1
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +11 -7
- package/examples/jsm/nodes/materials/Materials.js +4 -0
- package/examples/jsm/nodes/materials/MeshMatcapNodeMaterial.js +52 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +0 -2
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +2 -2
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +94 -6
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +11 -4
- package/examples/jsm/nodes/materials/MeshToonNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/NodeMaterial.js +43 -45
- package/examples/jsm/nodes/materials/ShadowNodeMaterial.js +34 -0
- package/examples/jsm/nodes/materials/VolumeNodeMaterial.js +106 -0
- package/examples/jsm/nodes/math/HashNode.js +2 -2
- package/examples/jsm/nodes/pmrem/PMREMUtils.js +1 -1
- package/examples/jsm/nodes/shadernode/ShaderNode.js +57 -41
- package/examples/jsm/nodes/utils/ArrayElementNode.js +1 -1
- package/examples/jsm/nodes/utils/MatcapUVNode.js +1 -1
- package/examples/jsm/nodes/utils/TimerNode.js +1 -1
- package/examples/jsm/objects/Lensflare.js +2 -2
- package/examples/jsm/physics/JoltPhysics.js +281 -0
- package/examples/jsm/postprocessing/RenderPass.js +1 -1
- package/examples/jsm/postprocessing/RenderTransitionPass.js +193 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +25 -5
- package/examples/jsm/renderers/CSS3DRenderer.js +24 -3
- package/examples/jsm/renderers/common/Attributes.js +2 -0
- package/examples/jsm/renderers/common/Background.js +3 -3
- package/examples/jsm/renderers/common/Bindings.js +17 -0
- package/examples/jsm/renderers/common/ChainMap.js +18 -48
- package/examples/jsm/renderers/common/ClippingContext.js +5 -5
- package/examples/jsm/renderers/common/Pipelines.js +2 -2
- package/examples/jsm/renderers/common/RenderBundle.js +18 -0
- package/examples/jsm/renderers/common/RenderBundles.js +38 -0
- package/examples/jsm/renderers/common/RenderList.js +10 -1
- package/examples/jsm/renderers/common/RenderObject.js +49 -1
- package/examples/jsm/renderers/common/Renderer.js +268 -25
- package/examples/jsm/renderers/common/Textures.js +1 -1
- package/examples/jsm/renderers/common/Uniform.js +1 -1
- package/examples/jsm/renderers/common/extras/PMREMGenerator.js +13 -17
- package/examples/jsm/renderers/common/nodes/NodeSampledTexture.js +18 -4
- package/examples/jsm/renderers/common/nodes/NodeSampler.js +6 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +31 -47
- package/examples/jsm/renderers/webgl/WebGLBackend.js +7 -21
- package/examples/jsm/renderers/webgl/WebGLBufferRenderer.js +5 -1
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +23 -5
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +114 -13
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +3 -21
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +80 -46
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +85 -12
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +4 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +10 -1
- package/examples/jsm/renderers/webgpu/utils/WebGPUConstants.js +6 -0
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +62 -19
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +62 -3
- package/examples/jsm/transpiler/GLSLDecoder.js +1 -1
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/examples/jsm/utils/BufferGeometryUtils.js +18 -16
- package/examples/jsm/utils/GPUStatsPanel.js +2 -0
- package/examples/jsm/utils/SceneUtils.js +60 -1
- package/examples/jsm/utils/SortUtils.js +8 -5
- package/examples/jsm/webxr/OculusHandModel.js +3 -2
- package/examples/jsm/webxr/XRHandModelFactory.js +4 -2
- package/package.json +3 -2
- package/src/animation/tracks/BooleanKeyframeTrack.js +10 -1
- package/src/animation/tracks/QuaternionKeyframeTrack.js +1 -2
- package/src/animation/tracks/StringKeyframeTrack.js +10 -1
- package/src/constants.js +1 -1
- package/src/core/Object3D.js +2 -0
- package/src/core/Raycaster.js +6 -2
- package/src/core/RenderTarget.js +8 -0
- package/src/extras/PMREMGenerator.js +12 -11
- package/src/loaders/FileLoader.js +5 -1
- package/src/loaders/LoaderUtils.js +3 -1
- package/src/loaders/MaterialLoader.js +1 -0
- package/src/loaders/ObjectLoader.js +1 -0
- package/src/materials/Material.js +2 -0
- package/src/materials/MeshPhysicalMaterial.js +20 -0
- package/src/objects/BatchedMesh.js +114 -1
- package/src/objects/Line.js +66 -43
- package/src/renderers/WebGLRenderer.js +371 -109
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +15 -0
- package/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js +9 -1
- package/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js +8 -22
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +1 -0
- package/src/renderers/shaders/ShaderChunk/morphcolor_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphinstance_vertex.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js +3 -14
- package/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js +10 -31
- package/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js +3 -23
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +17 -9
- package/src/renderers/shaders/ShaderChunk/transmission_fragment.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/transmission_pars_fragment.glsl.js +47 -13
- package/src/renderers/shaders/ShaderChunk.js +0 -2
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -0
- package/src/renderers/shaders/ShaderLib.js +1 -0
- package/src/renderers/webgl/WebGLBackground.js +24 -3
- package/src/renderers/webgl/WebGLBufferRenderer.js +36 -0
- package/src/renderers/webgl/WebGLCapabilities.js +33 -1
- package/src/renderers/webgl/WebGLExtensions.js +3 -1
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +36 -0
- package/src/renderers/webgl/WebGLLights.js +9 -12
- package/src/renderers/webgl/WebGLMaterials.js +7 -5
- package/src/renderers/webgl/WebGLMorphtargets.js +1 -2
- package/src/renderers/webgl/WebGLProgram.js +5 -36
- package/src/renderers/webgl/WebGLPrograms.js +19 -14
- package/src/renderers/webgl/WebGLRenderStates.js +8 -4
- package/src/renderers/webgl/WebGLShadowMap.js +25 -25
- package/src/renderers/webgl/WebGLTextures.js +206 -129
- package/src/renderers/webgl/WebGLUtils.js +3 -21
- package/src/renderers/webxr/WebXRDepthSensing.js +3 -3
- package/src/renderers/webxr/WebXRManager.js +8 -6
- package/src/textures/CompressedArrayTexture.js +14 -0
- package/src/textures/DataArrayTexture.js +14 -0
- package/src/textures/DepthTexture.js +1 -3
- package/src/utils.js +30 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/GLSL1NodeBuilder.js +0 -318
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +0 -26
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +0 -792
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +0 -51
- package/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js +0 -10
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
|
+
import { materialReference } from '../accessors/MaterialReferenceNode.js';
|
|
3
|
+
import { diffuseColor } from '../core/PropertyNode.js';
|
|
4
|
+
import { vec3 } from '../shadernode/ShaderNode.js';
|
|
5
|
+
import { MeshMatcapMaterial } from 'three';
|
|
6
|
+
import { mix } from '../math/MathNode.js';
|
|
7
|
+
import { matcapUV } from '../utils/MatcapUVNode.js';
|
|
8
|
+
|
|
9
|
+
const defaultValues = new MeshMatcapMaterial();
|
|
10
|
+
|
|
11
|
+
class MeshMatcapNodeMaterial extends NodeMaterial {
|
|
12
|
+
|
|
13
|
+
constructor( parameters ) {
|
|
14
|
+
|
|
15
|
+
super();
|
|
16
|
+
|
|
17
|
+
this.isMeshMatcapNodeMaterial = true;
|
|
18
|
+
|
|
19
|
+
this.lights = false;
|
|
20
|
+
|
|
21
|
+
this.setDefaultValues( defaultValues );
|
|
22
|
+
|
|
23
|
+
this.setValues( parameters );
|
|
24
|
+
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setupVariants( builder ) {
|
|
28
|
+
|
|
29
|
+
const uv = matcapUV;
|
|
30
|
+
|
|
31
|
+
let matcapColor;
|
|
32
|
+
|
|
33
|
+
if ( builder.material.matcap ) {
|
|
34
|
+
|
|
35
|
+
matcapColor = materialReference( 'matcap', 'texture' ).context( { getUV: () => uv } );
|
|
36
|
+
|
|
37
|
+
} else {
|
|
38
|
+
|
|
39
|
+
matcapColor = vec3( mix( 0.2, 0.8, uv.y ) ); // default if matcap is missing
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
diffuseColor.rgb.mulAssign( matcapColor.rgb );
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
export default MeshMatcapNodeMaterial;
|
|
51
|
+
|
|
52
|
+
addNodeMaterial( 'MeshMatcapNodeMaterial', MeshMatcapNodeMaterial );
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
2
|
import { shininess, specularColor } from '../core/PropertyNode.js';
|
|
3
|
-
import { materialShininess,
|
|
3
|
+
import { materialShininess, materialSpecular } from '../accessors/MaterialNode.js';
|
|
4
4
|
import { float } from '../shadernode/ShaderNode.js';
|
|
5
5
|
import PhongLightingModel from '../functions/PhongLightingModel.js';
|
|
6
6
|
|
|
@@ -43,7 +43,7 @@ class MeshPhongNodeMaterial extends NodeMaterial {
|
|
|
43
43
|
|
|
44
44
|
// SPECULAR COLOR
|
|
45
45
|
|
|
46
|
-
const specularNode = this.specularNode ||
|
|
46
|
+
const specularNode = this.specularNode || materialSpecular;
|
|
47
47
|
|
|
48
48
|
specularColor.assign( specularNode );
|
|
49
49
|
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { addNodeMaterial } from './NodeMaterial.js';
|
|
2
2
|
import { transformedClearcoatNormalView } from '../accessors/NormalNode.js';
|
|
3
|
-
import { clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness } from '../core/PropertyNode.js';
|
|
4
|
-
import { materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness } from '../accessors/MaterialNode.js';
|
|
5
|
-
import { float, vec3 } from '../shadernode/ShaderNode.js';
|
|
3
|
+
import { clearcoat, clearcoatRoughness, sheen, sheenRoughness, iridescence, iridescenceIOR, iridescenceThickness, specularColor, specularF90, diffuseColor, metalness, roughness, anisotropy, alphaT, anisotropyT, anisotropyB, ior, transmission, thickness, attenuationDistance, attenuationColor, dispersion } from '../core/PropertyNode.js';
|
|
4
|
+
import { materialClearcoat, materialClearcoatRoughness, materialClearcoatNormal, materialSheen, materialSheenRoughness, materialIridescence, materialIridescenceIOR, materialIridescenceThickness, materialSpecularIntensity, materialSpecularColor, materialAnisotropy, materialIOR, materialTransmission, materialThickness, materialAttenuationDistance, materialAttenuationColor, materialDispersion } from '../accessors/MaterialNode.js';
|
|
5
|
+
import { float, vec2, vec3, If } from '../shadernode/ShaderNode.js';
|
|
6
|
+
import getRoughness from '../functions/material/getRoughness.js';
|
|
7
|
+
import { TBNViewMatrix } from '../accessors/AccessorsUtils.js';
|
|
6
8
|
import PhysicalLightingModel from '../functions/PhysicalLightingModel.js';
|
|
7
9
|
import MeshStandardNodeMaterial from './MeshStandardNodeMaterial.js';
|
|
8
|
-
|
|
10
|
+
import { mix, pow2, min } from '../math/MathNode.js';
|
|
9
11
|
import { MeshPhysicalMaterial } from 'three';
|
|
10
12
|
|
|
11
13
|
const defaultValues = new MeshPhysicalMaterial();
|
|
@@ -32,10 +34,14 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
32
34
|
this.specularIntensityNode = null;
|
|
33
35
|
this.specularColorNode = null;
|
|
34
36
|
|
|
37
|
+
this.iorNode = null;
|
|
35
38
|
this.transmissionNode = null;
|
|
36
39
|
this.thicknessNode = null;
|
|
37
40
|
this.attenuationDistanceNode = null;
|
|
38
41
|
this.attenuationColorNode = null;
|
|
42
|
+
this.dispersionNode = null;
|
|
43
|
+
|
|
44
|
+
this.anisotropyNode = null;
|
|
39
45
|
|
|
40
46
|
this.setDefaultValues( defaultValues );
|
|
41
47
|
|
|
@@ -61,9 +67,37 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
61
67
|
|
|
62
68
|
}
|
|
63
69
|
|
|
70
|
+
get useAnisotropy() {
|
|
71
|
+
|
|
72
|
+
return this.anisotropy > 0 || this.anisotropyNode !== null;
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
get useTransmission() {
|
|
77
|
+
|
|
78
|
+
return this.transmission > 0 || this.transmissionNode !== null;
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
get useDispersion() {
|
|
83
|
+
|
|
84
|
+
return this.dispersion > 0 || this.dispersionNode !== null;
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
setupSpecular() {
|
|
89
|
+
|
|
90
|
+
const iorNode = this.iorNode ? float( this.iorNode ) : materialIOR;
|
|
91
|
+
|
|
92
|
+
ior.assign( iorNode );
|
|
93
|
+
specularColor.assign( mix( min( pow2( ior.sub( 1.0 ).div( ior.add( 1.0 ) ) ).mul( materialSpecularColor ), vec3( 1.0 ) ).mul( materialSpecularIntensity ), diffuseColor.rgb, metalness ) );
|
|
94
|
+
specularF90.assign( mix( materialSpecularIntensity, 1.0, metalness ) );
|
|
95
|
+
|
|
96
|
+
}
|
|
97
|
+
|
|
64
98
|
setupLightingModel( /*builder*/ ) {
|
|
65
99
|
|
|
66
|
-
return new PhysicalLightingModel( this.useClearcoat, this.useSheen, this.useIridescence );
|
|
100
|
+
return new PhysicalLightingModel( this.useClearcoat, this.useSheen, this.useIridescence, this.useAnisotropy, this.useTransmission, this.useDispersion );
|
|
67
101
|
|
|
68
102
|
}
|
|
69
103
|
|
|
@@ -79,7 +113,7 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
79
113
|
const clearcoatRoughnessNode = this.clearcoatRoughnessNode ? float( this.clearcoatRoughnessNode ) : materialClearcoatRoughness;
|
|
80
114
|
|
|
81
115
|
clearcoat.assign( clearcoatNode );
|
|
82
|
-
clearcoatRoughness.assign( clearcoatRoughnessNode );
|
|
116
|
+
clearcoatRoughness.assign( getRoughness( { roughness: clearcoatRoughnessNode } ) );
|
|
83
117
|
|
|
84
118
|
}
|
|
85
119
|
|
|
@@ -109,6 +143,57 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
109
143
|
|
|
110
144
|
}
|
|
111
145
|
|
|
146
|
+
// ANISOTROPY
|
|
147
|
+
|
|
148
|
+
if ( this.useAnisotropy ) {
|
|
149
|
+
|
|
150
|
+
const anisotropyV = ( this.anisotropyNode ? vec2( this.anisotropyNode ) : materialAnisotropy ).toVar();
|
|
151
|
+
|
|
152
|
+
anisotropy.assign( anisotropyV.length() );
|
|
153
|
+
|
|
154
|
+
If( anisotropy.equal( 0.0 ), () => {
|
|
155
|
+
|
|
156
|
+
anisotropyV.assign( vec2( 1.0, 0.0 ) );
|
|
157
|
+
|
|
158
|
+
} ).else( () => {
|
|
159
|
+
|
|
160
|
+
anisotropyV.divAssign( anisotropy );
|
|
161
|
+
anisotropy.assign( anisotropy.saturate() );
|
|
162
|
+
|
|
163
|
+
} );
|
|
164
|
+
|
|
165
|
+
// Roughness along the anisotropy bitangent is the material roughness, while the tangent roughness increases with anisotropy.
|
|
166
|
+
alphaT.assign( anisotropy.pow2().mix( roughness.pow2(), 1.0 ) );
|
|
167
|
+
|
|
168
|
+
anisotropyT.assign( TBNViewMatrix[ 0 ].mul( anisotropyV.x ).add( TBNViewMatrix[ 1 ].mul( anisotropyV.y ) ) );
|
|
169
|
+
anisotropyB.assign( TBNViewMatrix[ 1 ].mul( anisotropyV.x ).sub( TBNViewMatrix[ 0 ].mul( anisotropyV.y ) ) );
|
|
170
|
+
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// TRANSMISSION
|
|
174
|
+
|
|
175
|
+
if ( this.useTransmission ) {
|
|
176
|
+
|
|
177
|
+
const transmissionNode = this.transmissionNode ? float( this.transmissionNode ) : materialTransmission;
|
|
178
|
+
const thicknessNode = this.thicknessNode ? float( this.thicknessNode ) : materialThickness;
|
|
179
|
+
const attenuationDistanceNode = this.attenuationDistanceNode ? float( this.attenuationDistanceNode ) : materialAttenuationDistance;
|
|
180
|
+
const attenuationColorNode = this.attenuationColorNode ? vec3( this.attenuationColorNode ) : materialAttenuationColor;
|
|
181
|
+
|
|
182
|
+
transmission.assign( transmissionNode );
|
|
183
|
+
thickness.assign( thicknessNode );
|
|
184
|
+
attenuationDistance.assign( attenuationDistanceNode );
|
|
185
|
+
attenuationColor.assign( attenuationColorNode );
|
|
186
|
+
|
|
187
|
+
if ( this.useDispersion ) {
|
|
188
|
+
|
|
189
|
+
const dispersionNode = this.dispersionNode ? float( this.dispersionNode ) : materialDispersion;
|
|
190
|
+
|
|
191
|
+
dispersion.assign( dispersionNode );
|
|
192
|
+
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
}
|
|
196
|
+
|
|
112
197
|
}
|
|
113
198
|
|
|
114
199
|
setupNormal( builder ) {
|
|
@@ -143,6 +228,9 @@ class MeshPhysicalNodeMaterial extends MeshStandardNodeMaterial {
|
|
|
143
228
|
this.thicknessNode = source.thicknessNode;
|
|
144
229
|
this.attenuationDistanceNode = source.attenuationDistanceNode;
|
|
145
230
|
this.attenuationColorNode = source.attenuationColorNode;
|
|
231
|
+
this.dispersionNode = source.dispersionNode;
|
|
232
|
+
|
|
233
|
+
this.anisotropyNode = source.anisotropyNode;
|
|
146
234
|
|
|
147
235
|
return super.copy( source );
|
|
148
236
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
|
-
import { diffuseColor, metalness, roughness, specularColor } from '../core/PropertyNode.js';
|
|
2
|
+
import { diffuseColor, metalness, roughness, specularColor, specularF90 } from '../core/PropertyNode.js';
|
|
3
3
|
import { mix } from '../math/MathNode.js';
|
|
4
4
|
import { materialRoughness, materialMetalness } from '../accessors/MaterialNode.js';
|
|
5
5
|
import getRoughness from '../functions/material/getRoughness.js';
|
|
@@ -35,6 +35,15 @@ class MeshStandardNodeMaterial extends NodeMaterial {
|
|
|
35
35
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
setupSpecular() {
|
|
39
|
+
|
|
40
|
+
const specularColorNode = mix( vec3( 0.04 ), diffuseColor.rgb, metalness );
|
|
41
|
+
|
|
42
|
+
specularColor.assign( specularColorNode );
|
|
43
|
+
specularF90.assign( 1.0 );
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
38
47
|
setupVariants() {
|
|
39
48
|
|
|
40
49
|
// METALNESS
|
|
@@ -52,9 +61,7 @@ class MeshStandardNodeMaterial extends NodeMaterial {
|
|
|
52
61
|
|
|
53
62
|
// SPECULAR COLOR
|
|
54
63
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
specularColor.assign( specularColorNode );
|
|
64
|
+
this.setupSpecular();
|
|
58
65
|
|
|
59
66
|
// DIFFUSE COLOR
|
|
60
67
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
|
+
import ToonLightingModel from '../functions/ToonLightingModel.js';
|
|
3
|
+
|
|
4
|
+
import { MeshToonMaterial } from 'three';
|
|
5
|
+
|
|
6
|
+
const defaultValues = new MeshToonMaterial();
|
|
7
|
+
|
|
8
|
+
class MeshToonNodeMaterial extends NodeMaterial {
|
|
9
|
+
|
|
10
|
+
constructor( parameters ) {
|
|
11
|
+
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
this.isMeshToonNodeMaterial = true;
|
|
15
|
+
|
|
16
|
+
this.lights = true;
|
|
17
|
+
|
|
18
|
+
this.setDefaultValues( defaultValues );
|
|
19
|
+
|
|
20
|
+
this.setValues( parameters );
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setupLightingModel( /*builder*/ ) {
|
|
25
|
+
|
|
26
|
+
return new ToonLightingModel();
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default MeshToonNodeMaterial;
|
|
33
|
+
|
|
34
|
+
addNodeMaterial( 'MeshToonNodeMaterial', MeshToonNodeMaterial );
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Material
|
|
1
|
+
import { Material } from 'three';
|
|
2
2
|
import { getNodeChildren, getCacheKey } from '../core/NodeUtils.js';
|
|
3
3
|
import { attribute } from '../core/AttributeNode.js';
|
|
4
4
|
import { output, diffuseColor, varyingProperty } from '../core/PropertyNode.js';
|
|
5
5
|
import { materialAlphaTest, materialColor, materialOpacity, materialEmissive, materialNormal } from '../accessors/MaterialNode.js';
|
|
6
6
|
import { modelViewProjection } from '../accessors/ModelViewProjectionNode.js';
|
|
7
|
-
import { transformedNormalView } from '../accessors/NormalNode.js';
|
|
7
|
+
import { transformedNormalView, normalLocal } from '../accessors/NormalNode.js';
|
|
8
8
|
import { instance } from '../accessors/InstanceNode.js';
|
|
9
9
|
import { batch } from '../accessors/BatchNode.js';
|
|
10
|
-
|
|
10
|
+
import { materialReference } from '../accessors/MaterialReferenceNode.js';
|
|
11
11
|
import { positionLocal, positionView } from '../accessors/PositionNode.js';
|
|
12
12
|
import { skinningReference } from '../accessors/SkinningNode.js';
|
|
13
13
|
import { morphReference } from '../accessors/MorphNode.js';
|
|
@@ -19,6 +19,7 @@ import { float, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
|
19
19
|
import AONode from '../lighting/AONode.js';
|
|
20
20
|
import { lightingContext } from '../lighting/LightingContextNode.js';
|
|
21
21
|
import EnvironmentNode from '../lighting/EnvironmentNode.js';
|
|
22
|
+
import IrradianceNode from '../lighting/IrradianceNode.js';
|
|
22
23
|
import { depthPixel } from '../display/ViewportDepthNode.js';
|
|
23
24
|
import { cameraLogDepth } from '../accessors/CameraNode.js';
|
|
24
25
|
import { clipping, clippingAlpha } from '../accessors/ClippingNode.js';
|
|
@@ -26,7 +27,7 @@ import { faceDirection } from '../display/FrontFacingNode.js';
|
|
|
26
27
|
|
|
27
28
|
const NodeMaterials = new Map();
|
|
28
29
|
|
|
29
|
-
class NodeMaterial extends
|
|
30
|
+
class NodeMaterial extends Material {
|
|
30
31
|
|
|
31
32
|
constructor() {
|
|
32
33
|
|
|
@@ -42,10 +43,9 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
42
43
|
this.lights = true;
|
|
43
44
|
this.normals = true;
|
|
44
45
|
|
|
45
|
-
this.colorSpaced = true;
|
|
46
|
-
|
|
47
46
|
this.lightsNode = null;
|
|
48
47
|
this.envNode = null;
|
|
48
|
+
this.aoNode = null;
|
|
49
49
|
|
|
50
50
|
this.colorNode = null;
|
|
51
51
|
this.normalNode = null;
|
|
@@ -58,6 +58,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
58
58
|
|
|
59
59
|
this.depthNode = null;
|
|
60
60
|
this.shadowNode = null;
|
|
61
|
+
this.shadowPositionNode = null;
|
|
61
62
|
|
|
62
63
|
this.outputNode = null;
|
|
63
64
|
|
|
@@ -96,9 +97,9 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
96
97
|
|
|
97
98
|
const clippingNode = this.setupClipping( builder );
|
|
98
99
|
|
|
99
|
-
if ( this.
|
|
100
|
+
if ( this.depthWrite === true ) this.setupDepth( builder );
|
|
100
101
|
|
|
101
|
-
|
|
102
|
+
if ( this.fragmentNode === null ) {
|
|
102
103
|
|
|
103
104
|
if ( this.normals === true ) this.setupNormal( builder );
|
|
104
105
|
|
|
@@ -125,7 +126,15 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
125
126
|
|
|
126
127
|
} else {
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
let fragmentNode = this.fragmentNode;
|
|
130
|
+
|
|
131
|
+
if ( fragmentNode.isOutputStructNode !== true ) {
|
|
132
|
+
|
|
133
|
+
fragmentNode = vec4( fragmentNode );
|
|
134
|
+
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
resultNode = this.setupOutput( builder, fragmentNode );
|
|
129
138
|
|
|
130
139
|
}
|
|
131
140
|
|
|
@@ -137,6 +146,8 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
137
146
|
|
|
138
147
|
setupClipping( builder ) {
|
|
139
148
|
|
|
149
|
+
if ( builder.clippingContext === null ) return null;
|
|
150
|
+
|
|
140
151
|
const { globalClippingCount, localClippingCount } = builder.clippingContext;
|
|
141
152
|
|
|
142
153
|
let result = null;
|
|
@@ -205,6 +216,16 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
205
216
|
|
|
206
217
|
}
|
|
207
218
|
|
|
219
|
+
if ( this.displacementMap ) {
|
|
220
|
+
|
|
221
|
+
const displacementMap = materialReference( 'displacementMap', 'texture' );
|
|
222
|
+
const displacementScale = materialReference( 'displacementScale', 'float' );
|
|
223
|
+
const displacementBias = materialReference( 'displacementBias', 'float' );
|
|
224
|
+
|
|
225
|
+
positionLocal.addAssign( normalLocal.normalize().mul( ( displacementMap.x.mul( displacementScale ).add( displacementBias ) ) ) );
|
|
226
|
+
|
|
227
|
+
}
|
|
228
|
+
|
|
208
229
|
if ( object.isBatchedMesh ) {
|
|
209
230
|
|
|
210
231
|
batch( object ).append();
|
|
@@ -337,9 +358,17 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
337
358
|
|
|
338
359
|
}
|
|
339
360
|
|
|
340
|
-
if ( builder.material.
|
|
361
|
+
if ( builder.material.lightMap ) {
|
|
362
|
+
|
|
363
|
+
materialLightsNode.push( new IrradianceNode( materialReference( 'lightMap', 'texture' ) ) );
|
|
364
|
+
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
if ( this.aoNode !== null || builder.material.aoMap ) {
|
|
368
|
+
|
|
369
|
+
const aoNode = this.aoNode !== null ? this.aoNode : texture( builder.material.aoMap );
|
|
341
370
|
|
|
342
|
-
materialLightsNode.push( new AONode(
|
|
371
|
+
materialLightsNode.push( new AONode( aoNode ) );
|
|
343
372
|
|
|
344
373
|
}
|
|
345
374
|
|
|
@@ -400,41 +429,11 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
400
429
|
|
|
401
430
|
setupOutput( builder, outputNode ) {
|
|
402
431
|
|
|
403
|
-
const renderer = builder.renderer;
|
|
404
|
-
|
|
405
432
|
// FOG
|
|
406
433
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
const fogNode = builder.fogNode;
|
|
410
|
-
|
|
411
|
-
if ( fogNode ) outputNode = vec4( fogNode.mix( outputNode.rgb, fogNode.colorNode ), outputNode.a );
|
|
412
|
-
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
// TONE MAPPING
|
|
416
|
-
|
|
417
|
-
const toneMappingNode = builder.toneMappingNode;
|
|
418
|
-
|
|
419
|
-
if ( this.toneMapped === true && toneMappingNode ) {
|
|
420
|
-
|
|
421
|
-
outputNode = vec4( toneMappingNode.context( { color: outputNode.rgb } ), outputNode.a );
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
// ENCODING
|
|
426
|
-
|
|
427
|
-
if ( this.colorSpaced === true ) {
|
|
428
|
-
|
|
429
|
-
const outputColorSpace = renderer.currentColorSpace;
|
|
430
|
-
|
|
431
|
-
if ( outputColorSpace !== LinearSRGBColorSpace && outputColorSpace !== NoColorSpace ) {
|
|
434
|
+
const fogNode = builder.fogNode;
|
|
432
435
|
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
}
|
|
436
|
+
if ( fogNode ) outputNode = vec4( fogNode.mix( outputNode.rgb, fogNode.colorNode ), outputNode.a );
|
|
438
437
|
|
|
439
438
|
return outputNode;
|
|
440
439
|
|
|
@@ -459,8 +458,6 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
459
458
|
|
|
460
459
|
}
|
|
461
460
|
|
|
462
|
-
Object.assign( this.defines, material.defines );
|
|
463
|
-
|
|
464
461
|
const descriptors = Object.getOwnPropertyDescriptors( material.constructor.prototype );
|
|
465
462
|
|
|
466
463
|
for ( const key in descriptors ) {
|
|
@@ -551,6 +548,7 @@ class NodeMaterial extends ShaderMaterial {
|
|
|
551
548
|
|
|
552
549
|
this.depthNode = source.depthNode;
|
|
553
550
|
this.shadowNode = source.shadowNode;
|
|
551
|
+
this.shadowPositionNode = source.shadowPositionNode;
|
|
554
552
|
|
|
555
553
|
this.outputNode = source.outputNode;
|
|
556
554
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
|
+
import ShadowMaskModel from '../functions/ShadowMaskModel.js';
|
|
3
|
+
|
|
4
|
+
import { ShadowMaterial } from 'three';
|
|
5
|
+
|
|
6
|
+
const defaultValues = new ShadowMaterial();
|
|
7
|
+
|
|
8
|
+
class ShadowNodeMaterial extends NodeMaterial {
|
|
9
|
+
|
|
10
|
+
constructor( parameters ) {
|
|
11
|
+
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
this.isShadowNodeMaterial = true;
|
|
15
|
+
|
|
16
|
+
this.lights = true;
|
|
17
|
+
|
|
18
|
+
this.setDefaultValues( defaultValues );
|
|
19
|
+
|
|
20
|
+
this.setValues( parameters );
|
|
21
|
+
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
setupLightingModel( /*builder*/ ) {
|
|
25
|
+
|
|
26
|
+
return new ShadowMaskModel();
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default ShadowNodeMaterial;
|
|
33
|
+
|
|
34
|
+
addNodeMaterial( 'ShadowNodeMaterial', ShadowNodeMaterial );
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import NodeMaterial, { addNodeMaterial } from './NodeMaterial.js';
|
|
2
|
+
import { varying } from '../core/VaryingNode.js';
|
|
3
|
+
import { property } from '../core/PropertyNode.js';
|
|
4
|
+
import { materialReference } from '../accessors/MaterialReferenceNode.js';
|
|
5
|
+
import { modelWorldMatrixInverse } from '../accessors/ModelNode.js';
|
|
6
|
+
import { cameraPosition } from '../accessors/CameraNode.js';
|
|
7
|
+
import { positionGeometry } from '../accessors/PositionNode.js';
|
|
8
|
+
import { tslFn, vec2, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
9
|
+
import { min, max } from '../math/MathNode.js';
|
|
10
|
+
import { loop, Break } from '../utils/LoopNode.js';
|
|
11
|
+
import { texture3D } from '../accessors/Texture3DNode.js';
|
|
12
|
+
|
|
13
|
+
class VolumeNodeMaterial extends NodeMaterial {
|
|
14
|
+
|
|
15
|
+
constructor( params = {} ) {
|
|
16
|
+
|
|
17
|
+
super();
|
|
18
|
+
|
|
19
|
+
this.normals = false;
|
|
20
|
+
this.lights = false;
|
|
21
|
+
this.isVolumeNodeMaterial = true;
|
|
22
|
+
this.testNode = null;
|
|
23
|
+
|
|
24
|
+
this.setValues( params );
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
setup( builder ) {
|
|
29
|
+
|
|
30
|
+
const map = texture3D( this.map, null, 0 );
|
|
31
|
+
|
|
32
|
+
const hitBox = tslFn( ( { orig, dir } ) => {
|
|
33
|
+
|
|
34
|
+
const box_min = vec3( - 0.5 );
|
|
35
|
+
const box_max = vec3( 0.5 );
|
|
36
|
+
|
|
37
|
+
const inv_dir = dir.reciprocal();
|
|
38
|
+
|
|
39
|
+
const tmin_tmp = box_min.sub( orig ).mul( inv_dir );
|
|
40
|
+
const tmax_tmp = box_max.sub( orig ).mul( inv_dir );
|
|
41
|
+
|
|
42
|
+
const tmin = min( tmin_tmp, tmax_tmp );
|
|
43
|
+
const tmax = max( tmin_tmp, tmax_tmp );
|
|
44
|
+
|
|
45
|
+
const t0 = max( tmin.x, max( tmin.y, tmin.z ) );
|
|
46
|
+
const t1 = min( tmax.x, min( tmax.y, tmax.z ) );
|
|
47
|
+
|
|
48
|
+
return vec2( t0, t1 );
|
|
49
|
+
|
|
50
|
+
} );
|
|
51
|
+
|
|
52
|
+
this.fragmentNode = tslFn( () => {
|
|
53
|
+
|
|
54
|
+
const vOrigin = varying( vec3( modelWorldMatrixInverse.mul( vec4( cameraPosition, 1.0 ) ) ) );
|
|
55
|
+
const vDirection = varying( positionGeometry.sub( vOrigin ) );
|
|
56
|
+
|
|
57
|
+
const rayDir = vDirection.normalize();
|
|
58
|
+
const bounds = property( 'vec2', 'bounds' ).assign( hitBox( { orig: vOrigin, dir: rayDir } ) );
|
|
59
|
+
|
|
60
|
+
bounds.x.greaterThan( bounds.y ).discard();
|
|
61
|
+
|
|
62
|
+
bounds.assign( vec2( max( bounds.x, 0.0 ), bounds.y ) );
|
|
63
|
+
|
|
64
|
+
const p = property( 'vec3', 'p' ).assign( vOrigin.add( bounds.x.mul( rayDir ) ) );
|
|
65
|
+
const inc = property( 'vec3', 'inc' ).assign( vec3( rayDir.abs().reciprocal() ) );
|
|
66
|
+
const delta = property( 'float', 'delta' ).assign( min( inc.x, min( inc.y, inc.z ) ) );
|
|
67
|
+
|
|
68
|
+
delta.divAssign( materialReference( 'steps', 'float' ) );
|
|
69
|
+
|
|
70
|
+
const ac = property( 'vec4', 'ac' ).assign( vec4( materialReference( 'base', 'color' ), 0.0 ) );
|
|
71
|
+
|
|
72
|
+
loop( { type: 'float', start: bounds.x, end: bounds.y, update: '+= delta' }, () => {
|
|
73
|
+
|
|
74
|
+
const d = property( 'float', 'd' ).assign( map.uv( p.add( 0.5 ) ).r );
|
|
75
|
+
|
|
76
|
+
if ( this.testNode !== null ) {
|
|
77
|
+
|
|
78
|
+
this.testNode( { map: map, mapValue: d, probe: p, finalColor: ac } ).append();
|
|
79
|
+
|
|
80
|
+
} else {
|
|
81
|
+
|
|
82
|
+
// default to show surface of mesh
|
|
83
|
+
ac.a.assign( 1 );
|
|
84
|
+
Break();
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
p.addAssign( rayDir.mul( delta ) );
|
|
89
|
+
|
|
90
|
+
} );
|
|
91
|
+
|
|
92
|
+
ac.a.equal( 0 ).discard();
|
|
93
|
+
|
|
94
|
+
return vec4( ac );
|
|
95
|
+
|
|
96
|
+
} )();
|
|
97
|
+
|
|
98
|
+
super.setup( builder );
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export default VolumeNodeMaterial;
|
|
105
|
+
|
|
106
|
+
addNodeMaterial( 'VolumeNodeMaterial', VolumeNodeMaterial );
|
|
@@ -15,11 +15,11 @@ class HashNode extends Node {
|
|
|
15
15
|
|
|
16
16
|
// Taken from https://www.shadertoy.com/view/XlGcRh, originally from pcg-random.org
|
|
17
17
|
|
|
18
|
-
const state = this.seedNode.
|
|
18
|
+
const state = this.seedNode.toUint().mul( 747796405 ).add( 2891336453 );
|
|
19
19
|
const word = state.shiftRight( state.shiftRight( 28 ).add( 4 ) ).bitXor( state ).mul( 277803737 );
|
|
20
20
|
const result = word.shiftRight( 22 ).bitXor( word );
|
|
21
21
|
|
|
22
|
-
return result.
|
|
22
|
+
return result.toFloat().mul( 1 / 2 ** 32 ); // Convert to range [0, 1)
|
|
23
23
|
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -237,7 +237,7 @@ const bilinearCubeUV = tslFn( ( [ envMap, direction_immutable, mipInt_immutable,
|
|
|
237
237
|
uv.x.mulAssign( CUBEUV_TEXEL_WIDTH );
|
|
238
238
|
uv.y.mulAssign( CUBEUV_TEXEL_HEIGHT );
|
|
239
239
|
|
|
240
|
-
return envMap.uv( uv );
|
|
240
|
+
return envMap.uv( uv ).grad( vec2(), vec2() ); // disable anisotropic filtering
|
|
241
241
|
|
|
242
242
|
} );
|
|
243
243
|
|