mirror of
https://github.com/ApfelTeeSaft/Slender.git
synced 2026-08-27 03:43:28 +00:00
71 lines
1.3 KiB
C#
71 lines
1.3 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
[Serializable]
|
|
[AddComponentMenu("Image Effects/Screen Overlay")]
|
|
[ExecuteInEditMode]
|
|
[RequireComponent(typeof(Camera))]
|
|
public class ScreenOverlay : PostEffectsBase
|
|
{
|
|
[Serializable]
|
|
public enum OverlayBlendMode
|
|
{
|
|
AddSub = 0,
|
|
ScreenBlend = 1,
|
|
Multiply = 2,
|
|
Overlay = 3,
|
|
AlphaBlend = 4
|
|
}
|
|
|
|
public OverlayBlendMode blendMode;
|
|
|
|
public float intensity;
|
|
|
|
public Texture2D texture;
|
|
|
|
public Shader overlayShader;
|
|
|
|
private Material overlayMaterial;
|
|
|
|
public ScreenOverlay()
|
|
{
|
|
blendMode = OverlayBlendMode.Overlay;
|
|
intensity = 1f;
|
|
}
|
|
|
|
public virtual void OnDisable()
|
|
{
|
|
if ((bool)overlayMaterial)
|
|
{
|
|
UnityEngine.Object.DestroyImmediate(overlayMaterial);
|
|
}
|
|
}
|
|
|
|
public override bool CheckResources()
|
|
{
|
|
CheckSupport(false);
|
|
overlayMaterial = CheckShaderAndCreateMaterial(overlayShader, overlayMaterial);
|
|
if (!isSupported)
|
|
{
|
|
ReportAutoDisable();
|
|
}
|
|
return isSupported;
|
|
}
|
|
|
|
public virtual void OnRenderImage(RenderTexture source, RenderTexture destination)
|
|
{
|
|
if (!CheckResources())
|
|
{
|
|
Graphics.Blit(source, destination);
|
|
return;
|
|
}
|
|
overlayMaterial.SetFloat("_Intensity", intensity);
|
|
overlayMaterial.SetTexture("_Overlay", texture);
|
|
Graphics.Blit(source, destination, overlayMaterial, (int)blendMode);
|
|
}
|
|
|
|
public override void Main()
|
|
{
|
|
}
|
|
}
|