Skip to content

Commit 79a6275

Browse files
committed
Update documentation
1 parent 8244d42 commit 79a6275

11 files changed

+90
-73
lines changed

Documentation~/articles/custom-meshes.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ The **Graphics Utils** package includes a few custom cube meshes.
1111
- `Cube-Inverted.mesh`: cube mesh with inverted normals and triangles (inside-out)
1212
- `Cube-Tiling.mesh` cube mesh designed specifically for [Material Tiling](/manual/material-tiling)
1313

14-
There are also 3 different scripts to generate cube meshes at runtime:
14+
There are also 3 different scripts to generate these cube meshes at runtime:
1515

1616
- [CubeMesh](/api/Zigurous.Graphics/CubeMesh)
1717
- [CubeMesh3](/api/Zigurous.Graphics/CubeMesh3)
@@ -38,7 +38,7 @@ int[] triangles = mesh.InvertedTriangles();
3838

3939
## 🔰 Combining Meshes
4040

41-
The **Graphics Utils** package includes a script to combine multiple meshes into a single mesh. This can sometimes be used to improve rendering performance, or as a way to create custom meshes and turn them into assets. Add the [CombineChildrenMeshes](/api/Zigurous.Graphics/CombineChildrenMeshes) script to a game object that includes an empty mesh filter. The script will combine the meshes of the children objects and apply the new combined mesh to the parent mesh filter.
41+
The **Graphics Utils** package includes a script to combine multiple meshes into a single mesh. This can be used to improve rendering performance, or as a way to create custom meshes and turn them into assets. Add the [CombineChildrenMeshes](/api/Zigurous.Graphics/CombineChildrenMeshes) script to the parent game object of children meshes. The combined mesh will be assigned to the mesh filter of the parent object, and the child game objects will either be destroyed or disabled.
4242

4343
You can also manually combine meshes through an extension method:
4444

@@ -51,7 +51,7 @@ Mesh combinedMesh = filters.CombineMesh();
5151

5252
## 💾 Saving Meshes
5353

54-
Often when generating meshes at runtime, you may want to save that mesh as an asset for future use so you do not need to regenerate them over and over. The **Graphics Utils** package comes with a [SaveMesh](/api/Zigurous.Graphics/SaveMesh) script that will save a mesh as an asset at runtime.
54+
Often when generating meshes at runtime, you may want to save that mesh as an asset for future use so you don't need to regenerate them again. The **Graphics Utils** package comes with a [SaveMesh](/api/Zigurous.Graphics/SaveMesh) script that will save a mesh as an asset at runtime.
5555

5656
You can also manually save a mesh through extension methods:
5757

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
slug: "/manual/extension-methods"
3+
---
4+
5+
# Extension Methods
6+
7+
The **Graphics Utils** package contains dozens of extension methods to provide enhanced support for common Unity classes. See each Scripting API for more information:
8+
9+
#### [Material](/api/Zigurous.Architecture/MaterialExtensions)
10+
11+
#### [Mesh](/api/Zigurous.Architecture/MeshExtensions)
12+
13+
#### [MeshFilter](/api/Zigurous.Architecture/MeshFilterExtensions)
14+
15+
#### [Texture](/api/Zigurous.Architecture/TextureExtensions)

Documentation~/articles/index.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ The **Graphics Utils** package provides scripts and utilities for graphics and r
2222

2323
## Reference
2424

25-
#### 🛤️ [Material Tiling](/manual/material-tiling)
26-
2725
#### 🔰 [Custom Meshes](/manual/custom-meshes)
2826

29-
#### 🌌 [Shader Properties](/manual/shader-properties)
27+
#### ⛰️ [Procedural Generation](/manual/procedural-generation)
28+
29+
#### 🛤️ [Material Tiling](/manual/material-tiling)
3030

3131
#### 🖼️ [Texture Drawers](/manual/texture-drawers)
32+
33+
#### 🔌 [Extension Methods](/manual/extension-methods)
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
slug: "/manual/procedural-generation"
3+
---
4+
5+
# Procedural Generation
6+
7+
The **Graphics Utils** package provides a utility class to generate procedural meshes at runtime. For example, use the [MeshGenerator](/api/Zigurous.Graphics/MeshGenerator) class to create a new procedural mesh that forms a grid of points.
8+
9+
```csharp
10+
Mesh mesh = MeshGenerator.Create(64, 64);
11+
```
12+
13+
This is a useful starting point to create more complex meshes, such as procedural terrain. The [MeshGenerator](/api/Zigurous.Graphics/MeshGenerator) class allows you to provide your own custom vertex generation function to create these more complex meshes.
14+
15+
```csharp
16+
void GenerateTerrain()
17+
{
18+
Mesh terrain = MeshGenerator.Create(64, 64, VertexGenerator);
19+
}
20+
21+
void VertexGenerator(int x, int y, float u, float v)
22+
{
23+
// sample terrain height using a noise function
24+
float height = Mathf.PerlinNoise(x, y);
25+
return new Vector3(x, height, y);
26+
}
27+
```
28+
29+
<hr/>
30+
31+
## 💎 Triangulation
32+
33+
Sometimes it is useful to split a polygon into triangles in order to generate a custom mesh for the polygon. The [Triangulator](/api/Zigurous.Graphics/Triangulator) class provides this utility. Pass in the points that form the polygon, and the indices of the triangles will be returned.
34+
35+
```csharp
36+
Vector2[] polygon; // array of points that form a polygon
37+
int[] triangles = Triangulator.Triangulate(polygon);
38+
```

Documentation~/articles/shader-properties.md

Lines changed: 0 additions & 52 deletions
This file was deleted.

Documentation~/articles/texture-drawers.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ slug: "/manual/texture-drawers"
44

55
# Texture Drawers
66

7-
The **Graphics Utils** package includes a base class for drawing textures at runtime. It provides the boilerplate code for creating and drawing new textures programmatically. Create a new class that inherits from [TextureDrawer](/api/Zigurous.Graphics/TextureDrawer) and override the function `SetPixels(Texture2D)` to complete the implementation.
7+
The **Graphics Utils** package includes a base class for drawing textures at runtime. It provides the boilerplate code for creating and drawing new textures programmatically.
8+
9+
Create a new class that inherits from [TextureDrawer](/api/Zigurous.Graphics/TextureDrawer) and override the function `SetPixels(Texture2D)` to complete the implementation.
10+
11+
Since [TextureDrawer](/api/Zigurous.Graphics/TextureDrawer) is a ScriptableObject, you'll want to add the `[CreateAssetMenu]` attribute to your class so you can save an instance of the class as an asset in your project using Unity's asset menu.
812

913
```csharp
14+
[CreateAssetMenu]
1015
public class CustomTextureDrawer : TextureDrawer
1116
{
1217
public override void SetPixels(Texture2D texture)
@@ -20,10 +25,14 @@ public class CustomTextureDrawer : TextureDrawer
2025

2126
## 🖼️ Rendering
2227

23-
The [TextureDrawer](/api/Zigurous.Graphics/TextureDrawer) script will automatically apply your texture to the renderer's main material on the object if a Renderer component is available. This is not required, but often is useful. There are additional customization options available in regards to the rendering, such as which shader property the texture is set to.
28+
The **Graphics Utils** package comes with a script to quickly render the result of a [TextureDrawer](/api/Zigurous.Graphics/TextureDrawer). This is an optional, but useful script to preview the texture without having to write any other code to manually assign the texture to a material.
29+
30+
Add the [TextureDrawerRenderer](/api/Zigurous.Graphics/TextureDrawerRenderer) script to any game object that contains any type of Renderer component. Assign the texture drawer you want to use and customize any other options you'd like. You can even render the texture in the editor without having to run the game.
2431

2532
<hr/>
2633

2734
## 🏁 Checkerboard
2835

2936
The **Graphics Utils** package includes a script [CheckerboardTextureDrawer](/api/Zigurous.Graphics/CheckerboardTextureDrawer) as a sample implementation. It is, of course, a fully functional script that draws a checkerboard pattern. This can be used however you desire, and there are even a number of customization options available.
37+
38+
To create a new checkerboard pattern texture, use the asset menu `Create > Zigurous > Graphics > Checkerboard Texture Drawer`.

Documentation~/data/sidenav.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,25 @@
2323
{
2424
"title": "📖 Reference",
2525
"items": [
26-
{
27-
"name": "Material Tiling",
28-
"path": "/manual/material-tiling"
29-
},
3026
{
3127
"name": "Custom Meshes",
3228
"path": "/manual/custom-meshes"
3329
},
3430
{
35-
"name": "Shader Properties",
36-
"path": "/manual/shader-properties"
31+
"name": "Procedural Generation",
32+
"path": "/manual/procedural-generation"
33+
},
34+
{
35+
"name": "Material Tiling",
36+
"path": "/manual/material-tiling"
3737
},
3838
{
3939
"name": "Texture Drawers",
4040
"path": "/manual/texture-drawers"
41+
},
42+
{
43+
"name": "Extension Methods",
44+
"path": "/manual/extension-methods"
4145
}
4246
]
4347
},

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,11 @@ The **Graphics Utils** package provides scripts and utilities for graphics and r
66

77
## Reference
88

9-
- [Auto Tiling](https://docs.zigurous.com/com.zigurous.graphics/manual/material-tiling)
109
- [Custom Meshes](https://docs.zigurous.com/com.zigurous.graphics/manual/custom-meshes)
11-
- [Shader Properties](https://docs.zigurous.com/com.zigurous.graphics/manual/shader-properties)
10+
- [Procedural Generation](https://docs.zigurous.com/com.zigurous.graphics/manual/procedural-generation)
11+
- [Material Tiling](https://docs.zigurous.com/com.zigurous.graphics/manual/material-tiling)
1212
- [Texture Drawers](https://docs.zigurous.com/com.zigurous.graphics/manual/texture-drawers)
13+
- [Extension Methods](https://docs.zigurous.com/com.zigurous.graphics/manual/extension-methods)
1314

1415
## Installation
1516

Runtime/CheckerboardTextureDrawer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Zigurous.Graphics
44
{
55
/// <summary>
6-
/// Draws a texture of a checkerboard pattern.
6+
/// Draws a checkerboard pattern texture.
77
/// </summary>
88
[CreateAssetMenu(menuName = "Zigurous/Graphics/Checkerboard Texture Drawer")]
99
[HelpURL("https://docs.zigurous.com/com.zigurous.graphics/api/Zigurous.Graphics/CheckerboardTextureDrawer")]

Runtime/CombineChildrenMeshes.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Zigurous.Graphics
44
{
55
/// <summary>
6-
/// Combines the meshes of the children of the game object into one mesh.
6+
/// Combines children meshes into one mesh.
77
/// </summary>
88
[AddComponentMenu("Zigurous/Graphics/Combine Children Meshes")]
99
[HelpURL("https://docs.zigurous.com/com.zigurous.graphics/api/Zigurous.Graphics/CombineChildrenMeshes")]
@@ -79,13 +79,11 @@ public Mesh Combine()
7979
continue;
8080
}
8181

82-
// Create a mesh combine instance
8382
CombineInstance instance = new CombineInstance();
8483
instance.mesh = child.mesh;
8584
instance.transform = child.transform.localToWorldMatrix;
8685
combine[submesh++] = instance;
8786

88-
// Destroy the child mesh
8987
if (child.transform != this.transform)
9088
{
9189
if (deleteChildren) {
@@ -96,7 +94,6 @@ public Mesh Combine()
9694
}
9795
}
9896

99-
// Create a new mesh from all of the combined children
10097
Mesh combinedMesh = new Mesh();
10198
combinedMesh.name = combinedMeshName;
10299
combinedMesh.CombineMeshes(combine, mergeSubmeshes);

0 commit comments

Comments
 (0)