super-three 0.169.1 → 0.170.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 +974 -562
- package/build/three.module.js +975 -559
- package/build/three.module.min.js +1 -1
- package/build/three.webgpu.js +8398 -9842
- package/build/three.webgpu.min.js +1 -1
- package/build/three.webgpu.nodes.js +8398 -9842
- package/build/three.webgpu.nodes.min.js +1 -1
- package/examples/jsm/Addons.js +3 -3
- package/examples/jsm/animation/MMDAnimationHelper.js +2 -0
- package/examples/jsm/animation/MMDPhysics.js +2 -0
- package/examples/jsm/controls/TransformControls.js +22 -6
- package/examples/jsm/csm/CSM.js +2 -2
- package/examples/jsm/csm/CSMFrustum.js +7 -4
- package/examples/jsm/csm/CSMHelper.js +2 -0
- package/examples/jsm/csm/CSMShadowNode.js +435 -0
- package/examples/jsm/curves/NURBSCurve.js +34 -3
- package/examples/jsm/exporters/GLTFExporter.js +138 -71
- package/examples/jsm/exporters/KTX2Exporter.js +35 -12
- package/examples/jsm/exporters/MMDExporter.js +6 -0
- package/examples/jsm/exporters/USDZExporter.js +21 -3
- package/examples/jsm/geometries/DecalGeometry.js +65 -20
- package/examples/jsm/geometries/InstancedPointsGeometry.js +2 -0
- package/examples/jsm/helpers/TextureHelperGPU.js +175 -0
- package/examples/jsm/interactive/HTMLMesh.js +1 -0
- package/examples/jsm/lighting/TiledLighting.js +18 -0
- package/examples/jsm/lights/RectAreaLightTexturesLib.js +1 -1
- package/examples/jsm/lines/LineMaterial.js +7 -2
- package/examples/jsm/lines/LineSegmentsGeometry.js +2 -0
- package/examples/jsm/lines/webgpu/LineSegments2.js +0 -15
- package/examples/jsm/lines/webgpu/Wireframe.js +56 -0
- package/examples/jsm/loaders/3DMLoader.js +1 -0
- package/examples/jsm/loaders/3MFLoader.js +91 -0
- package/examples/jsm/loaders/FBXLoader.js +12 -2
- package/examples/jsm/loaders/GLTFLoader.js +2 -0
- package/examples/jsm/loaders/KTX2Loader.js +140 -49
- package/examples/jsm/loaders/LDrawLoader.js +22 -136
- package/examples/jsm/loaders/LottieLoader.js +1 -0
- package/examples/jsm/loaders/MMDLoader.js +9 -2
- package/examples/jsm/materials/LDrawConditionalLineMaterial.js +143 -0
- package/examples/jsm/materials/LDrawConditionalLineNodeMaterial.js +114 -0
- package/examples/jsm/materials/MeshGouraudMaterial.js +6 -2
- package/examples/jsm/math/ColorSpaces.js +76 -0
- package/examples/jsm/misc/ProgressiveLightMap.js +52 -40
- package/examples/jsm/misc/ProgressiveLightMapGPU.js +293 -0
- package/examples/jsm/misc/VolumeSlice.js +1 -0
- package/examples/jsm/objects/WaterMesh.js +8 -8
- package/examples/jsm/postprocessing/AfterimagePass.js +14 -3
- package/examples/jsm/postprocessing/SSRPass.js +6 -0
- package/examples/jsm/renderers/CSS2DRenderer.js +6 -3
- package/examples/jsm/renderers/CSS3DRenderer.js +7 -4
- package/examples/jsm/shaders/FXAAShader.js +225 -224
- package/examples/jsm/transpiler/ShaderToyDecoder.js +1 -1
- package/{src/nodes → examples/jsm/tsl}/display/AfterImageNode.js +17 -20
- package/{src/nodes → examples/jsm/tsl}/display/AnaglyphPassNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/AnamorphicNode.js +12 -18
- package/{src/nodes → examples/jsm/tsl}/display/BleachBypass.js +1 -3
- package/{src/nodes → examples/jsm/tsl}/display/BloomNode.js +11 -40
- package/{src/nodes → examples/jsm/tsl}/display/DenoiseNode.js +18 -41
- package/{src/nodes → examples/jsm/tsl}/display/DepthOfFieldNode.js +2 -8
- package/{src/nodes → examples/jsm/tsl}/display/DotScreenNode.js +2 -9
- package/examples/jsm/tsl/display/FXAANode.js +316 -0
- package/{src/nodes → examples/jsm/tsl}/display/FilmNode.js +2 -6
- package/{src/nodes → examples/jsm/tsl}/display/GTAONode.js +30 -70
- package/{src/nodes → examples/jsm/tsl}/display/GaussianBlurNode.js +74 -36
- package/examples/jsm/tsl/display/LensflareNode.js +161 -0
- package/{src/nodes → examples/jsm/tsl}/display/Lut3DNode.js +1 -4
- package/{src/nodes → examples/jsm/tsl}/display/MotionBlur.js +2 -3
- package/examples/jsm/tsl/display/OutlineNode.js +434 -0
- package/{src/nodes → examples/jsm/tsl}/display/ParallaxBarrierPassNode.js +1 -5
- package/{src/nodes → examples/jsm/tsl}/display/PixelationPassNode.js +3 -15
- package/{src/nodes → examples/jsm/tsl}/display/RGBShiftNode.js +1 -6
- package/examples/jsm/tsl/display/SMAANode.js +620 -0
- package/{src/nodes → examples/jsm/tsl}/display/SSAAPassNode.js +10 -25
- package/examples/jsm/tsl/display/SSRNode.js +343 -0
- package/{src/nodes → examples/jsm/tsl}/display/Sepia.js +1 -2
- package/{src/nodes → examples/jsm/tsl}/display/SobelOperatorNode.js +3 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoCompositePassNode.js +9 -11
- package/{src/nodes → examples/jsm/tsl}/display/StereoPassNode.js +10 -11
- package/examples/jsm/tsl/display/TRAAPassNode.js +355 -0
- package/{src/nodes → examples/jsm/tsl}/display/TransitionNode.js +1 -6
- package/examples/jsm/tsl/display/hashBlur.js +24 -0
- package/examples/jsm/tsl/lighting/TiledLightsNode.js +392 -0
- package/examples/jsm/utils/{TextureUtilsGPU.js → WebGPUTextureUtils.js} +2 -1
- package/examples/jsm/webxr/OculusHandPointerModel.js +21 -21
- package/examples/jsm/webxr/Text2D.js +6 -6
- package/package.json +2 -2
- package/src/Three.WebGPU.Nodes.js +4 -0
- package/src/Three.WebGPU.js +4 -0
- package/src/constants.js +1 -6
- package/src/core/BufferGeometry.js +44 -6
- package/src/geometries/CylinderGeometry.js +2 -2
- package/src/materials/LineBasicMaterial.js +6 -2
- package/src/materials/LineDashedMaterial.js +6 -2
- package/src/materials/Material.js +14 -1
- package/src/materials/MeshBasicMaterial.js +6 -2
- package/src/materials/MeshDepthMaterial.js +6 -2
- package/src/materials/MeshDistanceMaterial.js +6 -2
- package/src/materials/MeshLambertMaterial.js +6 -2
- package/src/materials/MeshMatcapMaterial.js +6 -2
- package/src/materials/MeshNormalMaterial.js +6 -2
- package/src/materials/MeshPhongMaterial.js +6 -2
- package/src/materials/MeshPhysicalMaterial.js +6 -2
- package/src/materials/MeshStandardMaterial.js +6 -2
- package/src/materials/MeshToonMaterial.js +6 -2
- package/src/materials/PointsMaterial.js +6 -2
- package/src/materials/RawShaderMaterial.js +6 -2
- package/src/materials/ShaderMaterial.js +6 -2
- package/src/materials/ShadowMaterial.js +6 -2
- package/src/materials/SpriteMaterial.js +6 -2
- package/src/materials/nodes/NodeMaterial.js +31 -9
- package/src/materials/nodes/SpriteNodeMaterial.js +11 -2
- package/src/materials/nodes/manager/NodeMaterialObserver.js +111 -2
- package/src/math/ColorManagement.js +118 -85
- package/src/math/Vector4.js +11 -0
- package/src/nodes/Nodes.js +1 -21
- package/src/nodes/TSL.js +6 -24
- package/src/nodes/accessors/Camera.js +0 -1
- package/src/nodes/accessors/SceneNode.js +35 -1
- package/src/nodes/accessors/StorageBufferNode.js +32 -10
- package/src/nodes/accessors/VelocityNode.js +13 -3
- package/src/nodes/code/FunctionCallNode.js +16 -5
- package/src/nodes/code/ScriptableNode.js +4 -4
- package/src/nodes/core/Node.js +1 -0
- package/src/nodes/core/NodeBuilder.js +29 -5
- package/src/nodes/core/VarNode.js +15 -3
- package/src/nodes/display/ColorAdjustment.js +53 -4
- package/src/nodes/display/ColorSpaceFunctions.js +5 -5
- package/src/nodes/display/ColorSpaceNode.js +27 -39
- package/src/nodes/display/PassNode.js +6 -4
- package/src/nodes/display/ToneMappingNode.js +1 -1
- package/src/nodes/display/ViewportDepthNode.js +33 -1
- package/src/nodes/functions/PhysicalLightingModel.js +21 -15
- package/src/nodes/functions/material/getAlphaHashThreshold.js +64 -0
- package/src/nodes/functions/material/getGeometryRoughness.js +8 -2
- package/src/nodes/functions/material/getParallaxCorrectNormal.js +22 -0
- package/src/nodes/gpgpu/ComputeNode.js +9 -1
- package/src/nodes/lighting/AnalyticLightNode.js +12 -416
- package/src/nodes/lighting/LightsNode.js +24 -12
- package/src/nodes/lighting/PointLightNode.js +36 -26
- package/src/nodes/lighting/RectAreaLightNode.js +3 -0
- package/src/nodes/lighting/ShadowNode.js +484 -0
- package/src/nodes/utils/LoopNode.js +2 -2
- package/src/nodes/utils/Oscillators.js +6 -0
- package/src/nodes/utils/PostProcessingUtils.js +89 -0
- package/src/nodes/utils/ReflectorNode.js +101 -15
- package/src/nodes/utils/Timer.js +29 -0
- package/src/objects/BatchedMesh.js +458 -241
- package/src/renderers/WebGLRenderer.js +120 -117
- package/src/renderers/common/Attributes.js +4 -0
- package/src/renderers/common/Backend.js +2 -0
- package/src/renderers/common/Background.js +14 -4
- package/src/renderers/common/Bindings.js +3 -2
- package/src/renderers/common/Constants.js +2 -1
- package/src/renderers/common/Geometries.js +20 -0
- package/src/renderers/common/IndirectStorageBufferAttribute.js +15 -0
- package/src/renderers/common/Lighting.js +45 -0
- package/src/renderers/common/PostProcessingUtils.js +86 -0
- package/src/renderers/common/RenderList.js +39 -11
- package/src/renderers/common/RenderLists.js +4 -2
- package/src/renderers/common/RenderObject.js +18 -1
- package/src/renderers/common/Renderer.js +165 -26
- package/src/renderers/common/Textures.js +30 -14
- package/src/renderers/common/nodes/NodeLibrary.js +1 -14
- package/src/renderers/common/nodes/Nodes.js +2 -2
- package/src/renderers/shaders/ShaderChunk/colorspace_pars_fragment.glsl.js +4 -24
- package/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js +8 -0
- package/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js +2 -2
- package/src/renderers/webgl/WebGLBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLCapabilities.js +0 -7
- package/src/renderers/webgl/WebGLIndexedBufferRenderer.js +2 -6
- package/src/renderers/webgl/WebGLProgram.js +24 -28
- package/src/renderers/webgl/WebGLPrograms.js +5 -2
- package/src/renderers/webgl/WebGLState.js +37 -1
- package/src/renderers/webgl/WebGLTextures.js +29 -12
- package/src/renderers/webgl-fallback/WebGLBackend.js +98 -31
- package/src/renderers/webgl-fallback/WebGLBufferRenderer.js +2 -7
- package/src/renderers/webgl-fallback/utils/WebGLTextureUtils.js +33 -8
- package/src/renderers/webgpu/WebGPUBackend.js +105 -25
- package/src/renderers/webgpu/WebGPURenderer.Nodes.js +1 -1
- package/src/renderers/webgpu/WebGPURenderer.js +1 -1
- package/src/renderers/webgpu/nodes/BasicNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/StandardNodeLibrary.js +0 -8
- package/src/renderers/webgpu/nodes/WGSLNodeBuilder.js +10 -20
- package/src/renderers/webgpu/nodes/WGSLNodeFunction.js +12 -4
- package/src/renderers/webgpu/utils/WebGPUPipelineUtils.js +29 -9
- package/src/renderers/webgpu/utils/WebGPUTextureUtils.js +24 -6
- package/src/renderers/webgpu/utils/WebGPUUtils.js +0 -1
- package/src/renderers/webxr/WebXRManager.js +4 -4
- package/examples/jsm/cameras/CinematicCamera.js +0 -208
- package/src/nodes/display/FXAANode.js +0 -332
- package/src/nodes/utils/OscNode.js +0 -85
- package/src/nodes/utils/TimerNode.js +0 -97
- /package/examples/jsm/utils/{TextureUtils.js → WebGLTextureUtils.js} +0 -0
|
@@ -2,14 +2,6 @@ import {
|
|
|
2
2
|
Vector2
|
|
3
3
|
} from 'three';
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* NVIDIA FXAA by Timothy Lottes
|
|
7
|
-
* https://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf
|
|
8
|
-
* - WebGL port by @supereggbert
|
|
9
|
-
* http://www.glge.org/demos/fxaa/
|
|
10
|
-
* Further improved by Daniel Sturk
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
5
|
const FXAAShader = {
|
|
14
6
|
|
|
15
7
|
name: 'FXAAShader',
|
|
@@ -33,253 +25,262 @@ const FXAAShader = {
|
|
|
33
25
|
}`,
|
|
34
26
|
|
|
35
27
|
fragmentShader: /* glsl */`
|
|
36
|
-
precision highp float;
|
|
37
28
|
|
|
38
|
-
|
|
29
|
+
// FXAA algorithm from NVIDIA, C# implementation by Jasper Flick, GLSL port by Dave Hoskins
|
|
30
|
+
// http://developer.download.nvidia.com/assets/gamedev/files/sdk/11/FXAA_WhitePaper.pdf
|
|
31
|
+
// https://catlikecoding.com/unity/tutorials/advanced-rendering/fxaa/
|
|
39
32
|
|
|
33
|
+
uniform sampler2D tDiffuse;
|
|
40
34
|
uniform vec2 resolution;
|
|
41
|
-
|
|
42
35
|
varying vec2 vUv;
|
|
43
36
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
37
|
+
#define EDGE_STEP_COUNT 6
|
|
38
|
+
#define EDGE_GUESS 8.0
|
|
39
|
+
#define EDGE_STEPS 1.0, 1.5, 2.0, 2.0, 2.0, 4.0
|
|
40
|
+
const float edgeSteps[EDGE_STEP_COUNT] = float[EDGE_STEP_COUNT]( EDGE_STEPS );
|
|
41
|
+
|
|
42
|
+
float _ContrastThreshold = 0.0312;
|
|
43
|
+
float _RelativeThreshold = 0.063;
|
|
44
|
+
float _SubpixelBlending = 1.0;
|
|
45
|
+
|
|
46
|
+
vec4 Sample( sampler2D tex2D, vec2 uv ) {
|
|
47
|
+
|
|
48
|
+
return texture( tex2D, uv );
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
float SampleLuminance( sampler2D tex2D, vec2 uv ) {
|
|
53
|
+
|
|
54
|
+
return dot( Sample( tex2D, uv ).rgb, vec3( 0.3, 0.59, 0.11 ) );
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
float SampleLuminance( sampler2D tex2D, vec2 texSize, vec2 uv, float uOffset, float vOffset ) {
|
|
59
|
+
|
|
60
|
+
uv += texSize * vec2(uOffset, vOffset);
|
|
61
|
+
return SampleLuminance(tex2D, uv);
|
|
62
|
+
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
struct LuminanceData {
|
|
66
|
+
|
|
67
|
+
float m, n, e, s, w;
|
|
68
|
+
float ne, nw, se, sw;
|
|
69
|
+
float highest, lowest, contrast;
|
|
70
|
+
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
LuminanceData SampleLuminanceNeighborhood( sampler2D tex2D, vec2 texSize, vec2 uv ) {
|
|
74
|
+
|
|
75
|
+
LuminanceData l;
|
|
76
|
+
l.m = SampleLuminance( tex2D, uv );
|
|
77
|
+
l.n = SampleLuminance( tex2D, texSize, uv, 0.0, 1.0 );
|
|
78
|
+
l.e = SampleLuminance( tex2D, texSize, uv, 1.0, 0.0 );
|
|
79
|
+
l.s = SampleLuminance( tex2D, texSize, uv, 0.0, -1.0 );
|
|
80
|
+
l.w = SampleLuminance( tex2D, texSize, uv, -1.0, 0.0 );
|
|
81
|
+
|
|
82
|
+
l.ne = SampleLuminance( tex2D, texSize, uv, 1.0, 1.0 );
|
|
83
|
+
l.nw = SampleLuminance( tex2D, texSize, uv, -1.0, 1.0 );
|
|
84
|
+
l.se = SampleLuminance( tex2D, texSize, uv, 1.0, -1.0 );
|
|
85
|
+
l.sw = SampleLuminance( tex2D, texSize, uv, -1.0, -1.0 );
|
|
86
|
+
|
|
87
|
+
l.highest = max( max( max( max( l.n, l.e ), l.s ), l.w ), l.m );
|
|
88
|
+
l.lowest = min( min( min( min( l.n, l.e ), l.s ), l.w ), l.m );
|
|
89
|
+
l.contrast = l.highest - l.lowest;
|
|
90
|
+
return l;
|
|
91
|
+
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
bool ShouldSkipPixel( LuminanceData l ) {
|
|
95
|
+
|
|
96
|
+
float threshold = max( _ContrastThreshold, _RelativeThreshold * l.highest );
|
|
97
|
+
return l.contrast < threshold;
|
|
98
|
+
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
float DeterminePixelBlendFactor( LuminanceData l ) {
|
|
102
|
+
|
|
103
|
+
float f = 2.0 * ( l.n + l.e + l.s + l.w );
|
|
104
|
+
f += l.ne + l.nw + l.se + l.sw;
|
|
105
|
+
f *= 1.0 / 12.0;
|
|
106
|
+
f = abs( f - l.m );
|
|
107
|
+
f = clamp( f / l.contrast, 0.0, 1.0 );
|
|
108
|
+
|
|
109
|
+
float blendFactor = smoothstep( 0.0, 1.0, f );
|
|
110
|
+
return blendFactor * blendFactor * _SubpixelBlending;
|
|
111
|
+
|
|
103
112
|
}
|
|
104
113
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
float
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
float contrastN = contrast( rgbaM, rgbaN );
|
|
145
|
-
float contrastS = contrast( rgbaM, rgbaS );
|
|
146
|
-
float contrastE = contrast( rgbaM, rgbaE );
|
|
147
|
-
float contrastW = contrast( rgbaM, rgbaW );
|
|
148
|
-
|
|
149
|
-
float relativeVContrast = ( contrastN + contrastS ) - ( contrastE + contrastW );
|
|
150
|
-
relativeVContrast *= fxaaQualityinvEdgeThreshold;
|
|
151
|
-
|
|
152
|
-
bool horzSpan = relativeVContrast > 0.;
|
|
153
|
-
// . 1 .
|
|
154
|
-
// 0 0 0
|
|
155
|
-
// . 1 .
|
|
156
|
-
|
|
157
|
-
// 45 deg edge detection and corners of objects, aka V/H contrast is too similar
|
|
158
|
-
if( abs( relativeVContrast ) < .3 ) {
|
|
159
|
-
// locate the edge
|
|
160
|
-
vec2 dirToEdge;
|
|
161
|
-
dirToEdge.x = contrastE > contrastW ? 1. : -1.;
|
|
162
|
-
dirToEdge.y = contrastS > contrastN ? 1. : -1.;
|
|
163
|
-
// . 2 . . 1 .
|
|
164
|
-
// 1 0 2 ~= 0 0 1
|
|
165
|
-
// . 1 . . 0 .
|
|
166
|
-
|
|
167
|
-
// tap 2 pixels and see which ones are "outside" the edge, to
|
|
168
|
-
// determine if the edge is vertical or horizontal
|
|
169
|
-
|
|
170
|
-
vec4 rgbaAlongH = FxaaTexOff(tex, posM, vec2( dirToEdge.x, -dirToEdge.y ), fxaaQualityRcpFrame.xy);
|
|
171
|
-
float matchAlongH = contrast( rgbaM, rgbaAlongH );
|
|
172
|
-
// . 1 .
|
|
173
|
-
// 0 0 1
|
|
174
|
-
// . 0 H
|
|
175
|
-
|
|
176
|
-
vec4 rgbaAlongV = FxaaTexOff(tex, posM, vec2( -dirToEdge.x, dirToEdge.y ), fxaaQualityRcpFrame.xy);
|
|
177
|
-
float matchAlongV = contrast( rgbaM, rgbaAlongV );
|
|
178
|
-
// V 1 .
|
|
179
|
-
// 0 0 1
|
|
180
|
-
// . 0 .
|
|
181
|
-
|
|
182
|
-
relativeVContrast = matchAlongV - matchAlongH;
|
|
183
|
-
relativeVContrast *= fxaaQualityinvEdgeThreshold;
|
|
184
|
-
|
|
185
|
-
if( abs( relativeVContrast ) < .3 ) { // 45 deg edge
|
|
186
|
-
// 1 1 .
|
|
187
|
-
// 0 0 1
|
|
188
|
-
// . 0 1
|
|
189
|
-
|
|
190
|
-
// do a simple blur
|
|
191
|
-
return mix(
|
|
192
|
-
rgbaM,
|
|
193
|
-
(rgbaN + rgbaS + rgbaE + rgbaW) * .25,
|
|
194
|
-
.4
|
|
195
|
-
);
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
horzSpan = relativeVContrast > 0.;
|
|
114
|
+
struct EdgeData {
|
|
115
|
+
|
|
116
|
+
bool isHorizontal;
|
|
117
|
+
float pixelStep;
|
|
118
|
+
float oppositeLuminance, gradient;
|
|
119
|
+
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
EdgeData DetermineEdge( vec2 texSize, LuminanceData l ) {
|
|
123
|
+
|
|
124
|
+
EdgeData e;
|
|
125
|
+
float horizontal =
|
|
126
|
+
abs( l.n + l.s - 2.0 * l.m ) * 2.0 +
|
|
127
|
+
abs( l.ne + l.se - 2.0 * l.e ) +
|
|
128
|
+
abs( l.nw + l.sw - 2.0 * l.w );
|
|
129
|
+
float vertical =
|
|
130
|
+
abs( l.e + l.w - 2.0 * l.m ) * 2.0 +
|
|
131
|
+
abs( l.ne + l.nw - 2.0 * l.n ) +
|
|
132
|
+
abs( l.se + l.sw - 2.0 * l.s );
|
|
133
|
+
e.isHorizontal = horizontal >= vertical;
|
|
134
|
+
|
|
135
|
+
float pLuminance = e.isHorizontal ? l.n : l.e;
|
|
136
|
+
float nLuminance = e.isHorizontal ? l.s : l.w;
|
|
137
|
+
float pGradient = abs( pLuminance - l.m );
|
|
138
|
+
float nGradient = abs( nLuminance - l.m );
|
|
139
|
+
|
|
140
|
+
e.pixelStep = e.isHorizontal ? texSize.y : texSize.x;
|
|
141
|
+
|
|
142
|
+
if (pGradient < nGradient) {
|
|
143
|
+
|
|
144
|
+
e.pixelStep = -e.pixelStep;
|
|
145
|
+
e.oppositeLuminance = nLuminance;
|
|
146
|
+
e.gradient = nGradient;
|
|
147
|
+
|
|
148
|
+
} else {
|
|
149
|
+
|
|
150
|
+
e.oppositeLuminance = pLuminance;
|
|
151
|
+
e.gradient = pGradient;
|
|
152
|
+
|
|
199
153
|
}
|
|
200
154
|
|
|
201
|
-
|
|
202
|
-
if(!horzSpan) rgbaS = rgbaE;
|
|
203
|
-
// . 0 . 1
|
|
204
|
-
// 1 0 1 -> 0
|
|
205
|
-
// . 0 . 1
|
|
155
|
+
return e;
|
|
206
156
|
|
|
207
|
-
|
|
208
|
-
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
float DetermineEdgeBlendFactor( sampler2D tex2D, vec2 texSize, LuminanceData l, EdgeData e, vec2 uv ) {
|
|
160
|
+
|
|
161
|
+
vec2 uvEdge = uv;
|
|
162
|
+
vec2 edgeStep;
|
|
163
|
+
if (e.isHorizontal) {
|
|
164
|
+
|
|
165
|
+
uvEdge.y += e.pixelStep * 0.5;
|
|
166
|
+
edgeStep = vec2( texSize.x, 0.0 );
|
|
167
|
+
|
|
168
|
+
} else {
|
|
169
|
+
|
|
170
|
+
uvEdge.x += e.pixelStep * 0.5;
|
|
171
|
+
edgeStep = vec2( 0.0, texSize.y );
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
float edgeLuminance = ( l.m + e.oppositeLuminance ) * 0.5;
|
|
176
|
+
float gradientThreshold = e.gradient * 0.25;
|
|
177
|
+
|
|
178
|
+
vec2 puv = uvEdge + edgeStep * edgeSteps[0];
|
|
179
|
+
float pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;
|
|
180
|
+
bool pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;
|
|
181
|
+
|
|
182
|
+
for ( int i = 1; i < EDGE_STEP_COUNT && !pAtEnd; i++ ) {
|
|
209
183
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
184
|
+
puv += edgeStep * edgeSteps[i];
|
|
185
|
+
pLuminanceDelta = SampleLuminance( tex2D, puv ) - edgeLuminance;
|
|
186
|
+
pAtEnd = abs( pLuminanceDelta ) >= gradientThreshold;
|
|
213
187
|
|
|
214
|
-
|
|
215
|
-
bool doneP = false;
|
|
188
|
+
}
|
|
216
189
|
|
|
217
|
-
|
|
218
|
-
float pDist = 0.;
|
|
190
|
+
if ( !pAtEnd ) {
|
|
219
191
|
|
|
220
|
-
|
|
221
|
-
vec2 posP = posM;
|
|
192
|
+
puv += edgeStep * EDGE_GUESS;
|
|
222
193
|
|
|
223
|
-
|
|
224
|
-
int iterationsUsedP = 0;
|
|
225
|
-
for( int i = 0; i < NUM_SAMPLES; i++ ) {
|
|
194
|
+
}
|
|
226
195
|
|
|
227
|
-
|
|
196
|
+
vec2 nuv = uvEdge - edgeStep * edgeSteps[0];
|
|
197
|
+
float nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;
|
|
198
|
+
bool nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;
|
|
228
199
|
|
|
229
|
-
|
|
230
|
-
nDist += increment;
|
|
231
|
-
posN = posM + offNP * nDist;
|
|
232
|
-
vec4 rgbaEndN = FxaaTexTop(tex, posN.xy);
|
|
233
|
-
doneN = contrast( rgbaEndN, rgbaM ) > contrast( rgbaEndN, rgbaN );
|
|
234
|
-
iterationsUsedN = i;
|
|
235
|
-
}
|
|
200
|
+
for ( int i = 1; i < EDGE_STEP_COUNT && !nAtEnd; i++ ) {
|
|
236
201
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
vec4 rgbaEndP = FxaaTexTop(tex, posP.xy);
|
|
241
|
-
doneP = contrast( rgbaEndP, rgbaM ) > contrast( rgbaEndP, rgbaN );
|
|
242
|
-
iterationsUsedP = i;
|
|
243
|
-
}
|
|
202
|
+
nuv -= edgeStep * edgeSteps[i];
|
|
203
|
+
nLuminanceDelta = SampleLuminance( tex2D, nuv ) - edgeLuminance;
|
|
204
|
+
nAtEnd = abs( nLuminanceDelta ) >= gradientThreshold;
|
|
244
205
|
|
|
245
|
-
if(doneN || doneP) break;
|
|
246
206
|
}
|
|
247
207
|
|
|
208
|
+
if ( !nAtEnd ) {
|
|
209
|
+
|
|
210
|
+
nuv -= edgeStep * EDGE_GUESS;
|
|
248
211
|
|
|
249
|
-
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
float pDistance, nDistance;
|
|
215
|
+
if ( e.isHorizontal ) {
|
|
250
216
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
doneP ? float( iterationsUsedP ) / float( NUM_SAMPLES - 1 ) : 1.
|
|
254
|
-
);
|
|
217
|
+
pDistance = puv.x - uv.x;
|
|
218
|
+
nDistance = uv.x - nuv.x;
|
|
255
219
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
220
|
+
} else {
|
|
221
|
+
|
|
222
|
+
pDistance = puv.y - uv.y;
|
|
223
|
+
nDistance = uv.y - nuv.y;
|
|
259
224
|
|
|
260
|
-
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
float shortestDistance;
|
|
228
|
+
bool deltaSign;
|
|
229
|
+
if ( pDistance <= nDistance ) {
|
|
230
|
+
|
|
231
|
+
shortestDistance = pDistance;
|
|
232
|
+
deltaSign = pLuminanceDelta >= 0.0;
|
|
233
|
+
|
|
234
|
+
} else {
|
|
235
|
+
|
|
236
|
+
shortestDistance = nDistance;
|
|
237
|
+
deltaSign = nLuminanceDelta >= 0.0;
|
|
238
|
+
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if ( deltaSign == ( l.m - edgeLuminance >= 0.0 ) ) {
|
|
242
|
+
|
|
243
|
+
return 0.0;
|
|
244
|
+
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
return 0.5 - shortestDistance / ( pDistance + nDistance );
|
|
261
248
|
|
|
262
|
-
return mix(
|
|
263
|
-
rgbaM,
|
|
264
|
-
rgbaN,
|
|
265
|
-
dist * .5
|
|
266
|
-
);
|
|
267
249
|
}
|
|
268
250
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
251
|
+
vec4 ApplyFXAA( sampler2D tex2D, vec2 texSize, vec2 uv ) {
|
|
252
|
+
|
|
253
|
+
LuminanceData luminance = SampleLuminanceNeighborhood( tex2D, texSize, uv );
|
|
254
|
+
if ( ShouldSkipPixel( luminance ) ) {
|
|
255
|
+
|
|
256
|
+
return Sample( tex2D, uv );
|
|
257
|
+
|
|
258
|
+
}
|
|
272
259
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
260
|
+
float pixelBlend = DeterminePixelBlendFactor( luminance );
|
|
261
|
+
EdgeData edge = DetermineEdge( texSize, luminance );
|
|
262
|
+
float edgeBlend = DetermineEdgeBlendFactor( tex2D, texSize, luminance, edge, uv );
|
|
263
|
+
float finalBlend = max( pixelBlend, edgeBlend );
|
|
264
|
+
|
|
265
|
+
if (edge.isHorizontal) {
|
|
266
|
+
|
|
267
|
+
uv.y += edge.pixelStep * finalBlend;
|
|
268
|
+
|
|
269
|
+
} else {
|
|
270
|
+
|
|
271
|
+
uv.x += edge.pixelStep * finalBlend;
|
|
272
|
+
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
return Sample( tex2D, uv );
|
|
280
276
|
|
|
281
277
|
}
|
|
282
|
-
|
|
278
|
+
|
|
279
|
+
void main() {
|
|
280
|
+
|
|
281
|
+
gl_FragColor = ApplyFXAA( tDiffuse, resolution.xy, vUv );
|
|
282
|
+
|
|
283
|
+
}`
|
|
283
284
|
|
|
284
285
|
};
|
|
285
286
|
|
|
@@ -7,7 +7,7 @@ class ShaderToyDecoder extends GLSLDecoder {
|
|
|
7
7
|
|
|
8
8
|
super();
|
|
9
9
|
|
|
10
|
-
this.addPolyfill( 'iTime', 'float iTime =
|
|
10
|
+
this.addPolyfill( 'iTime', 'float iTime = time;' );
|
|
11
11
|
this.addPolyfill( 'iResolution', 'vec2 iResolution = screenSize;' );
|
|
12
12
|
this.addPolyfill( 'fragCoord', 'vec3 fragCoord = vec3( screenCoordinate.x, screenSize.y - screenCoordinate.y, screenCoordinate.z );' );
|
|
13
13
|
|
|
@@ -1,22 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { nodeObject, Fn, float, vec4 } from '
|
|
3
|
-
import { NodeUpdateType } from '../core/constants.js';
|
|
4
|
-
import { uv } from '../accessors/UV.js';
|
|
5
|
-
import { texture } from '../accessors/TextureNode.js';
|
|
6
|
-
import { passTexture } from './PassNode.js';
|
|
7
|
-
import { uniform } from '../core/UniformNode.js';
|
|
8
|
-
import { sign, max } from '../math/MathNode.js';
|
|
9
|
-
import { convertToTexture } from '../utils/RTTNode.js';
|
|
10
|
-
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
11
|
-
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
12
|
-
|
|
13
|
-
import { Vector2 } from '../../math/Vector2.js';
|
|
14
|
-
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
1
|
+
import { RenderTarget, Vector2, PostProcessingUtils } from 'three';
|
|
2
|
+
import { TempNode, nodeObject, Fn, float, vec4, NodeUpdateType, uv, texture, passTexture, uniform, sign, max, convertToTexture, QuadMesh, NodeMaterial } from 'three/tsl';
|
|
15
3
|
|
|
16
4
|
const _size = /*@__PURE__*/ new Vector2();
|
|
17
|
-
|
|
18
5
|
const _quadMeshComp = /*@__PURE__*/ new QuadMesh();
|
|
19
6
|
|
|
7
|
+
let _rendererState;
|
|
8
|
+
|
|
20
9
|
class AfterImageNode extends TempNode {
|
|
21
10
|
|
|
22
11
|
static get type() {
|
|
@@ -33,15 +22,15 @@ class AfterImageNode extends TempNode {
|
|
|
33
22
|
this.textureNodeOld = texture();
|
|
34
23
|
this.damp = uniform( damp );
|
|
35
24
|
|
|
36
|
-
this._compRT = new RenderTarget();
|
|
25
|
+
this._compRT = new RenderTarget( 1, 1, { depthBuffer: false } );
|
|
37
26
|
this._compRT.texture.name = 'AfterImageNode.comp';
|
|
38
27
|
|
|
39
|
-
this._oldRT = new RenderTarget();
|
|
28
|
+
this._oldRT = new RenderTarget( 1, 1, { depthBuffer: false } );
|
|
40
29
|
this._oldRT.texture.name = 'AfterImageNode.old';
|
|
41
30
|
|
|
42
31
|
this._textureNode = passTexture( this, this._compRT.texture );
|
|
43
32
|
|
|
44
|
-
this.updateBeforeType = NodeUpdateType.
|
|
33
|
+
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
45
34
|
|
|
46
35
|
}
|
|
47
36
|
|
|
@@ -62,6 +51,10 @@ class AfterImageNode extends TempNode {
|
|
|
62
51
|
|
|
63
52
|
const { renderer } = frame;
|
|
64
53
|
|
|
54
|
+
_rendererState = PostProcessingUtils.resetRendererState( renderer, _rendererState );
|
|
55
|
+
|
|
56
|
+
//
|
|
57
|
+
|
|
65
58
|
const textureNode = this.textureNode;
|
|
66
59
|
const map = textureNode.value;
|
|
67
60
|
|
|
@@ -74,23 +67,27 @@ class AfterImageNode extends TempNode {
|
|
|
74
67
|
|
|
75
68
|
this.setSize( _size.x, _size.y );
|
|
76
69
|
|
|
77
|
-
const currentRenderTarget = renderer.getRenderTarget();
|
|
78
70
|
const currentTexture = textureNode.value;
|
|
79
71
|
|
|
80
72
|
this.textureNodeOld.value = this._oldRT.texture;
|
|
81
73
|
|
|
82
74
|
// comp
|
|
75
|
+
|
|
83
76
|
renderer.setRenderTarget( this._compRT );
|
|
84
77
|
_quadMeshComp.render( renderer );
|
|
85
78
|
|
|
86
79
|
// Swap the textures
|
|
80
|
+
|
|
87
81
|
const temp = this._oldRT;
|
|
88
82
|
this._oldRT = this._compRT;
|
|
89
83
|
this._compRT = temp;
|
|
90
84
|
|
|
91
|
-
|
|
85
|
+
//
|
|
86
|
+
|
|
92
87
|
textureNode.value = currentTexture;
|
|
93
88
|
|
|
89
|
+
PostProcessingUtils.restoreRendererState( renderer, _rendererState );
|
|
90
|
+
|
|
94
91
|
}
|
|
95
92
|
|
|
96
93
|
setup( builder ) {
|
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { uniform } from '../core/UniformNode.js';
|
|
4
|
-
import { uv } from '../accessors/UV.js';
|
|
5
|
-
import { clamp, max } from '../math/MathNode.js';
|
|
1
|
+
import { Matrix3 } from 'three';
|
|
2
|
+
import { clamp, nodeObject, Fn, vec4, uv, uniform, max, NodeMaterial } from 'three/tsl';
|
|
6
3
|
import StereoCompositePassNode from './StereoCompositePassNode.js';
|
|
7
|
-
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
8
4
|
|
|
9
5
|
class AnaglyphPassNode extends StereoCompositePassNode {
|
|
10
6
|
|
|
@@ -1,20 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { nodeObject, Fn, float, vec2, vec3 } from '
|
|
3
|
-
import { Loop } from '../utils/LoopNode.js';
|
|
4
|
-
import { uniform } from '../core/UniformNode.js';
|
|
5
|
-
import { NodeUpdateType } from '../core/constants.js';
|
|
6
|
-
import { threshold } from './ColorAdjustment.js';
|
|
7
|
-
import { uv } from '../accessors/UV.js';
|
|
8
|
-
import { passTexture } from './PassNode.js';
|
|
9
|
-
import { convertToTexture } from '../utils/RTTNode.js';
|
|
10
|
-
import QuadMesh from '../../renderers/common/QuadMesh.js';
|
|
11
|
-
import NodeMaterial from '../../materials/nodes/NodeMaterial.js';
|
|
12
|
-
|
|
13
|
-
import { Vector2 } from '../../math/Vector2.js';
|
|
14
|
-
import { RenderTarget } from '../../core/RenderTarget.js';
|
|
1
|
+
import { RenderTarget, Vector2, PostProcessingUtils } from 'three';
|
|
2
|
+
import { TempNode, nodeObject, Fn, float, NodeUpdateType, uv, passTexture, uniform, convertToTexture, QuadMesh, NodeMaterial, vec2, vec3, Loop, threshold } from 'three/tsl';
|
|
15
3
|
|
|
16
4
|
const _quadMesh = /*@__PURE__*/ new QuadMesh();
|
|
17
5
|
|
|
6
|
+
let _rendererState;
|
|
7
|
+
|
|
18
8
|
class AnamorphicNode extends TempNode {
|
|
19
9
|
|
|
20
10
|
static get type() {
|
|
@@ -34,14 +24,14 @@ class AnamorphicNode extends TempNode {
|
|
|
34
24
|
this.samples = samples;
|
|
35
25
|
this.resolution = new Vector2( 1, 1 );
|
|
36
26
|
|
|
37
|
-
this._renderTarget = new RenderTarget();
|
|
27
|
+
this._renderTarget = new RenderTarget( 1, 1, { depthBuffer: false } );
|
|
38
28
|
this._renderTarget.texture.name = 'anamorphic';
|
|
39
29
|
|
|
40
30
|
this._invSize = uniform( new Vector2() );
|
|
41
31
|
|
|
42
32
|
this._textureNode = passTexture( this, this._renderTarget.texture );
|
|
43
33
|
|
|
44
|
-
this.updateBeforeType = NodeUpdateType.
|
|
34
|
+
this.updateBeforeType = NodeUpdateType.FRAME;
|
|
45
35
|
|
|
46
36
|
}
|
|
47
37
|
|
|
@@ -66,12 +56,15 @@ class AnamorphicNode extends TempNode {
|
|
|
66
56
|
|
|
67
57
|
const { renderer } = frame;
|
|
68
58
|
|
|
59
|
+
_rendererState = PostProcessingUtils.resetRendererState( renderer, _rendererState );
|
|
60
|
+
|
|
61
|
+
//
|
|
62
|
+
|
|
69
63
|
const textureNode = this.textureNode;
|
|
70
64
|
const map = textureNode.value;
|
|
71
65
|
|
|
72
66
|
this._renderTarget.texture.type = map.type;
|
|
73
67
|
|
|
74
|
-
const currentRenderTarget = renderer.getRenderTarget();
|
|
75
68
|
const currentTexture = textureNode.value;
|
|
76
69
|
|
|
77
70
|
_quadMesh.material = this._material;
|
|
@@ -86,9 +79,10 @@ class AnamorphicNode extends TempNode {
|
|
|
86
79
|
|
|
87
80
|
// restore
|
|
88
81
|
|
|
89
|
-
renderer.setRenderTarget( currentRenderTarget );
|
|
90
82
|
textureNode.value = currentTexture;
|
|
91
83
|
|
|
84
|
+
PostProcessingUtils.restoreRendererState( renderer, _rendererState );
|
|
85
|
+
|
|
92
86
|
}
|
|
93
87
|
|
|
94
88
|
setup( builder ) {
|