shaderpad 1.0.0-beta.21 → 1.0.0-beta.23

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/README.md CHANGED
@@ -297,14 +297,15 @@ ShaderPad supports plugins to add additional functionality. Plugins are imported
297
297
 
298
298
  The `helpers` plugin provides convenience functions and constants. See [helpers.glsl](./src/plugins/helpers.glsl) for the implementation.
299
299
 
300
- ```typescript
300
+ ````typescript
301
301
  import ShaderPad from 'shaderpad';
302
302
  import helpers from 'shaderpad/plugins/helpers';
303
303
 
304
304
  const shader = new ShaderPad(fragmentShaderSrc, {
305
305
  plugins: [helpers()],
306
306
  });
307
- ```
307
+
308
+ **Note:** The `helpers` plugin automatically injects the `u_resolution` uniform into your shader. Do not declare it yourself.
308
309
 
309
310
  #### save
310
311
 
@@ -1,7 +1,22 @@
1
- "use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var p=(e,t)=>{for(var i in t)o(e,i,{get:t[i],enumerable:!0})},m=(e,t,i,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of h(t))!s.call(e,r)&&r!==i&&o(e,r,{get:()=>t[r],enumerable:!(f=a(t,r))||f.enumerable});return e};var l=e=>m(o({},"__esModule",{value:!0}),e);var g={};p(g,{default:()=>x});module.exports=l(g);var n=`float historyZ(highp sampler2DArray tex, int frameOffset, int framesAgo) {
1
+ "use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var x=(t,e)=>{for(var i in e)o(t,i,{get:e[i],enumerable:!0})},f=(t,e,i,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of c(e))!s.call(t,r)&&r!==i&&o(t,r,{get:()=>e[r],enumerable:!(u=a(e,r))||u.enumerable});return t};var l=t=>f(o({},"__esModule",{value:!0}),t);var p={};x(p,{default:()=>h});module.exports=l(p);var n=`uniform vec2 u_resolution;
2
+
3
+ // Apply aspect ratio correction (object-fit: contain)
4
+ vec2 fitContain(vec2 uv, vec2 textureSize) {
5
+ vec2 scale = u_resolution.xy * textureSize.yx / (u_resolution.yx * textureSize.xy);
6
+ return (uv - 0.5) * min(scale, vec2(1.0)) + 0.5;
7
+ }
8
+
9
+ // Apply aspect ratio correction (object-fit: cover)
10
+ vec2 fitCover(vec2 uv, vec2 textureSize) {
11
+ vec2 scale = u_resolution.xy * textureSize.yx / (u_resolution.yx * textureSize.xy);
12
+ return (uv - 0.5) * max(scale, vec2(1.0)) + 0.5;
13
+ }
14
+
15
+ // Get the array index for a history texture
16
+ float historyZ(highp sampler2DArray tex, int frameOffset, int framesAgo) {
2
17
  int historyDepth = textureSize(tex, 0).z;
3
18
  int z = (historyDepth + frameOffset - framesAgo) % historyDepth;
4
19
  return float(z);
5
20
  }
6
- `;function d(){return function(e,t){t.injectGLSL(n)}}var x=d;
21
+ `;function y(){return function(t,e){e.injectGLSL(n)}}var h=y;
7
22
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/helpers.ts","../../src/plugins/helpers.glsl"],"sourcesContent":["import ShaderPad, { PluginContext } from '../index';\nimport helpersGLSL from './helpers.glsl';\n\nfunction helpers() {\n\treturn function (_shader: ShaderPad, context: PluginContext) {\n\t\tcontext.injectGLSL(helpersGLSL);\n\t};\n}\n\nexport default helpers;\n","float historyZ(highp sampler2DArray tex, int frameOffset, int framesAgo) {\n\tint historyDepth = textureSize(tex, 0).z;\n\tint z = (historyDepth + frameOffset - framesAgo) % historyDepth;\n\treturn float(z);\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAA;AAAA;AAAA;AAAA;AAAA;EDGA,SAASC,GAAU,CAClB,OAAO,SAAUC,EAAoBC,EAAwB,CAC5DA,EAAQ,WAAWC,CAAW,CAC/B,CACD,CAEA,IAAOA,EAAQH","names":["helpers_exports","__export","helpers_default","__toCommonJS","helpers_default","helpers","_shader","context","helpers_default"]}
1
+ {"version":3,"sources":["../../src/plugins/helpers.ts","../../src/plugins/helpers.glsl"],"sourcesContent":["import ShaderPad, { PluginContext } from '../index';\nimport helpersGLSL from './helpers.glsl';\n\nfunction helpers() {\n\treturn function (_shader: ShaderPad, context: PluginContext) {\n\t\tcontext.injectGLSL(helpersGLSL);\n\t};\n}\n\nexport default helpers;\n","uniform vec2 u_resolution;\n\n// Apply aspect ratio correction (object-fit: contain)\nvec2 fitContain(vec2 uv, vec2 textureSize) {\n\tvec2 scale = u_resolution.xy * textureSize.yx / (u_resolution.yx * textureSize.xy);\n\treturn (uv - 0.5) * min(scale, vec2(1.0)) + 0.5;\n}\n\n// Apply aspect ratio correction (object-fit: cover)\nvec2 fitCover(vec2 uv, vec2 textureSize) {\n\tvec2 scale = u_resolution.xy * textureSize.yx / (u_resolution.yx * textureSize.xy);\n\treturn (uv - 0.5) * max(scale, vec2(1.0)) + 0.5;\n}\n\n// Get the array index for a history texture\nfloat historyZ(highp sampler2DArray tex, int frameOffset, int framesAgo) {\n\tint historyDepth = textureSize(tex, 0).z;\n\tint z = (historyDepth + frameOffset - framesAgo) % historyDepth;\n\treturn float(z);\n}\n"],"mappings":"yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GCAA,IAAAI,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EDGA,SAASC,GAAU,CAClB,OAAO,SAAUC,EAAoBC,EAAwB,CAC5DA,EAAQ,WAAWC,CAAW,CAC/B,CACD,CAEA,IAAOA,EAAQH","names":["helpers_exports","__export","helpers_default","__toCommonJS","helpers_default","helpers","_shader","context","helpers_default"]}
@@ -1,7 +1,22 @@
1
- var t=`float historyZ(highp sampler2DArray tex, int frameOffset, int framesAgo) {
1
+ var e=`uniform vec2 u_resolution;
2
+
3
+ // Apply aspect ratio correction (object-fit: contain)
4
+ vec2 fitContain(vec2 uv, vec2 textureSize) {
5
+ vec2 scale = u_resolution.xy * textureSize.yx / (u_resolution.yx * textureSize.xy);
6
+ return (uv - 0.5) * min(scale, vec2(1.0)) + 0.5;
7
+ }
8
+
9
+ // Apply aspect ratio correction (object-fit: cover)
10
+ vec2 fitCover(vec2 uv, vec2 textureSize) {
11
+ vec2 scale = u_resolution.xy * textureSize.yx / (u_resolution.yx * textureSize.xy);
12
+ return (uv - 0.5) * max(scale, vec2(1.0)) + 0.5;
13
+ }
14
+
15
+ // Get the array index for a history texture
16
+ float historyZ(highp sampler2DArray tex, int frameOffset, int framesAgo) {
2
17
  int historyDepth = textureSize(tex, 0).z;
3
18
  int z = (historyDepth + frameOffset - framesAgo) % historyDepth;
4
19
  return float(z);
5
20
  }
6
- `;function i(){return function(o,e){e.injectGLSL(t)}}var a=i;export{a as default};
21
+ `;function i(){return function(o,t){t.injectGLSL(e)}}var a=i;export{a as default};
7
22
  //# sourceMappingURL=helpers.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/plugins/helpers.glsl","../../src/plugins/helpers.ts"],"sourcesContent":["float historyZ(highp sampler2DArray tex, int frameOffset, int framesAgo) {\n\tint historyDepth = textureSize(tex, 0).z;\n\tint z = (historyDepth + frameOffset - framesAgo) % historyDepth;\n\treturn float(z);\n}\n","import ShaderPad, { PluginContext } from '../index';\nimport helpersGLSL from './helpers.glsl';\n\nfunction helpers() {\n\treturn function (_shader: ShaderPad, context: PluginContext) {\n\t\tcontext.injectGLSL(helpersGLSL);\n\t};\n}\n\nexport default helpers;\n"],"mappings":"AAAA,IAAAA,EAAA;AAAA;AAAA;AAAA;AAAA;ECGA,SAASC,GAAU,CAClB,OAAO,SAAUC,EAAoBC,EAAwB,CAC5DA,EAAQ,WAAWC,CAAW,CAC/B,CACD,CAEA,IAAOA,EAAQH","names":["helpers_default","helpers","_shader","context","helpers_default"]}
1
+ {"version":3,"sources":["../../src/plugins/helpers.glsl","../../src/plugins/helpers.ts"],"sourcesContent":["uniform vec2 u_resolution;\n\n// Apply aspect ratio correction (object-fit: contain)\nvec2 fitContain(vec2 uv, vec2 textureSize) {\n\tvec2 scale = u_resolution.xy * textureSize.yx / (u_resolution.yx * textureSize.xy);\n\treturn (uv - 0.5) * min(scale, vec2(1.0)) + 0.5;\n}\n\n// Apply aspect ratio correction (object-fit: cover)\nvec2 fitCover(vec2 uv, vec2 textureSize) {\n\tvec2 scale = u_resolution.xy * textureSize.yx / (u_resolution.yx * textureSize.xy);\n\treturn (uv - 0.5) * max(scale, vec2(1.0)) + 0.5;\n}\n\n// Get the array index for a history texture\nfloat historyZ(highp sampler2DArray tex, int frameOffset, int framesAgo) {\n\tint historyDepth = textureSize(tex, 0).z;\n\tint z = (historyDepth + frameOffset - framesAgo) % historyDepth;\n\treturn float(z);\n}\n","import ShaderPad, { PluginContext } from '../index';\nimport helpersGLSL from './helpers.glsl';\n\nfunction helpers() {\n\treturn function (_shader: ShaderPad, context: PluginContext) {\n\t\tcontext.injectGLSL(helpersGLSL);\n\t};\n}\n\nexport default helpers;\n"],"mappings":"AAAA,IAAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;ECGA,SAASC,GAAU,CAClB,OAAO,SAAUC,EAAoBC,EAAwB,CAC5DA,EAAQ,WAAWC,CAAW,CAC/B,CACD,CAEA,IAAOA,EAAQH","names":["helpers_default","helpers","_shader","context","helpers_default"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shaderpad",
3
- "version": "1.0.0-beta.21",
3
+ "version": "1.0.0-beta.23",
4
4
  "description": "A lightweight, dependency-free library to reduce boilerplate when writing fragment shaders.",
5
5
  "keywords": [
6
6
  "shaders",