Skip to content

Add adaptive performance decals scaler options. #6013

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 13 commits into from
Oct 26, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.universal/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 Depth Texture setting for Overlay Camera.
- Added Depth Priming support for Vulkan with MSAA.
- Added Shadows and Additional Lights off variants stripping.
- Added Adaptive Performance Decals scaler.
- Exposed public API for DebugDisplaySettings.
- Added Display Stats panel to Rendering Debugger that displays CPU/GPU frame timings and bottlenecks.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ internal class DecalCreateDrawCallSystem
private ProfilingSampler m_Sampler;
private float m_MaxDrawDistance;

/// <summary>
/// Provides acces to the maximum draw distance.
/// </summary>
public float maxDrawDistance
{
get { return m_MaxDrawDistance; }
set { m_MaxDrawDistance = value; }
}

public DecalCreateDrawCallSystem(DecalEntityManager entityManager, float maxDrawDistance)
{
m_EntityManager = entityManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ public override void Dispose()
/// </summary>
internal class DecalUpdateCullingGroupSystem
{
/// <summary>
/// Provides acces to the bounding distance.
/// </summary>
public float boundingDistance
{
get { return m_BoundingDistance[0]; }
set { m_BoundingDistance[0] = value; }
}

private float[] m_BoundingDistance = new float[1];
private Camera m_Camera;
private DecalEntityManager m_EntityManager;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System.Diagnostics;
using UnityEngine.Assertions;
using UnityEngine.Rendering.Universal.Internal;

Expand Down Expand Up @@ -409,6 +410,8 @@ public override void OnCameraPreCull(ScriptableRenderer renderer, in CameraData

RecreateSystemsIfNeeded(renderer, cameraData);

ChangeAdaptivePerformanceDrawDistances();

m_DecalEntityManager.Update();


Expand Down Expand Up @@ -446,6 +449,8 @@ public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingD

RecreateSystemsIfNeeded(renderer, renderingData.cameraData);

ChangeAdaptivePerformanceDrawDistances();

if (intermediateRendering)
{
m_DecalUpdateCulledSystem.Execute();
Expand Down Expand Up @@ -504,5 +509,23 @@ protected override void Dispose(bool disposing)
sharedDecalEntityManager.Release(m_DecalEntityManager);
}
}

[Conditional("ADAPTIVE_PERFORMANCE_4_0_0_OR_NEWER")]
private void ChangeAdaptivePerformanceDrawDistances()
{
#if ADAPTIVE_PERFORMANCE_4_0_0_OR_NEWER
if (UniversalRenderPipeline.asset.useAdaptivePerformance)
{
if (m_DecalCreateDrawCallSystem != null)
{
m_DecalCreateDrawCallSystem.maxDrawDistance = AdaptivePerformance.AdaptivePerformanceRenderSettings.DecalsDrawDistance;
}
if (m_DecalUpdateCullingGroupSystem != null)
{
m_DecalUpdateCullingGroupSystem.boundingDistance = AdaptivePerformance.AdaptivePerformanceRenderSettings.DecalsDrawDistance;
}
}
#endif
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
"expression": "2.1.0",
"define": "ADAPTIVE_PERFORMANCE_2_1_0_OR_NEWER"
},
{
"name": "com.unity.adaptiveperformance",
"expression": "4.0.0-pre.1",
"define": "ADAPTIVE_PERFORMANCE_4_0_0_OR_NEWER"
},
{
"name": "com.unity.burst",
"expression": "1.0.0",
Expand Down