@takram/three-geospatial-effects 0.0.1-alpha.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.
Files changed (60) hide show
  1. package/README.md +15 -0
  2. package/build/index.cjs +1 -0
  3. package/build/index.js +25 -0
  4. package/build/r3f.cjs +748 -0
  5. package/build/r3f.js +1645 -0
  6. package/build/shared.cjs +315 -0
  7. package/build/shared.js +741 -0
  8. package/package.json +52 -0
  9. package/src/DepthEffect.ts +81 -0
  10. package/src/DitheringEffect.ts +28 -0
  11. package/src/DownsampleThresholdMaterial.ts +83 -0
  12. package/src/GeometryEffect.ts +79 -0
  13. package/src/GeometryPass.ts +53 -0
  14. package/src/LensFlareEffect.ts +185 -0
  15. package/src/LensFlareFeaturesMaterial.ts +96 -0
  16. package/src/NormalEffect.ts +135 -0
  17. package/src/createHaldLookupTexture.ts +20 -0
  18. package/src/index.ts +7 -0
  19. package/src/r3f/Depth.tsx +8 -0
  20. package/src/r3f/Dithering.tsx +5 -0
  21. package/src/r3f/EffectComposer.tsx +189 -0
  22. package/src/r3f/Geometry.tsx +45 -0
  23. package/src/r3f/LensFlare.tsx +30 -0
  24. package/src/r3f/Normal.tsx +49 -0
  25. package/src/r3f/SSAO.tsx +123 -0
  26. package/src/r3f/index.ts +8 -0
  27. package/src/r3f/types.ts +12 -0
  28. package/src/setupMaterialsForGeometryPass.ts +131 -0
  29. package/src/shaders/depthEffect.frag +26 -0
  30. package/src/shaders/ditheringEffect.frag +7 -0
  31. package/src/shaders/downsampleThreshold.frag +73 -0
  32. package/src/shaders/downsampleThreshold.vert +34 -0
  33. package/src/shaders/geometryEffect.frag +17 -0
  34. package/src/shaders/lensFlareEffect.frag +12 -0
  35. package/src/shaders/lensFlareFeatures.frag +73 -0
  36. package/src/shaders/lensFlareFeatures.vert +10 -0
  37. package/src/shaders/normalEffect.frag +37 -0
  38. package/src/shaders/ssr.frag +381 -0
  39. package/src/shaders/ssr.vert +6 -0
  40. package/src/shaders/ssrEffect.frag +6 -0
  41. package/types/DepthEffect.d.ts +23 -0
  42. package/types/DitheringEffect.d.ts +11 -0
  43. package/types/DownsampleThresholdMaterial.d.ts +21 -0
  44. package/types/GeometryEffect.d.ts +20 -0
  45. package/types/GeometryPass.d.ts +9 -0
  46. package/types/LensFlareEffect.d.ts +43 -0
  47. package/types/LensFlareFeaturesMaterial.d.ts +26 -0
  48. package/types/NormalEffect.d.ts +27 -0
  49. package/types/createHaldLookupTexture.d.ts +4 -0
  50. package/types/index.d.ts +7 -0
  51. package/types/r3f/Depth.d.ts +8 -0
  52. package/types/r3f/Dithering.d.ts +6 -0
  53. package/types/r3f/EffectComposer.d.ts +25 -0
  54. package/types/r3f/Geometry.d.ts +6 -0
  55. package/types/r3f/LensFlare.d.ts +6 -0
  56. package/types/r3f/Normal.d.ts +6 -0
  57. package/types/r3f/SSAO.d.ts +26 -0
  58. package/types/r3f/index.d.ts +8 -0
  59. package/types/r3f/types.d.ts +8 -0
  60. package/types/setupMaterialsForGeometryPass.d.ts +8 -0
@@ -0,0 +1,381 @@
1
+ // Based on the following work and adapted to Three.js.
2
+ // https://github.com/kode80/kode80SSR/blob/master/Assets/Resources/Shaders/SSR.shader
3
+ //
4
+ // Copyright (c) 2015, Ben Hopkins (kode80)
5
+ // All rights reserved.
6
+ //
7
+ // Redistribution and use in source and binary forms, with or without modification,
8
+ // are permitted provided that the following conditions are met:
9
+ //
10
+ // 1. Redistributions of source code must retain the above copyright notice,
11
+ // this list of conditions and the following disclaimer.
12
+ //
13
+ // 2. Redistributions in binary form must reproduce the above copyright notice,
14
+ // this list of conditions and the following disclaimer in the documentation
15
+ // and/or other materials provided with the distribution.
16
+ //
17
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
18
+ // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19
+ // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
20
+ // THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
22
+ // OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
+ // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
25
+ // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+
27
+ #include <common>
28
+ #include <packing>
29
+
30
+ uniform sampler2D inputBuffer;
31
+ uniform sampler2D geometryBuffer;
32
+ uniform sampler2D depthBuffer;
33
+
34
+ uniform vec2 resolution;
35
+ uniform vec2 texelSize;
36
+ uniform float cameraNear;
37
+ uniform float cameraFar;
38
+ uniform mat4 projectionMatrix;
39
+ uniform mat4 inverseProjectionMatrix;
40
+
41
+ uniform float iterations;
42
+ uniform float binarySearchIterations;
43
+ uniform float pixelZSize;
44
+ uniform float pixelStride;
45
+ uniform float pixelStrideZCutoff;
46
+ uniform float maxRayDistance;
47
+ uniform float screenEdgeFadeStart;
48
+ uniform float eyeFadeStart;
49
+ uniform float eyeFadeEnd;
50
+ uniform float jitter;
51
+ uniform float roughness;
52
+
53
+ in vec2 vUv;
54
+
55
+ float readDepth(const vec2 uv) {
56
+ #if DEPTH_PACKING == 3201
57
+ return unpackRGBAToDepth(texture2D(depthBuffer, uv));
58
+ #else
59
+ return texture2D(depthBuffer, uv).r;
60
+ #endif // DEPTH_PACKING == 3201
61
+ }
62
+
63
+ float getLinearDepth(vec2 screenPosition) {
64
+ float fragCoordZ = texture2D(depthBuffer, screenPosition).x;
65
+ float nz = cameraNear * fragCoordZ;
66
+ return -nz / (cameraFar * (fragCoordZ - 1.0) - nz);
67
+ }
68
+
69
+ float getViewZ(const float depth) {
70
+ #ifdef PERSPECTIVE_CAMERA
71
+ return perspectiveDepthToViewZ(depth, cameraNear, cameraFar);
72
+ #else
73
+ return orthographicDepthToViewZ(depth, cameraNear, cameraFar);
74
+ #endif
75
+ }
76
+
77
+ vec3 readNormal(const vec2 uv) {
78
+ return unpackVec2ToNormal(texture2D(geometryBuffer, uv).xy);
79
+ }
80
+
81
+ void swapIfBigger(inout float aa, inout float bb) {
82
+ if (aa > bb) {
83
+ float tmp = aa;
84
+ aa = bb;
85
+ bb = tmp;
86
+ }
87
+ }
88
+
89
+ float distanceSquared(vec2 a, vec2 b) {
90
+ a -= b;
91
+ return dot(a, a);
92
+ }
93
+
94
+ bool rayIntersectsDepth(float zA, float zB, vec2 uv) {
95
+ float sceneZMax = getViewZ(
96
+ reverseLogDepth(readDepth(uv), cameraNear, cameraFar)
97
+ );
98
+ float sceneZMin = sceneZMax - pixelZSize;
99
+ return zB >= sceneZMin && zA <= sceneZMax;
100
+ }
101
+
102
+ // Trace a ray in screenspace from rayOrg (in camera space) pointing in
103
+ // rayDirection (in camera space) using jitter to offset the ray based on
104
+ // (jitter * pixelStride).
105
+ // Returns true if the ray hits a pixel in the depth buffer and outputs the
106
+ // hitPixel (in UV space), the hitPoint (in camera space) and the number of
107
+ // iterations it took to get there.
108
+ //
109
+ // Based on Morgan McGuire & Mike's GLSL implementation:
110
+ // http://casual-effects.blogspot.com/2014/08/screen-space-ray-tracing.html
111
+ bool traceScreenSpaceRay(
112
+ vec3 rayOrigin,
113
+ vec3 rayDirection,
114
+ float jitter,
115
+ out vec2 hitPixel,
116
+ out vec3 hitPoint,
117
+ out float iterationCount
118
+ ) {
119
+ // Clip to the near plane
120
+ float rayLength =
121
+ rayOrigin.z + rayDirection.z * maxRayDistance > -cameraNear
122
+ ? (-cameraNear - rayOrigin.z) / rayDirection.z
123
+ : maxRayDistance;
124
+ vec3 rayEnd = rayOrigin + rayDirection * rayLength;
125
+
126
+ // Project into homogeneous clip space
127
+ vec4 H0 = projectionMatrix * vec4(rayOrigin, 1.0);
128
+ vec4 H1 = projectionMatrix * vec4(rayEnd, 1.0);
129
+ float k0 = 1.0 / H0.w;
130
+ float k1 = 1.0 / H1.w;
131
+
132
+ // The interpolated homogeneous version of the camera-space points
133
+ vec3 Q0 = rayOrigin * k0;
134
+ vec3 Q1 = rayEnd * k1;
135
+
136
+ // Screen-space endpoints
137
+ vec2 P0 = H0.xy * k0;
138
+ vec2 P1 = H1.xy * k1;
139
+ P0 = (P0 * 0.5 + 0.5) * resolution;
140
+ P1 = (P1 * 0.5 + 0.5) * resolution;
141
+
142
+ // If the line is degenerate, make it cover at least one pixel to avoid
143
+ // handling zero-pixel extent as a special case later.
144
+ P1 += distanceSquared(P0, P1) < 0.0001 ? 0.01 : 0.0;
145
+ vec2 delta = P1 - P0;
146
+
147
+ // Permute so that the primary iteration is in x to collapse all quadrant-
148
+ // specific DDA class later.
149
+ bool permute = false;
150
+ if (abs(delta.x) < abs(delta.y)) {
151
+ // This is a more-vertical line
152
+ permute = true;
153
+ delta = delta.yx;
154
+ P0 = P0.yx;
155
+ P1 = P1.yx;
156
+ }
157
+
158
+ float stepDirection = sign(delta.x);
159
+ float invdx = stepDirection / delta.x;
160
+
161
+ // Track the derivatives of Q and K
162
+ vec3 dQ = (Q1 - Q0) * invdx;
163
+ float dk = (k1 - k0) * invdx;
164
+ vec2 dP = vec2(stepDirection, delta.y * invdx);
165
+
166
+ // Calculate pixel stride based on distance of ray origin from camera.
167
+ // Since perspective means distant objects will be smaller in screen space,
168
+ // we can use this to have higher quality reflections for far away objects
169
+ // while still using a large pixel stride for near objects (and increase
170
+ // performance). This also helps mitigate artifacts on distance reflections
171
+ // when we use a large pixel stride.
172
+ float strideScaler = 1.0 - min(1.0, -rayOrigin.z / pixelStrideZCutoff);
173
+ float pixelStride = 1.0 + strideScaler * pixelStride;
174
+
175
+ // Scale derivatives by the desired pixel stride and then offset the starting
176
+ // values by the jitter fraction.
177
+ dP *= pixelStride;
178
+ dQ *= pixelStride;
179
+ dk *= pixelStride;
180
+ P0 += dP * jitter;
181
+ Q0 += dQ * jitter;
182
+ k0 += dk * jitter;
183
+
184
+ float zA = 0.0;
185
+ float zB = 0.0;
186
+
187
+ // Track ray step and derivatives in a vec4 to parallelize.
188
+ vec4 PQK = vec4(P0, Q0.z, k0);
189
+ vec4 dPQK = vec4(dP, dQ.z, dk);
190
+ bool intersect = false;
191
+
192
+ float count = 0.0;
193
+ for (int i = 0; i < MAX_ITERATIONS; ++i) {
194
+ if (float(i) >= iterations) {
195
+ break;
196
+ }
197
+ if (intersect) {
198
+ break;
199
+ }
200
+
201
+ PQK += dPQK;
202
+ zA = zB;
203
+ zB = (dPQK.z * 0.5 + PQK.z) / (dPQK.w * 0.5 + PQK.w);
204
+ swapIfBigger(zB, zA);
205
+
206
+ hitPixel = permute ? PQK.yx : PQK.xy;
207
+ hitPixel *= texelSize;
208
+ intersect = rayIntersectsDepth(zA, zB, hitPixel);
209
+
210
+ count = float(i);
211
+ }
212
+
213
+ // Binary search refinement
214
+ if (pixelStride > 1.0 && intersect) {
215
+ float originalStride = pixelStride * 0.5;
216
+ float stride = originalStride;
217
+
218
+ PQK -= dPQK;
219
+ dPQK /= pixelStride;
220
+ zA = PQK.z / PQK.w;
221
+ zB = zA;
222
+
223
+ for (int i = 0; i < MAX_BINARY_SEARCH_ITERATIONS; ++i) {
224
+ if (float(i) >= binarySearchIterations) {
225
+ break;
226
+ }
227
+
228
+ PQK += dPQK * stride;
229
+ zA = zB;
230
+ zB = (dPQK.z * -0.5 + PQK.z) / (dPQK.w * -0.5 + PQK.w);
231
+ swapIfBigger(zB, zA);
232
+
233
+ hitPixel = permute ? PQK.yx : PQK.xy;
234
+ hitPixel *= texelSize;
235
+
236
+ originalStride *= 0.5;
237
+ stride = rayIntersectsDepth(zA, zB, hitPixel)
238
+ ? -originalStride
239
+ : originalStride;
240
+ }
241
+ }
242
+
243
+ Q0.xy += dQ.xy * count;
244
+ Q0.z = PQK.z;
245
+ hitPoint = Q0 / PQK.w;
246
+ iterationCount = count;
247
+
248
+ return intersect;
249
+ }
250
+
251
+ // https://github.com/kode80/kode80SSR
252
+ float calculateAlphaForIntersection(
253
+ bool intersect,
254
+ float iterationCount,
255
+ float specularStrength,
256
+ vec2 hitPixel,
257
+ vec3 hitPoint,
258
+ vec3 rayOrigin,
259
+ vec3 rayDirection
260
+ ) {
261
+ float alpha = 1.0;
262
+ // float alpha = min(1.0, specularStrength);
263
+
264
+ // Fade ray hits test approach the maximum iterations.
265
+ alpha *= 1.0 - iterationCount / iterations;
266
+
267
+ // Fade ray hits that approach the screen edge.
268
+ float screenFade = screenEdgeFadeStart;
269
+ vec2 hitPixelNDC = hitPixel * 2.0 - 1.0;
270
+ float maxDistance = min(1.0, max(abs(hitPixelNDC.x), abs(hitPixelNDC.y)));
271
+ alpha *= 1.0 - max(0.0, maxDistance - screenFade) / (1.0 - screenFade);
272
+
273
+ // Fade ray hits base on how much they face the camera.
274
+ float eyeFadeStart = eyeFadeStart;
275
+ float eyeFadeEnd = eyeFadeEnd;
276
+ swapIfBigger(eyeFadeStart, eyeFadeEnd);
277
+ float eyeDirection = clamp(rayDirection.z, eyeFadeStart, eyeFadeEnd);
278
+ alpha *= 1.0 - (eyeDirection - eyeFadeStart) / (eyeFadeEnd - eyeFadeStart);
279
+
280
+ // Fade ray hits based on distance from ray origin.
281
+ float rayDistance = distance(rayOrigin, hitPoint);
282
+ alpha *= 1.0 - clamp(rayDistance / maxRayDistance, 0.0, 1.0);
283
+
284
+ alpha *= intersect ? 1.0 : 0.0;
285
+
286
+ return alpha;
287
+ }
288
+
289
+ // TODO: Use blue noise.
290
+ vec2 whiteNoise(vec3 v) {
291
+ v = fract(v * vec3(443.897, 441.423, 0.0973));
292
+ v += dot(v, v.yzx + 19.19);
293
+ return fract((v.xx + v.yz) * v.zy);
294
+ }
295
+
296
+ // Source: https://github.com/tuxalin/vulkanri/blob/master/examples/pbr_ibl/shaders/importanceSampleGGX.glsl
297
+ vec3 sampleGGX(const vec3 n, const vec2 u, float roughness) {
298
+ float alpha = roughness * roughness;
299
+ float alpha2 = alpha * alpha;
300
+
301
+ float phi = 2.0 * PI * u.x;
302
+ float cosTheta = sqrt((1.0 - u.y) / (1.0 + (alpha2 - 1.0) * u.y));
303
+ float sinTheta = sqrt(1.0 - cosTheta * cosTheta);
304
+
305
+ vec3 H;
306
+ H.x = cos(phi) * sinTheta;
307
+ H.y = sin(phi) * sinTheta;
308
+ H.z = cosTheta;
309
+
310
+ vec3 up = abs(n.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0);
311
+ vec3 tangent = normalize(cross(up, n));
312
+ vec3 bitangent = cross(n, tangent);
313
+
314
+ vec3 sampleVec = tangent * H.x + bitangent * H.y + n * H.z;
315
+ return normalize(sampleVec);
316
+ }
317
+
318
+ void main() {
319
+ vec4 geometry = texture2D(geometryBuffer, vUv);
320
+ float metalness = geometry.z;
321
+ if (metalness < 0.01) {
322
+ return;
323
+ }
324
+
325
+ float depth = readDepth(vUv);
326
+ if (depth > 0.9999) {
327
+ return;
328
+ }
329
+ depth = reverseLogDepth(depth, cameraNear, cameraFar);
330
+ float viewZ = getViewZ(depth);
331
+
332
+ vec3 viewPosition = screenToView(
333
+ vUv,
334
+ depth,
335
+ viewZ,
336
+ projectionMatrix,
337
+ inverseProjectionMatrix
338
+ );
339
+ vec3 viewNormal = readNormal(vUv);
340
+
341
+ vec3 rayOrigin = viewPosition;
342
+ vec3 rayDirection = reflect(normalize(rayOrigin), viewNormal);
343
+ float scaledRoughness = geometry.w * roughness;
344
+ if (scaledRoughness > 0.0001) {
345
+ rayDirection = sampleGGX(
346
+ rayDirection,
347
+ whiteNoise(vec3(vUv, 0.0)),
348
+ scaledRoughness
349
+ );
350
+ }
351
+
352
+ vec2 uv2 = vUv * resolution;
353
+ float c = (uv2.x + uv2.y) * 0.25;
354
+ float jitter = mod(c, 1.0) * jitter;
355
+
356
+ vec2 hitPixel;
357
+ vec3 hitPoint;
358
+ float iterationCount;
359
+
360
+ bool intersect = traceScreenSpaceRay(
361
+ rayOrigin,
362
+ rayDirection,
363
+ jitter,
364
+ hitPixel,
365
+ hitPoint,
366
+ iterationCount
367
+ );
368
+
369
+ float alpha = calculateAlphaForIntersection(
370
+ intersect,
371
+ iterationCount,
372
+ 1.0,
373
+ hitPixel,
374
+ hitPoint,
375
+ rayOrigin,
376
+ rayDirection
377
+ );
378
+
379
+ vec3 color = texture2D(inputBuffer, hitPixel).rgb;
380
+ gl_FragColor = vec4(color, alpha);
381
+ }
@@ -0,0 +1,6 @@
1
+ out vec2 vUv;
2
+
3
+ void main() {
4
+ vUv = position.xy * 0.5 + 0.5;
5
+ gl_Position = vec4(position.xy, 1.0, 1.0);
6
+ }
@@ -0,0 +1,6 @@
1
+ uniform sampler2D ssrBuffer;
2
+
3
+ void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
4
+ vec4 ssr = texture2D(ssrBuffer, uv);
5
+ outputColor = vec4(mix(inputColor.rgb, ssr.rgb, ssr.a), 1.0);
6
+ }
@@ -0,0 +1,23 @@
1
+ import { BlendFunction, Effect } from 'postprocessing';
2
+
3
+ export interface DepthEffectOptions {
4
+ blendFunction?: BlendFunction;
5
+ useTurbo?: boolean;
6
+ near?: number;
7
+ far?: number;
8
+ }
9
+ export declare const depthEffectOptionsDefaults: {
10
+ blendFunction: BlendFunction;
11
+ useTurbo: false;
12
+ near: number;
13
+ far: number;
14
+ };
15
+ export declare class DepthEffect extends Effect {
16
+ constructor(options?: DepthEffectOptions);
17
+ get useTurbo(): boolean;
18
+ set useTurbo(value: boolean);
19
+ get near(): number;
20
+ set near(value: number);
21
+ get far(): number;
22
+ set far(value: number);
23
+ }
@@ -0,0 +1,11 @@
1
+ import { BlendFunction, Effect } from 'postprocessing';
2
+
3
+ export interface DitheringEffectOptions {
4
+ blendFunction?: BlendFunction;
5
+ }
6
+ export declare const ditheringOptionsDefaults: {
7
+ blendFunction: BlendFunction;
8
+ };
9
+ export declare class DitheringEffect extends Effect {
10
+ constructor(options?: DitheringEffectOptions);
11
+ }
@@ -0,0 +1,21 @@
1
+ import { ShaderMaterial, ShaderMaterialParameters, Texture } from 'three';
2
+
3
+ export interface DownsampleThresholdMaterialParameters extends ShaderMaterialParameters {
4
+ inputBuffer?: Texture | null;
5
+ thresholdLevel?: number;
6
+ thresholdRange?: number;
7
+ }
8
+ export declare const downsampleThresholdMaterialParametersDefaults: {
9
+ thresholdLevel: number;
10
+ thresholdRange: number;
11
+ };
12
+ export declare class DownsampleThresholdMaterial extends ShaderMaterial {
13
+ constructor(params?: DownsampleThresholdMaterialParameters);
14
+ setSize(width: number, height: number): void;
15
+ get inputBuffer(): Texture | null;
16
+ set inputBuffer(value: Texture | null);
17
+ get thresholdLevel(): number;
18
+ set thresholdLevel(value: number);
19
+ get thresholdRange(): number;
20
+ set thresholdRange(value: number);
21
+ }
@@ -0,0 +1,20 @@
1
+ import { Texture } from 'three';
2
+ import { BlendFunction, Effect } from 'postprocessing';
3
+
4
+ export type GeometryEffectOutput = 'normal' | 'pbr';
5
+ export interface GeometryEffectOptions {
6
+ blendFunction?: BlendFunction;
7
+ geometryBuffer?: Texture | null;
8
+ output?: GeometryEffectOutput;
9
+ }
10
+ export declare const geometryEffectOptionsDefaults: {
11
+ blendFunction: BlendFunction;
12
+ output: "normal";
13
+ };
14
+ export declare class GeometryEffect extends Effect {
15
+ constructor(options?: GeometryEffectOptions);
16
+ get geometryBuffer(): Texture | null;
17
+ set geometryBuffer(value: Texture | null);
18
+ get output(): GeometryEffectOutput;
19
+ set output(value: GeometryEffectOutput);
20
+ }
@@ -0,0 +1,9 @@
1
+ import { Camera, Material, Scene, Texture, WebGLRenderer, WebGLRenderTarget } from 'three';
2
+ import { RenderPass } from 'postprocessing';
3
+
4
+ export declare class GeometryPass extends RenderPass {
5
+ readonly geometryTexture: Texture;
6
+ constructor(inputBuffer: WebGLRenderTarget, scene?: Scene, camera?: Camera, overrideMaterial?: Material);
7
+ render(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget | null, outputBuffer: WebGLRenderTarget | null, deltaTime?: number, stencilTest?: boolean): void;
8
+ setSize(width: number, height: number): void;
9
+ }
@@ -0,0 +1,43 @@
1
+ import { LensFlareFeaturesMaterial } from './LensFlareFeaturesMaterial';
2
+ import { DownsampleThresholdMaterial } from './DownsampleThresholdMaterial';
3
+ import { WebGLRenderTarget, TextureDataType, WebGLRenderer } from 'three';
4
+ import { BlendFunction, Effect, KawaseBlurPass, MipmapBlurPass, Resolution, ShaderPass } from 'postprocessing';
5
+
6
+ export interface LensFlareEffectOptions {
7
+ blendFunction?: BlendFunction;
8
+ resolutionScale?: number;
9
+ width?: number;
10
+ height?: number;
11
+ resolutionX?: number;
12
+ resolutionY?: number;
13
+ intensity?: number;
14
+ }
15
+ export declare const lensFlareEffectOptionsDefaults: {
16
+ blendFunction: BlendFunction;
17
+ resolutionScale: number;
18
+ width: number;
19
+ height: number;
20
+ intensity: number;
21
+ };
22
+ export declare class LensFlareEffect extends Effect {
23
+ readonly resolution: Resolution;
24
+ readonly renderTarget1: WebGLRenderTarget;
25
+ readonly renderTarget2: WebGLRenderTarget;
26
+ readonly thresholdMaterial: DownsampleThresholdMaterial;
27
+ readonly thresholdPass: ShaderPass;
28
+ readonly blurPass: MipmapBlurPass;
29
+ readonly preBlurPass: KawaseBlurPass;
30
+ readonly featuresMaterial: LensFlareFeaturesMaterial;
31
+ readonly featuresPass: ShaderPass;
32
+ constructor(options?: LensFlareEffectOptions);
33
+ private readonly onResolutionChange;
34
+ initialize(renderer: WebGLRenderer, alpha: boolean, frameBufferType: TextureDataType): void;
35
+ update(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, deltaTime?: number): void;
36
+ setSize(width: number, height: number): void;
37
+ get intensity(): number;
38
+ set intensity(value: number);
39
+ get thresholdLevel(): number;
40
+ set thresholdLevel(value: number);
41
+ get thresholdRange(): number;
42
+ set thresholdRange(value: number);
43
+ }
@@ -0,0 +1,26 @@
1
+ import { ShaderMaterial, ShaderMaterialParameters, Texture } from 'three';
2
+
3
+ export interface LensFlareFeaturesMaterialParameters extends ShaderMaterialParameters {
4
+ inputBuffer?: Texture | null;
5
+ lensColorTexture?: Texture | null;
6
+ ghostAmount?: number;
7
+ haloAmount?: number;
8
+ chromaticAberration?: number;
9
+ }
10
+ export declare const lensFlareFeaturesMaterialParametersDefaults: {
11
+ ghostAmount: number;
12
+ haloAmount: number;
13
+ chromaticAberration: number;
14
+ };
15
+ export declare class LensFlareFeaturesMaterial extends ShaderMaterial {
16
+ constructor(params?: LensFlareFeaturesMaterialParameters);
17
+ setSize(width: number, height: number): void;
18
+ get inputBuffer(): Texture | null;
19
+ set inputBuffer(value: Texture | null);
20
+ get ghostAmount(): number;
21
+ set ghostAmount(value: number);
22
+ get haloAmount(): number;
23
+ set haloAmount(value: number);
24
+ get chromaticAberration(): number;
25
+ set chromaticAberration(value: number);
26
+ }
@@ -0,0 +1,27 @@
1
+ import { Camera, Texture, WebGLRenderer, WebGLRenderTarget } from 'three';
2
+ import { BlendFunction, Effect } from 'postprocessing';
3
+
4
+ export interface NormalEffectOptions {
5
+ blendFunction?: BlendFunction;
6
+ normalBuffer?: Texture | null;
7
+ octEncoded?: boolean;
8
+ reconstructFromDepth?: boolean;
9
+ }
10
+ export declare const normalEffectOptionsDefaults: {
11
+ blendFunction: BlendFunction;
12
+ octEncoded: false;
13
+ reconstructFromDepth: false;
14
+ };
15
+ export declare class NormalEffect extends Effect {
16
+ private camera;
17
+ constructor(camera: Camera, options?: NormalEffectOptions);
18
+ get mainCamera(): Camera;
19
+ set mainCamera(value: Camera);
20
+ update(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, deltaTime?: number): void;
21
+ get normalBuffer(): Texture | null;
22
+ set normalBuffer(value: Texture | null);
23
+ get octEncoded(): boolean;
24
+ set octEncoded(value: boolean);
25
+ get reconstructFromDepth(): boolean;
26
+ set reconstructFromDepth(value: boolean);
27
+ }
@@ -0,0 +1,4 @@
1
+ import { Texture } from 'three';
2
+ import { LookupTexture } from 'postprocessing';
3
+
4
+ export declare function createHaldLookupTexture(texture: Texture): LookupTexture;
@@ -0,0 +1,7 @@
1
+ export * from './createHaldLookupTexture';
2
+ export * from './DepthEffect';
3
+ export * from './DitheringEffect';
4
+ export * from './GeometryPass';
5
+ export * from './LensFlareEffect';
6
+ export * from './NormalEffect';
7
+ export * from './setupMaterialsForGeometryPass';
@@ -0,0 +1,8 @@
1
+ import { DepthEffect } from '../DepthEffect';
2
+ import { ComponentPropsWithoutRef } from 'react';
3
+
4
+ export declare const Depth: import('react').ForwardRefExoticComponent<Omit<import('@react-three/fiber').ExtendedColors<import('@react-three/fiber').Overwrite<Partial<DepthEffect>, import('@react-three/fiber').NodeProps<DepthEffect, typeof DepthEffect>>> & import('../DepthEffect').DepthEffectOptions & {
5
+ blendFunction?: import('postprocessing').BlendFunction;
6
+ opacity?: number;
7
+ }, "ref"> & import('react').RefAttributes<typeof DepthEffect>>;
8
+ export type DepthProps = ComponentPropsWithoutRef<typeof Depth>;
@@ -0,0 +1,6 @@
1
+ import { DitheringEffect } from '../DitheringEffect';
2
+
3
+ export declare const Dithering: import('react').ForwardRefExoticComponent<Omit<import('@react-three/fiber').ExtendedColors<import('@react-three/fiber').Overwrite<Partial<DitheringEffect>, import('@react-three/fiber').NodeProps<DitheringEffect, typeof DitheringEffect>>> & import('../DitheringEffect').DitheringEffectOptions & {
4
+ blendFunction?: import('postprocessing').BlendFunction;
5
+ opacity?: number;
6
+ }, "ref"> & import('react').RefAttributes<typeof DitheringEffect>>;
@@ -0,0 +1,25 @@
1
+ import { GeometryPass } from '../GeometryPass';
2
+ import { Camera, Scene, TextureDataType } from 'three';
3
+ import { Context, ReactNode } from 'react';
4
+ import { EffectComposer as EffectComposerImpl } from 'postprocessing';
5
+ import { EffectComposerContext } from '@react-three/postprocessing';
6
+
7
+ type InferContextValue<T> = T extends Context<infer U> ? U : never;
8
+ export interface EffectComposerContextValue extends InferContextValue<typeof EffectComposerContext> {
9
+ geometryPass?: GeometryPass;
10
+ }
11
+ export interface EffectComposerProps {
12
+ enabled?: boolean;
13
+ depthBuffer?: boolean;
14
+ stencilBuffer?: boolean;
15
+ autoClear?: boolean;
16
+ resolutionScale?: number;
17
+ multisampling?: number;
18
+ frameBufferType?: TextureDataType;
19
+ renderPriority?: number;
20
+ camera?: Camera;
21
+ scene?: Scene;
22
+ children?: ReactNode;
23
+ }
24
+ export declare const EffectComposer: import('react').ForwardRefExoticComponent<EffectComposerProps & import('react').RefAttributes<EffectComposerImpl>>;
25
+ export {};
@@ -0,0 +1,6 @@
1
+ import { EffectProps } from './types';
2
+ import { GeometryEffect, GeometryEffectOptions } from '../GeometryEffect';
3
+
4
+ export interface GeometryProps extends EffectProps<typeof GeometryEffect, GeometryEffectOptions> {
5
+ }
6
+ export declare const Geometry: import('react').ForwardRefExoticComponent<Omit<GeometryProps, "ref"> & import('react').RefAttributes<GeometryEffect>>;
@@ -0,0 +1,6 @@
1
+ import { EffectProps } from './types';
2
+ import { LensFlareEffect, LensFlareEffectOptions } from '../LensFlareEffect';
3
+
4
+ export interface LensFlareProps extends EffectProps<typeof LensFlareEffect, LensFlareEffectOptions> {
5
+ }
6
+ export declare const LensFlare: import('react').ForwardRefExoticComponent<Omit<LensFlareProps, "ref"> & import('react').RefAttributes<LensFlareEffect>>;
@@ -0,0 +1,6 @@
1
+ import { EffectProps } from './types';
2
+ import { NormalEffect, NormalEffectOptions } from '../NormalEffect';
3
+
4
+ export interface NormalProps extends EffectProps<typeof NormalEffect, NormalEffectOptions> {
5
+ }
6
+ export declare const Normal: import('react').ForwardRefExoticComponent<Omit<NormalProps, "ref"> & import('react').RefAttributes<NormalEffect>>;