yum/3ner
A toon shader for Unity's BIRP.
git clone https://git.yummers.dev/yum/3ner
a6a3d3f
master
files
| FoldEditorWindow.cs | 27.5 KiB |
| FoldOperations.cs | 12.1 KiB |
| FoldPipelineBuilder.cs | 6.1 KiB |
| README.md | 3.0 KiB |
| package-lock.json | 85 B |
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 );