yum/3ner
A toon shader for Unity's BIRP.
git clone https://git.yummers.dev/yum/3ner
00553b3
master
Fold - Vertex Deformation Pipeline Builder
A visual editor and fluent API for building vertex deformation pipelines.
Quick Start
Using the Editor Window
Open Tools > yum_food > Fold to access the dockable pipeline editor:
- Select a target material
- Click "Add Operation" to add deformation operations
- Configure parameters for each operation
- Reorder operations with ▲▼ buttons
- Click "Apply to Material" to write the pipeline to the material
Use "Load Presets" for common pipelines.
Using the Fluent API
using UnityEngine ; // Apply to a material FoldPipelineBuilder . Create () . For ( material ) . TubeToPlane ( Vector3 . zero , Vector3 . right , Vector3 . forward , 1f ) . NormConversion ( 2f , 1f , 1f ) . Apply ();
Available Operations
TubeToPlane(p, r, s, t)
Unfolds a tube into a plane.
p: Origin point (Vector3)r: R axis direction (Vector3)s: S axis direction (Vector3)t: Interpolation factor (float, 0-1)
PlaneToTube(p, r, s, t)
Folds a plane into a tube.
- Same parameters as TubeToPlane
PlaneToHemiOctahedron(p, r, s, t)
Maps a plane to a hemi-octahedron (half octahedron) shape.
p: Origin point (Vector3)r: R axis direction (Vector3)s: S axis direction (Vector3)t: Interpolation factor (float, 0-1)
Useful for creating dome-like or hemisphere projections from planar geometry.
PointAlign(po, pp, r, t)
Aligns geometry to a point.
po: Original point (Vector3)pp: Target point (Vector3)r: Rotation axis (Vector3)t: Interpolation factor (float, 0-1)
AxisAlign(po, pp, r, t)
Aligns geometry along an axis.
- Same parameters as PointAlign
NormConversion(inputK, outputK, t)
Converts between different norms (L1, L2, L∞).
inputK: Input norm (float, e.g., 1 for L1, 2 for L2, ∞ for L∞)outputK: Output norm (float)t: Interpolation factor (float, 0-1)
Common conversions:
- Sphere to box:
NormConversion(2f, float.PositiveInfinity, 1f) - Box to sphere:
NormConversion(float.PositiveInfinity, 2f, 1f) - Diamond to sphere:
NormConversion(1f, 2f, 1f)
Seal(A, k, st, t)
Sealing operation for closing geometry.
A: Amplitude (float)k: Smoothness factor (float)st: Scale factor (float)t: Interpolation factor (float, 0-1)
SineWaves()
Applies sine wave deformation.
FBM()
Applies fractal Brownian motion deformation.
Custom(opcode, f0-f3, v0-v3)
For advanced use cases or custom opcodes.
Pipeline Chaining
Operations are applied in the order they're chained:
FoldPipelineBuilder . Create () . For ( material ) . TubeToPlane ( ...) // Step 1 . NormConversion ( ...) // Step 2 . PointAlign ( ...) // Step 3 . Seal ( ...) // Step 4 . Apply (); // Execute
The shader supports up to 16 operations per material.
Clearing Deformations
In the Fold window, click "Clear All" to remove all operations from the pipeline.
Via code:
targetMaterial . SetFloat ( "_Vertex_Deformation_Enabled" , 0f );
1# Fold - Vertex Deformation Pipeline Builder 2 3A visual editor and fluent API for building vertex deformation pipelines. 4 5## Quick Start 6 7### Using the Editor Window 8 9Open `Tools > yum_food > Fold` to access the dockable pipeline editor: 10 111. Select a target material 122. Click "Add Operation" to add deformation operations 133. Configure parameters for each operation 144. Reorder operations with ▲▼ buttons 155. Click "Apply to Material" to write the pipeline to the material 16 17Use "Load Presets" for common pipelines. 18 19### Using the Fluent API 20 21``` csharp 22using UnityEngine; 23 24// Apply to a material 25FoldPipelineBuilder.Create() 26.For(material) 27.TubeToPlane(Vector3.zero, Vector3.right, Vector3.forward, 1f) 28.NormConversion(2f, 1f, 1f) 29.Apply(); 30``` 31 32## Available Operations 33 34### TubeToPlane(p, r, s, t) 35Unfolds a tube into a plane. 36- `p`: Origin point (Vector3) 37- `r`: R axis direction (Vector3) 38- `s`: S axis direction (Vector3) 39- `t`: Interpolation factor (float, 0-1) 40 41### PlaneToTube(p, r, s, t) 42Folds a plane into a tube. 43- Same parameters as TubeToPlane 44 45### PlaneToHemiOctahedron(p, r, s, t) 46Maps a plane to a hemi-octahedron (half octahedron) shape. 47- `p`: Origin point (Vector3) 48- `r`: R axis direction (Vector3) 49- `s`: S axis direction (Vector3) 50- `t`: Interpolation factor (float, 0-1) 51 52Useful for creating dome-like or hemisphere projections from planar geometry. 53 54### PointAlign(po, pp, r, t) 55Aligns geometry to a point. 56- `po`: Original point (Vector3) 57- `pp`: Target point (Vector3) 58- `r`: Rotation axis (Vector3) 59- `t`: Interpolation factor (float, 0-1) 60 61### AxisAlign(po, pp, r, t) 62Aligns geometry along an axis. 63- Same parameters as PointAlign 64 65### NormConversion(inputK, outputK, t) 66Converts between different norms (L1, L2, L∞). 67- `inputK`: Input norm (float, e.g., 1 for L1, 2 for L2, ∞ for L∞) 68- `outputK`: Output norm (float) 69- `t`: Interpolation factor (float, 0-1) 70 71Common conversions: 72- Sphere to box: `NormConversion(2f, float.PositiveInfinity, 1f)` 73- Box to sphere: `NormConversion(float.PositiveInfinity, 2f, 1f)` 74- Diamond to sphere: `NormConversion(1f, 2f, 1f)` 75 76### Seal(A, k, st, t) 77Sealing operation for closing geometry. 78- `A`: Amplitude (float) 79- `k`: Smoothness factor (float) 80- `st`: Scale factor (float) 81- `t`: Interpolation factor (float, 0-1) 82 83### SineWaves() 84Applies sine wave deformation. 85 86### FBM() 87Applies fractal Brownian motion deformation. 88 89### Custom(opcode, f0-f3, v0-v3) 90For advanced use cases or custom opcodes. 91 92## Pipeline Chaining 93 94Operations are applied in the order they're chained: 95 96``` csharp 97FoldPipelineBuilder.Create() 98.For(material) 99.TubeToPlane(...) // Step 1 100.NormConversion(...) // Step 2 101.PointAlign(...) // Step 3 102.Seal(...) // Step 4 103.Apply(); // Execute 104``` 105 106The shader supports up to 16 operations per material. 107 108## Clearing Deformations 109 110In the Fold window, click "Clear All" to remove all operations from the pipeline. 111 112Via code: 113``` csharp 114targetMaterial.SetFloat("_Vertex_Deformation_Enabled", 0f); 115```