diff options
| author | yum <yum.food.vr@gmail.com> | 2026-01-12 20:55:18 -0800 |
|---|---|---|
| committer | yum <yum.food.vr@gmail.com> | 2026-01-12 20:55:18 -0800 |
| commit | bd4d3aa6537cb3121cd1eca4a8ea4eb65eb28522 (patch) | |
| tree | 021f4296a91ba890a45b7d9cd920bf473c7bb216 /Scripts/Fold/Editor/README.md | |
| parent | 6d86c9663bab3ec1ef95ba455dfa7281415b7f44 (diff) | |
Fold: update UI, add plane -> hemioctahedron
Diffstat (limited to 'Scripts/Fold/Editor/README.md')
| -rw-r--r-- | Scripts/Fold/Editor/README.md | 83 |
1 files changed, 54 insertions, 29 deletions
diff --git a/Scripts/Fold/Editor/README.md b/Scripts/Fold/Editor/README.md index 8305abf..d2b7494 100644 --- a/Scripts/Fold/Editor/README.md +++ b/Scripts/Fold/Editor/README.md @@ -1,14 +1,28 @@ -# Vertex Deformation Fluent Builder +# Fold - Vertex Deformation Pipeline Builder -A simple, code-first API for building vertex deformation pipelines without visual node editors. +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: + +1. Select a target material +2. Click "Add Operation" to add deformation operations +3. Configure parameters for each operation +4. Reorder operations with ▲▼ buttons +5. Click "Apply to Material" to write the pipeline to the material + +Use "Load Presets" for common pipelines. + +### Using the Fluent API + ```csharp using UnityEngine; // Apply to a material -VertexDeformationBuilder.Create() +FoldPipelineBuilder.Create() .For(material) .TubeToPlane(Vector3.zero, Vector3.right, Vector3.forward, 1f) .NormConversion(2f, 1f, 1f) @@ -28,6 +42,15 @@ Unfolds a tube into a plane. 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) @@ -66,47 +89,53 @@ Applies fractal Brownian motion deformation. ### Custom(opcode, f0-f3, v0-v3) For advanced use cases or custom opcodes. -## Presets +## Presets (Code) -Use built-in presets from anywhere: +Use built-in presets from code: ```csharp -VertexDeformationPresets.TubeToPlaneFull(material); -VertexDeformationPresets.NormConvL2ToL1(material); -VertexDeformationPresets.NormConvL2ToLinf(material); +FoldPresets.TubeToPlaneFull(material); +FoldPresets.NormConvL2ToL1(material); +FoldPresets.NormConvL2ToLinf(material); ``` -## GUI Window +## Adding Custom Presets -Open `Window > Vertex Deformation Presets` for a GUI with buttons for common operations. +Edit `FoldEditorWindow.cs` to add presets to the "Load Presets" menu: -## Adding Custom Presets +```csharp +// In ShowPresetsMenu(): +menu.AddItem(new GUIContent("My Custom Effect"), false, () => LoadPreset_MyEffect()); + +// Add the preset loader method: +void LoadPreset_MyEffect() +{ + operations.Clear(); + AddOperation(new TubeToPlaneOp()); + var norm = new NormConversionOp(); + norm.inputK = 2f; + norm.outputK = 1f; + AddOperation(norm); +} +``` -1. Edit `VertexDeformationPresets` class: +Or use the fluent API in code: ```csharp public static void MyCustomEffect(Material mat) => - VertexDeformationBuilder.Create() + FoldPipelineBuilder.Create() .For(mat) .TubeToPlane(Vector3.zero, Vector3.right, Vector3.forward, 1f) .NormConversion(2f, 1f, 0.5f) - .Seal(0.1f, 2f, 0.8f, 1f) .Apply(); ``` -2. Add button in `VertexDeformationEditorWindow`: - -```csharp -if (GUILayout.Button("My Custom Effect")) - VertexDeformationPresets.MyCustomEffect(targetMaterial); -``` - ## Pipeline Chaining Operations are applied in the order they're chained: ```csharp -VertexDeformationBuilder.Create() +FoldPipelineBuilder.Create() .For(material) .TubeToPlane(...) // Step 1 .NormConversion(...) // Step 2 @@ -119,13 +148,9 @@ The shader supports up to 16 operations per material. ## Clearing Deformations -```csharp -// Via GUI: Use "Clear All Deformations" button +In the Fold window, click "Clear All" to remove all operations from the pipeline. -// Via code: +Via code: +```csharp targetMaterial.SetFloat("_Vertex_Deformation_Enabled", 0f); ``` - -## Examples - -See `VertexDeformationExamples.cs` for menu items under `Tools > Vertex Deformation > Example: ...` |
