@margoengine/points 0.1.0 → 1.0.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.
@@ -101,15 +101,15 @@ export type PointShading = 'flat' | 'sphere';
101
101
  export interface PointsMaterialOptions extends BaseMaterialOptions {
102
102
  /** Optional screen-door coverage [lower,upper], both in [0,1]. Default full coverage. */
103
103
  ditherFade?: readonly [number, number];
104
- /** Point diameter: pixels, or world units when `sizeUnits` is 'world'. Per-point sizes multiply it. Default 4. */
104
+ /** Point diameter: CSS pixels, or world units when `sizeUnits` is 'world'. Per-point sizes multiply it. Default 4. */
105
105
  size?: number;
106
106
  /** 'pixels' keeps a constant screen size; 'world' attenuates with distance. Default 'pixels'. */
107
107
  sizeUnits?: 'pixels' | 'world';
108
108
  /** Alias: true is `sizeUnits: 'world'`, false is 'pixels'. */
109
109
  sizeAttenuation?: boolean;
110
- /** Clamp of the final diameter in pixels. Defaults 1 and 256. */
110
+ /** Clamp of the final diameter in CSS pixels. Defaults 1 and 256. */
111
111
  minPixelSize?: number;
112
- /** Upper clamp of the final diameter in pixels; must be at least `minPixelSize`. Default 256. */
112
+ /** Upper clamp of the final diameter in CSS pixels; must be at least `minPixelSize`. Default 256. */
113
113
  maxPixelSize?: number;
114
114
  /** 'square', or 'round' (an antialiased disc). Default 'square'. A `map` is sampled across either shape. */
115
115
  shape?: PointShape;
package/dist/octree.js CHANGED
@@ -1,4 +1,4 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
3
 
4
4
  import { n as e, t } from "./cloud-B4O_G-Df.js";
@@ -144,8 +144,8 @@ function c(e) {
144
144
  for (let n = e; n; n = n.parent) t += s(n);
145
145
  return t;
146
146
  }
147
- var l = (e, t) => e.length === t.length && e.every((e, n) => e === t[n]), u = 0, d = class i {coreRequirement=__margoCoreRequirement("0.1.0",import.meta.url);
148
- static attach(e, t, n, r) {__margoAssertCore(e,__margoCoreRequirement("0.1.0",import.meta.url));
147
+ var l = (e, t) => e.length === t.length && e.every((e, n) => e === t[n]), u = 0, d = class i {coreRequirement=__margoCoreRequirement("1.0.0",import.meta.url);
148
+ static attach(e, t, n, r) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
149
149
  let a = new i(t, n, r);
150
150
  return e.use(a), a;
151
151
  }
package/dist/pick.js CHANGED
@@ -1,7 +1,7 @@
1
- // @margo/core-built 0.1.0
1
+ // @margo/core-built 1.0.0
2
2
  import {coreRequirement as __margoCoreRequirement,assertCore as __margoAssertCore} from '@margoengine/core/extension';
3
3
 
4
- import { c as e, g as t } from "./shaders-Deu8H36P.js";
4
+ import { _ as e, c as t } from "./shaders-DCnbvb0-.js";
5
5
  import { MargoError as n } from "@margoengine/math/errors";
6
6
  //#region ../shared/pick-base.js
7
7
  function r(e, t, n) {
@@ -38,15 +38,15 @@ function i(e, t) {
38
38
  //#region src/pick.ts
39
39
  var a = 256, o = 2 ** 28, s = "\n@group(2) @binding(0) var<uniform> pickBase:vec4u;\nstruct SpherePick{@location(0) id:u32,@builtin(frag_depth) depth:f32}\n\n@fragment fn pick(i:VOut)->@location(0) u32{\n let s=surface(i);\n if(s.color.a<=0.0){discard;}\n return pickBase.x+i.slot;\n}\n@fragment fn pickSphere(i:VOut)->SpherePick{\n let s=surface(i);\n if(s.color.a<=0.0){discard;}\n return SpherePick(pickBase.x+i.slot,sphereDepth(i,s.nz));\n}";
40
40
  function c() {
41
- let t = "@location(3) @interpolate(flat) center:vec3f,", r = "out.center=world.xyz;";
42
- if (!e.includes(t) || !e.includes(r)) throw new n("unsupported", "Point picking needs the shader it was written for; update its edits with it");
43
- return e.replace(t, `${t}@location(5) @interpolate(flat) slot:u32,`).replace(r, `${r}out.slot=slot;`) + s;
41
+ let e = "@location(3) @interpolate(flat) center:vec3f,", r = "out.center=world.xyz;";
42
+ if (!t.includes(e) || !t.includes(r)) throw new n("unsupported", "Point picking needs the shader it was written for; update its edits with it");
43
+ return t.replace(e, `${e}@location(5) @interpolate(flat) slot:u32,`).replace(r, `${r}out.slot=slot;`) + s;
44
44
  }
45
- var l = class e {
46
- static attach(t, r) {__margoAssertCore(t,__margoCoreRequirement("0.1.0",import.meta.url));
45
+ var l = class t {
46
+ static attach(e, r) {__margoAssertCore(e,__margoCoreRequirement("1.0.0",import.meta.url));
47
47
  if (!r.engine) throw new n("state", "Attach PointsPlugin to the engine before PointPicking.attach");
48
- let i = new e(r);
49
- i.remove = t.addOverlay(i), r.watchers.add(i);
48
+ let i = new t(r);
49
+ i.remove = e.addOverlay(i), r.watchers.add(i);
50
50
  for (let e of r.pointClouds) i.added(e);
51
51
  return i;
52
52
  }
@@ -124,11 +124,11 @@ var l = class e {
124
124
  let t = this.standIns.get(e);
125
125
  t && (this.standIns.delete(e), this.owners.delete(t), t.dispose());
126
126
  }
127
- drawPick(e) {
127
+ drawPick(t) {
128
128
  let n = this.points, s = n.device, c = n.gpu;
129
129
  if (this.entries = [], !s || !c) return;
130
130
  let l;
131
- for (let t of n.pickViews.drawn()) t.rect.every((t, n) => t === e.rect[n]) && (l = t);
131
+ for (let e of n.pickViews.drawn()) e.rect.every((e, n) => e === t.rect[n]) && (l = e);
132
132
  if (!l) return;
133
133
  let u = [];
134
134
  for (let e of n.pointClouds) {
@@ -142,18 +142,18 @@ var l = class e {
142
142
  let d = this.resources(s, c), f = new Uint32Array(u.length * a / 4);
143
143
  r(s, d, f.byteLength);
144
144
  let p = this.frameData;
145
- t(p, this.view, e.camera, e.rect[2], e.rect[3], "rgba8unorm-srgb"), p.set(e.matrix, 0), p[16] = p[17] = 3, s.queue.writeBuffer(d.frame, 0, p);
146
- let m = i(e, d.frameGroup), h = 0, g = 0;
147
- for (let { cloud: t, list: r } of u) {
148
- if (h + t.count > o) break;
149
- let i = n.cloudGpu.get(t), c = t.material;
150
- m.setPipeline(this.pipeline(s, d, c.shading === "sphere", c.depthTest)), f[g * a / 4] = e.firstId + h, this.entries.push({
151
- cloud: t,
145
+ e(p, this.view, t.camera, t.rect[2], t.rect[3], "rgba8unorm-srgb"), p.set(t.matrix, 0), p[16] = p[17] = 3, s.queue.writeBuffer(d.frame, 0, p);
146
+ let m = i(t, d.frameGroup), h = 0, g = 0;
147
+ for (let { cloud: e, list: r } of u) {
148
+ if (h + e.count > o) break;
149
+ let i = n.cloudGpu.get(e), c = e.material;
150
+ m.setPipeline(this.pipeline(s, d, c.shading === "sphere", c.depthTest)), f[g * a / 4] = t.firstId + h, this.entries.push({
151
+ cloud: e,
152
152
  first: h,
153
153
  model: i.model
154
154
  }), m.setBindGroup(1, i.group), m.setBindGroup(2, d.baseGroup, [g * a]);
155
- for (let e = 0; e < r.length; e += 2) m.draw(4, r[e + 1], 0, t.blocks.starts[r[e]]);
156
- h += t.count, g++;
155
+ for (let t = 0; t < r.length; t += 2) m.draw(4, r[t + 1], 0, e.blocks.starts[r[t]]);
156
+ h += e.count, g++;
157
157
  }
158
158
  s.queue.writeBuffer(d.base, 0, f), m.end();
159
159
  }
package/dist/plugin.d.ts CHANGED
@@ -92,9 +92,9 @@ export declare class PointsPlugin implements EnginePlugin {
92
92
  private gpu?;
93
93
  private edl?;
94
94
  /**
95
- * @internal Target pixels per unit of the clouds' pixel sizes (`size` in 'pixels' units, `minPixelSize`,
96
- * `maxPixelSize`) for the frame being drawn. Unset, the sizes are pixels of the drawn target. An owner that sizes in CSS
97
- * pixels (sciviz) returns the target's pixels per CSS pixel, so the material keeps the caller's values.
95
+ * @internal Target pixels per CSS pixel for the frame being drawn, applied to pixel sizes (`size` in 'pixels' units,
96
+ * `minPixelSize`, `maxPixelSize`, pixel sprites). Unset, the drawn target's width over the canvas's CSS width. An
97
+ * owner that maps differently (sciviz, whose tiled exports draw no canvas pixels) returns its own.
98
98
  */
99
99
  pixelScale: ((context: GpuContext) => number) | undefined;
100
100
  private readonly frameData;
@@ -0,0 +1 @@
1
+ export { parseLAS } from "./las.js";
@@ -0,0 +1 @@
1
+ export { parseLAS } from './las.js';
package/dist/potree.js CHANGED
@@ -299,7 +299,7 @@ async function D(e, t, r, a) {
299
299
  return {
300
300
  ...R,
301
301
  fetchNode: async (t, i) => {
302
- let a = await n(r, `${P(t)}.${e ? "laz" : "las"}`, i), o = await (l ?? (await import("./las.js")).parseLAS)(a, {
302
+ let a = await n(r, `${P(t)}.${e ? "laz" : "las"}`, i), o = await (l ?? (await import("./potree-las-RC8sjbYU.js")).parseLAS)(a, {
303
303
  origin: v,
304
304
  laz: u,
305
305
  signal: i
@@ -31,7 +31,11 @@ function i(e, t) {
31
31
  }
32
32
  //#endregion
33
33
  //#region src/frame.ts
34
- function a(e, t, n, r, a, o) {
34
+ function a(e, t) {
35
+ let n = e?.clientWidth;
36
+ return n ? t / n : 1;
37
+ }
38
+ function o(e, t, n, r, a, o) {
35
39
  let s = n.matrix, c = !(s[3] || s[7] || s[11]);
36
40
  if (e.set(s, 0), e[16] = r, e[17] = a, c) e[18] = .5 * a * Math.hypot(s[1], s[5], s[9]);
37
41
  else {
@@ -44,7 +48,7 @@ function a(e, t, n, r, a, o) {
44
48
  }
45
49
  //#endregion
46
50
  //#region ../shared/fog.js
47
- var o = (e, t) => `
51
+ var s = (e, t) => `
48
52
  struct MargoFog {color:vec4f,params:vec4f,eye:vec4f}
49
53
  @group(${e}) @binding(${t}) var<uniform> margoFog:MargoFog;
50
54
  fn fogAmount(p:vec3f)->f32 {
@@ -52,29 +56,29 @@ fn fogAmount(p:vec3f)->f32 {
52
56
  let amount=select(clamp((d-q.x)/max(q.y-q.x,1e-6),0.0,1.0),1.0-exp(-q.z*q.z*d*d),q.z>0.0);
53
57
  return amount*exp(-q.w*max(p.y-margoFog.color.w,0.0));
54
58
  }
55
- `, s = (e, t, n, r) => {
59
+ `, c = (e, t, n, r) => {
56
60
  let i = e === void 0 ? t : e;
57
61
  if (typeof i != "number" || !Number.isFinite(i) || i < r) throw RangeError(`Fog ${n} is ${String(i)}; pass a finite number${r === 0 ? ", 0 or more" : ""}`);
58
62
  return i;
59
63
  };
60
- function c(e) {
64
+ function l(e) {
61
65
  if (e !== null && (typeof e != "object" || Array.isArray(e))) throw TypeError("Fog must be an object with Fog fields; pass an environment Fog, such an object or null");
62
- return e && l(e, [
66
+ return e && u(e, [
63
67
  0,
64
68
  0,
65
69
  0
66
70
  ], /* @__PURE__ */ new Float32Array(12)), e;
67
71
  }
68
- function l(e, t, i, a = !1) {
72
+ function u(e, t, i, a = !1) {
69
73
  let o = e.enabled ?? !0;
70
74
  if (typeof o != "boolean") throw TypeError(`Fog enabled is ${String(o)}; pass true or false`);
71
- let c = s(e.height, 0, "height", -Infinity), l = s(e.near, 1, "near", 0), u = s(e.far, 1e3, "far", 0), d = s(e.density, 0, "density", 0), f = s(e.heightFalloff, 0, "heightFalloff", 0);
75
+ let s = c(e.height, 0, "height", -Infinity), l = c(e.near, 1, "near", 0), u = c(e.far, 1e3, "far", 0), d = c(e.density, 0, "density", 0), f = c(e.heightFalloff, 0, "heightFalloff", 0);
72
76
  if (r(e.color ?? "#ffffff", i, 0), a) for (let e = 0; e < 3; e++) i[e] = n(i[e]);
73
- i[3] = c, i[4] = l, i[5] = u, i[6] = d, i[7] = f, o || (i.fill(0, 0, 8), i[4] = i[5] = 34028234663852886e22), i[8] = t[0], i[9] = t[1], i[10] = t[2], i[11] = 0;
77
+ i[3] = s, i[4] = l, i[5] = u, i[6] = d, i[7] = f, o || (i.fill(0, 0, 8), i[4] = i[5] = 34028234663852886e22), i[8] = t[0], i[9] = t[1], i[10] = t[2], i[11] = 0;
74
78
  }
75
79
  //#endregion
76
80
  //#region ../shared/pass.js
77
- var u = /* @__PURE__ */ Object.freeze({
81
+ var d = /* @__PURE__ */ Object.freeze({
78
82
  color: {
79
83
  srcFactor: "src-alpha",
80
84
  dstFactor: "one-minus-src-alpha",
@@ -86,11 +90,11 @@ var u = /* @__PURE__ */ Object.freeze({
86
90
  operation: "add"
87
91
  }
88
92
  });
89
- function d(e, t, n, r, i) {
93
+ function f(e, t, n, r, i) {
90
94
  let a = e.includes("var<private> margoCoverage:u32");
91
95
  return `\n@fragment fn transparent(${t}${a ? ",@builtin(sample_mask) margoMask:u32" : ""})->MargoTransparent {${a ? "margoCoverage=margoMask;" : ""}return margoTransparentAt(${n},${r},${i});}\n`;
92
96
  }
93
- function f() {
97
+ function p() {
94
98
  return {
95
99
  hook: void 0,
96
100
  released: void 0,
@@ -103,7 +107,7 @@ function f() {
103
107
  }
104
108
  //#endregion
105
109
  //#region ../shared/selection-mask-wgsl.js
106
- var p = (e, t) => `
110
+ var m = (e, t) => `
107
111
  @group(${e}) @binding(${t}) var<storage,read> margoMask:array<u32>;
108
112
  fn margoMaskPresent()->bool{return margoMask[3]==1u;}
109
113
  fn margoMaskOn(i:u32)->bool{return ((margoMask[4u+(i>>5u)]>>(i&31u))&1u)!=0u;}
@@ -115,7 +119,7 @@ fn margoMaskColor(c:vec4f,on:bool)->vec4f{
115
119
  else{s*=bitcast<f32>(margoMask[1]);}
116
120
  return vec4f(select(pow((s+0.055)/1.055,vec3f(2.4)),s/12.92,s<=vec3f(0.04045)),c.a);
117
121
  }
118
- `, m = {
122
+ `, h = {
119
123
  colors: 1,
120
124
  sizes: 2,
121
125
  world: 4,
@@ -126,16 +130,16 @@ fn margoMaskColor(c:vec4f,on:bool)->vec4f{
126
130
  srgbColors: 128,
127
131
  floatColors: 256,
128
132
  mask: 512
129
- }, h = `
133
+ }, g = `
130
134
  fn pointColor(p:u32)->vec4f{
131
135
  var c:vec4f;
132
- if(has(${m.floatColors}u)){
136
+ if(has(${h.floatColors}u)){
133
137
  let q=p*4u;
134
138
  c=vec4f(bitcast<f32>(colors[q]),bitcast<f32>(colors[q+1u]),bitcast<f32>(colors[q+2u]),bitcast<f32>(colors[q+3u]));
135
139
  } else {c=unpack4x8unorm(colors[p]);}
136
- return vec4f(select(c.rgb,toLinear(c.rgb),has(${m.srgbColors}u)),c.a);
140
+ return vec4f(select(c.rgb,toLinear(c.rgb),has(${h.srgbColors}u)),c.a);
137
141
  }
138
- `, g = "\nstruct Frame{viewProj:mat4x4f,viewport:vec4f,depth:vec4f,right:vec4f,up:vec4f,back:vec4f}\n@group(0) @binding(0) var<uniform> frame:Frame;\nfn toLinear(c:vec3f)->vec3f{return select(pow((c+0.055)/1.055,vec3f(2.4)),c/12.92,c<=vec3f(0.04045));}\n\nfn encode(c:vec4f)->vec4f{\n if(frame.viewport.w<0.5){return c;}\n let l=max(c.rgb,vec3f(0.0));\n return vec4f(select(1.055*pow(l,vec3f(1.0/2.4))-0.055,l*12.92,l<=vec3f(0.0031308)),c.a);\n}\n\nconst CORNERS=array<vec2f,4>(vec2f(-1.0,-1.0),vec2f(1.0,-1.0),vec2f(-1.0,1.0),vec2f(1.0,1.0));\n", _ = g + e + `
142
+ `, _ = "\nstruct Frame{viewProj:mat4x4f,viewport:vec4f,depth:vec4f,right:vec4f,up:vec4f,back:vec4f}\n@group(0) @binding(0) var<uniform> frame:Frame;\nfn toLinear(c:vec3f)->vec3f{return select(pow((c+0.055)/1.055,vec3f(2.4)),c/12.92,c<=vec3f(0.04045));}\n\nfn encode(c:vec4f)->vec4f{\n if(frame.viewport.w<0.5){return c;}\n let l=max(c.rgb,vec3f(0.0));\n return vec4f(select(1.055*pow(l,vec3f(1.0/2.4))-0.055,l*12.92,l<=vec3f(0.0031308)),c.a);\n}\n\nconst CORNERS=array<vec2f,4>(vec2f(-1.0,-1.0),vec2f(1.0,-1.0),vec2f(-1.0,1.0),vec2f(1.0,1.0));\n", v = _ + e + `
139
143
  struct Cloud{model:mat4x4f,color:vec4f,size:vec4f,flags:vec4u,pad:vec4f,planes:array<vec4f,6>}
140
144
  @group(1) @binding(0) var<uniform> cloud:Cloud;
141
145
  @group(1) @binding(1) var<storage,read> positions:array<f32>;
@@ -144,7 +148,7 @@ struct Cloud{model:mat4x4f,color:vec4f,size:vec4f,flags:vec4u,pad:vec4f,planes:a
144
148
  @group(1) @binding(4) var<storage,read> order:array<u32>;
145
149
  @group(1) @binding(5) var map:texture_2d<f32>;
146
150
  @group(1) @binding(6) var mapSampler:sampler;
147
- ${p(1, 7)}
151
+ ${m(1, 7)}
148
152
  struct VOut{
149
153
  @builtin(position) clip:vec4f,
150
154
  @location(0) color:vec4f,
@@ -153,27 +157,27 @@ struct VOut{
153
157
  @location(3) @interpolate(flat) center:vec3f,
154
158
  }
155
159
  fn has(bit:u32)->bool{return (cloud.flags.x&bit)!=0u;}
156
- ${h}
160
+ ${g}
157
161
  @vertex fn vertex(@builtin(vertex_index) vi:u32,@builtin(instance_index) slot:u32)->VOut{
158
162
  var out:VOut;
159
163
  var p=slot;
160
- if(!has(${m.direct}u)){p=order[slot];}
164
+ if(!has(${h.direct}u)){p=order[slot];}
161
165
  let world=cloud.model*vec4f(positions[p*3u],positions[p*3u+1u],positions[p*3u+2u],1.0);
162
166
  var clip=frame.viewProj*world;
163
167
  if(!(clip.w>1e-6)){out.clip=vec4f(0.0,0.0,-1.0,1.0);return out;}
164
168
  var size=cloud.size.x;
165
- if(has(${m.sizes}u)){size*=sizes[p];}
166
- var px=select(size,size*frame.viewport.z/clip.w,has(${m.world}u));
169
+ if(has(${h.sizes}u)){size*=sizes[p];}
170
+ var px=select(size,size*frame.viewport.z/clip.w,has(${h.world}u));
167
171
  px=clamp(px,cloud.size.y,cloud.size.z);
168
172
  let radius=0.5*px;
169
173
 
170
- let extent=radius+select(0.0,1.0,has(${m.round}u)||has(${m.sphere}u));
174
+ let extent=radius+select(0.0,1.0,has(${h.round}u)||has(${h.sphere}u));
171
175
  let corner=CORNERS[vi];
172
176
  clip=vec4f(clip.xy+corner*extent*2.0/frame.viewport.xy*clip.w,clip.zw);
173
177
  var color=cloud.color;
174
- if(has(${m.colors}u)){color*=pointColor(p);}
178
+ if(has(${h.colors}u)){color*=pointColor(p);}
175
179
 
176
- if(has(${m.mask}u)){let on=margoMaskOn(p);if(margoMaskHidden(on)){out.clip=vec4f(0.0,0.0,-1.0,1.0);return out;}color=margoMaskColor(color,on);}
180
+ if(has(${h.mask}u)){let on=margoMaskOn(p);if(margoMaskHidden(on)){out.clip=vec4f(0.0,0.0,-1.0,1.0);return out;}color=margoMaskColor(color,on);}
177
181
  out.clip=clip;out.color=color;out.quad=corner*extent;
178
182
  out.info=vec4f(radius,select(clip.w,1.0+(1.0-clip.z)/frame.depth.y,frame.depth.w>0.5),radius*clip.w/frame.viewport.z,0.0);
179
183
  out.center=world.xyz;
@@ -190,15 +194,15 @@ fn surface(i:VOut)->Surface{
190
194
  let dims=vec2f(textureDimensions(map));
191
195
  let texel=textureSampleLevel(map,mapSampler,clamp(uv,vec2f(0.0),vec2f(1.0)),max(log2(max(dims.x,dims.y)/(2.0*r)),0.0));
192
196
  var color=i.color;
193
- if(has(${m.map}u)){color*=texel;}
197
+ if(has(${h.map}u)){color*=texel;}
194
198
  if(color.a<cloud.size.w){discard;}
195
199
  var s:Surface;s.nz=1.0;
196
- if(has(${m.round}u)||has(${m.sphere}u)){
200
+ if(has(${h.round}u)||has(${h.sphere}u)){
197
201
  let d=length(i.quad);
198
202
  let coverage=clamp(r+0.5-d,0.0,1.0);
199
203
  if(coverage<=0.0){discard;}
200
204
  color.a*=coverage;
201
- if(has(${m.sphere}u)){
205
+ if(has(${h.sphere}u)){
202
206
  let n2=i.quad/r;
203
207
  s.nz=sqrt(max(1.0-dot(n2,n2),0.0));
204
208
  let n=frame.right.xyz*n2.x+frame.up.xyz*n2.y+frame.back.xyz*s.nz;
@@ -211,7 +215,7 @@ fn surface(i:VOut)->Surface{
211
215
  let clipCount=cloud.flags.y&0xffffu;
212
216
  if(clipCount>0u){
213
217
  let wp=i.center+(frame.right.xyz*i.quad.x+frame.up.xyz*i.quad.y)*(i.info.z/r)
214
- +frame.back.xyz*select(0.0,s.nz*i.info.z,has(${m.sphere}u));
218
+ +frame.back.xyz*select(0.0,s.nz*i.info.z,has(${h.sphere}u));
215
219
  var clipBehind=0u;
216
220
  for(var p=0u;p<clipCount;p++){if(dot(cloud.planes[p].xyz,wp)+cloud.planes[p].w<0.0){clipBehind++;}}
217
221
  if(select(clipBehind>0u,clipBehind==clipCount,(cloud.flags.y&65536u)!=0u)){discard;}
@@ -234,24 +238,24 @@ struct SphereEdlOut{@location(0) color:vec4f,@location(1) edl:f32,@builtin(frag_
234
238
  let s=surface(i);
235
239
  return SphereEdlOut(s.color,max(i.info.y-i.info.z*s.nz,frame.depth.z),sphereDepth(i,s.nz));
236
240
  }
237
- `, v = g + "\nstruct Batch{model:mat4x4f,color:vec4f,params:vec4f,planes:array<vec4f,6>}\n@group(1) @binding(0) var<uniform> batch:Batch;\n@group(1) @binding(1) var<storage,read> sprites:array<vec4f>;\n@group(1) @binding(2) var map:texture_2d<f32>;\n@group(1) @binding(3) var mapSampler:sampler;\nstruct VOut{@builtin(position) clip:vec4f,@location(0) color:vec4f,@location(1) uv:vec2f,@location(2) world:vec3f}\n\n@vertex fn vertex(@builtin(vertex_index) vi:u32,@builtin(instance_index) ii:u32)->VOut{\n var out:VOut;\n let a=sprites[ii*4u];let b=sprites[ii*4u+1u];let rect=sprites[ii*4u+2u];let tint=sprites[ii*4u+3u];\n let q=CORNERS[vi]*0.5+0.5;\n let angle=a.w+batch.params.x;\n let local=(q-b.zw)*b.xy;\n let offset=vec2f(local.x*cos(angle)-local.y*sin(angle),local.x*sin(angle)+local.y*cos(angle));\n var world=batch.model*vec4f(a.xyz,1.0);\n var clip:vec4f;\n\n var wp=world.xyz;\n if(batch.params.z>0.5){\n clip=frame.viewProj*world;\n clip=vec4f(clip.xy+offset*2.0/frame.viewport.xy*clip.w,clip.zw);\n } else {\n wp=world.xyz+frame.right.xyz*offset.x+frame.up.xyz*offset.y;\n clip=frame.viewProj*vec4f(wp,1.0);\n }\n out.clip=clip;out.world=wp;\n out.uv=mix(rect.xy,rect.zw,vec2f(q.x,1.0-q.y));\n out.color=batch.color*tint;\n return out;\n}\n@fragment fn fragment(i:VOut)->@location(0) vec4f{\n\n let dims=vec2f(textureDimensions(map));\n let dx=dpdx(i.uv)*dims;let dy=dpdy(i.uv)*dims;\n let texel=textureSampleLevel(map,mapSampler,i.uv,max(0.5*log2(max(max(dot(dx,dx),dot(dy,dy)),1e-12)),0.0));\n let color=i.color*texel;\n if(color.a<batch.params.y||color.a<=0.0){discard;}\n\n let clipCount=u32(abs(batch.params.w));var clipBehind=0u;\n for(var p=0u;p<clipCount;p++){if(dot(batch.planes[p].xyz,i.world)+batch.planes[p].w<0.0){clipBehind++;}}\n if(clipCount>0u&&select(clipBehind>0u,clipBehind==clipCount,batch.params.w<0.0)){discard;}\n return encode(color);\n}\n", y = {
241
+ `, y = _ + "\nstruct Batch{model:mat4x4f,color:vec4f,params:vec4f,planes:array<vec4f,6>}\n@group(1) @binding(0) var<uniform> batch:Batch;\n@group(1) @binding(1) var<storage,read> sprites:array<vec4f>;\n@group(1) @binding(2) var map:texture_2d<f32>;\n@group(1) @binding(3) var mapSampler:sampler;\nstruct VOut{@builtin(position) clip:vec4f,@location(0) color:vec4f,@location(1) uv:vec2f,@location(2) world:vec3f}\n\n@vertex fn vertex(@builtin(vertex_index) vi:u32,@builtin(instance_index) ii:u32)->VOut{\n var out:VOut;\n let a=sprites[ii*4u];let b=sprites[ii*4u+1u];let rect=sprites[ii*4u+2u];let tint=sprites[ii*4u+3u];\n let q=CORNERS[vi]*0.5+0.5;\n let angle=a.w+batch.params.x;\n let local=(q-b.zw)*b.xy;\n let offset=vec2f(local.x*cos(angle)-local.y*sin(angle),local.x*sin(angle)+local.y*cos(angle));\n var world=batch.model*vec4f(a.xyz,1.0);\n var clip:vec4f;\n\n var wp=world.xyz;\n if(batch.params.z>0.0){\n clip=frame.viewProj*world;\n clip=vec4f(clip.xy+offset*batch.params.z*2.0/frame.viewport.xy*clip.w,clip.zw);\n } else {\n wp=world.xyz+frame.right.xyz*offset.x+frame.up.xyz*offset.y;\n clip=frame.viewProj*vec4f(wp,1.0);\n }\n out.clip=clip;out.world=wp;\n out.uv=mix(rect.xy,rect.zw,vec2f(q.x,1.0-q.y));\n out.color=batch.color*tint;\n return out;\n}\n@fragment fn fragment(i:VOut)->@location(0) vec4f{\n\n let dims=vec2f(textureDimensions(map));\n let dx=dpdx(i.uv)*dims;let dy=dpdy(i.uv)*dims;\n let texel=textureSampleLevel(map,mapSampler,i.uv,max(0.5*log2(max(max(dot(dx,dx),dot(dy,dy)),1e-12)),0.0));\n let color=i.color*texel;\n if(color.a<batch.params.y||color.a<=0.0){discard;}\n\n let clipCount=u32(abs(batch.params.w));var clipBehind=0u;\n for(var p=0u;p<clipCount;p++){if(dot(batch.planes[p].xyz,i.world)+batch.planes[p].w<0.0){clipBehind++;}}\n if(clipCount>0u&&select(clipBehind>0u,clipBehind==clipCount,batch.params.w<0.0)){discard;}\n return encode(color);\n}\n", b = {
238
242
  point: [
239
243
  ["@location(2) @interpolate(flat) info:vec4f,", "@location(2) @interpolate(flat) info:vec4f,@location(4) @interpolate(flat) fog:f32,"],
240
244
  ["out.clip=clip;out.color=color;out.quad=corner*extent;", "out.clip=clip;out.color=color;out.quad=corner*extent;out.fog=fogAmount(world.xyz);"],
241
245
  ["s.color=encode(color);", "s.color=encode(fogged(color,i.fog));"]
242
246
  ],
243
247
  sprite: [["return encode(color);", "return encode(fogged(color,fogAmount(i.world)));"]]
244
- }, b = "@fragment fn fragment(i:VOut)->@location(0) vec4f{";
245
- function x(e, n, r) {
246
- let i = r === void 0 ? e === "point" ? _ : v : T(e, r);
248
+ }, x = "@fragment fn fragment(i:VOut)->@location(0) vec4f{";
249
+ function S(e, n, r) {
250
+ let i = r === void 0 ? e === "point" ? v : y : E(e, r);
247
251
  if (e === "sprite") {
248
- if (i.split(b).length !== 2) throw new t("unsupported", "Sprite transparency needs the shader it was written for; update its edit");
249
- i = i.replace(b, "fn margoShade(i:VOut)->vec4f{");
252
+ if (i.split(x).length !== 2) throw new t("unsupported", "Sprite transparency needs the shader it was written for; update its edit");
253
+ i = i.replace(x, "fn margoShade(i:VOut)->vec4f{");
250
254
  }
251
- return n + i + "fn margoViewDepth(p:vec4f)->f32{return select(1.0/p.w,frame.right.w+(1.0-p.z)/frame.depth.y,frame.depth.w>0.5);}\n" + d(n, "i:VOut", e === "point" ? "surface(i).color" : "margoShade(i)", "i.clip", "margoViewDepth(i.clip)");
255
+ return n + i + "fn margoViewDepth(p:vec4f)->f32{return select(1.0/p.w,frame.right.w+(1.0-p.z)/frame.depth.y,frame.depth.w>0.5);}\n" + f(n, "i:VOut", e === "point" ? "surface(i).color" : "margoShade(i)", "i.clip", "margoViewDepth(i.clip)");
252
256
  }
253
- var S = "\nfn packDepth(d:f32)->vec4f{\n let b=bitcast<u32>(d);\n return vec4f(f32(b&255u),f32((b>>8u)&255u),f32((b>>16u)&255u),f32(b>>24u))/255.0;\n}\nfn unpackDepth(c:vec4f)->f32{\n let b=vec4u(round(c*255.0));\n return bitcast<f32>(b.x|(b.y<<8u)|(b.z<<16u)|(b.w<<24u));\n}\n";
254
- function C(e, n) {
257
+ var C = "\nfn packDepth(d:f32)->vec4f{\n let b=bitcast<u32>(d);\n return vec4f(f32(b&255u),f32((b>>8u)&255u),f32((b>>16u)&255u),f32(b>>24u))/255.0;\n}\nfn unpackDepth(c:vec4f)->f32{\n let b=vec4u(round(c*255.0));\n return bitcast<f32>(b.x|(b.y<<8u)|(b.z<<16u)|(b.w<<24u));\n}\n";
258
+ function w(e, n) {
255
259
  let r = e;
256
260
  for (let [e, i] of n) {
257
261
  if (r.split(e).length !== 2) throw new t("unsupported", `Points needs the shaders it was written for; no ${e} to edit.`);
@@ -259,20 +263,20 @@ function C(e, n) {
259
263
  }
260
264
  return r;
261
265
  }
262
- var w = (e) => C(e, [
266
+ var T = (e) => w(e, [
263
267
  ["struct EdlOut{@location(0) color:vec4f,@location(1) depth:f32}", "struct EdlOut{@location(0) color:vec4f,@location(1) depth:vec4f}"],
264
268
  ["@location(1) edl:f32,@builtin(frag_depth)", "@location(1) edl:vec4f,@builtin(frag_depth)"],
265
269
  ["return EdlOut(s.color,i.info.y);", "return EdlOut(s.color,packDepth(i.info.y));"],
266
270
  ["return SphereEdlOut(s.color,max(i.info.y-i.info.z*s.nz,frame.depth.z),sphereDepth(i,s.nz));", "return SphereEdlOut(s.color,packDepth(max(i.info.y-i.info.z*s.nz,frame.depth.z)),sphereDepth(i,s.nz));"]
267
- ]) + S;
268
- function T(e, n) {
269
- let r = e === "point" ? _ : v;
270
- for (let [n, i] of y[e]) {
271
+ ]) + C;
272
+ function E(e, n) {
273
+ let r = e === "point" ? v : y;
274
+ for (let [n, i] of b[e]) {
271
275
  if (r.split(n).length !== 2) throw new t("unsupported", "Points fog needs the shaders it was written for; update the fog edits with them");
272
276
  r = r.replace(n, i);
273
277
  }
274
- return r + o(2, 0) + (n ? "fn fogged(c:vec4f,a:f32)->vec4f{return vec4f(c.rgb*(1.0-a),c.a);}" : "fn fogged(c:vec4f,a:f32)->vec4f{return vec4f(mix(c.rgb,margoFog.color.rgb,a),c.a);}");
278
+ return r + s(2, 0) + (n ? "fn fogged(c:vec4f,a:f32)->vec4f{return vec4f(c.rgb*(1.0-a),c.a);}" : "fn fogged(c:vec4f,a:f32)->vec4f{return vec4f(mix(c.rgb,margoFog.color.rgb,a),c.a);}");
275
279
  }
276
- var E = "\n@group(0) @binding(0) var depths:texture_2d<f32>;\n@group(0) @binding(1) var<uniform> params:vec4f;\n\nconst RING=array<vec2f,8>(vec2f(1.0,0.0),vec2f(0.70710678,0.70710678),vec2f(0.0,1.0),vec2f(-0.70710678,0.70710678),\n vec2f(-1.0,0.0),vec2f(-0.70710678,-0.70710678),vec2f(0.0,-1.0),vec2f(0.70710678,-0.70710678));\n\n\n\nconst GAIN=32.0;\n@vertex fn vertex(@builtin(vertex_index) i:u32)->@builtin(position) vec4f{\n\n return vec4f(f32(i&1u)*4.0-1.0,f32(i>>1u)*4.0-1.0,0.0,1.0);\n}\n\nfn nearer(c:f32,n:f32)->f32{\n if(n<=0.0){return 0.0;}\n if(params.z>0.0){return max(0.0,(c-n)*params.z);}\n return max(0.0,log2(c)-log2(n));\n}\n@fragment fn fragment(@builtin(position) position:vec4f)->@location(0) vec4f{\n let p=vec2i(position.xy);\n let c=textureLoad(depths,p,0).r;\n if(c<=0.0){discard;}\n let last=vec2i(textureDimensions(depths))-1;\n var sum=0.0;\n for(var k=0;k<8;k++){\n let q=clamp(p+vec2i(round(RING[k]*params.y)),vec2i(0),last);\n sum+=nearer(c,textureLoad(depths,q,0).r);\n }\n let shade=exp(-GAIN*params.x*sum/8.0);\n return vec4f(shade,shade,shade,1.0);\n}\n";
280
+ var D = "\n@group(0) @binding(0) var depths:texture_2d<f32>;\n@group(0) @binding(1) var<uniform> params:vec4f;\n\nconst RING=array<vec2f,8>(vec2f(1.0,0.0),vec2f(0.70710678,0.70710678),vec2f(0.0,1.0),vec2f(-0.70710678,0.70710678),\n vec2f(-1.0,0.0),vec2f(-0.70710678,-0.70710678),vec2f(0.0,-1.0),vec2f(0.70710678,-0.70710678));\n\n\n\nconst GAIN=32.0;\n@vertex fn vertex(@builtin(vertex_index) i:u32)->@builtin(position) vec4f{\n\n return vec4f(f32(i&1u)*4.0-1.0,f32(i>>1u)*4.0-1.0,0.0,1.0);\n}\n\nfn nearer(c:f32,n:f32)->f32{\n if(n<=0.0){return 0.0;}\n if(params.z>0.0){return max(0.0,(c-n)*params.z);}\n return max(0.0,log2(c)-log2(n));\n}\n@fragment fn fragment(@builtin(position) position:vec4f)->@location(0) vec4f{\n let p=vec2i(position.xy);\n let c=textureLoad(depths,p,0).r;\n if(c<=0.0){discard;}\n let last=vec2i(textureDimensions(depths))-1;\n var sum=0.0;\n for(var k=0;k<8;k++){\n let q=clamp(p+vec2i(round(RING[k]*params.y)),vec2i(0),last);\n sum+=nearer(c,textureLoad(depths,q,0).r);\n }\n let shade=exp(-GAIN*params.x*sum/8.0);\n return vec4f(shade,shade,shade,1.0);\n}\n";
277
281
  //#endregion
278
- export { g as a, _ as c, u as d, f, a as g, l as h, T as i, v as l, o as m, S as n, w as o, c as p, E as r, h as s, m as t, x as u };
282
+ export { o as _, _ as a, v as c, d, p as f, a as g, u as h, E as i, y as l, s as m, C as n, T as o, l as p, D as r, g as s, h as t, S as u };
@@ -1,33 +1,33 @@
1
- import type { ColorInput } from '@margoengine/math/color';
2
-
3
- /**
4
- * Fog as `@margoengine/environment`'s `Fog` exposes it: pass that Fog, or any object with these fields. Read every
5
- * frame, so changing the Fog changes the fog at once. Missing fields take Fog's defaults. A negative or non-finite
6
- * distance, density or falloff (or a non-finite height) throws a RangeError, a malformed colour a TypeError or
7
- * RangeError, a non-boolean `enabled` a TypeError.
8
- */
9
- export interface FogLike {
10
- /** Fog colour: hex is sRGB, `[r, g, b]` linear. Default '#ffffff'. */
11
- readonly color?: ColorInput;
12
- /** Linear fog start distance from the camera. Default 1. */
13
- readonly near?: number;
14
- /** Linear fog end distance, where fog is full. Default 1000. */
15
- readonly far?: number;
16
- /** Above 0 selects exponential-squared fog `1 - exp(-(density * distance)^2)`. Default 0. */
17
- readonly density?: number;
18
- /** Height fog: fog thins by `exp(-heightFalloff * (y - height))` above world height `height`. Default 0 (off). */
19
- readonly heightFalloff?: number;
20
- /** World height below which fog is at full strength. Default 0. */
21
- readonly height?: number;
22
- /** False mixes in no fog; switching never recompiles. Default true. */
23
- readonly enabled?: boolean;
24
- }
25
-
26
- /** Bytes of the fog uniform: colour and height, near/far/density/falloff, camera position. */
27
- export const FOG_BYTES: 48;
28
- /** WGSL: the fog uniform at `@group(group) @binding(binding)` and `fogAmount(world position)`, 0 (clear) to 1. */
29
- export function fogWgsl(group: number, binding: number): string;
30
- /** Throws when `fog` is neither null nor an object; `setFog` calls it so a wrong argument fails where it is passed. */
31
- export function checkFog(fog: FogLike | null): FogLike | null;
32
- /** Validates `fog` and writes the 12-float fog uniform into `out` (colour sRGB-encoded with `encode`). */
33
- export function writeFog(fog: FogLike, eye: ArrayLike<number>, out: Float32Array, encode?: boolean): void;
1
+ import type { ColorInput } from '@margoengine/math/color';
2
+
3
+ /**
4
+ * Fog as `@margoengine/environment`'s `Fog` exposes it: pass that Fog, or any object with these fields. Read every
5
+ * frame, so changing the Fog changes the fog at once. Missing fields take Fog's defaults. A negative or non-finite
6
+ * distance, density or falloff (or a non-finite height) throws a RangeError, a malformed colour a TypeError or
7
+ * RangeError, a non-boolean `enabled` a TypeError.
8
+ */
9
+ export interface FogLike {
10
+ /** Fog colour: hex is sRGB, `[r, g, b]` linear. Default '#ffffff'. */
11
+ readonly color?: ColorInput;
12
+ /** Linear fog start distance from the camera. Default 1. */
13
+ readonly near?: number;
14
+ /** Linear fog end distance, where fog is full. Default 1000. */
15
+ readonly far?: number;
16
+ /** Above 0 selects exponential-squared fog `1 - exp(-(density * distance)^2)`. Default 0. */
17
+ readonly density?: number;
18
+ /** Height fog: fog thins by `exp(-heightFalloff * (y - height))` above world height `height`. Default 0 (off). */
19
+ readonly heightFalloff?: number;
20
+ /** World height below which fog is at full strength. Default 0. */
21
+ readonly height?: number;
22
+ /** False mixes in no fog; switching never recompiles. Default true. */
23
+ readonly enabled?: boolean;
24
+ }
25
+
26
+ /** Bytes of the fog uniform: colour and height, near/far/density/falloff, camera position. */
27
+ export const FOG_BYTES: 48;
28
+ /** WGSL: the fog uniform at `@group(group) @binding(binding)` and `fogAmount(world position)`, 0 (clear) to 1. */
29
+ export function fogWgsl(group: number, binding: number): string;
30
+ /** Throws when `fog` is neither null nor an object; `setFog` calls it so a wrong argument fails where it is passed. */
31
+ export function checkFog(fog: FogLike | null): FogLike | null;
32
+ /** Validates `fog` and writes the 12-float fog uniform into `out` (colour sRGB-encoded with `encode`). */
33
+ export function writeFog(fog: FogLike, eye: ArrayLike<number>, out: Float32Array, encode?: boolean): void;
@@ -1,53 +1,53 @@
1
- /** A reusable pass descriptor drawing over the frame: colour load/store, depth and stencil read only. */
2
- export function overlayPass(): GPURenderPassDescriptor & {
3
- colorAttachments: [GPURenderPassColorAttachment];
4
- depthStencilAttachment: GPURenderPassDepthStencilAttachment;
5
- };
6
- /** {@link overlayPass} that also loads and stores depth. */
7
- export function overlayDepthPass(): GPURenderPassDescriptor & {
8
- colorAttachments: [GPURenderPassColorAttachment];
9
- depthStencilAttachment: GPURenderPassDepthStencilAttachment;
10
- };
11
- /** Straight (non-premultiplied) alpha blending. */
12
- export const alphaBlend: GPUBlendState;
13
- /** Straight alpha blending that leaves the target's alpha channel unchanged: precipitation and other overlays drawn into a frame. */
14
- export const overlayBlend: GPUBlendState;
15
-
16
- /** `mesh` when it is null or a core mesh handle (checked live); else a TypeError. */
17
- export function attachableMesh<M extends { check(): void } | null>(mesh: M): M;
18
- /**
19
- * What an order-independent pass offers an effect that is no PBR surface (particles, splats, points), in place of
20
- * gltf/pbr's transparency hook. Same contract, but `surface` declares `fn margoTransparentAt(color:vec4f,clip:vec4f,
21
- * depth:f32)->MargoTransparent`: `clip` is the fragment's position builtin, `depth` its view depth.
22
- */
23
- export interface SurfaceTransparency {
24
- /** Module-scope WGSL: `struct MargoTransparent` (one output per target), `margoTransparentAt` and its bindings in `group`. */
25
- surface(group: number): string;
26
- /** Layout of those bindings, for an effect with explicit pipeline layouts. */
27
- readonly layout: readonly GPUBindGroupLayoutEntry[];
28
- /** Entries for those bindings. */
29
- bindings(): GPUBindGroupEntry[];
30
- /** True: declarations hold `override margoKind:u32`, 0 normal, 1 additive; additive surfaces may draw here. */
31
- readonly blends?: boolean;
32
- /** Colour targets of the transparent pass, in `MargoTransparent` location order. */
33
- readonly targets: readonly GPUColorTargetState[];
34
- /** This frame's transparent pass, begun on the first draw and ended by the owner. */
35
- begin(): GPURenderPassEncoder;
36
- }
37
- /** The fragment entry `transparent` of an effect under a transparency hook: `inputs` are its parameters, the rest WGSL expressions. */
38
- export function surfaceEntry(declarations: string, inputs: string, color: string, clip: string, depth: string): string;
39
- /** Holds an effect's transparency hook: `set` takes it and `released`, and returns the remover. */
40
- export function transparencySlot(): {
41
- hook?: SurfaceTransparency;
42
- released?: () => void;
43
- set(hook: SurfaceTransparency, released?: () => void): () => void;
44
- };
45
- /** `hook`'s pass with `pipeline` set, `group` at group 0 and the hook's bindings at group 1, for an effect with an auto layout. */
46
- export function surfacePass(
47
- device: GPUDevice,
48
- hook: SurfaceTransparency,
49
- pipeline: GPURenderPipeline,
50
- group: GPUBindGroup,
51
- ): GPURenderPassEncoder;
52
- /** The WGSL `make(group)` builds for bind group `group`, made once per group and kept in `cache`. */
53
- export function groupCode(cache: Map<number, string>, group: number, make: (group: number) => string): string;
1
+ /** A reusable pass descriptor drawing over the frame: colour load/store, depth and stencil read only. */
2
+ export function overlayPass(): GPURenderPassDescriptor & {
3
+ colorAttachments: [GPURenderPassColorAttachment];
4
+ depthStencilAttachment: GPURenderPassDepthStencilAttachment;
5
+ };
6
+ /** {@link overlayPass} that also loads and stores depth. */
7
+ export function overlayDepthPass(): GPURenderPassDescriptor & {
8
+ colorAttachments: [GPURenderPassColorAttachment];
9
+ depthStencilAttachment: GPURenderPassDepthStencilAttachment;
10
+ };
11
+ /** Straight (non-premultiplied) alpha blending. */
12
+ export const alphaBlend: GPUBlendState;
13
+ /** Straight alpha blending that leaves the target's alpha channel unchanged: precipitation and other overlays drawn into a frame. */
14
+ export const overlayBlend: GPUBlendState;
15
+
16
+ /** `mesh` when it is null or a core mesh handle (checked live); else a TypeError. */
17
+ export function attachableMesh<M extends { check(): void } | null>(mesh: M): M;
18
+ /**
19
+ * What an order-independent pass offers an effect that is no PBR surface (particles, splats, points), in place of
20
+ * gltf/pbr's transparency hook. Same contract, but `surface` declares `fn margoTransparentAt(color:vec4f,clip:vec4f,
21
+ * depth:f32)->MargoTransparent`: `clip` is the fragment's position builtin, `depth` its view depth.
22
+ */
23
+ export interface SurfaceTransparency {
24
+ /** Module-scope WGSL: `struct MargoTransparent` (one output per target), `margoTransparentAt` and its bindings in `group`. */
25
+ surface(group: number): string;
26
+ /** Layout of those bindings, for an effect with explicit pipeline layouts. */
27
+ readonly layout: readonly GPUBindGroupLayoutEntry[];
28
+ /** Entries for those bindings. */
29
+ bindings(): GPUBindGroupEntry[];
30
+ /** True: declarations hold `override margoKind:u32`, 0 normal, 1 additive; additive surfaces may draw here. */
31
+ readonly blends?: boolean;
32
+ /** Colour targets of the transparent pass, in `MargoTransparent` location order. */
33
+ readonly targets: readonly GPUColorTargetState[];
34
+ /** This frame's transparent pass, begun on the first draw and ended by the owner. */
35
+ begin(): GPURenderPassEncoder;
36
+ }
37
+ /** The fragment entry `transparent` of an effect under a transparency hook: `inputs` are its parameters, the rest WGSL expressions. */
38
+ export function surfaceEntry(declarations: string, inputs: string, color: string, clip: string, depth: string): string;
39
+ /** Holds an effect's transparency hook: `set` takes it and `released`, and returns the remover. */
40
+ export function transparencySlot(): {
41
+ hook?: SurfaceTransparency;
42
+ released?: () => void;
43
+ set(hook: SurfaceTransparency, released?: () => void): () => void;
44
+ };
45
+ /** `hook`'s pass with `pipeline` set, `group` at group 0 and the hook's bindings at group 1, for an effect with an auto layout. */
46
+ export function surfacePass(
47
+ device: GPUDevice,
48
+ hook: SurfaceTransparency,
49
+ pipeline: GPURenderPipeline,
50
+ group: GPUBindGroup,
51
+ ): GPURenderPassEncoder;
52
+ /** The WGSL `make(group)` builds for bind group `group`, made once per group and kept in `cache`. */
53
+ export function groupCode(cache: Map<number, string>, group: number, make: (group: number) => string): string;