super-three 0.157.1 → 0.160.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 +6 -4
- package/build/three.cjs +3100 -1537
- package/build/three.js +3100 -1537
- package/build/three.min.js +1 -1
- package/build/three.module.js +3093 -1538
- package/build/three.module.min.js +1 -1
- package/examples/jsm/Addons.js +291 -0
- package/examples/jsm/controls/FlyControls.js +26 -0
- package/examples/jsm/controls/OrbitControls.js +62 -41
- package/examples/jsm/controls/TransformControls.js +27 -11
- package/examples/jsm/csm/CSMShader.js +53 -48
- package/examples/jsm/exporters/GLTFExporter.js +151 -3
- package/examples/jsm/exporters/USDZExporter.js +27 -19
- package/examples/jsm/geometries/InstancedPointsGeometry.js +174 -0
- package/examples/jsm/geometries/SDFGeometryGenerator.js +144 -0
- package/examples/jsm/helpers/TextureHelper.js +237 -0
- package/examples/jsm/interactive/HTMLMesh.js +9 -2
- package/examples/jsm/libs/lottie_canvas.module.js +6 -1
- package/examples/jsm/libs/opentype.module.js +13 -75
- package/examples/jsm/libs/surfaceNet.js +201 -0
- package/examples/jsm/lines/LineMaterial.js +16 -33
- package/examples/jsm/loaders/ColladaLoader.js +0 -6
- package/examples/jsm/loaders/DRACOLoader.js +4 -3
- package/examples/jsm/loaders/FBXLoader.js +294 -124
- package/examples/jsm/loaders/GLTFLoader.js +83 -6
- package/examples/jsm/loaders/LUTImageLoader.js +162 -0
- package/examples/jsm/loaders/MaterialXLoader.js +73 -54
- package/examples/jsm/loaders/NRRDLoader.js +0 -13
- package/examples/jsm/loaders/SVGLoader.js +4 -4
- package/examples/jsm/loaders/USDZLoader.js +3 -17
- package/examples/jsm/loaders/lwo/IFFParser.js +89 -93
- package/examples/jsm/materials/MeshGouraudMaterial.js +2 -0
- package/examples/jsm/math/Capsule.js +0 -55
- package/examples/jsm/math/Octree.js +85 -7
- package/examples/jsm/misc/Timer.js +119 -0
- package/examples/jsm/misc/TubePainter.js +3 -6
- package/examples/jsm/modifiers/CurveModifier.js +20 -2
- package/examples/jsm/modifiers/SimplifyModifier.js +103 -11
- package/examples/jsm/modifiers/TessellateModifier.js +3 -3
- package/examples/jsm/nodes/Nodes.js +16 -12
- package/examples/jsm/nodes/accessors/CameraNode.js +18 -2
- package/examples/jsm/nodes/accessors/CubeTextureNode.js +5 -73
- package/examples/jsm/nodes/accessors/InstanceNode.js +3 -3
- package/examples/jsm/nodes/accessors/InstancedPointsMaterialNode.js +21 -0
- package/examples/jsm/nodes/accessors/MaterialNode.js +68 -31
- package/examples/jsm/nodes/accessors/MaterialReferenceNode.js +11 -2
- package/examples/jsm/nodes/accessors/ModelNode.js +1 -2
- package/examples/jsm/nodes/accessors/ModelViewProjectionNode.js +12 -3
- package/examples/jsm/nodes/accessors/MorphNode.js +191 -16
- package/examples/jsm/nodes/accessors/NormalNode.js +1 -1
- package/examples/jsm/nodes/accessors/PositionNode.js +1 -1
- package/examples/jsm/nodes/accessors/ReferenceNode.js +25 -1
- package/examples/jsm/nodes/accessors/SkinningNode.js +13 -3
- package/examples/jsm/nodes/accessors/TextureNode.js +123 -37
- package/examples/jsm/nodes/code/CodeNode.js +3 -3
- package/examples/jsm/nodes/code/FunctionNode.js +1 -1
- package/examples/jsm/nodes/core/AssignNode.js +72 -0
- package/examples/jsm/nodes/core/AttributeNode.js +7 -1
- package/examples/jsm/nodes/core/CacheNode.js +4 -1
- package/examples/jsm/nodes/core/ConstNode.js +1 -1
- package/examples/jsm/nodes/core/LightingModel.js +3 -1
- package/examples/jsm/nodes/core/Node.js +13 -15
- package/examples/jsm/nodes/core/NodeBuilder.js +209 -42
- package/examples/jsm/nodes/core/NodeFrame.js +10 -8
- package/examples/jsm/nodes/core/NodeUniform.js +12 -0
- package/examples/jsm/nodes/core/NodeUtils.js +7 -9
- package/examples/jsm/nodes/core/OutputStructNode.js +4 -4
- package/examples/jsm/nodes/core/ParameterNode.js +33 -0
- package/examples/jsm/nodes/core/PropertyNode.js +15 -6
- package/examples/jsm/nodes/core/StackNode.js +7 -17
- package/examples/jsm/nodes/core/StructTypeNode.js +4 -4
- package/examples/jsm/nodes/core/TempNode.js +1 -1
- package/examples/jsm/nodes/core/UniformGroup.js +13 -0
- package/examples/jsm/nodes/core/UniformGroupNode.js +36 -0
- package/examples/jsm/nodes/core/UniformNode.js +17 -0
- package/examples/jsm/nodes/core/VarNode.js +7 -34
- package/examples/jsm/nodes/core/VaryingNode.js +3 -7
- package/examples/jsm/nodes/display/BumpMapNode.js +35 -13
- package/examples/jsm/nodes/display/ColorAdjustmentNode.js +6 -10
- package/examples/jsm/nodes/display/GaussianBlurNode.js +170 -0
- package/examples/jsm/nodes/display/NormalMapNode.js +3 -1
- package/examples/jsm/nodes/display/PassNode.js +182 -0
- package/examples/jsm/nodes/display/ViewportDepthNode.js +31 -3
- package/examples/jsm/nodes/display/ViewportDepthTextureNode.js +2 -2
- package/examples/jsm/nodes/display/ViewportNode.js +17 -10
- package/examples/jsm/nodes/functions/BSDF/BRDF_Sheen.js +20 -6
- package/examples/jsm/nodes/functions/BSDF/DFGApprox.js +8 -7
- package/examples/jsm/nodes/functions/BSDF/D_GGX.js +8 -3
- package/examples/jsm/nodes/functions/BSDF/Schlick_to_F0.js +8 -0
- package/examples/jsm/nodes/functions/BSDF/V_GGX_SmithCorrelated.js +8 -0
- package/examples/jsm/nodes/functions/PhysicalLightingModel.js +93 -43
- package/examples/jsm/nodes/gpgpu/ComputeNode.js +2 -2
- package/examples/jsm/nodes/lighting/AmbientLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/AnalyticLightNode.js +55 -6
- package/examples/jsm/nodes/lighting/DirectionalLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/EnvironmentNode.js +8 -18
- package/examples/jsm/nodes/lighting/LightingContextNode.js +21 -57
- package/examples/jsm/nodes/lighting/LightsNode.js +80 -20
- package/examples/jsm/nodes/lighting/PointLightNode.js +1 -1
- package/examples/jsm/nodes/lighting/SpotLightNode.js +1 -1
- package/examples/jsm/nodes/materials/InstancedPointsNodeMaterial.js +162 -0
- package/examples/jsm/nodes/materials/Line2NodeMaterial.js +76 -77
- package/examples/jsm/nodes/materials/LineDashedNodeMaterial.js +5 -5
- package/examples/jsm/nodes/materials/Materials.js +1 -0
- package/examples/jsm/nodes/materials/MeshBasicNodeMaterial.js +1 -0
- package/examples/jsm/nodes/materials/MeshNormalNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhongNodeMaterial.js +3 -3
- package/examples/jsm/nodes/materials/MeshPhysicalNodeMaterial.js +47 -20
- package/examples/jsm/nodes/materials/MeshStandardNodeMaterial.js +6 -6
- package/examples/jsm/nodes/materials/NodeMaterial.js +82 -60
- package/examples/jsm/nodes/materials/PointsNodeMaterial.js +0 -10
- package/examples/jsm/nodes/materials/SpriteNodeMaterial.js +0 -7
- package/examples/jsm/nodes/materialx/MaterialXNodes.js +10 -10
- package/examples/jsm/nodes/materialx/lib/mx_hsv.js +128 -54
- package/examples/jsm/nodes/materialx/lib/mx_noise.js +1430 -618
- package/examples/jsm/nodes/materialx/lib/mx_transform_color.js +24 -14
- package/examples/jsm/nodes/math/MathNode.js +2 -0
- package/examples/jsm/nodes/math/OperatorNode.js +24 -27
- package/examples/jsm/nodes/shadernode/ShaderNode.js +158 -10
- package/examples/jsm/nodes/utils/ArrayElementNode.js +2 -0
- package/examples/jsm/nodes/utils/DiscardNode.js +3 -2
- package/examples/jsm/nodes/utils/FunctionOverloadingNode.js +95 -0
- package/examples/jsm/nodes/utils/JoinNode.js +11 -1
- package/examples/jsm/nodes/utils/LoopNode.js +36 -24
- package/examples/jsm/nodes/utils/RemapNode.js +2 -2
- package/examples/jsm/nodes/utils/SplitNode.js +10 -2
- package/examples/jsm/nodes/utils/TriplanarTexturesNode.js +3 -3
- package/examples/jsm/objects/InstancedPoints.js +21 -0
- package/examples/jsm/objects/Lensflare.js +20 -0
- package/examples/jsm/objects/QuadMesh.js +60 -0
- package/examples/jsm/objects/ReflectorForSSRPass.js +3 -0
- package/examples/jsm/objects/Refractor.js +3 -0
- package/examples/jsm/objects/Sky.js +5 -3
- package/examples/jsm/objects/Water.js +5 -2
- package/examples/jsm/objects/Water2.js +3 -0
- package/examples/jsm/physics/AmmoPhysics.js +21 -0
- package/examples/jsm/physics/RapierPhysics.js +21 -0
- package/examples/jsm/postprocessing/BokehPass.js +3 -2
- package/examples/jsm/postprocessing/GTAOPass.js +572 -0
- package/examples/jsm/postprocessing/LUTPass.js +2 -1
- package/examples/jsm/postprocessing/OutputPass.js +3 -0
- package/examples/jsm/postprocessing/Pass.js +14 -3
- package/examples/jsm/postprocessing/SAOPass.js +0 -1
- package/examples/jsm/postprocessing/SMAAPass.js +0 -2
- package/examples/jsm/postprocessing/TAARenderPass.js +1 -2
- package/examples/jsm/renderers/CSS3DRenderer.js +3 -9
- package/examples/jsm/renderers/SVGRenderer.js +9 -6
- package/examples/jsm/renderers/common/Animation.js +10 -21
- package/examples/jsm/renderers/common/Backend.js +19 -3
- package/examples/jsm/renderers/common/Background.js +20 -22
- package/examples/jsm/renderers/common/Bindings.js +31 -22
- package/examples/jsm/renderers/common/ChainMap.js +3 -3
- package/examples/jsm/renderers/common/Color4.js +37 -0
- package/examples/jsm/renderers/common/Geometries.js +4 -4
- package/examples/jsm/renderers/common/Info.js +12 -2
- package/examples/jsm/renderers/common/Pipelines.js +3 -51
- package/examples/jsm/renderers/common/PostProcessing.js +25 -0
- package/examples/jsm/renderers/common/RenderContext.js +1 -1
- package/examples/jsm/renderers/common/RenderContexts.js +1 -1
- package/examples/jsm/renderers/common/RenderObject.js +21 -2
- package/examples/jsm/renderers/common/RenderObjects.js +5 -3
- package/examples/jsm/renderers/common/Renderer.js +137 -37
- package/examples/jsm/renderers/common/StorageTexture.js +1 -0
- package/examples/jsm/renderers/common/Textures.js +8 -37
- package/examples/jsm/renderers/common/nodes/NodeBuilderState.js +10 -2
- package/examples/jsm/renderers/common/nodes/NodeUniformsGroup.js +44 -0
- package/examples/jsm/renderers/common/nodes/Nodes.js +121 -19
- package/examples/jsm/renderers/webgl/WebGLBackend.js +366 -67
- package/examples/jsm/renderers/webgl/nodes/GLSLNodeBuilder.js +183 -38
- package/examples/jsm/renderers/webgl/utils/WebGLAttributeUtils.js +92 -5
- package/examples/jsm/renderers/webgl/utils/WebGLCapabilities.js +36 -0
- package/examples/jsm/renderers/webgl/utils/WebGLExtensions.js +11 -1
- package/examples/jsm/renderers/webgl/utils/WebGLState.js +14 -2
- package/examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js +71 -2
- package/examples/jsm/renderers/webgl/utils/WebGLUtils.js +42 -0
- package/examples/jsm/renderers/webgl-legacy/nodes/SlotNode.js +1 -1
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodeBuilder.js +33 -3
- package/examples/jsm/renderers/webgl-legacy/nodes/WebGLNodes.js +4 -14
- package/examples/jsm/renderers/webgpu/WebGPUBackend.js +188 -137
- package/examples/jsm/renderers/webgpu/WebGPURenderer.js +1 -1
- package/examples/jsm/renderers/webgpu/nodes/WGSLNodeBuilder.js +241 -90
- package/examples/jsm/renderers/webgpu/utils/WebGPUAttributeUtils.js +15 -10
- package/examples/jsm/renderers/webgpu/utils/WebGPUBindingUtils.js +11 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUPipelineUtils.js +2 -3
- package/examples/jsm/renderers/webgpu/utils/WebGPUTextureUtils.js +88 -6
- package/examples/jsm/shaders/ACESFilmicToneMappingShader.js +2 -0
- package/examples/jsm/shaders/AfterimageShader.js +2 -0
- package/examples/jsm/shaders/BasicShader.js +2 -0
- package/examples/jsm/shaders/BlendShader.js +2 -0
- package/examples/jsm/shaders/BokehShader.js +2 -0
- package/examples/jsm/shaders/BokehShader2.js +4 -0
- package/examples/jsm/shaders/BrightnessContrastShader.js +2 -0
- package/examples/jsm/shaders/ColorCorrectionShader.js +2 -0
- package/examples/jsm/shaders/DOFMipMapShader.js +2 -0
- package/examples/jsm/shaders/DepthLimitedBlurShader.js +5 -0
- package/examples/jsm/shaders/FXAAShader.js +135 -133
- package/examples/jsm/shaders/FilmShader.js +1 -1
- package/examples/jsm/shaders/FocusShader.js +2 -0
- package/examples/jsm/shaders/FreiChenShader.js +2 -0
- package/examples/jsm/shaders/GTAOShader.js +424 -0
- package/examples/jsm/shaders/GodRaysShader.js +8 -0
- package/examples/jsm/shaders/HalftoneShader.js +2 -0
- package/examples/jsm/shaders/HorizontalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/HueSaturationShader.js +2 -0
- package/examples/jsm/shaders/KaleidoShader.js +2 -0
- package/examples/jsm/shaders/LuminosityHighPassShader.js +2 -0
- package/examples/jsm/shaders/LuminosityShader.js +2 -0
- package/examples/jsm/shaders/MMDToonShader.js +2 -0
- package/examples/jsm/shaders/MirrorShader.js +2 -0
- package/examples/jsm/shaders/NormalMapShader.js +2 -0
- package/examples/jsm/shaders/OutputShader.js +8 -5
- package/examples/jsm/shaders/PoissonDenoiseShader.js +226 -0
- package/examples/jsm/shaders/SAOShader.js +7 -3
- package/examples/jsm/shaders/SMAAShader.js +6 -0
- package/examples/jsm/shaders/SSAOShader.js +8 -3
- package/examples/jsm/shaders/SSRShader.js +6 -0
- package/examples/jsm/shaders/SobelOperatorShader.js +2 -0
- package/examples/jsm/shaders/SubsurfaceScatteringShader.js +2 -0
- package/examples/jsm/shaders/TechnicolorShader.js +2 -0
- package/examples/jsm/shaders/TriangleBlurShader.js +2 -0
- package/examples/jsm/shaders/UnpackDepthRGBAShader.js +2 -0
- package/examples/jsm/shaders/VelocityShader.js +2 -0
- package/examples/jsm/shaders/VerticalTiltShiftShader.js +2 -0
- package/examples/jsm/shaders/WaterRefractionShader.js +2 -0
- package/examples/jsm/transpiler/AST.js +270 -0
- package/examples/jsm/transpiler/GLSLDecoder.js +941 -0
- package/examples/jsm/transpiler/ShaderToyDecoder.js +49 -0
- package/examples/jsm/transpiler/TSLEncoder.js +715 -0
- package/examples/jsm/transpiler/Transpiler.js +18 -0
- package/examples/jsm/utils/SortUtils.js +158 -0
- package/examples/jsm/utils/TextureUtils.js +33 -21
- package/examples/jsm/webxr/ARButton.js +14 -0
- package/examples/jsm/webxr/VRButton.js +24 -9
- package/examples/jsm/webxr/XRButton.js +27 -11
- package/examples/jsm/webxr/XREstimatedLight.js +1 -1
- package/package.json +8 -6
- package/src/Three.js +1 -0
- package/src/constants.js +8 -1
- package/src/core/BufferAttribute.js +21 -2
- package/src/core/InterleavedBuffer.js +21 -1
- package/src/core/Object3D.js +60 -12
- package/src/core/UniformsGroup.js +7 -1
- package/src/extras/PMREMGenerator.js +7 -1
- package/src/extras/curves/LineCurve3.js +4 -0
- package/src/loaders/AudioLoader.js +1 -1
- package/src/loaders/BufferGeometryLoader.js +0 -7
- package/src/loaders/ImageBitmapLoader.js +25 -1
- package/src/loaders/MaterialLoader.js +10 -2
- package/src/loaders/ObjectLoader.js +49 -0
- package/src/materials/Material.js +27 -13
- package/src/materials/ShaderMaterial.js +2 -1
- package/src/math/Box3.js +35 -18
- package/src/math/ColorManagement.js +0 -16
- package/src/math/Quaternion.js +5 -4
- package/src/math/Sphere.js +2 -0
- package/src/math/Triangle.js +17 -5
- package/src/math/Vector3.js +11 -12
- package/src/objects/BatchedMesh.js +1020 -0
- package/src/objects/Skeleton.js +1 -3
- package/src/objects/SkinnedMesh.js +6 -7
- package/src/renderers/WebGL3DRenderTarget.js +2 -2
- package/src/renderers/WebGLArrayRenderTarget.js +2 -2
- package/src/renderers/WebGLRenderer.js +165 -43
- package/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/batching_pars_vertex.glsl.js +19 -0
- package/src/renderers/shaders/ShaderChunk/batching_vertex.glsl.js +5 -0
- package/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js +3 -2
- package/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js +0 -5
- package/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js +31 -4
- package/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js +1 -1
- package/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js +9 -4
- package/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js +8 -6
- package/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js +9 -17
- package/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js +84 -0
- package/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js +6 -0
- package/src/renderers/shaders/ShaderChunk.js +4 -0
- package/src/renderers/shaders/ShaderLib/depth.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/distanceRGBA.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshbasic.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshlambert.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshmatcap.glsl.js +3 -0
- package/src/renderers/shaders/ShaderLib/meshnormal.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphong.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/meshphysical.glsl.js +4 -2
- package/src/renderers/shaders/ShaderLib/meshtoon.glsl.js +2 -0
- package/src/renderers/shaders/ShaderLib/shadow.glsl.js +3 -0
- package/src/renderers/webgl/WebGLAttributes.js +39 -5
- package/src/renderers/webgl/WebGLBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLCubeMaps.js +1 -1
- package/src/renderers/webgl/WebGLExtensions.js +1 -0
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +31 -0
- package/src/renderers/webgl/WebGLLights.js +11 -2
- package/src/renderers/webgl/WebGLProgram.js +100 -51
- package/src/renderers/webgl/WebGLPrograms.js +8 -0
- package/src/renderers/webgl/WebGLShadowMap.js +35 -0
- package/src/renderers/webgl/WebGLState.js +25 -4
- package/src/renderers/webgl/WebGLTextures.js +7 -11
- package/src/renderers/webgl/WebGLUniforms.js +11 -1
- package/src/renderers/webgl/WebGLUniformsGroups.js +72 -93
- package/src/renderers/webxr/WebXRManager.js +16 -0
- package/examples/jsm/nodes/accessors/ExtendedMaterialNode.js +0 -76
- package/examples/jsm/nodes/accessors/LineMaterialNode.js +0 -29
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import TempNode from '../core/TempNode.js';
|
|
2
|
+
import { nodeObject, addNodeElement, tslFn, float, vec2, vec3, vec4 } from '../shadernode/ShaderNode.js';
|
|
3
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
4
|
+
import { mul } from '../math/OperatorNode.js';
|
|
5
|
+
import { uv } from '../accessors/UVNode.js';
|
|
6
|
+
import { texture } from '../accessors/TextureNode.js';
|
|
7
|
+
import { uniform } from '../core/UniformNode.js';
|
|
8
|
+
import { Vector2, RenderTarget } from 'three';
|
|
9
|
+
import QuadMesh from '../../objects/QuadMesh.js';
|
|
10
|
+
|
|
11
|
+
const quadMesh = new QuadMesh();
|
|
12
|
+
|
|
13
|
+
class GaussianBlurNode extends TempNode {
|
|
14
|
+
|
|
15
|
+
constructor( textureNode, sigma = 2 ) {
|
|
16
|
+
|
|
17
|
+
super( textureNode );
|
|
18
|
+
|
|
19
|
+
this.textureNode = textureNode;
|
|
20
|
+
this.sigma = sigma;
|
|
21
|
+
|
|
22
|
+
this.directionNode = vec2( 1 );
|
|
23
|
+
|
|
24
|
+
this._invSize = uniform( new Vector2() );
|
|
25
|
+
this._passDirection = uniform( new Vector2() );
|
|
26
|
+
|
|
27
|
+
this._horizontalRT = new RenderTarget();
|
|
28
|
+
this._verticalRT = new RenderTarget();
|
|
29
|
+
|
|
30
|
+
this.updateBeforeType = NodeUpdateType.RENDER;
|
|
31
|
+
|
|
32
|
+
this.resolution = new Vector2( 1, 1 );
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
setSize( width, height ) {
|
|
37
|
+
|
|
38
|
+
width = Math.max( Math.round( width * this.resolution.x ), 1 );
|
|
39
|
+
height = Math.max( Math.round( height * this.resolution.y ), 1 );
|
|
40
|
+
|
|
41
|
+
this._invSize.value.set( 1 / width, 1 / height );
|
|
42
|
+
this._horizontalRT.setSize( width, height );
|
|
43
|
+
this._verticalRT.setSize( width, height );
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
updateBefore( frame ) {
|
|
48
|
+
|
|
49
|
+
const { renderer } = frame;
|
|
50
|
+
|
|
51
|
+
const textureNode = this.textureNode;
|
|
52
|
+
const map = textureNode.value;
|
|
53
|
+
|
|
54
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
55
|
+
const currentTexture = textureNode.value;
|
|
56
|
+
|
|
57
|
+
quadMesh.material = this._material;
|
|
58
|
+
|
|
59
|
+
this.setSize( map.image.width, map.image.height );
|
|
60
|
+
|
|
61
|
+
// horizontal
|
|
62
|
+
|
|
63
|
+
renderer.setRenderTarget( this._horizontalRT );
|
|
64
|
+
|
|
65
|
+
this._passDirection.value.set( 1, 0 );
|
|
66
|
+
|
|
67
|
+
quadMesh.render( renderer );
|
|
68
|
+
|
|
69
|
+
// vertical
|
|
70
|
+
|
|
71
|
+
textureNode.value = this._horizontalRT.texture;
|
|
72
|
+
renderer.setRenderTarget( this._verticalRT );
|
|
73
|
+
|
|
74
|
+
this._passDirection.value.set( 0, 1 );
|
|
75
|
+
|
|
76
|
+
quadMesh.render( renderer );
|
|
77
|
+
|
|
78
|
+
// restore
|
|
79
|
+
|
|
80
|
+
renderer.setRenderTarget( currentRenderTarget );
|
|
81
|
+
textureNode.value = currentTexture;
|
|
82
|
+
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
setup( builder ) {
|
|
86
|
+
|
|
87
|
+
const textureNode = this.textureNode;
|
|
88
|
+
|
|
89
|
+
if ( textureNode.isTextureNode !== true ) {
|
|
90
|
+
|
|
91
|
+
console.error( 'GaussianBlurNode requires a TextureNode.' );
|
|
92
|
+
|
|
93
|
+
return vec4();
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
//
|
|
98
|
+
|
|
99
|
+
const uvNode = textureNode.uvNode || uv();
|
|
100
|
+
|
|
101
|
+
const sampleTexture = ( uv ) => textureNode.cache().context( { getUV: () => uv, forceUVContext: true } );
|
|
102
|
+
|
|
103
|
+
const blur = tslFn( () => {
|
|
104
|
+
|
|
105
|
+
const kernelSize = 3 + ( 2 * this.sigma );
|
|
106
|
+
const gaussianCoefficients = this._getCoefficients( kernelSize );
|
|
107
|
+
|
|
108
|
+
const invSize = this._invSize;
|
|
109
|
+
const direction = vec2( this.directionNode ).mul( this._passDirection );
|
|
110
|
+
|
|
111
|
+
const weightSum = float( gaussianCoefficients[ 0 ] ).toVar();
|
|
112
|
+
const diffuseSum = vec3( sampleTexture( uvNode ).mul( weightSum ) ).toVar();
|
|
113
|
+
|
|
114
|
+
for ( let i = 1; i < kernelSize; i ++ ) {
|
|
115
|
+
|
|
116
|
+
const x = float( i );
|
|
117
|
+
const w = float( gaussianCoefficients[ i ] );
|
|
118
|
+
|
|
119
|
+
const uvOffset = vec2( direction.mul( invSize.mul( x ) ) ).toVar();
|
|
120
|
+
|
|
121
|
+
const sample1 = vec3( sampleTexture( uvNode.add( uvOffset ) ) );
|
|
122
|
+
const sample2 = vec3( sampleTexture( uvNode.sub( uvOffset ) ) );
|
|
123
|
+
|
|
124
|
+
diffuseSum.addAssign( sample1.add( sample2 ).mul( w ) );
|
|
125
|
+
weightSum.addAssign( mul( 2.0, w ) );
|
|
126
|
+
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return vec4( diffuseSum.div( weightSum ), 1.0 );
|
|
130
|
+
|
|
131
|
+
} );
|
|
132
|
+
|
|
133
|
+
//
|
|
134
|
+
|
|
135
|
+
const material = this._material || ( this._material = builder.createNodeMaterial( 'MeshBasicNodeMaterial' ) );
|
|
136
|
+
material.fragmentNode = blur();
|
|
137
|
+
|
|
138
|
+
//
|
|
139
|
+
|
|
140
|
+
const properties = builder.getNodeProperties( this );
|
|
141
|
+
properties.textureNode = textureNode;
|
|
142
|
+
|
|
143
|
+
//
|
|
144
|
+
|
|
145
|
+
return texture( this._verticalRT.texture );
|
|
146
|
+
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
_getCoefficients( kernelRadius ) {
|
|
150
|
+
|
|
151
|
+
const coefficients = [];
|
|
152
|
+
|
|
153
|
+
for ( let i = 0; i < kernelRadius; i ++ ) {
|
|
154
|
+
|
|
155
|
+
coefficients.push( 0.39894 * Math.exp( - 0.5 * i * i / ( kernelRadius * kernelRadius ) ) / kernelRadius );
|
|
156
|
+
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return coefficients;
|
|
160
|
+
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export const gaussianBlur = ( node, sigma ) => nodeObject( new GaussianBlurNode( nodeObject( node ), sigma ) );
|
|
166
|
+
|
|
167
|
+
addNodeElement( 'gaussianBlur', gaussianBlur );
|
|
168
|
+
|
|
169
|
+
export default GaussianBlurNode;
|
|
170
|
+
|
|
@@ -8,7 +8,7 @@ import { tangentView } from '../accessors/TangentNode.js';
|
|
|
8
8
|
import { uv } from '../accessors/UVNode.js';
|
|
9
9
|
import { faceDirection } from './FrontFacingNode.js';
|
|
10
10
|
import { addNodeClass } from '../core/Node.js';
|
|
11
|
-
import { tslFn, nodeProxy, vec3, mat3 } from '../shadernode/ShaderNode.js';
|
|
11
|
+
import { addNodeElement, tslFn, nodeProxy, vec3, mat3 } from '../shadernode/ShaderNode.js';
|
|
12
12
|
|
|
13
13
|
import { TangentSpaceNormalMap, ObjectSpaceNormalMap } from 'three';
|
|
14
14
|
|
|
@@ -103,4 +103,6 @@ export const normalMap = nodeProxy( NormalMapNode );
|
|
|
103
103
|
|
|
104
104
|
export const TBNViewMatrix = mat3( tangentView, bitangentView, normalView );
|
|
105
105
|
|
|
106
|
+
addNodeElement( 'normalMap', normalMap );
|
|
107
|
+
|
|
106
108
|
addNodeClass( 'NormalMapNode', NormalMapNode );
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { addNodeClass } from '../core/Node.js';
|
|
2
|
+
import TempNode from '../core/TempNode.js';
|
|
3
|
+
import TextureNode from '../accessors/TextureNode.js';
|
|
4
|
+
import { NodeUpdateType } from '../core/constants.js';
|
|
5
|
+
import { nodeObject } from '../shadernode/ShaderNode.js';
|
|
6
|
+
import { uniform } from '../core/UniformNode.js';
|
|
7
|
+
import { viewZToOrthographicDepth, perspectiveDepthToViewZ } from './ViewportDepthNode.js';
|
|
8
|
+
import { RenderTarget, Vector2, HalfFloatType, DepthTexture, FloatType, NoToneMapping } from 'three';
|
|
9
|
+
|
|
10
|
+
class PassTextureNode extends TextureNode {
|
|
11
|
+
|
|
12
|
+
constructor( passNode, texture ) {
|
|
13
|
+
|
|
14
|
+
super( texture );
|
|
15
|
+
|
|
16
|
+
this.passNode = passNode;
|
|
17
|
+
|
|
18
|
+
this.setUpdateMatrix( false );
|
|
19
|
+
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
setup( builder ) {
|
|
23
|
+
|
|
24
|
+
this.passNode.build( builder );
|
|
25
|
+
|
|
26
|
+
return super.setup( builder );
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
clone() {
|
|
31
|
+
|
|
32
|
+
return new this.constructor( this.passNode, this.value );
|
|
33
|
+
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class PassNode extends TempNode {
|
|
39
|
+
|
|
40
|
+
constructor( scope, scene, camera ) {
|
|
41
|
+
|
|
42
|
+
super( 'vec4' );
|
|
43
|
+
|
|
44
|
+
this.scope = scope;
|
|
45
|
+
this.scene = scene;
|
|
46
|
+
this.camera = camera;
|
|
47
|
+
|
|
48
|
+
this._pixelRatio = 1;
|
|
49
|
+
this._width = 1;
|
|
50
|
+
this._height = 1;
|
|
51
|
+
|
|
52
|
+
const depthTexture = new DepthTexture();
|
|
53
|
+
depthTexture.isRenderTargetTexture = true;
|
|
54
|
+
depthTexture.type = FloatType;
|
|
55
|
+
depthTexture.name = 'PostProcessingDepth';
|
|
56
|
+
|
|
57
|
+
const renderTarget = new RenderTarget( this._width * this._pixelRatio, this._height * this._pixelRatio, { type: HalfFloatType } );
|
|
58
|
+
renderTarget.texture.name = 'PostProcessing';
|
|
59
|
+
renderTarget.depthTexture = depthTexture;
|
|
60
|
+
|
|
61
|
+
this.renderTarget = renderTarget;
|
|
62
|
+
|
|
63
|
+
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
64
|
+
|
|
65
|
+
this._textureNode = nodeObject( new PassTextureNode( this, renderTarget.texture ) );
|
|
66
|
+
this._depthTextureNode = nodeObject( new PassTextureNode( this, depthTexture ) );
|
|
67
|
+
|
|
68
|
+
this._depthNode = null;
|
|
69
|
+
this._cameraNear = uniform( 0 );
|
|
70
|
+
this._cameraFar = uniform( 0 );
|
|
71
|
+
|
|
72
|
+
this.isPassNode = true;
|
|
73
|
+
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
isGlobal() {
|
|
77
|
+
|
|
78
|
+
return true;
|
|
79
|
+
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getTextureNode() {
|
|
83
|
+
|
|
84
|
+
return this._textureNode;
|
|
85
|
+
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
getTextureDepthNode() {
|
|
89
|
+
|
|
90
|
+
return this._depthTextureNode;
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
getDepthNode() {
|
|
95
|
+
|
|
96
|
+
if ( this._depthNode === null ) {
|
|
97
|
+
|
|
98
|
+
const cameraNear = this._cameraNear;
|
|
99
|
+
const cameraFar = this._cameraFar;
|
|
100
|
+
|
|
101
|
+
this._depthNode = viewZToOrthographicDepth( perspectiveDepthToViewZ( this._depthTextureNode, cameraNear, cameraFar ), cameraNear, cameraFar );
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return this._depthNode;
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
setup() {
|
|
110
|
+
|
|
111
|
+
return this.scope === PassNode.COLOR ? this.getTextureNode() : this.getDepthNode();
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
updateBefore( frame ) {
|
|
116
|
+
|
|
117
|
+
const { renderer } = frame;
|
|
118
|
+
const { scene, camera } = this;
|
|
119
|
+
|
|
120
|
+
this._pixelRatio = renderer.getPixelRatio();
|
|
121
|
+
|
|
122
|
+
const size = renderer.getSize( new Vector2() );
|
|
123
|
+
|
|
124
|
+
this.setSize( size.width, size.height );
|
|
125
|
+
|
|
126
|
+
const currentToneMapping = renderer.toneMapping;
|
|
127
|
+
const currentToneMappingNode = renderer.toneMappingNode;
|
|
128
|
+
const currentRenderTarget = renderer.getRenderTarget();
|
|
129
|
+
|
|
130
|
+
this._cameraNear.value = camera.near;
|
|
131
|
+
this._cameraFar.value = camera.far;
|
|
132
|
+
|
|
133
|
+
renderer.toneMapping = NoToneMapping;
|
|
134
|
+
renderer.toneMappingNode = null;
|
|
135
|
+
renderer.setRenderTarget( this.renderTarget );
|
|
136
|
+
|
|
137
|
+
renderer.render( scene, camera );
|
|
138
|
+
|
|
139
|
+
renderer.toneMapping = currentToneMapping;
|
|
140
|
+
renderer.toneMappingNode = currentToneMappingNode;
|
|
141
|
+
renderer.setRenderTarget( currentRenderTarget );
|
|
142
|
+
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
setSize( width, height ) {
|
|
146
|
+
|
|
147
|
+
this._width = width;
|
|
148
|
+
this._height = height;
|
|
149
|
+
|
|
150
|
+
const effectiveWidth = this._width * this._pixelRatio;
|
|
151
|
+
const effectiveHeight = this._height * this._pixelRatio;
|
|
152
|
+
|
|
153
|
+
this.renderTarget.setSize( effectiveWidth, effectiveHeight );
|
|
154
|
+
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
setPixelRatio( pixelRatio ) {
|
|
158
|
+
|
|
159
|
+
this._pixelRatio = pixelRatio;
|
|
160
|
+
|
|
161
|
+
this.setSize( this._width, this._height );
|
|
162
|
+
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
dispose() {
|
|
166
|
+
|
|
167
|
+
this.renderTarget.dispose();
|
|
168
|
+
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
PassNode.COLOR = 'color';
|
|
175
|
+
PassNode.DEPTH = 'depth';
|
|
176
|
+
|
|
177
|
+
export default PassNode;
|
|
178
|
+
|
|
179
|
+
export const pass = ( scene, camera ) => nodeObject( new PassNode( PassNode.COLOR, scene, camera ) );
|
|
180
|
+
export const depthPass = ( scene, camera ) => nodeObject( new PassNode( PassNode.DEPTH, scene, camera ) );
|
|
181
|
+
|
|
182
|
+
addNodeClass( 'PassNode', PassNode );
|
|
@@ -6,17 +6,31 @@ import { viewportDepthTexture } from './ViewportDepthTextureNode.js';
|
|
|
6
6
|
|
|
7
7
|
class ViewportDepthNode extends Node {
|
|
8
8
|
|
|
9
|
-
constructor( scope,
|
|
9
|
+
constructor( scope, valueNode = null ) {
|
|
10
10
|
|
|
11
11
|
super( 'float' );
|
|
12
12
|
|
|
13
13
|
this.scope = scope;
|
|
14
|
-
this.
|
|
14
|
+
this.valueNode = valueNode;
|
|
15
15
|
|
|
16
16
|
this.isViewportDepthNode = true;
|
|
17
17
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
generate( builder ) {
|
|
21
|
+
|
|
22
|
+
const { scope } = this;
|
|
23
|
+
|
|
24
|
+
if ( scope === ViewportDepthNode.DEPTH_PIXEL ) {
|
|
25
|
+
|
|
26
|
+
return builder.getFragDepth();
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return super.generate( builder );
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
20
34
|
setup( /*builder*/ ) {
|
|
21
35
|
|
|
22
36
|
const { scope } = this;
|
|
@@ -29,11 +43,19 @@ class ViewportDepthNode extends Node {
|
|
|
29
43
|
|
|
30
44
|
} else if ( scope === ViewportDepthNode.DEPTH_TEXTURE ) {
|
|
31
45
|
|
|
32
|
-
const texture = this.
|
|
46
|
+
const texture = this.valueNode || viewportDepthTexture();
|
|
33
47
|
|
|
34
48
|
const viewZ = perspectiveDepthToViewZ( texture, cameraNear, cameraFar );
|
|
35
49
|
node = viewZToOrthographicDepth( viewZ, cameraNear, cameraFar );
|
|
36
50
|
|
|
51
|
+
} else if ( scope === ViewportDepthNode.DEPTH_PIXEL ) {
|
|
52
|
+
|
|
53
|
+
if ( this.valueNode !== null ) {
|
|
54
|
+
|
|
55
|
+
node = depthPixelBase().assign( this.valueNode );
|
|
56
|
+
|
|
57
|
+
}
|
|
58
|
+
|
|
37
59
|
}
|
|
38
60
|
|
|
39
61
|
return node;
|
|
@@ -60,10 +82,16 @@ export const perspectiveDepthToViewZ = ( depth, near, far ) => near.mul( far ).d
|
|
|
60
82
|
|
|
61
83
|
ViewportDepthNode.DEPTH = 'depth';
|
|
62
84
|
ViewportDepthNode.DEPTH_TEXTURE = 'depthTexture';
|
|
85
|
+
ViewportDepthNode.DEPTH_PIXEL = 'depthPixel';
|
|
63
86
|
|
|
64
87
|
export default ViewportDepthNode;
|
|
65
88
|
|
|
89
|
+
const depthPixelBase = nodeProxy( ViewportDepthNode, ViewportDepthNode.DEPTH_PIXEL );
|
|
90
|
+
|
|
66
91
|
export const depth = nodeImmutable( ViewportDepthNode, ViewportDepthNode.DEPTH );
|
|
67
92
|
export const depthTexture = nodeProxy( ViewportDepthNode, ViewportDepthNode.DEPTH_TEXTURE );
|
|
93
|
+
export const depthPixel = nodeImmutable( ViewportDepthNode, ViewportDepthNode.DEPTH_PIXEL );
|
|
94
|
+
|
|
95
|
+
depthPixel.assign = ( value ) => depthPixelBase( value );
|
|
68
96
|
|
|
69
97
|
addNodeClass( 'ViewportDepthNode', ViewportDepthNode );
|
|
@@ -2,7 +2,7 @@ import ViewportTextureNode from './ViewportTextureNode.js';
|
|
|
2
2
|
import { addNodeClass } from '../core/Node.js';
|
|
3
3
|
import { addNodeElement, nodeProxy } from '../shadernode/ShaderNode.js';
|
|
4
4
|
import { viewportTopLeft } from './ViewportNode.js';
|
|
5
|
-
import { DepthTexture,
|
|
5
|
+
import { DepthTexture, NearestMipmapNearestFilter, DepthFormat, UnsignedIntType } from 'three';
|
|
6
6
|
|
|
7
7
|
let sharedDepthbuffer = null;
|
|
8
8
|
|
|
@@ -13,7 +13,7 @@ class ViewportDepthTextureNode extends ViewportTextureNode {
|
|
|
13
13
|
if ( sharedDepthbuffer === null ) {
|
|
14
14
|
|
|
15
15
|
sharedDepthbuffer = new DepthTexture();
|
|
16
|
-
sharedDepthbuffer.minFilter =
|
|
16
|
+
sharedDepthbuffer.minFilter = NearestMipmapNearestFilter;
|
|
17
17
|
sharedDepthbuffer.type = UnsignedIntType;
|
|
18
18
|
sharedDepthbuffer.format = DepthFormat;
|
|
19
19
|
|
|
@@ -21,7 +21,7 @@ class ViewportNode extends Node {
|
|
|
21
21
|
|
|
22
22
|
getNodeType() {
|
|
23
23
|
|
|
24
|
-
return this.scope === ViewportNode.
|
|
24
|
+
return this.scope === ViewportNode.VIEWPORT ? 'vec4' : 'vec2';
|
|
25
25
|
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -55,7 +55,7 @@ class ViewportNode extends Node {
|
|
|
55
55
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
setup( builder ) {
|
|
58
|
+
setup( /*builder*/ ) {
|
|
59
59
|
|
|
60
60
|
const scope = this.scope;
|
|
61
61
|
|
|
@@ -73,17 +73,12 @@ class ViewportNode extends Node {
|
|
|
73
73
|
|
|
74
74
|
} else {
|
|
75
75
|
|
|
76
|
-
|
|
77
|
-
const resolutionNode = new ViewportNode( ViewportNode.RESOLUTION );
|
|
78
|
-
|
|
79
|
-
output = coordinateNode.div( resolutionNode );
|
|
76
|
+
output = viewportCoordinate.div( viewportResolution );
|
|
80
77
|
|
|
81
78
|
let outX = output.x;
|
|
82
79
|
let outY = output.y;
|
|
83
80
|
|
|
84
|
-
if ( /
|
|
85
|
-
else if ( /bottom/i.test( scope ) && builder.isFlipY() === false ) outY = outY.oneMinus();
|
|
86
|
-
|
|
81
|
+
if ( /bottom/i.test( scope ) ) outY = outY.oneMinus();
|
|
87
82
|
if ( /right/i.test( scope ) ) outX = outX.oneMinus();
|
|
88
83
|
|
|
89
84
|
output = vec2( outX, outY );
|
|
@@ -98,7 +93,19 @@ class ViewportNode extends Node {
|
|
|
98
93
|
|
|
99
94
|
if ( this.scope === ViewportNode.COORDINATE ) {
|
|
100
95
|
|
|
101
|
-
|
|
96
|
+
let coord = builder.getFragCoord();
|
|
97
|
+
|
|
98
|
+
if ( builder.isFlipY() ) {
|
|
99
|
+
|
|
100
|
+
// follow webgpu standards
|
|
101
|
+
|
|
102
|
+
const resolution = builder.getNodeProperties( viewportResolution ).outputNode.build( builder );
|
|
103
|
+
|
|
104
|
+
coord = `${ builder.getType( 'vec2' ) }( ${ coord }.x, ${ resolution }.y - ${ coord }.y )`;
|
|
105
|
+
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return coord;
|
|
102
109
|
|
|
103
110
|
}
|
|
104
111
|
|
|
@@ -4,7 +4,7 @@ import { sheen, sheenRoughness } from '../../core/PropertyNode.js';
|
|
|
4
4
|
import { tslFn, float } from '../../shadernode/ShaderNode.js';
|
|
5
5
|
|
|
6
6
|
// https://github.com/google/filament/blob/master/shaders/src/brdf.fs
|
|
7
|
-
const D_Charlie = ( roughness, dotNH ) => {
|
|
7
|
+
const D_Charlie = tslFn( ( { roughness, dotNH } ) => {
|
|
8
8
|
|
|
9
9
|
const alpha = roughness.pow2();
|
|
10
10
|
|
|
@@ -15,15 +15,29 @@ const D_Charlie = ( roughness, dotNH ) => {
|
|
|
15
15
|
|
|
16
16
|
return float( 2.0 ).add( invAlpha ).mul( sin2h.pow( invAlpha.mul( 0.5 ) ) ).div( 2.0 * Math.PI );
|
|
17
17
|
|
|
18
|
-
}
|
|
18
|
+
} ).setLayout( {
|
|
19
|
+
name: 'D_Charlie',
|
|
20
|
+
type: 'float',
|
|
21
|
+
inputs: [
|
|
22
|
+
{ name: 'roughness', type: 'float' },
|
|
23
|
+
{ name: 'dotNH', type: 'float' }
|
|
24
|
+
]
|
|
25
|
+
} );
|
|
19
26
|
|
|
20
27
|
// https://github.com/google/filament/blob/master/shaders/src/brdf.fs
|
|
21
|
-
const V_Neubelt = ( dotNV, dotNL ) => {
|
|
28
|
+
const V_Neubelt = tslFn( ( { dotNV, dotNL } ) => {
|
|
22
29
|
|
|
23
30
|
// Neubelt and Pettineo 2013, "Crafting a Next-gen Material Pipeline for The Order: 1886"
|
|
24
31
|
return float( 1.0 ).div( float( 4.0 ).mul( dotNL.add( dotNV ).sub( dotNL.mul( dotNV ) ) ) );
|
|
25
32
|
|
|
26
|
-
}
|
|
33
|
+
} ).setLayout( {
|
|
34
|
+
name: 'V_Neubelt',
|
|
35
|
+
type: 'float',
|
|
36
|
+
inputs: [
|
|
37
|
+
{ name: 'dotNV', type: 'float' },
|
|
38
|
+
{ name: 'dotNL', type: 'float' }
|
|
39
|
+
]
|
|
40
|
+
} );
|
|
27
41
|
|
|
28
42
|
const BRDF_Sheen = tslFn( ( { lightDirection } ) => {
|
|
29
43
|
|
|
@@ -33,8 +47,8 @@ const BRDF_Sheen = tslFn( ( { lightDirection } ) => {
|
|
|
33
47
|
const dotNV = transformedNormalView.dot( positionViewDirection ).clamp();
|
|
34
48
|
const dotNH = transformedNormalView.dot( halfDir ).clamp();
|
|
35
49
|
|
|
36
|
-
const D = D_Charlie( sheenRoughness, dotNH );
|
|
37
|
-
const V = V_Neubelt( dotNV, dotNL );
|
|
50
|
+
const D = D_Charlie( { roughness: sheenRoughness, dotNH } );
|
|
51
|
+
const V = V_Neubelt( { dotNV, dotNL } );
|
|
38
52
|
|
|
39
53
|
return sheen.mul( D ).mul( V );
|
|
40
54
|
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import { transformedNormalView } from '../../accessors/NormalNode.js';
|
|
2
|
-
import { positionViewDirection } from '../../accessors/PositionNode.js';
|
|
3
1
|
import { tslFn, vec2, vec4 } from '../../shadernode/ShaderNode.js';
|
|
4
2
|
|
|
5
3
|
// Analytical approximation of the DFG LUT, one half of the
|
|
6
4
|
// split-sum approximation used in indirect specular lighting.
|
|
7
5
|
// via 'environmentBRDF' from "Physically Based Shading on Mobile"
|
|
8
6
|
// https://www.unrealengine.com/blog/physically-based-shading-on-mobile
|
|
9
|
-
const DFGApprox = tslFn( (
|
|
10
|
-
|
|
11
|
-
const { roughness } = inputs;
|
|
12
|
-
|
|
13
|
-
const dotNV = inputs.dotNV || transformedNormalView.dot( positionViewDirection ).clamp(); // @ TODO: Move to core dotNV
|
|
7
|
+
const DFGApprox = tslFn( ( { roughness, dotNV } ) => {
|
|
14
8
|
|
|
15
9
|
const c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );
|
|
16
10
|
|
|
@@ -24,6 +18,13 @@ const DFGApprox = tslFn( ( inputs ) => {
|
|
|
24
18
|
|
|
25
19
|
return fab;
|
|
26
20
|
|
|
21
|
+
} ).setLayout( {
|
|
22
|
+
name: 'DFGApprox',
|
|
23
|
+
type: 'vec2',
|
|
24
|
+
inputs: [
|
|
25
|
+
{ name: 'roughness', type: 'float' },
|
|
26
|
+
{ name: 'dotNV', type: 'vec3' }
|
|
27
|
+
]
|
|
27
28
|
} );
|
|
28
29
|
|
|
29
30
|
export default DFGApprox;
|
|
@@ -3,9 +3,7 @@ import { tslFn } from '../../shadernode/ShaderNode.js';
|
|
|
3
3
|
// Microfacet Models for Refraction through Rough Surfaces - equation (33)
|
|
4
4
|
// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html
|
|
5
5
|
// alpha is "roughness squared" in Disney’s reparameterization
|
|
6
|
-
const D_GGX = tslFn( (
|
|
7
|
-
|
|
8
|
-
const { alpha, dotNH } = inputs;
|
|
6
|
+
const D_GGX = tslFn( ( { alpha, dotNH } ) => {
|
|
9
7
|
|
|
10
8
|
const a2 = alpha.pow2();
|
|
11
9
|
|
|
@@ -13,6 +11,13 @@ const D_GGX = tslFn( ( inputs ) => {
|
|
|
13
11
|
|
|
14
12
|
return a2.div( denom.pow2() ).mul( 1 / Math.PI );
|
|
15
13
|
|
|
14
|
+
} ).setLayout( {
|
|
15
|
+
name: 'D_GGX',
|
|
16
|
+
type: 'float',
|
|
17
|
+
inputs: [
|
|
18
|
+
{ name: 'alpha', type: 'float' },
|
|
19
|
+
{ name: 'dotNH', type: 'float' }
|
|
20
|
+
]
|
|
16
21
|
} ); // validated
|
|
17
22
|
|
|
18
23
|
export default D_GGX;
|
|
@@ -8,6 +8,14 @@ const Schlick_to_F0 = tslFn( ( { f, f90, dotVH } ) => {
|
|
|
8
8
|
|
|
9
9
|
return f.sub( vec3( f90 ).mul( x5 ) ).div( x5.oneMinus() );
|
|
10
10
|
|
|
11
|
+
} ).setLayout( {
|
|
12
|
+
name: 'Schlick_to_F0',
|
|
13
|
+
type: 'vec3',
|
|
14
|
+
inputs: [
|
|
15
|
+
{ name: 'f', type: 'vec3' },
|
|
16
|
+
{ name: 'f90', type: 'float' },
|
|
17
|
+
{ name: 'dotVH', type: 'float' }
|
|
18
|
+
]
|
|
11
19
|
} );
|
|
12
20
|
|
|
13
21
|
export default Schlick_to_F0;
|
|
@@ -15,6 +15,14 @@ const V_GGX_SmithCorrelated = tslFn( ( inputs ) => {
|
|
|
15
15
|
|
|
16
16
|
return div( 0.5, gv.add( gl ).max( EPSILON ) );
|
|
17
17
|
|
|
18
|
+
} ).setLayout( {
|
|
19
|
+
name: 'V_GGX_SmithCorrelated',
|
|
20
|
+
type: 'float',
|
|
21
|
+
inputs: [
|
|
22
|
+
{ name: 'alpha', type: 'float' },
|
|
23
|
+
{ name: 'dotNL', type: 'float' },
|
|
24
|
+
{ name: 'dotNV', type: 'float' }
|
|
25
|
+
]
|
|
18
26
|
} ); // validated
|
|
19
27
|
|
|
20
28
|
export default V_GGX_SmithCorrelated;
|