Skip to content

Reducing the number of variants for ray tracing when building a player #94

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 7 commits into from
Apr 17, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Added support for POM for emissive map
- Added alpha channel support in motion blur pass.
- Added the HDRP Compositor Tool (in Preview).
- Added a ray tracing mode option in the HDRP asset that allows to override and shader stripping.

### Fixed
- Fix when rescale probe all direction below zero (1219246)
Expand Down Expand Up @@ -658,6 +659,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Updated shaders to be compatible with Microsoft's DXC.
- Debug exposure in debug menu have been replace to debug exposure compensation in EV100 space and is always visible.
- Further optimized PrepareLightsForGPU (3x faster with few shadows, 1.4x faster with a lot of shadows or equivalently cost reduced by 68% to 37%).
- Raytracing: Replaced the DIFFUSE_LIGHTING_ONLY multicompile by a uniform.
- Raytracing: Removed the dynamic lightmap multicompile.
- Raytracing: Remove the LOD cross fade multi compile for ray tracing.

## [7.1.1] - 2019-09-05

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,25 +100,39 @@ public override void OnInspectorGUI()
PropertyField(m_LayerMask, EditorGUIUtility.TrTextContent("Layer Mask", "Layer mask used to include the objects for screen space reflection."));
PropertyField(m_RayLength, EditorGUIUtility.TrTextContent("Ray Length", "Controls the length of reflection rays."));
PropertyField(m_ClampValue, EditorGUIUtility.TrTextContent("Clamp Value", "Clamps the exposed intensity."));
PropertyField(m_Mode, EditorGUIUtility.TrTextContent("Mode", "Controls which version of the effect should be used."));

EditorGUI.indentLevel++;
switch (m_Mode.value.GetEnumValue<RayTracingMode>())
if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Both)
{
case RayTracingMode.Performance:
{
PropertyField(m_UpscaleRadius, EditorGUIUtility.TrTextContent("Upscale Radius", "Controls the size of the upscale radius."));
PropertyField(m_FullResolution, EditorGUIUtility.TrTextContent("Full Resolution", "Enables full resolution mode."));
}
break;
case RayTracingMode.Quality:
PropertyField(m_Mode, EditorGUIUtility.TrTextContent("Mode", "Controls which version of the effect should be used."));
EditorGUI.indentLevel++;
switch (m_Mode.value.GetEnumValue<RayTracingMode>())
{
PropertyField(m_SampleCount, EditorGUIUtility.TrTextContent("Sample Count", "Number of samples for reflections."));
PropertyField(m_BounceCount, EditorGUIUtility.TrTextContent("Bounce Count", "Number of bounces for reflection rays."));
case RayTracingMode.Performance:
{
PropertyField(m_UpscaleRadius, EditorGUIUtility.TrTextContent("Upscale Radius", "Controls the size of the upscale radius."));
PropertyField(m_FullResolution, EditorGUIUtility.TrTextContent("Full Resolution", "Enables full resolution mode."));
}
break;
case RayTracingMode.Quality:
{
PropertyField(m_SampleCount, EditorGUIUtility.TrTextContent("Sample Count", "Number of samples for reflections."));
PropertyField(m_BounceCount, EditorGUIUtility.TrTextContent("Bounce Count", "Number of bounces for reflection rays."));
}
break;
}
break;
EditorGUI.indentLevel--;
}
else if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Quality)
{
PropertyField(m_SampleCount, EditorGUIUtility.TrTextContent("Sample Count", "Number of samples for reflections."));
PropertyField(m_BounceCount, EditorGUIUtility.TrTextContent("Bounce Count", "Number of bounces for reflection rays."));
}
else
{
PropertyField(m_UpscaleRadius, EditorGUIUtility.TrTextContent("Upscale Radius", "Controls the size of the upscale radius."));
PropertyField(m_FullResolution, EditorGUIUtility.TrTextContent("Full Resolution", "Enables full resolution mode."));
}
EditorGUI.indentLevel--;

PropertyField(m_Denoise, EditorGUIUtility.TrTextContent("Denoise", "Enable denoising on the ray traced reflections."));
{
EditorGUI.indentLevel++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public class GeneralSection
public static readonly GUIContent supportTransparentDepthPrepass = EditorGUIUtility.TrTextContent("Transparent Depth Prepass", "When disabled, HDRP removes all transparent depth prepass Shader variants when you build for the Unity Player. This decreases build time.");
public static readonly GUIContent supportTransparentDepthPostpass = EditorGUIUtility.TrTextContent("Transparent Depth Postpass", "When disabled, HDRP removes all transparent depth postpass Shader variants when you build for the Unity Player. This decreases build time.");
public static readonly GUIContent supportRaytracing = EditorGUIUtility.TrTextContent("Realtime Raytracing (Preview)");
public static readonly GUIContent supportedRayTracingMode = EditorGUIUtility.TrTextContent("Supported Ray Tracing Mode (Preview)");
public static readonly GUIContent rayTracingUnsupportedWarning = EditorGUIUtility.TrTextContent("Ray tracing is not supported on your device. Please refer to the documentation.");
public static readonly GUIContent maximumLODLevel = EditorGUIUtility.TrTextContent("Maximum LOD Level");
public static readonly GUIContent LODBias = EditorGUIUtility.TrTextContent("LOD Bias");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,13 @@ static void Drawer_SectionRenderingUnsorted(SerializedHDRenderPipelineAsset seri
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.supportRayTracing, Styles.supportRaytracing);
using (new EditorGUI.DisabledScope(!serialized.renderPipelineSettings.supportRayTracing.boolValue))
{
++EditorGUI.indentLevel;
EditorGUILayout.PropertyField(serialized.renderPipelineSettings.supportedRayTracingMode, Styles.supportedRayTracingMode);
if (serialized.renderPipelineSettings.supportRayTracing.boolValue && !UnityEngine.SystemInfo.supportsRayTracing)
{
EditorGUILayout.HelpBox(Styles.rayTracingUnsupportedWarning.text, MessageType.Warning, wide: true);
}
--EditorGUI.indentLevel;
}

serialized.renderPipelineSettings.lodBias.ValueGUI<float>(Styles.LODBias);
Expand Down Expand Up @@ -1011,6 +1014,7 @@ static void SupportedSettingsInfoSection(SerializedHDRenderPipelineAsset seriali
AppendSupport(builder, serialized.renderPipelineSettings.supportTransparentDepthPostpass, Styles.supportTransparentDepthPostpass);
AppendSupport(builder, serialized.renderPipelineSettings.supportRayTracing, Styles.supportRaytracing);
AppendSupport(builder, serialized.renderPipelineSettings.supportProbeVolume, Styles.supportProbeVolumeContent);
AppendSupport(builder, serialized.renderPipelineSettings.supportedRayTracingMode, Styles.supportedRayTracingMode);

EditorGUILayout.HelpBox(builder.ToString(), MessageType.Info, wide: true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,38 @@ public override void OnInspectorGUI()
PropertyField(m_LayerMask);
PropertyField(m_RayLength);
PropertyField(m_ClampValue);
PropertyField(m_Mode);

EditorGUI.indentLevel++;
switch (m_Mode.value.GetEnumValue<RayTracingMode>())
if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Both)
{
case RayTracingMode.Performance:
{
PropertyField(m_FullResolution);
PropertyField(m_UpscaleRadius);
}
break;
case RayTracingMode.Quality:
{
PropertyField(m_SampleCount);
PropertyField(m_BounceCount);
}
break;
PropertyField(m_Mode);
EditorGUI.indentLevel++;
switch (m_Mode.value.GetEnumValue<RayTracingMode>())
{
case RayTracingMode.Performance:
{
PropertyField(m_FullResolution);
PropertyField(m_UpscaleRadius);
}
break;
case RayTracingMode.Quality:
{
PropertyField(m_SampleCount);
PropertyField(m_BounceCount);
}
break;
}
EditorGUI.indentLevel--;
}
else if (currentAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Quality)
{
PropertyField(m_SampleCount);
PropertyField(m_BounceCount);
}
else
{
PropertyField(m_FullResolution);
PropertyField(m_UpscaleRadius);
}
EditorGUI.indentLevel--;

PropertyField(m_Denoise);
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ protected override bool DoShadersStripper(HDRenderPipelineAsset hdrpAsset, Shade
|| snippet.passName == "SubSurfaceDXR")
return true;
}
else
{
// If we only support Performance mode, we do not want the indirectDXR shader
if (hdrpAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Performance
&& snippet.passName == "IndirectDXR")
return true;

// If we only support Quality mode, we do not want the indirectDXR shader
if (hdrpAsset.currentPlatformRenderPipelineSettings.supportedRayTracingMode == RenderPipelineSettings.SupportedRayTracingMode.Quality
&& snippet.passName == "GBufferDXR")
return true;
}

return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class SerializedRenderPipelineSettings
public SerializedProperty supportDitheringCrossFade;
public SerializedProperty supportTerrainHole;
public SerializedProperty supportRayTracing;
public SerializedProperty supportedRayTracingMode;
public SerializedProperty supportDistortion;
public SerializedProperty supportTransparentBackface;
public SerializedProperty supportTransparentDepthPrepass;
Expand Down Expand Up @@ -115,6 +116,7 @@ public SerializedRenderPipelineSettings(SerializedProperty root)
supportProbeVolume = root.Find((RenderPipelineSettings s) => s.supportProbeVolume);

supportRayTracing = root.Find((RenderPipelineSettings s) => s.supportRayTracing);
supportedRayTracingMode = root.Find((RenderPipelineSettings s) => s.supportedRayTracingMode);

lightLoopSettings = new SerializedGlobalLightLoopSettings(root.Find((RenderPipelineSettings s) => s.lightLoopSettings));
hdShadowInitParams = new SerializedHDShadowInitParameters(root.Find((RenderPipelineSettings s) => s.hdShadowInitParams));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine.Rendering;
Expand Down Expand Up @@ -541,6 +541,15 @@ static class CoreKeywords
{ CoreKeywordDescriptors.AlphaTest, new FieldCondition(Fields.AlphaTest, true) },
};

public static KeywordCollection HDBaseNoCrossFade = new KeywordCollection
Copy link
Contributor

Choose a reason for hiding this comment

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

poking @Kink3d and @alelievr about this PR that affect shader graph and have been merged into HDRP/staging

{
{ CoreKeywordDescriptors.SurfaceTypeTransparent },
{ CoreKeywordDescriptors.BlendMode },
{ CoreKeywordDescriptors.DoubleSided, new FieldCondition(HDFields.SubShader.Unlit, false) },
{ CoreKeywordDescriptors.FogOnTransparent },
{ CoreKeywordDescriptors.AlphaTest, new FieldCondition(Fields.AlphaTest, true) },
};

public static KeywordCollection Lightmaps = new KeywordCollection
{
{ CoreKeywordDescriptors.Lightmap },
Expand Down Expand Up @@ -578,14 +587,13 @@ static class CoreKeywords

public static KeywordCollection RaytracingIndirect = new KeywordCollection
{
{ HDBase },
{ CoreKeywordDescriptors.DiffuseLightingOnly },
{ HDBaseNoCrossFade },
{ Lightmaps },
};

public static KeywordCollection RaytracingGBufferForward = new KeywordCollection
{
{ HDBase },
{ HDBaseNoCrossFade },
{ Lightmaps },
};
}
Expand Down Expand Up @@ -871,15 +879,6 @@ static class CoreKeywordDescriptors
scope = KeywordScope.Global,
};

public static KeywordDescriptor DiffuseLightingOnly = new KeywordDescriptor()
{
displayName = "Diffuse Lighting Only",
referenceName = "DIFFUSE_LIGHTING_ONLY",
type = KeywordType.Boolean,
definition = KeywordDefinition.MultiCompile,
scope = KeywordScope.Global,
};

public static KeywordDescriptor LightLayers = new KeywordDescriptor()
{
displayName = "Light Layers",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,9 +460,6 @@ Shader "HDRP/LayeredLit"
#pragma shader_feature_local _MATERIAL_FEATURE_SUBSURFACE_SCATTERING
#pragma shader_feature_local _MATERIAL_FEATURE_TRANSMISSION

// enable dithering LOD crossfade
#pragma multi_compile _ LOD_FADE_CROSSFADE

//-------------------------------------------------------------------------------------
// Define
//-------------------------------------------------------------------------------------
Expand Down Expand Up @@ -534,6 +531,7 @@ Shader "HDRP/LayeredLit"
//enable GPU instancing support
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer
#pragma multi_compile _ LOD_FADE_CROSSFADE

// Note: Require _ObjectId and _PassValue variables

Expand Down Expand Up @@ -576,6 +574,7 @@ Shader "HDRP/LayeredLit"
//enable GPU instancing support
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer
#pragma multi_compile _ LOD_FADE_CROSSFADE

#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
Expand Down Expand Up @@ -623,6 +622,7 @@ Shader "HDRP/LayeredLit"
//enable GPU instancing support
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer
#pragma multi_compile _ LOD_FADE_CROSSFADE

// Lightmap memo
// DYNAMICLIGHTMAP_ON is used when we have an "enlighten lightmap" ie a lightmap updated at runtime by enlighten.This lightmap contain indirect lighting from realtime lights and realtime emissive material.Offline baked lighting(from baked material / light,
Expand Down Expand Up @@ -666,6 +666,7 @@ Shader "HDRP/LayeredLit"
//enable GPU instancing support
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer
#pragma multi_compile _ LOD_FADE_CROSSFADE

#pragma multi_compile _ WRITE_NORMAL_BUFFER
#pragma multi_compile _ WRITE_MSAA_DEPTH
Expand Down Expand Up @@ -706,6 +707,7 @@ Shader "HDRP/LayeredLit"
//enable GPU instancing support
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer
#pragma multi_compile _ LOD_FADE_CROSSFADE

#define SHADERPASS SHADERPASS_SHADOWS
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
Expand Down Expand Up @@ -745,6 +747,7 @@ Shader "HDRP/LayeredLit"
//enable GPU instancing support
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer
#pragma multi_compile _ LOD_FADE_CROSSFADE

// In deferred, depth only pass don't output anything.
// In forward it output the normal buffer
Expand Down Expand Up @@ -795,6 +798,7 @@ Shader "HDRP/LayeredLit"
//enable GPU instancing support
#pragma multi_compile_instancing
#pragma instancing_options renderinglayer
#pragma multi_compile _ LOD_FADE_CROSSFADE

#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
Expand Down Expand Up @@ -889,12 +893,10 @@ Shader "HDRP/LayeredLit"
#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON

#define SHADERPASS SHADERPASS_RAYTRACING_INDIRECT

// multi compile that allows us to
#pragma multi_compile _ DIFFUSE_LIGHTING_ONLY
#pragma multi_compile _ MULTI_BOUNCE_INDIRECT

// We use the low shadow maps for raytracing
Expand Down Expand Up @@ -934,7 +936,6 @@ Shader "HDRP/LayeredLit"
#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON

#define SHADERPASS SHADERPASS_RAYTRACING_FORWARD

Expand Down Expand Up @@ -975,8 +976,6 @@ Shader "HDRP/LayeredLit"
#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ DIFFUSE_LIGHTING_ONLY

#define SHADERPASS SHADERPASS_RAYTRACING_GBUFFER

Expand Down Expand Up @@ -1038,8 +1037,6 @@ Shader "HDRP/LayeredLit"
#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON
#pragma multi_compile _ DIFFUSE_LIGHTING_ONLY

#define SHADERPASS SHADERPASS_RAYTRACING_SUB_SURFACE

Expand Down Expand Up @@ -1072,7 +1069,6 @@ Shader "HDRP/LayeredLit"
#pragma multi_compile _ DEBUG_DISPLAY
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ DYNAMICLIGHTMAP_ON

#define SHADERPASS SHADERPASS_PATH_TRACING
#define SKIP_RASTERIZED_SHADOWS
Expand Down
Loading