@react-three/postprocessing 2.14.10 → 2.14.12

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.
@@ -1,14 +1,13 @@
1
- import React from 'react';
1
+ /// <reference types="react" />
2
2
  import { ChromaticAberrationEffect } from 'postprocessing';
3
- import { ReactThreeFiber } from '@react-three/fiber';
4
- export type ChromaticAberrationProps = ConstructorParameters<typeof ChromaticAberrationEffect>[0] & Partial<{
5
- offset: ReactThreeFiber.Vector2;
6
- }>;
7
- export declare const ChromaticAberration: React.ForwardRefExoticComponent<{
3
+ import { type EffectProps } from '../util';
4
+ export type ChromaticAberrationProps = EffectProps<typeof ChromaticAberrationEffect>;
5
+ export declare const ChromaticAberration: import("react").ForwardRefExoticComponent<Omit<import("@react-three/fiber").ExtendedColors<import("@react-three/fiber").Overwrite<Partial<ChromaticAberrationEffect>, import("@react-three/fiber").NodeProps<ChromaticAberrationEffect, typeof ChromaticAberrationEffect>>> & {
8
6
  blendFunction?: import("postprocessing").BlendFunction | undefined;
9
7
  offset?: import("three").Vector2 | undefined;
10
8
  radialModulation: boolean;
11
9
  modulationOffset: number;
12
- } & Partial<{
13
- offset: ReactThreeFiber.Vector2;
14
- }> & React.RefAttributes<ChromaticAberrationEffect>>;
10
+ } & {
11
+ blendFunction?: import("postprocessing").BlendFunction | undefined;
12
+ opacity?: number | undefined;
13
+ }, "ref"> & import("react").RefAttributes<typeof ChromaticAberrationEffect>>;
@@ -8,7 +8,7 @@ export type OutlineProps = ConstructorParameters<typeof OutlineEffect>[2] & Part
8
8
  }>;
9
9
  export declare const Outline: import("react").ForwardRefExoticComponent<{
10
10
  blendFunction?: import("postprocessing").BlendFunction | undefined;
11
- patternTexture?: number | undefined;
11
+ patternTexture?: import("three").Texture | undefined;
12
12
  patternScale?: number | undefined;
13
13
  edgeStrength?: number | undefined;
14
14
  pulseSpeed?: number | undefined;
package/dist/index.cjs CHANGED
@@ -328,11 +328,7 @@ const Bloom = wrapEffect(postprocessing.BloomEffect, {
328
328
  blendFunction: postprocessing.BlendFunction.ADD
329
329
  });
330
330
  const BrightnessContrast = wrapEffect(postprocessing.BrightnessContrastEffect);
331
- const ChromaticAberration = React.forwardRef(function ChromaticAberration2(props, ref) {
332
- const offset = useVector2(props, "offset");
333
- const effect = React.useMemo(() => new postprocessing.ChromaticAberrationEffect({ ...props, offset }), [offset, props]);
334
- return /* @__PURE__ */ jsxRuntime.jsx("primitive", { ref, object: effect, dispose: null });
335
- });
331
+ const ChromaticAberration = wrapEffect(postprocessing.ChromaticAberrationEffect);
336
332
  const ColorAverage = React.forwardRef(function ColorAverage2({ blendFunction = postprocessing.BlendFunction.NORMAL }, ref) {
337
333
  const effect = React.useMemo(() => new postprocessing.ColorAverageEffect(blendFunction), [blendFunction]);
338
334
  return /* @__PURE__ */ jsxRuntime.jsx("primitive", { ref, object: effect, dispose: null });
@@ -930,7 +926,7 @@ void main() {
930
926
  #define SAMPLES 16
931
927
  #define FSAMPLES 16.0
932
928
  uniform sampler2D sceneDiffuse;
933
- uniform sampler2D sceneNormal;
929
+ uniform highp sampler2D sceneNormal;
934
930
  uniform highp sampler2D sceneDepth;
935
931
  uniform mat4 projectionMatrixInv;
936
932
  uniform mat4 viewMatrixInv;
@@ -980,7 +976,7 @@ uniform sampler2D bluenoise;
980
976
  float b = farZ * nearZ / (nearZ - farZ);
981
977
  float linDepth = a + b / depth;
982
978
  vec4 clipVec = vec4(uv, linDepth, 1.0) * 2.0 - 1.0;
983
- vec4 wpos = viewMatrixInv * projectionMatrixInv * clipVec;
979
+ vec4 wpos = projectionMatrixInv * clipVec;
984
980
  return wpos.xyz / wpos.w;
985
981
  }
986
982
  vec3 getWorldPos(float depth, vec2 coord) {
@@ -991,7 +987,7 @@ uniform sampler2D bluenoise;
991
987
  vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);
992
988
  vec4 viewSpacePosition = projectionMatrixInv * clipSpacePosition;
993
989
  // Perspective division
994
- vec4 worldSpacePosition = viewMatrixInv * viewSpacePosition;
990
+ vec4 worldSpacePosition = viewSpacePosition;
995
991
  worldSpacePosition.xyz /= worldSpacePosition.w;
996
992
  return worldSpacePosition.xyz;
997
993
  }
@@ -1070,7 +1066,7 @@ void main() {
1070
1066
  ;
1071
1067
  float moveAmt = samplesR[int(mod(i + noise.a * FSAMPLES, FSAMPLES))];
1072
1068
  vec3 samplePos = worldPos + radiusToUse * moveAmt * sampleDirection;
1073
- vec4 offset = projViewMat * vec4(samplePos, 1.0);
1069
+ vec4 offset = projMat * vec4(samplePos, 1.0);
1074
1070
  offset.xyz /= offset.w;
1075
1071
  offset.xyz = offset.xyz * 0.5 + 0.5;
1076
1072
  float sampleDepth = textureLod(sceneDepth, offset.xy, 0.0).x;
@@ -1206,8 +1202,8 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
1206
1202
  /* glsl */
1207
1203
  `
1208
1204
  uniform sampler2D sceneDiffuse;
1209
- uniform sampler2D sceneDepth;
1210
- uniform sampler2D downsampledDepth;
1205
+ uniform highp sampler2D sceneDepth;
1206
+ uniform highp sampler2D downsampledDepth;
1211
1207
  uniform sampler2D tDiffuse;
1212
1208
  uniform sampler2D blueNoise;
1213
1209
  uniform vec2 resolution;
@@ -1260,7 +1256,7 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
1260
1256
  float b = farZ * nearZ / (nearZ - farZ);
1261
1257
  float linDepth = a + b / depth;
1262
1258
  vec4 clipVec = vec4(uv, linDepth, 1.0) * 2.0 - 1.0;
1263
- vec4 wpos = viewMatrixInv * projectionMatrixInv * clipVec;
1259
+ vec4 wpos = projectionMatrixInv * clipVec;
1264
1260
  return wpos.xyz / wpos.w;
1265
1261
  }
1266
1262
  vec3 getWorldPos(float depth, vec2 coord) {
@@ -1273,7 +1269,7 @@ const $12b21d24d1192a04$export$a815acccbd2c9a49 = {
1273
1269
  vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);
1274
1270
  vec4 viewSpacePosition = projectionMatrixInv * clipSpacePosition;
1275
1271
  // Perspective division
1276
- vec4 worldSpacePosition = viewMatrixInv * viewSpacePosition;
1272
+ vec4 worldSpacePosition = viewSpacePosition;
1277
1273
  worldSpacePosition.xyz /= worldSpacePosition.w;
1278
1274
  return worldSpacePosition.xyz;
1279
1275
  }
@@ -1528,7 +1524,7 @@ const $e52378cd0f5a973d$export$57856b59f317262e = {
1528
1524
  float b = farZ * nearZ / (nearZ - farZ);
1529
1525
  float linDepth = a + b / depth;
1530
1526
  vec4 clipVec = vec4(uv, linDepth, 1.0) * 2.0 - 1.0;
1531
- vec4 wpos = viewMatrixInv * projectionMatrixInv * clipVec;
1527
+ vec4 wpos = projectionMatrixInv * clipVec;
1532
1528
  return wpos.xyz / wpos.w;
1533
1529
  }
1534
1530
  vec3 getWorldPos(float depth, vec2 coord) {
@@ -1540,7 +1536,7 @@ const $e52378cd0f5a973d$export$57856b59f317262e = {
1540
1536
  vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);
1541
1537
  vec4 viewSpacePosition = projectionMatrixInv * clipSpacePosition;
1542
1538
  // Perspective division
1543
- vec4 worldSpacePosition = viewMatrixInv * viewSpacePosition;
1539
+ vec4 worldSpacePosition = viewSpacePosition;
1544
1540
  worldSpacePosition.xyz /= worldSpacePosition.w;
1545
1541
  return worldSpacePosition.xyz;
1546
1542
  }
@@ -1557,6 +1553,10 @@ const $e52378cd0f5a973d$export$57856b59f317262e = {
1557
1553
  vec3 normal = data.rgb * 2.0 - 1.0;
1558
1554
  float count = 1.0;
1559
1555
  float d = texture2D(sceneDepth, vUv).x;
1556
+ if (d == 1.0) {
1557
+ gl_FragColor = data;
1558
+ return;
1559
+ }
1560
1560
  vec3 worldPos = getWorldPos(d, vUv);
1561
1561
  float size = radius;
1562
1562
  float angle;
@@ -1589,7 +1589,7 @@ const $e52378cd0f5a973d$export$57856b59f317262e = {
1589
1589
  float dSample = texture2D(sceneDepth, uv + offset).x;
1590
1590
  vec3 worldPosSample = getWorldPos(dSample, uv + offset);
1591
1591
  float tangentPlaneDist = abs(dot(worldPos - worldPosSample, normal));
1592
- float rangeCheck = exp(-1.0 * tangentPlaneDist * (1.0 / distanceFalloffToUse)) * max(dot(normal, normalSample), 0.0) * (1.0 - abs(occSample - baseOcc));
1592
+ float rangeCheck = dSample == 1.0 ? 0.0 :exp(-1.0 * tangentPlaneDist * (1.0 / distanceFalloffToUse)) * max(dot(normal, normalSample), 0.0) * (1.0 - abs(occSample - baseOcc));
1593
1593
  occlusion += occSample * rangeCheck;
1594
1594
  count += rangeCheck;
1595
1595
  }
@@ -1635,7 +1635,7 @@ const $26aca173e0984d99$export$1efdf491687cd442 = {
1635
1635
  fragmentShader: (
1636
1636
  /* glsl */
1637
1637
  `
1638
- uniform sampler2D sceneDepth;
1638
+ uniform highp sampler2D sceneDepth;
1639
1639
  uniform vec2 resolution;
1640
1640
  uniform float near;
1641
1641
  uniform float far;
@@ -1654,7 +1654,7 @@ const $26aca173e0984d99$export$1efdf491687cd442 = {
1654
1654
  float b = farZ * nearZ / (nearZ - farZ);
1655
1655
  float linDepth = a + b / depth;
1656
1656
  vec4 clipVec = vec4(uv, linDepth, 1.0) * 2.0 - 1.0;
1657
- vec4 wpos = viewMatrixInv * projectionMatrixInv * clipVec;
1657
+ vec4 wpos = projectionMatrixInv * clipVec;
1658
1658
  return wpos.xyz / wpos.w;
1659
1659
  }
1660
1660
  vec3 getWorldPos(float depth, vec2 coord) {
@@ -1665,7 +1665,7 @@ const $26aca173e0984d99$export$1efdf491687cd442 = {
1665
1665
  vec4 clipSpacePosition = vec4(coord * 2.0 - 1.0, z, 1.0);
1666
1666
  vec4 viewSpacePosition = projectionMatrixInv * clipSpacePosition;
1667
1667
  // Perspective division
1668
- vec4 worldSpacePosition = viewMatrixInv * viewSpacePosition;
1668
+ vec4 worldSpacePosition = viewSpacePosition;
1669
1669
  worldSpacePosition.xyz /= worldSpacePosition.w;
1670
1670
  return worldSpacePosition.xyz;
1671
1671
  }