Skip to content

Commit 8bce786

Browse files
committed
Add new docs manuals
1 parent 42520ee commit 8bce786

File tree

10 files changed

+94
-49
lines changed

10 files changed

+94
-49
lines changed

.docfx/filterconfig.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,13 @@ apiRules:
55
uidRegex: ^UnityEngine
66
- exclude:
77
uidRegex: ^UnityEditor
8+
- exclude:
9+
uidRegex: ^Zigurous.Graphics.CheckerboardTextureDrawer.OnValidate
10+
- exclude:
11+
uidRegex: ^Zigurous.Graphics.TextureDrawer.Awake
12+
- exclude:
13+
uidRegex: ^Zigurous.Graphics.TextureDrawer.OnEnable
14+
- exclude:
15+
uidRegex: ^Zigurous.Graphics.TextureDrawer.OnValidate
16+
- exclude:
17+
uidRegex: ^Zigurous.Graphics.TextureDrawer.Update

.docfx/manual/auto-tiling.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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+
Add the [AutoTile](xref:Zigurous.Graphics.AutoTile) script to the object you want to tile. The main properties that are usually edited are the `submeshes`. Each element in the array indicates how a submesh of the mesh is tiled, such as which axis the object is tiled on, the unit scale of the object, the texture offset, etc. For example, a plane is usually tiled around the Y+ axis and has a unit scale of 10. See the [Scripting API](xref:Zigurous.Graphics.AutoTile) for more information.
6+
7+
### Cube Tiling
8+
9+
When tiling cubes, the script gives the best results when used with the `Cube-Tiling.mesh` asset instead of Unity's default cube mesh. 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.
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,18 @@
1-
# Meshes
1+
# Custom Meshes
22

3-
The Graphics Utils package comes with a few custom cube meshes.
3+
The Graphics Utils package includes a few custom cube meshes.
44

55
- `Cube-3.mesh`: cube mesh with 3 submeshes (one for each axis)
66
- `Cube-6.mesh`: cube mesh with 6 submeshes (one for each face)
77
- `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)
8+
- `Cube-Tiling.mesh` cube mesh designed specifically for [Auto Tiling](auto-tiling.md)
99

1010
There are also 3 different scripts to generate cube meshes at runtime:
1111

1212
- [CubeMesh](xref:Zigurous.Graphics.CubeMesh)
1313
- [CubeMesh3](xref:Zigurous.Graphics.CubeMesh3)
1414
- [CubeMesh6](xref:Zigurous.Graphics.CubeMesh6)
1515

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-
2016
### Inverting Meshes
2117

2218
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.
@@ -31,3 +27,11 @@ mesh.InvertTriangles();
3127
Vector3[] normals = mesh.InvertedNormals();
3228
int[] triangles = mesh.InvertedTriangles();
3329
```
30+
31+
### Combining Meshes
32+
33+
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](xref:Zigurous.Graphics.CombineChildrenMeshes) script to a game object that includes an empty mesh filter. The script will combines the meshes of the children objects and apply the new combined mesh to the parent mesh filter.
34+
35+
### Saving Meshes
36+
37+
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.

.docfx/manual/identifiers.md

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

.docfx/manual/index.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ The Graphics Utils package provides scripts and utilities for graphics and rende
44

55
### Reference
66

7-
- [Meshes](meshes.md)
8-
- [Identifiers](identifiers.md)
9-
- [Auto Tiling](tiling.md)
7+
- [Auto Tiling](auto-tiling.md)
8+
- [Custom Meshes](custom-meshes.md)
9+
- [Shader Properties](shader-properties.md)
10+
- [Texture Drawers](texture-drawers.md)

.docfx/manual/shader-properties.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Shader Properties
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 common shader properties.
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+
### Automatic Property Ids
14+
15+
The [ShaderProperty](xref:Zigurous.Graphics.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 as a string in the editor, but you can use the id when getting or setting a shader property on a material.
16+
17+
To learn more, see https://docs.unity3d.com/ScriptReference/Shader.PropertyToID.html.
18+
19+
```csharp
20+
public ShaderProperty property = "_Custom";
21+
public float propertyValue;
22+
23+
private void Start()
24+
{
25+
Material material = GetComponent<MeshRenderer>().material;
26+
material.SetFloat(property.id, propertyValue);
27+
}
28+
```
29+
30+
### Animated Properties
31+
32+
Sometimes you want to animate a shader property over time. The Graphics Utils package includes a few data structures to accomplish this. You can declare any one of the following in a script:
33+
34+
- [AnimatedShaderIntProperty](xref:Zigurous.Graphics.AnimatedShaderIntProperty)
35+
- [AnimatedShaderFloatProperty](xref:Zigurous.Graphics.AnimatedShaderFloatProperty)
36+
- [AnimatedShaderColorProperty](xref:Zigurous.Graphics.AnimatedShaderColorProperty)
37+
38+
The structs provide a `valueOverTime` or `colorOverTime` variable that you can use to set the animated values. At this point your script can call `Animate(material, time)` to evaluate the value at the given time and apply it to the provided material.

.docfx/manual/texture-drawers.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Texture Drawers
2+
3+
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](xref:Zigurous.Graphics.TextureDrawer) and override the function `SetPixels(Texture2D)` to complete the implementation.
4+
5+
### Rendering
6+
7+
The [TextureDrawer](xref: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.
8+
9+
### Checkerboard
10+
11+
The Graphics Utils package includes a script [CheckerboardTextureDrawer](xref: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.

.docfx/manual/tiling.md

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

.docfx/manual/toc.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
href: installation.md
55
- name: Reference
66
items:
7-
- name: Meshes
8-
href: meshes.md
9-
- name: Identifiers
10-
href: identifiers.md
117
- name: Auto Tiling
12-
href: tiling.md
8+
href: auto-tiling.md
9+
- name: Custom Meshes
10+
href: custom-meshes.md
11+
- name: Shader Properties
12+
href: shader-properties.md
13+
- name: Texture Drawers
14+
href: texture-drawers.md

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ using Zigurous.Graphics;
3232

3333
## Reference
3434

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)
35+
- [Auto Tiling](https://docs.zigurous.com/com.zigurous.graphics/manual/auto-tiling.md)
36+
- [Custom Meshes](https://docs.zigurous.com/com.zigurous.graphics/manual/custom-meshes.md)
37+
- [Shader Properties](https://docs.zigurous.com/com.zigurous.graphics/manual/shader-properties.md)
38+
- [Texture Drawers](https://docs.zigurous.com/com.zigurous.graphics/manual/texture-drawers.md)

0 commit comments

Comments
 (0)