[BetterShadowClone] Added DontRespectFPR setting

This commit is contained in:
NotAKidoS 2024-02-03 04:14:17 -06:00
parent 829ad55195
commit 0d82606308
6 changed files with 45 additions and 24 deletions

View file

@ -6,6 +6,6 @@ public interface ITransformHider : IDisposable
bool IsValid { get; }
bool Process();
bool PostProcess();
void HideTransform();
void HideTransform(bool forced = false);
void ShowTransform();
}

View file

@ -16,6 +16,9 @@ public class MeshTransformHider : ITransformHider, IFPRExclusionTask
private readonly MeshRenderer _mainMesh;
private bool _enabledState;
// exclusion
private readonly FPRExclusion _exclusion;
#region ITransformHider Methods
public bool IsActive { get; set; } = true; // default hide, but FPRExclusion can override
@ -34,7 +37,8 @@ public class MeshTransformHider : ITransformHider, IFPRExclusionTask
return;
}
exclusion.relatedTasks.Add(this);
_exclusion = exclusion;
_exclusion.relatedTasks.Add(this);
_mainMesh = renderer;
@ -71,14 +75,15 @@ public class MeshTransformHider : ITransformHider, IFPRExclusionTask
_frameInitCounter++;
return false;
}
public bool PostProcess()
{
return true;
}
public void HideTransform()
public bool PostProcess()
=> true;
public void HideTransform(bool forced = false)
{
if (!forced && !IsActive)
return;
_enabledState = _mainMesh.enabled;
_mainMesh.enabled = false;
}

View file

@ -75,7 +75,7 @@ public class SkinnedTransformHider : ITransformHider
if (exclusionVerts.Count == 0)
continue;
SubTask subTask = new(this, exclusion.target, exclusionVerts);
SubTask subTask = new(this, exclusion, exclusionVerts);
_subTasks.Add(subTask);
exclusion.relatedTasks.Add(subTask);
}
@ -116,14 +116,15 @@ public class SkinnedTransformHider : ITransformHider
public bool PostProcess()
=> false; // not needed
public void HideTransform()
public void HideTransform(bool forced = false)
{
_mainMesh.forceRenderingOff = false;
_graphicsBuffer = _mainMesh.GetVertexBuffer();
foreach (SubTask subTask in _subTasks)
if (subTask.IsActive && subTask.IsValid) subTask.Dispatch();
if ((forced || subTask.IsActive) && subTask.IsValid)
subTask.Dispatch();
_graphicsBuffer.Release();
}
@ -169,17 +170,20 @@ public class SkinnedTransformHider : ITransformHider
{
public bool IsActive { get; set; } = true;
public bool IsValid => _computeBuffer != null; // TODO: cleanup dead tasks
private readonly SkinnedTransformHider _parent;
private readonly Transform _shrinkBone;
private readonly int _vertexCount;
private readonly ComputeBuffer _computeBuffer;
private readonly int _threadGroups;
public SubTask(SkinnedTransformHider parent, Transform shrinkBone, List<int> exclusionVerts)
private readonly FPRExclusion _exclusion;
public SubTask(SkinnedTransformHider parent, FPRExclusion exclusion, List<int> exclusionVerts)
{
_parent = parent;
_shrinkBone = shrinkBone;
_exclusion = exclusion;
_shrinkBone = _exclusion.target;
_vertexCount = exclusionVerts.Count;
_computeBuffer = new ComputeBuffer(_vertexCount, sizeof(int));