scripts
This commit is contained in:
@@ -0,0 +1,234 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityStandardAssets.CinematicEffects
|
||||
{
|
||||
// Token: 0x0200001A RID: 26
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Camera))]
|
||||
[AddComponentMenu("Image Effects/Cinematic/Bloom")]
|
||||
[ImageEffectAllowedInSceneView]
|
||||
public class Bloom : MonoBehaviour
|
||||
{
|
||||
// Token: 0x17000023 RID: 35
|
||||
// (get) Token: 0x06000052 RID: 82 RVA: 0x000037FB File Offset: 0x00001BFB
|
||||
public Shader shader
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_Shader == null)
|
||||
{
|
||||
this.m_Shader = Shader.Find("Hidden/Image Effects/Cinematic/Bloom");
|
||||
}
|
||||
return this.m_Shader;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000024 RID: 36
|
||||
// (get) Token: 0x06000053 RID: 83 RVA: 0x00003824 File Offset: 0x00001C24
|
||||
public Material material
|
||||
{
|
||||
get
|
||||
{
|
||||
if (this.m_Material == null)
|
||||
{
|
||||
this.m_Material = ImageEffectHelper.CheckShaderAndCreateMaterial(this.shader);
|
||||
}
|
||||
return this.m_Material;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000054 RID: 84 RVA: 0x0000384E File Offset: 0x00001C4E
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!ImageEffectHelper.IsSupported(this.shader, true, false, this))
|
||||
{
|
||||
base.enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000055 RID: 85 RVA: 0x0000386A File Offset: 0x00001C6A
|
||||
private void OnDisable()
|
||||
{
|
||||
if (this.m_Material != null)
|
||||
{
|
||||
global::UnityEngine.Object.DestroyImmediate(this.m_Material);
|
||||
}
|
||||
this.m_Material = null;
|
||||
}
|
||||
|
||||
// Token: 0x06000056 RID: 86 RVA: 0x00003890 File Offset: 0x00001C90
|
||||
private void OnRenderImage(RenderTexture source, RenderTexture destination)
|
||||
{
|
||||
bool isMobilePlatform = Application.isMobilePlatform;
|
||||
int num = source.width;
|
||||
int num2 = source.height;
|
||||
if (!this.settings.highQuality)
|
||||
{
|
||||
num /= 2;
|
||||
num2 /= 2;
|
||||
}
|
||||
RenderTextureFormat renderTextureFormat = ((!isMobilePlatform) ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default);
|
||||
float num3 = Mathf.Log((float)num2, 2f) + this.settings.radius - 8f;
|
||||
int num4 = (int)num3;
|
||||
int num5 = Mathf.Clamp(num4, 1, 16);
|
||||
float thresholdLinear = this.settings.thresholdLinear;
|
||||
this.material.SetFloat("_Threshold", thresholdLinear);
|
||||
float num6 = thresholdLinear * 0.5f + 1E-05f;
|
||||
Vector3 vector = new Vector3(thresholdLinear - num6, num6 * 2f, 0.25f / num6);
|
||||
this.material.SetVector("_Curve", vector);
|
||||
bool flag = !this.settings.highQuality && this.settings.antiFlicker;
|
||||
this.material.SetFloat("_PrefilterOffs", (!flag) ? 0f : (-0.5f));
|
||||
this.material.SetFloat("_SampleScale", 0.5f + num3 - (float)num4);
|
||||
this.material.SetFloat("_Intensity", Mathf.Max(0f, this.settings.intensity));
|
||||
if (this.settings.highQuality)
|
||||
{
|
||||
this.material.EnableKeyword("HIGH_QUALITY");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.material.DisableKeyword("HIGH_QUALITY");
|
||||
}
|
||||
if (this.settings.antiFlicker)
|
||||
{
|
||||
this.material.EnableKeyword("ANTI_FLICKER");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.material.DisableKeyword("ANTI_FLICKER");
|
||||
}
|
||||
RenderTexture temporary = RenderTexture.GetTemporary(num, num2, 0, renderTextureFormat);
|
||||
Graphics.Blit(source, temporary, this.material, 0);
|
||||
RenderTexture renderTexture = temporary;
|
||||
for (int i = 0; i < num5; i++)
|
||||
{
|
||||
this.m_blurBuffer1[i] = RenderTexture.GetTemporary(renderTexture.width / 2, renderTexture.height / 2, 0, renderTextureFormat);
|
||||
Graphics.Blit(renderTexture, this.m_blurBuffer1[i], this.material, (i != 0) ? 2 : 1);
|
||||
renderTexture = this.m_blurBuffer1[i];
|
||||
}
|
||||
for (int j = num5 - 2; j >= 0; j--)
|
||||
{
|
||||
RenderTexture renderTexture2 = this.m_blurBuffer1[j];
|
||||
this.material.SetTexture("_BaseTex", renderTexture2);
|
||||
this.m_blurBuffer2[j] = RenderTexture.GetTemporary(renderTexture2.width, renderTexture2.height, 0, renderTextureFormat);
|
||||
Graphics.Blit(renderTexture, this.m_blurBuffer2[j], this.material, 3);
|
||||
renderTexture = this.m_blurBuffer2[j];
|
||||
}
|
||||
this.material.SetTexture("_BaseTex", source);
|
||||
Graphics.Blit(renderTexture, destination, this.material, 4);
|
||||
for (int k = 0; k < 16; k++)
|
||||
{
|
||||
if (this.m_blurBuffer1[k] != null)
|
||||
{
|
||||
RenderTexture.ReleaseTemporary(this.m_blurBuffer1[k]);
|
||||
}
|
||||
if (this.m_blurBuffer2[k] != null)
|
||||
{
|
||||
RenderTexture.ReleaseTemporary(this.m_blurBuffer2[k]);
|
||||
}
|
||||
this.m_blurBuffer1[k] = null;
|
||||
this.m_blurBuffer2[k] = null;
|
||||
}
|
||||
RenderTexture.ReleaseTemporary(temporary);
|
||||
}
|
||||
|
||||
// Token: 0x04000065 RID: 101
|
||||
[SerializeField]
|
||||
public Bloom.Settings settings = Bloom.Settings.defaultSettings;
|
||||
|
||||
// Token: 0x04000066 RID: 102
|
||||
[SerializeField]
|
||||
[HideInInspector]
|
||||
private Shader m_Shader;
|
||||
|
||||
// Token: 0x04000067 RID: 103
|
||||
private Material m_Material;
|
||||
|
||||
// Token: 0x04000068 RID: 104
|
||||
private const int kMaxIterations = 16;
|
||||
|
||||
// Token: 0x04000069 RID: 105
|
||||
private RenderTexture[] m_blurBuffer1 = new RenderTexture[16];
|
||||
|
||||
// Token: 0x0400006A RID: 106
|
||||
private RenderTexture[] m_blurBuffer2 = new RenderTexture[16];
|
||||
|
||||
// Token: 0x0200001B RID: 27
|
||||
[Serializable]
|
||||
public struct Settings
|
||||
{
|
||||
// Token: 0x17000025 RID: 37
|
||||
// (get) Token: 0x06000058 RID: 88 RVA: 0x00003BF7 File Offset: 0x00001FF7
|
||||
// (set) Token: 0x06000057 RID: 87 RVA: 0x00003BEE File Offset: 0x00001FEE
|
||||
public float thresholdGamma
|
||||
{
|
||||
get
|
||||
{
|
||||
return Mathf.Max(0f, this.threshold);
|
||||
}
|
||||
set
|
||||
{
|
||||
this.threshold = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000026 RID: 38
|
||||
// (get) Token: 0x0600005A RID: 90 RVA: 0x00003C17 File Offset: 0x00002017
|
||||
// (set) Token: 0x06000059 RID: 89 RVA: 0x00003C09 File Offset: 0x00002009
|
||||
public float thresholdLinear
|
||||
{
|
||||
get
|
||||
{
|
||||
return Mathf.GammaToLinearSpace(this.thresholdGamma);
|
||||
}
|
||||
set
|
||||
{
|
||||
this.threshold = Mathf.LinearToGammaSpace(value);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x17000027 RID: 39
|
||||
// (get) Token: 0x0600005B RID: 91 RVA: 0x00003C24 File Offset: 0x00002024
|
||||
public static Bloom.Settings defaultSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Bloom.Settings
|
||||
{
|
||||
threshold = 0.9f,
|
||||
radius = 2f,
|
||||
intensity = 0.7f,
|
||||
highQuality = true,
|
||||
antiFlicker = false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0400006B RID: 107
|
||||
[SerializeField]
|
||||
[Tooltip("Filters out pixels under this level of brightness.")]
|
||||
public float threshold;
|
||||
|
||||
// Token: 0x0400006C RID: 108
|
||||
[SerializeField]
|
||||
[Range(1f, 7f)]
|
||||
[Tooltip("Changes extent of veiling effects in a screen resolution-independent fashion.")]
|
||||
public float radius;
|
||||
|
||||
// Token: 0x0400006D RID: 109
|
||||
[SerializeField]
|
||||
[Tooltip("Blend factor of the result image.")]
|
||||
public float intensity;
|
||||
|
||||
// Token: 0x0400006E RID: 110
|
||||
[SerializeField]
|
||||
[Tooltip("Controls filter quality and buffer resolution.")]
|
||||
public bool highQuality;
|
||||
|
||||
// Token: 0x0400006F RID: 111
|
||||
[SerializeField]
|
||||
[Tooltip("Reduces flashing noise with an additional filter.")]
|
||||
public bool antiFlicker;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user