cailean
10 months ago
8 changed files with 1227 additions and 4 deletions
@ -0,0 +1,44 @@ |
|||
using UnityEngine; |
|||
using UnityEngine.Rendering; |
|||
using UnityEngine.Rendering.HighDefinition; |
|||
using System; |
|||
|
|||
[Serializable, VolumeComponentMenu("Post-processing/Custom/Scale")] |
|||
public sealed class Scale : CustomPostProcessVolumeComponent, IPostProcessComponent |
|||
{ |
|||
[Tooltip("Controls the intensity of the effect.")] |
|||
public ClampedFloatParameter intensity = new ClampedFloatParameter(0f, 0f, 1f); |
|||
public ClampedFloatParameter scale = new ClampedFloatParameter(0f, 0f, 1); |
|||
Material m_Material; |
|||
|
|||
public bool IsActive() => m_Material != null && intensity.value > 0f; |
|||
|
|||
// Do not forget to add this post process in the Custom Post Process Orders list (Project Settings > Graphics > HDRP Global Settings).
|
|||
public override CustomPostProcessInjectionPoint injectionPoint => CustomPostProcessInjectionPoint.AfterPostProcess; |
|||
|
|||
const string kShaderName = "Shader Graphs/Scale"; |
|||
|
|||
public override void Setup() |
|||
{ |
|||
if (Shader.Find(kShaderName) != null) |
|||
m_Material = new Material(Shader.Find(kShaderName)); |
|||
else |
|||
Debug.LogError($"Unable to find shader '{kShaderName}'. Post Process Volume Scale is unable to load."); |
|||
} |
|||
|
|||
public override void Render(CommandBuffer cmd, HDCamera camera, RTHandle source, RTHandle destination) |
|||
{ |
|||
if (m_Material == null) |
|||
return; |
|||
|
|||
m_Material.SetFloat("_Intensity", intensity.value); |
|||
m_Material.SetFloat("_Scale", scale.value); |
|||
m_Material.SetTexture("_MainTex", source); |
|||
HDUtils.DrawFullScreen(cmd, m_Material, destination, shaderPassId: 0); |
|||
} |
|||
|
|||
public override void Cleanup() |
|||
{ |
|||
CoreUtils.Destroy(m_Material); |
|||
} |
|||
} |
@ -0,0 +1,2 @@ |
|||
fileFormatVersion: 2 |
|||
guid: d39585a76d5fe4440a829bdff2e7d6f5 |
File diff suppressed because it is too large
@ -0,0 +1,10 @@ |
|||
fileFormatVersion: 2 |
|||
guid: 78fab9e2adf9a6d4cb00cbebbd101f32 |
|||
ScriptedImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} |
Loading…
Reference in new issue