Skip to content

[HDRP][Path Tracing] Environment (sky) importance sampling #6472

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

Merged
merged 48 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
76b50e7
WIP...
eturquin Nov 16, 2021
b213335
Merge branch 'master' into hd/pt_env
eturquin Nov 22, 2021
b4d3eb7
...
eturquin Nov 22, 2021
c499d8a
Merge branch 'master' into hd/pt_env
eturquin Nov 24, 2021
ba920cd
Refactor.
eturquin Nov 25, 2021
e11b49f
WIP...
eturquin Nov 26, 2021
fe8e106
Merge branch 'master' into hd/pt_env
eturquin Nov 29, 2021
1251aca
Added marginal texture.
eturquin Nov 29, 2021
62b19bf
Data generation (almost) complete.
eturquin Nov 30, 2021
9f51ee3
First working version.
eturquin Dec 2, 2021
8449a60
Further polish.
eturquin Dec 2, 2021
c042184
...
eturquin Dec 2, 2021
a8320fe
...
eturquin Dec 2, 2021
e415110
Added dichotomic search.
eturquin Dec 2, 2021
a8554cf
Merge branch 'master' into hd/pt_env
eturquin Dec 2, 2021
0bbeeb5
Fixed visibility in light evaluation.
eturquin Dec 2, 2021
18f36da
Removed unused code (incl. PDF storage).
eturquin Dec 3, 2021
ad72235
Merge branch 'master' into hd/pt_env
eturquin Dec 3, 2021
af67cf0
Updated changelog.
eturquin Dec 3, 2021
1b7dff5
Fixed Jacobian.
eturquin Dec 3, 2021
0251252
Removed commented out code.
eturquin Dec 3, 2021
a28ee58
Fixed volume attenuation on env light eval.
eturquin Dec 3, 2021
9ec3049
Renamed variables only used in path tracing.
eturquin Dec 6, 2021
7387b80
Only activate sky importance sampling for HDRIs.
eturquin Dec 6, 2021
cbebdde
Merge branch 'master' into hd/pt_env
eturquin Dec 6, 2021
4e49fc7
Updated ref images that use HDRIs.
eturquin Dec 6, 2021
9d2375c
Fixed formatting.
eturquin Dec 6, 2021
60736cd
Cosmetic.
eturquin Dec 6, 2021
67c8748
Merge branch 'master' into hd/pt_env
eturquin Dec 6, 2021
292580a
Merge branch 'master' into hd/pt_env
eturquin Dec 7, 2021
f983247
Update HDRP resources asset.
eturquin Dec 7, 2021
68b7f0d
Fixed sky auto-exposure mismatch.
eturquin Dec 8, 2021
eb676d2
Updated changelog.
eturquin Dec 8, 2021
c23cc26
Fixed camera clear color.
eturquin Dec 8, 2021
f6e11e1
Merge branch 'master' into hd/pt_env
eturquin Dec 8, 2021
b14a590
Merge branch 'hd/pt_sky_exposure' into hd/pt_env
eturquin Dec 8, 2021
26d234e
Fixed unlit transparent.
eturquin Dec 8, 2021
cf815b1
Minor clean up.
eturquin Dec 8, 2021
4f56bfd
Merge branch 'master' into hd/pt_env
eturquin Dec 9, 2021
35843df
Changed intensity clamping method.
eturquin Dec 10, 2021
6a919ad
Added sky importance sampling parameter.
eturquin Dec 13, 2021
a99ec3e
Merge branch 'master' into hd/pt_env
eturquin Dec 13, 2021
e04e9d5
Reordered params.
eturquin Dec 13, 2021
e1c1182
Improved robustness with null PDFs.
eturquin Dec 14, 2021
df41b49
...
eturquin Dec 14, 2021
995ac0c
Updated doc with section on sky sampling.
eturquin Dec 14, 2021
31b9050
Merge branch 'master' into hd/pt_env
eturquin Dec 14, 2021
5feda73
Cosmetic.
eturquin Dec 14, 2021
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added FSR sharpness override to camera and pipeline asset.
- Added an option on the lit shader to perform Planar and Triplanar mapping in Object Space.
- Added a button in the Probe Volume Baking window to open the Probe Volume debug panel.
- Added importance sampling of the sky in path tracing (aka environment sampling).

### Fixed
- Fixed some XR devices: Pulling camera world space position from mainViewConstants instead of transform.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ Path tracing uses the [Volume](Volumes.md) framework, so to enable this feature,

## Properties

| Property | Description |
| --------------------- | ------------------------------------------------------------ |
| **Maximum Samples** | Set the number of frames to accumulate for the final image. There is a progress bar at the bottom of the Scene view which indicates the current accumulation with respect to this value. |
| **Minimum Depth** | Set the minimum number of light bounces in each path. |
| **Maximum Depth** | Set the maximum number of light bounces in each path. You can not set this to be lower than Minimum Depth.<br /> **Note**: You can set this and Minimum Depth to 1 if you only want to direct lighting. You can set them both to 2 if you only want to visualize indirect lighting (which is only visible on the second bounce). |
| **Maximum Intensity** | Set a value to clamp the intensity of the light value each bounce returns. This avoids very bright, isolated pixels in the final result.<br />**Note**: This property makes the final image dimmer, so if the result looks dark, increase the value of this property. |
| Property | Description |
| --------------------------- | ------------------------------------------------------------ |
| **Maximum Samples** | Set the number of frames to accumulate for the final image. There is a progress bar at the bottom of the Scene view which indicates the current accumulation with respect to this value. |
| **Minimum Depth** | Set the minimum number of light bounces in each path. |
| **Maximum Depth** | Set the maximum number of light bounces in each path. You can not set this to be lower than Minimum Depth.<br /> **Note**: You can set this and Minimum Depth to 1 if you only want to direct lighting. You can set them both to 2 if you only want to visualize indirect lighting (which is only visible on the second bounce). |
| **Maximum Intensity** | Set a value to clamp the intensity of the light value each bounce returns. This avoids very bright, isolated pixels in the final result.<br />**Note**: This property can make the final image dimmer, so if the result looks dark, increase the value of this property. |
| **Sky Importance Sampling** | Set the sky sampling mode. Importance sampling favors the brightest directions, which is beneficial when using a sky model with high contrast and very intense spots (like a sun, or street lights). On the other hand, it can be slightly detrimental when using a smooth, uniform sky. It is active by default for HDRI skies only, but can also be turned On and Off, regardless of the type of sky in use. |

![](Images/RayTracingPathTracing4.png)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class PathTracingEditor : VolumeComponentEditor
SerializedDataParameter m_MinDepth;
SerializedDataParameter m_MaxDepth;
SerializedDataParameter m_MaxIntensity;
SerializedDataParameter m_SkyImportanceSampling;

public override void OnEnable()
{
Expand All @@ -28,6 +29,7 @@ public override void OnEnable()
m_MinDepth = Unpack(o.Find(x => x.minimumDepth));
m_MaxDepth = Unpack(o.Find(x => x.maximumDepth));
m_MaxIntensity = Unpack(o.Find(x => x.maximumIntensity));
m_SkyImportanceSampling = Unpack(o.Find(x => x.skyImportanceSampling));
}

public override void OnInspectorGUI()
Expand All @@ -54,6 +56,7 @@ public override void OnInspectorGUI()
PropertyField(m_MinDepth);
PropertyField(m_MaxDepth);
PropertyField(m_MaxIntensity);
PropertyField(m_SkyImportanceSampling);
}

// Make sure MaxDepth is always greater or equal than MinDepth
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public HDRenderPipeline(HDRenderPipelineAsset asset)
InitRayTracedIndirectDiffuse();
InitRaytracingDeferred();
InitRecursiveRenderer();
InitPathTracing(m_RenderGraph);
InitPathTracing();
InitRayTracingAmbientOcclusion();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ partial class HDRenderPipelineRayTracingResources : HDRenderPipelineResources

// Path Tracing
[Reload("Runtime/RenderPipeline/PathTracing/Shaders/PathTracingMain.raytrace")]
public RayTracingShader pathTracing;
public RayTracingShader pathTracingRT;
[Reload("Runtime/RenderPipeline/PathTracing/Shaders/PathTracingSkySamplingData.compute")]
public ComputeShader pathTracingSkySamplingDataCS;

// Ray Marching
[Reload("Runtime/RenderPipeline/Raytracing/Shaders/RayMarching.compute")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,12 @@ static class HDShaderIDs
public static readonly int _InvViewportScaleBias = Shader.PropertyToID("_InvViewportScaleBias");
public static readonly int _PathTracingDoFParameters = Shader.PropertyToID("_PathTracingDoFParameters");
public static readonly int _PathTracingTilingParameters = Shader.PropertyToID("_PathTracingTilingParameters");
public static readonly int _PathTracingCameraSkyEnabled = Shader.PropertyToID("_PathTracingCameraSkyEnabled");
public static readonly int _PathTracingCameraClearColor = Shader.PropertyToID("_PathTracingCameraClearColor");
public static readonly int _PathTracingSkyTextureWidth = Shader.PropertyToID("_PathTracingSkyTextureWidth");
public static readonly int _PathTracingSkyTextureHeight = Shader.PropertyToID("_PathTracingSkyTextureHeight");
public static readonly int _PathTracingSkyCDFTexture = Shader.PropertyToID("_PathTracingSkyCDFTexture");
public static readonly int _PathTracingSkyMarginalTexture = Shader.PropertyToID("_PathTracingSkyMarginalTexture");

// Light Cluster
public static readonly int _LightDatasRT = Shader.PropertyToID("_LightDatasRT");
Expand Down Expand Up @@ -740,8 +746,6 @@ static class HDShaderIDs
// Primary Visibility
public static readonly int _RaytracingFlagMask = Shader.PropertyToID("_RaytracingFlagMask");
public static readonly int _RaytracingPrimaryDebug = Shader.PropertyToID("_RaytracingPrimaryDebug");
public static readonly int _RaytracingCameraSkyEnabled = Shader.PropertyToID("_RaytracingCameraSkyEnabled");
public static readonly int _RaytracingCameraClearColor = Shader.PropertyToID("_RaytracingCameraClearColor");

// Indirect diffuse
public static readonly int _IndirectDiffuseTexture = Shader.PropertyToID("_IndirectDiffuseTexture");
Expand Down
Loading