liquid-gl 2.1.0 → 2.1.1

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 (3) hide show
  1. package/README.md +1 -1
  2. package/liquidGL.js +15 -7
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  <a href="https://liquidgl.naughtyduk.com"><img src="https://raw.githubusercontent.com/naughtyduk/liquidGL/main/assets/liquidGL-npm-preview.gif" alt="liquidGL" width="100%" height="auto"/></a>
4
4
 
5
- ### v2.1.0
5
+ ### v2.1.1
6
6
 
7
7
  > [!NOTE]
8
8
  > `liquidGL` is free to use for both non-commercial and commercial purposes.
package/liquidGL.js CHANGED
@@ -2064,6 +2064,8 @@ const liquidGL = (() => {
2064
2064
  vec2 texel = 1.0 / u_textureResolution;
2065
2065
  vec4 refrCol;
2066
2066
 
2067
+ vec2 chroma = offset * u_aberration;
2068
+
2067
2069
  if (u_frost > 0.0) {
2068
2070
  float radius = u_frost * 4.0;
2069
2071
  vec4 sum = vec4(0.0);
@@ -2072,8 +2074,15 @@ const liquidGL = (() => {
2072
2074
  for (int i = 0; i < SAMPLES; i++) {
2073
2075
  float angle = random(v_uv + float(i)) * 6.283185;
2074
2076
  float dist = sqrt(random(v_uv - float(i))) * radius;
2075
- vec2 offset = vec2(cos(angle), sin(angle)) * texel * dist;
2076
- sum += texture2D(u_tex, sampleUV + offset);
2077
+ vec2 foff = vec2(cos(angle), sin(angle)) * texel * dist;
2078
+ if (u_aberration > 0.0) {
2079
+ sum.r += texture2D(u_tex, sampleUV + foff - chroma).r;
2080
+ sum.g += texture2D(u_tex, sampleUV + foff).g;
2081
+ sum.b += texture2D(u_tex, sampleUV + foff + chroma).b;
2082
+ sum.a += texture2D(u_tex, sampleUV + foff).a;
2083
+ } else {
2084
+ sum += texture2D(u_tex, sampleUV + foff);
2085
+ }
2077
2086
  }
2078
2087
  refrCol = sum / float(SAMPLES);
2079
2088
  } else {
@@ -2083,12 +2092,11 @@ const liquidGL = (() => {
2083
2092
  refrCol += texture2D(u_tex, sampleUV + vec2(0.0, texel.y));
2084
2093
  refrCol += texture2D(u_tex, sampleUV + vec2(0.0, -texel.y));
2085
2094
  refrCol /= 5.0;
2086
- }
2087
2095
 
2088
- if (u_aberration > 0.0) {
2089
- vec2 chroma = offset * u_aberration;
2090
- refrCol.r = texture2D(u_tex, sampleUV - chroma).r;
2091
- refrCol.b = texture2D(u_tex, sampleUV + chroma).b;
2096
+ if (u_aberration > 0.0) {
2097
+ refrCol.r = texture2D(u_tex, sampleUV - chroma).r;
2098
+ refrCol.b = texture2D(u_tex, sampleUV + chroma).b;
2099
+ }
2092
2100
  }
2093
2101
 
2094
2102
  if (refrCol.a < 0.1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "liquid-gl",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Liquid Glass - Powered by WebGL.",
5
5
  "type": "module",
6
6
  "main": "./liquidGL.js",