> For the complete documentation index, see [llms.txt](https://ipgames.gitbook.io/htrace-wsgi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ipgames.gitbook.io/htrace-wsgi/quick-start-manual/shader-graph-and-custom-shaders-setup.md).

# Shader Graph & Custom Shaders Setup

HTrace WSGI is compatible with Shader Graph and custom shaders as long as they adhere to the naming conventions used by Unity in its own shaders. If an object using a custom shader or a Shader Graph material is missing from voxelization or appears to have an incorrect diffuse color, it is likely that the issue stems from property naming. This guide outlines how to set up shaders to ensure compatibility with voxelization:<br>

## Base Color and Alpha

Each graph or shader must contain a `Vector4` property with a **Reference** named `_BaseColor`, with the **Exposed** checkbox set to true. This property represents the color multiplier for the Base Map in the material inspector UI of Unity’s native Lit shader.

<figure><img src="https://877355991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfjAg5otUNTCfeLUhM6dT%2Fuploads%2FV2dLTkFKG2BCPpOZdNjD%2Fimage.png?alt=media&amp;token=3bfa65df-7bd1-4707-b257-77bdbf607ade" alt="" width="563"><figcaption></figcaption></figure>

**This property is essential for making a surface visible during voxelization, as it serves as the final fallback for surface color and alpha if all other properties are absent.**

If this color multiplier is irrelevant for your shader, you can set all its four components to `1` and multiply any used (connected to the Master Node) node by it. This way, the shader output remains unaltered, but the property will still be registered.

{% hint style="info" %}
You can keep this property (or any other property) disconnected from your graph when working in the editor. However, be aware that it may be stripped during the build process.&#x20;
{% endhint %}

It is crucial that this property is non-zero in the material UI—specifically, the `.w`component must not be zero, and at least one of the `.xyz`components must be non-zero. In other words, a surface will not be voxelized if it is fully transparent or completely black.

<figure><img src="https://877355991-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FfjAg5otUNTCfeLUhM6dT%2Fuploads%2FNVcH2l6CH3ALEWe0vxX9%2Fimage.png?alt=media&amp;token=e5ddda19-dd4c-43f6-b419-534d90af2e2b" alt=""><figcaption></figcaption></figure>

## Texture & Other Properties

When adding additional properties, ensure that they follow Unity’s naming conventions. For example, a simple Lit shader might include the following properties:

* `_BaseColor`: Diffuse color multiplier
* `_BaseColorMap`  (for HDRP) / `_BaseMap` (for URP): Diffuse color texture
* `_BaseColorMap_ST` (for HDRP) / `_BaseMap_ST` (for URP): Diffuse color texture tiling (`.xy`) and offset (`.zw`)
* `_UVBase`: Texture UV channel

Using these properties you can voxelize a textured surface. An example of such shader (for HDRP) can be downloaded here:

{% file src="/files/uuErWE1HL0GSEir6LJ6Q" %}

## Complex Shaders

HTrace WSGI can support complex shaders with layered texturing and additional custom properties. All natively supported properties and their names can be found in `VoxelMaterialEvaluation.hlsl` file. You are free to add your own properties and logic there and customize the exiting ones to fit your needs.

The evaluation of certain shader types can be disabled if they are not required. For example, if your project does not utilize Terrain or Terrain Trees, you can disable the evaluation of the `TerrainLit` and `SpeedTree` shaders. This can be achieved in the `VoxelMaterialEvaluation.hlsl` file by flipping the `#define` toggles of `EVALUATE_`*`SHADERNAME`* to `0`. Disabling unnecessary shader evaluations can speed up the voxelization process in certain scenarios.
