гигантский ассет
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using UnityEngine.Rendering;
|
||||
using System;
|
||||
|
||||
namespace UHFPS.Rendering
|
||||
{
|
||||
[Serializable, VolumeComponentMenu("UHFPS Post-Processing/Scanlines")]
|
||||
public class Scanlines : VolumeComponent, IPostProcessComponent
|
||||
{
|
||||
public ClampedFloatParameter ScanlinesStrength = new (0f, 0f, 2f);
|
||||
public ClampedFloatParameter ScanlinesSharpness = new (1.5f, 0f, 5f);
|
||||
public ClampedFloatParameter ScanlinesScroll = new (2f, 0f, 5f);
|
||||
public FloatParameter ScanlinesFrequency = new (5);
|
||||
|
||||
public FloatParameter GlitchIntensity = new(0);
|
||||
public FloatParameter GlitchFrequency = new (0);
|
||||
|
||||
private bool State => active && ScanlinesStrength.overrideState;
|
||||
public bool IsActive() => State && ScanlinesStrength.value > 0;
|
||||
public bool IsTileCompatible() => false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 924484cda5dee3144ab04608116b5be7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,18 @@
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UHFPS.Rendering
|
||||
{
|
||||
public class ScanlinesFeature : EffectFeature
|
||||
{
|
||||
public override string Name => "Scanlines";
|
||||
|
||||
public RenderPassEvent RenderPassEvent = RenderPassEvent.AfterRenderingTransparents;
|
||||
public Material EffectMaterial;
|
||||
|
||||
public override void OnCreate()
|
||||
{
|
||||
RenderPass = new ScanlinesPass(RenderPassEvent, EffectMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3d909b6bd505099489f49cd9cfcf9e31
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
using UnityEngine.Rendering.Universal;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UHFPS.Rendering
|
||||
{
|
||||
public class ScanlinesPass : ScriptableRenderPass
|
||||
{
|
||||
private static readonly int ScanlinesStrength = Shader.PropertyToID("_ScanlinesStrength");
|
||||
private static readonly int ScanlinesSharpness = Shader.PropertyToID("_ScanlinesSharpness");
|
||||
private static readonly int ScanlinesScroll = Shader.PropertyToID("_ScanlinesScroll");
|
||||
private static readonly int ScanlinesFrequency = Shader.PropertyToID("_ScanlinesFrequency");
|
||||
private static readonly int GlitchIntensity = Shader.PropertyToID("_GlitchIntensity");
|
||||
private static readonly int GlitchFrequency = Shader.PropertyToID("_GlitchFrequency");
|
||||
|
||||
private readonly Material m_Material;
|
||||
private RTHandle m_CameraTempColor;
|
||||
|
||||
public ScanlinesPass(RenderPassEvent renderPassEvent, Material material)
|
||||
{
|
||||
this.renderPassEvent = renderPassEvent;
|
||||
m_Material = material;
|
||||
}
|
||||
|
||||
public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
|
||||
{
|
||||
var colorDesc = renderingData.cameraData.cameraTargetDescriptor;
|
||||
colorDesc.depthBufferBits = 0;
|
||||
|
||||
RenderingUtils.ReAllocateIfNeeded(ref m_CameraTempColor, colorDesc, name: "_TemporaryColorTexture");
|
||||
}
|
||||
|
||||
public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
|
||||
{
|
||||
if (m_Material == null) return;
|
||||
if (renderingData.cameraData.isSceneViewCamera) return;
|
||||
if (!renderingData.cameraData.postProcessEnabled) return;
|
||||
|
||||
VolumeStack stack = VolumeManager.instance.stack;
|
||||
Scanlines scanlinesVolume = stack.GetComponent<Scanlines>();
|
||||
if (!scanlinesVolume.IsActive()) return;
|
||||
|
||||
m_Material.SetFloat(ScanlinesStrength, scanlinesVolume.ScanlinesStrength.value);
|
||||
m_Material.SetFloat(ScanlinesSharpness, scanlinesVolume.ScanlinesSharpness.value);
|
||||
m_Material.SetFloat(ScanlinesScroll, scanlinesVolume.ScanlinesScroll.value);
|
||||
m_Material.SetFloat(ScanlinesFrequency, scanlinesVolume.ScanlinesFrequency.value);
|
||||
m_Material.SetFloat(GlitchIntensity, scanlinesVolume.GlitchIntensity.value);
|
||||
m_Material.SetFloat(GlitchFrequency, scanlinesVolume.GlitchFrequency.value);
|
||||
|
||||
var cmd = CommandBufferPool.Get();
|
||||
using (new ProfilingScope(cmd, new ProfilingSampler("Scanlines")))
|
||||
{
|
||||
RTHandle camTarget = renderingData.cameraData.renderer.cameraColorTargetHandle;
|
||||
Blitter.BlitCameraTexture(cmd, camTarget, m_CameraTempColor, m_Material, 0);
|
||||
Blitter.BlitCameraTexture(cmd, m_CameraTempColor, camTarget);
|
||||
}
|
||||
|
||||
context.ExecuteCommandBuffer(cmd);
|
||||
cmd.Clear();
|
||||
|
||||
CommandBufferPool.Release(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 161bfb569d1a73c4282723b50a2be7a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user