Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix recursive mutation bug in ZH Fit version of ProbePropagationIniti…
…alize projection. Dynamic GI Propagation: Sample Neighbors: Use ZH-Fit to convert from SH to our 26-axis basis - it produces results that are a bit closer to our monte carlo naive projection ground truth Dynamic GI: Fix Infinite Bounce calculation after we changed our basis coefficients. We were missing scaling each lobe contribution by that lobes normalized integral. Also delete some dead code that was hanging around in the dynamic GI area for too long, and fix some code erroneously included inside of an ifdef (#109) Dynamic GI probe dirty flag (#111) * Store a dirty flag for each light probe in a volume, update only the ones that had reasons to change since the last update. * Added a setting to Frame Setting to be able to disable dirty flags. * Added debug visualisation of dirty probes of all active volumes. DGI propagation fixes (#112) * Fixed fallback radiance baking when dirty flags are enabled. * Fixed noticeable intensity loss for lower propagation quality due to axis weights renormalization error. * Separate radiance comparison for LogLUV encoding that avoids many false positives in dirty flags. * Fixed propagation data not being cleared when Frame Settings are changed via the settings window causing the pipeline to be destroyed. critical exception fix that was firing on domain reloads & enter play mode transitions
- Loading branch information
1 parent
1bdf5e9
commit ee96637
Showing
25 changed files
with
650 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
...r-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/DebugDirtyFlags.shader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
Shader "Hidden/Debug/DebugDirtyFlags" | ||
{ | ||
Properties | ||
{ | ||
_ProbeVolumeResolution("_ProbeVolumeResolution", Vector) = (0, 0, 0, 0) | ||
_ProbeVolumeProbeDisplayRadiusWS("_ProbeVolumeProbeDisplayRadiusWS", Float) = 1.0 | ||
} | ||
|
||
SubShader | ||
{ | ||
Tags{ "RenderPipeline" = "HDRenderPipeline" "RenderType" = "Opaque" "Queue" = "Transparent" } | ||
ZWrite On | ||
Cull Front | ||
|
||
Pass | ||
{ | ||
Name "ForwardUnlit" | ||
Tags{ "LightMode" = "Forward" } | ||
|
||
HLSLPROGRAM | ||
|
||
#pragma editor_sync_compilation | ||
|
||
#pragma vertex vert | ||
#pragma fragment frag | ||
|
||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl" | ||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl" | ||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Color.hlsl" | ||
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/EntityLighting.hlsl" | ||
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/ProbePropagationGlobals.hlsl" | ||
|
||
struct appdata | ||
{ | ||
uint vertexID : SV_VertexID; | ||
}; | ||
|
||
struct v2f | ||
{ | ||
float4 positionCS : SV_POSITION; | ||
float3 color : COLOR; | ||
float2 uv : TEXCOORD0; | ||
}; | ||
|
||
float3 _ProbeVolumeResolution; | ||
float4x4 _ProbeIndex3DToPositionWSMatrix; | ||
float _ProbeVolumeProbeDisplayRadiusWS; | ||
StructuredBuffer<int> _ProbeVolumeDirtyFlags; | ||
|
||
uint3 ComputeWriteIndexFromReadIndex(uint readIndex, float3 resolution) | ||
{ | ||
// _ProbeVolumeAtlasReadBuffer[z * resolutionY * resolutionX + y * resolutionX + x] | ||
// TODO: Could implement as floating point operations, which is likely faster. | ||
// Would need to verify precision. | ||
uint x = readIndex % (uint)resolution.x; | ||
uint y = (readIndex / (uint)resolution.x) % (uint)resolution.y; | ||
uint z = readIndex / ((uint)resolution.y * (uint)resolution.x); | ||
|
||
return uint3(x, y, z); | ||
} | ||
|
||
v2f vert(appdata v) | ||
{ | ||
v2f o; | ||
|
||
uint probeIndex1D = v.vertexID / 6u; | ||
uint probeTriangleIndex = (v.vertexID / 3u) & 1u; | ||
uint probeVertexIndex = v.vertexID - probeIndex1D * 6u - probeTriangleIndex * 3u; | ||
|
||
bool dirty = IsProbeDirty(_ProbeVolumeDirtyFlags, probeIndex1D); | ||
|
||
float2 vertexPositionOS = (probeTriangleIndex == 1u) | ||
? float2((probeVertexIndex & 1u), saturate(probeVertexIndex)) | ||
: float2(saturate(probeVertexIndex), saturate((float)probeVertexIndex - 1.0)); | ||
o.uv = vertexPositionOS; | ||
vertexPositionOS = vertexPositionOS * 2.0 - 1.0; | ||
vertexPositionOS *= _ProbeVolumeProbeDisplayRadiusWS; | ||
|
||
float3 probeIndex3D = ComputeWriteIndexFromReadIndex(probeIndex1D, _ProbeVolumeResolution); | ||
float3 probeOriginWS = mul(_ProbeIndex3DToPositionWSMatrix, float4(probeIndex3D, 1.0)).xyz; | ||
float3 probeOriginRWS = GetCameraRelativePositionWS(probeOriginWS); | ||
|
||
float3 cameraRightWS = mul(float4(1.0, 0.0, 0.0, 0.0), UNITY_MATRIX_V).xyz; | ||
float3 cameraUpWS = mul(float4(0.0, 1.0, 0.0, 0.0), UNITY_MATRIX_V).xyz; | ||
|
||
float3 positionRWS = (cameraRightWS * vertexPositionOS.x + cameraUpWS * vertexPositionOS.y) + probeOriginRWS; | ||
|
||
o.color = dirty ? float3(1, 0.5, 0) : float3(0.5, 0, 0); | ||
o.positionCS = TransformWorldToHClip(positionRWS); | ||
|
||
return o; | ||
} | ||
|
||
void ClipProbeSphere(float2 uv) | ||
{ | ||
float2 positionProbeCard = uv * 2.0 - 1.0; | ||
clip(dot(positionProbeCard, positionProbeCard) < 1.0 ? 1.0 : -1.0); | ||
} | ||
|
||
float4 frag(v2f i) : SV_Target | ||
{ | ||
ClipProbeSphere(i.uv); | ||
return float4(i.color, 1.0); | ||
} | ||
|
||
ENDHLSL | ||
} | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
...elines.high-definition/Runtime/Lighting/ProbeVolume/DynamicGI/DebugDirtyFlags.shader.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.