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

[HDRP] APV - Fix voxelization issues with planes at the origin #5897

Merged
merged 6 commits into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,8 @@ public void Initialize(ProbeReferenceVolumeProfile profile, Vector3 refVolOrigin
if ((flags & StaticEditorFlags.ContributeGI) == 0)
continue;

var volume = ProbePlacement.ToVolume(r.bounds);
// Inflate a bit the volume in case it's too small (plane case)
var volume = ProbePlacement.ToVolume(new Bounds(r.bounds.center, r.bounds.size + Vector3.one * 0.01f));

renderers.Add((r, volume));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Shader "Hidden/ProbeVolume/VoxelizeScene"
Tags { "RenderType"="Opaque" }
LOD 100

HLSLINCLUDE
#define EPSILON (1e-10)
ENDHLSL

Pass
{
Name "Voxelize Mesh"
Expand Down Expand Up @@ -68,10 +72,10 @@ Shader "Hidden/ProbeVolume/VoxelizeScene"

float4 frag(VertexToFragment i) : COLOR
{
if (any(i.cellPos01 < 0) || any(i.cellPos01 >= 1))
if (any(i.cellPos01 < -EPSILON) || any(i.cellPos01 >= 1 + EPSILON))
return 0;

uint3 pos = uint3(i.cellPos01 * _OutputSize);
uint3 pos = min(uint3(i.cellPos01 * _OutputSize), _OutputSize);

_Output[pos] = 1;

Expand All @@ -93,7 +97,7 @@ Shader "Hidden/ProbeVolume/VoxelizeScene"
#pragma vertex vert
#pragma fragment frag
#pragma target 4.5
#pragma enable_d3d11_debug_symbols
// #pragma enable_d3d11_debug_symbols

#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"

Expand Down Expand Up @@ -167,14 +171,14 @@ Shader "Hidden/ProbeVolume/VoxelizeScene"

float4 frag(VertexToFragment i) : COLOR
{
if (any(i.cellPos01 < 0) || any(i.cellPos01 >= 1))
if (any(i.cellPos01 < -EPSILON) || any(i.cellPos01 >= 1 + EPSILON))
return 0;

// Offset the cellposition with the heightmap
float hole = _TerrainHolesTexture.Sample(s_point_clamp_sampler, float3(i.uv, 0));
clip(hole == 0.0f ? -1 : 1);

uint3 pos = uint3(i.cellPos01 * _OutputSize);
uint3 pos = min(uint3(i.cellPos01 * _OutputSize), _OutputSize);
_Output[pos] = 1;

return float4(i.cellPos01.xyz, 1);
Expand Down
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed the clouds not taking properly into account the fog when in distant mode and with a close far plane (case 1367993).
- Fixed overwriting of preview camera background color. [case 1357004](https://issuetracker.unity3d.com/product/unity/issues/guid/1361557/)
- Fixed selection of light types (point, area, directional) for path-traced Unlit shadow mattes.
- Fixed precision issues with the scene voxelization for APV, especially with geometry at the origin.

## [13.0.0] - 2021-09-01

Expand Down