Skip to content

Commit 1f5e4a6

Browse files
authored
Merge pull request #1 from zigurous/release/0.4.0
Release/0.4.0
2 parents e1caa2f + 71a3e72 commit 1f5e4a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+1202
-665
lines changed

.github/FUNDING.yml

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

.github/workflows/docs.yml

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

.github/workflows/generate-docs.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Generate Docs
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
workflow_dispatch:
8+
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
generate:
15+
name: Docs
16+
uses: zigurous/docs/.github/workflows/unity-package.yml@main
17+
with:
18+
package_title: "Graphics Utils"
19+
package_base_path: com.zigurous.graphics
20+
package_workflow: generate-docs.yml
21+
package_artifact: docs
22+
secrets:
23+
token: ${{ secrets.DOCS_TOKEN }}

.gitmodules

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

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,35 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [0.4.0] - 2023/06/19
9+
10+
### Added
11+
12+
- New `MeshGenerator` static class to generate procedural meshes
13+
- New `Triangulator` static class to split polygons into triangles
14+
- New `HiddenMaterialPropertyDrawer` attribute to hide material properties
15+
- New `Mesh.RecalculateUV` extension method
16+
- New texture extension methods
17+
- `GetPixelCoordinates`
18+
- `GetUVCoordinates`
19+
- `Sample(u, v)`
20+
- `Sample(rect, point)`
21+
- `Sample(bounds, position)`
22+
- `SetColor`
23+
- Context menu added to `SaveMesh` to save directly from the editor
24+
- Help URLs added to all behaviors
25+
26+
### Changed
27+
28+
- Refactored `TextureDrawer` as a ScriptableObject and a separate `TextureDrawerRenderer` behavior
29+
- Improved `CombineChildrenMeshes` with better transform matrix, option to set mesh name, and toggle to destroy or disable child game objects
30+
- Renamed `AutoTile.Submesh` to `AutoTile.SubmeshTiling`
31+
- Formatting changes
32+
33+
### Removed
34+
35+
- `ShaderProperty` and `AnimatedShaderProperty` (moved to AnimationLibrary package)
36+
837
## [0.3.0] - 2021/11/14
938

1039
### Added
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
slug: "/manual/custom-meshes"
3+
---
4+
5+
# Custom Meshes
6+
7+
The **Graphics Utils** package includes a few custom cube meshes.
8+
9+
- `Cube-3.mesh`: cube mesh with 3 submeshes (one for each axis)
10+
- `Cube-6.mesh`: cube mesh with 6 submeshes (one for each face)
11+
- `Cube-Inverted.mesh`: cube mesh with inverted normals and triangles (inside-out)
12+
- `Cube-Tiling.mesh` cube mesh designed specifically for [Material Tiling](/manual/material-tiling)
13+
14+
There are also 3 different scripts to generate these cube meshes at runtime:
15+
16+
- [CubeMesh](/api/Zigurous.Graphics/CubeMesh)
17+
- [CubeMesh3](/api/Zigurous.Graphics/CubeMesh3)
18+
- [CubeMesh6](/api/Zigurous.Graphics/CubeMesh6)
19+
20+
<hr/>
21+
22+
## ⭕ Inverting Meshes
23+
24+
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](/api/Zigurous.Graphics/InvertMesh) script that handles this automatically.
25+
26+
You can also manually invert the normals and triangles of a mesh using extension methods:
27+
28+
```csharp
29+
mesh.InvertNormals();
30+
mesh.InvertTriangles();
31+
32+
// Returns the inverted values without changing the actual mesh
33+
Vector3[] normals = mesh.InvertedNormals();
34+
int[] triangles = mesh.InvertedTriangles();
35+
```
36+
37+
<hr/>
38+
39+
## 🔰 Combining Meshes
40+
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.
42+
43+
You can also manually combine meshes through an extension method:
44+
45+
```csharp
46+
MeshFilter[] filters = GetComponentsInChildren<MeshFilter>();
47+
Mesh combinedMesh = filters.CombineMesh();
48+
```
49+
50+
<hr/>
51+
52+
## 💾 Saving Meshes
53+
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.
55+
56+
You can also manually save a mesh through extension methods:
57+
58+
```csharp
59+
mesh.Save("Custom");
60+
meshFilter.SaveMesh("Custom");
61+
```
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: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
slug: "/manual"
3+
---
4+
5+
# Graphics Utils
6+
7+
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. Let us know what other features you would like to see.
8+
9+
<hr/>
10+
11+
## Overview
12+
13+
#### ⚙️ [Installation](/installation)
14+
15+
#### 🧰 [Scripting API](/api/Zigurous.Graphics)
16+
17+
#### 📋 [Changelog](/changelog)
18+
19+
#### ⚖️ [License](/license)
20+
21+
<hr/>
22+
23+
## Reference
24+
25+
#### 🔰 [Custom Meshes](/manual/custom-meshes)
26+
27+
#### ⛰️ [Procedural Generation](/manual/procedural-generation)
28+
29+
#### 🛤️ [Material Tiling](/manual/material-tiling)
30+
31+
#### 🖼️ [Texture Drawers](/manual/texture-drawers)
32+
33+
#### 🔌 [Extension Methods](/manual/extension-methods)
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
slug: "/installation"
3+
---
4+
5+
# Installation
6+
7+
Use the Unity [Package Manager](https://docs.unity3d.com/Manual/upm-ui.html) to install the **Graphics Utils** package.
8+
9+
1. Open the Package Manager in `Window > Package Manager`
10+
2. Click the add (`+`) button in the status bar
11+
3. Select `Add package from git URL` from the add menu
12+
4. Enter the following Git URL in the text box and click Add:
13+
14+
```http
15+
https://github.com/zigurous/unity-graphics-utils.git
16+
```
17+
18+
<hr/>
19+
20+
## 🏷️ Namespace
21+
22+
Import the package namespace in each script or file you want to use it. You may need to regenerate project files/assemblies first.
23+
24+
```csharp
25+
using Zigurous.Graphics;
26+
```
27+
28+
<hr/>
29+
30+
## 💻 Source Code
31+
32+
The source code for the **Graphics Utils** package is in the following repository:
33+
34+
- https://github.com/zigurous/unity-graphics-utils
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
slug: "/manual/material-tiling"
3+
---
4+
5+
# Material Tiling
6+
7+
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.
8+
9+
Add the [AutoTile](/api/Zigurous.Graphics/AutoTile) script to the object you want to tile. The main property that is usually edited is `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, has a unit scale of 10, and only 1 submesh.
10+
11+
<hr/>
12+
13+
## 🕋 Cube Tiling
14+
15+
When tiling cubes, the [AutoTile](/api/Zigurous.Graphics/AutoTile) 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. Using the custom tiling mesh, the script should be set up with 3 submeshes tiled around the X+, Y+, and Z+ axis, respectively, and the unit scale set to 1.
16+
17+
<img src="../images/tiling.jpg" width="360px"/>

0 commit comments

Comments
 (0)