Added Cinematic Effects, QuickRopes 2, removed unresolved dependencies.
9
Assets/Cinematic Effects/AmbientOcclusion.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ed6d7947a564a4dd1987f60392be4349
|
||||
folderAsset: yes
|
||||
timeCreated: 1457326591
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
347
Assets/Cinematic Effects/AmbientOcclusion/AmbientOcclusion.cs
Normal file
|
@ -0,0 +1,347 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace UnityStandardAssets.CinematicEffects
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Camera))]
|
||||
[AddComponentMenu("Image Effects/Cinematic/Ambient Occlusion")]
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
[ImageEffectAllowedInSceneView]
|
||||
#endif
|
||||
public partial class AmbientOcclusion : MonoBehaviour
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
/// Effect settings.
|
||||
[SerializeField]
|
||||
public Settings settings = Settings.defaultSettings;
|
||||
|
||||
/// Checks if the ambient-only mode is supported under the current settings.
|
||||
public bool isAmbientOnlySupported
|
||||
{
|
||||
get { return targetCamera.hdr && isGBufferAvailable; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Properties
|
||||
|
||||
// Properties referring to the current settings
|
||||
|
||||
float intensity
|
||||
{
|
||||
get { return settings.intensity; }
|
||||
}
|
||||
|
||||
float radius
|
||||
{
|
||||
get { return Mathf.Max(settings.radius, 1e-4f); }
|
||||
}
|
||||
|
||||
SampleCount sampleCount
|
||||
{
|
||||
get { return settings.sampleCount; }
|
||||
}
|
||||
|
||||
int sampleCountValue
|
||||
{
|
||||
get
|
||||
{
|
||||
switch (settings.sampleCount)
|
||||
{
|
||||
case SampleCount.Lowest: return 3;
|
||||
case SampleCount.Low: return 6;
|
||||
case SampleCount.Medium: return 12;
|
||||
case SampleCount.High: return 20;
|
||||
}
|
||||
return Mathf.Clamp(settings.sampleCountValue, 1, 256);
|
||||
}
|
||||
}
|
||||
|
||||
bool downsampling
|
||||
{
|
||||
get { return settings.downsampling; }
|
||||
}
|
||||
|
||||
bool ambientOnly
|
||||
{
|
||||
get { return settings.ambientOnly && isAmbientOnlySupported; }
|
||||
}
|
||||
|
||||
// AO shader
|
||||
Shader aoShader
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_aoShader == null)
|
||||
_aoShader = Shader.Find("Hidden/Image Effects/Cinematic/AmbientOcclusion");
|
||||
return _aoShader;
|
||||
}
|
||||
}
|
||||
|
||||
[SerializeField] Shader _aoShader;
|
||||
|
||||
// Temporary aterial for the AO shader
|
||||
Material aoMaterial
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_aoMaterial == null)
|
||||
_aoMaterial = ImageEffectHelper.CheckShaderAndCreateMaterial(aoShader);
|
||||
return _aoMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
Material _aoMaterial;
|
||||
|
||||
// Command buffer for the AO pass
|
||||
CommandBuffer aoCommands
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_aoCommands == null)
|
||||
{
|
||||
_aoCommands = new CommandBuffer();
|
||||
_aoCommands.name = "AmbientOcclusion";
|
||||
}
|
||||
return _aoCommands;
|
||||
}
|
||||
}
|
||||
|
||||
CommandBuffer _aoCommands;
|
||||
|
||||
// Target camera
|
||||
Camera targetCamera
|
||||
{
|
||||
get { return GetComponent<Camera>(); }
|
||||
}
|
||||
|
||||
// Property observer
|
||||
PropertyObserver propertyObserver { get; set; }
|
||||
|
||||
// Check if the G-buffer is available
|
||||
bool isGBufferAvailable
|
||||
{
|
||||
get
|
||||
{
|
||||
var path = targetCamera.actualRenderingPath;
|
||||
return path == RenderingPath.DeferredShading;
|
||||
}
|
||||
}
|
||||
|
||||
// Reference to the quad mesh in the built-in assets
|
||||
// (used in MRT blitting)
|
||||
Mesh quadMesh
|
||||
{
|
||||
get { return _quadMesh; }
|
||||
}
|
||||
|
||||
[SerializeField] Mesh _quadMesh;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Effect Passes
|
||||
|
||||
// Build commands for the AO pass (used in the ambient-only mode).
|
||||
void BuildAOCommands()
|
||||
{
|
||||
var cb = aoCommands;
|
||||
|
||||
var tw = targetCamera.pixelWidth;
|
||||
var th = targetCamera.pixelHeight;
|
||||
var ts = downsampling ? 2 : 1;
|
||||
var format = RenderTextureFormat.R8;
|
||||
var rwMode = RenderTextureReadWrite.Linear;
|
||||
var filter = FilterMode.Bilinear;
|
||||
|
||||
// AO buffer
|
||||
var m = aoMaterial;
|
||||
var rtMask = Shader.PropertyToID("_OcclusionTexture");
|
||||
cb.GetTemporaryRT(rtMask, tw / ts, th / ts, 0, filter, format, rwMode);
|
||||
|
||||
// AO estimation
|
||||
cb.Blit((Texture)null, rtMask, m, 0);
|
||||
|
||||
// Blur buffer
|
||||
var rtBlur = Shader.PropertyToID("_OcclusionBlurTexture");
|
||||
|
||||
// Primary blur filter (large kernel)
|
||||
cb.GetTemporaryRT(rtBlur, tw, th, 0, filter, format, rwMode);
|
||||
cb.SetGlobalVector("_BlurVector", Vector2.right * 2);
|
||||
cb.Blit(rtMask, rtBlur, m, 1);
|
||||
cb.ReleaseTemporaryRT(rtMask);
|
||||
|
||||
cb.GetTemporaryRT(rtMask, tw, th, 0, filter, format, rwMode);
|
||||
cb.SetGlobalVector("_BlurVector", Vector2.up * 2 * ts);
|
||||
cb.Blit(rtBlur, rtMask, m, 1);
|
||||
cb.ReleaseTemporaryRT(rtBlur);
|
||||
|
||||
// Secondary blur filter (small kernel)
|
||||
cb.GetTemporaryRT(rtBlur, tw, th, 0, filter, format, rwMode);
|
||||
cb.SetGlobalVector("_BlurVector", Vector2.right * ts);
|
||||
cb.Blit(rtMask, rtBlur, m, 2);
|
||||
cb.ReleaseTemporaryRT(rtMask);
|
||||
|
||||
cb.GetTemporaryRT(rtMask, tw, th, 0, filter, format, rwMode);
|
||||
cb.SetGlobalVector("_BlurVector", Vector2.up * ts);
|
||||
cb.Blit(rtBlur, rtMask, m, 2);
|
||||
cb.ReleaseTemporaryRT(rtBlur);
|
||||
|
||||
// Combine AO to the G-buffer.
|
||||
var mrt = new RenderTargetIdentifier[] {
|
||||
BuiltinRenderTextureType.GBuffer0, // Albedo, Occ
|
||||
BuiltinRenderTextureType.CameraTarget // Ambient
|
||||
};
|
||||
cb.SetRenderTarget(mrt, BuiltinRenderTextureType.CameraTarget);
|
||||
cb.SetGlobalTexture("_OcclusionTexture", rtMask);
|
||||
cb.DrawMesh(quadMesh, Matrix4x4.identity, m, 0, 4);
|
||||
|
||||
cb.ReleaseTemporaryRT(rtMask);
|
||||
}
|
||||
|
||||
// Execute the AO pass immediately (used in the forward mode).
|
||||
void ExecuteAOPass(RenderTexture source, RenderTexture destination)
|
||||
{
|
||||
var tw = source.width;
|
||||
var th = source.height;
|
||||
var ts = downsampling ? 2 : 1;
|
||||
var format = RenderTextureFormat.R8;
|
||||
var rwMode = RenderTextureReadWrite.Linear;
|
||||
|
||||
// AO buffer
|
||||
var m = aoMaterial;
|
||||
var rtMask = RenderTexture.GetTemporary(tw / ts, th / ts, 0, format, rwMode);
|
||||
|
||||
// AO estimation
|
||||
Graphics.Blit((Texture)null, rtMask, m, 0);
|
||||
|
||||
// Primary blur filter (large kernel)
|
||||
var rtBlur = RenderTexture.GetTemporary(tw, th, 0, format, rwMode);
|
||||
m.SetVector("_BlurVector", Vector2.right * 2);
|
||||
Graphics.Blit(rtMask, rtBlur, m, 1);
|
||||
RenderTexture.ReleaseTemporary(rtMask);
|
||||
|
||||
rtMask = RenderTexture.GetTemporary(tw, th, 0, format, rwMode);
|
||||
m.SetVector("_BlurVector", Vector2.up * 2 * ts);
|
||||
Graphics.Blit(rtBlur, rtMask, m, 1);
|
||||
RenderTexture.ReleaseTemporary(rtBlur);
|
||||
|
||||
// Secondary blur filter (small kernel)
|
||||
rtBlur = RenderTexture.GetTemporary(tw, th, 0, format, rwMode);
|
||||
m.SetVector("_BlurVector", Vector2.right * ts);
|
||||
Graphics.Blit(rtMask, rtBlur, m, 2);
|
||||
RenderTexture.ReleaseTemporary(rtMask);
|
||||
|
||||
rtMask = RenderTexture.GetTemporary(tw, th, 0, format, rwMode);
|
||||
m.SetVector("_BlurVector", Vector2.up * ts);
|
||||
Graphics.Blit(rtBlur, rtMask, m, 2);
|
||||
RenderTexture.ReleaseTemporary(rtBlur);
|
||||
|
||||
// Combine AO with the source.
|
||||
m.SetTexture("_OcclusionTexture", rtMask);
|
||||
|
||||
if (!settings.debug)
|
||||
Graphics.Blit(source, destination, m, 3);
|
||||
else
|
||||
Graphics.Blit(source, destination, m, 5);
|
||||
|
||||
RenderTexture.ReleaseTemporary(rtMask);
|
||||
}
|
||||
|
||||
// Update the common material properties.
|
||||
void UpdateMaterialProperties()
|
||||
{
|
||||
var m = aoMaterial;
|
||||
m.shaderKeywords = null;
|
||||
|
||||
m.SetFloat("_Intensity", intensity);
|
||||
m.SetFloat("_Radius", radius);
|
||||
m.SetFloat("_TargetScale", downsampling ? 0.5f : 1);
|
||||
|
||||
// Use G-buffer if available.
|
||||
if (isGBufferAvailable)
|
||||
m.EnableKeyword("_SOURCE_GBUFFER");
|
||||
|
||||
// Sample count
|
||||
if (sampleCount == SampleCount.Lowest)
|
||||
m.EnableKeyword("_SAMPLECOUNT_LOWEST");
|
||||
else
|
||||
m.SetInt("_SampleCount", sampleCountValue);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region MonoBehaviour Functions
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
// Check if the shader is supported in the current platform.
|
||||
if (!ImageEffectHelper.IsSupported(aoShader, true, false, this))
|
||||
{
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
// Register the command buffer if in the ambient-only mode.
|
||||
if (ambientOnly)
|
||||
targetCamera.AddCommandBuffer(CameraEvent.BeforeReflections, aoCommands);
|
||||
|
||||
// Requires DepthNormals when G-buffer is not available.
|
||||
if (!isGBufferAvailable)
|
||||
targetCamera.depthTextureMode |= DepthTextureMode.DepthNormals;
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
// Destroy all the temporary resources.
|
||||
if (_aoMaterial != null) DestroyImmediate(_aoMaterial);
|
||||
_aoMaterial = null;
|
||||
|
||||
if (_aoCommands != null)
|
||||
targetCamera.RemoveCommandBuffer(CameraEvent.BeforeReflections, _aoCommands);
|
||||
_aoCommands = null;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (propertyObserver.CheckNeedsReset(settings, targetCamera))
|
||||
{
|
||||
// Reinitialize all the resources by disabling/enabling itself.
|
||||
// This is not very efficient way but just works...
|
||||
OnDisable();
|
||||
OnEnable();
|
||||
|
||||
// Build the command buffer if in the ambient-only mode.
|
||||
if (ambientOnly)
|
||||
{
|
||||
aoCommands.Clear();
|
||||
BuildAOCommands();
|
||||
}
|
||||
|
||||
propertyObserver.Update(settings, targetCamera);
|
||||
}
|
||||
|
||||
// Update the material properties (later used in the AO commands).
|
||||
if (ambientOnly) UpdateMaterialProperties();
|
||||
}
|
||||
|
||||
[ImageEffectOpaque]
|
||||
void OnRenderImage(RenderTexture source, RenderTexture destination)
|
||||
{
|
||||
if (ambientOnly)
|
||||
{
|
||||
// Do nothing in the ambient-only mode.
|
||||
Graphics.Blit(source, destination);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Execute the AO pass.
|
||||
UpdateMaterialProperties();
|
||||
ExecuteAOPass(source, destination);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e89654dcf6db746d2a57aeaaa14f5e83
|
||||
timeCreated: 1457327177
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- _aoShader: {fileID: 4800000, guid: 65e203e5acda447acbf9dc1ef78c4a39, type: 3}
|
||||
- _quadMesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/AmbientOcclusion/Editor.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c1589efc0706e448d9a0af709e2c99cc
|
||||
folderAsset: yes
|
||||
timeCreated: 1457326964
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,63 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityStandardAssets.CinematicEffects
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(AmbientOcclusion))]
|
||||
public class AmbientOcclusionEditor : Editor
|
||||
{
|
||||
SerializedProperty _intensity;
|
||||
SerializedProperty _radius;
|
||||
SerializedProperty _sampleCount;
|
||||
SerializedProperty _sampleCountValue;
|
||||
SerializedProperty _downsampling;
|
||||
SerializedProperty _ambientOnly;
|
||||
SerializedProperty _debug;
|
||||
|
||||
static GUIContent _textValue = new GUIContent("Value");
|
||||
|
||||
static string _textNoAmbientOnly =
|
||||
"The ambient-only mode is currently disabled; " +
|
||||
"it needs deferred shading and HDR rendering.";
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
_intensity = serializedObject.FindProperty("settings.intensity");
|
||||
_radius = serializedObject.FindProperty("settings.radius");
|
||||
_sampleCount = serializedObject.FindProperty("settings.sampleCount");
|
||||
_sampleCountValue = serializedObject.FindProperty("settings.sampleCountValue");
|
||||
_downsampling = serializedObject.FindProperty("settings.downsampling");
|
||||
_ambientOnly = serializedObject.FindProperty("settings.ambientOnly");
|
||||
_debug = serializedObject.FindProperty("settings.debug");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.PropertyField(_intensity);
|
||||
EditorGUILayout.PropertyField(_radius);
|
||||
EditorGUILayout.PropertyField(_sampleCount);
|
||||
|
||||
if (_sampleCount.hasMultipleDifferentValues ||
|
||||
_sampleCount.enumValueIndex == (int)AmbientOcclusion.SampleCount.Variable)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_sampleCountValue, _textValue);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(_downsampling);
|
||||
EditorGUILayout.PropertyField(_ambientOnly);
|
||||
EditorGUILayout.PropertyField(_debug);
|
||||
|
||||
// Show a warning if the ambient-only mode is not supported.
|
||||
if (!_ambientOnly.hasMultipleDifferentValues && _ambientOnly.boolValue)
|
||||
if (!((AmbientOcclusion)target).isAmbientOnlySupported)
|
||||
EditorGUILayout.HelpBox(_textNoAmbientOnly, MessageType.Info);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 05ea8e27ed8e74e67a9220b4f4119e51
|
||||
timeCreated: 1457327141
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/AmbientOcclusion/Helpers.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d775599023574a39befabe47bdfddde
|
||||
folderAsset: yes
|
||||
timeCreated: 1457326936
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,38 @@
|
|||
using UnityEngine;
|
||||
|
||||
namespace UnityStandardAssets.CinematicEffects
|
||||
{
|
||||
public partial class AmbientOcclusion : MonoBehaviour
|
||||
{
|
||||
// Observer class that detects changes on properties
|
||||
struct PropertyObserver
|
||||
{
|
||||
// AO properties
|
||||
bool _downsampling;
|
||||
bool _ambientOnly;
|
||||
|
||||
// Camera properties
|
||||
int _pixelWidth;
|
||||
int _pixelHeight;
|
||||
|
||||
// Check if it has to reset itself for property changes.
|
||||
public bool CheckNeedsReset(Settings setting, Camera camera)
|
||||
{
|
||||
return
|
||||
_downsampling != setting.downsampling ||
|
||||
_ambientOnly != setting.ambientOnly ||
|
||||
_pixelWidth != camera.pixelWidth ||
|
||||
_pixelHeight != camera.pixelHeight;
|
||||
}
|
||||
|
||||
// Update the internal state.
|
||||
public void Update(Settings setting, Camera camera)
|
||||
{
|
||||
_downsampling = setting.downsampling;
|
||||
_ambientOnly = setting.ambientOnly;
|
||||
_pixelWidth = camera.pixelWidth;
|
||||
_pixelHeight = camera.pixelHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d9548d9a173a40e4b758ecf6e4fed49
|
||||
timeCreated: 1457326885
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,71 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityStandardAssets.CinematicEffects
|
||||
{
|
||||
public partial class AmbientOcclusion : MonoBehaviour
|
||||
{
|
||||
/// Values for Settings.sampleCount, determining the number of sample points.
|
||||
public enum SampleCount
|
||||
{
|
||||
Lowest, Low, Medium, High, Variable
|
||||
}
|
||||
|
||||
/// Class used for storing settings of AmbientOcclusion.
|
||||
[Serializable]
|
||||
public class Settings
|
||||
{
|
||||
/// Degree of darkness produced by the effect.
|
||||
[SerializeField, Range(0, 4)]
|
||||
[Tooltip("Degree of darkness produced by the effect.")]
|
||||
public float intensity;
|
||||
|
||||
/// Radius of sample points, which affects extent of darkened areas.
|
||||
[SerializeField]
|
||||
[Tooltip("Radius of sample points, which affects extent of darkened areas.")]
|
||||
public float radius;
|
||||
|
||||
/// Number of sample points, which affects quality and performance.
|
||||
[SerializeField]
|
||||
[Tooltip("Number of sample points, which affects quality and performance.")]
|
||||
public SampleCount sampleCount;
|
||||
|
||||
/// Determines the sample count when SampleCount.Variable is used.
|
||||
[SerializeField]
|
||||
[Tooltip("Determines the sample count when SampleCount.Variable is used.")]
|
||||
public int sampleCountValue;
|
||||
|
||||
/// Halves the resolution of the effect to increase performance.
|
||||
[SerializeField]
|
||||
[Tooltip("Halves the resolution of the effect to increase performance.")]
|
||||
public bool downsampling;
|
||||
|
||||
/// Enables the ambient-only mode in that the effect only affects
|
||||
/// ambient lighting. This mode is only available with deferred
|
||||
/// shading and HDR rendering.
|
||||
[SerializeField]
|
||||
[Tooltip("If checked, the effect only affects ambient lighting.")]
|
||||
public bool ambientOnly;
|
||||
|
||||
[SerializeField]
|
||||
public bool debug;
|
||||
|
||||
/// Returns the default settings.
|
||||
public static Settings defaultSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Settings
|
||||
{
|
||||
intensity = 1,
|
||||
radius = 0.3f,
|
||||
sampleCount = SampleCount.Medium,
|
||||
sampleCountValue = 24,
|
||||
downsampling = false,
|
||||
ambientOnly = false
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e952a344c72354904a417d27abe6f55e
|
||||
timeCreated: 1457331804
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/AmbientOcclusion/Resources.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ae08100d29090452888e1b6a7b5a7170
|
||||
folderAsset: yes
|
||||
timeCreated: 1457326958
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,476 @@
|
|||
Shader "Hidden/Image Effects/Cinematic/AmbientOcclusion"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("", 2D) = ""{}
|
||||
_OcclusionTexture("", 2D) = ""{}
|
||||
}
|
||||
CGINCLUDE
|
||||
|
||||
// --------
|
||||
// Additional options for further customization
|
||||
// --------
|
||||
|
||||
// By default, a fixed sampling pattern is used in the AO estimator.
|
||||
// Although this gives preferable results in most cases, a completely
|
||||
// random sampling pattern could give aesthetically good results in some
|
||||
// cases. Comment out the line below to use the random pattern instead of
|
||||
// the fixed one.
|
||||
#define FIXED_SAMPLING_PATTERN 1
|
||||
|
||||
// The constant below determines the contrast of occlusion. Altough this
|
||||
// allows intentional over/under occlusion, currently is not exposed to the
|
||||
// editor, because it’s thought to be rarely useful.
|
||||
static const float kContrast = 0.6;
|
||||
|
||||
// The constant below controls the geometry-awareness of the blur filter.
|
||||
// The higher value, the more sensitive it is.
|
||||
static const float kGeom = 50;
|
||||
|
||||
// The constants below are used in the AO estimator. Beta is mainly used
|
||||
// for suppressing self-shadowing noise, and Epsilon is used to prevent
|
||||
// calculation underflow. See the paper (Morgan 2011 http://goo.gl/2iz3P)
|
||||
// for further details of these constants.
|
||||
static const float kBeta = 0.002;
|
||||
static const float kEpsilon = 1e-4;
|
||||
|
||||
// --------
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
#if _SAMPLECOUNT_LOWEST
|
||||
static const int _SampleCount = 3;
|
||||
#else
|
||||
int _SampleCount;
|
||||
#endif
|
||||
|
||||
// Global shader properties
|
||||
#if _SOURCE_GBUFFER
|
||||
sampler2D _CameraGBufferTexture2;
|
||||
sampler2D_float _CameraDepthTexture;
|
||||
float4x4 _WorldToCamera;
|
||||
#else
|
||||
sampler2D_float _CameraDepthNormalsTexture;
|
||||
#endif
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize;
|
||||
|
||||
sampler2D _OcclusionTexture;
|
||||
|
||||
// Material shader properties
|
||||
half _Intensity;
|
||||
float _Radius;
|
||||
float _TargetScale;
|
||||
float2 _BlurVector;
|
||||
|
||||
// Utility for sin/cos
|
||||
float2 CosSin(float theta)
|
||||
{
|
||||
float sn, cs;
|
||||
sincos(theta, sn, cs);
|
||||
return float2(cs, sn);
|
||||
}
|
||||
|
||||
// Gamma encoding function for AO value
|
||||
// (do nothing if in the linear mode)
|
||||
half EncodeAO(half x)
|
||||
{
|
||||
// Gamma encoding
|
||||
half x_g = 1 - pow(1 - x, 1 / 2.2);
|
||||
// ColorSpaceLuminance.w is 0 (gamma) or 1 (linear).
|
||||
return lerp(x_g, x, unity_ColorSpaceLuminance.w);
|
||||
}
|
||||
|
||||
// Pseudo random number generator with 2D argument
|
||||
float UVRandom(float u, float v)
|
||||
{
|
||||
float f = dot(float2(12.9898, 78.233), float2(u, v));
|
||||
return frac(43758.5453 * sin(f));
|
||||
}
|
||||
|
||||
// Interleaved gradient function from Jimenez 2014 http://goo.gl/eomGso
|
||||
float GradientNoise(float2 uv)
|
||||
{
|
||||
uv = floor(uv * _ScreenParams.xy);
|
||||
float f = dot(float2(0.06711056f, 0.00583715f), uv);
|
||||
return frac(52.9829189f * frac(f));
|
||||
}
|
||||
|
||||
// Boundary check for depth sampler
|
||||
// (returns a very large value if it lies out of bounds)
|
||||
float CheckBounds(float2 uv, float d)
|
||||
{
|
||||
float ob = any(uv < 0) + any(uv > 1);
|
||||
#if defined(UNITY_REVERSED_Z)
|
||||
ob += (d <= 0.00001);
|
||||
#else
|
||||
ob += (d >= 0.99999);
|
||||
#endif
|
||||
return ob * 1e8;
|
||||
}
|
||||
|
||||
// Depth/normal sampling functions
|
||||
float SampleDepth(float2 uv)
|
||||
{
|
||||
#if _SOURCE_GBUFFER
|
||||
float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv);
|
||||
return LinearEyeDepth(d) + CheckBounds(uv, d);
|
||||
#else
|
||||
float4 cdn = tex2D(_CameraDepthNormalsTexture, uv);
|
||||
float d = DecodeFloatRG(cdn.zw);
|
||||
return d * _ProjectionParams.z + CheckBounds(uv, d);
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 SampleNormal(float2 uv)
|
||||
{
|
||||
#if _SOURCE_GBUFFER
|
||||
float3 norm = tex2D(_CameraGBufferTexture2, uv).xyz * 2 - 1;
|
||||
return mul((float3x3)_WorldToCamera, norm);
|
||||
#else
|
||||
float4 cdn = tex2D(_CameraDepthNormalsTexture, uv);
|
||||
return DecodeViewNormalStereo(cdn) * float3(1, 1, -1);
|
||||
#endif
|
||||
}
|
||||
|
||||
float SampleDepthNormal(float2 uv, out float3 normal)
|
||||
{
|
||||
#if _SOURCE_GBUFFER
|
||||
normal = SampleNormal(uv);
|
||||
return SampleDepth(uv);
|
||||
#else
|
||||
float4 cdn = tex2D(_CameraDepthNormalsTexture, uv);
|
||||
normal = DecodeViewNormalStereo(cdn) * float3(1, 1, -1);
|
||||
float d = DecodeFloatRG(cdn.zw);
|
||||
return d * _ProjectionParams.z + CheckBounds(uv, d);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Reconstruct view-space position from UV and depth.
|
||||
// p11_22 = (unity_CameraProjection._11, unity_CameraProjection._22)
|
||||
// p13_31 = (unity_CameraProjection._13, unity_CameraProjection._23)
|
||||
float3 ReconstructViewPos(float2 uv, float depth, float2 p11_22, float2 p13_31)
|
||||
{
|
||||
return float3((uv * 2 - 1 - p13_31) / p11_22, 1) * depth;
|
||||
}
|
||||
|
||||
// Normal vector comparer (for geometry-aware weighting)
|
||||
half CompareNormal(half3 d1, half3 d2)
|
||||
{
|
||||
return pow((dot(d1, d2) + 1) * 0.5, kGeom);
|
||||
}
|
||||
|
||||
// Final combiner function
|
||||
half3 CombineOcclusion(half3 src, half3 ao)
|
||||
{
|
||||
return lerp(src, 0, EncodeAO(ao));
|
||||
}
|
||||
|
||||
// Sample point picker
|
||||
float3 PickSamplePoint(float2 uv, float index)
|
||||
{
|
||||
// Uniformaly distributed points on a unit sphere http://goo.gl/X2F1Ho
|
||||
#if FIXED_SAMPLING_PATTERN
|
||||
float gn = GradientNoise(uv * _TargetScale);
|
||||
float u = frac(UVRandom(0, index) + gn) * 2 - 1;
|
||||
float theta = (UVRandom(1, index) + gn) * UNITY_PI * 2;
|
||||
#else
|
||||
float u = UVRandom(uv.x + _Time.x, uv.y + index) * 2 - 1;
|
||||
float theta = UVRandom(-uv.x - _Time.x, uv.y + index) * UNITY_PI * 2;
|
||||
#endif
|
||||
float3 v = float3(CosSin(theta) * sqrt(1 - u * u), u);
|
||||
// Make them distributed between [0, _Radius]
|
||||
float l = sqrt((index + 1) / _SampleCount) * _Radius;
|
||||
return v * l;
|
||||
}
|
||||
|
||||
// Occlusion estimator function
|
||||
float EstimateOcclusion(float2 uv)
|
||||
{
|
||||
// Parameters used in coordinate conversion
|
||||
float3x3 proj = (float3x3)unity_CameraProjection;
|
||||
float2 p11_22 = float2(unity_CameraProjection._11, unity_CameraProjection._22);
|
||||
float2 p13_31 = float2(unity_CameraProjection._13, unity_CameraProjection._23);
|
||||
|
||||
// View space normal and depth
|
||||
float3 norm_o;
|
||||
float depth_o = SampleDepthNormal(uv, norm_o);
|
||||
|
||||
#if _SOURCE_DEPTHNORMALS
|
||||
// Offset the depth value to avoid precision error.
|
||||
// (depth in the DepthNormals mode has only 16-bit precision)
|
||||
depth_o -= _ProjectionParams.z / 65536;
|
||||
#endif
|
||||
|
||||
// Reconstruct the view-space position.
|
||||
float3 vpos_o = ReconstructViewPos(uv, depth_o, p11_22, p13_31);
|
||||
|
||||
// Distance-based AO estimator based on Morgan 2011 http://goo.gl/2iz3P
|
||||
float ao = 0.0;
|
||||
|
||||
for (int s = 0; s < _SampleCount; s++)
|
||||
{
|
||||
// Sample point
|
||||
float3 v_s1 = PickSamplePoint(uv, s);
|
||||
v_s1 = faceforward(v_s1, -norm_o, v_s1);
|
||||
float3 vpos_s1 = vpos_o + v_s1;
|
||||
|
||||
// Reproject the sample point
|
||||
float3 spos_s1 = mul(proj, vpos_s1);
|
||||
float2 uv_s1 = (spos_s1.xy / vpos_s1.z + 1) * 0.5;
|
||||
|
||||
// Depth at the sample point
|
||||
float depth_s1 = SampleDepth(uv_s1);
|
||||
|
||||
// Relative position of the sample point
|
||||
float3 vpos_s2 = ReconstructViewPos(uv_s1, depth_s1, p11_22, p13_31);
|
||||
float3 v_s2 = vpos_s2 - vpos_o;
|
||||
|
||||
// Estimate the obscurance value
|
||||
float a1 = max(dot(v_s2, norm_o) - kBeta * depth_o, 0);
|
||||
float a2 = dot(v_s2, v_s2) + kEpsilon;
|
||||
ao += a1 / a2;
|
||||
}
|
||||
|
||||
ao *= _Radius; // intensity normalization
|
||||
|
||||
// Apply other parameters.
|
||||
return pow(ao * _Intensity / _SampleCount, kContrast);
|
||||
}
|
||||
|
||||
// Geometry-aware separable blur filter (large kernel)
|
||||
half SeparableBlurLarge(sampler2D tex, float2 uv, float2 delta)
|
||||
{
|
||||
#if !SHADER_API_MOBILE
|
||||
// 9-tap Gaussian blur with adaptive sampling
|
||||
float2 uv1a = uv - delta;
|
||||
float2 uv1b = uv + delta;
|
||||
float2 uv2a = uv - delta * 2;
|
||||
float2 uv2b = uv + delta * 2;
|
||||
float2 uv3a = uv - delta * 3.2307692308;
|
||||
float2 uv3b = uv + delta * 3.2307692308;
|
||||
|
||||
half3 n0 = SampleNormal(uv);
|
||||
|
||||
half w0 = 0.37004405286;
|
||||
half w1a = CompareNormal(n0, SampleNormal(uv1a)) * 0.31718061674;
|
||||
half w1b = CompareNormal(n0, SampleNormal(uv1b)) * 0.31718061674;
|
||||
half w2a = CompareNormal(n0, SampleNormal(uv2a)) * 0.19823788546;
|
||||
half w2b = CompareNormal(n0, SampleNormal(uv2b)) * 0.19823788546;
|
||||
half w3a = CompareNormal(n0, SampleNormal(uv3a)) * 0.11453744493;
|
||||
half w3b = CompareNormal(n0, SampleNormal(uv3b)) * 0.11453744493;
|
||||
|
||||
half s = tex2D(_MainTex, uv).r * w0;
|
||||
s += tex2D(_MainTex, uv1a).r * w1a;
|
||||
s += tex2D(_MainTex, uv1b).r * w1b;
|
||||
s += tex2D(_MainTex, uv2a).r * w2a;
|
||||
s += tex2D(_MainTex, uv2b).r * w2b;
|
||||
s += tex2D(_MainTex, uv3a).r * w3a;
|
||||
s += tex2D(_MainTex, uv3b).r * w3b;
|
||||
|
||||
return s / (w0 + w1a + w1b + w2a + w2b + w3a + w3b);
|
||||
#else
|
||||
// 9-tap Gaussian blur with linear sampling
|
||||
// (less quality but slightly fast)
|
||||
float2 uv1a = uv - delta * 1.3846153846;
|
||||
float2 uv1b = uv + delta * 1.3846153846;
|
||||
float2 uv2a = uv - delta * 3.2307692308;
|
||||
float2 uv2b = uv + delta * 3.2307692308;
|
||||
|
||||
half3 n0 = SampleNormal(uv);
|
||||
|
||||
half w0 = 0.2270270270;
|
||||
half w1a = CompareNormal(n0, SampleNormal(uv1a)) * 0.3162162162;
|
||||
half w1b = CompareNormal(n0, SampleNormal(uv1b)) * 0.3162162162;
|
||||
half w2a = CompareNormal(n0, SampleNormal(uv2a)) * 0.0702702703;
|
||||
half w2b = CompareNormal(n0, SampleNormal(uv2b)) * 0.0702702703;
|
||||
|
||||
half s = tex2D(_MainTex, uv).r * w0;
|
||||
s += tex2D(_MainTex, uv1a).r * w1a;
|
||||
s += tex2D(_MainTex, uv1b).r * w1b;
|
||||
s += tex2D(_MainTex, uv2a).r * w2a;
|
||||
s += tex2D(_MainTex, uv2b).r * w2b;
|
||||
|
||||
return s / (w0 + w1a + w1b + w2a + w2b);
|
||||
#endif
|
||||
}
|
||||
|
||||
// Geometry-aware separable blur filter (small kernel)
|
||||
half SeparableBlurSmall(sampler2D tex, float2 uv, float2 delta)
|
||||
{
|
||||
float2 uv1 = uv - delta;
|
||||
float2 uv2 = uv + delta;
|
||||
|
||||
half3 n0 = SampleNormal(uv);
|
||||
|
||||
half w0 = 2;
|
||||
half w1 = CompareNormal(n0, SampleNormal(uv1));
|
||||
half w2 = CompareNormal(n0, SampleNormal(uv2));
|
||||
|
||||
half s = tex2D(_MainTex, uv).r * w0;
|
||||
s += tex2D(_MainTex, uv1).r * w1;
|
||||
s += tex2D(_MainTex, uv2).r * w2;
|
||||
|
||||
return s / (w0 + w1 + w2);
|
||||
}
|
||||
|
||||
// Pass 0: Occlusion estimation
|
||||
half4 frag_ao(v2f_img i) : SV_Target
|
||||
{
|
||||
return EstimateOcclusion(i.uv);
|
||||
}
|
||||
|
||||
// Pass 1: Primary blur filter
|
||||
half4 frag_blur1(v2f_img i) : SV_Target
|
||||
{
|
||||
float2 delta = _MainTex_TexelSize.xy * _BlurVector;
|
||||
return SeparableBlurLarge(_MainTex, i.uv, delta);
|
||||
}
|
||||
|
||||
// Pass 2: Secondary blur filter
|
||||
half4 frag_blur2(v2f_img i) : SV_Target
|
||||
{
|
||||
float2 delta = _MainTex_TexelSize.xy * _BlurVector;
|
||||
return SeparableBlurSmall(_MainTex, i.uv, delta);
|
||||
}
|
||||
|
||||
// Pass 3: Combiner for the forward mode
|
||||
struct v2f_multitex
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv0 : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f_multitex vert_multitex(appdata_img v)
|
||||
{
|
||||
// Handles vertically-flipped case.
|
||||
float vflip = sign(_MainTex_TexelSize.y);
|
||||
|
||||
v2f_multitex o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv0 = v.texcoord.xy;
|
||||
o.uv1 = (v.texcoord.xy - 0.5) * float2(1, vflip) + 0.5;
|
||||
return o;
|
||||
}
|
||||
|
||||
half4 frag_combine(v2f_multitex i) : SV_Target
|
||||
{
|
||||
half4 src = tex2D(_MainTex, i.uv0);
|
||||
half ao = tex2D(_OcclusionTexture, i.uv1).r;
|
||||
return half4(CombineOcclusion(src.rgb, ao), src.a);
|
||||
}
|
||||
|
||||
// Pass 4: Combiner for the ambient-only mode
|
||||
v2f_img vert_gbuffer(appdata_img v)
|
||||
{
|
||||
v2f_img o;
|
||||
o.pos = v.vertex * float4(2, 2, 0, 0) + float4(0, 0, 0, 1);
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
o.uv = v.texcoord * float2(1, -1) + float2(0, 1);
|
||||
#else
|
||||
o.uv = v.texcoord;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
#if !SHADER_API_GLES // excluding the MRT pass under GLES2
|
||||
|
||||
struct CombinerOutput
|
||||
{
|
||||
half4 gbuffer0 : SV_Target0;
|
||||
half4 gbuffer3 : SV_Target1;
|
||||
};
|
||||
|
||||
CombinerOutput frag_gbuffer_combine(v2f_img i)
|
||||
{
|
||||
half ao = tex2D(_OcclusionTexture, i.uv).r;
|
||||
CombinerOutput o;
|
||||
o.gbuffer0 = half4(0, 0, 0, ao);
|
||||
o.gbuffer3 = half4((half3)EncodeAO(ao), 0);
|
||||
return o;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
fixed4 frag_gbuffer_combine(v2f_img i) : SV_Target0
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Pass 5: Debug blit
|
||||
half4 frag_blit_ao(v2f_multitex i) : SV_Target
|
||||
{
|
||||
half4 src = tex2D(_MainTex, i.uv0);
|
||||
half ao = tex2D(_OcclusionTexture, i.uv1).r;
|
||||
return half4(CombineOcclusion(1, ao), src.a);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma multi_compile _SOURCE_DEPTHNORMALS _SOURCE_GBUFFER
|
||||
#pragma multi_compile _ _SAMPLECOUNT_LOWEST
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag_ao
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma multi_compile _SOURCE_DEPTHNORMALS _SOURCE_GBUFFER
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag_blur1
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma multi_compile _SOURCE_DEPTHNORMALS _SOURCE_GBUFFER
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag_blur2
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_multitex
|
||||
#pragma fragment frag_combine
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Blend Zero OneMinusSrcColor, Zero OneMinusSrcAlpha
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_gbuffer
|
||||
#pragma fragment frag_gbuffer_combine
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_multitex
|
||||
#pragma fragment frag_blit_ao
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 65e203e5acda447acbf9dc1ef78c4a39
|
||||
timeCreated: 1457327141
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/Bloom.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 193f90bb87f484c62ad73788d9cb2d44
|
||||
folderAsset: yes
|
||||
timeCreated: 1454052266
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
223
Assets/Cinematic Effects/Bloom/Bloom.cs
Normal file
|
@ -0,0 +1,223 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityStandardAssets.CinematicEffects
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Camera))]
|
||||
[AddComponentMenu("Image Effects/Cinematic/Bloom")]
|
||||
#if UNITY_5_4_OR_NEWER
|
||||
[ImageEffectAllowedInSceneView]
|
||||
#endif
|
||||
public class Bloom : MonoBehaviour
|
||||
{
|
||||
[Serializable]
|
||||
public struct Settings
|
||||
{
|
||||
[SerializeField]
|
||||
[Tooltip("Filters out pixels under this level of brightness.")]
|
||||
public float threshold;
|
||||
|
||||
public float thresholdGamma
|
||||
{
|
||||
set { threshold = value; }
|
||||
get { return Mathf.Max(0.0f, threshold); }
|
||||
}
|
||||
|
||||
public float thresholdLinear
|
||||
{
|
||||
set { threshold = Mathf.LinearToGammaSpace(value); }
|
||||
get { return Mathf.GammaToLinearSpace(thresholdGamma); }
|
||||
}
|
||||
|
||||
[SerializeField, Range(1, 7)]
|
||||
[Tooltip("Changes extent of veiling effects in a screen resolution-independent fashion.")]
|
||||
public float radius;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("Blend factor of the result image.")]
|
||||
public float intensity;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("Controls filter quality and buffer resolution.")]
|
||||
public bool highQuality;
|
||||
|
||||
[SerializeField]
|
||||
[Tooltip("Reduces flashing noise with an additional filter.")]
|
||||
public bool antiFlicker;
|
||||
|
||||
public static Settings defaultSettings
|
||||
{
|
||||
get
|
||||
{
|
||||
var settings = new Settings
|
||||
{
|
||||
threshold = 0.9f,
|
||||
radius = 2.0f,
|
||||
intensity = 0.7f,
|
||||
highQuality = true,
|
||||
antiFlicker = false
|
||||
};
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region Public Properties
|
||||
|
||||
[SerializeField]
|
||||
public Settings settings = Settings.defaultSettings;
|
||||
|
||||
#endregion
|
||||
|
||||
[SerializeField, HideInInspector]
|
||||
private Shader m_Shader;
|
||||
|
||||
public Shader shader
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Shader == null)
|
||||
{
|
||||
const string shaderName = "Hidden/Image Effects/Cinematic/Bloom";
|
||||
m_Shader = Shader.Find(shaderName);
|
||||
}
|
||||
|
||||
return m_Shader;
|
||||
}
|
||||
}
|
||||
|
||||
private Material m_Material;
|
||||
public Material material
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_Material == null)
|
||||
m_Material = ImageEffectHelper.CheckShaderAndCreateMaterial(shader);
|
||||
|
||||
return m_Material;
|
||||
}
|
||||
}
|
||||
|
||||
#region Private Members
|
||||
|
||||
const int kMaxIterations = 16;
|
||||
RenderTexture[] m_blurBuffer1 = new RenderTexture[kMaxIterations];
|
||||
RenderTexture[] m_blurBuffer2 = new RenderTexture[kMaxIterations];
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (!ImageEffectHelper.IsSupported(shader, true, false, this))
|
||||
enabled = false;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (m_Material != null)
|
||||
DestroyImmediate(m_Material);
|
||||
|
||||
m_Material = null;
|
||||
}
|
||||
|
||||
private void OnRenderImage(RenderTexture source, RenderTexture destination)
|
||||
{
|
||||
var useRGBM = Application.isMobilePlatform;
|
||||
var isGamma = QualitySettings.activeColorSpace == ColorSpace.Gamma;
|
||||
|
||||
// source texture size
|
||||
var tw = source.width;
|
||||
var th = source.height;
|
||||
|
||||
// halve the texture size for the low quality mode
|
||||
if (!settings.highQuality)
|
||||
{
|
||||
tw /= 2;
|
||||
th /= 2;
|
||||
}
|
||||
|
||||
// blur buffer format
|
||||
var rtFormat = useRGBM ? RenderTextureFormat.Default : RenderTextureFormat.DefaultHDR;
|
||||
|
||||
// determine the iteration count
|
||||
var logh = Mathf.Log(th, 2) + settings.radius - 8;
|
||||
var logh_i = (int)logh;
|
||||
var iterations = Mathf.Clamp(logh_i, 1, kMaxIterations);
|
||||
|
||||
// update the shader properties
|
||||
var threshold = settings.thresholdLinear;
|
||||
material.SetFloat("_Threshold", threshold);
|
||||
|
||||
const float softKneeRatio = 0.5f;
|
||||
var knee = threshold * softKneeRatio + 1e-5f;
|
||||
var curve = new Vector3(threshold - knee, knee * 2, 0.25f / knee);
|
||||
material.SetVector("_Curve", curve);
|
||||
|
||||
var pfo = !settings.highQuality && settings.antiFlicker;
|
||||
material.SetFloat("_PrefilterOffs", pfo ? -0.5f : 0.0f);
|
||||
|
||||
material.SetFloat("_SampleScale", 0.5f + logh - logh_i);
|
||||
material.SetFloat("_Intensity", Mathf.Max(0.0f, settings.intensity));
|
||||
|
||||
if (settings.highQuality)
|
||||
material.EnableKeyword("HIGH_QUALITY");
|
||||
else
|
||||
material.DisableKeyword("HIGH_QUALITY");
|
||||
|
||||
if (settings.antiFlicker)
|
||||
material.EnableKeyword("ANTI_FLICKER");
|
||||
else
|
||||
material.DisableKeyword("ANTI_FLICKER");
|
||||
|
||||
if (isGamma)
|
||||
{
|
||||
material.DisableKeyword("LINEAR_COLOR");
|
||||
material.EnableKeyword("GAMMA_COLOR");
|
||||
}
|
||||
else
|
||||
{
|
||||
material.EnableKeyword("LINEAR_COLOR");
|
||||
material.DisableKeyword("GAMMA_COLOR");
|
||||
}
|
||||
|
||||
// prefilter pass
|
||||
var prefiltered = RenderTexture.GetTemporary(tw, th, 0, rtFormat);
|
||||
Graphics.Blit(source, prefiltered, material, 0);
|
||||
|
||||
// construct a mip pyramid
|
||||
var last = prefiltered;
|
||||
for (var level = 0; level < iterations; level++)
|
||||
{
|
||||
m_blurBuffer1[level] = RenderTexture.GetTemporary(last.width / 2, last.height / 2, 0, rtFormat);
|
||||
Graphics.Blit(last, m_blurBuffer1[level], material, (level == 0) ? 1 : 2);
|
||||
last = m_blurBuffer1[level];
|
||||
}
|
||||
|
||||
// upsample and combine loop
|
||||
for (var level = iterations - 2; level >= 0; level--)
|
||||
{
|
||||
var basetex = m_blurBuffer1[level];
|
||||
material.SetTexture("_BaseTex", basetex);
|
||||
m_blurBuffer2[level] = RenderTexture.GetTemporary(basetex.width, basetex.height, 0, rtFormat);
|
||||
Graphics.Blit(last, m_blurBuffer2[level], material, 3);
|
||||
last = m_blurBuffer2[level];
|
||||
}
|
||||
|
||||
// finish process
|
||||
material.SetTexture("_BaseTex", source);
|
||||
Graphics.Blit(last, destination, material, 4);
|
||||
|
||||
// release the temporary buffers
|
||||
for (var i = 0; i < kMaxIterations; i++)
|
||||
{
|
||||
if (m_blurBuffer1[i] != null) RenderTexture.ReleaseTemporary(m_blurBuffer1[i]);
|
||||
if (m_blurBuffer2[i] != null) RenderTexture.ReleaseTemporary(m_blurBuffer2[i]);
|
||||
m_blurBuffer1[i] = null;
|
||||
m_blurBuffer2[i] = null;
|
||||
}
|
||||
|
||||
RenderTexture.ReleaseTemporary(prefiltered);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
13
Assets/Cinematic Effects/Bloom/Bloom.cs.meta
Normal file
|
@ -0,0 +1,13 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 32187365ced0c42219cde2b57c99b323
|
||||
timeCreated: 1454052338
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- _shader: {fileID: 4800000, guid: e45d4f28262b04d10a075856ab5fdb5e, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/Bloom/Editor.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 92a024b1f1430409eb656f65969aa3d5
|
||||
folderAsset: yes
|
||||
timeCreated: 1454052266
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
32
Assets/Cinematic Effects/Bloom/Editor/BloomEditor.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace UnityStandardAssets.CinematicEffects
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(Bloom))]
|
||||
public class BloomEditor : Editor
|
||||
{
|
||||
[NonSerialized]
|
||||
private List<SerializedProperty> m_Properties = new List<SerializedProperty>();
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
var settings = FieldFinder<Bloom>.GetField(x => x.settings);
|
||||
foreach (var setting in settings.FieldType.GetFields())
|
||||
{
|
||||
var prop = settings.Name + "." + setting.Name;
|
||||
m_Properties.Add(serializedObject.FindProperty(prop));
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
foreach (var property in m_Properties)
|
||||
EditorGUILayout.PropertyField(property);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
12
Assets/Cinematic Effects/Bloom/Editor/BloomEditor.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 38020a6029a85434a95a6f725a5aae5f
|
||||
timeCreated: 1454052266
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/Bloom/Resources.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4af3202dbe79e460e9be42bcb6509fe0
|
||||
folderAsset: yes
|
||||
timeCreated: 1454052266
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
284
Assets/Cinematic Effects/Bloom/Resources/Bloom.shader
Normal file
|
@ -0,0 +1,284 @@
|
|||
Shader "Hidden/Image Effects/Cinematic/Bloom"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex("", 2D) = "" {}
|
||||
_BaseTex("", 2D) = "" {}
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
// Mobile: use RGBM instead of float/half RGB
|
||||
#define USE_RGBM defined(SHADER_API_MOBILE)
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _BaseTex;
|
||||
float2 _MainTex_TexelSize;
|
||||
float2 _BaseTex_TexelSize;
|
||||
|
||||
float _PrefilterOffs;
|
||||
half _Threshold;
|
||||
half3 _Curve;
|
||||
float _SampleScale;
|
||||
half _Intensity;
|
||||
|
||||
// Brightness function
|
||||
half Brightness(half3 c)
|
||||
{
|
||||
return max(max(c.r, c.g), c.b);
|
||||
}
|
||||
|
||||
// 3-tap median filter
|
||||
half3 Median(half3 a, half3 b, half3 c)
|
||||
{
|
||||
return a + b + c - min(min(a, b), c) - max(max(a, b), c);
|
||||
}
|
||||
|
||||
// Clamp HDR value within a safe range
|
||||
half3 SafeHDR(half3 c) { return min(c, 65000); }
|
||||
half4 SafeHDR(half4 c) { return min(c, 65000); }
|
||||
|
||||
// RGBM encoding/decoding
|
||||
half4 EncodeHDR(float3 rgb)
|
||||
{
|
||||
#if USE_RGBM
|
||||
rgb *= 1.0 / 8;
|
||||
float m = max(max(rgb.r, rgb.g), max(rgb.b, 1e-6));
|
||||
m = ceil(m * 255) / 255;
|
||||
return half4(rgb / m, m);
|
||||
#else
|
||||
return half4(rgb, 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 DecodeHDR(half4 rgba)
|
||||
{
|
||||
#if USE_RGBM
|
||||
return rgba.rgb * rgba.a * 8;
|
||||
#else
|
||||
return rgba.rgb;
|
||||
#endif
|
||||
}
|
||||
|
||||
// Downsample with a 4x4 box filter
|
||||
half3 DownsampleFilter(float2 uv)
|
||||
{
|
||||
float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1);
|
||||
|
||||
half3 s;
|
||||
s = DecodeHDR(tex2D(_MainTex, uv + d.xy));
|
||||
s += DecodeHDR(tex2D(_MainTex, uv + d.zy));
|
||||
s += DecodeHDR(tex2D(_MainTex, uv + d.xw));
|
||||
s += DecodeHDR(tex2D(_MainTex, uv + d.zw));
|
||||
|
||||
return s * (1.0 / 4);
|
||||
}
|
||||
|
||||
// Downsample with a 4x4 box filter + anti-flicker filter
|
||||
half3 DownsampleAntiFlickerFilter(float2 uv)
|
||||
{
|
||||
float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1);
|
||||
|
||||
half3 s1 = DecodeHDR(tex2D(_MainTex, uv + d.xy));
|
||||
half3 s2 = DecodeHDR(tex2D(_MainTex, uv + d.zy));
|
||||
half3 s3 = DecodeHDR(tex2D(_MainTex, uv + d.xw));
|
||||
half3 s4 = DecodeHDR(tex2D(_MainTex, uv + d.zw));
|
||||
|
||||
// Karis's luma weighted average
|
||||
half s1w = 1 / (Brightness(s1) + 1);
|
||||
half s2w = 1 / (Brightness(s2) + 1);
|
||||
half s3w = 1 / (Brightness(s3) + 1);
|
||||
half s4w = 1 / (Brightness(s4) + 1);
|
||||
half one_div_wsum = 1.0 / (s1w + s2w + s3w + s4w);
|
||||
|
||||
return (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * one_div_wsum;
|
||||
}
|
||||
|
||||
half3 UpsampleFilter(float2 uv)
|
||||
{
|
||||
#if HIGH_QUALITY
|
||||
// 9-tap bilinear upsampler (tent filter)
|
||||
float4 d = _MainTex_TexelSize.xyxy * float4(1, 1, -1, 0) * _SampleScale;
|
||||
|
||||
half3 s;
|
||||
s = DecodeHDR(tex2D(_MainTex, uv - d.xy));
|
||||
s += DecodeHDR(tex2D(_MainTex, uv - d.wy)) * 2;
|
||||
s += DecodeHDR(tex2D(_MainTex, uv - d.zy));
|
||||
|
||||
s += DecodeHDR(tex2D(_MainTex, uv + d.zw)) * 2;
|
||||
s += DecodeHDR(tex2D(_MainTex, uv )) * 4;
|
||||
s += DecodeHDR(tex2D(_MainTex, uv + d.xw)) * 2;
|
||||
|
||||
s += DecodeHDR(tex2D(_MainTex, uv + d.zy));
|
||||
s += DecodeHDR(tex2D(_MainTex, uv + d.wy)) * 2;
|
||||
s += DecodeHDR(tex2D(_MainTex, uv + d.xy));
|
||||
|
||||
return s * (1.0 / 16);
|
||||
#else
|
||||
// 4-tap bilinear upsampler
|
||||
float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1) * (_SampleScale * 0.5);
|
||||
|
||||
half3 s;
|
||||
s = DecodeHDR(tex2D(_MainTex, uv + d.xy));
|
||||
s += DecodeHDR(tex2D(_MainTex, uv + d.zy));
|
||||
s += DecodeHDR(tex2D(_MainTex, uv + d.xw));
|
||||
s += DecodeHDR(tex2D(_MainTex, uv + d.zw));
|
||||
|
||||
return s * (1.0 / 4);
|
||||
#endif
|
||||
}
|
||||
|
||||
//
|
||||
// Vertex shader
|
||||
//
|
||||
|
||||
struct v2f_multitex
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uvMain : TEXCOORD0;
|
||||
float2 uvBase : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f_multitex vert_multitex(appdata_full v)
|
||||
{
|
||||
v2f_multitex o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uvMain = v.texcoord.xy;
|
||||
o.uvBase = v.texcoord.xy;
|
||||
#if UNITY_UV_STARTS_AT_TOP
|
||||
if (_BaseTex_TexelSize.y < 0.0)
|
||||
o.uvBase.y = 1.0 - v.texcoord.y;
|
||||
#endif
|
||||
return o;
|
||||
}
|
||||
|
||||
//
|
||||
// fragment shader
|
||||
//
|
||||
|
||||
half4 frag_prefilter(v2f_img i) : SV_Target
|
||||
{
|
||||
float2 uv = i.uv + _MainTex_TexelSize.xy * _PrefilterOffs;
|
||||
|
||||
#if ANTI_FLICKER
|
||||
float3 d = _MainTex_TexelSize.xyx * float3(1, 1, 0);
|
||||
half4 s0 = SafeHDR(tex2D(_MainTex, uv));
|
||||
half3 s1 = SafeHDR(tex2D(_MainTex, uv - d.xz).rgb);
|
||||
half3 s2 = SafeHDR(tex2D(_MainTex, uv + d.xz).rgb);
|
||||
half3 s3 = SafeHDR(tex2D(_MainTex, uv - d.zy).rgb);
|
||||
half3 s4 = SafeHDR(tex2D(_MainTex, uv + d.zy).rgb);
|
||||
half3 m = Median(Median(s0.rgb, s1, s2), s3, s4);
|
||||
#else
|
||||
half4 s0 = SafeHDR(tex2D(_MainTex, uv));
|
||||
half3 m = s0.rgb;
|
||||
#endif
|
||||
|
||||
#if GAMMA_COLOR
|
||||
m = GammaToLinearSpace(m);
|
||||
#endif
|
||||
// Pixel brightness
|
||||
half br = Brightness(m);
|
||||
|
||||
// Under-threshold part: quadratic curve
|
||||
half rq = clamp(br - _Curve.x, 0, _Curve.y);
|
||||
rq = _Curve.z * rq * rq;
|
||||
|
||||
// Combine and apply the brightness response curve.
|
||||
m *= max(rq, br - _Threshold) / (br + 1e-5);
|
||||
|
||||
return EncodeHDR(m);
|
||||
}
|
||||
|
||||
half4 frag_downsample1(v2f_img i) : SV_Target
|
||||
{
|
||||
#if ANTI_FLICKER
|
||||
return EncodeHDR(DownsampleAntiFlickerFilter(i.uv));
|
||||
#else
|
||||
return EncodeHDR(DownsampleFilter(i.uv));
|
||||
#endif
|
||||
}
|
||||
|
||||
half4 frag_downsample2(v2f_img i) : SV_Target
|
||||
{
|
||||
return EncodeHDR(DownsampleFilter(i.uv));
|
||||
}
|
||||
|
||||
half4 frag_upsample(v2f_multitex i) : SV_Target
|
||||
{
|
||||
half3 base = DecodeHDR(tex2D(_BaseTex, i.uvBase));
|
||||
half3 blur = UpsampleFilter(i.uvMain);
|
||||
return EncodeHDR(base + blur);
|
||||
}
|
||||
|
||||
half4 frag_upsample_final(v2f_multitex i) : SV_Target
|
||||
{
|
||||
half4 base = tex2D(_BaseTex, i.uvBase);
|
||||
half3 blur = UpsampleFilter(i.uvMain);
|
||||
#if GAMMA_COLOR
|
||||
base.rgb = GammaToLinearSpace(base.rgb);
|
||||
#endif
|
||||
half3 cout = base.rgb + blur * _Intensity;
|
||||
#if GAMMA_COLOR
|
||||
cout = LinearToGammaSpace(cout);
|
||||
#endif
|
||||
return half4(cout, base.a);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
SubShader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma multi_compile _ ANTI_FLICKER
|
||||
#pragma multi_compile LINEAR_COLOR GAMMA_COLOR
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag_prefilter
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma multi_compile _ ANTI_FLICKER
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag_downsample1
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag_downsample2
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma multi_compile _ HIGH_QUALITY
|
||||
#pragma vertex vert_multitex
|
||||
#pragma fragment frag_upsample
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
CGPROGRAM
|
||||
#pragma multi_compile _ HIGH_QUALITY
|
||||
#pragma multi_compile LINEAR_COLOR GAMMA_COLOR
|
||||
#pragma vertex vert_multitex
|
||||
#pragma fragment frag_upsample_final
|
||||
#pragma target 3.0
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e45d4f28262b04d10a075856ab5fdb5e
|
||||
timeCreated: 1454052270
|
||||
licenseType: Pro
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/BloomBeta.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c6eb038cfff9e4dd990eeca4d9f4013f
|
||||
folderAsset: yes
|
||||
timeCreated: 1461974392
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/BloomBeta/Editor.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 59c160308a8e47545a7b1baa9377c744
|
||||
folderAsset: yes
|
||||
timeCreated: 1443580217
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,526 @@
|
|||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
using System;
|
||||
|
||||
public class CameraDirtTextureGenerator : EditorWindow
|
||||
{
|
||||
|
||||
|
||||
Texture2D m_DestinationTexture = null;
|
||||
|
||||
[SerializeField]
|
||||
int m_PassCount;
|
||||
|
||||
|
||||
[SerializeField]
|
||||
BokehGenerationPass[] m_BokehPasses = new BokehGenerationPass[5];
|
||||
|
||||
[Serializable]
|
||||
class BokehGenerationPass
|
||||
{
|
||||
[SerializeField]
|
||||
public Texture2D m_BokehTexture;
|
||||
[SerializeField]
|
||||
public float m_MinimumSize = 100.0f;
|
||||
[SerializeField]
|
||||
public float m_MaximumSize = 200.0f;
|
||||
[SerializeField]
|
||||
public float m_Density = 0.1f;
|
||||
[SerializeField]
|
||||
public float m_MinIntensity = 0.1f;
|
||||
[SerializeField]
|
||||
public float m_MaxIntensity = 0.3f;
|
||||
[SerializeField]
|
||||
public float m_BlurRadius = 1;
|
||||
[SerializeField]
|
||||
public float m_VignettePower = 0.5f;
|
||||
[SerializeField]
|
||||
public float m_ChromaticAberration = 20.0f;
|
||||
[SerializeField]
|
||||
public float m_HueVariation = 0.3f;
|
||||
[SerializeField]
|
||||
public bool m_RandomRotation = false;
|
||||
}
|
||||
|
||||
List<Vector3>[] m_Positions = new List<Vector3>[5];
|
||||
float[] m_MinimumDistance = new float[5];
|
||||
|
||||
Vector2 m_ScrollPos;
|
||||
|
||||
[MenuItem("Window/Bokeh Texture Generator")]
|
||||
public static void ShowWindow()
|
||||
{
|
||||
EditorWindow.GetWindow(typeof(CameraDirtTextureGenerator));
|
||||
}
|
||||
|
||||
|
||||
GUIStyle m_Background1;
|
||||
GUIStyle m_Background2;
|
||||
GUIStyle m_Background3;
|
||||
GUIStyle m_Background4;
|
||||
void OnEnable()
|
||||
{
|
||||
m_Background1 = new GUIStyle();
|
||||
m_Background1.normal.background = MakeTex(600, 1, new Color(1.0f, 1.0f, 1.0f, 0.1f));
|
||||
m_Background2 = new GUIStyle();
|
||||
m_Background2.normal.background = MakeTex(600, 1, new Color(1.0f, 1.0f, 1.0f, 0.0f));
|
||||
m_Background3 = new GUIStyle();
|
||||
m_Background3.normal.background = MakeTex(600, 1, new Color(1.0f, 1.0f, 1.0f, 0.05f));
|
||||
m_Background4 = new GUIStyle();
|
||||
m_Background4.normal.background = MakeTex(600, 1, new Color(0.0f, 0.0f, 0.0f, 1.0f));
|
||||
|
||||
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
GameObject.DestroyImmediate(m_Background1.normal.background);
|
||||
GameObject.DestroyImmediate(m_Background2.normal.background);
|
||||
GameObject.DestroyImmediate(m_Background3.normal.background);
|
||||
GameObject.DestroyImmediate(m_Background4.normal.background);
|
||||
}
|
||||
|
||||
void CreateAndSetTexture()
|
||||
{
|
||||
Texture2D tmp = new Texture2D(m_Width, m_Height);
|
||||
var bytes = tmp.EncodeToPNG();
|
||||
File.WriteAllBytes("Assets/UB_BokehTexture.png", bytes);
|
||||
AssetDatabase.ImportAsset("Assets/UB_BokehTexture.png");
|
||||
|
||||
m_DestinationTexture = (Texture2D)AssetDatabase.LoadAssetAtPath("Assets/UB_BokehTexture.png", typeof(Texture2D));
|
||||
}
|
||||
|
||||
int m_Width = 1280;
|
||||
int m_Height = 720;
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
Undo.RecordObject(this, "Lens Bokeh Texture Generator");
|
||||
|
||||
GUILayout.Label("SETTINGS", EditorStyles.boldLabel);
|
||||
|
||||
m_DestinationTexture = (Texture2D)EditorGUILayout.ObjectField("Destination Texture", m_DestinationTexture, typeof(Texture2D), false);
|
||||
|
||||
if (m_DestinationTexture == null)
|
||||
{
|
||||
GUILayout.Label("Please set or create a destination texture.");
|
||||
GUILayout.BeginHorizontal();
|
||||
m_Width = Mathf.Clamp(EditorGUILayout.IntField("Width", m_Width),10, 4096);
|
||||
m_Height = Mathf.Clamp(EditorGUILayout.IntField("Height", m_Height), 10, 4096);
|
||||
GUILayout.EndHorizontal();
|
||||
if (GUILayout.Button("Create and set Texture"))
|
||||
{
|
||||
CreateAndSetTexture();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_PassCount = Mathf.Clamp(EditorGUILayout.IntField("Layer Count", m_PassCount), 1, 5);
|
||||
GUILayout.Space(20.0f);
|
||||
GUILayout.Label("LAYERS", EditorStyles.boldLabel);
|
||||
m_ScrollPos = GUILayout.BeginScrollView(m_ScrollPos);
|
||||
for (int i = 0; i < m_PassCount; ++i)
|
||||
{
|
||||
GUILayout.BeginVertical(i % 2 == 0 ? m_Background3 : m_Background1);
|
||||
BokehGenerationPass p = m_BokehPasses[i];
|
||||
p.m_BokehTexture = (Texture2D)EditorGUILayout.ObjectField("Sprite Texture", p.m_BokehTexture, typeof(Texture2D), false);
|
||||
p.m_MinimumSize = DoSlider("Minimum Size", p.m_MinimumSize, 20.0f, 400.0f);
|
||||
p.m_MaximumSize = DoSlider("Maximum Size", p.m_MaximumSize, 20.0f, 400.0f);
|
||||
p.m_BlurRadius = DoSlider("Blur Radius", p.m_BlurRadius, 0.0f, 10.0f);
|
||||
p.m_VignettePower = DoSlider("Vignette Power", p.m_VignettePower, 0.0f, 10.0f);
|
||||
p.m_HueVariation = DoSlider("Hue Variation", p.m_HueVariation, 0.0f, 0.8f);
|
||||
p.m_MinIntensity = DoSlider("Minimum Intensity", p.m_MinIntensity, 0.0f, 1.0f);
|
||||
p.m_MaxIntensity = DoSlider("Maximum Intensity", p.m_MaxIntensity, 0.0f, 1.0f);
|
||||
p.m_Density = DoSlider("Density", p.m_Density, 0.0f, 1.0f);
|
||||
p.m_ChromaticAberration = DoSlider("Chromatic Aberration", p.m_ChromaticAberration, 0.0f, 50.0f);
|
||||
p.m_RandomRotation = EditorGUILayout.Toggle("Random Rotation", p.m_RandomRotation);
|
||||
GUILayout.Space(20.0f);
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
GUILayout.EndScrollView();
|
||||
|
||||
|
||||
|
||||
|
||||
if (GUILayout.Button("Generate Bokeh Texture"))
|
||||
{
|
||||
GenerateTexture();
|
||||
}
|
||||
|
||||
if (m_DestinationTexture != null)
|
||||
{
|
||||
GUILayout.BeginVertical(m_Background4);
|
||||
|
||||
float w = m_DestinationTexture.width;
|
||||
if (m_DestinationTexture.width > 300.0f)
|
||||
w = 300.0f;
|
||||
|
||||
float h = ((float)m_DestinationTexture.height / (float)m_DestinationTexture.width) * w;
|
||||
|
||||
Rect r = GUILayoutUtility.GetRect(w, h);
|
||||
|
||||
|
||||
r.position = new Vector2(r.width * 0.5f - w*0.5f, r.position.y);
|
||||
|
||||
r.height = h;
|
||||
r.width = w;
|
||||
|
||||
//Debug.Log("r=" + h);
|
||||
EditorGUI.DrawPreviewTexture(r, m_DestinationTexture);
|
||||
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (GUI.changed)
|
||||
{
|
||||
EditorUtility.SetDirty(this);
|
||||
}
|
||||
}
|
||||
|
||||
float DoSlider(string label, float value, float min, float max)
|
||||
{
|
||||
float v = value;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
v = Mathf.Clamp(EditorGUILayout.FloatField(label, v), min, max);
|
||||
v = GUILayout.HorizontalSlider(v, min, max);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
Material m_MixerMaterial = null;
|
||||
|
||||
void GenerateTexture()
|
||||
{
|
||||
for (int i = 0; i < m_Positions.Length; ++i)
|
||||
{
|
||||
m_Positions[i] = new List<Vector3>();
|
||||
m_MinimumDistance[i] = 1.0f;
|
||||
}
|
||||
|
||||
Material bokehMaterial = new Material(Shader.Find("Hidden/Ultimate/BokehTexture"));
|
||||
bokehMaterial.hideFlags = HideFlags.HideAndDontSave;
|
||||
|
||||
Material blurMaterial = new Material(Shader.Find("Hidden/Ultimate/Sampling"));
|
||||
blurMaterial.hideFlags = HideFlags.HideAndDontSave;
|
||||
|
||||
Material miscMaterial = new Material(Shader.Find("Hidden/Ultimate/BokehMisc"));
|
||||
miscMaterial.hideFlags = HideFlags.HideAndDontSave;
|
||||
|
||||
Material mixerMaterial = new Material(Shader.Find("Hidden/Ultimate/BloomMixer"));
|
||||
mixerMaterial.hideFlags = HideFlags.HideAndDontSave;
|
||||
|
||||
m_MixerMaterial = mixerMaterial;
|
||||
|
||||
RenderTexture accumulation = null;
|
||||
for (int i = 0; i < m_PassCount; ++i)
|
||||
{
|
||||
RenderTexture current = GenerateTexture(i, bokehMaterial, blurMaterial, miscMaterial, m_DestinationTexture.width, m_DestinationTexture.height, m_BokehPasses[i]);
|
||||
if (accumulation == null && current != null)
|
||||
accumulation = current;
|
||||
else if (current != null)
|
||||
{
|
||||
RenderTextureAdditive(current, accumulation, 1.0f);
|
||||
RenderTexture.ReleaseTemporary(current);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string path = AssetDatabase.GetAssetPath(m_DestinationTexture);
|
||||
|
||||
Texture2D newTexture = new Texture2D(m_DestinationTexture.width, m_DestinationTexture.height);
|
||||
|
||||
RenderTexture.active = accumulation;
|
||||
newTexture.ReadPixels(new Rect(0, 0, newTexture.width, newTexture.height), 0, 0);
|
||||
newTexture.Apply();
|
||||
|
||||
var bytes = newTexture.EncodeToPNG();
|
||||
File.WriteAllBytes(path, bytes);
|
||||
AssetDatabase.ImportAsset(path);
|
||||
|
||||
GameObject.DestroyImmediate(bokehMaterial);
|
||||
GameObject.DestroyImmediate(miscMaterial);
|
||||
GameObject.DestroyImmediate(mixerMaterial);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private RenderTexture GenerateTexture(int idx, Material material, Material blurMaterial, Material miscMaterial,int width, int height, BokehGenerationPass p)
|
||||
{
|
||||
RenderTexture rtA = RenderTexture.GetTemporary(width, height);
|
||||
//RenderTexture lastActive = RenderTexture.active;
|
||||
|
||||
material.mainTexture = p.m_BokehTexture;
|
||||
|
||||
RenderTexture.active = rtA;
|
||||
GL.Clear(true, true, Color.black);
|
||||
|
||||
|
||||
//GL.LoadPixelMatrix(0,width,0,height);
|
||||
//GL.LoadPixelMatrix(0, width, 0, height);
|
||||
Matrix4x4 proj = Matrix4x4.Ortho(0, width, 0, height, -1.0f, 1.0f);
|
||||
|
||||
material.SetMatrix("_MeshProjectionMatrix", proj);
|
||||
|
||||
int nbPixel = width * height;
|
||||
int nbQuad = (int)(p.m_Density * 0.0004f * nbPixel);
|
||||
material.SetFloat("_Intensity", UnityEngine.Random.Range( p.m_MinIntensity, p.m_MaxIntensity) );
|
||||
|
||||
float cellSize = Mathf.Max( Mathf.Sqrt(nbQuad), 0.1f);
|
||||
|
||||
float xStep = (float)width / cellSize;
|
||||
float yStep = (float)height / cellSize;
|
||||
|
||||
for (float i = 0; i < width; i += xStep)
|
||||
{
|
||||
for (float j = 0; j < height; j += yStep)
|
||||
{
|
||||
|
||||
Color tint = new Color(UnityEngine.Random.Range(1.0f - p.m_HueVariation, 1.0f), UnityEngine.Random.Range(1.0f - p.m_HueVariation, 1.0f), UnityEngine.Random.Range(1.0f - p.m_HueVariation, 1.0f));
|
||||
material.SetColor("_Tint", tint);
|
||||
material.SetPass(0);
|
||||
float size = UnityEngine.Random.Range(p.m_MinimumSize, p.m_MaximumSize);
|
||||
|
||||
//float x = UnityEngine.Random.Range(-1f, 1f);
|
||||
//float y = UnityEngine.Random.Range(-1f, 1f);
|
||||
|
||||
|
||||
float x = (i + UnityEngine.Random.Range(0, xStep)) / width * 2.0f - 1.0f;
|
||||
float y = (j + UnityEngine.Random.Range(0, yStep)) / height * 2.0f - 1.0f;
|
||||
|
||||
float dist = new Vector2(x, y).magnitude;
|
||||
float sizeMul = Mathf.Min(Mathf.Pow(dist, p.m_VignettePower), 1.0f);
|
||||
|
||||
|
||||
float s = sizeMul > 0.5f ? size * sizeMul : 0.0f;
|
||||
float angle = UnityEngine.Random.Range(0.0f, p.m_RandomRotation ? 360.0f : 0.0f);
|
||||
Vector3 nDiv = new Vector3(1.0f / width, 1.0f / height, 0.0f);
|
||||
Vector3 tl = RotateZ(new Vector3(-s, -s, 0.0f), angle);
|
||||
Vector3 tr = RotateZ(new Vector3(s, -s, 0f), angle);
|
||||
Vector3 br = RotateZ(new Vector3(s, s, 0f), angle);
|
||||
Vector3 bl = RotateZ(new Vector3(-s, s, 0f), angle);
|
||||
|
||||
tl = new Vector3(tl.x * nDiv.x, tl.y * nDiv.y, 0.0f);
|
||||
tr = new Vector3(tr.x * nDiv.x, tr.y * nDiv.y, 0.0f);
|
||||
br = new Vector3(br.x * nDiv.x, br.y * nDiv.y, 0.0f);
|
||||
bl = new Vector3(bl.x * nDiv.x, bl.y * nDiv.y, 0.0f);
|
||||
|
||||
|
||||
DrawQuad(x, y, tl, tr, br, bl);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (material.SetPass(0))
|
||||
{
|
||||
|
||||
/*for (int i = 0; i < nbQuad; ++i)
|
||||
{
|
||||
Color tint = new Color(UnityEngine.Random.Range(1.0f - p.m_HueVariation, 1.0f), UnityEngine.Random.Range(1.0f - p.m_HueVariation, 1.0f), UnityEngine.Random.Range(1.0f - p.m_HueVariation, 1.0f));
|
||||
material.SetColor("_Tint", tint);
|
||||
material.SetPass(0);
|
||||
float size = UnityEngine.Random.Range(p.m_MinimumSize, p.m_MaximumSize);
|
||||
|
||||
//float x = UnityEngine.Random.Range(-1f, 1f);
|
||||
//float y = UnityEngine.Random.Range(-1f, 1f);
|
||||
|
||||
Vector3 pos = PickPosition(idx);
|
||||
float x = pos.x;
|
||||
float y = pos.y;
|
||||
|
||||
float dist = new Vector2(x, y).magnitude;
|
||||
float sizeMul = Mathf.Min(Mathf.Pow(dist, p.m_VignettePower), 1.0f);
|
||||
|
||||
|
||||
float s = sizeMul > 0.5f ? size * sizeMul : 0.0f;
|
||||
float angle = UnityEngine.Random.Range(0.0f, p.m_RandomRotation? 360.0f : 0.0f);
|
||||
Vector3 nDiv = new Vector3(1.0f / width, 1.0f / height, 0.0f);
|
||||
Vector3 tl = RotateZ(new Vector3(-s, -s, 0.0f), angle);
|
||||
Vector3 tr = RotateZ(new Vector3(s, -s, 0f), angle);
|
||||
Vector3 br = RotateZ(new Vector3(s, s, 0f), angle);
|
||||
Vector3 bl = RotateZ(new Vector3(-s, s, 0f), angle);
|
||||
|
||||
tl = new Vector3(tl.x * nDiv.x, tl.y * nDiv.y, 0.0f);
|
||||
tr = new Vector3(tr.x * nDiv.x, tr.y * nDiv.y, 0.0f);
|
||||
br = new Vector3(br.x * nDiv.x, br.y * nDiv.y, 0.0f);
|
||||
bl = new Vector3(bl.x * nDiv.x, bl.y * nDiv.y, 0.0f);
|
||||
|
||||
|
||||
DrawQuad(x, y, tl , tr , br , bl );
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
RenderTexture rtB = RenderTexture.GetTemporary(width, height);
|
||||
for (int i = 0; i < 1; ++i)
|
||||
{
|
||||
RenderTexture.active = rtB;
|
||||
blurMaterial.SetTexture("_AdditiveTexture", Texture2D.blackTexture);
|
||||
blurMaterial.SetVector("_OffsetInfos", new Vector4(1.0f / width * p.m_BlurRadius, 0, 0, 0));
|
||||
blurMaterial.SetVector("_Tint", Color.white);
|
||||
blurMaterial.SetFloat("_Intensity", 1.0f);
|
||||
Graphics.Blit(rtA, rtB, blurMaterial, 2);
|
||||
|
||||
blurMaterial.SetVector("_OffsetInfos", new Vector4(0, 1.0f / height * p.m_BlurRadius, 0, 0));
|
||||
Graphics.Blit(rtB, rtA, blurMaterial, 4);
|
||||
}
|
||||
|
||||
// Chromatic Aberration
|
||||
miscMaterial.SetFloat("_ChromaticAberration", p.m_ChromaticAberration);
|
||||
Graphics.Blit(rtA, rtB, miscMaterial, 0);
|
||||
|
||||
/*RenderTexture.active = rtB;
|
||||
Texture2D texture = new Texture2D(width, height);
|
||||
texture.ReadPixels(new Rect(0, 0, width, height), 0, 0);
|
||||
texture.Apply();*/
|
||||
|
||||
RenderTexture.ReleaseTemporary(rtA);
|
||||
//RenderTexture.ReleaseTemporary(rtB);
|
||||
//RenderTexture.active = lastActive;
|
||||
|
||||
return rtB;
|
||||
}
|
||||
|
||||
Vector3 PickPosition(int idx)
|
||||
{
|
||||
float minDistance = m_MinimumDistance[idx];
|
||||
List<Vector3> positions = m_Positions[idx];
|
||||
|
||||
int nbTry = 20000;
|
||||
bool ok = false;
|
||||
|
||||
while (!ok)
|
||||
{
|
||||
float x = UnityEngine.Random.Range(-1f, 1f);
|
||||
float y = UnityEngine.Random.Range(-1f, 1f);
|
||||
|
||||
Vector3 pos = new Vector3(x, y, 0.0f);
|
||||
|
||||
bool foundNearPos = false;
|
||||
foreach (Vector3 cPos in positions)
|
||||
{
|
||||
if (Vector3.Distance(cPos, pos) < minDistance)
|
||||
{
|
||||
minDistance -= 0.1f;
|
||||
m_MinimumDistance[idx] = minDistance;
|
||||
foundNearPos = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundNearPos)
|
||||
{
|
||||
return pos;
|
||||
}
|
||||
|
||||
nbTry--;
|
||||
if (nbTry < 0)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Vector3.zero;
|
||||
}
|
||||
|
||||
public Vector3 RotateZ(Vector3 v, float angle)
|
||||
{
|
||||
float sin = Mathf.Sin(angle);
|
||||
float cos = Mathf.Cos(angle);
|
||||
|
||||
float tx = v.x;
|
||||
float ty = v.y;
|
||||
|
||||
Vector3 r = new Vector3();
|
||||
r.x = (cos * tx) - (sin * ty);
|
||||
r.y = (cos * ty) + (sin * tx);
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
void DrawQuad(float x, float y, Vector3 tl, Vector3 tr, Vector3 br, Vector3 bl)
|
||||
{
|
||||
|
||||
|
||||
GL.Begin(GL.QUADS); // Quad
|
||||
|
||||
GL.MultiTexCoord2(0, 1 - 0f, 0f);
|
||||
GL.Vertex3(tl.x + x, tl.y + y, 0f);
|
||||
|
||||
GL.MultiTexCoord2(0, 1 - 1f, 0f);
|
||||
GL.Vertex3(tr.x + x, tr.y + y, 0f);
|
||||
|
||||
GL.MultiTexCoord2(0, 1 - 1f, 1f);
|
||||
GL.Vertex3(br.x + x, br.y + y, 0f);
|
||||
|
||||
GL.MultiTexCoord2(0, 1 - 0f, 1f);
|
||||
GL.Vertex3(bl.x + x, bl.y + y, 0f);
|
||||
|
||||
GL.End();
|
||||
}
|
||||
|
||||
/* void DrawQuad(float x, float y, float halfWidth, float halfHeight)
|
||||
{
|
||||
|
||||
float angle = UnityEngine.Random.Range(0.0f, 360.0f);
|
||||
|
||||
|
||||
Vector3 tl = RotateZ(new Vector3(-halfWidth, -halfHeight, 0.0f), 0.0f);
|
||||
Vector3 tr = RotateZ( new Vector3(halfWidth, -halfHeight, 0f), 0.0f);
|
||||
Vector3 br = RotateZ(new Vector3(halfWidth, halfHeight, 0f), 0.0f);
|
||||
Vector3 bl = RotateZ(new Vector3(-halfWidth, halfHeight, 0f), 0.0f);
|
||||
|
||||
GL.Begin(GL.QUADS); // Quad
|
||||
|
||||
GL.MultiTexCoord2(0, 1-0f, 0f);
|
||||
GL.Vertex3(tl.x + x, tl.y + y, 0f);
|
||||
|
||||
GL.MultiTexCoord2(0, 1 - 1f, 0f);
|
||||
GL.Vertex3(tr.x + x, tr.y + y, 0f);
|
||||
|
||||
GL.MultiTexCoord2(0, 1 - 1f, 1f);
|
||||
GL.Vertex3(br.x + x, br.y + y, 0f);
|
||||
|
||||
GL.MultiTexCoord2(0, 1 - 0f, 1f);
|
||||
GL.Vertex3(bl.x + x, bl.y + y, 0f);
|
||||
|
||||
GL.End();
|
||||
}*/
|
||||
|
||||
|
||||
private Texture2D MakeTex(int width, int height, Color col)
|
||||
{
|
||||
Color[] pix = new Color[width * height];
|
||||
|
||||
for (int i = 0; i < pix.Length; i++)
|
||||
pix[i] = col;
|
||||
|
||||
Texture2D result = new Texture2D(width, height);
|
||||
result.hideFlags = HideFlags.HideAndDontSave;
|
||||
result.SetPixels(pix);
|
||||
result.Apply();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void RenderTextureAdditive(RenderTexture source, RenderTexture destination, float intensity)
|
||||
{
|
||||
RenderTexture tmpTexture = RenderTexture.GetTemporary(source.width, source.height, source.depth, source.format);
|
||||
Graphics.Blit(destination, tmpTexture);
|
||||
|
||||
m_MixerMaterial.SetTexture("_ColorBuffer", tmpTexture);
|
||||
m_MixerMaterial.SetFloat("_Intensity", intensity);
|
||||
|
||||
Graphics.Blit(source, destination, m_MixerMaterial, 0);
|
||||
|
||||
RenderTexture.ReleaseTemporary(tmpTexture);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a470493edcac30948be9a852dfd59a05
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
445
Assets/Cinematic Effects/BloomBeta/Editor/UltimateBloomEditor.cs
Normal file
|
@ -0,0 +1,445 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEditor;
|
||||
using System.IO;
|
||||
|
||||
[CustomEditor(typeof(UltimateBloom))]
|
||||
public class UltimateBloomEditor : Editor
|
||||
{
|
||||
|
||||
private Texture2D MakeTex(int width, int height, Color col)
|
||||
{
|
||||
Color[] pix = new Color[width * height];
|
||||
|
||||
for (int i = 0; i < pix.Length; i++)
|
||||
pix[i] = col;
|
||||
|
||||
Texture2D result = new Texture2D(width, height);
|
||||
result.hideFlags = HideFlags.HideAndDontSave;
|
||||
result.SetPixels(pix);
|
||||
result.Apply();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
GUIStyle m_Background1;
|
||||
GUIStyle m_Background2;
|
||||
GUIStyle m_Background3;
|
||||
|
||||
Texture2D m_Logo;
|
||||
|
||||
public static string GetAbsoluteAssetPath(string path)
|
||||
{
|
||||
UltimateBloomPathLocator locator = ScriptableObject.CreateInstance<UltimateBloomPathLocator>();
|
||||
MonoScript script = MonoScript.FromScriptableObject(locator);
|
||||
string scriptPath = AssetDatabase.GetAssetPath(script);
|
||||
ScriptableObject.DestroyImmediate(locator);
|
||||
return Path.GetDirectoryName(scriptPath) + "/" + path;
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
m_Background1 = new GUIStyle();
|
||||
m_Background1.normal.background = MakeTex(600, 1, new Color(1.0f, 1.0f, 1.0f, 0.1f));
|
||||
m_Background2 = new GUIStyle();
|
||||
m_Background2.normal.background = MakeTex(600, 1, new Color(1.0f, 1.0f, 1.0f, 0.0f));
|
||||
m_Background3 = new GUIStyle();
|
||||
m_Background3.normal.background = MakeTex(600, 1, new Color(1.0f, 1.0f, 1.0f, 0.05f));
|
||||
|
||||
string logoPath = GetAbsoluteAssetPath("Editor/ub_logo.png");
|
||||
m_Logo = (Texture2D)AssetDatabase.LoadAssetAtPath(logoPath, typeof(Texture2D));
|
||||
|
||||
if (m_Logo != null)
|
||||
m_Logo.hideFlags = HideFlags.HideAndDontSave;
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
GameObject.DestroyImmediate(m_Background1.normal.background);
|
||||
GameObject.DestroyImmediate(m_Background2.normal.background);
|
||||
GameObject.DestroyImmediate(m_Background3.normal.background);
|
||||
}
|
||||
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
UltimateBloom bloomDeluxe = (UltimateBloom)target;
|
||||
Undo.RecordObject(bloomDeluxe, "Bloom DELUXE");
|
||||
|
||||
if (m_Logo != null)
|
||||
{
|
||||
Rect rect = GUILayoutUtility.GetRect(m_Logo.width, m_Logo.height);
|
||||
GUI.DrawTexture(rect, m_Logo, ScaleMode.ScaleToFit);
|
||||
}
|
||||
GUILayout.BeginVertical("Box");
|
||||
bloomDeluxe.m_UiShowBloomSettings = UBHelper.GroupHeader("Bloom Settings", bloomDeluxe.m_UiShowBloomSettings);
|
||||
if (bloomDeluxe.m_UiShowBloomSettings)
|
||||
{
|
||||
|
||||
bloomDeluxe.m_HDR = (UltimateBloom.HDRBloomMode)EditorGUILayout.EnumPopup("HDR", bloomDeluxe.m_HDR);
|
||||
bloomDeluxe.m_InvertImage = EditorGUILayout.Toggle("Flip Image", bloomDeluxe.m_InvertImage);
|
||||
|
||||
|
||||
bloomDeluxe.m_BloomIntensity = DoSlider("Bloom Master Intensity", bloomDeluxe.m_BloomIntensity, 0.0f, 5.0f);
|
||||
//bloomDeluxe.m_BloomIntensity = Mathf.Clamp(EditorGUILayout.FloatField("Bloom Master Intensity", bloomDeluxe.m_BloomIntensity), 0.0f, 100.0f);
|
||||
bloomDeluxe.m_DownscaleCount = Mathf.Clamp(EditorGUILayout.IntField("Layers (Downscale Count)", bloomDeluxe.m_DownscaleCount), 1, 6);
|
||||
if (GUILayout.Button((bloomDeluxe.m_UiShowBloomScales ? "Hide Layers" : "Show Layers") + "[" + bloomDeluxe.m_DownscaleCount + "]"))
|
||||
bloomDeluxe.m_UiShowBloomScales = !bloomDeluxe.m_UiShowBloomScales;
|
||||
|
||||
if (bloomDeluxe.m_UiShowBloomScales)
|
||||
{
|
||||
|
||||
for (int i = 0; i < bloomDeluxe.m_DownscaleCount; ++i)
|
||||
{
|
||||
GUILayout.BeginVertical(i % 2 == 0 ? m_Background3 : m_Background1);
|
||||
int idx = i + 1;
|
||||
bloomDeluxe.m_BloomUsages[i] = EditorGUILayout.Toggle(" Layer " + idx + " Enabled", bloomDeluxe.m_BloomUsages[i]);
|
||||
bloomDeluxe.m_BloomIntensities[i] = DoSlider(" Layer " + idx + " Intensity", bloomDeluxe.m_BloomIntensities[i], 0.0f, 5.0f);
|
||||
bloomDeluxe.m_BloomColors[i] = EditorGUILayout.ColorField(" Layer " + idx + " Tint", bloomDeluxe.m_BloomColors[i]);
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
GUILayout.Space(10.0f);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Intensity Management
|
||||
GUILayout.BeginVertical("Box");
|
||||
bloomDeluxe.m_UiShowIntensity = UBHelper.GroupHeader("Intensity Settings", bloomDeluxe.m_UiShowIntensity);
|
||||
if (bloomDeluxe.m_UiShowIntensity)
|
||||
{
|
||||
UltimateBloom.BloomIntensityManagement lastIm = bloomDeluxe.m_IntensityManagement;
|
||||
bloomDeluxe.m_IntensityManagement = (UltimateBloom.BloomIntensityManagement)EditorGUILayout.EnumPopup("Intensity Function", bloomDeluxe.m_IntensityManagement);
|
||||
if (bloomDeluxe.m_IntensityManagement == UltimateBloom.BloomIntensityManagement.Threshold)
|
||||
{
|
||||
bloomDeluxe.m_BloomThreshhold = DoSlider(" Threshold", bloomDeluxe.m_BloomThreshhold, 0.0f, 5.0f);
|
||||
}
|
||||
else if (bloomDeluxe.m_IntensityManagement == UltimateBloom.BloomIntensityManagement.FilmicCurve)
|
||||
{
|
||||
bloomDeluxe.m_BloomCurve.OnGUI();
|
||||
}
|
||||
if (lastIm != bloomDeluxe.m_IntensityManagement)
|
||||
bloomDeluxe.ForceShadersReload();
|
||||
GUILayout.Space(10.0f);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Sampling
|
||||
GUILayout.BeginVertical("Box");
|
||||
bloomDeluxe.m_UiShowSampling = UBHelper.GroupHeader("Sampling", bloomDeluxe.m_UiShowSampling);
|
||||
if (bloomDeluxe.m_UiShowSampling)
|
||||
{
|
||||
bloomDeluxe.m_TemporalStableDownsampling = EditorGUILayout.Toggle("Temporal Stability Filter", bloomDeluxe.m_TemporalStableDownsampling);
|
||||
bloomDeluxe.m_SamplingMode = (UltimateBloom.SamplingMode)EditorGUILayout.EnumPopup("Sampling Mode", bloomDeluxe.m_SamplingMode);
|
||||
if (bloomDeluxe.m_SamplingMode == UltimateBloom.SamplingMode.Fixed)
|
||||
bloomDeluxe.m_UpsamplingQuality = (UltimateBloom.BloomSamplingQuality)EditorGUILayout.EnumPopup("Sampling Kernel Size", bloomDeluxe.m_UpsamplingQuality);
|
||||
else // Screen relative sampling
|
||||
{
|
||||
bloomDeluxe.m_SamplingMinHeight = DoSlider("Min Height", bloomDeluxe.m_SamplingMinHeight, 300.0f, 1000.0f);
|
||||
|
||||
if (GUILayout.Button((bloomDeluxe.m_UiShowHeightSampling ? "Hide Sampling Heights" : "Show Sampling Heights")))
|
||||
bloomDeluxe.m_UiShowHeightSampling = !bloomDeluxe.m_UiShowHeightSampling;
|
||||
|
||||
if (bloomDeluxe.m_UiShowHeightSampling)
|
||||
{
|
||||
bloomDeluxe.ComputeResolutionRelativeData();
|
||||
for (int i = 0; i < bloomDeluxe.m_ResSamplingPixelCount.Length; ++i)
|
||||
{
|
||||
GUILayout.Label("Sampling Height[" + i + "] = " + bloomDeluxe.m_ResSamplingPixelCount[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(10.0f);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Optimizations
|
||||
GUILayout.BeginVertical("Box");
|
||||
bloomDeluxe.m_UiShowOptimizations = UBHelper.GroupHeader("Optimizations", bloomDeluxe.m_UiShowOptimizations);
|
||||
if (bloomDeluxe.m_UiShowOptimizations)
|
||||
{
|
||||
bloomDeluxe.m_DirectDownSample = EditorGUILayout.Toggle("Direct Downsampling", bloomDeluxe.m_DirectDownSample);
|
||||
if (bloomDeluxe.m_DirectDownSample)
|
||||
EditorGUILayout.HelpBox("Enabling direct downsampling may introduce jittering. It should only be enabled on low end hardwares.", MessageType.Info);
|
||||
bloomDeluxe.m_DirectUpsample = EditorGUILayout.Toggle("Direct Upsampling", bloomDeluxe.m_DirectUpsample);
|
||||
GUILayout.Space(10.0f);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// LENS DUST
|
||||
GUILayout.BeginVertical("Box");
|
||||
bloomDeluxe.m_UiShowLensDirt = UBHelper.GroupHeader("Lens Dirt", bloomDeluxe.m_UiShowLensDirt);
|
||||
if (bloomDeluxe.m_UiShowLensDirt)
|
||||
{
|
||||
bool lastUseLensDust = bloomDeluxe.m_UseLensDust;
|
||||
bloomDeluxe.m_UseLensDust = EditorGUILayout.Toggle("Use Lens Dirt", bloomDeluxe.m_UseLensDust);
|
||||
if (bloomDeluxe.m_UseLensDust)
|
||||
{
|
||||
bloomDeluxe.m_DustTexture = (Texture2D)EditorGUILayout.ObjectField(" Dirt Texture", bloomDeluxe.m_DustTexture, typeof(Texture2D), false);
|
||||
bloomDeluxe.m_DustIntensity = DoSlider(" Dirtiness", bloomDeluxe.m_DustIntensity, 0.0f, 10.0f);
|
||||
bloomDeluxe.m_DirtLightIntensity = DoSlider(" Dirt Light Intensity", bloomDeluxe.m_DirtLightIntensity, 0.0f, 30.0f);
|
||||
}
|
||||
if (lastUseLensDust != bloomDeluxe.m_UseLensDust)
|
||||
bloomDeluxe.ForceShadersReload();
|
||||
GUILayout.Space(10.0f);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// LENS FLARE
|
||||
GUILayout.BeginVertical("Box");
|
||||
bloomDeluxe.m_UiShowLensFlare = UBHelper.GroupHeader("Lens Flare (Bokeh & Ghost)", bloomDeluxe.m_UiShowLensFlare);
|
||||
if (bloomDeluxe.m_UiShowLensFlare)
|
||||
{
|
||||
bool lastUseLensFlare = bloomDeluxe.m_UseLensFlare;
|
||||
bloomDeluxe.m_UseLensFlare = EditorGUILayout.Toggle("Use Lens Flare", bloomDeluxe.m_UseLensFlare);
|
||||
if (bloomDeluxe.m_UseLensFlare)
|
||||
{
|
||||
UltimateBloom.FlarePresets preset = (UltimateBloom.FlarePresets)EditorGUILayout.EnumPopup("Flare Preset", UltimateBloom.FlarePresets.ChoosePreset);
|
||||
SetFlarePreset(preset, bloomDeluxe);
|
||||
|
||||
bloomDeluxe.m_FlareRendering = (UltimateBloom.FlareRendering)EditorGUILayout.EnumPopup(" Flare Rendering", bloomDeluxe.m_FlareRendering);
|
||||
if (bloomDeluxe.m_FlareRendering != UltimateBloom.FlareRendering.Sharp)
|
||||
{
|
||||
bloomDeluxe.m_FlareBlurQuality = (UltimateBloom.FlareBlurQuality)EditorGUILayout.EnumPopup(" Blur Quality", bloomDeluxe.m_FlareBlurQuality);
|
||||
}
|
||||
|
||||
UltimateBloom.FlareType lastFareType = bloomDeluxe.m_FlareType;
|
||||
bloomDeluxe.m_FlareType = (UltimateBloom.FlareType)EditorGUILayout.EnumPopup(" Flare Duplication", bloomDeluxe.m_FlareType);
|
||||
if (lastFareType != bloomDeluxe.m_FlareType)
|
||||
bloomDeluxe.ForceShadersReload();
|
||||
|
||||
bloomDeluxe.m_FlareIntensity = DoSlider(" Flare Intensity", bloomDeluxe.m_FlareIntensity, 0.0f, 30.0f);
|
||||
bloomDeluxe.m_FlareTreshold = DoSlider(" Threshold", bloomDeluxe.m_FlareTreshold, 0.0f, 5.0f);
|
||||
bloomDeluxe.m_FlareGlobalScale = DoSlider(" Global Scale", bloomDeluxe.m_FlareGlobalScale, 0.1f, 5.0f);
|
||||
bloomDeluxe.m_FlareScales = EditorGUILayout.Vector4Field(" Flare Scales Far", bloomDeluxe.m_FlareScales);
|
||||
if (bloomDeluxe.m_FlareType == UltimateBloom.FlareType.Double)
|
||||
bloomDeluxe.m_FlareScalesNear = EditorGUILayout.Vector4Field(" Flare Scales Near", bloomDeluxe.m_FlareScalesNear);
|
||||
Vector4 tmp = bloomDeluxe.m_FlareScales;
|
||||
float maxFlareScale = 12.0f;
|
||||
bloomDeluxe.m_FlareScales = new Vector4(Mathf.Clamp(tmp.x, 0, maxFlareScale), Mathf.Clamp(tmp.y, 0, maxFlareScale), Mathf.Clamp(tmp.z, 0, maxFlareScale), Mathf.Clamp(tmp.w, 0, maxFlareScale));
|
||||
|
||||
tmp = bloomDeluxe.m_FlareScalesNear;
|
||||
bloomDeluxe.m_FlareScalesNear = new Vector4(Mathf.Clamp(tmp.x, 0, maxFlareScale), Mathf.Clamp(tmp.y, 0, maxFlareScale), Mathf.Clamp(tmp.z, 0, maxFlareScale), Mathf.Clamp(tmp.w, 0, maxFlareScale));
|
||||
|
||||
bloomDeluxe.m_FlareTint0 = EditorGUILayout.ColorField(" Flare Tint 0", bloomDeluxe.m_FlareTint0);
|
||||
bloomDeluxe.m_FlareTint1 = EditorGUILayout.ColorField(" Flare Tint 1", bloomDeluxe.m_FlareTint1);
|
||||
bloomDeluxe.m_FlareTint2 = EditorGUILayout.ColorField(" Flare Tint 2", bloomDeluxe.m_FlareTint2);
|
||||
bloomDeluxe.m_FlareTint3 = EditorGUILayout.ColorField(" Flare Tint 3", bloomDeluxe.m_FlareTint3);
|
||||
|
||||
if (bloomDeluxe.m_FlareType == UltimateBloom.FlareType.Double)
|
||||
{
|
||||
bloomDeluxe.m_FlareTint4 = EditorGUILayout.ColorField(" Flare Tint 4", bloomDeluxe.m_FlareTint4);
|
||||
bloomDeluxe.m_FlareTint5 = EditorGUILayout.ColorField(" Flare Tint 5", bloomDeluxe.m_FlareTint5);
|
||||
bloomDeluxe.m_FlareTint6 = EditorGUILayout.ColorField(" Flare Tint 6", bloomDeluxe.m_FlareTint6);
|
||||
bloomDeluxe.m_FlareTint7 = EditorGUILayout.ColorField(" Flare Tint 7", bloomDeluxe.m_FlareTint7);
|
||||
}
|
||||
|
||||
bloomDeluxe.m_FlareMask = (Texture2D)EditorGUILayout.ObjectField(" Flare Mask", bloomDeluxe.m_FlareMask, typeof(Texture2D), false);
|
||||
|
||||
bloomDeluxe.m_UseBokehFlare = EditorGUILayout.Toggle("Use Bokeh Texture", bloomDeluxe.m_UseBokehFlare);
|
||||
if (bloomDeluxe.m_UseBokehFlare)
|
||||
{
|
||||
bloomDeluxe.m_BokehFlareQuality = (UltimateBloom.BokehFlareQuality)EditorGUILayout.EnumPopup(" Bokeh Quality", bloomDeluxe.m_BokehFlareQuality);
|
||||
|
||||
bloomDeluxe.m_BokehScale = Mathf.Clamp(EditorGUILayout.FloatField(" Bokeh Scale", bloomDeluxe.m_BokehScale), 0.2f, 2.5f);
|
||||
bloomDeluxe.m_FlareShape = (Texture2D)EditorGUILayout.ObjectField(" Bokeh Texture", bloomDeluxe.m_FlareShape, typeof(Texture2D), false);
|
||||
}
|
||||
}
|
||||
if (lastUseLensFlare != bloomDeluxe.m_UseLensFlare)
|
||||
bloomDeluxe.ForceShadersReload();
|
||||
GUILayout.Space(10.0f);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Anamorphic lens flare
|
||||
|
||||
GUILayout.BeginVertical("Box");
|
||||
bloomDeluxe.m_UiShowAnamorphic = UBHelper.GroupHeader("Anamorphic Lens Flare", bloomDeluxe.m_UiShowAnamorphic);
|
||||
if (bloomDeluxe.m_UiShowAnamorphic)
|
||||
{
|
||||
bool lastUseAnamorphic = bloomDeluxe.m_UseAnamorphicFlare;
|
||||
bloomDeluxe.m_UseAnamorphicFlare = EditorGUILayout.Toggle("Use Anamorphic Lens Flare", bloomDeluxe.m_UseAnamorphicFlare);
|
||||
if (bloomDeluxe.m_UseAnamorphicFlare)
|
||||
{
|
||||
bloomDeluxe.m_AnamorphicDownscaleCount = Mathf.Clamp(EditorGUILayout.IntField(" Layers (Downscale Count)", bloomDeluxe.m_AnamorphicDownscaleCount), 1, 6);
|
||||
bloomDeluxe.m_AnamorphicFlareIntensity = DoSlider(" Intensity", bloomDeluxe.m_AnamorphicFlareIntensity, 0.0f, 5.0f);
|
||||
//bloomDeluxe.m_AnamorphicFlareTreshold = DoSlider(" Treshold", bloomDeluxe.m_AnamorphicFlareTreshold, 0.0f, 5.0f);
|
||||
bloomDeluxe.m_AnamorphicScale = DoSlider(" Scale", bloomDeluxe.m_AnamorphicScale, 0.0f, 6.0f);
|
||||
bloomDeluxe.m_AnamorphicBlurPass = Mathf.Clamp(EditorGUILayout.IntField(" Blur Pass", bloomDeluxe.m_AnamorphicBlurPass), 1, 6);
|
||||
bloomDeluxe.m_AnamorphicSmallVerticalBlur = EditorGUILayout.Toggle(" Anti-jitter Pass", bloomDeluxe.m_AnamorphicSmallVerticalBlur);
|
||||
bloomDeluxe.m_AnamorphicDirection = (UltimateBloom.AnamorphicDirection)EditorGUILayout.EnumPopup(" Direction", bloomDeluxe.m_AnamorphicDirection);
|
||||
}
|
||||
if (lastUseAnamorphic != bloomDeluxe.m_UseAnamorphicFlare)
|
||||
bloomDeluxe.ForceShadersReload();
|
||||
|
||||
if (bloomDeluxe.m_UseAnamorphicFlare)
|
||||
{
|
||||
if (GUILayout.Button((bloomDeluxe.m_UiShowAnamorphicBloomScales ? "Hide Layers" : "Show Layers") + "[" + bloomDeluxe.m_AnamorphicDownscaleCount + "]"))
|
||||
bloomDeluxe.m_UiShowAnamorphicBloomScales = !bloomDeluxe.m_UiShowAnamorphicBloomScales;
|
||||
if (bloomDeluxe.m_UiShowAnamorphicBloomScales)
|
||||
{
|
||||
for (int i = 0; i < bloomDeluxe.m_AnamorphicDownscaleCount; ++i)
|
||||
{
|
||||
GUILayout.BeginVertical(i % 2 == 0 ? m_Background3 : m_Background1);
|
||||
int idx = i + 1;
|
||||
bloomDeluxe.m_AnamorphicBloomUsages[i] = EditorGUILayout.Toggle(" Layer " + idx + " Enabled", bloomDeluxe.m_AnamorphicBloomUsages[i]);
|
||||
bloomDeluxe.m_AnamorphicBloomIntensities[i] = DoSlider(" Layer " + idx + " Intensity", bloomDeluxe.m_AnamorphicBloomIntensities[i], 0.0f, 5.0f);
|
||||
bloomDeluxe.m_AnamorphicBloomColors[i] = EditorGUILayout.ColorField(" Layer " + idx + " Tint", bloomDeluxe.m_AnamorphicBloomColors[i]);
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GUILayout.Space(10.0f);
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
// Star lens flare
|
||||
|
||||
GUILayout.BeginVertical("Box");
|
||||
bloomDeluxe.m_UiShowStar = UBHelper.GroupHeader("Star Lens Flare", bloomDeluxe.m_UiShowStar);
|
||||
if (bloomDeluxe.m_UiShowStar)
|
||||
{
|
||||
bool lastUseStar = bloomDeluxe.m_UseStarFlare;
|
||||
bloomDeluxe.m_UseStarFlare = EditorGUILayout.Toggle("Use Star Lens Flare", bloomDeluxe.m_UseStarFlare);
|
||||
if (bloomDeluxe.m_UseStarFlare)
|
||||
{
|
||||
bloomDeluxe.m_StarDownscaleCount = Mathf.Clamp(EditorGUILayout.IntField(" Layers (Downscale Count)", bloomDeluxe.m_StarDownscaleCount), 1, 6);
|
||||
bloomDeluxe.m_StarFlareIntensity = DoSlider(" Intensity", bloomDeluxe.m_StarFlareIntensity, 0.0f, 5.0f);
|
||||
//bloomDeluxe.m_StarFlareTreshol = DoSlider(" Treshold", bloomDeluxe.m_StarFlareTreshol, 0.0f, 5.0f);
|
||||
bloomDeluxe.m_StarScale = DoSlider(" Scale", bloomDeluxe.m_StarScale, 0.0f, 5.0f);
|
||||
bloomDeluxe.m_StarBlurPass = Mathf.Clamp(EditorGUILayout.IntField(" Blur Pass", bloomDeluxe.m_StarBlurPass), 1, 4);
|
||||
}
|
||||
if (lastUseStar != bloomDeluxe.m_UseStarFlare)
|
||||
bloomDeluxe.ForceShadersReload();
|
||||
|
||||
if (bloomDeluxe.m_UseStarFlare)
|
||||
{
|
||||
if (GUILayout.Button((bloomDeluxe.m_UiShowStarBloomScales ? "Hide Layers" : "Show Layers") + "[" + bloomDeluxe.m_StarDownscaleCount + "]"))
|
||||
bloomDeluxe.m_UiShowStarBloomScales = !bloomDeluxe.m_UiShowStarBloomScales;
|
||||
if (bloomDeluxe.m_UiShowStarBloomScales)
|
||||
{
|
||||
for (int i = 0; i < bloomDeluxe.m_StarDownscaleCount; ++i)
|
||||
{
|
||||
GUILayout.BeginVertical(i % 2 == 0 ? m_Background3 : m_Background1);
|
||||
int idx = i + 1;
|
||||
bloomDeluxe.m_StarBloomUsages[i] = EditorGUILayout.Toggle(" Layer " + idx + " Enabled", bloomDeluxe.m_StarBloomUsages[i]);
|
||||
bloomDeluxe.m_StarBloomIntensities[i] = DoSlider(" Layer " + idx + " Intensity", bloomDeluxe.m_StarBloomIntensities[i], 0.0f, 5.0f);
|
||||
bloomDeluxe.m_StarBloomColors[i] = EditorGUILayout.ColorField(" Layer " + idx + " Tint", bloomDeluxe.m_StarBloomColors[i]);
|
||||
GUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndVertical();
|
||||
|
||||
if (GUI.changed)
|
||||
{
|
||||
EditorUtility.SetDirty(target);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[MenuItem("Component/UltimateBloom/Add to selected camera")]
|
||||
public static void AddPreset()
|
||||
{
|
||||
UltimateBloom ub = GetUltimateBloomObject();
|
||||
if (ub == null)
|
||||
return;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static UltimateBloom GetUltimateBloomObject()
|
||||
{
|
||||
GameObject obj = Selection.activeGameObject;
|
||||
if (obj == null)
|
||||
return null;
|
||||
if (obj.GetComponent<Camera>() == null)
|
||||
return null;
|
||||
|
||||
return obj.AddComponent<UltimateBloom>();
|
||||
}
|
||||
|
||||
float DoSlider(string label, float value, float min, float max)
|
||||
{
|
||||
float v = value;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
v = Mathf.Clamp(EditorGUILayout.FloatField(label, v, GUILayout.ExpandWidth(false)), min, max);
|
||||
v = GUILayout.HorizontalSlider(v, min, max);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
void SetFlarePreset(UltimateBloom.FlarePresets preset, UltimateBloom ub)
|
||||
{
|
||||
if (preset == UltimateBloom.FlarePresets.ChoosePreset)
|
||||
return;
|
||||
|
||||
if (preset == UltimateBloom.FlarePresets.Bokeh2 || preset == UltimateBloom.FlarePresets.Ghost2)
|
||||
{
|
||||
ub.m_FlareTint0 = new Color(78 / 255.0f, 69 / 255.0f, 149.0f / 255.0f);
|
||||
ub.m_FlareTint1 = new Color(36 / 255.0f, 51 / 255.0f, 141 / 255.0f);
|
||||
ub.m_FlareTint2 = new Color(29 / 255.0f, 41 / 255.0f, 105 / 255.0f);
|
||||
ub.m_FlareTint3 = new Color(17 / 255.0f, 22 / 255.0f, 107 / 255.0f);
|
||||
ub.m_FlareTint4 = new Color(78 / 255.0f, 69 / 255.0f, 149.0f / 255.0f);
|
||||
ub.m_FlareTint5 = new Color(36 / 255.0f, 51 / 255.0f, 141 / 255.0f);
|
||||
ub.m_FlareTint6 = new Color(29 / 255.0f, 41 / 255.0f, 105 / 255.0f);
|
||||
ub.m_FlareTint7 = new Color(17 / 255.0f, 22 / 255.0f, 107 / 255.0f);
|
||||
}
|
||||
else if (preset == UltimateBloom.FlarePresets.Bokeh3 || preset == UltimateBloom.FlarePresets.Ghost3)
|
||||
{
|
||||
ub.m_FlareTint0 = new Color(255 / 255.0f, 135 / 255.0f, 2/ 255.0f);
|
||||
ub.m_FlareTint1 = new Color(255 / 255.0f, 96 / 255.0f, 1 / 255.0f);
|
||||
ub.m_FlareTint2 = new Color(255 / 255.0f, 60 / 255.0f, 1 / 255.0f);
|
||||
ub.m_FlareTint3 = new Color(255 / 255.0f, 12 / 255.0f, 0 / 255.0f);
|
||||
ub.m_FlareTint4 = new Color(255 / 255.0f, 184 / 255.0f, 3 / 255.0f);
|
||||
ub.m_FlareTint5 = new Color(255 / 255.0f, 135 / 255.0f, 2 / 255.0f);
|
||||
ub.m_FlareTint6 = new Color(255 / 255.0f, 135 / 255.0f, 2 / 255.0f);
|
||||
ub.m_FlareTint7 = new Color(255 / 255.0f, 96 / 255.0f, 0 / 255.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
ub.m_FlareTint0 = new Color(137 / 255.0f, 82 / 255.0f, 0 / 255.0f);
|
||||
ub.m_FlareTint1 = new Color(0 / 255.0f, 63 / 255.0f, 126 / 255.0f);
|
||||
ub.m_FlareTint2 = new Color(72 / 255.0f, 151 / 255.0f, 0 / 255.0f);
|
||||
ub.m_FlareTint3 = new Color(114 / 255.0f, 35 / 255.0f, 0 / 255.0f);
|
||||
ub.m_FlareTint4 = new Color(122 / 255.0f, 88 / 255.0f, 0 / 255.0f);
|
||||
ub.m_FlareTint5 = new Color(137 / 255.0f, 71 / 255.0f, 0 / 255.0f);
|
||||
ub.m_FlareTint6 = new Color(97 / 255.0f, 139 / 255.0f, 0 / 255.0f);
|
||||
ub.m_FlareTint7 = new Color(40 / 255.0f, 142 / 255.0f, 0 / 255.0f);
|
||||
}
|
||||
|
||||
ub.m_FlareIntensity = 1.0f;
|
||||
ub.m_FlareTreshold = 0.8f;
|
||||
|
||||
if (preset == UltimateBloom.FlarePresets.Bokeh1 || preset == UltimateBloom.FlarePresets.Bokeh2 || preset == UltimateBloom.FlarePresets.Bokeh3)
|
||||
{
|
||||
ub.m_FlareScales = new Vector4(5.77f, 2.5f, 1.32f, 1.12f);
|
||||
ub.m_FlareScalesNear = new Vector4(12, 7.37f, 5.3f, 4.14f);
|
||||
ub.m_FlareRendering = UltimateBloom.FlareRendering.Sharp;
|
||||
ub.m_UseBokehFlare = true;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
ub.m_FlareScales = new Vector4(1.0f, 0.6f, 0.5f, 0.4f);
|
||||
ub.m_FlareScalesNear = new Vector4(1.0f, 0.8f, 0.6f, 0.5f);
|
||||
ub.m_FlareBlurQuality = UltimateBloom.FlareBlurQuality.High;
|
||||
ub.m_FlareRendering = UltimateBloom.FlareRendering.Blurred;
|
||||
ub.m_UseBokehFlare = false;
|
||||
|
||||
|
||||
if (preset == UltimateBloom.FlarePresets.GhostFast)
|
||||
ub.m_FlareBlurQuality = UltimateBloom.FlareBlurQuality.Fast;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ChangeQualityPreset(UltimateBloom.BloomQualityPreset newPreset)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 285efee97a9b0b742b510e3de78b0b38
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/BloomBeta/Graphics.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7ffc125439b8b7b40bca3705f9e0a6eb
|
||||
folderAsset: yes
|
||||
timeCreated: 1443580217
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Cinematic Effects/BloomBeta/Graphics/Bokeh.png
Normal file
After Width: | Height: | Size: 5.3 KiB |
53
Assets/Cinematic Effects/BloomBeta/Graphics/Bokeh.png.meta
Normal file
|
@ -0,0 +1,53 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c689cb7ab25ee59439a73274bbcda927
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -3
|
||||
maxTextureSize: 1024
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
textureType: -1
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Cinematic Effects/BloomBeta/Graphics/BokehRound.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
|
@ -0,0 +1,53 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d27d217d25bb6e44ca371090b6169245
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -3
|
||||
maxTextureSize: 1024
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
textureType: -1
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Cinematic Effects/BloomBeta/Graphics/Bokehround2.png
Normal file
After Width: | Height: | Size: 8 KiB |
|
@ -0,0 +1,53 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 58c6d4ee6f7515d428df6d3f41dd1c26
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -1
|
||||
maxTextureSize: 1024
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
textureType: -1
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Cinematic Effects/BloomBeta/Graphics/FlareMask.png
Normal file
After Width: | Height: | Size: 6.2 KiB |
|
@ -0,0 +1,53 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9caff1227d841d143862adba1dc06356
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -3
|
||||
maxTextureSize: 1024
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 0
|
||||
textureType: -1
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,35 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 3
|
||||
m_ObjectHideFlags: 0
|
||||
m_PrefabParentObject: {fileID: 0}
|
||||
m_PrefabInternal: {fileID: 0}
|
||||
m_Name: FlareMaterial
|
||||
m_Shader: {fileID: 4800000, guid: abe4898237b1d4d49b8a3ebc0f5b4d49, type: 3}
|
||||
m_ShaderKeywords: []
|
||||
m_CustomRenderQueue: -1
|
||||
m_SavedProperties:
|
||||
serializedVersion: 2
|
||||
m_TexEnvs:
|
||||
data:
|
||||
first:
|
||||
name: _MainTex
|
||||
second:
|
||||
m_Texture: {fileID: 2800000, guid: 14a3e99f4d475b64990c89f22f1e307a, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
data:
|
||||
first:
|
||||
name: _BrightTexture
|
||||
second:
|
||||
m_Texture: {fileID: 2800000, guid: 14a3e99f4d475b64990c89f22f1e307a, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats: {}
|
||||
m_Colors:
|
||||
data:
|
||||
first:
|
||||
name: _Color
|
||||
second: {r: 1, g: 1, b: 1, a: 1}
|
|
@ -0,0 +1,6 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bc4691e301d4e4445bbd1df0a85d4006
|
||||
NativeFormatImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: aa977a839fe077f44856ab4ab60094eb
|
||||
folderAsset: yes
|
||||
timeCreated: 1443580217
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 5.6 KiB |
|
@ -0,0 +1,53 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bbf784a872adaba4884518c6f1d12f4a
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -3
|
||||
maxTextureSize: 1024
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
textureType: -1
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 5 KiB |
|
@ -0,0 +1,53 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 92a2f93cd546f41428182e2dbb8b2715
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -3
|
||||
maxTextureSize: 1024
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
textureType: -1
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
After Width: | Height: | Size: 5.8 KiB |
|
@ -0,0 +1,53 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dd74936895f016b4b9563ce1e1593f38
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 2
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
linearTexture: 0
|
||||
correctGamma: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: .25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 0
|
||||
cubemapConvolution: 0
|
||||
cubemapConvolutionSteps: 8
|
||||
cubemapConvolutionExponent: 1.5
|
||||
seamlessCubemap: 0
|
||||
textureFormat: -3
|
||||
maxTextureSize: 1024
|
||||
textureSettings:
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapMode: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
rGBM: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: .5, y: .5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaIsTransparency: 1
|
||||
textureType: -1
|
||||
buildTargetSettings: []
|
||||
spriteSheet:
|
||||
sprites: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/BloomBeta/Resources.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 56ee327717a93674a9cba1b3d60ec916
|
||||
folderAsset: yes
|
||||
timeCreated: 1443580217
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4790c2802bfcf4b4eb367eec50a925ed
|
||||
timeCreated: 1456313800
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,59 @@
|
|||
Shader "Hidden/Ultimate/BokehMisc" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
|
||||
Subshader
|
||||
{
|
||||
Pass // #0 Chromatic Aberration
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_TexelSize;
|
||||
half _ChromaticAberration;
|
||||
|
||||
half4 frag(v2f i) : COLOR
|
||||
{
|
||||
half2 coords = i.uv;
|
||||
half2 uv = i.uv;
|
||||
|
||||
coords = (coords - 0.5) * 2.0;
|
||||
half coordDot = dot (coords,coords);
|
||||
|
||||
half2 uvG = uv - _MainTex_TexelSize.xy * _ChromaticAberration * coords * coordDot;
|
||||
half4 color = tex2D (_MainTex, uv);
|
||||
#if SHADER_API_D3D9
|
||||
// Work around Cg's code generation bug for D3D9 pixel shaders :(
|
||||
color.g = color.g * 0.0001 + tex2D (_MainTex, uvG).g;
|
||||
#else
|
||||
color.g = tex2D (_MainTex, uvG).g;
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 25b151c9a48c18747a9c043a91bedc31
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,337 @@
|
|||
Shader "Hidden/Ultimate/BloomCombine" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB)", 2D) = "black" {}
|
||||
_FlareTexture ("Flare (RGB)", 2D) = "black" {}
|
||||
}
|
||||
|
||||
|
||||
Subshader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
// Curve mapping
|
||||
half4 _Toe;
|
||||
half4 _Shoulder;
|
||||
half _K;
|
||||
half _Crossover;
|
||||
float Map(half x)
|
||||
{
|
||||
float4 data;
|
||||
float endAdd;
|
||||
|
||||
if (x > _Crossover)
|
||||
{
|
||||
data = _Shoulder;
|
||||
endAdd = _K;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = _Toe;
|
||||
endAdd = 0;
|
||||
}
|
||||
|
||||
|
||||
float2 numDenum = data.xy * x + data.zw;
|
||||
return numDenum.x / numDenum.y + endAdd;
|
||||
}
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _FlareTexture;
|
||||
sampler2D _ColorBuffer;
|
||||
sampler2D _AdditiveTexture;
|
||||
sampler2D _brightTexture;
|
||||
half _Intensity;
|
||||
half _FlareIntensity;
|
||||
half _DirtIntensity;
|
||||
half _DirtLightIntensity;
|
||||
half _ScreenMaxIntensity;
|
||||
|
||||
|
||||
inline float ComputeLuma( float3 c )
|
||||
{
|
||||
return dot( c, fixed3(0.299, 0.587, 0.114) );
|
||||
}
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
|
||||
half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,i.uv.y));
|
||||
|
||||
half4 bloom = addedbloom;
|
||||
|
||||
#ifdef ULTIMATE_BLOOM_CURVE
|
||||
half intensity = dot(screencolor, half3(0.3,0.3,0.3));
|
||||
|
||||
float colLuma = ComputeLuma(x);
|
||||
|
||||
//colLuma *= _uTAA_Exposure;
|
||||
half bloomIntensity = x/max(1.0+colLuma,0.001);
|
||||
|
||||
//half bloomIntensity = Map(intensity);
|
||||
bloom *= screencolor * bloomIntensity/intensity*2000;
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_FLARE
|
||||
bloom += tex2D(_FlareTexture, i.uv); /* _FlareIntensity;*/
|
||||
#endif
|
||||
|
||||
bloom *= _Intensity;
|
||||
|
||||
#ifdef ULTIMATE_USE_DIRT
|
||||
half3 dirt = tex2D(_AdditiveTexture, i.uv).rgb;
|
||||
|
||||
float dirtIntensity = dot(dirt.xyz, half3(0.3,0.3,0.3));
|
||||
float bloomIntensity = dot(bloom.xyz, half3(0.3,0.3,0.3));
|
||||
float factor = saturate(bloomIntensity * dirtIntensity * _DirtIntensity);
|
||||
|
||||
bloom.xyz *= (dirt*_DirtIntensity + _DirtLightIntensity*0.2);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
return bloom + screencolor;
|
||||
|
||||
|
||||
}
|
||||
|
||||
fixed4 fragINV(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
|
||||
half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,1- i.uv.y));
|
||||
|
||||
half4 bloom = _Intensity * addedbloom;
|
||||
|
||||
#ifdef ULTIMATE_BLOOM_CURVE
|
||||
bloom.x = Map(bloom.x);
|
||||
bloom.y = Map(bloom.y);
|
||||
bloom.z = Map(bloom.z);
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_FLARE
|
||||
|
||||
bloom += tex2D(_FlareTexture, i.uv);
|
||||
|
||||
/*half3 flare = tex2D(_FlareTexture, i.uv).rgb * 40;
|
||||
half3 flareIntensity = dot(half3(0.3,0.3,0.3),flare);
|
||||
half flareFactor = saturate(flareIntensity );
|
||||
bloom.xyz = lerp(bloom.xyz, flare, flareFactor);*/
|
||||
|
||||
//bloom += tex2D(_FlareTexture, i.uv) * 5;
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_DIRT
|
||||
half3 dirt = tex2D(_AdditiveTexture, i.uv).rgb;
|
||||
|
||||
float dirtIntensity = dot(dirt.xyz, half3(0.3,0.3,0.3));
|
||||
float bloomIntensity = dot(bloom.xyz, half3(0.3,0.3,0.3));
|
||||
float factor = saturate(bloomIntensity * dirtIntensity * _DirtIntensity);
|
||||
|
||||
bloom.xyz *= (dirt*_DirtIntensity + _DirtLightIntensity*0.2);
|
||||
#endif
|
||||
|
||||
return bloom + screencolor;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
// Curve mapping
|
||||
half4 _Toe;
|
||||
half4 _Shoulder;
|
||||
half _K;
|
||||
half _Crossover;
|
||||
float Map(half x)
|
||||
{
|
||||
float4 data;
|
||||
float endAdd;
|
||||
|
||||
if (x > _Crossover)
|
||||
{
|
||||
data = _Shoulder;
|
||||
endAdd = _K;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = _Toe;
|
||||
endAdd = 0;
|
||||
}
|
||||
|
||||
|
||||
float2 numDenum = data.xy * x + data.zw;
|
||||
return numDenum.x / numDenum.y + endAdd;
|
||||
}
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _FlareTexture;
|
||||
sampler2D _ColorBuffer;
|
||||
sampler2D _AdditiveTexture;
|
||||
sampler2D _brightTexture;
|
||||
half _Intensity;
|
||||
half _FlareIntensity;
|
||||
half _DirtIntensity;
|
||||
half _DirtLightIntensity;
|
||||
half _ScreenMaxIntensity;
|
||||
|
||||
|
||||
inline float ComputeLuma( float3 c )
|
||||
{
|
||||
return dot( c, fixed3(0.299, 0.587, 0.114) );
|
||||
}
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
|
||||
half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,i.uv.y));
|
||||
|
||||
half4 bloom = addedbloom;
|
||||
|
||||
#ifdef ULTIMATE_BLOOM_CURVE
|
||||
half intensity = dot(screencolor, half3(0.3,0.3,0.3));
|
||||
|
||||
float colLuma = ComputeLuma(x);
|
||||
|
||||
//colLuma *= _uTAA_Exposure;
|
||||
half bloomIntensity = x/max(1.0+colLuma,0.001);
|
||||
|
||||
//half bloomIntensity = Map(intensity);
|
||||
bloom *= screencolor * bloomIntensity/intensity*2000;
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_FLARE
|
||||
bloom += tex2D(_FlareTexture, i.uv); /* _FlareIntensity;*/
|
||||
#endif
|
||||
|
||||
bloom *= _Intensity;
|
||||
|
||||
#ifdef ULTIMATE_USE_DIRT
|
||||
half3 dirt = tex2D(_AdditiveTexture, i.uv).rgb;
|
||||
|
||||
float dirtIntensity = dot(dirt.xyz, half3(0.3,0.3,0.3));
|
||||
float bloomIntensity = dot(bloom.xyz, half3(0.3,0.3,0.3));
|
||||
float factor = saturate(bloomIntensity * dirtIntensity * _DirtIntensity);
|
||||
|
||||
bloom.xyz *= (dirt*_DirtIntensity + _DirtLightIntensity*0.2);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
return bloom + screencolor;
|
||||
|
||||
|
||||
}
|
||||
|
||||
fixed4 fragINV(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
|
||||
half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,1- i.uv.y));
|
||||
|
||||
half4 bloom = _Intensity * addedbloom;
|
||||
|
||||
#ifdef ULTIMATE_BLOOM_CURVE
|
||||
bloom.x = Map(bloom.x);
|
||||
bloom.y = Map(bloom.y);
|
||||
bloom.z = Map(bloom.z);
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_FLARE
|
||||
|
||||
bloom += tex2D(_FlareTexture, i.uv);
|
||||
|
||||
/*half3 flare = tex2D(_FlareTexture, i.uv).rgb * 40;
|
||||
half3 flareIntensity = dot(half3(0.3,0.3,0.3),flare);
|
||||
half flareFactor = saturate(flareIntensity );
|
||||
bloom.xyz = lerp(bloom.xyz, flare, flareFactor);*/
|
||||
|
||||
//bloom += tex2D(_FlareTexture, i.uv) * 5;
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_DIRT
|
||||
half3 dirt = tex2D(_AdditiveTexture, i.uv).rgb;
|
||||
|
||||
float dirtIntensity = dot(dirt.xyz, half3(0.3,0.3,0.3));
|
||||
float bloomIntensity = dot(bloom.xyz, half3(0.3,0.3,0.3));
|
||||
float factor = saturate(bloomIntensity * dirtIntensity * _DirtIntensity);
|
||||
|
||||
bloom.xyz *= (dirt*_DirtIntensity + _DirtLightIntensity*0.2);
|
||||
#endif
|
||||
|
||||
return bloom + screencolor;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma vertex vert
|
||||
#pragma fragment fragINV
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 481edcf7070d4ba49a3e69a7161224a5
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,147 @@
|
|||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
// Curve mapping
|
||||
half4 _Toe;
|
||||
half4 _Shoulder;
|
||||
half _K;
|
||||
half _Crossover;
|
||||
float Map(half x)
|
||||
{
|
||||
float4 data;
|
||||
float endAdd;
|
||||
|
||||
if (x > _Crossover)
|
||||
{
|
||||
data = _Shoulder;
|
||||
endAdd = _K;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = _Toe;
|
||||
endAdd = 0;
|
||||
}
|
||||
|
||||
|
||||
float2 numDenum = data.xy * x + data.zw;
|
||||
return numDenum.x / numDenum.y + endAdd;
|
||||
}
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _FlareTexture;
|
||||
sampler2D _ColorBuffer;
|
||||
sampler2D _AdditiveTexture;
|
||||
sampler2D _brightTexture;
|
||||
half _Intensity;
|
||||
half _FlareIntensity;
|
||||
half _DirtIntensity;
|
||||
half _DirtLightIntensity;
|
||||
half _ScreenMaxIntensity;
|
||||
|
||||
|
||||
inline float ComputeLuma( float3 c )
|
||||
{
|
||||
return dot( c, fixed3(0.299, 0.587, 0.114) );
|
||||
}
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
|
||||
half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,i.uv.y));
|
||||
|
||||
half4 bloom = addedbloom;
|
||||
|
||||
#ifdef ULTIMATE_BLOOM_CURVE
|
||||
half intensity = dot(screencolor, half3(0.3,0.3,0.3));
|
||||
|
||||
float colLuma = ComputeLuma(x);
|
||||
|
||||
//colLuma *= _uTAA_Exposure;
|
||||
half bloomIntensity = x/max(1.0+colLuma,0.001);
|
||||
|
||||
//half bloomIntensity = Map(intensity);
|
||||
bloom *= screencolor * bloomIntensity/intensity*2000;
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_FLARE
|
||||
bloom += tex2D(_FlareTexture, i.uv); /* _FlareIntensity;*/
|
||||
#endif
|
||||
|
||||
bloom *= _Intensity;
|
||||
|
||||
#ifdef ULTIMATE_USE_DIRT
|
||||
half3 dirt = tex2D(_AdditiveTexture, i.uv).rgb;
|
||||
|
||||
float dirtIntensity = dot(dirt.xyz, half3(0.3,0.3,0.3));
|
||||
float bloomIntensity = dot(bloom.xyz, half3(0.3,0.3,0.3));
|
||||
float factor = saturate(bloomIntensity * dirtIntensity * _DirtIntensity);
|
||||
|
||||
bloom.xyz *= (dirt*_DirtIntensity + _DirtLightIntensity*0.2);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
return bloom + screencolor;
|
||||
|
||||
|
||||
}
|
||||
|
||||
fixed4 fragINV(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
|
||||
half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,1- i.uv.y));
|
||||
|
||||
half4 bloom = _Intensity * addedbloom;
|
||||
|
||||
#ifdef ULTIMATE_BLOOM_CURVE
|
||||
bloom.x = Map(bloom.x);
|
||||
bloom.y = Map(bloom.y);
|
||||
bloom.z = Map(bloom.z);
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_FLARE
|
||||
|
||||
bloom += tex2D(_FlareTexture, i.uv);
|
||||
|
||||
/*half3 flare = tex2D(_FlareTexture, i.uv).rgb * 40;
|
||||
half3 flareIntensity = dot(half3(0.3,0.3,0.3),flare);
|
||||
half flareFactor = saturate(flareIntensity );
|
||||
bloom.xyz = lerp(bloom.xyz, flare, flareFactor);*/
|
||||
|
||||
//bloom += tex2D(_FlareTexture, i.uv) * 5;
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_DIRT
|
||||
half3 dirt = tex2D(_AdditiveTexture, i.uv).rgb;
|
||||
|
||||
float dirtIntensity = dot(dirt.xyz, half3(0.3,0.3,0.3));
|
||||
float bloomIntensity = dot(bloom.xyz, half3(0.3,0.3,0.3));
|
||||
float factor = saturate(bloomIntensity * dirtIntensity * _DirtIntensity);
|
||||
|
||||
bloom.xyz *= (dirt*_DirtIntensity + _DirtLightIntensity*0.2);
|
||||
#endif
|
||||
|
||||
return bloom + screencolor;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8630408eab779e24fb43f1ede27bbcf2
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,342 @@
|
|||
Shader "Hidden/Ultimate/BloomCombineFlareDirt" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB)", 2D) = "black" {}
|
||||
_FlareTexture ("Flare (RGB)", 2D) = "black" {}
|
||||
}
|
||||
|
||||
|
||||
Subshader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#define ULTIMATE_USE_FLARE
|
||||
#define ULTIMATE_USE_DIRT
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
// Curve mapping
|
||||
half4 _Toe;
|
||||
half4 _Shoulder;
|
||||
half _K;
|
||||
half _Crossover;
|
||||
float Map(half x)
|
||||
{
|
||||
float4 data;
|
||||
float endAdd;
|
||||
|
||||
if (x > _Crossover)
|
||||
{
|
||||
data = _Shoulder;
|
||||
endAdd = _K;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = _Toe;
|
||||
endAdd = 0;
|
||||
}
|
||||
|
||||
|
||||
float2 numDenum = data.xy * x + data.zw;
|
||||
return numDenum.x / numDenum.y + endAdd;
|
||||
}
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _FlareTexture;
|
||||
sampler2D _ColorBuffer;
|
||||
sampler2D _AdditiveTexture;
|
||||
sampler2D _brightTexture;
|
||||
half _Intensity;
|
||||
half _FlareIntensity;
|
||||
half _DirtIntensity;
|
||||
half _DirtLightIntensity;
|
||||
half _ScreenMaxIntensity;
|
||||
|
||||
|
||||
inline float ComputeLuma( float3 c )
|
||||
{
|
||||
return dot( c, fixed3(0.299, 0.587, 0.114) );
|
||||
}
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
|
||||
half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,i.uv.y));
|
||||
|
||||
half4 bloom = addedbloom;
|
||||
|
||||
#ifdef ULTIMATE_BLOOM_CURVE
|
||||
half intensity = dot(screencolor, half3(0.3,0.3,0.3));
|
||||
|
||||
float colLuma = ComputeLuma(x);
|
||||
|
||||
//colLuma *= _uTAA_Exposure;
|
||||
half bloomIntensity = x/max(1.0+colLuma,0.001);
|
||||
|
||||
//half bloomIntensity = Map(intensity);
|
||||
bloom *= screencolor * bloomIntensity/intensity*2000;
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_FLARE
|
||||
bloom += tex2D(_FlareTexture, i.uv); /* _FlareIntensity;*/
|
||||
#endif
|
||||
|
||||
bloom *= _Intensity;
|
||||
|
||||
#ifdef ULTIMATE_USE_DIRT
|
||||
half3 dirt = tex2D(_AdditiveTexture, i.uv).rgb;
|
||||
|
||||
float dirtIntensity = dot(dirt.xyz, half3(0.3,0.3,0.3));
|
||||
float bloomIntensity = dot(bloom.xyz, half3(0.3,0.3,0.3));
|
||||
float factor = saturate(bloomIntensity * dirtIntensity * _DirtIntensity);
|
||||
|
||||
bloom.xyz *= (dirt*_DirtIntensity + _DirtLightIntensity*0.2);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
return bloom + screencolor;
|
||||
|
||||
|
||||
}
|
||||
|
||||
fixed4 fragINV(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
|
||||
half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,1- i.uv.y));
|
||||
|
||||
half4 bloom = _Intensity * addedbloom;
|
||||
|
||||
#ifdef ULTIMATE_BLOOM_CURVE
|
||||
bloom.x = Map(bloom.x);
|
||||
bloom.y = Map(bloom.y);
|
||||
bloom.z = Map(bloom.z);
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_FLARE
|
||||
|
||||
bloom += tex2D(_FlareTexture, i.uv);
|
||||
|
||||
/*half3 flare = tex2D(_FlareTexture, i.uv).rgb * 40;
|
||||
half3 flareIntensity = dot(half3(0.3,0.3,0.3),flare);
|
||||
half flareFactor = saturate(flareIntensity );
|
||||
bloom.xyz = lerp(bloom.xyz, flare, flareFactor);*/
|
||||
|
||||
//bloom += tex2D(_FlareTexture, i.uv) * 5;
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_DIRT
|
||||
half3 dirt = tex2D(_AdditiveTexture, i.uv).rgb;
|
||||
|
||||
float dirtIntensity = dot(dirt.xyz, half3(0.3,0.3,0.3));
|
||||
float bloomIntensity = dot(bloom.xyz, half3(0.3,0.3,0.3));
|
||||
float factor = saturate(bloomIntensity * dirtIntensity * _DirtIntensity);
|
||||
|
||||
bloom.xyz *= (dirt*_DirtIntensity + _DirtLightIntensity*0.2);
|
||||
#endif
|
||||
|
||||
return bloom + screencolor;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#define ULTIMATE_USE_FLARE
|
||||
#define ULTIMATE_USE_DIRT
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
// Curve mapping
|
||||
half4 _Toe;
|
||||
half4 _Shoulder;
|
||||
half _K;
|
||||
half _Crossover;
|
||||
float Map(half x)
|
||||
{
|
||||
float4 data;
|
||||
float endAdd;
|
||||
|
||||
if (x > _Crossover)
|
||||
{
|
||||
data = _Shoulder;
|
||||
endAdd = _K;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = _Toe;
|
||||
endAdd = 0;
|
||||
}
|
||||
|
||||
|
||||
float2 numDenum = data.xy * x + data.zw;
|
||||
return numDenum.x / numDenum.y + endAdd;
|
||||
}
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _FlareTexture;
|
||||
sampler2D _ColorBuffer;
|
||||
sampler2D _AdditiveTexture;
|
||||
sampler2D _brightTexture;
|
||||
half _Intensity;
|
||||
half _FlareIntensity;
|
||||
half _DirtIntensity;
|
||||
half _DirtLightIntensity;
|
||||
half _ScreenMaxIntensity;
|
||||
|
||||
|
||||
inline float ComputeLuma( float3 c )
|
||||
{
|
||||
return dot( c, fixed3(0.299, 0.587, 0.114) );
|
||||
}
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
|
||||
half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,i.uv.y));
|
||||
|
||||
half4 bloom = addedbloom;
|
||||
|
||||
#ifdef ULTIMATE_BLOOM_CURVE
|
||||
half intensity = dot(screencolor, half3(0.3,0.3,0.3));
|
||||
|
||||
float colLuma = ComputeLuma(x);
|
||||
|
||||
//colLuma *= _uTAA_Exposure;
|
||||
half bloomIntensity = x/max(1.0+colLuma,0.001);
|
||||
|
||||
//half bloomIntensity = Map(intensity);
|
||||
bloom *= screencolor * bloomIntensity/intensity*2000;
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_FLARE
|
||||
bloom += tex2D(_FlareTexture, i.uv); /* _FlareIntensity;*/
|
||||
#endif
|
||||
|
||||
bloom *= _Intensity;
|
||||
|
||||
#ifdef ULTIMATE_USE_DIRT
|
||||
half3 dirt = tex2D(_AdditiveTexture, i.uv).rgb;
|
||||
|
||||
float dirtIntensity = dot(dirt.xyz, half3(0.3,0.3,0.3));
|
||||
float bloomIntensity = dot(bloom.xyz, half3(0.3,0.3,0.3));
|
||||
float factor = saturate(bloomIntensity * dirtIntensity * _DirtIntensity);
|
||||
|
||||
bloom.xyz *= (dirt*_DirtIntensity + _DirtLightIntensity*0.2);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
return bloom + screencolor;
|
||||
|
||||
|
||||
}
|
||||
|
||||
fixed4 fragINV(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
|
||||
half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,1- i.uv.y));
|
||||
|
||||
half4 bloom = _Intensity * addedbloom;
|
||||
|
||||
#ifdef ULTIMATE_BLOOM_CURVE
|
||||
bloom.x = Map(bloom.x);
|
||||
bloom.y = Map(bloom.y);
|
||||
bloom.z = Map(bloom.z);
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_FLARE
|
||||
|
||||
bloom += tex2D(_FlareTexture, i.uv);
|
||||
|
||||
/*half3 flare = tex2D(_FlareTexture, i.uv).rgb * 40;
|
||||
half3 flareIntensity = dot(half3(0.3,0.3,0.3),flare);
|
||||
half flareFactor = saturate(flareIntensity );
|
||||
bloom.xyz = lerp(bloom.xyz, flare, flareFactor);*/
|
||||
|
||||
//bloom += tex2D(_FlareTexture, i.uv) * 5;
|
||||
#endif
|
||||
|
||||
#ifdef ULTIMATE_USE_DIRT
|
||||
half3 dirt = tex2D(_AdditiveTexture, i.uv).rgb;
|
||||
|
||||
float dirtIntensity = dot(dirt.xyz, half3(0.3,0.3,0.3));
|
||||
float bloomIntensity = dot(bloom.xyz, half3(0.3,0.3,0.3));
|
||||
float factor = saturate(bloomIntensity * dirtIntensity * _DirtIntensity);
|
||||
|
||||
bloom.xyz *= (dirt*_DirtIntensity + _DirtLightIntensity*0.2);
|
||||
#endif
|
||||
|
||||
return bloom + screencolor;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma vertex vert
|
||||
#pragma fragment fragINV
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f0ecc1337a36c4f48871c943fddaed12
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,108 @@
|
|||
Shader "Hidden/Ultimate/BloomMixer" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
|
||||
Subshader
|
||||
{
|
||||
Pass // #0 Blend Add
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _ColorBuffer;
|
||||
half _Intensity;
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
half4 screencolor = tex2D(_ColorBuffer, i.uv);
|
||||
return _Intensity * addedbloom + screencolor;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #1 Blend With Intensity
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _ColorBuffer;
|
||||
half _Intensity0;
|
||||
half _Intensity1;
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 tex0 = tex2D(_MainTex, i.uv);
|
||||
half4 tex1 = tex2D(_ColorBuffer, i.uv);
|
||||
return tex0 * _Intensity0 + tex1 * _Intensity1;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #2 Blit with intensity
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
half _Intensity;
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 tex = tex2D(_MainTex, i.uv);
|
||||
return tex * _Intensity;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9a9192f3e87433946bcfb49c036c997d
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,488 @@
|
|||
Shader "Hidden/Ultimate/Bloom"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
_AdditiveTexture ("Base (RGB)", 2D) = "black" {}
|
||||
_OffsetInfos ("HorizontalOffset", Vector) = (0.0,0.0,0.0,0.0)
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
|
||||
#pragma target 3.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f_opts
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv[7] : TEXCOORD0;
|
||||
};
|
||||
|
||||
uniform half4 _MainTex_TexelSize;
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float4 _OffsetInfos;
|
||||
sampler2D _MainTex;
|
||||
half _Intensity;
|
||||
sampler2D _ColorBuffer;
|
||||
sampler2D _AdditiveTexture;
|
||||
sampler2D _FlareTexture;
|
||||
half4 _Threshhold;
|
||||
|
||||
float Gaussian(float Scale, int iSamplePoint)
|
||||
{
|
||||
float sigma = (Scale-1.0)/5;
|
||||
float g = 1.0f / sqrt(2.0f * 3.14159 * sigma * sigma);
|
||||
return (g * exp(-(iSamplePoint * iSamplePoint) / (2 * sigma * sigma)));
|
||||
}
|
||||
|
||||
|
||||
half4 fragGaussBlurHigh (v2f i) : SV_Target
|
||||
{
|
||||
half4 color = half4 (0,0,0,0);
|
||||
|
||||
float Scale = 31;
|
||||
|
||||
float2 gUV = i.uv;
|
||||
float Offset = 0;
|
||||
|
||||
color += Gaussian(Scale, 0.0 + Offset) * tex2D (_MainTex, gUV);
|
||||
color += Gaussian(Scale, 1.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 1.0);
|
||||
color += Gaussian(Scale, 1.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 1.0);
|
||||
color += Gaussian(Scale, 2.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 2.0);
|
||||
color += Gaussian(Scale, 2.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 2.0);
|
||||
color += Gaussian(Scale, 3.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 3.0);
|
||||
color += Gaussian(Scale, 3.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 3.0);
|
||||
color += Gaussian(Scale, 4.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 4.0);
|
||||
color += Gaussian(Scale, 4.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 4.0);
|
||||
color += Gaussian(Scale, 5.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 5.0);
|
||||
color += Gaussian(Scale, 5.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 5.0);
|
||||
color += Gaussian(Scale, 6.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 6.0);
|
||||
color += Gaussian(Scale, 6.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 6.0);
|
||||
color += Gaussian(Scale, 7.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 7.0);
|
||||
color += Gaussian(Scale, 7.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 7.0);
|
||||
color += Gaussian(Scale, 8.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 8.0);
|
||||
color += Gaussian(Scale, 8.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 8.0);
|
||||
color += Gaussian(Scale, 9.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 9.0);
|
||||
color += Gaussian(Scale, 9.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 9.0);
|
||||
color += Gaussian(Scale, 10.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 10.0);
|
||||
color += Gaussian(Scale, 10.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 10.0);
|
||||
color += Gaussian(Scale, 11.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 11.0);
|
||||
color += Gaussian(Scale, 11.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 11.0);
|
||||
color += Gaussian(Scale, 12.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 12.0);
|
||||
color += Gaussian(Scale, 12.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 12.0);
|
||||
color += Gaussian(Scale, 13.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 13.0);
|
||||
color += Gaussian(Scale, 13.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 13.0);
|
||||
color += Gaussian(Scale, 14.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 14.0);
|
||||
color += Gaussian(Scale, 14.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 14.0);
|
||||
color += Gaussian(Scale, 15.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 15.0);
|
||||
color += Gaussian(Scale, 15.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 15.0);
|
||||
|
||||
return color + tex2D(_AdditiveTexture, i.uv);
|
||||
}
|
||||
|
||||
half4 fragGaussBlurMedium (v2f i) : SV_Target
|
||||
{
|
||||
half4 color = half4 (0,0,0,0);
|
||||
|
||||
float Scale = 17;
|
||||
|
||||
float2 gUV = i.uv;
|
||||
float Offset = 0;
|
||||
|
||||
color += Gaussian(Scale, 0.0 + Offset) * tex2D (_MainTex, gUV);
|
||||
color += Gaussian(Scale, 1.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 1.0);
|
||||
color += Gaussian(Scale, 1.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 1.0);
|
||||
color += Gaussian(Scale, 2.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 2.0);
|
||||
color += Gaussian(Scale, 2.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 2.0);
|
||||
color += Gaussian(Scale, 3.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 3.0);
|
||||
color += Gaussian(Scale, 3.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 3.0);
|
||||
color += Gaussian(Scale, 4.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 4.0);
|
||||
color += Gaussian(Scale, 4.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 4.0);
|
||||
color += Gaussian(Scale, 5.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 5.0);
|
||||
color += Gaussian(Scale, 5.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 5.0);
|
||||
color += Gaussian(Scale, 6.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 6.0);
|
||||
color += Gaussian(Scale, 6.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 6.0);
|
||||
color += Gaussian(Scale, 7.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 7.0);
|
||||
color += Gaussian(Scale, 7.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 7.0);
|
||||
color += Gaussian(Scale, 8.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 8.0);
|
||||
color += Gaussian(Scale, 8.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 8.0);
|
||||
|
||||
return color + tex2D(_AdditiveTexture, i.uv);
|
||||
}
|
||||
|
||||
half4 fragGaussBlurLow (v2f i) : SV_Target
|
||||
{
|
||||
half4 color = half4 (0,0,0,0);
|
||||
|
||||
float Scale = 9;
|
||||
|
||||
float2 gUV = i.uv;
|
||||
float Offset = 0;
|
||||
|
||||
color += Gaussian(Scale, 0.0 + Offset) * tex2D (_MainTex, gUV);
|
||||
color += Gaussian(Scale, 1.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 1.0);
|
||||
color += Gaussian(Scale, 1.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 1.0);
|
||||
color += Gaussian(Scale, 2.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 2.0);
|
||||
color += Gaussian(Scale, 2.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 2.0);
|
||||
color += Gaussian(Scale, 3.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 3.0);
|
||||
color += Gaussian(Scale, 3.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 3.0);
|
||||
color += Gaussian(Scale, 4.0 + Offset) * tex2D (_MainTex, gUV + _OffsetInfos.xy * 4.0);
|
||||
color += Gaussian(Scale, 4.0 + Offset) * tex2D (_MainTex, gUV - _OffsetInfos.xy * 4.0);
|
||||
|
||||
return color + tex2D(_AdditiveTexture, i.uv);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
Pass // #0 Simple Downscaling
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
|
||||
|
||||
float2 UV[4];
|
||||
|
||||
UV[0] = i.uv + float2(-1.0 * _OffsetInfos.x, -1.0 * _OffsetInfos.y);
|
||||
UV[1] = i.uv + float2( 1.0 * _OffsetInfos.x, -1.0 * _OffsetInfos.y);
|
||||
UV[2] = i.uv + float2(-1.0 * _OffsetInfos.x, 1.0 * _OffsetInfos.y);
|
||||
UV[3] = i.uv + float2( 1.0 * _OffsetInfos.x, 1.0 * _OffsetInfos.y);
|
||||
|
||||
|
||||
fixed4 Sample[4];
|
||||
|
||||
for(int j = 0; j < 4; ++j)
|
||||
{
|
||||
Sample[j] = tex2D(_MainTex, UV[j]);
|
||||
}
|
||||
|
||||
return (Sample[0] + Sample[1] + Sample[2] + Sample[3]) * 1.0/4;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #1 Gaussian Sampling High
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma exclude_renderers flash
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment fragGaussBlurHigh
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #2 Gaussian Sampling Medium
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma exclude_renderers flash
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment fragGaussBlurMedium
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #3 Gaussian Sampling Low
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma exclude_renderers flash
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment fragGaussBlurLow
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #4 Color Brightpass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.uv);
|
||||
|
||||
half3 tColor = max(half3(0,0,0), color.rgb-_Threshhold.rgb);
|
||||
//half intensity = dot(tColor, float3(0.212671, 0.71516, 0.072169));
|
||||
half intensity = dot(tColor, half3(0.3,0.3,0.3));
|
||||
|
||||
return color * intensity;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #5 Blend Add
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
half4 screencolor = tex2D(_ColorBuffer, i.uv);
|
||||
return _Intensity * addedbloom + screencolor;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #6 Blend Screen
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
half4 screencolor = tex2D(_ColorBuffer, i.uv);
|
||||
return _Intensity * addedbloom + screencolor;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #7 Add One One
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
Blend One One
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 addedColors = tex2D(_MainTex, i.uv.xy);
|
||||
return addedColors * _Intensity;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #8 Render Flare
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
half4 _FlareScales;
|
||||
half4 _FlareTint0;
|
||||
half4 _FlareTint1;
|
||||
half4 _FlareTint2;
|
||||
half4 _FlareTint3;
|
||||
|
||||
half2 cUV(half2 uv)
|
||||
{
|
||||
return 2.0 * uv - float2(1.0,1.0);
|
||||
}
|
||||
|
||||
half2 tUV(half2 uv)
|
||||
{
|
||||
return (uv + float2(1.0,1.0))*0.5;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half scale0 = _FlareScales.x;//1.1f;
|
||||
half scale1 = _FlareScales.y;//0.95f;
|
||||
half scale2 = _FlareScales.z;//0.75f;
|
||||
half scale3 = _FlareScales.w;//0.55f;
|
||||
|
||||
half2 flareUv = cUV(float2(1.0,1.0) - i.uv);
|
||||
|
||||
float4 col0 = tex2D(_MainTex, tUV(flareUv*scale0) ) * _FlareTint0;
|
||||
float4 col1 = tex2D(_MainTex, tUV(flareUv*scale1) ) * _FlareTint1;
|
||||
float4 col2 = tex2D(_MainTex, tUV(flareUv*scale2) ) * _FlareTint2;
|
||||
float4 col3 = tex2D(_MainTex, tUV(flareUv*scale3) ) * _FlareTint3;
|
||||
|
||||
// Optional...
|
||||
flareUv = cUV(i.uv);
|
||||
float4 col4 = tex2D(_MainTex, tUV(flareUv*scale0) ) * _FlareTint0;
|
||||
float4 col5 = tex2D(_MainTex, tUV(flareUv*scale1) ) * _FlareTint1;
|
||||
float4 col6 = tex2D(_MainTex, tUV(flareUv*scale2) ) * _FlareTint2;
|
||||
float4 col7 = tex2D(_MainTex, tUV(flareUv*scale3) ) * _FlareTint3;
|
||||
|
||||
return (col0 + col1 + col2 + col3 + col4 + col5 + col6 + col7) * tex2D(_FlareTexture,i.uv);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #9 Blend Add with flares
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
half _FlareIntensity;
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
//half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,1- i.uv.y));
|
||||
half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,i.uv.y));
|
||||
half4 bloom = _Intensity * addedbloom + tex2D(_FlareTexture, i.uv) * _FlareIntensity;
|
||||
|
||||
half3 dirt = tex2D(_AdditiveTexture, i.uv).rgb * bloom * 1000;
|
||||
//bloom.rgb -= dirt;
|
||||
return bloom + screencolor + float4(dirt,1.0) ;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #10 Complex Downscaling
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
|
||||
|
||||
float2 UV[9];
|
||||
|
||||
UV[0] = i.uv;
|
||||
|
||||
UV[1] = i.uv + float2( -2.0 * _OffsetInfos.x, -2.0 * _OffsetInfos.y);
|
||||
UV[2] = i.uv + float2( 0.0 * _OffsetInfos.x, -2.0 * _OffsetInfos.y);
|
||||
UV[3] = i.uv + float2( 2.0 * _OffsetInfos.x, -2.0 * _OffsetInfos.y);
|
||||
UV[4] = i.uv + float2( -2.0 * _OffsetInfos.x, 2.0 * _OffsetInfos.y);
|
||||
UV[5] = i.uv + float2( 0.0 * _OffsetInfos.x, 2.0 * _OffsetInfos.y);
|
||||
UV[6] = i.uv + float2( 2.0 * _OffsetInfos.x, 2.0 * _OffsetInfos.y);
|
||||
UV[7] = i.uv + float2( -2.0 * _OffsetInfos.x, 0.0 * _OffsetInfos.y);
|
||||
UV[8] = i.uv + float2( 2.0 * _OffsetInfos.x, 0.0 * _OffsetInfos.y);
|
||||
|
||||
|
||||
fixed4 Sample[9];
|
||||
|
||||
for(int j = 0; j < 9; ++j)
|
||||
{
|
||||
Sample[j] = tex2D(_MainTex, UV[j]);
|
||||
}
|
||||
|
||||
return (Sample[0] + Sample[1] + Sample[2] + Sample[3] + Sample[4] + Sample[5] + Sample[6] + Sample[7] + Sample[8]) * 1.0/9;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #11 Blend Add with flares Inverted Source (for forward MSAA)
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
half _FlareIntensity;
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 addedbloom = tex2D(_MainTex, i.uv);
|
||||
half4 screencolor = tex2D(_ColorBuffer, float2(i.uv.x,1- i.uv.y));
|
||||
half4 bloom = _Intensity * addedbloom + tex2D(_FlareTexture, i.uv) * _FlareIntensity;
|
||||
|
||||
half3 dirt = tex2D(_AdditiveTexture, i.uv).rgb * bloom * 1000;
|
||||
return bloom + screencolor + float4(dirt,1.0) ;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FallBack off
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ab676bda447e26b43b1479fa93ae8d8b
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,72 @@
|
|||
// Unlit alpha-blended shader.
|
||||
// - no lighting
|
||||
// - no lightmap support
|
||||
// - no per-material color
|
||||
|
||||
Shader "Hidden/Ultimate/BokehTexture" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
|
||||
_Intensity ("Intensity", Float) = 1
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
|
||||
LOD 100
|
||||
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
//Blend SrcAlpha One
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
float4x4 _MeshProjectionMatrix;
|
||||
float4x4 _MeshTransformationMatrix;
|
||||
half _Intensity;
|
||||
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
half4 _Tint;
|
||||
|
||||
v2f vert (appdata_full v)
|
||||
{
|
||||
v2f o;
|
||||
//o.vertex = mul(_MeshTransformationMatrix, v.vertex);
|
||||
//o.vertex = mul(_MeshProjectionMatrix, v.vertex);
|
||||
|
||||
o.vertex = v.vertex;
|
||||
|
||||
o.texcoord = v.texcoord;
|
||||
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = tex2D(_MainTex, i.texcoord);
|
||||
|
||||
|
||||
col.xyz *= _Tint;
|
||||
col.a *= _Intensity;
|
||||
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 239f6fb2ba87e0147bd6ade6d10111a9
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,44 @@
|
|||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _MaskTex;
|
||||
half4 _Threshhold;
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.uv);
|
||||
|
||||
half3 tColor = max(half3(0,0,0), color.rgb-_Threshhold.rgb);
|
||||
half intensity = dot(tColor, half3(0.3,0.3,0.3));
|
||||
|
||||
return clamp(color * intensity * tex2D(_MaskTex, i.uv).r,0,65000);
|
||||
}
|
||||
|
||||
fixed4 fragNOI(v2f i):COLOR
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.uv);
|
||||
|
||||
half3 tColor = max(half3(0,0,0), color.rgb-_Threshhold.rgb);
|
||||
|
||||
return half4(tColor, 1.0) * tex2D(_MaskTex, i.uv).r;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2ced9b82dce9c754d9cbcffaee39e640
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,131 @@
|
|||
Shader "Hidden/Ultimate/BrightpassMask" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
_MaskTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
|
||||
Subshader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _MaskTex;
|
||||
half4 _Threshhold;
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.uv);
|
||||
|
||||
half3 tColor = max(half3(0,0,0), color.rgb-_Threshhold.rgb);
|
||||
half intensity = dot(tColor, half3(0.3,0.3,0.3));
|
||||
|
||||
return clamp(color * intensity * tex2D(_MaskTex, i.uv).r,0,65000);
|
||||
}
|
||||
|
||||
fixed4 fragNOI(v2f i):COLOR
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.uv);
|
||||
|
||||
half3 tColor = max(half3(0,0,0), color.rgb-_Threshhold.rgb);
|
||||
|
||||
return half4(tColor, 1.0) * tex2D(_MaskTex, i.uv).r;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _MaskTex;
|
||||
half4 _Threshhold;
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.uv);
|
||||
|
||||
half3 tColor = max(half3(0,0,0), color.rgb-_Threshhold.rgb);
|
||||
half intensity = dot(tColor, half3(0.3,0.3,0.3));
|
||||
|
||||
return clamp(color * intensity * tex2D(_MaskTex, i.uv).r,0,65000);
|
||||
}
|
||||
|
||||
fixed4 fragNOI(v2f i):COLOR
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.uv);
|
||||
|
||||
half3 tColor = max(half3(0,0,0), color.rgb-_Threshhold.rgb);
|
||||
|
||||
return half4(tColor, 1.0) * tex2D(_MaskTex, i.uv).r;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma vertex vert
|
||||
#pragma fragment fragNOI
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 68bd60cbcc102e3459b4065ed54e526b
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,95 @@
|
|||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
half4 uv0 : TEXCOORD1;
|
||||
half4 uv1 : TEXCOORD2;
|
||||
half4 uv2 : TEXCOORD3;
|
||||
half4 uv3 : TEXCOORD4;
|
||||
};
|
||||
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _FlareTexture;
|
||||
half _Intensity;
|
||||
|
||||
half4 _FlareScales;
|
||||
half4 _FlareScalesNear;
|
||||
half4 _FlareTint0;
|
||||
half4 _FlareTint1;
|
||||
half4 _FlareTint2;
|
||||
half4 _FlareTint3;
|
||||
half4 _FlareTint4;
|
||||
half4 _FlareTint5;
|
||||
half4 _FlareTint6;
|
||||
half4 _FlareTint7;
|
||||
|
||||
half2 cUV(half2 uv)
|
||||
{
|
||||
return 2.0 * uv - float2(1.0,1.0);
|
||||
}
|
||||
|
||||
half2 tUV(half2 uv)
|
||||
{
|
||||
return (uv + float2(1.0,1.0))*0.5;
|
||||
}
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
|
||||
half scale0 = _FlareScales.x;
|
||||
half scale1 = _FlareScales.y;
|
||||
half scale2 = _FlareScales.z;
|
||||
half scale3 = _FlareScales.w;
|
||||
|
||||
half2 flareUv = cUV(half2(1.0,1.0) - o.uv);
|
||||
o.uv0.xy = tUV(flareUv*scale0);
|
||||
o.uv1.xy = tUV(flareUv*scale1);
|
||||
o.uv2.xy = tUV(flareUv*scale2);
|
||||
o.uv3.xy = tUV(flareUv*scale3);
|
||||
|
||||
half scale4 = _FlareScalesNear.x;
|
||||
half scale5 = _FlareScalesNear.y;
|
||||
half scale6 = _FlareScalesNear.z;
|
||||
half scale7 = _FlareScalesNear.w;
|
||||
|
||||
flareUv = cUV(o.uv);
|
||||
o.uv0.zw = tUV(flareUv*scale4);
|
||||
o.uv1.zw = tUV(flareUv*scale5);
|
||||
o.uv2.zw = tUV(flareUv*scale6);
|
||||
o.uv3.zw = tUV(flareUv*scale7);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half2 flareUv = cUV(float2(1.0,1.0) - i.uv);
|
||||
|
||||
float4 acc = float4(0,0,0,0);
|
||||
|
||||
acc += tex2D(_MainTex, i.uv0.xy ) * _FlareTint0;
|
||||
acc += tex2D(_MainTex, i.uv1.xy ) * _FlareTint1;
|
||||
acc += tex2D(_MainTex, i.uv2.xy ) * _FlareTint2;
|
||||
acc += tex2D(_MainTex, i.uv3.xy ) * _FlareTint3;
|
||||
|
||||
#ifdef FLARE_DOUBLE
|
||||
flareUv = cUV(i.uv);
|
||||
|
||||
acc += tex2D(_MainTex, i.uv0.zw ) * _FlareTint4;
|
||||
acc += tex2D(_MainTex, i.uv1.zw ) * _FlareTint5;
|
||||
acc += tex2D(_MainTex, i.uv2.zw ) * _FlareTint6;
|
||||
acc += tex2D(_MainTex, i.uv3.zw ) * _FlareTint7;
|
||||
#endif
|
||||
|
||||
return clamp(acc *_Intensity,0, 65000);
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 734a7bdac9cb2e64e8a8d013f9aec730
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,123 @@
|
|||
Shader "Hidden/Ultimate/FlareDouble" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
|
||||
Subshader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#define FLARE_DOUBLE
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
half4 uv0 : TEXCOORD1;
|
||||
half4 uv1 : TEXCOORD2;
|
||||
half4 uv2 : TEXCOORD3;
|
||||
half4 uv3 : TEXCOORD4;
|
||||
};
|
||||
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _FlareTexture;
|
||||
half _Intensity;
|
||||
|
||||
half4 _FlareScales;
|
||||
half4 _FlareScalesNear;
|
||||
half4 _FlareTint0;
|
||||
half4 _FlareTint1;
|
||||
half4 _FlareTint2;
|
||||
half4 _FlareTint3;
|
||||
half4 _FlareTint4;
|
||||
half4 _FlareTint5;
|
||||
half4 _FlareTint6;
|
||||
half4 _FlareTint7;
|
||||
|
||||
half2 cUV(half2 uv)
|
||||
{
|
||||
return 2.0 * uv - float2(1.0,1.0);
|
||||
}
|
||||
|
||||
half2 tUV(half2 uv)
|
||||
{
|
||||
return (uv + float2(1.0,1.0))*0.5;
|
||||
}
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
|
||||
half scale0 = _FlareScales.x;
|
||||
half scale1 = _FlareScales.y;
|
||||
half scale2 = _FlareScales.z;
|
||||
half scale3 = _FlareScales.w;
|
||||
|
||||
half2 flareUv = cUV(half2(1.0,1.0) - o.uv);
|
||||
o.uv0.xy = tUV(flareUv*scale0);
|
||||
o.uv1.xy = tUV(flareUv*scale1);
|
||||
o.uv2.xy = tUV(flareUv*scale2);
|
||||
o.uv3.xy = tUV(flareUv*scale3);
|
||||
|
||||
half scale4 = _FlareScalesNear.x;
|
||||
half scale5 = _FlareScalesNear.y;
|
||||
half scale6 = _FlareScalesNear.z;
|
||||
half scale7 = _FlareScalesNear.w;
|
||||
|
||||
flareUv = cUV(o.uv);
|
||||
o.uv0.zw = tUV(flareUv*scale4);
|
||||
o.uv1.zw = tUV(flareUv*scale5);
|
||||
o.uv2.zw = tUV(flareUv*scale6);
|
||||
o.uv3.zw = tUV(flareUv*scale7);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half2 flareUv = cUV(float2(1.0,1.0) - i.uv);
|
||||
|
||||
float4 acc = float4(0,0,0,0);
|
||||
|
||||
acc += tex2D(_MainTex, i.uv0.xy ) * _FlareTint0;
|
||||
acc += tex2D(_MainTex, i.uv1.xy ) * _FlareTint1;
|
||||
acc += tex2D(_MainTex, i.uv2.xy ) * _FlareTint2;
|
||||
acc += tex2D(_MainTex, i.uv3.xy ) * _FlareTint3;
|
||||
|
||||
#ifdef FLARE_DOUBLE
|
||||
flareUv = cUV(i.uv);
|
||||
|
||||
acc += tex2D(_MainTex, i.uv0.zw ) * _FlareTint4;
|
||||
acc += tex2D(_MainTex, i.uv1.zw ) * _FlareTint5;
|
||||
acc += tex2D(_MainTex, i.uv2.zw ) * _FlareTint6;
|
||||
acc += tex2D(_MainTex, i.uv3.zw ) * _FlareTint7;
|
||||
#endif
|
||||
|
||||
return clamp(acc *_Intensity,0, 65000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 82d5870d890eb51468257e24b9f26478
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,52 @@
|
|||
Shader "Hidden/Ultimate/FlareMask" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
_MaskTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
|
||||
Subshader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _MaskTex;
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
return tex2D(_MainTex, i.uv) * tex2D(_MaskTex, i.uv).r;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b6119eaa372f3504a92a1603c0afebc8
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,72 @@
|
|||
// Unlit alpha-blended shader.
|
||||
// - no lighting
|
||||
// - no lightmap support
|
||||
// - no per-material color
|
||||
|
||||
Shader "Hidden/Ultimate/FlareMesh" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "black" {}
|
||||
_BrightTexture ("Base (RGB) Trans (A)", 2D) = "black" {}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
|
||||
LOD 100
|
||||
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend SrcAlpha One
|
||||
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 3.0
|
||||
#pragma glsl
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
float4x4 _FlareProj;
|
||||
half _Intensity;
|
||||
|
||||
|
||||
struct v2f {
|
||||
float4 vertex : SV_POSITION;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
half3 color : TEXCOORD1;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
sampler2D _BrightTexture;
|
||||
|
||||
v2f vert (appdata_full v)
|
||||
{
|
||||
v2f o;
|
||||
//o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.vertex = mul(_FlareProj, v.vertex);
|
||||
o.texcoord = v.texcoord;
|
||||
|
||||
half3 bloom = tex2Dlod(_BrightTexture, float4(v.texcoord1.xy,0,0) ).xyz;
|
||||
o.color = bloom * _Intensity;
|
||||
|
||||
half intensity = dot(half3(0.3,0.3,0.3), o.color.xyz);
|
||||
if (intensity < 0.001)
|
||||
o.vertex = half4(-10000,-10000,0.0,1.0);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
fixed4 col = tex2D(_MainTex, i.texcoord);
|
||||
col.xyz *= i.color.xyz;
|
||||
|
||||
return col;
|
||||
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: abe4898237b1d4d49b8a3ebc0f5b4d49
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,121 @@
|
|||
Shader "Hidden/Ultimate/FlareSingle" {
|
||||
Properties {
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
|
||||
Subshader
|
||||
{
|
||||
Pass
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
half4 uv0 : TEXCOORD1;
|
||||
half4 uv1 : TEXCOORD2;
|
||||
half4 uv2 : TEXCOORD3;
|
||||
half4 uv3 : TEXCOORD4;
|
||||
};
|
||||
|
||||
|
||||
|
||||
sampler2D _MainTex;
|
||||
sampler2D _FlareTexture;
|
||||
half _Intensity;
|
||||
|
||||
half4 _FlareScales;
|
||||
half4 _FlareScalesNear;
|
||||
half4 _FlareTint0;
|
||||
half4 _FlareTint1;
|
||||
half4 _FlareTint2;
|
||||
half4 _FlareTint3;
|
||||
half4 _FlareTint4;
|
||||
half4 _FlareTint5;
|
||||
half4 _FlareTint6;
|
||||
half4 _FlareTint7;
|
||||
|
||||
half2 cUV(half2 uv)
|
||||
{
|
||||
return 2.0 * uv - float2(1.0,1.0);
|
||||
}
|
||||
|
||||
half2 tUV(half2 uv)
|
||||
{
|
||||
return (uv + float2(1.0,1.0))*0.5;
|
||||
}
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
|
||||
half scale0 = _FlareScales.x;
|
||||
half scale1 = _FlareScales.y;
|
||||
half scale2 = _FlareScales.z;
|
||||
half scale3 = _FlareScales.w;
|
||||
|
||||
half2 flareUv = cUV(half2(1.0,1.0) - o.uv);
|
||||
o.uv0.xy = tUV(flareUv*scale0);
|
||||
o.uv1.xy = tUV(flareUv*scale1);
|
||||
o.uv2.xy = tUV(flareUv*scale2);
|
||||
o.uv3.xy = tUV(flareUv*scale3);
|
||||
|
||||
half scale4 = _FlareScalesNear.x;
|
||||
half scale5 = _FlareScalesNear.y;
|
||||
half scale6 = _FlareScalesNear.z;
|
||||
half scale7 = _FlareScalesNear.w;
|
||||
|
||||
flareUv = cUV(o.uv);
|
||||
o.uv0.zw = tUV(flareUv*scale4);
|
||||
o.uv1.zw = tUV(flareUv*scale5);
|
||||
o.uv2.zw = tUV(flareUv*scale6);
|
||||
o.uv3.zw = tUV(flareUv*scale7);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half2 flareUv = cUV(float2(1.0,1.0) - i.uv);
|
||||
|
||||
float4 acc = float4(0,0,0,0);
|
||||
|
||||
acc += tex2D(_MainTex, i.uv0.xy ) * _FlareTint0;
|
||||
acc += tex2D(_MainTex, i.uv1.xy ) * _FlareTint1;
|
||||
acc += tex2D(_MainTex, i.uv2.xy ) * _FlareTint2;
|
||||
acc += tex2D(_MainTex, i.uv3.xy ) * _FlareTint3;
|
||||
|
||||
#ifdef FLARE_DOUBLE
|
||||
flareUv = cUV(i.uv);
|
||||
|
||||
acc += tex2D(_MainTex, i.uv0.zw ) * _FlareTint4;
|
||||
acc += tex2D(_MainTex, i.uv1.zw ) * _FlareTint5;
|
||||
acc += tex2D(_MainTex, i.uv2.zw ) * _FlareTint6;
|
||||
acc += tex2D(_MainTex, i.uv3.zw ) * _FlareTint7;
|
||||
#endif
|
||||
|
||||
return clamp(acc *_Intensity,0, 65000);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 079e3a5c047c057468f404709ddfe3dc
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,751 @@
|
|||
Shader "Hidden/Ultimate/Sampling"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Base (RGB)", 2D) = "white" {}
|
||||
}
|
||||
|
||||
CGINCLUDE
|
||||
|
||||
#pragma target 3.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
float4 _OffsetInfos;
|
||||
float4 _Tint;
|
||||
float _Intensity;
|
||||
sampler2D _MainTex;
|
||||
sampler2D _AdditiveTexture;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f_opts
|
||||
{
|
||||
half4 pos : SV_POSITION;
|
||||
half2 uv[7] : TEXCOORD0;
|
||||
};
|
||||
|
||||
v2f vert( appdata_img v )
|
||||
{
|
||||
v2f o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
struct v2fLow {
|
||||
half4 pos : POSITION;
|
||||
half2 uv : TEXCOORD0;
|
||||
half4 uv01 : TEXCOORD1;
|
||||
half4 uv23 : TEXCOORD2;
|
||||
half4 uv45 : TEXCOORD3;
|
||||
half4 uv67 : TEXCOORD4;
|
||||
half4 uv89 : TEXCOORD5;
|
||||
};
|
||||
|
||||
|
||||
v2fLow vertLow( appdata_img v )
|
||||
{
|
||||
v2fLow o;
|
||||
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
|
||||
o.uv01 = v.texcoord.xyxy + _OffsetInfos.xyxy * half4(1,1, -1,-1);
|
||||
o.uv23 = v.texcoord.xyxy + _OffsetInfos.xyxy * half4(1,1, -1,-1) * 2;
|
||||
o.uv45 = v.texcoord.xyxy + _OffsetInfos.xyxy * half4(1,1, -1,-1) * 3;
|
||||
o.uv67 = v.texcoord.xyxy + _OffsetInfos.xyxy * half4(1,1, -1,-1) * 4;
|
||||
o.uv89 = v.texcoord.xyxy + _OffsetInfos.xyxy * half4(1,1, -1,-1) * 5;
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
inline float ComputeLuma( float3 c )
|
||||
{
|
||||
return dot( c, fixed3(0.299, 0.587, 0.114) );
|
||||
}
|
||||
|
||||
|
||||
float Gaussian(float Scale, int iSamplePoint)
|
||||
{
|
||||
float sigma = (Scale-1.0)/5;
|
||||
float g = 1.0f / sqrt(2.0f * 3.14159 * sigma * sigma);
|
||||
return (g * exp(-(iSamplePoint * iSamplePoint) / (2 * sigma * sigma)));
|
||||
}
|
||||
|
||||
float4 Upsample(half2 uv)
|
||||
{
|
||||
half4 f0 = tex2D (_AdditiveTexture, uv + half2(_OffsetInfos.z,_OffsetInfos.w));
|
||||
half4 f1 = tex2D (_AdditiveTexture, uv + half2(-_OffsetInfos.z,_OffsetInfos.w));
|
||||
half4 f2 = tex2D (_AdditiveTexture, uv + half2(-_OffsetInfos.z,-_OffsetInfos.w));
|
||||
half4 f3 = tex2D (_AdditiveTexture, uv + half2(_OffsetInfos.z,-_OffsetInfos.w));
|
||||
|
||||
return (f0+f1+f2+f3)*0.25;
|
||||
}
|
||||
|
||||
|
||||
half4 fragGaussBlurVeryHigh (v2f i) : SV_Target
|
||||
{
|
||||
half4 color = half4 (0,0,0,0);
|
||||
|
||||
float Scale = 31;
|
||||
|
||||
float2 gUV = i.uv;
|
||||
float Offset = 0;
|
||||
|
||||
color += 0.1480461 * tex2D (_MainTex, gUV);
|
||||
color += 0.1451146 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 1);
|
||||
color += 0.1451146 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 1);
|
||||
color += 0.1366637 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 2);
|
||||
color += 0.1366637 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 2);
|
||||
color += 0.1236585 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 3);
|
||||
color += 0.1236585 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 3);
|
||||
color += 0.1075035 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 4);
|
||||
color += 0.1075035 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 4);
|
||||
color += 0.08979447 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 5);
|
||||
color += 0.08979447 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 5);
|
||||
color += 0.07206175 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 6);
|
||||
color += 0.07206175 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 6);
|
||||
color += 0.05556333 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 7);
|
||||
color += 0.05556333 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 7);
|
||||
color += 0.04116233 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 8);
|
||||
color += 0.04116233 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 8);
|
||||
color += 0.02929812 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 9);
|
||||
color += 0.02929812 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 9);
|
||||
color += 0.02003586 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 10);
|
||||
color += 0.02003586 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 10);
|
||||
color += 0.01316449 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 11);
|
||||
color += 0.01316449 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 11);
|
||||
color += 0.008310529 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 12);
|
||||
color += 0.008310529 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 12);
|
||||
color += 0.005040591 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 13);
|
||||
color += 0.005040591 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 13);
|
||||
color += 0.002937396 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 14);
|
||||
color += 0.002937396 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 14);
|
||||
color += 0.001644643 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 15);
|
||||
color += 0.001644643 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 15);
|
||||
|
||||
|
||||
color.a = 1.0;
|
||||
return color * _Tint * _Intensity + Upsample(i.uv);
|
||||
}
|
||||
|
||||
half4 fragGaussBlurHigher (v2f i) : SV_Target
|
||||
{
|
||||
half4 color = half4 (0,0,0,0);
|
||||
|
||||
float Scale = 31;
|
||||
|
||||
float2 gUV = i.uv;
|
||||
float Offset = 0;
|
||||
|
||||
color += 0.1562562 * tex2D (_MainTex, gUV);
|
||||
color += 0.1527989 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 1);
|
||||
color += 0.1527989 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 1);
|
||||
color += 0.1428793 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 2);
|
||||
color += 0.1428793 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 2);
|
||||
color += 0.1277568 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 3);
|
||||
color += 0.1277568 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 3);
|
||||
color += 0.1092358 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 4);
|
||||
color += 0.1092358 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 4);
|
||||
color += 0.08931243 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 5);
|
||||
color += 0.08931243 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 5);
|
||||
color += 0.06982721 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 6);
|
||||
color += 0.06982721 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 6);
|
||||
color += 0.05220396 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 7);
|
||||
color += 0.05220396 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 7);
|
||||
color += 0.03732055 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 8);
|
||||
color += 0.03732055 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 8);
|
||||
color += 0.02551284 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 9);
|
||||
color += 0.02551284 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 9);
|
||||
color += 0.01667767 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 10);
|
||||
color += 0.01667767 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 10);
|
||||
color += 0.01042505 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 11);
|
||||
color += 0.01042505 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 11);
|
||||
color += 0.006231415 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 12);
|
||||
color += 0.006231415 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 12);
|
||||
color += 0.003561732 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 13);
|
||||
color += 0.003561732 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 13);
|
||||
|
||||
|
||||
color.a = 1.0;
|
||||
return color * _Tint * _Intensity + Upsample(i.uv);
|
||||
}
|
||||
|
||||
half4 fragGaussBlurHigh (v2f i) : SV_Target
|
||||
{
|
||||
half4 color = half4 (0,0,0,0);
|
||||
|
||||
float Scale = 31;
|
||||
|
||||
float2 gUV = i.uv;
|
||||
float Offset = 0;
|
||||
|
||||
color += 0.1820341 * tex2D (_MainTex, gUV);
|
||||
color += 0.1764335 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 1);
|
||||
color += 0.1764335 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 1);
|
||||
color += 0.1606445 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 2);
|
||||
color += 0.1606445 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 2);
|
||||
color += 0.1374065 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 3);
|
||||
color += 0.1374065 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 3);
|
||||
color += 0.1104092 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 4);
|
||||
color += 0.1104092 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 4);
|
||||
color += 0.08334126 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 5);
|
||||
color += 0.08334126 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 5);
|
||||
color += 0.05909781 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 6);
|
||||
color += 0.05909781 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 6);
|
||||
color += 0.03936763 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 7);
|
||||
color += 0.03936763 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 7);
|
||||
color += 0.02463563 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 8);
|
||||
color += 0.02463563 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 8);
|
||||
color += 0.01448254 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 9);
|
||||
color += 0.01448254 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 9);
|
||||
color += 0.007998019 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 10);
|
||||
color += 0.007998019 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 10);
|
||||
color += 0.004149318 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 11);
|
||||
color += 0.004149318 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 11);
|
||||
|
||||
|
||||
color.a = 1.0;
|
||||
return color * _Tint * _Intensity + Upsample(i.uv);
|
||||
}
|
||||
|
||||
half4 fragGaussBlurMedium (v2f i) : SV_Target
|
||||
{
|
||||
half4 color = half4 (0,0,0,0);
|
||||
|
||||
float Scale = 17;
|
||||
|
||||
float2 gUV = i.uv;
|
||||
float Offset = 0;
|
||||
|
||||
color += 0.2605744 * tex2D (_MainTex, gUV);
|
||||
color += 0.242882 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 1);
|
||||
color += 0.242882 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 1);
|
||||
color += 0.1966919 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 2);
|
||||
color += 0.1966919 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 2);
|
||||
color += 0.13839 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 3);
|
||||
color += 0.13839 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 3);
|
||||
color += 0.08459612 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 4);
|
||||
color += 0.08459612 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 4);
|
||||
color += 0.04492867 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 5);
|
||||
color += 0.04492867 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 5);
|
||||
color += 0.02073118 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 6);
|
||||
color += 0.02073118 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 6);
|
||||
color += 0.008310967 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 7);
|
||||
color += 0.008310967 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 7);
|
||||
color += 0.002894721 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 8);
|
||||
color += 0.002894721 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 8);
|
||||
|
||||
|
||||
return color * _Tint * _Intensity + Upsample(i.uv);
|
||||
}
|
||||
|
||||
half4 fragGaussBlurLow (v2f i) : SV_Target
|
||||
{
|
||||
half4 color = half4 (0,0,0,0);
|
||||
|
||||
float Scale = 17;
|
||||
|
||||
float2 gUV = i.uv;
|
||||
float Offset = 0;
|
||||
|
||||
color += 0.3098615 * tex2D (_MainTex, gUV);
|
||||
color += 0.2789662 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 1);
|
||||
color += 0.2789662 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 1);
|
||||
color += 0.2035652 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 2);
|
||||
color += 0.2035652 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 2);
|
||||
color += 0.1203992 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 3);
|
||||
color += 0.1203992 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 3);
|
||||
color += 0.05771804 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 4);
|
||||
color += 0.05771804 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 4);
|
||||
color += 0.02242682 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 5);
|
||||
color += 0.02242682 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 5);
|
||||
color += 0.00706304 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 6);
|
||||
color += 0.00706304 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 6);
|
||||
|
||||
|
||||
return color * _Tint * _Intensity + Upsample(i.uv);
|
||||
}
|
||||
|
||||
half4 fragGaussBlurVeryLow (v2fLow i) : SV_Target
|
||||
{
|
||||
half4 color = half4 (0,0,0,0);
|
||||
|
||||
float2 gUV = i.uv;
|
||||
float Offset = 0;
|
||||
|
||||
color += 0.4310208 * tex2D (_MainTex, i.uv);
|
||||
|
||||
color += 0.3403002 * tex2D (_MainTex, i.uv01.xy);
|
||||
color += 0.3403002 * tex2D (_MainTex, i.uv01.zw);
|
||||
|
||||
color += 0.1674766 * tex2D (_MainTex, i.uv23.xy);
|
||||
color += 0.1674766 * tex2D (_MainTex, i.uv23.zw);
|
||||
|
||||
color += 0.05137766 * tex2D (_MainTex, i.uv45.xy);
|
||||
color += 0.05137766 * tex2D (_MainTex, i.uv45.zw);
|
||||
|
||||
color += 0.009824769 * tex2D (_MainTex, i.uv67.xy);
|
||||
color += 0.009824769 * tex2D (_MainTex, i.uv67.zw);
|
||||
|
||||
return color * _Tint * _Intensity + Upsample(i.uv);
|
||||
}
|
||||
|
||||
|
||||
ENDCG
|
||||
|
||||
SubShader
|
||||
{
|
||||
Pass // #0 Simple Downscaling
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
float2 UV[4];
|
||||
|
||||
UV[0] = i.uv + float2(-1.0 * _OffsetInfos.x, -1.0 * _OffsetInfos.y);
|
||||
UV[1] = i.uv + float2( 1.0 * _OffsetInfos.x, -1.0 * _OffsetInfos.y);
|
||||
UV[2] = i.uv + float2(-1.0 * _OffsetInfos.x, 1.0 * _OffsetInfos.y);
|
||||
UV[3] = i.uv + float2( 1.0 * _OffsetInfos.x, 1.0 * _OffsetInfos.y);
|
||||
|
||||
|
||||
fixed4 Sample[4];
|
||||
|
||||
for(int j = 0; j < 4; ++j)
|
||||
{
|
||||
Sample[j] = tex2D(_MainTex, UV[j]);
|
||||
}
|
||||
|
||||
return (Sample[0] + Sample[1] + Sample[2] + Sample[3]) * 1.0/4;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #1 Complex Downscaling
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
|
||||
float2 UV[9];
|
||||
|
||||
UV[0] = i.uv;
|
||||
|
||||
UV[1] = i.uv + float2( -2.0 * _OffsetInfos.x, -2.0 * _OffsetInfos.y);
|
||||
UV[2] = i.uv + float2( 0.0 * _OffsetInfos.x, -2.0 * _OffsetInfos.y);
|
||||
UV[3] = i.uv + float2( 2.0 * _OffsetInfos.x, -2.0 * _OffsetInfos.y);
|
||||
UV[4] = i.uv + float2( -2.0 * _OffsetInfos.x, 2.0 * _OffsetInfos.y);
|
||||
UV[5] = i.uv + float2( 0.0 * _OffsetInfos.x, 2.0 * _OffsetInfos.y);
|
||||
UV[6] = i.uv + float2( 2.0 * _OffsetInfos.x, 2.0 * _OffsetInfos.y);
|
||||
UV[7] = i.uv + float2( -2.0 * _OffsetInfos.x, 0.0 * _OffsetInfos.y);
|
||||
UV[8] = i.uv + float2( 2.0 * _OffsetInfos.x, 0.0 * _OffsetInfos.y);
|
||||
|
||||
|
||||
|
||||
fixed4 Sample[9];
|
||||
|
||||
for(int j = 0; j < 9; ++j)
|
||||
{
|
||||
Sample[j] = tex2D(_MainTex, UV[j]);
|
||||
}
|
||||
|
||||
half4 sum = half4(0,0,0,0);
|
||||
for(int j = 0; j < 9; ++j)
|
||||
{
|
||||
sum += Sample[j];
|
||||
}
|
||||
|
||||
return sum* 1.0/9;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #2 Gaussian Sampling Very High
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma exclude_renderers flash
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment fragGaussBlurVeryHigh
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #3 Gaussian Sampling Medium
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma exclude_renderers flash
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment fragGaussBlurMedium
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #4 Gaussian Sampling Very Low
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma exclude_renderers flash
|
||||
#pragma vertex vertLow
|
||||
#pragma fragment fragGaussBlurVeryLow
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
Pass // #5 Filmic curve sampling
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
// Curve mapping
|
||||
half4 _Toe;
|
||||
half4 _Shoulder;
|
||||
half _K;
|
||||
half _Crossover;
|
||||
half _MaxValue;
|
||||
half _CurveExposure;
|
||||
float Map(half x)
|
||||
{
|
||||
float4 data;
|
||||
float endAdd;
|
||||
|
||||
if (x > _Crossover)
|
||||
{
|
||||
data = _Shoulder;
|
||||
endAdd = _K;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = _Toe;
|
||||
endAdd = 0;
|
||||
}
|
||||
|
||||
|
||||
float2 numDenum = data.xy * x + data.zw;
|
||||
return numDenum.x / numDenum.y + endAdd;
|
||||
}
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
float2 UV[4];
|
||||
|
||||
UV[0] = i.uv + float2(-1.0 * _OffsetInfos.x, -1.0 * _OffsetInfos.y);
|
||||
UV[1] = i.uv + float2( 1.0 * _OffsetInfos.x, -1.0 * _OffsetInfos.y);
|
||||
UV[2] = i.uv + float2(-1.0 * _OffsetInfos.x, 1.0 * _OffsetInfos.y);
|
||||
UV[3] = i.uv + float2( 1.0 * _OffsetInfos.x, 1.0 * _OffsetInfos.y);
|
||||
|
||||
fixed4 Sample[4];
|
||||
|
||||
for(int j = 0; j < 4; ++j)
|
||||
{
|
||||
Sample[j] = tex2D(_MainTex, UV[j]);
|
||||
}
|
||||
|
||||
half4 color = (Sample[0] + Sample[1] + Sample[2] + Sample[3]) * 1.0/4;
|
||||
|
||||
half intensity = ComputeLuma(color);
|
||||
|
||||
|
||||
|
||||
half bloomIntensity = intensity/max(1.0+intensity*_CurveExposure,0.01);
|
||||
|
||||
bloomIntensity = Map(bloomIntensity) * _MaxValue;
|
||||
|
||||
return clamp(color * bloomIntensity/intensity,0,65000);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #6 Low Gaussian Filmic Curve
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
// Curve mapping
|
||||
half4 _Toe;
|
||||
half4 _Shoulder;
|
||||
half _K;
|
||||
half _Crossover;
|
||||
float Map(half x)
|
||||
{
|
||||
float4 data;
|
||||
float endAdd;
|
||||
|
||||
if (x > _Crossover)
|
||||
{
|
||||
data = _Shoulder;
|
||||
endAdd = _K;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = _Toe;
|
||||
endAdd = 0;
|
||||
}
|
||||
|
||||
|
||||
float2 numDenum = data.xy * x + data.zw;
|
||||
return numDenum.x / numDenum.y + endAdd;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
half4 color = half4 (0,0,0,0);
|
||||
|
||||
float Scale = 9;
|
||||
|
||||
float2 gUV = i.uv;
|
||||
float Offset = 0;
|
||||
|
||||
color += 0.4005 * tex2D (_MainTex, gUV);
|
||||
color += 0.3294 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 1.0);
|
||||
color += 0.3294 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 1.0);
|
||||
color += 0.1833 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 2.0);
|
||||
color += 0.1833 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 2.0);
|
||||
color += 0.0691 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 3.0);
|
||||
color += 0.0691 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 3.0);
|
||||
color += 0.0175 * tex2D (_MainTex, gUV + _OffsetInfos.xy * 4.0);
|
||||
color += 0.0175 * tex2D (_MainTex, gUV - _OffsetInfos.xy * 4.0);
|
||||
|
||||
|
||||
|
||||
|
||||
half intensity = dot(color, half3(0.3,0.3,0.3));
|
||||
half bloomIntensity = Map(intensity);
|
||||
|
||||
return color * bloomIntensity/intensity;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #7 Simple Blur
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
|
||||
|
||||
float2 UV[3];
|
||||
|
||||
UV[0] = i.uv;
|
||||
UV[1] = i.uv + 1.5*_OffsetInfos;
|
||||
UV[2] = i.uv - 1.5*_OffsetInfos;
|
||||
//UV[2] = i.uv + 2*_OffsetInfos;
|
||||
//UV[3] = i.uv - 2*_OffsetInfos;
|
||||
|
||||
|
||||
fixed4 Sample[3];
|
||||
|
||||
for(int j = 0; j < 3; ++j)
|
||||
{
|
||||
Sample[j] = tex2D(_MainTex, UV[j]);
|
||||
}
|
||||
|
||||
return (Sample[0] + Sample[1] + Sample[2]) * 1.0/3;
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #8 Gaussian Sampling Small
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma exclude_renderers flash
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment fragGaussBlurLow
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #9 Gaussian Sampling High
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma exclude_renderers flash
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment fragGaussBlurHigh
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #10 Gaussian Sampling Higher
|
||||
{
|
||||
CGPROGRAM
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma exclude_renderers flash
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment fragGaussBlurHigher
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass // #11 Temporal Stable Downsampling
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
float2 _MainTex_TexelSize;
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
float4 offsets = _MainTex_TexelSize.xyxy * float4(-1.0, -1.0, +1.0, +1.0);
|
||||
half3 c0 = tex2D(_MainTex, i.uv + offsets.xy);
|
||||
half3 c1 = tex2D(_MainTex, i.uv + offsets.zy);
|
||||
half3 c2 = tex2D(_MainTex, i.uv + offsets.xw);
|
||||
half3 c3 = tex2D(_MainTex, i.uv + offsets.zw);
|
||||
half w0 = 1.0 / (ComputeLuma(c0) + 1.0);
|
||||
half w1 = 1.0 / (ComputeLuma(c1) + 1.0);
|
||||
half w2 = 1.0 / (ComputeLuma(c2) + 1.0);
|
||||
half w3 = 1.0 / (ComputeLuma(c3) + 1.0);
|
||||
half div = 1.0 / max(w0 + w1 + w2 + w3, 0.01);
|
||||
float3 color = (c0 * w0 + c1 * w1 + c2 * w2 + c3 * w3) * div;
|
||||
|
||||
return float4(clamp(color,0,65000), 1);
|
||||
|
||||
//half intensity = dot(color, half3(0.3,0.3,0.3));
|
||||
|
||||
//half bloomIntensity = intensity/max(1.0+intensity*_CurveExposure,0.01);
|
||||
|
||||
//return float4(clamp(color * bloomIntensity/intensity,0,65000), 1);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
|
||||
Pass // #12 Temporal Stable Downsampling with filmic curve
|
||||
{
|
||||
ZTest Always Cull Off ZWrite Off
|
||||
Fog { Mode off }
|
||||
|
||||
CGPROGRAM
|
||||
|
||||
#pragma vertex vert_img
|
||||
#pragma fragment frag
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
float2 _MainTex_TexelSize;
|
||||
|
||||
// Curve mapping
|
||||
half4 _Toe;
|
||||
half4 _Shoulder;
|
||||
half _K;
|
||||
half _Crossover;
|
||||
half _MaxValue;
|
||||
half _CurveExposure;
|
||||
float Map(half x)
|
||||
{
|
||||
float4 data;
|
||||
float endAdd;
|
||||
|
||||
if (x > _Crossover)
|
||||
{
|
||||
data = _Shoulder;
|
||||
endAdd = _K;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = _Toe;
|
||||
endAdd = 0;
|
||||
}
|
||||
|
||||
|
||||
float2 numDenum = data.xy * x + data.zw;
|
||||
return numDenum.x / numDenum.y + endAdd;
|
||||
}
|
||||
|
||||
fixed4 frag(v2f i):COLOR
|
||||
{
|
||||
float4 offsets = _MainTex_TexelSize.xyxy * float4(-1.0, -1.0, +1.0, +1.0);
|
||||
half3 c0 = tex2D(_MainTex, i.uv + offsets.xy);
|
||||
half3 c1 = tex2D(_MainTex, i.uv + offsets.zy);
|
||||
half3 c2 = tex2D(_MainTex, i.uv + offsets.xw);
|
||||
half3 c3 = tex2D(_MainTex, i.uv + offsets.zw);
|
||||
half w0 = 1.0 / (ComputeLuma(c0) + 1.0);
|
||||
half w1 = 1.0 / (ComputeLuma(c1) + 1.0);
|
||||
half w2 = 1.0 / (ComputeLuma(c2) + 1.0);
|
||||
half w3 = 1.0 / (ComputeLuma(c3) + 1.0);
|
||||
half div = 1.0 / max(w0 + w1 + w2 + w3, 0.01);
|
||||
float3 color = (c0 * w0 + c1 * w1 + c2 * w2 + c3 * w3) * div;
|
||||
|
||||
half intensity = ComputeLuma(color);
|
||||
|
||||
half bloomIntensity = intensity/max(1.0+intensity*_CurveExposure,0.01);
|
||||
bloomIntensity = Map(bloomIntensity) * _MaxValue;
|
||||
|
||||
return float4(clamp(color * bloomIntensity/intensity,0,65000), 1);
|
||||
}
|
||||
|
||||
ENDCG
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
FallBack off
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: aae4bb3d598e50d4bada0867c1df4eb4
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/BloomBeta/Scripts.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8d98caaa93f108b4a8be214f58dfe23f
|
||||
folderAsset: yes
|
||||
timeCreated: 1443580217
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
191
Assets/Cinematic Effects/BloomBeta/Scripts/BokehRenderer.cs
Normal file
|
@ -0,0 +1,191 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
class BokehRenderer
|
||||
{
|
||||
Texture2D m_CurrentTexture;
|
||||
//Mesh[] m_FlareMeshes = null;
|
||||
Material m_FlareMaterial;
|
||||
|
||||
int m_CurrentWidth;
|
||||
int m_CurrentHeight;
|
||||
float m_CurrentRelativeScaleX;
|
||||
float m_CurrentRelativeScaleY;
|
||||
|
||||
public BokehRenderer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void RebuildMeshIfNeeded(int width, int height, float spriteRelativeScaleX, float spriteRelativeScaleY, ref Mesh[] meshes)
|
||||
{
|
||||
if (m_CurrentWidth == width && m_CurrentHeight == height && m_CurrentRelativeScaleX == spriteRelativeScaleX && m_CurrentRelativeScaleY == spriteRelativeScaleY && meshes != null)
|
||||
return;
|
||||
|
||||
if (meshes != null)
|
||||
foreach (Mesh m in meshes)
|
||||
{
|
||||
GameObject.DestroyImmediate(m, true);
|
||||
}
|
||||
meshes = null;
|
||||
|
||||
BuildMeshes(width, height, spriteRelativeScaleX, spriteRelativeScaleY, ref meshes);
|
||||
|
||||
}
|
||||
|
||||
public void BuildMeshes(int width, int height, float spriteRelativeScaleX, float spriteRelativeScaleY, ref Mesh[] meshes)
|
||||
{
|
||||
int maxQuads = 65000 / 6;
|
||||
int totalQuads = width * height;
|
||||
int meshCount = Mathf.CeilToInt((1.0f * totalQuads) / (1.0f * maxQuads));
|
||||
meshes = new Mesh[meshCount];
|
||||
int currentQuads = totalQuads;
|
||||
|
||||
|
||||
m_CurrentWidth = width;
|
||||
m_CurrentHeight = height;
|
||||
m_CurrentRelativeScaleX = spriteRelativeScaleX;
|
||||
m_CurrentRelativeScaleY = spriteRelativeScaleY;
|
||||
int currentPixel = 0;
|
||||
|
||||
for (int m = 0; m < meshCount; ++m)
|
||||
{
|
||||
Mesh currentMesh = new Mesh();
|
||||
currentMesh.hideFlags = HideFlags.HideAndDontSave;
|
||||
|
||||
int nbQuads = currentQuads;
|
||||
if (currentQuads > maxQuads)
|
||||
nbQuads = maxQuads;
|
||||
currentQuads -= nbQuads;
|
||||
|
||||
Vector3[] vertices = new Vector3[nbQuads * 4];
|
||||
int[] triangles = new int[nbQuads * 6];
|
||||
Vector2[] uv0 = new Vector2[nbQuads * 4];
|
||||
Vector2[] uv1 = new Vector2[nbQuads * 4];
|
||||
Vector3[] normals = new Vector3[nbQuads * 4];
|
||||
Color[] colors = new Color[nbQuads * 4];
|
||||
|
||||
float spriteWidth = m_CurrentRelativeScaleX * width;
|
||||
float spriteHeigth = m_CurrentRelativeScaleY * height;
|
||||
|
||||
|
||||
for (int i = 0; i < nbQuads; ++i)
|
||||
{
|
||||
int x = currentPixel % width;
|
||||
int y = (currentPixel - x) / width;
|
||||
SetupSprite(i, x, y, vertices, triangles, uv0, uv1, normals, colors, new Vector2((float)x / (float)width, 1.0f - ((float)y / (float)height)), spriteWidth * 0.5f, spriteHeigth * 0.5f);
|
||||
currentPixel++;
|
||||
}
|
||||
|
||||
currentMesh.vertices = vertices;
|
||||
currentMesh.triangles = triangles;
|
||||
currentMesh.colors = colors;
|
||||
currentMesh.uv = uv0;
|
||||
currentMesh.uv2 = uv1;
|
||||
currentMesh.normals = normals;
|
||||
currentMesh.RecalculateBounds();
|
||||
currentMesh.UploadMeshData(true);
|
||||
meshes[m] = currentMesh;
|
||||
}
|
||||
}
|
||||
|
||||
public void Clear(ref Mesh[] meshes)
|
||||
{
|
||||
if (meshes != null)
|
||||
foreach (Mesh m in meshes)
|
||||
{
|
||||
GameObject.DestroyImmediate(m, true);
|
||||
}
|
||||
meshes = null;
|
||||
}
|
||||
|
||||
public void SetTexture(Texture2D texture)
|
||||
{
|
||||
m_CurrentTexture = texture;
|
||||
m_FlareMaterial.SetTexture("_MainTex", m_CurrentTexture);
|
||||
}
|
||||
|
||||
public void SetMaterial(Material flareMaterial)
|
||||
{
|
||||
m_FlareMaterial = flareMaterial;
|
||||
}
|
||||
|
||||
public void RenderFlare(RenderTexture brightPixels, RenderTexture destination, float intensity, ref Mesh[] meshes)
|
||||
{
|
||||
|
||||
RenderTexture lastActive = RenderTexture.active;
|
||||
|
||||
RenderTexture.active = destination;
|
||||
GL.Clear(true, true, Color.black);
|
||||
|
||||
Matrix4x4 proj = Matrix4x4.Ortho(0, m_CurrentWidth, 0, m_CurrentHeight, -1.0f, 1.0f);
|
||||
|
||||
m_FlareMaterial.SetMatrix("_FlareProj", proj);
|
||||
m_FlareMaterial.SetTexture("_BrightTexture", brightPixels);
|
||||
m_FlareMaterial.SetFloat("_Intensity", intensity);
|
||||
|
||||
if (m_FlareMaterial.SetPass(0))
|
||||
{
|
||||
//Debug.Log("MeshCount=" + m_FlareMeshes.Length);
|
||||
|
||||
for (int i = 0; i < meshes.Length; ++i )
|
||||
Graphics.DrawMeshNow(meshes[i], Matrix4x4.identity);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Can't render flare mesh");
|
||||
}
|
||||
|
||||
RenderTexture.active = lastActive;
|
||||
|
||||
}
|
||||
|
||||
public void SetupSprite(int idx, int x, int y, Vector3[] vertices, int[] triangles, Vector2[] uv0, Vector2[] uv1, Vector3[] normals, Color[] colors, Vector2 targetPixelUV, float halfWidth, float halfHeight)
|
||||
{
|
||||
int vIdx = idx * 4;
|
||||
int tIdx = idx * 6;
|
||||
|
||||
triangles[tIdx + 0] = vIdx + 0;
|
||||
triangles[tIdx + 1] = vIdx + 2;
|
||||
triangles[tIdx + 2] = vIdx + 1;
|
||||
|
||||
triangles[tIdx + 3] = vIdx + 2;
|
||||
triangles[tIdx + 4] = vIdx + 3;
|
||||
triangles[tIdx + 5] = vIdx + 1;
|
||||
|
||||
vertices[vIdx + 0] = new Vector3((-halfWidth + x), (-halfHeight + y), 0);
|
||||
vertices[vIdx + 1] = new Vector3((halfWidth + x), (-halfHeight + y), 0);
|
||||
vertices[vIdx + 2] = new Vector3((-halfWidth + x), (halfHeight + y), 0);
|
||||
vertices[vIdx + 3] = new Vector3((halfWidth + x), (halfHeight + y), 0);
|
||||
|
||||
Vector2 p = targetPixelUV;
|
||||
|
||||
colors[vIdx + 0] = new Color((-halfWidth / m_CurrentWidth + p.x), (-halfHeight*-1/ m_CurrentHeight + p.y), 0, 0);
|
||||
colors[vIdx + 1] = new Color((halfWidth / m_CurrentWidth + p.x), (-halfHeight * -1 / m_CurrentHeight + p.y), 0, 0);
|
||||
colors[vIdx + 2] = new Color((-halfWidth / m_CurrentWidth + p.x), (halfHeight * -1 / m_CurrentHeight + p.y), 0, 0);
|
||||
colors[vIdx + 3] = new Color((halfWidth / m_CurrentWidth + p.x), (halfHeight * -1 / m_CurrentHeight + p.y), 0, 0);
|
||||
|
||||
normals[vIdx + 0] = -Vector3.forward;
|
||||
normals[vIdx + 1] = -Vector3.forward;
|
||||
normals[vIdx + 2] = -Vector3.forward;
|
||||
normals[vIdx + 3] = -Vector3.forward;
|
||||
|
||||
uv0[vIdx + 0] = new Vector2(0, 0);
|
||||
uv0[vIdx + 1] = new Vector2(1.0f, 0);
|
||||
uv0[vIdx + 2] = new Vector2(0, 1.0f);
|
||||
uv0[vIdx + 3] = new Vector2(1.0f, 1.0f);
|
||||
|
||||
uv1[vIdx + 0] = targetPixelUV;
|
||||
uv1[vIdx + 1] = targetPixelUV;
|
||||
uv1[vIdx + 2] = targetPixelUV;
|
||||
uv1[vIdx + 3] = targetPixelUV;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f26e82e850c24c444bb8306feb47738d
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
241
Assets/Cinematic Effects/BloomBeta/Scripts/DeluxeFilmicCurve.cs
Normal file
|
@ -0,0 +1,241 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
using UnityEditor;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
[Serializable]
|
||||
public class DeluxeFilmicCurve
|
||||
{
|
||||
[SerializeField]
|
||||
public float m_BlackPoint = 0.0f;
|
||||
|
||||
[SerializeField]
|
||||
public float m_WhitePoint = 1.0f;
|
||||
|
||||
[SerializeField]
|
||||
public float m_CrossOverPoint = 0.3f;
|
||||
|
||||
[SerializeField]
|
||||
public float m_ToeStrength = 0.98f;
|
||||
|
||||
[SerializeField]
|
||||
public float m_ShoulderStrength = 0.0f;
|
||||
|
||||
[SerializeField]
|
||||
public float m_Highlights = 0.5f;
|
||||
|
||||
public float m_k;
|
||||
public Vector4 m_ToeCoef;
|
||||
public Vector4 m_ShoulderCoef;
|
||||
|
||||
public float GetExposure()
|
||||
{
|
||||
float highlights = m_Highlights;
|
||||
float exposure = 2.0f + (1.0f - highlights) * 20.0f;
|
||||
return (exposure * Mathf.Exp(-2.0f));
|
||||
}
|
||||
|
||||
public float ComputeK(float t, float c, float b, float s, float w)
|
||||
{
|
||||
float num = (1 - t) * (c - b);
|
||||
float denom = (1 - s) * (w - c) + (1 - t) * (c - b);
|
||||
|
||||
return num / denom;
|
||||
}
|
||||
|
||||
public float Toe(float x, float t, float c, float b, float s, float w, float k)
|
||||
{
|
||||
float xnum = m_ToeCoef.x * x;
|
||||
float xdenom = m_ToeCoef.y * x;
|
||||
|
||||
return (xnum + m_ToeCoef.z) / (xdenom + m_ToeCoef.w);
|
||||
|
||||
/*float num = k * (1 - t) * (x - b);
|
||||
float denom = c - (1 - t) * b - t * x;
|
||||
|
||||
return num / denom;*/
|
||||
}
|
||||
|
||||
public float Shoulder(float x, float t, float c, float b, float s, float w, float k)
|
||||
{
|
||||
float xnum = m_ShoulderCoef.x * x;
|
||||
float xdenom = m_ShoulderCoef.y * x;
|
||||
|
||||
return (xnum + m_ShoulderCoef.z) / (xdenom + m_ShoulderCoef.w) + k;
|
||||
|
||||
/*float num = (1 - k) * (x - c);
|
||||
float denom = s*x + (1 - s) * w - c;
|
||||
|
||||
return num / denom + k;*/
|
||||
}
|
||||
|
||||
public float Graph(float x, float t, float c, float b, float s, float w, float k)
|
||||
{
|
||||
if (x <= m_CrossOverPoint)
|
||||
return Toe(x, t, c, b, s, w, k);
|
||||
|
||||
return Shoulder(x, t, c, b, s, w, k);
|
||||
}
|
||||
|
||||
public void StoreK()
|
||||
{
|
||||
m_k = ComputeK(m_ToeStrength, m_CrossOverPoint, m_BlackPoint, m_ShoulderStrength, m_WhitePoint);
|
||||
}
|
||||
|
||||
public void ComputeShaderCoefficients(float t, float c, float b, float s, float w, float k)
|
||||
{
|
||||
{
|
||||
float xNumMul = k * (1 - t);
|
||||
float numAdd = k * (1 - t) * -b;
|
||||
float xDenomMul = -t;
|
||||
float denomAdd = c - (1 - t) * b;
|
||||
m_ToeCoef = new Vector4(xNumMul, xDenomMul, numAdd, denomAdd);
|
||||
}
|
||||
|
||||
{
|
||||
float xNumMul = (1 - k);
|
||||
float numAdd = (1 - k) * -c;
|
||||
float xDenomMul = s;
|
||||
float denomAdd = (1 - s) * w - c;
|
||||
m_ShoulderCoef = new Vector4(xNumMul, xDenomMul, numAdd, denomAdd);
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateCoefficients()
|
||||
{
|
||||
StoreK();
|
||||
ComputeShaderCoefficients(m_ToeStrength, m_CrossOverPoint, m_BlackPoint, m_ShoulderStrength, m_WhitePoint, m_k);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Vector3[] m_CurvePoints;
|
||||
|
||||
void DrawCurve()
|
||||
{
|
||||
//Rect rr = GUILayoutUtility.GetRect(Mathf.Min(r.width, 60), 60);
|
||||
//if (m_CurvePoints != null)
|
||||
{
|
||||
const int h = 100;
|
||||
const int h1 = h - 1;
|
||||
Rect rect;
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
rect = GUILayoutUtility.GetRect(Mathf.Max(EditorGUIUtility.currentViewWidth - 50.0f, 10.0f), h);
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
GUI.Box(rect, GUIContent.none);
|
||||
|
||||
int nbPoint = 40;
|
||||
int w = Mathf.FloorToInt(rect.width);
|
||||
|
||||
Vector3[] points = new Vector3[nbPoint];
|
||||
|
||||
for (int i = 0; i < nbPoint; i++)
|
||||
{
|
||||
float norm = (float)i / (float)nbPoint;
|
||||
float value = Graph(norm * m_WhitePoint, m_ToeStrength, m_CrossOverPoint, m_BlackPoint, m_ShoulderStrength, m_WhitePoint, m_k);
|
||||
value = Mathf.Clamp01(value);
|
||||
points[i] = new Vector3(rect.x + i * (float)w / (float)(nbPoint - 1), rect.y + (h - value * h1), 0f);
|
||||
}
|
||||
|
||||
|
||||
Handles.color = Color.green;
|
||||
Handles.DrawAAPolyLine(2f, points);
|
||||
}
|
||||
//EditorGUI.CurveField(rr, m_Curve);
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
{
|
||||
//SetupCurve();
|
||||
|
||||
float denom = m_WhitePoint - m_BlackPoint;
|
||||
|
||||
float co = (m_CrossOverPoint - m_BlackPoint) / denom;
|
||||
if (Mathf.Abs(denom) < 0.001f)
|
||||
co = 0.5f;
|
||||
|
||||
EditorGUILayout.LabelField("Curve Parameters", EditorStyles.boldLabel);
|
||||
m_WhitePoint = 1.0f;
|
||||
m_BlackPoint = 0.0f;
|
||||
co = DoSlider("Middle", co, 0.0f, 1.0f);
|
||||
m_ToeStrength = -1.0f * DoSlider("Dark", -1.0f * m_ToeStrength, -0.99f, 0.99f);
|
||||
m_ShoulderStrength = DoSlider("Bright", m_ShoulderStrength, -0.99f, 0.99f);
|
||||
m_Highlights = DoSlider("Highlights", m_Highlights, 0.0f, 1.0f);
|
||||
|
||||
m_CrossOverPoint = co * (m_WhitePoint - m_BlackPoint) + m_BlackPoint;
|
||||
UpdateCoefficients();
|
||||
|
||||
EditorGUILayout.BeginVertical(GUILayout.MinHeight(60));
|
||||
// Curve drawing
|
||||
DrawCurve();
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
AnimationCurve m_Curve;
|
||||
|
||||
private static float CalculateLinearTangent(AnimationCurve curve, int index, int toIndex)
|
||||
{
|
||||
return (float)(((double)curve[index].value - (double)curve[toIndex].value) / ((double)curve[index].time - (double)curve[toIndex].time));
|
||||
}
|
||||
|
||||
void SetupCurve()
|
||||
{
|
||||
m_Curve = new AnimationCurve();
|
||||
|
||||
DeluxeFilmicCurve dt = this;
|
||||
|
||||
float min = dt.m_BlackPoint;
|
||||
float max = dt.m_WhitePoint;
|
||||
|
||||
int nbFrame = 40;
|
||||
float step = (max - min) / nbFrame;
|
||||
|
||||
m_CurvePoints = new Vector3[nbFrame + 1];
|
||||
|
||||
float curr = min;
|
||||
float k = dt.ComputeK(dt.m_ToeStrength, dt.m_CrossOverPoint, dt.m_BlackPoint, dt.m_ShoulderStrength, dt.m_WhitePoint);
|
||||
|
||||
dt.StoreK();
|
||||
dt.ComputeShaderCoefficients(dt.m_ToeStrength, dt.m_CrossOverPoint, dt.m_BlackPoint, dt.m_ShoulderStrength, dt.m_WhitePoint, k);
|
||||
|
||||
for (int i = 0; i < nbFrame + 1; ++i)
|
||||
{
|
||||
float value = dt.Graph(curr, dt.m_ToeStrength, dt.m_CrossOverPoint, dt.m_BlackPoint, dt.m_ShoulderStrength, dt.m_WhitePoint, k);
|
||||
|
||||
m_CurvePoints[i] = new Vector3(curr, value);
|
||||
|
||||
m_Curve.AddKey(new Keyframe(curr, value));
|
||||
|
||||
curr += step;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_Curve.keys.Length - 1; ++i)
|
||||
{
|
||||
float tangent = CalculateLinearTangent(m_Curve, i, i + 1);
|
||||
m_Curve.keys[i].inTangent = tangent;
|
||||
m_Curve.keys[i].outTangent = tangent;
|
||||
|
||||
m_Curve.SmoothTangents(i, 0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
float DoSlider(string label, float value, float min, float max)
|
||||
{
|
||||
float v = value;
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
v = Mathf.Clamp(EditorGUILayout.FloatField(label, v), min, max);
|
||||
v = GUILayout.HorizontalSlider(v, min, max);
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4b47c958d5706f24d8fc004492f16384
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
84
Assets/Cinematic Effects/BloomBeta/Scripts/UBHelper.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class UBHelper : MonoBehaviour
|
||||
{
|
||||
|
||||
static UBHelper()
|
||||
{
|
||||
s_Styles = new Styles();
|
||||
}
|
||||
|
||||
public static bool GroupHeader(string text, bool isExpanded)
|
||||
{
|
||||
Rect rect = GUILayoutUtility.GetRect(16f, 22f, s_Styles.header);
|
||||
|
||||
s_Styles.Backup();
|
||||
s_Styles.Apply();
|
||||
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
s_Styles.header.Draw(rect, text, isExpanded, isExpanded, isExpanded, isExpanded);
|
||||
|
||||
Event e = Event.current;
|
||||
if (e.type == EventType.MouseDown)
|
||||
{
|
||||
if (rect.Contains(e.mousePosition))
|
||||
{
|
||||
isExpanded = !isExpanded;
|
||||
e.Use();
|
||||
}
|
||||
}
|
||||
|
||||
s_Styles.Revert();
|
||||
return isExpanded;
|
||||
}
|
||||
|
||||
private static Styles s_Styles;
|
||||
private class Styles
|
||||
{
|
||||
public GUIStyle header = "ShurikenModuleTitle";
|
||||
public GUIStyle headerArrow = "AC RightArrow";
|
||||
|
||||
internal Styles()
|
||||
{
|
||||
header.font = (new GUIStyle("Label")).font;
|
||||
}
|
||||
|
||||
RectOffset m_Border;
|
||||
float m_FixedHeight;
|
||||
Vector2 m_ContentOffset;
|
||||
TextAnchor m_TextAlign;
|
||||
FontStyle m_TextStyle;
|
||||
int m_FontSize;
|
||||
|
||||
public void Backup()
|
||||
{
|
||||
m_Border = s_Styles.header.border;
|
||||
m_FixedHeight = s_Styles.header.fixedHeight;
|
||||
m_ContentOffset = s_Styles.header.contentOffset;
|
||||
m_TextAlign = s_Styles.header.alignment;
|
||||
m_TextStyle = s_Styles.header.fontStyle;
|
||||
m_FontSize = s_Styles.header.fontSize;
|
||||
}
|
||||
|
||||
public void Apply()
|
||||
{
|
||||
s_Styles.header.border = new RectOffset(7, 7, 4, 4);
|
||||
s_Styles.header.fixedHeight = 22;
|
||||
s_Styles.header.contentOffset = new Vector2(20f, -2f);
|
||||
s_Styles.header.alignment = TextAnchor.MiddleLeft;
|
||||
s_Styles.header.fontStyle = FontStyle.Bold;
|
||||
s_Styles.header.fontSize = 12;
|
||||
}
|
||||
|
||||
public void Revert()
|
||||
{
|
||||
s_Styles.header.border = m_Border;
|
||||
s_Styles.header.fixedHeight = m_FixedHeight;
|
||||
s_Styles.header.contentOffset = m_ContentOffset;
|
||||
s_Styles.header.alignment = m_TextAlign;
|
||||
s_Styles.header.fontStyle = m_TextStyle;
|
||||
s_Styles.header.fontSize = m_FontSize;
|
||||
}
|
||||
}
|
||||
}
|
12
Assets/Cinematic Effects/BloomBeta/Scripts/UBHelper.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 68539e60785f1d44c8848e40b66f760f
|
||||
timeCreated: 1456307053
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
1568
Assets/Cinematic Effects/BloomBeta/Scripts/UltimateBloom.cs
Normal file
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c248faf0e10cd5a4cb2ca648c286bfa8
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,10 @@
|
|||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
/// <summary>
|
||||
/// Used to locate the root Ultimate Bloom Folder
|
||||
/// </summary>
|
||||
public class UltimateBloomPathLocator : ScriptableObject
|
||||
{
|
||||
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f196cd8bdabf54842954784952e8d059
|
||||
timeCreated: 1456303354
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/Common.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 88d2f1c604c7f6d4bb80a72b2f0219a7
|
||||
folderAsset: yes
|
||||
timeCreated: 1449044555
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
9
Assets/Cinematic Effects/Common/Editor.meta
Normal file
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e862ecde714eb154ca2d86a9a0809732
|
||||
folderAsset: yes
|
||||
timeCreated: 1453372226
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
62
Assets/Cinematic Effects/Common/Editor/EditorGUIHelper.cs
Normal file
|
@ -0,0 +1,62 @@
|
|||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
||||
namespace UnityStandardAssets.CinematicEffects
|
||||
{
|
||||
public static class EditorGUIHelper
|
||||
{
|
||||
private static Styles s_Styles;
|
||||
private class Styles
|
||||
{
|
||||
public GUIStyle header = "ShurikenModuleTitle";
|
||||
public GUIStyle headerCheckbox = "ShurikenCheckMark";
|
||||
|
||||
internal Styles()
|
||||
{
|
||||
header.font = (new GUIStyle("Label")).font;
|
||||
header.border = new RectOffset(15, 7, 4, 4);
|
||||
header.fixedHeight = 22;
|
||||
header.contentOffset = new Vector2(20f, -2f);
|
||||
}
|
||||
}
|
||||
|
||||
static EditorGUIHelper()
|
||||
{
|
||||
s_Styles = new Styles();
|
||||
}
|
||||
|
||||
public static bool Header(SerializedProperty group, SerializedProperty enabledField)
|
||||
{
|
||||
var display = group == null || group.isExpanded;
|
||||
var enabled = enabledField != null && enabledField.boolValue;
|
||||
var title = group == null ? "Unknown Group" : ObjectNames.NicifyVariableName(group.displayName);
|
||||
|
||||
Rect rect = GUILayoutUtility.GetRect(16f, 22f, s_Styles.header);
|
||||
GUI.Box(rect, title, s_Styles.header);
|
||||
|
||||
Rect toggleRect = new Rect(rect.x + 4f, rect.y + 4f, 13f, 13f);
|
||||
if (Event.current.type == EventType.Repaint)
|
||||
s_Styles.headerCheckbox.Draw(toggleRect, false, false, enabled, false);
|
||||
|
||||
Event e = Event.current;
|
||||
if (e.type == EventType.MouseDown)
|
||||
{
|
||||
if (toggleRect.Contains(e.mousePosition) && enabledField != null)
|
||||
{
|
||||
enabledField.boolValue = !enabledField.boolValue;
|
||||
e.Use();
|
||||
}
|
||||
else if (rect.Contains(e.mousePosition) && group != null)
|
||||
{
|
||||
display = !display;
|
||||
group.isExpanded = !group.isExpanded;
|
||||
e.Use();
|
||||
}
|
||||
}
|
||||
return display;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5b995f06a3ed14d449823cf7ab1c5a58
|
||||
timeCreated: 1454681943
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
25
Assets/Cinematic Effects/Common/Editor/FieldFinder.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
|
||||
namespace UnityStandardAssets.CinematicEffects
|
||||
{
|
||||
public static class FieldFinder<T>
|
||||
{
|
||||
public static FieldInfo GetField<TValue>(Expression<Func<T, TValue>> selector)
|
||||
{
|
||||
Expression body = selector;
|
||||
if (body is LambdaExpression)
|
||||
{
|
||||
body = ((LambdaExpression)body).Body;
|
||||
}
|
||||
switch (body.NodeType)
|
||||
{
|
||||
case ExpressionType.MemberAccess:
|
||||
return (FieldInfo)((MemberExpression)body).Member;
|
||||
default:
|
||||
throw new InvalidOperationException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
Assets/Cinematic Effects/Common/Editor/FieldFinder.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 39e54cb37a3a81a40b248f1cc25c4619
|
||||
timeCreated: 1454073160
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
Assets/Cinematic Effects/Common/Editor/MinDrawer.cs
Normal file
|
@ -0,0 +1,29 @@
|
|||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UnityStandardAssets.CinematicEffects
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(MinAttribute))]
|
||||
internal sealed class MinDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
MinAttribute attribute = (MinAttribute) base.attribute;
|
||||
|
||||
if (property.propertyType == SerializedPropertyType.Integer)
|
||||
{
|
||||
int v = EditorGUI.IntField(position, label, property.intValue);
|
||||
property.intValue = (int)Mathf.Max(v, attribute.min);
|
||||
}
|
||||
else if (property.propertyType == SerializedPropertyType.Float)
|
||||
{
|
||||
float v = EditorGUI.FloatField(position, label, property.floatValue);
|
||||
property.floatValue = Mathf.Max(v, attribute.min);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUI.LabelField(position, label.text, "Use Min with float or int.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
12
Assets/Cinematic Effects/Common/Editor/MinDrawer.cs.meta
Normal file
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9c615a85f13c6764fa4496d1d7f75f52
|
||||
timeCreated: 1453220014
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
63
Assets/Cinematic Effects/Common/ImageEffectHelper.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
|
||||
namespace UnityStandardAssets.CinematicEffects
|
||||
{
|
||||
public static class ImageEffectHelper
|
||||
{
|
||||
public static bool IsSupported(Shader s, bool needDepth, bool needHdr, MonoBehaviour effect)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// Don't check for shader compatibility while it's building as it would disable most effects
|
||||
// on build farms without good-enough gaming hardware.
|
||||
if (!BuildPipeline.isBuildingPlayer)
|
||||
{
|
||||
#endif
|
||||
if (s == null || !s.isSupported)
|
||||
{
|
||||
Debug.LogWarningFormat("Missing shader for image effect {0}", effect);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!SystemInfo.supportsImageEffects || !SystemInfo.supportsRenderTextures)
|
||||
{
|
||||
Debug.LogWarningFormat("Image effects aren't supported on this device ({0})", effect);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (needDepth && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth))
|
||||
{
|
||||
Debug.LogWarningFormat("Depth textures aren't supported on this device ({0})", effect);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (needHdr && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf))
|
||||
{
|
||||
Debug.LogWarningFormat("Floating point textures aren't supported on this device ({0})", effect);
|
||||
return false;
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Material CheckShaderAndCreateMaterial(Shader s)
|
||||
{
|
||||
if (s == null || !s.isSupported)
|
||||
return null;
|
||||
|
||||
var material = new Material(s);
|
||||
material.hideFlags = HideFlags.DontSave;
|
||||
return material;
|
||||
}
|
||||
|
||||
public static bool supportsDX11
|
||||
{
|
||||
get { return SystemInfo.graphicsShaderLevel >= 50 && SystemInfo.supportsComputeShaders; }
|
||||
}
|
||||
}
|
||||
}
|