# Quick Start

For achieving lowpoly style effect, mesh needs to have flattened surface *<mark style="color:blue;">normals</mark>* and color texture (by default Diffuse map) rendered per vertex.&#x20;

For generating lowpoly style meshes inside Unity Editor, open **Lowpoly Style Mesh Generator** editor window from the <mark style="color:blue;">**Main Toolbar**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">→</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**Window**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">→</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**Amazing Assets**</mark> menu:

<div align="center" data-full-width="false"><figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FC5zI28gVpKjRGwsAuaZq%2Feditor_window.png?alt=media&#x26;token=2043df97-4187-4c27-9105-92e4e4de2890" alt=""><figcaption></figcaption></figure></div>

{% hint style="info" %}
Editor window saves its settings before closing and restores them after opening it again, and before using, it is always better to reset its settings to the default values from the right click <mark style="color:blue;">**Context Menu**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">→</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**Reset**</mark> menu:

<p align="center"><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FHfifhB860kSO4LUsJBw6%2Fcontext_menu.png?alt=media&#x26;token=cfd5117b-13c9-48df-b8b9-50140847a3b2" alt="" data-size="original"></p>
{% endhint %}

Drag & drop objects from the **Hierarchy** window or prefab/meshes from the **Project** window inside **LSMG** editor window:

<figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FGKvSLnZ6LvisZsrJjJQN%2Feditor_scene.png?alt=media&#x26;token=bbac0eb7-2637-4a86-9744-f9a73b80e1d4" alt=""><figcaption><p><a href="https://assetstore.unity.com/packages/3d/environments/surroundead-survival-game-assets-76276"><mark style="color:orange;"><strong>SurrounDead - Free Sample</strong></mark><strong> by Justwo</strong></a></p></figcaption></figure>

Objects will be added to the conversion list:

<figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FpMaRq8Bpah8zP2zdj4T3%2Feditor_scene_2.png?alt=media&#x26;token=f3895e24-a6d5-4724-a2e1-3fab34f5c896" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
Inside editor window is displayed basic information about objects that is helpful during mesh conversion and in the case of any issues.&#x20;

For example, highlighted **Ground** object contains 1 mesh ([MeshFilter](https://docs.unity3d.com/ScriptReference/MeshFilter.html) in this case) with 1 submesh. Vertex count of its mesh is **625** and triangles count **1,152**. Generated lowpoly style mesh will have **3,456** vertices, that is 3 times more than the triangles count: **1,152** x **3 = 3,456** (452% more than in the source mesh). Triangles count will remain the same. &#x20;

[Mesh index format](https://docs.unity3d.com/ScriptReference/Mesh-indexFormat.html) depends on the vertex count and if it exceeds 65,535 than 32Bit mesh is generated.

**UV0** coordinate is needed for proper texture baking inside vertex color.
{% endhint %}

For baking texture into mesh vertex color, inside **Solver** group click on the **Texture #1** drop down menu and choose the <mark style="background-color:blue;">**\_MainTex**</mark> property. This is a texture property name inside shader used by object's material for texture rendering. During converting mesh into lowpoly style **LSMG** reads texture from material used by mesh using this property name and bakes it inside mesh vertex color:

<div align="left"><figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FDyiZQKles92JpVwSVAKy%2Fselect_texture.png?alt=media&#x26;token=f7831e53-94c4-475c-8bf5-49253c4a48e7" alt=""><figcaption></figcaption></figure></div>

{% hint style="warning" %}
Texture property names listed in this menu depends on the shaders used by objects in the conversion list. Choose texture property name that is used by the *<mark style="color:blue;">Diffuse</mark>* maps rendering inside materials.&#x20;
{% endhint %}

After choosing bake texture property name, conversion list will display if materials used by selected objects have such texture property:

<figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2Fm4jFiQsN5KGY1ZTZD9kx%2FBake_texture_info.png?alt=media&#x26;token=06631126-f923-4de5-b30a-deae778a789c" alt=""><figcaption></figcaption></figure>

Click on the **Run** button at the bottom of the editor window.

The editor tool will generate lowpoly style meshes with texture baked inside their vertex colors for all objects in the conversion list, replace all source meshes inside [MeshFilter](https://docs.unity3d.com/ScriptReference/MeshFilter.html) and [SkinnedMeshRenderer](https://docs.unity3d.com/ScriptReference/SkinnedMeshRenderer.html) components with newly generated lowpoly meshes and new material (for vertex color rendering) in the [Renderer](https://docs.unity3d.com/ScriptReference/Renderer.html) components. Based on all those actions new prefab asset file will be created and instantiated in the scene, in the same position as the source objects.

<figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FVMpfkQoOYnL1Oo0XQJCM%2Fconverted_1.png?alt=media&#x26;token=32d38d86-261a-4c86-9bc8-c4bbe75f8e7a" alt=""><figcaption><p>To see the generated prefabs, move them inside <strong>Scene</strong> view or hide the source objects</p></figcaption></figure>

***

### Mesh Combine

Instead of generating multiple meshes, **LSMG** editor tool can combine all meshes inside object hierarchy into one mesh and such way only one draw call will be used for their rendering.&#x20;

Inside **Generate** group select **Combine Everything** and click on the **Run** button again:

<div align="left"><figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FNbOCagSbL2H7pRQJBLgZ%2Fcombine_Everything.png?alt=media&#x26;token=740c2766-2286-46cd-adc6-0903bbb8e0bc" alt=""><figcaption></figcaption></figure></div>

Now instead of generating and rendering 117 meshes, only 7 meshes will be generated - one mesh for each object in the conversion list.&#x20;

Additionally, if group all scene meshes under one object's hierarchy, then **LSMG** tool can combine them all into one mesh and entire scene can be rendered using by one mesh, one material and one draw call:

<figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FeFP31zb0kBy3VMIHgojF%2Fconverted_2.png?alt=media&#x26;token=13c7e5ed-37a4-477a-bb0f-736e8e953e0e" alt=""><figcaption><p>All scene meshes are combined into one lowpoly style mesh</p></figcaption></figure>

***

### Optimize

Using the right click <mark style="color:blue;">**Context Menu**</mark> <mark style="color:blue;"></mark><mark style="color:blue;">→</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**Highlight Last Saved File**</mark> option, navigates **Projects** window to the folder where generated files are saved. It should contain mesh, material and prefab asset files:

<div><figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2F74VRiVVuf4O2DCn76OuT%2Fassets.png?alt=media&#x26;token=ae6cc03c-c483-43b4-b20f-06967eabcf4b" alt="" width="387"><figcaption></figcaption></figure> <figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FUL5WrGh4UDYuXeajMBKM%2Fsize.png?alt=media&#x26;token=cb1def90-6d36-4e6d-98bf-90344bdfd846" alt="" width="463"><figcaption></figcaption></figure></div>

Those are all files used by rendering current example scene. No other materials or textures are used and total size of those assets should be about 1.8 MB. It is possible to optimize meshes and reduce generated files size.

One way is to set **Mesh Compression** to the **High** value (not recommended), but the better options is to remove unwanted and unused vertex attributes from the generated mesh:

<figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FVVjnPUDAvdByHwXOAmRq%2Fcompresion_high.png?alt=media&#x26;token=3a0f0b18-912f-4e2b-bd6f-bbb2532ca5bd" alt=""><figcaption></figcaption></figure>

Generated mesh inherits all vertex attributes from the source mesh, and some of them may not be needed any more, for example *<mark style="color:blue;">tangent</mark>* attribute is used in shaders for **Normal/Bump** effect rendering and if lowpoly mesh doesn't need such effect then *<mark style="color:blue;">tangent</mark>* attribute can be removed from it:

<figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FZekRQ1eoZAgfCThJS5FI%2Fasset_components.png?alt=media&#x26;token=969284db-bed1-492f-abb5-66e11ddd4201" alt=""><figcaption></figcaption></figure>

Select **Attributes** dropdown menu, disable **Default** checkbox there (this enables to manually choose attributes) and remove checkbox for the **Tangent**:

<figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FXLoTpAspLnoHriEFuLUg%2Fattribute.png?alt=media&#x26;token=65149c12-b673-4cf5-b265-7cc7a639eea8" alt="" width="173"><figcaption></figcaption></figure>

Click on the **Run** button and check generate asset files size, it should be about 30% less:

<figure><img src="https://3756180815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F5YOwuRZNBMTHfltYFTeO%2Fuploads%2FIRaxDS6rsDfDP8V33qdD%2Fsize_2.png?alt=media&#x26;token=994bbf04-8519-4a09-9026-7b735f72b653" alt="" width="434"><figcaption></figcaption></figure>

If lowpoly meshes will be rendered only with Unlit vertex color shaders, then *<mark style="color:blue;">normal</mark>* and *<mark style="color:blue;">uv</mark>* attributes can be removed too, this reduces generated file size even more.

{% hint style="danger" %}
Be cautious when removing attributes from the mesh, ensure they are never needed.
{% endhint %}

{% hint style="warning" %}
Package included **Preview** shader used for vertex color rendering of the generated lowpoly meshes is a **Lit** shader and requires mesh *<mark style="color:blue;">normal</mark>* attribute. Without it, the shader renders the mesh in black.
{% endhint %}
