feat (vision): remove the crt
This commit is contained in:
@@ -16,9 +16,9 @@ public class PlayerLook : MonoBehaviour
|
|||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
m_rigidbody = GetComponent<Rigidbody>();
|
m_rigidbody = GetComponent<Rigidbody>();
|
||||||
input = GetComponent<PlayerInputController>();
|
input = GetComponent<PlayerInputController>();
|
||||||
headController = GetComponent<PlayerHeadController>();
|
headController = GetComponent<PlayerHeadController>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FixedUpdate()
|
private void FixedUpdate()
|
||||||
|
|||||||
@@ -1,123 +1,123 @@
|
|||||||
using UnityEngine;
|
// using UnityEngine;
|
||||||
using UnityEngine.Rendering;
|
// using UnityEngine.Rendering;
|
||||||
using UnityEngine.Rendering.RenderGraphModule;
|
// using UnityEngine.Rendering.RenderGraphModule;
|
||||||
using UnityEngine.Rendering.RenderGraphModule.Util;
|
// using UnityEngine.Rendering.RenderGraphModule.Util;
|
||||||
using UnityEngine.Rendering.Universal;
|
// using UnityEngine.Rendering.Universal;
|
||||||
|
|
||||||
public class CRTRendererFeature : ScriptableRendererFeature
|
// public class CRTRendererFeature : ScriptableRendererFeature
|
||||||
{
|
// {
|
||||||
[System.Serializable]
|
// [System.Serializable]
|
||||||
public class CRTSettings
|
// public class CRTSettings
|
||||||
{
|
// {
|
||||||
public bool EffectEnabled = true;
|
// public bool EffectEnabled = true;
|
||||||
public RenderPassEvent PassEvent = RenderPassEvent.AfterRenderingPostProcessing;
|
// public RenderPassEvent PassEvent = RenderPassEvent.AfterRenderingPostProcessing;
|
||||||
public Shader CRTShader;
|
// public Shader CRTShader;
|
||||||
|
|
||||||
[Range(0f, 1f)] public float Intensity = 0.65f;
|
// [Range(0f, 1f)] public float Intensity = 0.65f;
|
||||||
[Range(0f, 2f)] public float ScanlineDensity = 1.2f;
|
// [Range(0f, 2f)] public float ScanlineDensity = 1.2f;
|
||||||
[Range(0f, 1f)] public float ScanlineStrength = 0.18f;
|
// [Range(0f, 1f)] public float ScanlineStrength = 0.18f;
|
||||||
[Range(0f, 0.2f)] public float Curvature = 0.04f;
|
// [Range(0f, 0.2f)] public float Curvature = 0.04f;
|
||||||
[Range(0f, 1f)] public float VignetteStrength = 0.28f;
|
// [Range(0f, 1f)] public float VignetteStrength = 0.28f;
|
||||||
[Range(0f, 0.05f)] public float ChromaticAberration = 0.004f;
|
// [Range(0f, 0.05f)] public float ChromaticAberration = 0.004f;
|
||||||
[Range(0f, 0.2f)] public float NoiseStrength = 0.03f;
|
// [Range(0f, 0.2f)] public float NoiseStrength = 0.03f;
|
||||||
[Range(0f, 0.1f)] public float FlickerStrength = 0.015f;
|
// [Range(0f, 0.1f)] public float FlickerStrength = 0.015f;
|
||||||
}
|
// }
|
||||||
|
|
||||||
class CRTPass : ScriptableRenderPass
|
// class CRTPass : ScriptableRenderPass
|
||||||
{
|
// {
|
||||||
private Material m_Material;
|
// private Material m_Material;
|
||||||
private CRTSettings m_Settings;
|
// private CRTSettings m_Settings;
|
||||||
|
|
||||||
public void Setup(Material material, CRTSettings settings)
|
// public void Setup(Material material, CRTSettings settings)
|
||||||
{
|
// {
|
||||||
m_Material = material;
|
// m_Material = material;
|
||||||
m_Settings = settings;
|
// m_Settings = settings;
|
||||||
renderPassEvent = settings.PassEvent;
|
// renderPassEvent = settings.PassEvent;
|
||||||
requiresIntermediateTexture = true;
|
// requiresIntermediateTexture = true;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
|
// public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
|
||||||
{
|
// {
|
||||||
if (m_Material == null || m_Settings == null || !m_Settings.EffectEnabled)
|
// if (m_Material == null || m_Settings == null || !m_Settings.EffectEnabled)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
UniversalResourceData resourceData = frameData.Get<UniversalResourceData>();
|
// UniversalResourceData resourceData = frameData.Get<UniversalResourceData>();
|
||||||
if (resourceData.isActiveTargetBackBuffer)
|
// if (resourceData.isActiveTargetBackBuffer)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
m_Material.SetFloat("_Intensity", m_Settings.Intensity);
|
// m_Material.SetFloat("_Intensity", m_Settings.Intensity);
|
||||||
m_Material.SetFloat("_ScanlineDensity", m_Settings.ScanlineDensity);
|
// m_Material.SetFloat("_ScanlineDensity", m_Settings.ScanlineDensity);
|
||||||
m_Material.SetFloat("_ScanlineStrength", m_Settings.ScanlineStrength);
|
// m_Material.SetFloat("_ScanlineStrength", m_Settings.ScanlineStrength);
|
||||||
m_Material.SetFloat("_Curvature", m_Settings.Curvature);
|
// m_Material.SetFloat("_Curvature", m_Settings.Curvature);
|
||||||
m_Material.SetFloat("_VignetteStrength", m_Settings.VignetteStrength);
|
// m_Material.SetFloat("_VignetteStrength", m_Settings.VignetteStrength);
|
||||||
m_Material.SetFloat("_ChromaticAberration", m_Settings.ChromaticAberration);
|
// m_Material.SetFloat("_ChromaticAberration", m_Settings.ChromaticAberration);
|
||||||
m_Material.SetFloat("_NoiseStrength", m_Settings.NoiseStrength);
|
// m_Material.SetFloat("_NoiseStrength", m_Settings.NoiseStrength);
|
||||||
m_Material.SetFloat("_FlickerStrength", m_Settings.FlickerStrength);
|
// m_Material.SetFloat("_FlickerStrength", m_Settings.FlickerStrength);
|
||||||
|
|
||||||
TextureHandle source = resourceData.activeColorTexture;
|
// TextureHandle source = resourceData.activeColorTexture;
|
||||||
TextureDesc destinationDesc = renderGraph.GetTextureDesc(source);
|
// TextureDesc destinationDesc = renderGraph.GetTextureDesc(source);
|
||||||
destinationDesc.name = "CameraColor-CRT";
|
// destinationDesc.name = "CameraColor-CRT";
|
||||||
destinationDesc.clearBuffer = false;
|
// destinationDesc.clearBuffer = false;
|
||||||
|
|
||||||
TextureHandle destination = renderGraph.CreateTexture(destinationDesc);
|
// TextureHandle destination = renderGraph.CreateTexture(destinationDesc);
|
||||||
RenderGraphUtils.BlitMaterialParameters blitParams = new(source, destination, m_Material, 0);
|
// RenderGraphUtils.BlitMaterialParameters blitParams = new(source, destination, m_Material, 0);
|
||||||
renderGraph.AddBlitPass(blitParams, "CRT Effect");
|
// renderGraph.AddBlitPass(blitParams, "CRT Effect");
|
||||||
|
|
||||||
resourceData.cameraColor = destination;
|
// resourceData.cameraColor = destination;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void Dispose()
|
// public void Dispose()
|
||||||
{
|
// {
|
||||||
// RenderGraph path does not allocate persistent RTHandles in this pass.
|
// // RenderGraph path does not allocate persistent RTHandles in this pass.
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public CRTSettings Settings = new();
|
// public CRTSettings Settings = new();
|
||||||
|
|
||||||
private CRTPass m_Pass;
|
// private CRTPass m_Pass;
|
||||||
private Material m_Material;
|
// private Material m_Material;
|
||||||
|
|
||||||
public override void Create()
|
// public override void Create()
|
||||||
{
|
// {
|
||||||
if (Settings.CRTShader == null)
|
// if (Settings.CRTShader == null)
|
||||||
{
|
// {
|
||||||
Settings.CRTShader = Shader.Find("Hidden/HeadlessHazard/CRT");
|
// Settings.CRTShader = Shader.Find("Hidden/HeadlessHazard/CRT");
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (Settings.CRTShader != null)
|
// if (Settings.CRTShader != null)
|
||||||
{
|
// {
|
||||||
m_Material = CoreUtils.CreateEngineMaterial(Settings.CRTShader);
|
// m_Material = CoreUtils.CreateEngineMaterial(Settings.CRTShader);
|
||||||
}
|
// }
|
||||||
|
|
||||||
m_Pass ??= new CRTPass();
|
// m_Pass ??= new CRTPass();
|
||||||
}
|
// }
|
||||||
|
|
||||||
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
// public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
|
||||||
{
|
// {
|
||||||
if (m_Material == null || !Settings.EffectEnabled)
|
// if (m_Material == null || !Settings.EffectEnabled)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (renderingData.cameraData.cameraType != CameraType.Game)
|
// if (renderingData.cameraData.cameraType != CameraType.Game)
|
||||||
{
|
// {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
m_Pass.Setup(m_Material, Settings);
|
// m_Pass.Setup(m_Material, Settings);
|
||||||
renderer.EnqueuePass(m_Pass);
|
// renderer.EnqueuePass(m_Pass);
|
||||||
}
|
// }
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
// protected override void Dispose(bool disposing)
|
||||||
{
|
// {
|
||||||
m_Pass?.Dispose();
|
// m_Pass?.Dispose();
|
||||||
m_Pass = null;
|
// m_Pass = null;
|
||||||
|
|
||||||
CoreUtils.Destroy(m_Material);
|
// CoreUtils.Destroy(m_Material);
|
||||||
m_Material = null;
|
// m_Material = null;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|||||||
Reference in New Issue
Block a user