Skip to content

backport adaptive performance decals scaler #6069

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
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
3 changes: 3 additions & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [12.1.1] - 2021-10-04

### Added
- Added Adaptive Performance Decals scaler access.

### Fixed
- Fixed a regression bug where XR camera postion can not be modified in beginCameraRendering [case 1365000]
- Fix for rendering thumbnails. [case 1348209](https://issuetracker.unity3d.com/issues/preview-of-assets-do-not-show-in-the-project-window)
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 @@ -406,6 +407,8 @@ public override void OnCameraPreCull(ScriptableRenderer renderer, in CameraData

RecreateSystemsIfNeeded(renderer, cameraData);

ChangeAdaptivePerformanceDrawDistances();

m_DecalEntityManager.Update();


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

RecreateSystemsIfNeeded(renderer, renderingData.cameraData);

ChangeAdaptivePerformanceDrawDistances();

if (intermediateRendering)
{
m_DecalUpdateCulledSystem.Execute();
Expand Down Expand Up @@ -494,5 +499,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