Skip to content
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

Add adaptive performance decals scaler options. #6013

Merged
merged 13 commits into from
Oct 26, 2021
Merged
Prev Previous commit
Next Next commit
Upgrade to properties.
  • Loading branch information
odbb committed Oct 19, 2021
commit 69f0fc45dc7ab8d53c0bbd04a7a5b721209ea31c
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,22 @@ internal class DecalCreateDrawCallSystem
{
private DecalEntityManager m_EntityManager;
private ProfilingSampler m_Sampler;
public float maxDrawDistance;
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;
m_Sampler = new ProfilingSampler("DecalCreateDrawCallSystem.Execute");
this.maxDrawDistance = maxDrawDistance;
m_MaxDrawDistance = maxDrawDistance;
}

public void Execute()
Expand Down Expand Up @@ -102,7 +111,7 @@ private void Execute(DecalCachedChunk cachedChunk, DecalCulledChunk culledChunk,
cullingMask = culledChunk.cullingMask,
visibleDecalIndices = culledChunk.visibleDecalIndices,
visibleDecalCount = culledChunk.visibleDecalCount,
maxDrawDistance = maxDrawDistance,
maxDrawDistance = m_MaxDrawDistance,

decalToWorldsDraw = drawCallChunk.decalToWorlds,
normalToDecalsDraw = drawCallChunk.normalToDecals,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,24 @@ public override void Dispose()
/// </summary>
internal class DecalUpdateCullingGroupSystem
{
public float[] boundingDistance = new float[1];
/// <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;
private ProfilingSampler m_Sampler;

public DecalUpdateCullingGroupSystem(DecalEntityManager entityManager, float drawDistance)
{
m_EntityManager = entityManager;
boundingDistance[0] = drawDistance;
m_BoundingDistance[0] = drawDistance;
m_Sampler = new ProfilingSampler("DecalUpdateCullingGroupsSystem.Execute");
}

Expand All @@ -81,7 +90,7 @@ public void Execute(DecalCachedChunk cachedChunk, DecalCulledChunk culledChunk,
CullingGroup cullingGroup = culledChunk.cullingGroups;
cullingGroup.targetCamera = m_Camera;
cullingGroup.SetDistanceReferencePoint(m_Camera.transform.position);
cullingGroup.SetBoundingDistances(boundingDistance);
cullingGroup.SetBoundingDistances(m_BoundingDistance);
cachedChunk.boundingSpheres.CopyTo(cachedChunk.boundingSphereArray);
cullingGroup.SetBoundingSpheres(cachedChunk.boundingSphereArray);
cullingGroup.SetBoundingSphereCount(count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ private void ChangeAdaptivePerformanceDrawDistances()
}
if (m_DecalUpdateCullingGroupSystem != null)
{
m_DecalUpdateCullingGroupSystem.boundingDistance[0] = AdaptivePerformance.AdaptivePerformanceRenderSettings.DecalsDrawDistance;
m_DecalUpdateCullingGroupSystem.boundingDistance = AdaptivePerformance.AdaptivePerformanceRenderSettings.DecalsDrawDistance;
}
}
}
Expand Down