Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SG2]Imposter nodes and documents #7865

Open
wants to merge 21 commits into
base: sg2/main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions com.unity.sg2/Documentation~/Imposter-Sample-Node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Imposter Sample Node

## Description

The Imposter Sample Node utilizes the three virtual UVs to sample the imposter texture and blends them based on the camera intersection point on the octahedron sphere, thereby achieving accurate sampling results.
tracychen1234 marked this conversation as resolved.
Show resolved Hide resolved
## Ports

| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| Texture | Input | Texture2D | The texture asset to sample |
tracychen1234 marked this conversation as resolved.
Show resolved Hide resolved
| Sampler | Input | Sampler State | The texture sampler to use for sampling the texture |
| UV0 | Input | Vector4 | The virtual UV for the base frame |
tracychen1234 marked this conversation as resolved.
Show resolved Hide resolved
| UV1 | Input | Vector4 | The virtual UV for the second frame |
| UV2 | Input | Vector4 | The virtual UV for the third frame |
| Grid | Input | Vector4 | The current UV grid, which is used to find the corresponding sample frames |
| Frames | Input | Float | The amount of the imposter frames |
| Clip | Input | Float | The amount of clipping for a single frame |
| Parallax | Input | Float | Parallax strength|
| Height Map Channel | Input | Int | The channle of the height map to sample for parallax mapping, if any|
| RGBA | Output | Vector3 | A vector4 from the sampled texture |
tracychen1234 marked this conversation as resolved.
Show resolved Hide resolved

## Controls

The Imposter Sample Node [!include[nodes-controls](./snippets/nodes-controls.md)]

<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Sample Type</strong></th>
<th colspan="2"><strong>Description</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="3"><strong>Type</strong></td>
<td rowspan="3">Dropdown</td>
<td colspan="2">Select whether to sample three frames or one frame.</td>
</tr>
<tr>
<td><strong>Three Frames</strong></td>
<td>Blends between three frames to get the smoothest result.</td>
</tr>
<tr>
<td><strong>One Frame</strong></td>
<td>Calculates only one frame for better performance.</td>
</tr>
</tbody>
</table>

## Generated code example

[!include[nodes-generated-code](./snippets/nodes-generated-code.md)], based on the selected Mode on the Imposter Sample Node node:

### ThreeFrames

```
ImposterSample(HeightMapChannel, ViewDirectionTS, Parallax, Frames, Texture.tex, Texture.texelSize, Clip, Grid, UV0, UV1, UV2, Sampler.samplerstate, RGBA);
```

### OneFrame

```
ImposterSample_oneFrame(HeightMapChannel, ViewDirectionTS, Parallax, Frames, Texture.tex, Texture.texelSize, Clip, Grid, UV0, Sampler.samplerstate, RGBA);
```
65 changes: 65 additions & 0 deletions com.unity.sg2/Documentation~/Imposter-UV-Node.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Imposter UV Node

## Description

The Imposter UV Node calculates the billboard positon and the virtual UVs for sampling.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about we say: "The Imposter UV Node calculates the billboard position (fix the typo in this word) and the UV coordinates needed by the Imposter Sample node." We need to indicate that data output here is intended specifically for the Imposter Sample node.

## Ports

| Name | Direction | Type | Description |
|:------------ |:-------------|:-----|:---|
| In Position | Input | Vector3 | The postion in Object space |
| UV | Input | Vector4 | The UV coordinates of the mesh |
| Frames | Input | Float | The amount of the imposter frames |
tracychen1234 marked this conversation as resolved.
Show resolved Hide resolved
| Offset | Input | Float | The offset value from the pivot |
tracychen1234 marked this conversation as resolved.
Show resolved Hide resolved
| Size | Input | Float | The size of the imposter |
tracychen1234 marked this conversation as resolved.
Show resolved Hide resolved
| HemiSphere | Input | Boolean | If it's true, calculates the imposter grid and UVs base on hemisphere type |
tracychen1234 marked this conversation as resolved.
Show resolved Hide resolved
| Out Positon | Output | Vector3 | The output billboard position |
| UV0 | Output | Vector4 | The virtual UV for the base frame |
| UV1 | Output | Vector4 | The virtual UV for the second frame |
tracychen1234 marked this conversation as resolved.
Show resolved Hide resolved
| UV2 | Output | Vector4 | The virtual UV for the third frame |
| Grid | Output | Vector4 | The current UV grid, which is used to find the corresponding sample frames |


## Controls

The Imposter UV Node [!include[nodes-controls](./snippets/nodes-controls.md)]

<table>
<thead>
<tr>
<th><strong>Name</strong></th>
<th><strong>Sample Type</strong></th>
<th colspan="2"><strong>Description</strong></th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan="3"><strong>Type</strong></td>
<td rowspan="3">Dropdown</td>
<td colspan="2">Select whether to sample three frames or one frame.</td>
</tr>
<tr>
<td><strong>Three Frames</strong></td>
<td>Blends between three frames to get the smoothest result.</td>
</tr>
<tr>
<td><strong>One Frame</strong></td>
<td>Calculates only one frame for better performance.</td>
</tr>
</tbody>
</table>

## Generated code example

[!include[nodes-generated-code](./snippets/nodes-generated-code.md)], based on the selected Mode on the Imposter Sample Node node:

### ThreeFrames

```
ImposterUV(Pos, inUV, Frames, Offset, Size, HemiSphere, OutPos, Grid, UV0, UV1, UV2)```

### OneFrame

```
ImposterUV_oneFrame(Pos, inUV, Frames, Offset, Size, HemiSphere, OutPos, Grid, UV0);
```
19 changes: 19 additions & 0 deletions com.unity.sg2/Documentation~/previews/ImposterSample.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Description
Samples from the three virtual UVs and blends them base on the camera intersection point to get the correct result.
tracychen1234 marked this conversation as resolved.
Show resolved Hide resolved
## Inputs
**Texture** - The texture asset to sample.
**Sampler** - The texture sampler to use for sampling the texture.
**UV0** - The virtual UV for the base frame.
**UV1** - The virtual UV for the second frame.
**UV2** - The virtual UV for the third frame.
**Grid** - The current UV grid, which is used to find the corresponding sample frames.
**Frames** - The amount of the imposter frames
**Clip** - The amount of clipping for a single frame.
**Parallax** - Parallax strength.
**Height Map Channel** - The channle of the height map to sample for parallax mapping, if any.

## Output
**RGBA** - A vector4 from the sampled texture.

## Controls
**Sample Type** - Select whether to sample three frames or one frame, three frames for smoother result, one frame for better performance.
20 changes: 20 additions & 0 deletions com.unity.sg2/Documentation~/previews/ImposterUV.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Description
Calculates the billboard positon and the virtual UVs for sampling.

## Inputs
**InPosition** - The postion in Object space.
**UV** - The UV coordinates of the mesh.
**Frames** - The amount of the imposter frames
**Offset** - The offset value from the pivot.
**Size** - The size of the imposter.
**HemiSphere** - If it's true, calculates the imposter grid and UVs base on hemisphere type.

## Output
**OutPosition** - The output billboard position.
**UV0** - The virtual UV for the base frame.
**UV1** - The virtual UV for the second frame.
**UV2** - The virtual UV for the third frame.
**Grid** - The current UV grid using to find the sample frames.

## Controls
**Sample Type** - Select whether to sample three frames or one frame, three frames for smoother result, one frame for better performance.
Loading