Skip to content

Fog volumetric scattering for path tracing #2110

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 28 commits into from
Oct 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
6520e37
Brought changes from volume branch.
eturquin Sep 23, 2020
3ee9ea2
Merge branch 'HDRP/pt_volmerge' into HDRP/pt_volmerge2
eturquin Sep 23, 2020
2a3f1ab
Minor fixes on cone region of spot lights.
eturquin Sep 23, 2020
7732187
Re-added mistakenly removed headers from the PT pass of Unlit & Lit.
eturquin Sep 23, 2020
8e6ef82
Added clamping on cam ray misses with vol scattering.
eturquin Sep 23, 2020
e55ab5b
Minor tweaks.
eturquin Sep 23, 2020
0b7c2e2
Added support for box and pyramid point lights.
eturquin Sep 25, 2020
ff6005a
Merge branch 'HDRP/staging' into HDRP/pt_pointlightmodes
eturquin Sep 25, 2020
b72d000
Merge branch 'HDRP/pt_pointlightmodes' into HDRP/volmerge3
eturquin Sep 25, 2020
f886432
Merge branch 'HDRP/staging' into HDRP/pt_pointlightmodes
eturquin Oct 2, 2020
68ad43e
Updated changelog.
eturquin Oct 2, 2020
3d6e3d4
Merge branch 'HDRP/pt_pointlightmodes' into HDRP/pt_volmerge3
eturquin Oct 2, 2020
cdcdd65
Added vol light intensity multiplier support.
eturquin Oct 2, 2020
9518789
Merge branch 'HDRP/staging' into HDRP/pt_volmerge3
eturquin Oct 6, 2020
1d5560d
Added support for box and pyramid spot lights.
eturquin Oct 7, 2020
f0a2e4d
Merge branch 'HDRP/staging' into HDRP/pt_volmerge3
eturquin Oct 7, 2020
be03809
Updated Changelog.
eturquin Oct 7, 2020
99237b1
Merge branch 'HDRP/staging' into HDRP/pt_volmerge3
eturquin Oct 13, 2020
00f7a58
Reverted unwanted changes to diffusion profile asset.
eturquin Oct 13, 2020
909f261
...
eturquin Oct 13, 2020
6718735
FFS
eturquin Oct 13, 2020
e65de57
Added better path tracing support in shader graph.
eturquin Oct 14, 2020
c30c3f3
Merge branch 'HDRP/staging' into HDRP/pt_volmerge3
eturquin Oct 14, 2020
2db05b4
Fix PT directional light activation for null radius.
eturquin Oct 14, 2020
9c52ff4
Updated png reference images, to account for sampling seq changes.
eturquin Oct 14, 2020
754d624
Merge branch 'master' into HDRP/pt_volmerge3
eturquin Oct 23, 2020
53801e3
Merge branch 'master' into HDRP/pt_volmerge3
sebastienlagarde Oct 24, 2020
aece7cc
Merge branch 'master' into HDRP/pt_volmerge3
sebastienlagarde Oct 25, 2020
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.
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.
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.
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 @@ -21,6 +21,7 @@ The version number for this package has increased due to a version update of a r
- Added frame setting for Virtual Texturing.
- Added a fade distance for light influencing volumetric lighting.
- Adding an "Include For Ray Tracing" toggle on lights to allow the user to exclude them when ray tracing is enabled in the frame settings of a camera.
- Added fog volumetric scattering support for path tracing.

### Fixed
- Fixed an issue where the Exposure Shader Graph node had clipped text. (case 1265057)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public HDLitData litData
protected override string postDecalsInclude => "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitDecalData.hlsl";
protected override ShaderID shaderID => HDShaderUtils.ShaderID.SG_Lit;
protected override string raytracingInclude => CoreIncludes.kLitRaytracing;
protected override string pathtracingInclude => CoreIncludes.kLitPathtracing;
protected override FieldDescriptor subShaderField => new FieldDescriptor(kSubShader, "Lit Subshader", "");
protected override string subShaderInclude => CoreIncludes.kLit;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1115,8 +1115,8 @@ IncludeCollection GenerateIncludes()

// Each material has a specific hlsl file that should be included pre-graph and holds the lighting model
includes.Add(CoreIncludes.kPassPlaceholder, IncludeLocation.Pregraph);
// We need to then include the ray tracing missing bits for the lighting models (based on which lighting model)
includes.Add(CoreIncludes.kRaytracingPlaceholder, IncludeLocation.Pregraph);
// We need to then include path tracing support for the material
includes.Add(CoreIncludes.kPathtracingPlaceholder, IncludeLocation.Pregraph);

includes.Add(CoreIncludes.CoreUtility);
includes.Add(CoreIncludes.kRaytracingCommon, IncludeLocation.Pregraph);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public SystemData systemData

protected virtual string postDecalsInclude => null;
protected virtual string raytracingInclude => null;
protected virtual string pathtracingInclude => null;
protected virtual bool supportPathtracing => false;
protected virtual bool supportRaytracing => false;

Expand Down Expand Up @@ -148,6 +149,8 @@ protected SubShaderDescriptor PostProcessSubShader(SubShaderDescriptor subShader
include.descriptor.value = postDecalsInclude;
if (include.descriptor.value == CoreIncludes.kRaytracingPlaceholder)
include.descriptor.value = raytracingInclude;
if (include.descriptor.value == CoreIncludes.kPathtracingPlaceholder)
include.descriptor.value = pathtracingInclude;

if (!String.IsNullOrEmpty(include.descriptor.value))
finalIncludes.Add(include.descriptor.value, include.descriptor.location, include.fieldConditions);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -873,6 +873,7 @@ static class CoreIncludes
public const string kRaytracingIntersectionGBuffer = "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/Deferred/RaytracingIntersectonGBuffer.hlsl";
public const string kRaytracingIntersectionSubSurface = "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/SubSurface/RayTracingIntersectionSubSurface.hlsl";
public const string kLitRaytracing = "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitRaytracing.hlsl";
public const string kLitPathtracing = "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitPathTracing.hlsl";
public const string kUnlitRaytracing = "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/UnlitRaytracing.hlsl";
public const string kFabricRaytracing = "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Fabric/FabricRaytracing.hlsl";
public const string kEyeRaytracing = "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Eye/EyeRaytracing.hlsl";
Expand Down Expand Up @@ -913,6 +914,7 @@ static class CoreIncludes
public const string kPassPlaceholder = "Pass Include Placeholder, replace me !";
public const string kPostDecalsPlaceholder = "After Decal Include Placeholder, replace me !";
public const string kRaytracingPlaceholder = "Raytracing Include Placeholder, replace me !";
public const string kPathtracingPlaceholder = "Pathtracing Include Placeholder, replace me !";

// Public Postgraph Pass
public const string kPassLightTransport = "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassLightTransport.hlsl";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef UNITY_LIGHT_EVALUATION_INCLUDED
#define UNITY_LIGHT_EVALUATION_INCLUDED

// This files include various function uses to evaluate lights
// use #define LIGHT_EVALUATION_NO_HEIGHT_FOG to disable Height fog attenuation evaluation
// use #define LIGHT_EVALUATION_NO_COOKIE to disable cookie evaluation
Expand Down Expand Up @@ -582,3 +585,5 @@ void ApplyScreenSpaceReflectionWeight(inout float4 ssrLighting)
ssrLighting.rgb *= ssrLighting.a;
}
#endif

#endif // UNITY_LIGHT_EVALUATION_INCLUDED
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef UNITY_COOKIE_SAMPLING_INCLUDED
#define UNITY_COOKIE_SAMPLING_INCLUDED

//-----------------------------------------------------------------------------
// Cookie sampling functions
// ----------------------------------------------------------------------------
Expand Down Expand Up @@ -47,3 +50,5 @@ float3 SamplePointCookie(float3 lightToSample, float4 scaleOffset, float lod = 0

return SampleCookie2D(uv, scaleOffset, lod);
}

#endif // UNITY_COOKIE_SAMPLING_INCLUDED
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#ifndef UNITY_LIGHT_LOOP_DEF_INCLUDED
#define UNITY_LIGHT_LOOP_DEF_INCLUDED

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoop.cs.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/CookieSampling.hlsl"

Expand Down Expand Up @@ -375,3 +378,5 @@ float3 GetScreenSpaceColorShadow(PositionInputs posInput, int shadowIndex)
float4 res = LOAD_TEXTURE2D_ARRAY(_ScreenSpaceShadowsTexture, posInput.positionSS, INDEX_TEXTURE2D_ARRAY_X(shadowIndex & SCREEN_SPACE_SHADOW_INDEX_MASK));
return (SCREEN_SPACE_COLOR_SHADOW_FLAG & shadowIndex) ? res.xyz : res.xxx;
}

#endif // UNITY_LIGHT_LOOP_DEF_INCLUDED
Original file line number Diff line number Diff line change
Expand Up @@ -1137,19 +1137,17 @@ Shader "HDRP/LayeredLit"

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracing.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracingLightLoop.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl"

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingIntersection.hlsl"

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl"
#define HAS_LIGHTLOOP
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingCommon.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitRaytracing.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/LayeredLit/LayeredLitData.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingCommon.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitPathTracing.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl"

ENDHLSL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1153,26 +1153,24 @@ Shader "HDRP/Lit"

#define SHADERPASS SHADERPASS_PATH_TRACING

// This is just because it need to be defined, shadow maps are not used.
// This is just because it needs to be defined, shadow maps are not used.
#define SHADOW_LOW

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingMacros.hlsl"

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracing.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/ShaderVariablesRaytracingLightLoop.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/Lighting.hlsl"

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/ShaderPass/LitSharePass.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingIntersection.hlsl"

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Lighting/LightLoop/LightLoopDef.hlsl"
#define HAS_LIGHTLOOP
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitRaytracing.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingLightLoop.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RayTracingCommon.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitData.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/LitPathTracing.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl"

ENDHLSL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,9 @@ Shader "HDRP/Unlit"

#define SHADERPASS SHADERPASS_PATH_TRACING

#define SHADER_UNLIT
#define HAS_LIGHTLOOP // Used when computing volumetric scattering

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingMacros.hlsl"

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
Expand All @@ -616,7 +619,6 @@ Shader "HDRP/Unlit"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/RaytracingIntersection.hlsl"

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/Unlit.hlsl"

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Unlit/UnlitData.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/ShaderPass/ShaderPassPathTracing.hlsl"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ RenderAccumulationParameters PrepareRenderAccumulationParameters(HDCamera hdCame

void RenderAccumulation(HDCamera hdCamera, RTHandle inputTexture, RTHandle outputTexture, bool needExposure, CommandBuffer cmd)
{
// Grab the history buffer (hijack the reflections one)
// Grab the history buffer
RTHandle history = hdCamera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.PathTracing)
?? hdCamera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.PathTracing, PathTracingHistoryBufferAllocatorFunction, 1);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1406,7 +1406,7 @@ void RenderAccumulation(RenderGraph renderGraph, HDCamera hdCamera, TextureHandl
{
using (var builder = renderGraph.AddRenderPass<RenderAccumulationPassData>("Render Accumulation", out var passData))
{
// Grab the history buffer (hijack the reflections one)
// Grab the history buffer
TextureHandle history = renderGraph.ImportTexture(hdCamera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.PathTracing)
?? hdCamera.AllocHistoryFrameRT((int)HDCameraFrameHistoryType.PathTracing, PathTracingHistoryBufferAllocatorFunction, 1));

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef UNITY_PATH_TRACING_BSDF_INCLUDED
#define UNITY_PATH_TRACING_BSDF_INCLUDED

#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/PathTracing/Shaders/PathTracingSampling.hlsl"
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/Raytracing/Shaders/SubSurface.hlsl"

#define DELTA_PDF 1000000.0
Expand Down
Loading