@takram/three-geospatial-effects 0.0.1-alpha.4 → 0.0.1-alpha.6

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.
@@ -25,7 +25,7 @@ float clampToBorder(const vec2 uv) {
25
25
 
26
26
  // Reference: https://learnopengl.com/Guest-Articles/2022/Phys.-Based-Bloom
27
27
  void main() {
28
- vec3 color = 0.125 * texture2D(inputBuffer, vec2(vRowUv5)).rgb;
28
+ vec3 color = 0.125 * texture(inputBuffer, vec2(vRowUv5)).rgb;
29
29
  vec4 weight =
30
30
  0.03125 *
31
31
  vec4(
@@ -34,10 +34,10 @@ void main() {
34
34
  clampToBorder(vRowUv7),
35
35
  clampToBorder(vRowUv9)
36
36
  );
37
- color += weight.x * texture2D(inputBuffer, vec2(vRowUv1)).rgb;
38
- color += weight.y * texture2D(inputBuffer, vec2(vRowUv3)).rgb;
39
- color += weight.z * texture2D(inputBuffer, vec2(vRowUv7)).rgb;
40
- color += weight.w * texture2D(inputBuffer, vec2(vRowUv9)).rgb;
37
+ color += weight.x * texture(inputBuffer, vec2(vRowUv1)).rgb;
38
+ color += weight.y * texture(inputBuffer, vec2(vRowUv3)).rgb;
39
+ color += weight.z * texture(inputBuffer, vec2(vRowUv7)).rgb;
40
+ color += weight.w * texture(inputBuffer, vec2(vRowUv9)).rgb;
41
41
 
42
42
  weight =
43
43
  0.0625 *
@@ -47,10 +47,10 @@ void main() {
47
47
  clampToBorder(vRowUv6),
48
48
  clampToBorder(vRowUv8)
49
49
  );
50
- color += weight.x * texture2D(inputBuffer, vec2(vRowUv2)).rgb;
51
- color += weight.y * texture2D(inputBuffer, vec2(vRowUv4)).rgb;
52
- color += weight.z * texture2D(inputBuffer, vec2(vRowUv6)).rgb;
53
- color += weight.w * texture2D(inputBuffer, vec2(vRowUv8)).rgb;
50
+ color += weight.x * texture(inputBuffer, vec2(vRowUv2)).rgb;
51
+ color += weight.y * texture(inputBuffer, vec2(vRowUv4)).rgb;
52
+ color += weight.z * texture(inputBuffer, vec2(vRowUv6)).rgb;
53
+ color += weight.w * texture(inputBuffer, vec2(vRowUv8)).rgb;
54
54
 
55
55
  weight =
56
56
  0.125 *
@@ -60,10 +60,10 @@ void main() {
60
60
  clampToBorder(vRowUv6),
61
61
  clampToBorder(vRowUv8)
62
62
  );
63
- color += weight.x * texture2D(inputBuffer, vec2(vCenterUv1)).rgb;
64
- color += weight.y * texture2D(inputBuffer, vec2(vCenterUv2)).rgb;
65
- color += weight.z * texture2D(inputBuffer, vec2(vCenterUv3)).rgb;
66
- color += weight.w * texture2D(inputBuffer, vec2(vCenterUv4)).rgb;
63
+ color += weight.x * texture(inputBuffer, vec2(vCenterUv1)).rgb;
64
+ color += weight.y * texture(inputBuffer, vec2(vCenterUv2)).rgb;
65
+ color += weight.z * texture(inputBuffer, vec2(vCenterUv3)).rgb;
66
+ color += weight.w * texture(inputBuffer, vec2(vCenterUv4)).rgb;
67
67
 
68
68
  // WORKAROUND: Avoid screen flashes if the input buffer contains NaN texels.
69
69
  // See: https://github.com/takram-design-engineering/three-geospatial/issues/7
@@ -73,8 +73,6 @@ void main() {
73
73
  }
74
74
 
75
75
  float l = luminance(color);
76
- float scale = saturate(
77
- smoothstep(thresholdLevel, thresholdLevel + thresholdRange, l)
78
- );
76
+ float scale = saturate(smoothstep(thresholdLevel, thresholdLevel + thresholdRange, l));
79
77
  gl_FragColor = vec4(color * scale, 1.0);
80
78
  }
@@ -1,10 +1,12 @@
1
+ #include "core/packing"
2
+
1
3
  uniform sampler2D geometryBuffer;
2
4
 
3
5
  void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
4
- vec4 normalMetalnessRoughness = texture2D(geometryBuffer, uv);
6
+ vec4 normalMetalnessRoughness = texture(geometryBuffer, uv);
5
7
 
6
8
  #ifdef OUTPUT_NORMAL
7
- vec3 normal = unpackVec2ToNormal(texture2D(geometryBuffer, uv).xy);
9
+ vec3 normal = unpackVec2ToNormal(texture(geometryBuffer, uv).xy);
8
10
  outputColor = vec4(normal * 0.5 + 0.5, inputColor.a);
9
11
  #endif // OUTPUT_NORMAL
10
12
 
@@ -3,10 +3,7 @@ uniform sampler2D featuresBuffer;
3
3
  uniform float intensity;
4
4
 
5
5
  void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
6
- vec3 bloom = texture2D(bloomBuffer, uv).rgb;
7
- vec3 features = texture2D(featuresBuffer, uv).rgb;
8
- outputColor = vec4(
9
- inputColor.rgb + (bloom + features) * intensity,
10
- inputColor.a
11
- );
6
+ vec3 bloom = texture(bloomBuffer, uv).rgb;
7
+ vec3 features = texture(featuresBuffer, uv).rgb;
8
+ outputColor = vec4(inputColor.rgb + (bloom + features) * intensity, inputColor.a);
12
9
  }
@@ -14,7 +14,7 @@ in vec2 vAspectRatio;
14
14
 
15
15
  vec3 sampleGhost(const vec2 direction, const vec3 color, const float offset) {
16
16
  vec2 suv = clamp(1.0 - vUv + direction * offset, 0.0, 1.0);
17
- vec3 result = texture2D(inputBuffer, suv).rgb * color;
17
+ vec3 result = texture(inputBuffer, suv).rgb * color;
18
18
 
19
19
  // Falloff at the perimeter.
20
20
  float d = clamp(length(0.5 - suv) / (0.5 * SQRT_2), 0.0, 1.0);
@@ -48,9 +48,9 @@ vec3 sampleHalo(const float radius) {
48
48
  vec3 offset = vec3(texelSize.x * chromaticAberration) * vec3(-1.0, 0.0, 1.0);
49
49
  vec2 suv = fract(1.0 - vUv + direction * radius);
50
50
  vec3 result = vec3(
51
- texture2D(inputBuffer, suv + direction * offset.r).r,
52
- texture2D(inputBuffer, suv + direction * offset.g).g,
53
- texture2D(inputBuffer, suv + direction * offset.b).b
51
+ texture(inputBuffer, suv + direction * offset.r).r,
52
+ texture(inputBuffer, suv + direction * offset.g).g,
53
+ texture(inputBuffer, suv + direction * offset.b).b
54
54
  );
55
55
 
56
56
  // Falloff at the center and perimeter.
@@ -1,3 +1,7 @@
1
+ #include "core/depth"
2
+ #include "core/packing"
3
+ #include "core/transform"
4
+
1
5
  uniform highp sampler2D normalBuffer;
2
6
 
3
7
  uniform mat4 projectionMatrix;
@@ -20,16 +24,16 @@ vec3 reconstructNormal(const vec2 uv) {
20
24
 
21
25
  vec3 readNormal(const vec2 uv) {
22
26
  #ifdef OCT_ENCODED
23
- return unpackVec2ToNormal(texture2D(normalBuffer, uv).xy);
24
- #else
25
- return 2.0 * texture2D(normalBuffer, uv).xyz - 1.0;
27
+ return unpackVec2ToNormal(texture(normalBuffer, uv).xy);
28
+ #else // OCT_ENCODED
29
+ return 2.0 * texture(normalBuffer, uv).xyz - 1.0;
26
30
  #endif // OCT_ENCODED
27
31
  }
28
32
 
29
33
  void mainImage(const vec4 inputColor, const vec2 uv, out vec4 outputColor) {
30
34
  #ifdef RECONSTRUCT_FROM_DEPTH
31
35
  vec3 normal = reconstructNormal(uv);
32
- #else
36
+ #else // RECONSTRUCT_FROM_DEPTH
33
37
  vec3 normal = readNormal(uv);
34
38
  #endif // RECONSTRUCT_FROM_DEPTH
35
39
 
@@ -1,3 +1,5 @@
1
+ import { UniformMap } from '@takram/three-geospatial';
2
+ import { Uniform } from 'three';
1
3
  import { BlendFunction, Effect } from 'postprocessing';
2
4
 
3
5
  export interface DepthEffectOptions {
@@ -6,6 +8,10 @@ export interface DepthEffectOptions {
6
8
  near?: number;
7
9
  far?: number;
8
10
  }
11
+ export interface DepthEffectUniforms {
12
+ near: Uniform<number>;
13
+ far: Uniform<number>;
14
+ }
9
15
  export declare const depthEffectOptionsDefaults: {
10
16
  blendFunction: BlendFunction;
11
17
  useTurbo: false;
@@ -13,6 +19,7 @@ export declare const depthEffectOptionsDefaults: {
13
19
  far: number;
14
20
  };
15
21
  export declare class DepthEffect extends Effect {
22
+ uniforms: UniformMap<DepthEffectUniforms>;
16
23
  constructor(options?: DepthEffectOptions);
17
24
  get useTurbo(): boolean;
18
25
  set useTurbo(value: boolean);
@@ -1,4 +1,5 @@
1
- import { Texture } from 'three';
1
+ import { UniformMap } from '@takram/three-geospatial';
2
+ import { Uniform, Texture } from 'three';
2
3
  import { BlendFunction, Effect } from 'postprocessing';
3
4
 
4
5
  export type GeometryEffectOutput = 'normal' | 'pbr';
@@ -7,11 +8,15 @@ export interface GeometryEffectOptions {
7
8
  geometryBuffer?: Texture | null;
8
9
  output?: GeometryEffectOutput;
9
10
  }
11
+ export interface GeometryEffectUniforms {
12
+ geometryBuffer: Uniform<Texture | null>;
13
+ }
10
14
  export declare const geometryEffectOptionsDefaults: {
11
15
  blendFunction: BlendFunction;
12
16
  output: "normal";
13
17
  };
14
18
  export declare class GeometryEffect extends Effect {
19
+ uniforms: UniformMap<GeometryEffectUniforms>;
15
20
  constructor(options?: GeometryEffectOptions);
16
21
  get geometryBuffer(): Texture | null;
17
22
  set geometryBuffer(value: Texture | null);
@@ -1,6 +1,7 @@
1
1
  import { LensFlareFeaturesMaterial } from './LensFlareFeaturesMaterial';
2
2
  import { DownsampleThresholdMaterial } from './DownsampleThresholdMaterial';
3
- import { WebGLRenderTarget, TextureDataType, WebGLRenderer } from 'three';
3
+ import { UniformMap } from '@takram/three-geospatial';
4
+ import { Uniform, WebGLRenderTarget, Texture, TextureDataType, WebGLRenderer } from 'three';
4
5
  import { BlendFunction, Effect, KawaseBlurPass, MipmapBlurPass, Resolution, ShaderPass } from 'postprocessing';
5
6
 
6
7
  export interface LensFlareEffectOptions {
@@ -12,6 +13,11 @@ export interface LensFlareEffectOptions {
12
13
  resolutionY?: number;
13
14
  intensity?: number;
14
15
  }
16
+ export interface LensFlareEffectUniforms {
17
+ bloomBuffer: Uniform<Texture | null>;
18
+ featuresBuffer: Uniform<Texture | null>;
19
+ intensity: Uniform<number>;
20
+ }
15
21
  export declare const lensFlareEffectOptionsDefaults: {
16
22
  blendFunction: BlendFunction;
17
23
  resolutionScale: number;
@@ -20,6 +26,7 @@ export declare const lensFlareEffectOptionsDefaults: {
20
26
  intensity: number;
21
27
  };
22
28
  export declare class LensFlareEffect extends Effect {
29
+ uniforms: UniformMap<LensFlareEffectUniforms>;
23
30
  readonly resolution: Resolution;
24
31
  readonly renderTarget1: WebGLRenderTarget;
25
32
  readonly renderTarget2: WebGLRenderTarget;
@@ -33,7 +40,7 @@ export declare class LensFlareEffect extends Effect {
33
40
  private readonly onResolutionChange;
34
41
  initialize(renderer: WebGLRenderer, alpha: boolean, frameBufferType: TextureDataType): void;
35
42
  update(renderer: WebGLRenderer, inputBuffer: WebGLRenderTarget, deltaTime?: number): void;
36
- setSize(width: number, height: number): void;
43
+ setSize(baseWidth: number, baseHeight: number): void;
37
44
  get intensity(): number;
38
45
  set intensity(value: number);
39
46
  get thresholdLevel(): number;
@@ -1,4 +1,5 @@
1
- import { Camera, Texture, WebGLRenderer, WebGLRenderTarget } from 'three';
1
+ import { UniformMap } from '@takram/three-geospatial';
2
+ import { Matrix4, Uniform, Camera, Texture, WebGLRenderer, WebGLRenderTarget } from 'three';
2
3
  import { BlendFunction, Effect } from 'postprocessing';
3
4
 
4
5
  export interface NormalEffectOptions {
@@ -7,6 +8,11 @@ export interface NormalEffectOptions {
7
8
  octEncoded?: boolean;
8
9
  reconstructFromDepth?: boolean;
9
10
  }
11
+ export interface NormalEffectUniforms {
12
+ normalBuffer: Uniform<Texture | null>;
13
+ projectionMatrix: Uniform<Matrix4>;
14
+ inverseProjectionMatrix: Uniform<Matrix4>;
15
+ }
10
16
  export declare const normalEffectOptionsDefaults: {
11
17
  blendFunction: BlendFunction;
12
18
  octEncoded: false;
@@ -14,6 +20,7 @@ export declare const normalEffectOptionsDefaults: {
14
20
  };
15
21
  export declare class NormalEffect extends Effect {
16
22
  private camera;
23
+ uniforms: UniformMap<NormalEffectUniforms>;
17
24
  constructor(camera: Camera, options?: NormalEffectOptions);
18
25
  get mainCamera(): Camera;
19
26
  set mainCamera(value: Camera);