Skip to content

Commit 7d9074e

Browse files
committed
Add docs manuals
1 parent 76266f8 commit 7d9074e

File tree

6 files changed

+86
-2
lines changed

6 files changed

+86
-2
lines changed

.docfx/manual/identifiers.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Identifiers
2+
3+
When setting shader properties on materials, it is more efficient to use property ids instead of strings. The Graphics Utils package comes with a static class [Identifier](xref:Zigurous.Graphics.Identifier) with predefined ids for many common shader properties. To learn more, see https://docs.unity3d.com/ScriptReference/Shader.PropertyToID.html.
4+
5+
```csharp
6+
private void Start()
7+
{
8+
Material material = GetComponent<MeshRenderer>().material;
9+
material.SetFloat(Identifier.Glossiness, 1.0f);
10+
}
11+
```
12+
13+
### [Shader Property](xref:Zigurous.Graphics.ShaderProperty)
14+
15+
The `ShaderProperty` struct included in the Graphics Utils package automatically creates a property id for a given shader property name. Anywhere you might declare a variable for a custom shader property name use `ShaderProperty` instead. It will still be serialized in the editor as a string, but you can use the id when getting or setting a shader property on a material.
16+
17+
```csharp
18+
public ShaderProperty property = "_Custom";
19+
public float propertyValue;
20+
21+
private void Start()
22+
{
23+
Material material = GetComponent<MeshRenderer>().material;
24+
material.SetFloat(property.id, propertyValue);
25+
}
26+
```

.docfx/manual/index.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# Graphics Utils
22

3-
The Graphics Utils package provides scripts and utilities for graphics and rendering purposes in Unity projects.
3+
The Graphics Utils package provides scripts and utilities for graphics and rendering purposes in Unity projects. The package is still early in development, and more functionality will be added over time.
4+
5+
### Reference
6+
7+
- [Meshes](meshes.md)
8+
- [Identifiers](identifiers.md)
9+
- [Auto Tiling](tiling.md)

.docfx/manual/meshes.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Meshes
2+
3+
The Graphics Utils package comes with a few custom cube meshes.
4+
5+
- `Cube-3.mesh`: cube mesh with 3 submeshes (one for each axis)
6+
- `Cube-6.mesh`: cube mesh with 6 submeshes (one for each face)
7+
- `Cube-Inverted.mesh`: cube mesh with inverted normals and triangles (inside-out)
8+
- `Cube-Tiling.mesh` cube mesh designed specifically for [Auto Tiling](tiling.md)
9+
10+
There are also 3 different scripts to generate cube meshes at runtime:
11+
12+
- [CubeMesh](xref:Zigurous.Graphics.CubeMesh)
13+
- [CubeMesh3](xref:Zigurous.Graphics.CubeMesh3)
14+
- [CubeMesh6](xref:Zigurous.Graphics.CubeMesh6)
15+
16+
### Saving Meshes
17+
18+
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](xref:Zigurous.Graphics.SaveMesh) script that will save a mesh as an asset at runtime.
19+
20+
### Inverting Meshes
21+
22+
Sometimes it is useful to invert a mesh so it renders inside out. This is especially useful for cubes. Inverting a mesh flips the triangles and the normals. The Graphics Utils package comes with an [InvertMesh](xref:Zigurous.Graphics.InvertMesh) script that handles this automatically.
23+
24+
You can also manually invert the normals and triangles of a mesh by using extension methods:
25+
26+
```csharp
27+
mesh.InvertNormals();
28+
mesh.InvertTriangles();
29+
30+
// Returns the inverted values without changing the actual mesh
31+
Vector3[] normals = mesh.InvertedNormals();
32+
int[] triangles = mesh.InvertedTriangles();
33+
```

.docfx/manual/tiling.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Auto Tiling
2+
3+
One of the most powerful features included in the Graphics Utils package is the ability to auto tile materials based on the object's scale. In doing so, new materials are created that are unique to the object. This makes the workflow of creating materials for tiled objects effortless. Without this feature, you often end up creating dozens of variants of a material just to change the tiling values for different objects.
4+
5+
The [AutoTile](xref:Zigurous.Graphics.AutoTile) script is intended to be used with the `Cube-Tiling.mesh` asset. This mesh asset is split into 3 separate submeshes so you can tile each axis independently from the others. The mesh also has custom UV coordinates so the materials are tiled from the center of each axis. That said, the script has several properties to customize how you want to tile the object, so it is possible to use your own meshes.

.docfx/manual/toc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,11 @@
22
href: index.md
33
- name: Installation
44
href: installation.md
5+
- name: Reference
6+
items:
7+
- name: Meshes
8+
href: meshes.md
9+
- name: Identifiers
10+
href: identifiers.md
11+
- name: Auto Tiling
12+
href: tiling.md

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Graphics Utils
22

3-
The Graphics Utils package provides scripts and utilities for graphics and rendering purposes in Unity projects.
3+
The Graphics Utils package provides scripts and utilities for graphics and rendering purposes in Unity projects. The package is still early in development, and more functionality will be added over time.
44

55
## Installation
66

@@ -29,3 +29,9 @@ Import the package namespace in each script or file you want to use it.
2929
```csharp
3030
using Zigurous.Graphics;
3131
```
32+
33+
## Reference
34+
35+
- [Meshes](https://docs.zigurous.com/com.zigurous.graphics/manual/meshes.html)
36+
- [Identifiers](https://docs.zigurous.com/com.zigurous.graphics/manual/identifiers.html)
37+
- [Auto Tiling](https://docs.zigurous.com/com.zigurous.graphics/manual/tiling.html)

0 commit comments

Comments
 (0)