@casmo/tree.js 0.3.0 → 0.4.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.
Files changed (36) hide show
  1. package/README.md +186 -1
  2. package/dist/effects/effects.d.ts +51 -6
  3. package/dist/effects/effects.d.ts.map +1 -1
  4. package/dist/effects/glow.d.ts +5 -0
  5. package/dist/effects/glow.d.ts.map +1 -1
  6. package/dist/effects/grade.d.ts +3 -0
  7. package/dist/effects/grade.d.ts.map +1 -1
  8. package/dist/effects/highlight.d.ts +35 -0
  9. package/dist/effects/highlight.d.ts.map +1 -0
  10. package/dist/effects/index.d.ts +5 -1
  11. package/dist/effects/index.d.ts.map +1 -1
  12. package/dist/effects/inner-lines.d.ts +39 -0
  13. package/dist/effects/inner-lines.d.ts.map +1 -0
  14. package/dist/effects/live.d.ts +12 -0
  15. package/dist/effects/live.d.ts.map +1 -0
  16. package/dist/effects/mask.d.ts +23 -11
  17. package/dist/effects/mask.d.ts.map +1 -1
  18. package/dist/effects/outline.d.ts +12 -0
  19. package/dist/effects/outline.d.ts.map +1 -1
  20. package/dist/effects/pass.d.ts +27 -0
  21. package/dist/effects/pass.d.ts.map +1 -0
  22. package/dist/effects/screen.d.ts +31 -0
  23. package/dist/effects/screen.d.ts.map +1 -0
  24. package/dist/effects/suggested.d.ts +5 -0
  25. package/dist/effects/suggested.d.ts.map +1 -1
  26. package/dist/effects/tree-id.d.ts +50 -0
  27. package/dist/effects/tree-id.d.ts.map +1 -0
  28. package/dist/effects.js +772 -57
  29. package/dist/effects.js.map +1 -1
  30. package/dist/forest/Forest.d.ts +2 -0
  31. package/dist/forest/Forest.d.ts.map +1 -1
  32. package/dist/{forest-ChEaWJrf.js → forest-lg61rhKM.js} +5 -1
  33. package/dist/{forest-ChEaWJrf.js.map → forest-lg61rhKM.js.map} +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/react.js +1 -1
  36. package/package.json +1 -1
package/README.md CHANGED
@@ -532,6 +532,19 @@ renderer.setAnimationLoop(() => effects.render()); // instead of renderer.render
532
532
  effects.set({ outline: { color: '#203018', thickness: 2 }, grade: { saturation: 1.1 } }); // or null = none
533
533
  ```
534
534
 
535
+ Each Style has a suggested combination (`SUGGESTED_TREE_EFFECTS`): `low-poly` has a colour grade, ink
536
+ [Inner Lines](#inner-lines) and a dark outline that is also drawn [between overlapping trees](#outline-between-overlapping-trees);
537
+ `stylized` has a warm grade, a leaf glow, soft Inner Lines and a soft outline; `realistic` only a gentle
538
+ grade and a faint leaf glow (no ink).
539
+
540
+ > **Changed in this release:** the `low-poly` and `stylized` suggestions now include Inner Lines, and
541
+ > `low-poly` also `outline.betweenTrees`. Apps that use either suggestion get a changed look (ink lines
542
+ > inside the crown, and for low-poly between overlapping trees) and extra channels in the scene pass:
543
+ > the `normal` channel for both, and for low-poly also the [Tree ID](#tree-id) channel (a scene pass with
544
+ > the Tree ID renders without MSAA). In your own pipeline, request those channels from `treeEffectsPass`
545
+ > (see below). Use your own settings, e.g. `{ ...SUGGESTED_TREE_EFFECTS.stylized, innerLines: undefined }`,
546
+ > to keep the old look.
547
+
535
548
  Pass `selection: [tree]` to outline only some trees. In your own pipeline, the effects are nodes that
536
549
  compose with your other effects:
537
550
 
@@ -541,7 +554,8 @@ import { float, screenUV, vec4 } from 'three/tsl';
541
554
  import { applyTreeEffects, SUGGESTED_TREE_EFFECTS, treeEffectsPass } from '@casmo/tree.js/effects';
542
555
 
543
556
  const pipeline = new THREE.RenderPipeline(renderer);
544
- const input = treeEffectsPass(scene, camera); // { pass, color, mask }
557
+ // The low-poly suggestion's Inner Lines need the normal channel, its betweenTrees outline the Tree ID.
558
+ const input = treeEffectsPass(scene, camera, null, { normal: true, treeId: true }); // { pass, color, mask, ... }
545
559
  const trees = applyTreeEffects(input, SUGGESTED_TREE_EFFECTS['low-poly']); // or treeOutline / leafGlow / treeColorGrade
546
560
  const vignette = float(1).sub(screenUV.sub(0.5).length().mul(0.9).pow(2)); // your own effect on top
547
561
  pipeline.outputNode = vec4(trees.rgb.mul(vignette), 1);
@@ -551,6 +565,177 @@ renderer.setAnimationLoop(() => pipeline.render());
551
565
  To add the tree mask to a scene pass you already have, merge `treeMaskMRT()` into its MRT and read the
552
566
  mask with `scenePass.getTextureNode(TREE_MASK)`.
553
567
 
568
+ ### Tree ID
569
+
570
+ To tell trees apart on screen (GPU picking, your own per-tree effects), add the opt-in **Tree ID**
571
+ channel: an extra MRT target in which every tree writes its own number. Each Tree has one ID for all
572
+ its parts (wood, leaves, Fruit), and each tree of a Forest has its own. Nothing else changes: the tree
573
+ mask, its format and the `treeEffectsPass` default stay as they are.
574
+
575
+ ```ts
576
+ import { mrt, output, pass } from 'three/tsl';
577
+ import { readTreeId, TREE_ID, treeFromId, treeIdMRT, treeIdTexture, treeMaskMRT } from '@casmo/tree.js/effects';
578
+
579
+ const scenePass = pass(scene, camera);
580
+ scenePass.setMRT(mrt({ output }).merge(treeMaskMRT()).merge(treeIdMRT()));
581
+ treeIdTexture(scenePass); // makes the target one 32-bit unsigned integer per pixel
582
+ const ids = scenePass.getTextureNode(TREE_ID); // read it with exact texel loads (ids.load(...)), never filtered
583
+
584
+ renderer.domElement.addEventListener('click', async (event) => {
585
+ const id = await readTreeId(renderer, scenePass, event.offsetX, event.offsetY); // CSS pixels
586
+ const tree = treeFromId(id); // the Tree or ForestTree, or undefined (0 = no tree)
587
+ });
588
+ ```
589
+
590
+ - **Encoding:** `r32uint`, 0 = not a tree. A Forest Variant reserves a block of IDs the size of its
591
+ capacity, and its trees write block start + instance index.
592
+ - **No MSAA:** an integer target cannot be multisampled, so turning on the Tree ID turns MSAA off on
593
+ that scene pass: `treeIdTexture` sets `samples: 0`, also with an `antialias: true` renderer. This
594
+ applies wherever the ID channel is on: `treeIdTexture`, `treeEffectsPass(..., { treeId: true })`,
595
+ and in `TreeEffects` the `treeId: true` option, `outline.betweenTrees`, `highlight` and the
596
+ `low-poly` suggestion (which uses `betweenTrees`). Add FXAA or SMAA after the pass if you need
597
+ smooth edges there.
598
+ - **Limits:** IDs are handed out by one registry for the whole page on first use: the first time a
599
+ tree is drawn with the channel or asked for with `treeIdOf(tree)`, whichever comes first. They are
600
+ never reused: about 4.29 billion per session. The registry keeps no tree alive. The ID ignores the
601
+ outline's `selection`.
602
+ - **Frame-relative:** a Forest tree's ID follows its instance slot. Removing a tree (the last tree
603
+ moves into its slot) or a Variant growing past its capacity can change the IDs of other trees. So
604
+ resolve an ID with `treeFromId` in the frame it was read, and ask `treeIdOf(tree)` for a tree's
605
+ current ID; a removed tree resolves to `undefined`.
606
+ - `readTreeId` reads the pixel under a point of the canvas from the last render of the pass (it
607
+ handles the target's index, the y flip and the device pixel ratio). It works on WebGPU and on the
608
+ WebGL2 fallback.
609
+ - **WebGL2 fallback:** three clears every target there as floats, which is invalid for an integer
610
+ target, so `treeIdTexture` makes the pass clear the ID target itself right before every render (a
611
+ frame with nothing drawn reads 0). three's own clear still logs a GL warning
612
+ (a `GL_INVALID_OPERATION` from `clearBufferfv`) in the console each frame; it is harmless.
613
+
614
+ #### Picking with `TreeEffects` and the opt-in channels
615
+
616
+ The ready-made pipeline only renders the channels its settings need. Without them (`effects: null`,
617
+ or grade, glow and outline without `betweenTrees`) the scene pass is exactly `{ output, treeMask }` with the 8-bit mask, as
618
+ always. Pass `treeId: true` to keep the Tree ID channel on without any effect needing it, then pick
619
+ with one call:
620
+
621
+ ```ts
622
+ import { createTreeEffects } from '@casmo/tree.js/effects';
623
+
624
+ const effects = createTreeEffects(renderer, scene, camera, { effects: 'stylized', treeId: true });
625
+ renderer.domElement.addEventListener('pointermove', async (event) => {
626
+ const tree = await effects.pick(event.offsetX, event.offsetY); // Tree, ForestTree or undefined
627
+ });
628
+ ```
629
+
630
+ `pick` reads the ID from the last render and resolves it right away (IDs are frame-relative). Without
631
+ the Tree ID channel it throws an error that names the `treeId` option. The scene pass's MRT (and with
632
+ it the compiled materials of your scene) only changes when `set()` needs a different set of channels;
633
+ switching between settings that need the same channels keeps it. When the channels do change,
634
+ `effects.scenePass` is a new pass (three cannot remove a target from a pass, nor turn MSAA back on
635
+ for it), so read `effects.scenePass` again after such a `set()` instead of keeping the old one. In your own pipeline,
636
+ `treeEffectsPass(scene, camera, selection, { treeId: true })` adds the channel and fills in the
637
+ effects' `treeId` input.
638
+
639
+ #### Outline between overlapping trees
640
+
641
+ By default the outline goes around all trees together, so trees that overlap on screen merge into one
642
+ shape. With `betweenTrees` the outline is also drawn where a tree lies in front of another one, for a
643
+ Tree and a Tree, two Forest trees, or a Tree and a Forest tree:
644
+
645
+ ```ts
646
+ import { createTreeEffects } from '@casmo/tree.js/effects';
647
+
648
+ const effects = createTreeEffects(renderer, scene, camera, {
649
+ effects: { outline: { color: '#18230f', thickness: 2, betweenTrees: true } },
650
+ });
651
+ ```
652
+
653
+ The line is drawn on a selected tree pixel when the pixel `thickness` px away is another tree (a
654
+ different Tree ID) that is further away, so it lies on the front tree's side, with the outline's own
655
+ colour, thickness and strength (with a standard, reversed or logarithmic depth buffer). It is off by
656
+ default (the outline stays as it was). It needs the Tree
657
+ ID: `TreeEffects` turns the channel on for it, and switching `betweenTrees` on or off builds a new
658
+ graph. In your own pipeline, use `treeEffectsPass(scene, camera, selection, { treeId: true })`, which
659
+ also fills in the `depth` input; `treeOutline` throws when the `treeId` or `depth` input is missing.
660
+
661
+ ### Inner Lines
662
+
663
+ **Inner Lines** are ink lines inside the trees where the surface folds or steps away from the viewer,
664
+ such as around each leaf clump, on top of the outline around the tree. They come from depth edges
665
+ (a relative step `|Δz| / z`, so they look the same near and far) and normal edges (`1 − dot`), are
666
+ only drawn on tree pixels of every tree (whatever the `selection`) and only from neighbours that are
667
+ tree pixels too: the silhouette is left to the outline. They work with a standard, reversed
668
+ (`reversedDepthBuffer`) or logarithmic (`logarithmicDepthBuffer`) depth buffer.
669
+
670
+ ```ts
671
+ import { createTreeEffects } from '@casmo/tree.js/effects';
672
+
673
+ const effects = createTreeEffects(renderer, scene, camera, {
674
+ effects: { outline: {}, innerLines: { color: '#1d2a14', thickness: 1, strength: 1, normalThreshold: 0.4, depthThreshold: 0.02 } },
675
+ });
676
+ ```
677
+
678
+ Inner Lines need view normals, so with `innerLines` the ready-made pipeline adds a `normal` channel
679
+ (RGBA8) to its scene pass; without it the pass stays `{ output, treeMask }`. Order of the effects:
680
+ grade, glow, inner lines, outline. In your own pipeline, `treeEffectsPass(scene, camera, selection, { normal: true })`
681
+ fills in the `normal`, `depth` and `camera` inputs, or merge `treeNormalMRT()` into your scene pass.
682
+ `innerLines()` throws an error naming the missing input when `normal`, `depth` or `camera` is missing.
683
+
684
+ If your pipeline already renders normals (for GTAO, SSR and the like), pass that texture instead of
685
+ rendering them twice, with its encoding: `'color'` (default, `directionToColor(normalView)` in an
686
+ RGBA8 target) or `'direction'` (the normal itself, e.g. in a float target):
687
+
688
+ ```ts
689
+ import * as THREE from 'three/webgpu';
690
+ import { mrt, normalView, output, pass } from 'three/tsl';
691
+ import { innerLines, TREE_MASK, treeMaskMRT, treeOutline } from '@casmo/tree.js/effects';
692
+
693
+ const scenePass = pass(scene, camera);
694
+ scenePass.setMRT(mrt({ output, normal: normalView }).merge(treeMaskMRT())); // your MRT, plus the tree mask
695
+ scenePass.getTexture(TREE_MASK).type = THREE.UnsignedByteType;
696
+ const normal = scenePass.getTextureNode('normal'); // also feeds your GTAO / SSR
697
+ const input = {
698
+ color: scenePass.getTextureNode('output'),
699
+ mask: scenePass.getTextureNode(TREE_MASK),
700
+ depth: scenePass.getTextureNode('depth'),
701
+ camera,
702
+ normal,
703
+ normalEncoding: 'direction' as const,
704
+ };
705
+ const lined = innerLines(input, { strength: 0.8 });
706
+ const pipeline = new THREE.RenderPipeline(renderer);
707
+ pipeline.outputNode = treeOutline({ ...input, color: lined });
708
+ ```
709
+
710
+ ### Highlight
711
+
712
+ **Highlight** marks the trees you point out, such as the one under the cursor: it brightens and tints
713
+ them and draws a ring just outside them, optionally pulsing. It is the one Tree Effect that also
714
+ changes pixels next to a tree (its ring). It is never on by default and in no suggestion. It needs
715
+ the Tree ID, so `highlight` turns that channel on (and with it `pick`):
716
+
717
+ ```ts
718
+ import { createTreeEffects } from '@casmo/tree.js/effects';
719
+
720
+ const effects = createTreeEffects(renderer, scene, camera, {
721
+ effects: { outline: {}, highlight: { color: '#ffe066', tint: 0.25, brightness: 1.25, outlineColor: '#ffd23f', thickness: 2, pulse: 0 } },
722
+ });
723
+ renderer.domElement.addEventListener('pointermove', async (event) => {
724
+ const tree = await effects.pick(event.offsetX, event.offsetY);
725
+ effects.highlighted.splice(0, effects.highlighted.length, ...(tree ? [tree] : [])); // read every frame, no recompile
726
+ });
727
+ ```
728
+
729
+ - `highlighted` (an option, or the `effects.highlighted` list) holds Trees and Forest trees, not a
730
+ Forest or a group. Change it in place; it is read every frame. At most 64 trees are highlighted at
731
+ once (one console warning beyond that). Removed, disposed and undrawn trees are skipped.
732
+ - Options: `color` and `tint` (0..1) of the tint, `brightness` (a multiplier), `outlineColor` and
733
+ `thickness` (px) of the ring, `strength` (0..1) and `pulse` (Hz, 0 = off): tint and brightness swing
734
+ between their value and half of it, the ring stays solid.
735
+ - It is applied last (grade, glow, inner lines, outline, then highlight), so it is always on top. In your own
736
+ pipeline: `treeHighlight(input, highlighted, options)`, with the `treeId` input of
737
+ `treeEffectsPass(scene, camera, null, { treeId: true })`, or `applyTreeEffects(input, settings, highlighted)`.
738
+
554
739
  ## React Three Fiber
555
740
 
556
741
  ![Two low-poly trees rendered with React Three Fiber](docs/images/react.png)
@@ -1,13 +1,17 @@
1
1
  import { RenderPipeline, type Camera, type Node, type Object3D, type Renderer, type Scene } from 'three/webgpu';
2
2
  import type { StyleName } from '../styles/registry';
3
- import { type TreeEffectInput, type TreeEffectsPass } from './mask';
3
+ import type { TreeEffectInput } from './mask';
4
+ import { type TreeEffectsPass } from './pass';
4
5
  import { type TreeEffectsSettings } from './suggested';
6
+ import type { ForestTree } from '../forest';
7
+ import type { Tree } from '../tree';
5
8
  /**
6
9
  * Applies a combination of Tree Effects to `input` and returns the resulting colour node, for use in
7
10
  * your own post-processing pipeline (`pipeline.outputNode = applyTreeEffects(...)`, or feed it into
8
- * more effects). Order: colour grade, leaf glow, outline. Empty settings return `input.color`.
11
+ * more effects). Order: colour grade, leaf glow, inner lines, outline, highlight (always on top).
12
+ * Empty settings return `input.color`. `highlighted`: the trees the Highlight marks (mutable, read every frame).
9
13
  */
10
- export declare function applyTreeEffects(input: TreeEffectInput, settings: TreeEffectsSettings): Node<'vec4'>;
14
+ export declare function applyTreeEffects(input: TreeEffectInput, settings: TreeEffectsSettings, highlighted?: readonly (Tree | ForestTree)[]): Node<'vec4'>;
11
15
  /** The suggested combination of a built-in Style, or the settings themselves; `null` = no effects. */
12
16
  export type TreeEffectsChoice = StyleName | TreeEffectsSettings | null;
13
17
  export interface TreeEffectsOptions {
@@ -18,6 +22,19 @@ export interface TreeEffectsOptions {
18
22
  * Default: every tree in the scene.
19
23
  */
20
24
  selection?: Object3D[];
25
+ /**
26
+ * Keeps the Tree ID channel on even when no effect needs it, for {@link TreeEffects.pick}.
27
+ * Default: false (the channel is only rendered when an effect needs it). Whenever the Tree ID
28
+ * channel is on (this option, `outline.betweenTrees`, `highlight`, or the low-poly suggestion),
29
+ * the scene pass renders without MSAA: an integer target cannot be multisampled.
30
+ */
31
+ treeId?: boolean;
32
+ /**
33
+ * The trees the Highlight marks (`effects: { highlight: {...} }`): Trees and Forest trees, at most
34
+ * 64; mutable, read every frame, so hover and selection changes never recompile. Default: none
35
+ * (a new empty list, see {@link TreeEffects.highlighted}).
36
+ */
37
+ highlighted?: (Tree | ForestTree)[];
21
38
  }
22
39
  /**
23
40
  * A ready-made post-processing pipeline (`RenderPipeline`) with the Tree Effects: render with
@@ -26,16 +43,44 @@ export interface TreeEffectsOptions {
26
43
  * and {@link applyTreeEffects} instead.
27
44
  */
28
45
  export declare class TreeEffects {
46
+ private readonly renderer;
47
+ private readonly scene;
48
+ private readonly camera;
49
+ private readonly options;
29
50
  readonly pipeline: RenderPipeline;
30
- /** The scene pass (colour + tree mask). */
31
- readonly scenePass: TreeEffectsPass;
51
+ /** The trees the Highlight marks (the `highlighted` option, or an empty list): change it in place. */
52
+ readonly highlighted: (Tree | ForestTree)[];
32
53
  private nodes;
33
54
  private current;
55
+ private graph;
56
+ private input;
34
57
  constructor(renderer: Renderer, scene: Scene, camera: Camera, options?: TreeEffectsOptions);
58
+ /**
59
+ * The scene pass (colour + tree mask, plus the channels the settings need, such as the Tree ID).
60
+ *
61
+ * It is replaced by a new one (a new object, the old one disposed) when {@link set} needs another
62
+ * set of channels, and only then; read it again after such a `set()` rather than keeping it.
63
+ * Swapping only the MRT of one PassNode is not feasible with three: a PassNode can add targets
64
+ * (`getTexture`) but has no way to remove one, and its sample count is fixed per target, so
65
+ * turning a channel off (or the Tree ID off, which brings MSAA back) needs a new pass. Either way
66
+ * the scene's materials recompile, because the MRT changes; settings that need the same channels
67
+ * keep this pass and its MRT.
68
+ */
69
+ get scenePass(): TreeEffectsPass;
35
70
  /** The active combination (`{}` = none). */
36
71
  get settings(): TreeEffectsSettings;
37
- /** Switches to a Style's suggested combination, custom settings, or none (`null`). */
72
+ /**
73
+ * Switches to a Style's suggested combination, custom settings, or none (`null`). With the same
74
+ * effects on (and the same glow radius) only the colours and numbers change, without a recompile;
75
+ * otherwise a new graph is built and the old one freed.
76
+ */
38
77
  set(effects: TreeEffectsChoice): void;
78
+ /**
79
+ * GPU picking: the Tree or Forest tree under a point of the canvas (CSS pixels from its top left
80
+ * corner, as `event.offsetX/offsetY`) in the last render, or `undefined` where no tree is drawn.
81
+ * Needs the Tree ID channel: throws when it is off (create the effects with `treeId: true`).
82
+ */
83
+ pick(x: number, y: number): Promise<Tree | ForestTree | undefined>;
39
84
  /** Renders the scene with the effects (call instead of `renderer.render(scene, camera)`). */
40
85
  render(): void;
41
86
  dispose(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../../src/effects/effects.ts"],"names":[],"mappings":"AAAA,OAAO,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'./mask';
3
4
  /** Leaf glow settings. */
4
5
  export interface LeafGlowOptions {
@@ -11,9 +12,13 @@ export interface LeafGlowOptions {
11
12
  /** Blur radius (Gaussian sigma, in pixels at half resolution; default 6). */
12
13
  radius?: number;
13
14
  }
15
+ /** The blur radius of leaf glow settings (part of a Tree Effects graph's shape). */
16
+ export declare function glowRadius(options: LeafGlowOptions): number;
14
17
  /**
15
18
  * Tree Effect: a soft glow of the leaves. The bright (sunlit) leaf pixels are blurred and added
16
19
  * back onto the tree pixels (leaves and the wood between them), never onto the rest of the scene.
17
20
  */
18
21
  export declare function leafGlow(input: TreeEffectInput, options?: LeafGlowOptions): Node<'vec4'>;
22
+ /** {@link leafGlow} with its settings as uniforms; `radius` is fixed when built. */
23
+ export declare function liveLeafGlow(input: TreeEffectInput, options?: LeafGlowOptions): LiveTreeEffect<LeafGlowOptions>;
19
24
  //# sourceMappingURL=glow.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"glow.d.ts","sourceRoot":"","sources":["../../src/effects/glow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAG1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,0BAA0B;AAC1B,MAAM,WAAW,eAAe;IAC9B,4EAA4E;IAC5E,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,eAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,CAO5F"}
1
+ {"version":3,"file":"glow.d.ts","sourceRoot":"","sources":["../../src/effects/glow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAG1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,0BAA0B;AAC1B,MAAM,WAAW,eAAe;IAC9B,4EAA4E;IAC5E,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,mCAAmC;IACnC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kGAAkG;IAClG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6EAA6E;IAC7E,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,oFAAoF;AACpF,wBAAgB,UAAU,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM,CAE3D;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,eAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,CAE5F;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,eAAoB,GAAG,cAAc,CAAC,eAAe,CAAC,CAmBnH"}
@@ -1,4 +1,5 @@
1
1
  import { type ColorRepresentation, type Node } from 'three/webgpu';
2
+ import type { LiveTreeEffect } from './live';
2
3
  import type { TreeEffectInput } from './mask';
3
4
  /** Tree colour grading settings (all optional; the defaults change nothing). */
4
5
  export interface TreeColorGradeOptions {
@@ -16,4 +17,6 @@ export interface TreeColorGradeOptions {
16
17
  * Returns the graded colour where the tree mask is set and `input.color` unchanged elsewhere.
17
18
  */
18
19
  export declare function treeColorGrade(input: TreeEffectInput, options?: TreeColorGradeOptions): Node<'vec4'>;
20
+ /** {@link treeColorGrade} with its settings as uniforms. */
21
+ export declare function liveTreeColorGrade(input: TreeEffectInput, options?: TreeColorGradeOptions): LiveTreeEffect<TreeColorGradeOptions>;
19
22
  //# sourceMappingURL=grade.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"grade.d.ts","sourceRoot":"","sources":["../../src/effects/grade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAID;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,qBAA0B,GAAG,IAAI,CAAC,MAAM,CAAC,CAMxG"}
1
+ {"version":3,"file":"grade.d.ts","sourceRoot":"","sources":["../../src/effects/grade.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,gFAAgF;AAChF,MAAM,WAAW,qBAAqB;IACpC,yCAAyC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,IAAI,CAAC,EAAE,mBAAmB,CAAC;CAC5B;AAID;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,qBAA0B,GAAG,IAAI,CAAC,MAAM,CAAC,CAExG;AAED,4DAA4D;AAC5D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,qBAA0B,GAAG,cAAc,CAAC,qBAAqB,CAAC,CAkBrI"}
@@ -0,0 +1,35 @@
1
+ import { type ColorRepresentation, type Node } from 'three/webgpu';
2
+ import type { ForestTree } from '../forest';
3
+ import type { Tree } from '../tree';
4
+ import type { LiveTreeEffect } from './live';
5
+ import type { TreeEffectInput } from './mask';
6
+ /** Highlight settings. */
7
+ export interface TreeHighlightOptions {
8
+ /** Colour the highlighted trees are tinted towards (default a warm yellow, '#ffe066'). */
9
+ color?: ColorRepresentation;
10
+ /** How far the trees are tinted towards `color`, 0..1 (default 0.25). */
11
+ tint?: number;
12
+ /** Brightness multiplier of the highlighted trees (default 1.25). */
13
+ brightness?: number;
14
+ /** Colour of the ring just outside the highlighted trees (default '#ffd23f'). */
15
+ outlineColor?: ColorRepresentation;
16
+ /** Width of the ring in pixels (default 2). */
17
+ thickness?: number;
18
+ /** Opacity of the whole Highlight, 0..1 (default 1). */
19
+ strength?: number;
20
+ /**
21
+ * Pulse frequency in Hz: tint and brightness swing between their value and half of it (half the
22
+ * brightening); the ring stays solid. Default 0 = no pulse.
23
+ */
24
+ pulse?: number;
25
+ }
26
+ /**
27
+ * Tree Effect: marks the trees in `highlighted` (Trees and Forest trees; mutable, read every frame)
28
+ * by brightening and tinting their pixels and drawing a ring just outside them, the one Tree Effect
29
+ * that also changes pixels next to a tree. At most 64 trees (the rest is ignored with one warning); removed, disposed
30
+ * and undrawn trees are skipped. Needs the Tree ID input (`treeEffectsPass` with `{ treeId: true }`).
31
+ */
32
+ export declare function treeHighlight(input: TreeEffectInput, highlighted: readonly (Tree | ForestTree)[], options?: TreeHighlightOptions): Node<'vec4'>;
33
+ /** {@link treeHighlight} with its settings as uniforms. */
34
+ export declare function liveTreeHighlight(input: TreeEffectInput, highlighted: readonly (Tree | ForestTree)[], options?: TreeHighlightOptions): LiveTreeEffect<TreeHighlightOptions>;
35
+ //# sourceMappingURL=highlight.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlight.d.ts","sourceRoot":"","sources":["../../src/effects/highlight.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAI9C,0BAA0B;AAC1B,MAAM,WAAW,oBAAoB;IACnC,0FAA0F;IAC1F,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,yEAAyE;IACzE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,qEAAqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,iFAAiF;IACjF,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAgBD;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,SAAS,CAAC,IAAI,GAAG,UAAU,CAAC,EAAE,EAAE,OAAO,GAAE,oBAAyB,GAAG,IAAI,CAAC,MAAM,CAAC,CAEnJ;AAED,2DAA2D;AAC3D,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE,SAAS,CAAC,IAAI,GAAG,UAAU,CAAC,EAAE,EAC3C,OAAO,GAAE,oBAAyB,GACjC,cAAc,CAAC,oBAAoB,CAAC,CAoFtC"}
@@ -1,7 +1,11 @@
1
- export { TREE_MASK, createTreeMask, treeMaskMRT, treeEffectsPass, treePartOf, type TreeEffectInput, type TreeEffectsPass, type TreePart } from './mask';
1
+ export { TREE_MASK, createTreeMask, treeMaskMRT, treePartOf, type TreeEffectInput, type TreePart } from './mask';
2
+ export { treeEffectsPass, type TreeEffectsChannels, type TreeEffectsPass } from './pass';
2
3
  export { treeOutline, type TreeOutlineOptions } from './outline';
4
+ export { innerLines, TREE_NORMAL, treeNormalMRT, type InnerLinesOptions } from './inner-lines';
3
5
  export { leafGlow, type LeafGlowOptions } from './glow';
4
6
  export { treeColorGrade, type TreeColorGradeOptions } from './grade';
7
+ export { treeHighlight, type TreeHighlightOptions } from './highlight';
8
+ export { TREE_ID, readTreeId, treeFromId, treeIdMRT, treeIdOf, treeIdTexture } from './tree-id';
5
9
  export { SUGGESTED_TREE_EFFECTS, type TreeEffectsSettings } from './suggested';
6
10
  export { applyTreeEffects, createTreeEffects, TreeEffects, type TreeEffectsChoice, type TreeEffectsOptions, } from './effects';
7
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/effects/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACxJ,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/effects/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACjH,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC"}
@@ -0,0 +1,39 @@
1
+ import { type ColorRepresentation, type MRTNode, type Node } from 'three/webgpu';
2
+ import type { LiveTreeEffect } from './live';
3
+ import type { TreeEffectInput } from './mask';
4
+ /** Name of the view normal output in a pass's MRT (`scenePass.getTextureNode('normal')`), see {@link treeNormalMRT}. */
5
+ export declare const TREE_NORMAL = "normal";
6
+ /**
7
+ * The MRT output that renders view normals in the `'color'` encoding (`packNormalToRGB(normalView)`,
8
+ * the same as `directionToColor`) to a target named `normal`, for Inner Lines. Merge it into the MRT
9
+ * of your own scene pass and make the target RGBA8:
10
+ * `scenePass.setMRT(mrt({ output }).merge(treeMaskMRT()).merge(treeNormalMRT())); scenePass.getTexture('normal').type = UnsignedByteType;`.
11
+ * If your pipeline already renders normals (GTAO, SSR), pass that texture as the `normal` input instead.
12
+ */
13
+ export declare function treeNormalMRT(): MRTNode;
14
+ /** Inner Lines settings. */
15
+ export interface InnerLinesOptions {
16
+ /** Line colour (default a dark green-brown). */
17
+ color?: ColorRepresentation;
18
+ /** How far apart (in pixels) the compared pixels are, which sets the line width (default 1). */
19
+ thickness?: number;
20
+ /** Opacity of the lines, 0..1 (default 1). */
21
+ strength?: number;
22
+ /** A line where the normals of neighbouring pixels differ by more than this, as 1 − dot (default 0.4). */
23
+ normalThreshold?: number;
24
+ /** A line where neighbouring pixels step away by more than this, as relative depth |Δz| / z (default 0.02). */
25
+ depthThreshold?: number;
26
+ }
27
+ /**
28
+ * Tree Effect: ink lines inside the trees where the surface folds (normal edges) or steps away
29
+ * from the viewer (depth edges), such as around each leaf clump. Only drawn on tree pixels (of
30
+ * every tree, regardless of the outline's `selection`), and only from neighbours that are tree
31
+ * pixels too: the silhouette is left to the outline. Needs the `depth`, `camera` and `normal` inputs
32
+ * (`treeEffectsPass(scene, camera, null, { normal: true })` has them) and throws without them.
33
+ * Works with a standard, reversed (`reversedDepthBuffer`) or logarithmic (`logarithmicDepthBuffer`)
34
+ * depth buffer, and with perspective and orthographic cameras.
35
+ */
36
+ export declare function innerLines(input: TreeEffectInput, options?: InnerLinesOptions): Node<'vec4'>;
37
+ /** {@link innerLines} with its settings as uniforms; the normal encoding is fixed when built. */
38
+ export declare function liveInnerLines(input: TreeEffectInput, options?: InnerLinesOptions): LiveTreeEffect<InnerLinesOptions>;
39
+ //# sourceMappingURL=inner-lines.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inner-lines.d.ts","sourceRoot":"","sources":["../../src/effects/inner-lines.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAE,KAAK,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAExF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAG9C,wHAAwH;AACxH,eAAO,MAAM,WAAW,WAAW,CAAC;AAEpC;;;;;;GAMG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAEvC;AAED,4BAA4B;AAC5B,MAAM,WAAW,iBAAiB;IAChC,gDAAgD;IAChD,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,gGAAgG;IAChG,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0GAA0G;IAC1G,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,+GAA+G;IAC/G,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,iBAAsB,GAAG,IAAI,CAAC,MAAM,CAAC,CAEhG;AAED,iGAAiG;AACjG,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,iBAAsB,GAAG,cAAc,CAAC,iBAAiB,CAAC,CAkDzH"}
@@ -0,0 +1,12 @@
1
+ import type { Node } from 'three/webgpu';
2
+ /**
3
+ * A built Tree Effect whose colours and numbers are uniforms: `update()` changes them in place
4
+ * (no new graph, no recompile). Settings that change the graph itself (its shape) need a new build.
5
+ */
6
+ export interface LiveTreeEffect<Options> {
7
+ /** The resulting colour node. */
8
+ node: Node<'vec4'>;
9
+ /** Sets the uniforms to `options` (the shape-defining settings are ignored). */
10
+ update(options: Options): void;
11
+ }
12
+ //# sourceMappingURL=live.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"live.d.ts","sourceRoot":"","sources":["../../src/effects/live.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,OAAO;IACrC,iCAAiC;IACjC,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACnB,gFAAgF;IAChF,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;CAChC"}
@@ -1,4 +1,4 @@
1
- import { type Camera, type Material, type MRTNode, type Node, type Object3D, type PassNode, type Scene, type TextureNode } from 'three/webgpu';
1
+ import { type Camera, type Material, type MRTNode, type Node, type Object3D, type TextureNode } from 'three/webgpu';
2
2
  /** Name of the tree mask output in a pass's MRT (`scenePass.getTextureNode(TREE_MASK)`). */
3
3
  export declare const TREE_MASK = "treeMask";
4
4
  /** The part of a tree a material draws. */
@@ -30,15 +30,27 @@ export interface TreeEffectInput {
30
30
  color: Node<'vec4'>;
31
31
  /** Tree mask texture (see {@link createTreeMask}), e.g. `scenePass.getTextureNode(TREE_MASK)`. */
32
32
  mask: TextureNode;
33
+ /**
34
+ * Tree ID texture (`r32uint`, see `treeIdMRT`), e.g. `scenePass.getTextureNode(TREE_ID)`; only
35
+ * needed by effects that tell trees apart. Read it with exact texel loads, never filtered.
36
+ */
37
+ treeId?: TextureNode;
38
+ /**
39
+ * Scene depth texture, e.g. `scenePass.getTextureNode('depth')`; only needed by effects that
40
+ * compare distances (the outline's `betweenTrees`, and Inner Lines with `camera`).
41
+ */
42
+ depth?: TextureNode;
43
+ /** The camera the scene pass renders with (its near and far turn `depth` into view Z). */
44
+ camera?: Camera;
45
+ /**
46
+ * View-space normal texture, e.g. `scenePass.getTextureNode('normal')` (see `treeNormalMRT`, or
47
+ * your own normal MRT); only needed by Inner Lines. Encoded as `normalEncoding` says.
48
+ */
49
+ normal?: TextureNode;
50
+ /**
51
+ * How `normal` stores the view normal: `'color'` (default) = `directionToColor(normalView)`, as in
52
+ * an RGBA8 target; `'direction'` = the normal itself, as in a float target.
53
+ */
54
+ normalEncoding?: 'color' | 'direction';
33
55
  }
34
- /** A scene pass that renders the colour and the tree mask, ready for the Tree Effects. */
35
- export interface TreeEffectsPass extends TreeEffectInput {
36
- pass: PassNode;
37
- }
38
- /**
39
- * Creates `pass(scene, camera)` with MRT `{ output, treeMask }` and returns it with its colour and
40
- * mask texture nodes. `selection`: the trees to outline (default `null` = all trees), see
41
- * {@link createTreeMask}. If your pipeline already has a scene pass, merge {@link treeMaskMRT} into it instead.
42
- */
43
- export declare function treeEffectsPass(scene: Scene, camera: Camera, selection?: readonly Object3D[] | null): TreeEffectsPass;
44
56
  //# sourceMappingURL=mask.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../../src/effects/mask.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAGtB,4FAA4F;AAC5F,eAAO,MAAM,SAAS,aAAa,CAAC;AAEpC,2CAA2C;AAC3C,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,IAAI,CAGjF;AAOD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,SAAS,GAAE,SAAS,QAAQ,EAAE,GAAG,IAAW,GAAG,IAAI,CAAC,MAAM,CAAC,CAOzF;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,SAAS,GAA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,CAAC,MAAM,CAAC,CAAC;IACpB,kGAAkG;IAClG,IAAI,EAAE,WAAW,CAAC;IAClB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;OAGG;IACH,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,0FAA0F;IAC1F,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CACxC"}
@@ -1,4 +1,5 @@
1
1
  import { type ColorRepresentation, type Node } from 'three/webgpu';
2
+ import type { LiveTreeEffect } from './live';
2
3
  import type { TreeEffectInput } from './mask';
3
4
  /** Tree outline settings. */
4
5
  export interface TreeOutlineOptions {
@@ -8,11 +9,22 @@ export interface TreeOutlineOptions {
8
9
  thickness?: number;
9
10
  /** Opacity of the line, 0..1 (default 1). */
10
11
  strength?: number;
12
+ /**
13
+ * Also draw the line between overlapping trees (Tree–Tree, Forest tree–Forest tree, Tree–Forest
14
+ * tree): on a selected tree pixel next to another tree that is further away, so the line lies on
15
+ * the front tree's side, as thick as the outer outline (with a standard, reversed or logarithmic
16
+ * depth buffer). Needs the `treeId` and `depth` inputs (see `treeEffectsPass`). Default false.
17
+ * Changing it builds a new graph.
18
+ */
19
+ betweenTrees?: boolean;
11
20
  }
12
21
  /**
13
22
  * Tree Effect: an outline along the silhouettes of the selected trees (the `selection` of the
14
23
  * tree mask, see `createTreeMask`; all trees by default), around the outside of the canopy and
15
24
  * the gaps in it. The line is drawn on the inside of the silhouette, so only tree pixels change.
25
+ * With `betweenTrees`, it is also drawn where a tree overlaps another one behind it.
16
26
  */
17
27
  export declare function treeOutline(input: TreeEffectInput, options?: TreeOutlineOptions): Node<'vec4'>;
28
+ /** {@link treeOutline} with its settings as uniforms. */
29
+ export declare function liveTreeOutline(input: TreeEffectInput, options?: TreeOutlineOptions): LiveTreeEffect<TreeOutlineOptions>;
18
30
  //# sourceMappingURL=outline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/effects/outline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAE9C,6BAA6B;AAC7B,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAMD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,kBAAuB,GAAG,IAAI,CAAC,MAAM,CAAC,CAYlG"}
1
+ {"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/effects/outline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAG9C,6BAA6B;AAC7B,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,kBAAuB,GAAG,IAAI,CAAC,MAAM,CAAC,CAElG;AAED,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,kBAAuB,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAwB5H"}
@@ -0,0 +1,27 @@
1
+ import { type Camera, type Object3D, type PassNode, type Scene } from 'three/webgpu';
2
+ import { type TreeEffectInput } from './mask';
3
+ /**
4
+ * The opt-in extra channels of a scene pass, next to the colour and the tree mask (which are always
5
+ * there). Each one adds an MRT target, so leave them off unless an effect (or picking) needs them.
6
+ */
7
+ export interface TreeEffectsChannels {
8
+ /**
9
+ * The Tree ID target (`treeIdMRT`), for effects that tell trees apart and for picking. Turns MSAA
10
+ * off on the scene pass (see `treeIdTexture`).
11
+ */
12
+ treeId?: boolean;
13
+ /** The view normal target (`treeNormalMRT`, RGBA8, the 'color' encoding), for Inner Lines. */
14
+ normal?: boolean;
15
+ }
16
+ /** A scene pass that renders the colour, the tree mask and the chosen channels, ready for the Tree Effects. */
17
+ export interface TreeEffectsPass extends TreeEffectInput {
18
+ pass: PassNode;
19
+ }
20
+ /**
21
+ * Creates `pass(scene, camera)` with MRT `{ output, treeMask }` (plus the opt-in `channels`, e.g.
22
+ * `{ treeId: true }`, `{ normal: true }`) and returns it with the texture nodes of every target (and the depth and camera) as the effects' inputs.
23
+ * `selection`: the trees to outline (default `null` = all trees), see `createTreeMask`. If your
24
+ * pipeline already has a scene pass, merge `treeMaskMRT` (and `treeIdMRT`) into it instead.
25
+ */
26
+ export declare function treeEffectsPass(scene: Scene, camera: Camera, selection?: readonly Object3D[] | null, channels?: TreeEffectsChannels): TreeEffectsPass;
27
+ //# sourceMappingURL=pass.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pass.d.ts","sourceRoot":"","sources":["../../src/effects/pass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAEvG,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AAItE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8FAA8F;IAC9F,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,+GAA+G;AAC/G,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAS,QAAQ,EAAE,GAAG,IAAW,EAC5C,QAAQ,GAAE,mBAAwB,GACjC,eAAe,CAwBjB"}