Large diffs are not rendered by default.

@@ -1,64 +1,64 @@
public class Marker {

private int ID;
private float posX;
private float posY;
private float angle;
private int status;
private int ID;
private float posX;
private float posY;
private float angle;
private int status;

public Marker(int ID, float posX, float posY, float angle, int status){
this.ID = ID;
this.posX = posX;
this.posY = posY;
this.angle = angle;
this.status = status;
}
public Marker(int ID, float posX, float posY, float angle, int status){
this.ID = ID;
this.posX = posX;
this.posY = posY;
this.angle = angle;
this.status = status;
}

public int getID(){
return this.ID;
}
public int getID(){
return this.ID;
}

public float getPosX(){
return this.posX;
}
public float getPosX(){
return this.posX;
}

public float getPosY(){
return this.posY;
}
public float getPosY(){
return this.posY;
}

public float getAngle(){
return this.angle;
}
public float getAngle(){
return this.angle;
}

public int getStatus(){
return this.status;
}
public int getStatus(){
return this.status;
}

public void setID(int ID){
this.ID = ID;
}
public void setID(int ID){
this.ID = ID;
}

public void setPosX(float posX){
this.posX = posX;
}
public void setPosX(float posX){
this.posX = posX;
}

public void setPosY(float posY){
this.posY = posY;
}
public void setPosY(float posY){
this.posY = posY;
}

public void setAngle(float angle){
this.angle = angle;
}
public void setAngle(float angle){
this.angle = angle;
}

public void setStatus(int status){
this.status = status;
}
public void setStatus(int status){
this.status = status;
}

public string toStr(){
return "Marker " + this.ID + " data:\n" +
"\tPosition: (" + this.posX + "/" + this.posY + ")\n" +
"\tAngle: " + this.angle + "\n\tStatus: " + status;
}
public string toStr(){
return "Marker " + this.ID + " data:\n" +
"\tPosition: (" + this.posX + "/" + this.posY + ")\n" +
"\tAngle: " + this.angle + "\n\tStatus: " + status;
}

void Start () {}

@@ -0,0 +1,127 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Floor
m_Shader: {fileID: 4800000, guid: fa1a6c7535f84ef48912c2eaa5660918, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 5
m_CustomRenderQueue: -1
stringTagMap: {}
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
- first:
name: _BumpMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailAlbedoMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailMask
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _DetailNormalMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _EmissionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MainTex
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _MetallicGlossMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _OcclusionMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- first:
name: _ParallaxMap
second:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- first:
name: _BumpScale
second: 1
- first:
name: _Cutoff
second: 0.5
- first:
name: _DetailNormalMapScale
second: 1
- first:
name: _DstBlend
second: 0
- first:
name: _GlossMapScale
second: 1
- first:
name: _Glossiness
second: 0.5
- first:
name: _GlossyReflections
second: 1
- first:
name: _Metallic
second: 0
- first:
name: _Mode
second: 0
- first:
name: _OcclusionStrength
second: 1
- first:
name: _Parallax
second: 0.02
- first:
name: _SmoothnessTextureChannel
second: 0
- first:
name: _SpecularHighlights
second: 1
- first:
name: _SrcBlend
second: 1
- first:
name: _UVSec
second: 0
- first:
name: _ZWrite
second: 1
m_Colors:
- first:
name: _Color
second: {r: 1, g: 1, b: 1, a: 1}
- first:
name: _EmissionColor
second: {r: 0, g: 0, b: 0, a: 1}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

@@ -0,0 +1,111 @@
using UnityEngine;
using System.Collections;

[RequireComponent(typeof(RPCamera))]
public class RPCameraController : MonoBehaviour
{
public RPCamera rPCamera = null;

private Camera m_camera = null;
private float m_cameraInitialSize = 0.0f;

private Quaternion m_movingFlatDirection = Quaternion.identity;

private SmoothValue m_smoothMouseX = new SmoothValue(0.0f, 10f);
private SmoothValue m_smoothMouseY = new SmoothValue(0.0f, 10f);

private SmoothValue m_smoothPerspective = new SmoothValue(0.0f, 10f);
private SmoothValue m_smoothSizeScale = new SmoothValue(0.0f, 10f);

void Start() {
if (rPCamera == null) throw new UnityException ("Perspective Camera not set");
if (rPCamera.pivot == null) throw new UnityException ("Pivot not set");

m_camera = GetComponent<Camera>();
m_cameraInitialSize = m_camera.orthographicSize;

m_movingFlatDirection = Quaternion.Euler(0f, rPCamera.pivot.localRotation.eulerAngles.y, 0f);
}


void Update() {

float mx = Input.mousePosition.x / Screen.width * 2f - 1f; // -1..1
float my = Input.mousePosition.y / Screen.height * 2f - 1f;
m_smoothMouseX.target = mx;
m_smoothMouseY.target = my;
float mxs = m_smoothMouseX.GetValue();
float mys = m_smoothMouseY.GetValue();

// rotate
m_movingFlatDirection *= Quaternion.Euler(0f, Mathf.Pow(mxs, 3) * 2f, 0f);
Quaternion movingDirection = m_movingFlatDirection * Quaternion.Euler(0f, mxs * 60f, 0f);

Quaternion cameraRotation = Quaternion.Euler(-mys * 90f, movingDirection.eulerAngles.y, 0);

rPCamera.pivot.localRotation = cameraRotation;

// move
float mv = Input.GetAxis("Vertical");
float mh = Input.GetAxis("Horizontal");
Vector3 move = movingDirection * (Vector3.forward * mv + Vector3.right * mh) * m_camera.orthographicSize * 0.03f;

rPCamera.pivot.position += move;


// mouse wheel - zoom and FOV
float w = Input.GetAxis("Mouse ScrollWheel");
if (w != 0) {
if (Input.GetKey(KeyCode.LeftAlt)) { // change orthographic Size (FOV)
m_smoothSizeScale.target += w;
} else { // change perspective
m_smoothPerspective.target += w / m_camera.orthographicSize;
}
}

bool prepareProjection = false;
bool updateProjection = false;

if (m_smoothSizeScale.IsMoving())
{
float v = m_smoothSizeScale.GetValue();
float newSize = m_cameraInitialSize * Mathf.Exp(v * 2.0f);
m_smoothPerspective.target *= m_camera.orthographicSize / newSize;
m_camera.orthographicSize = newSize;
prepareProjection = true;
}
if (m_smoothPerspective.IsMoving())
{
//Debug.Log("smoothPerspective: " + m_smoothPerspective.value + " " + m_smoothPerspective.target);
float v = m_smoothPerspective.GetValue();
rPCamera.perspective = -v * 0.8f * 100f;
updateProjection = true;
}

// update camera projection
if (prepareProjection || updateProjection) {
rPCamera.UpdateProjection(prepareProjection);
}

}

}


public class SmoothValue {
public float target = 0.0f;
private float value = 0.0f;
private float velocity = 0.1f;
public SmoothValue(float value, float velocity) {
this.value = this.target = value;
this.velocity = velocity;
}
public bool IsMoving() {
return Mathf.Abs(target - value) > 0.000001f; // !!! make configurable
}
public float GetValue() {
value = Mathf.Lerp(value, target, velocity * Time.deltaTime);
return value;
}
}

@@ -0,0 +1,143 @@
using UnityEngine;
using System.Collections;

[RequireComponent(typeof(Camera))]
public class RPCamera : MonoBehaviour {

[Tooltip("objects located here stay the same size on perspective distortion")]
public Transform pivot = null;

[Tooltip("zero for parallel projection, negative for reverse perspective")]
[Range(-10.0f, 10.0f)]
public float perspective = 0.0f;

public Camera m_camera;

private float m_m00;
private float m_m11;

void Reset()
{
// m_camera = GetComponent<Camera>();
if (!m_camera.orthographic) {
m_camera.orthographic = true;
}

UpdateProjection(true);
}

void Start()
{
// m_camera = GetComponent<Camera>();
if (!m_camera.orthographic) {
throw new System.Exception("Camera projection should be orthographic");
}

UpdateProjection(true);
}

void OnValidate() // to not set projection on each Update
{
//m_camera = GetComponent<Camera>();

UpdateProjection(true);
}

public void UpdateProjection(bool prepare)
{
if (prepare) {
PrepareProjection();
}

float distance = GetCameraDistance();

Matrix4x4 matrix = GetProjectionMatrix(-perspective * 0.01f, -distance); // convert 'perspective' from percent

m_camera.projectionMatrix = matrix;
}

private float GetCameraDistance() {
if (pivot != null) {
return (pivot.position - this.transform.position).magnitude;
} else {
return this.transform.position.magnitude;
}
}

private void PrepareProjection()
{
m_m00 = 1f / m_camera.orthographicSize / m_camera.aspect;
m_m11 = 1f / m_camera.orthographicSize;
}

private Matrix4x4 GetProjectionMatrix(float p, float d)
{
// sx 0 0 0
// 0 sy 0 0
// 0 0 -0.001 p
// 0 0 p 1 - d*p
//
// X = sx * x / (1 + p*(z-d))
// Z = (p - 0.001 * z) / (1 + p*(z-d))
//
// Here is a discontinuity of projected Z coordinate near p==0
// http://www.wolframalpha.com/input/?i=plot+(p+-+0.001*z)%2F(1%2Bp*(z-30))+p%3D-0.5..0.5+z%3D-3..3
// So Z-buffer may glitch in that place.
// Workaround is to play with 'perspective' and 'distance' values.

var m = new Matrix4x4();
m.m00 = m_m00;
m.m11 = m_m11;
m.m22 = -0.000001f; m.m23 = p;
m.m32 = p; m.m33 = 1.0f - d * p;

return m;
}


void OnDrawGizmosSelected()
{
Matrix4x4 oldGizmosMatrix = Gizmos.matrix;

Gizmos.matrix = this.transform.localToWorldMatrix;
Gizmos.color = new Color(0.6f, 0.6f, 0.9f, 0.5f);

float d = GetCameraDistance();
float p = perspective * 0.01f;
float s = m_camera.orthographicSize;
float n = m_camera.nearClipPlane;
float f = m_camera.farClipPlane;
float a = m_camera.aspect;
float nx = s * (1.0f + p * (n-d));
float fx = s * (1.0f + p * (f-d));
var points = new [] {
new Vector3( nx, nx/a, n),
new Vector3(-nx, nx/a, n),
new Vector3(-nx,-nx/a, n),
new Vector3( nx,-nx/a, n),
new Vector3( fx, fx/a, f),
new Vector3(-fx, fx/a, f),
new Vector3(-fx,-fx/a, f),
new Vector3( fx,-fx/a, f),
new Vector3( s, s/a, d),
new Vector3( -s, s/a, d),
new Vector3( -s, -s/a, d),
new Vector3( s, -s/a, d),
};
var lines = new [] {
0,1, 1,2, 2,3, 3,0,
0,4, 1,5, 2,6, 3,7,
4,5, 5,6, 6,7, 7,4,
8,9, 9,10, 10,11, 11,8,
};
for (int i = 0; i < lines.Length; i += 2) {
Gizmos.DrawLine(points[lines[i]], points[lines[i+1]]);
}

Gizmos.matrix = oldGizmosMatrix;
}




}
@@ -0,0 +1,52 @@
Reverse Perspective Camera
-----------------------------------------------------------------

The script allows to make a continuous perspective distortion:
direct perspective - parallel projection - reverse perspective.
Kind of an ultimate Dolly zoom.

Related links:
https://en.wikipedia.org/wiki/Perspective_distortion_(photography)
https://en.wikipedia.org/wiki/Reverse_perspective
https://en.wikipedia.org/wiki/Dolly_zoom

-----------------------------------------------------------------

Asset contents:
ReversePerspective
RPCamera.cs - The main component which extends a standard orthographic camera.
Demo
RPCameraController.cs - Extends RPCamera adding a controlling to the camera.
Demo.unity - Demo scene with a pregenerated city model.

-----------------------------------------------------------------

Properties used for geometry of RPCamera component:
Size - property of Camera component, works as FOV;
Perspective - perspective coefficient:
positive - direct perspective
zero - parallel projection
negative - reverse perspective
Pivot - objects located here stay the same size on perspective distortion. (world's origin by default)

-----------------------------------------------------------------

RPCameraController controlling:
w/a/s/d - moving
mouse move - looking
mouse wheel - perspective
alt + mouse wheel - FOV

-----------------------------------------------------------------

Demo video:
Using the component in the Editor
https://www.youtube.com/watch?v=LrLJMP0Pi9E
Camera controller demo
https://www.youtube.com/watch?v=yvxw8pkG_Ac
"Japanese Otaku City" asset by ZENRIN (https://www.assetstore.unity3d.com/en/#!/content/20359) used.

-----------------------------------------------------------------

Viktor Massalogin
massalogin@gmail.com
@@ -0,0 +1,75 @@
using System;
using UnityEditor;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor(typeof (Antialiasing))]
public class AntialiasingEditor : Editor
{
private SerializedObject serObj;

private SerializedProperty mode;

private SerializedProperty showGeneratedNormals;
private SerializedProperty offsetScale;
private SerializedProperty blurRadius;
private SerializedProperty dlaaSharp;

private SerializedProperty edgeThresholdMin;
private SerializedProperty edgeThreshold;
private SerializedProperty edgeSharpness;


private void OnEnable()
{
serObj = new SerializedObject(target);

mode = serObj.FindProperty("mode");

showGeneratedNormals = serObj.FindProperty("showGeneratedNormals");
offsetScale = serObj.FindProperty("offsetScale");
blurRadius = serObj.FindProperty("blurRadius");
dlaaSharp = serObj.FindProperty("dlaaSharp");

edgeThresholdMin = serObj.FindProperty("edgeThresholdMin");
edgeThreshold = serObj.FindProperty("edgeThreshold");
edgeSharpness = serObj.FindProperty("edgeSharpness");
}


public override void OnInspectorGUI()
{
serObj.Update();

GUILayout.Label("Luminance based fullscreen antialiasing", EditorStyles.miniBoldLabel);

EditorGUILayout.PropertyField(mode, new GUIContent("Technique"));

Material mat = (target as Antialiasing).CurrentAAMaterial();
if (null == mat && (target as Antialiasing).enabled)
{
EditorGUILayout.HelpBox("This AA technique is currently not supported. Choose a different technique or disable the effect and use MSAA instead.", MessageType.Warning);
}

if (mode.enumValueIndex == (int) AAMode.NFAA)
{
EditorGUILayout.PropertyField(offsetScale, new GUIContent("Edge Detect Ofs"));
EditorGUILayout.PropertyField(blurRadius, new GUIContent("Blur Radius"));
EditorGUILayout.PropertyField(showGeneratedNormals, new GUIContent("Show Normals"));
}
else if (mode.enumValueIndex == (int) AAMode.DLAA)
{
EditorGUILayout.PropertyField(dlaaSharp, new GUIContent("Sharp"));
}
else if (mode.enumValueIndex == (int) AAMode.FXAA3Console)
{
EditorGUILayout.PropertyField(edgeThresholdMin, new GUIContent("Edge Min Threshhold"));
EditorGUILayout.PropertyField(edgeThreshold, new GUIContent("Edge Threshhold"));
EditorGUILayout.PropertyField(edgeSharpness, new GUIContent("Edge Sharpness"));
}

serObj.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,157 @@
using System;
using UnityEditor;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor (typeof(BloomAndFlares))]
class BloomAndFlaresEditor : Editor
{
SerializedProperty tweakMode;
SerializedProperty screenBlendMode;

SerializedObject serObj;

SerializedProperty hdr;
SerializedProperty sepBlurSpread;
SerializedProperty useSrcAlphaAsMask;

SerializedProperty bloomIntensity;
SerializedProperty bloomthreshold;
SerializedProperty bloomBlurIterations;

SerializedProperty lensflares;

SerializedProperty hollywoodFlareBlurIterations;

SerializedProperty lensflareMode;
SerializedProperty hollyStretchWidth;
SerializedProperty lensflareIntensity;
SerializedProperty lensflarethreshold;
SerializedProperty flareColorA;
SerializedProperty flareColorB;
SerializedProperty flareColorC;
SerializedProperty flareColorD;

SerializedProperty lensFlareVignetteMask;

void OnEnable () {
serObj = new SerializedObject (target);

screenBlendMode = serObj.FindProperty("screenBlendMode");
hdr = serObj.FindProperty("hdr");

sepBlurSpread = serObj.FindProperty("sepBlurSpread");
useSrcAlphaAsMask = serObj.FindProperty("useSrcAlphaAsMask");

bloomIntensity = serObj.FindProperty("bloomIntensity");
bloomthreshold = serObj.FindProperty("bloomThreshold");
bloomBlurIterations = serObj.FindProperty("bloomBlurIterations");

lensflares = serObj.FindProperty("lensflares");

lensflareMode = serObj.FindProperty("lensflareMode");
hollywoodFlareBlurIterations = serObj.FindProperty("hollywoodFlareBlurIterations");
hollyStretchWidth = serObj.FindProperty("hollyStretchWidth");
lensflareIntensity = serObj.FindProperty("lensflareIntensity");
lensflarethreshold = serObj.FindProperty("lensflareThreshold");
flareColorA = serObj.FindProperty("flareColorA");
flareColorB = serObj.FindProperty("flareColorB");
flareColorC = serObj.FindProperty("flareColorC");
flareColorD = serObj.FindProperty("flareColorD");
lensFlareVignetteMask = serObj.FindProperty("lensFlareVignetteMask");

tweakMode = serObj.FindProperty("tweakMode");
}


public override void OnInspectorGUI () {
serObj.Update();

GUILayout.Label("HDR " + (hdr.enumValueIndex == 0 ? "auto detected, " : (hdr.enumValueIndex == 1 ? "forced on, " : "disabled, ")) + (useSrcAlphaAsMask.floatValue < 0.1f ? " ignoring alpha channel glow information" : " using alpha channel glow information"), EditorStyles.miniBoldLabel);

EditorGUILayout.PropertyField (tweakMode, new GUIContent("Tweak mode"));
EditorGUILayout.PropertyField (screenBlendMode, new GUIContent("Blend mode"));
EditorGUILayout.PropertyField (hdr, new GUIContent("HDR"));

// display info text when screen blend mode cannot be used
Camera cam = (target as BloomAndFlares).GetComponent<Camera>();
if (cam != null) {
if (screenBlendMode.enumValueIndex==0 && ((cam.hdr && hdr.enumValueIndex==0) || (hdr.enumValueIndex==1))) {
EditorGUILayout.HelpBox("Screen blend is not supported in HDR. Using 'Add' instead.", MessageType.Info);
}
}

if (1 == tweakMode.intValue)
EditorGUILayout.PropertyField (lensflares, new GUIContent("Cast lens flares"));

EditorGUILayout.Separator ();

EditorGUILayout.PropertyField (bloomIntensity, new GUIContent("Intensity"));
bloomthreshold.floatValue = EditorGUILayout.Slider ("threshold", bloomthreshold.floatValue, -0.05f, 4.0f);
bloomBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", bloomBlurIterations.intValue, 1, 4);
sepBlurSpread.floatValue = EditorGUILayout.Slider ("Blur spread", sepBlurSpread.floatValue, 0.1f, 10.0f);

if (1 == tweakMode.intValue)
useSrcAlphaAsMask.floatValue = EditorGUILayout.Slider (new GUIContent("Use alpha mask", "Make alpha channel define glowiness"), useSrcAlphaAsMask.floatValue, 0.0f, 1.0f);
else
useSrcAlphaAsMask.floatValue = 0.0f;

if (1 == tweakMode.intValue) {
EditorGUILayout.Separator ();

if (lensflares.boolValue) {

// further lens flare tweakings
if (0 != tweakMode.intValue)
EditorGUILayout.PropertyField (lensflareMode, new GUIContent("Lens flare mode"));
else
lensflareMode.enumValueIndex = 0;

EditorGUILayout.PropertyField(lensFlareVignetteMask, new GUIContent("Lens flare mask", "This mask is needed to prevent lens flare artifacts"));

EditorGUILayout.PropertyField (lensflareIntensity, new GUIContent("Local intensity"));
lensflarethreshold.floatValue = EditorGUILayout.Slider ("Local threshold", lensflarethreshold.floatValue, 0.0f, 1.0f);

if (lensflareMode.intValue == 0) {
// ghosting
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorA, new GUIContent("1st Color"));
EditorGUILayout.PropertyField (flareColorB, new GUIContent("2nd Color"));
EditorGUILayout.EndHorizontal ();

EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorC, new GUIContent("3rd Color"));
EditorGUILayout.PropertyField (flareColorD, new GUIContent("4th Color"));
EditorGUILayout.EndHorizontal ();
}
else if (lensflareMode.intValue == 1) {
// hollywood
EditorGUILayout.PropertyField (hollyStretchWidth, new GUIContent("Stretch width"));
hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", hollywoodFlareBlurIterations.intValue, 1, 4);

EditorGUILayout.PropertyField (flareColorA, new GUIContent("Tint Color"));
}
else if (lensflareMode.intValue == 2) {
// both
EditorGUILayout.PropertyField (hollyStretchWidth, new GUIContent("Stretch width"));
hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", hollywoodFlareBlurIterations.intValue, 1, 4);

EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorA, new GUIContent("1st Color"));
EditorGUILayout.PropertyField (flareColorB, new GUIContent("2nd Color"));
EditorGUILayout.EndHorizontal ();

EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorC, new GUIContent("3rd Color"));
EditorGUILayout.PropertyField (flareColorD, new GUIContent("4th Color"));
EditorGUILayout.EndHorizontal ();
}
}
} else
lensflares.boolValue = false; // disable lens flares in simple tweak mode

serObj.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,162 @@
using System;
using UnityEditor;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor (typeof(Bloom))]
class BloomEditor : Editor
{
SerializedProperty tweakMode;
SerializedProperty screenBlendMode;

SerializedObject serObj;

SerializedProperty hdr;
SerializedProperty quality;
SerializedProperty sepBlurSpread;

SerializedProperty bloomIntensity;
SerializedProperty bloomThresholdColor;
SerializedProperty bloomThreshold;
SerializedProperty bloomBlurIterations;

SerializedProperty hollywoodFlareBlurIterations;

SerializedProperty lensflareMode;
SerializedProperty hollyStretchWidth;
SerializedProperty lensflareIntensity;
SerializedProperty flareRotation;
SerializedProperty lensFlareSaturation;
SerializedProperty lensflareThreshold;
SerializedProperty flareColorA;
SerializedProperty flareColorB;
SerializedProperty flareColorC;
SerializedProperty flareColorD;

SerializedProperty lensFlareVignetteMask;

void OnEnable () {
serObj = new SerializedObject (target);

screenBlendMode = serObj.FindProperty("screenBlendMode");
hdr = serObj.FindProperty("hdr");
quality = serObj.FindProperty("quality");

sepBlurSpread = serObj.FindProperty("sepBlurSpread");

bloomIntensity = serObj.FindProperty("bloomIntensity");
bloomThreshold = serObj.FindProperty("bloomThreshold");
bloomThresholdColor = serObj.FindProperty("bloomThresholdColor");
bloomBlurIterations = serObj.FindProperty("bloomBlurIterations");

lensflareMode = serObj.FindProperty("lensflareMode");
hollywoodFlareBlurIterations = serObj.FindProperty("hollywoodFlareBlurIterations");
hollyStretchWidth = serObj.FindProperty("hollyStretchWidth");
lensflareIntensity = serObj.FindProperty("lensflareIntensity");
lensflareThreshold = serObj.FindProperty("lensflareThreshold");
lensFlareSaturation = serObj.FindProperty("lensFlareSaturation");
flareRotation = serObj.FindProperty("flareRotation");
flareColorA = serObj.FindProperty("flareColorA");
flareColorB = serObj.FindProperty("flareColorB");
flareColorC = serObj.FindProperty("flareColorC");
flareColorD = serObj.FindProperty("flareColorD");
lensFlareVignetteMask = serObj.FindProperty("lensFlareVignetteMask");

tweakMode = serObj.FindProperty("tweakMode");
}


public override void OnInspectorGUI () {
serObj.Update();

EditorGUILayout.LabelField("Glow and Lens Flares for bright screen pixels", EditorStyles.miniLabel);

EditorGUILayout.PropertyField (quality, new GUIContent("Quality", "High quality preserves high frequencies with bigger blurs and uses a better blending and down-/upsampling"));

EditorGUILayout.Separator ();

EditorGUILayout.PropertyField (tweakMode, new GUIContent("Mode"));
EditorGUILayout.PropertyField (screenBlendMode, new GUIContent("Blend"));
EditorGUILayout.PropertyField (hdr, new GUIContent("HDR"));

EditorGUILayout.Separator ();

// display info text when screen blend mode cannot be used
Camera cam = (target as Bloom).GetComponent<Camera>();
if (cam != null) {
if (screenBlendMode.enumValueIndex==0 && ((cam.hdr && hdr.enumValueIndex==0) || (hdr.enumValueIndex==1))) {
EditorGUILayout.HelpBox("Screen blend is not supported in HDR. Using 'Add' instead.", MessageType.Info);
}
}

EditorGUILayout.PropertyField (bloomIntensity, new GUIContent("Intensity"));
bloomThreshold.floatValue = EditorGUILayout.Slider ("Threshold", bloomThreshold.floatValue, -0.05f, 4.0f);
if (1 == tweakMode.intValue) {
EditorGUILayout.PropertyField(bloomThresholdColor, new GUIContent(" RGB Threshold"));
}
EditorGUILayout.Separator ();

bloomBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur Iterations", bloomBlurIterations.intValue, 1, 4);
sepBlurSpread.floatValue = EditorGUILayout.Slider (" Sample Distance", sepBlurSpread.floatValue, 0.1f, 10.0f);
EditorGUILayout.Separator ();

if (1 == tweakMode.intValue) {
// further lens flare tweakings
if (0 != tweakMode.intValue)
EditorGUILayout.PropertyField (lensflareMode, new GUIContent("Lens Flares"));
else
lensflareMode.enumValueIndex = 0;

EditorGUILayout.PropertyField (lensflareIntensity, new GUIContent(" Local Intensity", "0 disables lens flares entirely (optimization)"));
lensflareThreshold.floatValue = EditorGUILayout.Slider ("Threshold", lensflareThreshold.floatValue, 0.0f, 4.0f);

if (Mathf.Abs(lensflareIntensity.floatValue) > Mathf.Epsilon) {
if (lensflareMode.intValue == 0) {
// ghosting
EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorA, new GUIContent(" 1st Color"));
EditorGUILayout.PropertyField (flareColorB, new GUIContent(" 2nd Color"));
EditorGUILayout.EndHorizontal ();

EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorC, new GUIContent(" 3rd Color"));
EditorGUILayout.PropertyField (flareColorD, new GUIContent(" 4th Color"));
EditorGUILayout.EndHorizontal ();
}
else if (lensflareMode.intValue == 1) {
// hollywood
EditorGUILayout.PropertyField (hollyStretchWidth, new GUIContent(" Stretch width"));
EditorGUILayout.PropertyField (flareRotation, new GUIContent( " Rotation"));
hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider (" Blur Iterations", hollywoodFlareBlurIterations.intValue, 1, 4);

EditorGUILayout.PropertyField (lensFlareSaturation, new GUIContent(" Saturation"));
EditorGUILayout.PropertyField (flareColorA, new GUIContent(" Tint Color"));
}
else if (lensflareMode.intValue == 2) {
// both
EditorGUILayout.PropertyField (hollyStretchWidth, new GUIContent(" Stretch width"));
hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider (" Blur Iterations", hollywoodFlareBlurIterations.intValue, 1, 4);

EditorGUILayout.PropertyField (lensFlareSaturation, new GUIContent(" Saturation"));

EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorA, new GUIContent(" 1st Color"));
EditorGUILayout.PropertyField (flareColorB, new GUIContent(" 2nd Color"));
EditorGUILayout.EndHorizontal ();

EditorGUILayout.BeginHorizontal ();
EditorGUILayout.PropertyField (flareColorC, new GUIContent(" 3rd Color"));
EditorGUILayout.PropertyField (flareColorD, new GUIContent(" 4th Color"));
EditorGUILayout.EndHorizontal ();
}

EditorGUILayout.PropertyField(lensFlareVignetteMask, new GUIContent(" Mask", "This mask is needed to prevent lens flare artifacts"));

}
}

serObj.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,99 @@
using System;
using UnityEditor;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor (typeof(CameraMotionBlur))]
class CameraMotionBlurEditor : Editor
{
SerializedObject serObj;

SerializedProperty filterType;
SerializedProperty preview;
SerializedProperty previewScale;
SerializedProperty movementScale;
SerializedProperty jitter;
SerializedProperty rotationScale;
SerializedProperty maxVelocity;
SerializedProperty minVelocity;
SerializedProperty velocityScale;
SerializedProperty velocityDownsample;
SerializedProperty noiseTexture;
SerializedProperty showVelocity;
SerializedProperty showVelocityScale;
SerializedProperty excludeLayers;

void OnEnable () {
serObj = new SerializedObject (target);

filterType = serObj.FindProperty ("filterType");

preview = serObj.FindProperty ("preview");
previewScale = serObj.FindProperty ("previewScale");

movementScale = serObj.FindProperty ("movementScale");
rotationScale = serObj.FindProperty ("rotationScale");

maxVelocity = serObj.FindProperty ("maxVelocity");
minVelocity = serObj.FindProperty ("minVelocity");

jitter = serObj.FindProperty ("jitter");

excludeLayers = serObj.FindProperty ("excludeLayers");

velocityScale = serObj.FindProperty ("velocityScale");
velocityDownsample = serObj.FindProperty ("velocityDownsample");

noiseTexture = serObj.FindProperty ("noiseTexture");
}


public override void OnInspectorGUI () {
serObj.Update ();

EditorGUILayout.LabelField("Simulates camera based motion blur", EditorStyles.miniLabel);

EditorGUILayout.PropertyField (filterType, new GUIContent("Technique"));
if (filterType.enumValueIndex == 3 && !(target as CameraMotionBlur).Dx11Support()) {
EditorGUILayout.HelpBox("DX11 mode not supported (need shader model 5)", MessageType.Info);
}
EditorGUILayout.PropertyField (velocityScale, new GUIContent(" Velocity Scale"));
if (filterType.enumValueIndex >= 2) {
EditorGUILayout.LabelField(" Tile size used during reconstruction filter:", EditorStyles.miniLabel);
EditorGUILayout.Slider(maxVelocity, 2.0f, 10.0f, new GUIContent(" Velocity Max"));
}
else
EditorGUILayout.Slider (maxVelocity, 2.0f, 10.0f, new GUIContent(" Velocity Max"));
EditorGUILayout.Slider(minVelocity, 0.0f, 10.0f, new GUIContent(" Velocity Min"));

EditorGUILayout.Separator ();

EditorGUILayout.LabelField("Technique Specific");

if (filterType.enumValueIndex == 0) {
// portal style motion blur
EditorGUILayout.PropertyField (rotationScale, new GUIContent(" Camera Rotation"));
EditorGUILayout.PropertyField (movementScale, new GUIContent(" Camera Movement"));
}
else {
// "plausible" blur or cheap, local blur
EditorGUILayout.PropertyField (excludeLayers, new GUIContent(" Exclude Layers"));
EditorGUILayout.PropertyField (velocityDownsample, new GUIContent(" Velocity Downsample"));
velocityDownsample.intValue = velocityDownsample.intValue < 1 ? 1 : velocityDownsample.intValue;
if (filterType.enumValueIndex >= 2) { // only display jitter for reconstruction
EditorGUILayout.PropertyField (noiseTexture, new GUIContent(" Sample Jitter"));
EditorGUILayout.Slider (jitter, 0.0f, 10.0f, new GUIContent(" Jitter Strength"));
}
}

EditorGUILayout.Separator ();

EditorGUILayout.PropertyField (preview, new GUIContent("Preview"));
if (preview.boolValue)
EditorGUILayout.PropertyField (previewScale, new GUIContent(""));

serObj.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,124 @@
using System;
using UnityEditor;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor (typeof(ColorCorrectionCurves))]
class ColorCorrectionCurvesEditor : Editor {
SerializedObject serObj;

SerializedProperty mode;

SerializedProperty redChannel;
SerializedProperty greenChannel;
SerializedProperty blueChannel;

SerializedProperty useDepthCorrection;

SerializedProperty depthRedChannel;
SerializedProperty depthGreenChannel;
SerializedProperty depthBlueChannel;

SerializedProperty zCurveChannel;

SerializedProperty saturation;

SerializedProperty selectiveCc;
SerializedProperty selectiveFromColor;
SerializedProperty selectiveToColor;

private bool applyCurveChanges = false;

void OnEnable () {
serObj = new SerializedObject (target);

mode = serObj.FindProperty ("mode");

saturation = serObj.FindProperty ("saturation");

redChannel = serObj.FindProperty ("redChannel");
greenChannel = serObj.FindProperty ("greenChannel");
blueChannel = serObj.FindProperty ("blueChannel");

useDepthCorrection = serObj.FindProperty ("useDepthCorrection");

zCurveChannel = serObj.FindProperty ("zCurve");

depthRedChannel = serObj.FindProperty ("depthRedChannel");
depthGreenChannel = serObj.FindProperty ("depthGreenChannel");
depthBlueChannel = serObj.FindProperty ("depthBlueChannel");

serObj.ApplyModifiedProperties ();

selectiveCc = serObj.FindProperty ("selectiveCc");
selectiveFromColor = serObj.FindProperty ("selectiveFromColor");
selectiveToColor = serObj.FindProperty ("selectiveToColor");
}

void CurveGui ( string name, SerializedProperty animationCurve, Color color) {
// @NOTE: EditorGUILayout.CurveField is buggy and flickers, using PropertyField for now
//animationCurve.animationCurveValue = EditorGUILayout.CurveField (GUIContent (name), animationCurve.animationCurveValue, color, Rect (0.0f,0.0f,1.0f,1.0f));
EditorGUILayout.PropertyField (animationCurve, new GUIContent (name));
if (GUI.changed)
applyCurveChanges = true;
}

void BeginCurves () {
applyCurveChanges = false;
}

void ApplyCurves () {
if (applyCurveChanges) {
serObj.ApplyModifiedProperties ();
(serObj.targetObject as ColorCorrectionCurves).gameObject.SendMessage ("UpdateTextures");
}
}


public override void OnInspectorGUI () {
serObj.Update ();

GUILayout.Label ("Use curves to tweak RGB channel colors", EditorStyles.miniBoldLabel);

saturation.floatValue = EditorGUILayout.Slider( "Saturation", saturation.floatValue, 0.0f, 5.0f);

EditorGUILayout.PropertyField (mode, new GUIContent ("Mode"));
EditorGUILayout.Separator ();

BeginCurves ();

CurveGui (" Red", redChannel, Color.red);
CurveGui (" Green", greenChannel, Color.green);
CurveGui (" Blue", blueChannel, Color.blue);

EditorGUILayout.Separator ();

if (mode.intValue > 0)
useDepthCorrection.boolValue = true;
else
useDepthCorrection.boolValue = false;

if (useDepthCorrection.boolValue) {
CurveGui (" Red (depth)", depthRedChannel, Color.red);
CurveGui (" Green (depth)", depthGreenChannel, Color.green);
CurveGui (" Blue (depth)", depthBlueChannel, Color.blue);
EditorGUILayout.Separator ();
CurveGui (" Blend Curve", zCurveChannel, Color.grey);
}

EditorGUILayout.Separator ();
EditorGUILayout.PropertyField (selectiveCc, new GUIContent ("Selective"));
if (selectiveCc.boolValue) {
EditorGUILayout.PropertyField (selectiveFromColor, new GUIContent (" Key"));
EditorGUILayout.PropertyField (selectiveToColor, new GUIContent (" Target"));
}


ApplyCurves ();

if (!applyCurveChanges)
serObj.ApplyModifiedProperties ();
}
}
}
@@ -0,0 +1,90 @@
using System;
using UnityEditor;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor (typeof(ColorCorrectionLookup))]
class ColorCorrectionLookupEditor : Editor
{
SerializedObject serObj;

void OnEnable () {
serObj = new SerializedObject (target);
}

private Texture2D tempClutTex2D;


public override void OnInspectorGUI () {
serObj.Update ();

EditorGUILayout.LabelField("Converts textures into color lookup volumes (for grading)", EditorStyles.miniLabel);

//EditorGUILayout.LabelField("Change Lookup Texture (LUT):");
//EditorGUILayout.BeginHorizontal ();
//Rect r = GUILayoutUtility.GetAspectRect(1.0ff);

Rect r; Texture2D t;

//EditorGUILayout.Space();
tempClutTex2D = EditorGUILayout.ObjectField (" Based on", tempClutTex2D, typeof(Texture2D), false) as Texture2D;
if (tempClutTex2D == null) {
t = AssetDatabase.LoadMainAssetAtPath(((ColorCorrectionLookup)target).basedOnTempTex) as Texture2D;
if (t) tempClutTex2D = t;
}

Texture2D tex = tempClutTex2D;

if (tex && (target as ColorCorrectionLookup).basedOnTempTex != AssetDatabase.GetAssetPath(tex))
{
EditorGUILayout.Separator();
if (!(target as ColorCorrectionLookup).ValidDimensions(tex))
{
EditorGUILayout.HelpBox ("Invalid texture dimensions!\nPick another texture or adjust dimension to e.g. 256x16.", MessageType.Warning);
}
else if (GUILayout.Button ("Convert and Apply"))
{
string path = AssetDatabase.GetAssetPath (tex);
TextureImporter textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
bool doImport = textureImporter.isReadable == false;
if (textureImporter.mipmapEnabled == true) {
doImport = true;
}
if (textureImporter.textureCompression != TextureImporterCompression.Uncompressed) {
doImport = true;
}

if (doImport)
{
textureImporter.isReadable = true;
textureImporter.mipmapEnabled = false;
textureImporter.textureCompression = TextureImporterCompression.Uncompressed;
AssetDatabase.ImportAsset (path, ImportAssetOptions.ForceUpdate);
//tex = AssetDatabase.LoadMainAssetAtPath(path);
}

(target as ColorCorrectionLookup).Convert(tex, path);
}
}

if ((target as ColorCorrectionLookup).basedOnTempTex != "")
{
EditorGUILayout.HelpBox("Using " + (target as ColorCorrectionLookup).basedOnTempTex, MessageType.Info);
t = AssetDatabase.LoadMainAssetAtPath(((ColorCorrectionLookup)target).basedOnTempTex) as Texture2D;
if (t) {
r = GUILayoutUtility.GetLastRect();
r = GUILayoutUtility.GetRect(r.width, 20);
r.x += r.width * 0.05f/2.0f;
r.width *= 0.95f;
GUI.DrawTexture (r, t);
GUILayoutUtility.GetRect(r.width, 4);
}
}

//EditorGUILayout.EndHorizontal ();

serObj.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,60 @@
using System;
using UnityEditor;
using UnityEditor.AnimatedValues;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor(typeof(CreaseShading))]
class CreaseShadingEditor : Editor {
SerializedObject serObj;

SerializedProperty m_intensity;
SerializedProperty m_softness;
SerializedProperty m_spread;

AnimBool m_showSoftnessWarning = new AnimBool();
AnimBool m_showSpreadWarning = new AnimBool();

private bool softnessWarningValue { get { return m_softness.intValue > 4; } }
private bool spreadWarningValue { get { return m_spread.floatValue > 4; } }

void OnEnable () {
serObj = new SerializedObject (target);

m_intensity = serObj.FindProperty("intensity");
m_softness = serObj.FindProperty("softness");
m_spread = serObj.FindProperty("spread");

m_showSoftnessWarning.valueChanged.AddListener(Repaint);
m_showSpreadWarning.valueChanged.AddListener(Repaint);

m_showSoftnessWarning.value = softnessWarningValue;
m_showSpreadWarning.value = spreadWarningValue;
}

public override void OnInspectorGUI () {
serObj.Update ();

EditorGUILayout.Slider(m_intensity, -5.0f, 5.0f, new GUIContent("Intensity"));

EditorGUILayout.IntSlider(m_softness, 0, 15, new GUIContent("Softness"));
m_showSoftnessWarning.target = softnessWarningValue;
if (EditorGUILayout.BeginFadeGroup(m_showSoftnessWarning.faded))
{
EditorGUILayout.HelpBox("High Softness value might reduce performance.", MessageType.Warning, false);
}
EditorGUILayout.EndFadeGroup();

EditorGUILayout.Slider(m_spread, 0.0f, 50.0f, new GUIContent("Spread"));
m_showSpreadWarning.target = spreadWarningValue;
if (EditorGUILayout.BeginFadeGroup(m_showSpreadWarning.faded))
{
EditorGUILayout.HelpBox("High Spread value might introduce visual artifacts.", MessageType.Warning, false);
}
EditorGUILayout.EndFadeGroup();

serObj.ApplyModifiedProperties ();
}
}
}
@@ -0,0 +1,149 @@
using System;
using UnityEditor;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor (typeof(DepthOfFieldDeprecated))]
class DepthOfFieldDeprecatedEditor : Editor
{
SerializedObject serObj;

SerializedProperty simpleTweakMode;

SerializedProperty focalPoint;
SerializedProperty smoothness;

SerializedProperty focalSize;

SerializedProperty focalZDistance;
SerializedProperty focalStartCurve;
SerializedProperty focalEndCurve;

SerializedProperty visualizeCoc;

SerializedProperty resolution;
SerializedProperty quality;

SerializedProperty objectFocus;

SerializedProperty bokeh;
SerializedProperty bokehScale;
SerializedProperty bokehIntensity;
SerializedProperty bokehThresholdLuminance;
SerializedProperty bokehThresholdContrast;
SerializedProperty bokehDownsample;
SerializedProperty bokehTexture;
SerializedProperty bokehDestination;

SerializedProperty bluriness;
SerializedProperty maxBlurSpread;
SerializedProperty foregroundBlurExtrude;

void OnEnable () {
serObj = new SerializedObject (target);

simpleTweakMode = serObj.FindProperty ("simpleTweakMode");

// simple tweak mode
focalPoint = serObj.FindProperty ("focalPoint");
smoothness = serObj.FindProperty ("smoothness");

// complex tweak mode
focalZDistance = serObj.FindProperty ("focalZDistance");
focalStartCurve = serObj.FindProperty ("focalZStartCurve");
focalEndCurve = serObj.FindProperty ("focalZEndCurve");
focalSize = serObj.FindProperty ("focalSize");

visualizeCoc = serObj.FindProperty ("visualize");

objectFocus = serObj.FindProperty ("objectFocus");

resolution = serObj.FindProperty ("resolution");
quality = serObj.FindProperty ("quality");
bokehThresholdContrast = serObj.FindProperty ("bokehThresholdContrast");
bokehThresholdLuminance = serObj.FindProperty ("bokehThresholdLuminance");

bokeh = serObj.FindProperty ("bokeh");
bokehScale = serObj.FindProperty ("bokehScale");
bokehIntensity = serObj.FindProperty ("bokehIntensity");
bokehDownsample = serObj.FindProperty ("bokehDownsample");
bokehTexture = serObj.FindProperty ("bokehTexture");
bokehDestination = serObj.FindProperty ("bokehDestination");

bluriness = serObj.FindProperty ("bluriness");
maxBlurSpread = serObj.FindProperty ("maxBlurSpread");
foregroundBlurExtrude = serObj.FindProperty ("foregroundBlurExtrude");
}


public override void OnInspectorGUI () {
serObj.Update ();

GameObject go = (target as DepthOfFieldDeprecated).gameObject;

if (!go)
return;

if (!go.GetComponent<Camera>())
return;

if (simpleTweakMode.boolValue)
GUILayout.Label ("Current: "+go.GetComponent<Camera>().name+", near "+go.GetComponent<Camera>().nearClipPlane+", far: "+go.GetComponent<Camera>().farClipPlane+", focal: "+focalPoint.floatValue, EditorStyles.miniBoldLabel);
else
GUILayout.Label ("Current: "+go.GetComponent<Camera>().name+", near "+go.GetComponent<Camera>().nearClipPlane+", far: "+go.GetComponent<Camera>().farClipPlane+", focal: "+focalZDistance.floatValue, EditorStyles.miniBoldLabel);

EditorGUILayout.PropertyField (resolution, new GUIContent("Resolution"));
EditorGUILayout.PropertyField (quality, new GUIContent("Quality"));

EditorGUILayout.PropertyField (simpleTweakMode, new GUIContent("Simple tweak"));
EditorGUILayout.PropertyField (visualizeCoc, new GUIContent("Visualize focus"));
EditorGUILayout.PropertyField (bokeh, new GUIContent("Enable bokeh"));


EditorGUILayout.Separator ();

GUILayout.Label ("Focal Settings", EditorStyles.boldLabel);

if (simpleTweakMode.boolValue) {
focalPoint.floatValue = EditorGUILayout.Slider ("Focal distance", focalPoint.floatValue, go.GetComponent<Camera>().nearClipPlane, go.GetComponent<Camera>().farClipPlane);
EditorGUILayout.PropertyField (objectFocus, new GUIContent("Transform"));
EditorGUILayout.PropertyField (smoothness, new GUIContent("Smoothness"));
focalSize.floatValue = EditorGUILayout.Slider ("Focal size", focalSize.floatValue, 0.0f, (go.GetComponent<Camera>().farClipPlane - go.GetComponent<Camera>().nearClipPlane));
}
else {
focalZDistance.floatValue = EditorGUILayout.Slider ("Distance", focalZDistance.floatValue, go.GetComponent<Camera>().nearClipPlane, go.GetComponent<Camera>().farClipPlane);
EditorGUILayout.PropertyField (objectFocus, new GUIContent("Transform"));
focalSize.floatValue = EditorGUILayout.Slider ("Size", focalSize.floatValue, 0.0f, (go.GetComponent<Camera>().farClipPlane - go.GetComponent<Camera>().nearClipPlane));
focalStartCurve.floatValue = EditorGUILayout.Slider ("Start curve", focalStartCurve.floatValue, 0.05f, 20.0f);
focalEndCurve.floatValue = EditorGUILayout.Slider ("End curve", focalEndCurve.floatValue, 0.05f, 20.0f);
}

EditorGUILayout.Separator ();

GUILayout.Label ("Blur (Fore- and Background)", EditorStyles.boldLabel);
EditorGUILayout.PropertyField (bluriness, new GUIContent("Blurriness"));
EditorGUILayout.PropertyField (maxBlurSpread, new GUIContent("Blur spread"));

if (quality.enumValueIndex > 0) {
EditorGUILayout.PropertyField (foregroundBlurExtrude, new GUIContent("Foreground size"));
}

EditorGUILayout.Separator ();

if (bokeh.boolValue) {
EditorGUILayout.Separator ();
GUILayout.Label ("Bokeh Settings", EditorStyles.boldLabel);
EditorGUILayout.PropertyField (bokehDestination, new GUIContent("Destination"));
bokehIntensity.floatValue = EditorGUILayout.Slider ("Intensity", bokehIntensity.floatValue, 0.0f, 1.0f);
bokehThresholdLuminance.floatValue = EditorGUILayout.Slider ("Min luminance", bokehThresholdLuminance.floatValue, 0.0f, 0.99f);
bokehThresholdContrast.floatValue = EditorGUILayout.Slider ("Min contrast", bokehThresholdContrast.floatValue, 0.0f, 0.25f);
bokehDownsample.intValue = EditorGUILayout.IntSlider ("Downsample", bokehDownsample.intValue, 1, 3);
bokehScale.floatValue = EditorGUILayout.Slider ("Size scale", bokehScale.floatValue, 0.0f, 20.0f);
EditorGUILayout.PropertyField (bokehTexture , new GUIContent("Texture mask"));
}

serObj.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,161 @@
using System;
using UnityEditor;
using UnityEditor.AnimatedValues;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor(typeof(DepthOfField))]
class DepthOfFieldEditor : Editor
{
SerializedObject serObj;

SerializedProperty visualizeFocus;
SerializedProperty focalLength;
SerializedProperty focalSize;
SerializedProperty aperture;
SerializedProperty focalTransform;
SerializedProperty maxBlurSize;
SerializedProperty highResolution;

SerializedProperty blurType;
SerializedProperty blurSampleCount;

SerializedProperty nearBlur;
SerializedProperty foregroundOverlap;

SerializedProperty dx11BokehThreshold;
SerializedProperty dx11SpawnHeuristic;
SerializedProperty dx11BokehTexture;
SerializedProperty dx11BokehScale;
SerializedProperty dx11BokehIntensity;

AnimBool showFocalDistance = new AnimBool();
AnimBool showDiscBlurSettings = new AnimBool();
AnimBool showDX11BlurSettings = new AnimBool();
AnimBool showNearBlurOverlapSize = new AnimBool();

bool useFocalDistance { get { return focalTransform.objectReferenceValue == null; } }
bool useDiscBlur { get { return blurType.enumValueIndex < 1; } }
bool useDX11Blur { get { return blurType.enumValueIndex > 0; } }
bool useNearBlur { get { return nearBlur.boolValue; } }


void OnEnable()
{
serObj = new SerializedObject(target);

visualizeFocus = serObj.FindProperty("visualizeFocus");

focalLength = serObj.FindProperty("focalLength");
focalSize = serObj.FindProperty("focalSize");
aperture = serObj.FindProperty("aperture");
focalTransform = serObj.FindProperty("focalTransform");
maxBlurSize = serObj.FindProperty("maxBlurSize");
highResolution = serObj.FindProperty("highResolution");

blurType = serObj.FindProperty("blurType");
blurSampleCount = serObj.FindProperty("blurSampleCount");

nearBlur = serObj.FindProperty("nearBlur");
foregroundOverlap = serObj.FindProperty("foregroundOverlap");

dx11BokehThreshold = serObj.FindProperty("dx11BokehThreshold");
dx11SpawnHeuristic = serObj.FindProperty("dx11SpawnHeuristic");
dx11BokehTexture = serObj.FindProperty("dx11BokehTexture");
dx11BokehScale = serObj.FindProperty("dx11BokehScale");
dx11BokehIntensity = serObj.FindProperty("dx11BokehIntensity");

InitializedAnimBools();
}

void InitializedAnimBools()
{
showFocalDistance.valueChanged.AddListener(Repaint);
showFocalDistance.value = useFocalDistance;

showDiscBlurSettings.valueChanged.AddListener(Repaint);
showDiscBlurSettings.value = useDiscBlur;

showDX11BlurSettings.valueChanged.AddListener(Repaint);
showDX11BlurSettings.value = useDX11Blur;

showNearBlurOverlapSize.valueChanged.AddListener(Repaint);
showNearBlurOverlapSize.value = useNearBlur;
}


void UpdateAnimBoolTargets()
{
showFocalDistance.target = useFocalDistance;
showDiscBlurSettings.target = useDiscBlur;
showDX11BlurSettings.target = useDX11Blur;
showNearBlurOverlapSize.target = useNearBlur;
}


public override void OnInspectorGUI()
{
serObj.Update();

UpdateAnimBoolTargets();

EditorGUILayout.LabelField("Simulates camera lens defocus", EditorStyles.miniLabel);

GUILayout.Label("Focal Settings");
EditorGUILayout.PropertyField(visualizeFocus, new GUIContent(" Visualize"));
EditorGUILayout.PropertyField(focalTransform, new GUIContent(" Focus on Transform"));

if (EditorGUILayout.BeginFadeGroup(showFocalDistance.faded))
{
EditorGUILayout.PropertyField(focalLength, new GUIContent(" Focal Distance"));
}
EditorGUILayout.EndFadeGroup();

EditorGUILayout.Slider(focalSize, 0.0f, 2.0f, new GUIContent(" Focal Size"));
EditorGUILayout.Slider(aperture, 0.0f, 1.0f, new GUIContent(" Aperture"));

EditorGUILayout.Separator();

EditorGUILayout.PropertyField(blurType, new GUIContent("Defocus Type"));

if (!(target as DepthOfField).Dx11Support() && blurType.enumValueIndex > 0)
{
EditorGUILayout.HelpBox("DX11 mode not supported (need shader model 5)", MessageType.Info);
}

if (EditorGUILayout.BeginFadeGroup(showDiscBlurSettings.faded))
{
EditorGUILayout.PropertyField(blurSampleCount, new GUIContent(" Sample Count"));
}
EditorGUILayout.EndFadeGroup();

EditorGUILayout.Slider(maxBlurSize, 0.1f, 2.0f, new GUIContent(" Max Blur Distance"));
EditorGUILayout.PropertyField(highResolution, new GUIContent(" High Resolution"));

EditorGUILayout.Separator();

EditorGUILayout.PropertyField(nearBlur, new GUIContent("Near Blur"));
if (EditorGUILayout.BeginFadeGroup(showNearBlurOverlapSize.faded))
{
EditorGUILayout.Slider(foregroundOverlap, 0.1f, 2.0f, new GUIContent(" Overlap Size"));
}
EditorGUILayout.EndFadeGroup();

EditorGUILayout.Separator();

if (EditorGUILayout.BeginFadeGroup(showDX11BlurSettings.faded))
{
GUILayout.Label("DX11 Bokeh Settings");
EditorGUILayout.PropertyField(dx11BokehTexture, new GUIContent(" Bokeh Texture"));
EditorGUILayout.Slider(dx11BokehScale, 0.0f, 50.0f, new GUIContent(" Bokeh Scale"));
EditorGUILayout.Slider(dx11BokehIntensity, 0.0f, 100.0f, new GUIContent(" Bokeh Intensity"));
EditorGUILayout.Slider(dx11BokehThreshold, 0.0f, 1.0f, new GUIContent(" Min Luminance"));
EditorGUILayout.Slider(dx11SpawnHeuristic, 0.01f, 1.0f, new GUIContent(" Spawn Heuristic"));
}
EditorGUILayout.EndFadeGroup();

serObj.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,72 @@
using System;
using UnityEditor;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor (typeof(EdgeDetection))]
class EdgeDetectionEditor : Editor
{
SerializedObject serObj;

SerializedProperty mode;
SerializedProperty sensitivityDepth;
SerializedProperty sensitivityNormals;

SerializedProperty lumThreshold;

SerializedProperty edgesOnly;
SerializedProperty edgesOnlyBgColor;

SerializedProperty edgeExp;
SerializedProperty sampleDist;


void OnEnable () {
serObj = new SerializedObject (target);

mode = serObj.FindProperty("mode");

sensitivityDepth = serObj.FindProperty("sensitivityDepth");
sensitivityNormals = serObj.FindProperty("sensitivityNormals");

lumThreshold = serObj.FindProperty("lumThreshold");

edgesOnly = serObj.FindProperty("edgesOnly");
edgesOnlyBgColor = serObj.FindProperty("edgesOnlyBgColor");

edgeExp = serObj.FindProperty("edgeExp");
sampleDist = serObj.FindProperty("sampleDist");
}


public override void OnInspectorGUI () {
serObj.Update ();

GUILayout.Label("Detects spatial differences and converts into black outlines", EditorStyles.miniBoldLabel);
EditorGUILayout.PropertyField (mode, new GUIContent("Mode"));

if (mode.intValue < 2) {
EditorGUILayout.PropertyField (sensitivityDepth, new GUIContent(" Depth Sensitivity"));
EditorGUILayout.PropertyField (sensitivityNormals, new GUIContent(" Normals Sensitivity"));
}
else if (mode.intValue < 4) {
EditorGUILayout.PropertyField (edgeExp, new GUIContent(" Edge Exponent"));
}
else {
// lum based mode
EditorGUILayout.PropertyField (lumThreshold, new GUIContent(" Luminance Threshold"));
}

EditorGUILayout.PropertyField (sampleDist, new GUIContent(" Sample Distance"));

EditorGUILayout.Separator ();

GUILayout.Label ("Background Options");
edgesOnly.floatValue = EditorGUILayout.Slider (" Edges only", edgesOnly.floatValue, 0.0f, 1.0f);
EditorGUILayout.PropertyField (edgesOnlyBgColor, new GUIContent (" Color"));

serObj.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,111 @@
using System;
using UnityEditor;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor (typeof( NoiseAndGrain))]
class NoiseAndGrainEditor : Editor
{
SerializedObject serObj;

SerializedProperty intensityMultiplier;
SerializedProperty generalIntensity;
SerializedProperty blackIntensity;
SerializedProperty whiteIntensity;
SerializedProperty midGrey;

SerializedProperty dx11Grain;
SerializedProperty softness;
SerializedProperty monochrome;

SerializedProperty intensities;
SerializedProperty tiling;
SerializedProperty monochromeTiling;

SerializedProperty noiseTexture;
SerializedProperty filterMode;

void OnEnable () {
serObj = new SerializedObject (target);

intensityMultiplier = serObj.FindProperty("intensityMultiplier");
generalIntensity = serObj.FindProperty("generalIntensity");
blackIntensity = serObj.FindProperty("blackIntensity");
whiteIntensity = serObj.FindProperty("whiteIntensity");
midGrey = serObj.FindProperty("midGrey");

dx11Grain = serObj.FindProperty("dx11Grain");
softness = serObj.FindProperty("softness");
monochrome = serObj.FindProperty("monochrome");

intensities = serObj.FindProperty("intensities");
tiling = serObj.FindProperty("tiling");
monochromeTiling = serObj.FindProperty("monochromeTiling");

noiseTexture = serObj.FindProperty("noiseTexture");
filterMode = serObj.FindProperty("filterMode");
}


public override void OnInspectorGUI () {
serObj.Update();

EditorGUILayout.LabelField("Overlays animated noise patterns", EditorStyles.miniLabel);

EditorGUILayout.PropertyField(dx11Grain, new GUIContent("DirectX 11 Grain"));

if (dx11Grain.boolValue && !(target as NoiseAndGrain).Dx11Support()) {
EditorGUILayout.HelpBox("DX11 mode not supported (need DX11 GPU and enable DX11 in PlayerSettings)", MessageType.Info);
}

EditorGUILayout.PropertyField(monochrome, new GUIContent("Monochrome"));

EditorGUILayout.Separator();

EditorGUILayout.Slider(intensityMultiplier, 0.0f, 10.0f, new GUIContent("Intensity Multiplier"));
EditorGUILayout.Slider(generalIntensity, 0.0f, 1.0f, new GUIContent(" General"));
EditorGUILayout.Slider(blackIntensity, 0.0f, 1.0f, new GUIContent(" Black Boost"));
EditorGUILayout.Slider(whiteIntensity, 0.0f, 1.0f, new GUIContent(" White Boost"));
midGrey.floatValue = EditorGUILayout.Slider( new GUIContent(" Mid Grey (for Boost)"), midGrey.floatValue, 0.0f, 1.0f);
if (monochrome.boolValue == false) {
Color c = new Color(intensities.vector3Value.x,intensities.vector3Value.y,intensities.vector3Value.z,1.0f);
c = EditorGUILayout.ColorField(new GUIContent(" Color Weights"), c);
intensities.vector3Value = new Vector3(c.r, c.g, c.b);
}

if (!dx11Grain.boolValue) {
EditorGUILayout.Separator();

EditorGUILayout.LabelField("Noise Shape");
EditorGUILayout.PropertyField(noiseTexture, new GUIContent(" Texture"));
EditorGUILayout.PropertyField(filterMode, new GUIContent(" Filter"));
}
else {
EditorGUILayout.Separator();
EditorGUILayout.LabelField("Noise Shape");
}

softness.floatValue = EditorGUILayout.Slider( new GUIContent(" Softness"),softness.floatValue, 0.0f, 0.99f);

if (!dx11Grain.boolValue) {
EditorGUILayout.Separator();
EditorGUILayout.LabelField("Advanced");

if (monochrome.boolValue == false)
{
Vector3 temp = tiling.vector3Value;
temp.x = EditorGUILayout.FloatField(new GUIContent(" Tiling (Red)"), tiling.vector3Value.x);
temp.y = EditorGUILayout.FloatField(new GUIContent(" Tiling (Green)"), tiling.vector3Value.y);
temp.z = EditorGUILayout.FloatField(new GUIContent(" Tiling (Blue)"), tiling.vector3Value.z);
tiling.vector3Value = temp;
}
else {
EditorGUILayout.PropertyField(monochromeTiling, new GUIContent(" Tiling"));
}
}

serObj.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,105 @@
using System;
using UnityEditor;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor (typeof(SunShafts))]
class SunShaftsEditor : Editor
{
SerializedObject serObj;

SerializedProperty sunTransform;
SerializedProperty radialBlurIterations;
SerializedProperty sunColor;
SerializedProperty sunThreshold;
SerializedProperty sunShaftBlurRadius;
SerializedProperty sunShaftIntensity;
SerializedProperty useDepthTexture;
SerializedProperty resolution;
SerializedProperty screenBlendMode;
SerializedProperty maxRadius;

void OnEnable () {
serObj = new SerializedObject (target);

screenBlendMode = serObj.FindProperty("screenBlendMode");

sunTransform = serObj.FindProperty("sunTransform");
sunColor = serObj.FindProperty("sunColor");
sunThreshold = serObj.FindProperty("sunThreshold");

sunShaftBlurRadius = serObj.FindProperty("sunShaftBlurRadius");
radialBlurIterations = serObj.FindProperty("radialBlurIterations");

sunShaftIntensity = serObj.FindProperty("sunShaftIntensity");

resolution = serObj.FindProperty("resolution");

maxRadius = serObj.FindProperty("maxRadius");

useDepthTexture = serObj.FindProperty("useDepthTexture");
}


public override void OnInspectorGUI () {
serObj.Update ();

EditorGUILayout.BeginHorizontal();

EditorGUILayout.PropertyField (useDepthTexture, new GUIContent ("Rely on Z Buffer?"));
if ((target as SunShafts).GetComponent<Camera>())
GUILayout.Label("Current camera mode: "+ (target as SunShafts).GetComponent<Camera>().depthTextureMode, EditorStyles.miniBoldLabel);

EditorGUILayout.EndHorizontal();

// depth buffer need
/*
bool newVal = useDepthTexture.boolValue;
if (newVal != oldVal) {
if (newVal)
(target as SunShafts).camera.depthTextureMode |= DepthTextureMode.Depth;
else
(target as SunShafts).camera.depthTextureMode &= ~DepthTextureMode.Depth;
}
*/

EditorGUILayout.PropertyField (resolution, new GUIContent("Resolution"));
EditorGUILayout.PropertyField (screenBlendMode, new GUIContent("Blend mode"));

EditorGUILayout.Separator ();

EditorGUILayout.BeginHorizontal();

EditorGUILayout.PropertyField (sunTransform, new GUIContent("Shafts caster", "Chose a transform that acts as a root point for the produced sun shafts"));
if ((target as SunShafts).sunTransform && (target as SunShafts).GetComponent<Camera>()) {
if (GUILayout.Button("Center on " + (target as SunShafts).GetComponent<Camera>().name)) {
if (EditorUtility.DisplayDialog ("Move sun shafts source?", "The SunShafts caster named "+ (target as SunShafts).sunTransform.name +"\n will be centered along "+(target as SunShafts).GetComponent<Camera>().name+". Are you sure? ", "Please do", "Don't")) {
Ray ray = (target as SunShafts).GetComponent<Camera>().ViewportPointToRay(new Vector3(0.5f,0.5f,0));
(target as SunShafts).sunTransform.position = ray.origin + ray.direction * 500.0f;
(target as SunShafts).sunTransform.LookAt ((target as SunShafts).transform);
}
}
}

EditorGUILayout.EndHorizontal();

EditorGUILayout.Separator ();

EditorGUILayout.PropertyField (sunThreshold, new GUIContent ("Threshold color"));
EditorGUILayout.PropertyField (sunColor, new GUIContent ("Shafts color"));
maxRadius.floatValue = 1.0f - EditorGUILayout.Slider ("Distance falloff", 1.0f - maxRadius.floatValue, 0.1f, 1.0f);

EditorGUILayout.Separator ();

sunShaftBlurRadius.floatValue = EditorGUILayout.Slider ("Blur size", sunShaftBlurRadius.floatValue, 1.0f, 10.0f);
radialBlurIterations.intValue = EditorGUILayout.IntSlider ("Blur iterations", radialBlurIterations.intValue, 1, 3);

EditorGUILayout.Separator ();

EditorGUILayout.PropertyField (sunShaftIntensity, new GUIContent("Intensity"));

serObj.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,81 @@
using System;
using UnityEditor;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor (typeof(Tonemapping))]
class TonemappingEditor : Editor
{
SerializedObject serObj;

SerializedProperty type;

// CURVE specific parameter
SerializedProperty remapCurve;

SerializedProperty exposureAdjustment;

// REINHARD specific parameter
SerializedProperty middleGrey;
SerializedProperty white;
SerializedProperty adaptionSpeed;
SerializedProperty adaptiveTextureSize;

void OnEnable () {
serObj = new SerializedObject (target);

type = serObj.FindProperty ("type");
remapCurve = serObj.FindProperty ("remapCurve");
exposureAdjustment = serObj.FindProperty ("exposureAdjustment");
middleGrey = serObj.FindProperty ("middleGrey");
white = serObj.FindProperty ("white");
adaptionSpeed = serObj.FindProperty ("adaptionSpeed");
adaptiveTextureSize = serObj.FindProperty("adaptiveTextureSize");
}


public override void OnInspectorGUI () {
serObj.Update ();

GUILayout.Label("Mapping HDR to LDR ranges since 1982", EditorStyles.miniLabel);

Camera cam = (target as Tonemapping).GetComponent<Camera>();
if (cam != null) {
if (!cam.hdr) {
EditorGUILayout.HelpBox("The camera is not HDR enabled. This will likely break the Tonemapper.", MessageType.Warning);
}
else if (!(target as Tonemapping).validRenderTextureFormat) {
EditorGUILayout.HelpBox("The input to Tonemapper is not in HDR. Make sure that all effects prior to this are executed in HDR.", MessageType.Warning);
}
}

EditorGUILayout.PropertyField (type, new GUIContent ("Technique"));

if (type.enumValueIndex == (int) Tonemapping.TonemapperType.UserCurve) {
EditorGUILayout.PropertyField (remapCurve, new GUIContent ("Remap curve", "Specify the mapping of luminances yourself"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.SimpleReinhard) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.Hable) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.Photographic) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.OptimizedHejiDawson) {
EditorGUILayout.PropertyField (exposureAdjustment, new GUIContent ("Exposure", "Exposure adjustment"));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.AdaptiveReinhard) {
EditorGUILayout.PropertyField (middleGrey, new GUIContent ("Middle grey", "Middle grey defines the average luminance thus brightening or darkening the entire image."));
EditorGUILayout.PropertyField (white, new GUIContent ("White", "Smallest luminance value that will be mapped to white"));
EditorGUILayout.PropertyField (adaptionSpeed, new GUIContent ("Adaption Speed", "Speed modifier for the automatic adaption"));
EditorGUILayout.PropertyField (adaptiveTextureSize, new GUIContent ("Texture size", "Defines the amount of downsamples needed."));
} else if (type.enumValueIndex == (int) Tonemapping.TonemapperType.AdaptiveReinhardAutoWhite) {
EditorGUILayout.PropertyField (middleGrey, new GUIContent ("Middle grey", "Middle grey defines the average luminance thus brightening or darkening the entire image."));
EditorGUILayout.PropertyField (adaptionSpeed, new GUIContent ("Adaption Speed", "Speed modifier for the automatic adaption"));
EditorGUILayout.PropertyField (adaptiveTextureSize, new GUIContent ("Texture size", "Defines the amount of downsamples needed."));
}

GUILayout.Label("All following effects will use LDR color buffers", EditorStyles.miniBoldLabel);

serObj.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,62 @@
using System;
using UnityEditor;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
[CustomEditor (typeof(VignetteAndChromaticAberration))]
class VignetteAndChromaticAberrationEditor : Editor
{
private SerializedObject m_SerObj;
private SerializedProperty m_Mode;
private SerializedProperty m_Intensity; // intensity == 0 disables pre pass (optimization)
private SerializedProperty m_ChromaticAberration;
private SerializedProperty m_AxialAberration;
private SerializedProperty m_Blur; // blur == 0 disables blur pass (optimization)
private SerializedProperty m_BlurSpread;
private SerializedProperty m_BlurDistance;
private SerializedProperty m_LuminanceDependency;


void OnEnable ()
{
m_SerObj = new SerializedObject (target);
m_Mode = m_SerObj.FindProperty ("mode");
m_Intensity = m_SerObj.FindProperty ("intensity");
m_ChromaticAberration = m_SerObj.FindProperty ("chromaticAberration");
m_AxialAberration = m_SerObj.FindProperty ("axialAberration");
m_Blur = m_SerObj.FindProperty ("blur");
m_BlurSpread = m_SerObj.FindProperty ("blurSpread");
m_LuminanceDependency = m_SerObj.FindProperty ("luminanceDependency");
m_BlurDistance = m_SerObj.FindProperty ("blurDistance");
}


public override void OnInspectorGUI ()
{
m_SerObj.Update ();

EditorGUILayout.LabelField("Simulates the common lens artifacts 'Vignette' and 'Aberration'", EditorStyles.miniLabel);

EditorGUILayout.Slider(m_Intensity, 0.0f, 1.0f, new GUIContent("Vignetting"));
EditorGUILayout.Slider(m_Blur, 0.0f, 1.0f, new GUIContent(" Blurred Corners"));
if (m_Blur.floatValue>0.0f)
EditorGUILayout.Slider(m_BlurSpread, 0.0f, 1.0f, new GUIContent(" Blur Distance"));

EditorGUILayout.Separator ();

EditorGUILayout.PropertyField (m_Mode, new GUIContent("Aberration"));
if (m_Mode.intValue>0)
{
EditorGUILayout.Slider(m_ChromaticAberration, 0.0f, 5.0f, new GUIContent(" Tangential Aberration"));
EditorGUILayout.Slider(m_AxialAberration, 0.0f, 5.0f, new GUIContent(" Axial Aberration"));
m_LuminanceDependency.floatValue = EditorGUILayout.Slider(" Contrast Dependency", m_LuminanceDependency.floatValue, 0.001f, 1.0f);
m_BlurDistance.floatValue = EditorGUILayout.Slider(" Blur Distance", m_BlurDistance.floatValue, 0.001f, 5.0f);
}
else
EditorGUILayout.PropertyField (m_ChromaticAberration, new GUIContent(" Chromatic Aberration"));

m_SerObj.ApplyModifiedProperties();
}
}
}
@@ -0,0 +1,50 @@
%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: GlassRefractive
m_Shader: {fileID: 4800000, guid: 963484209d11fd7f110076aa44295342, type: 3}
m_ShaderKeywords: []
m_CustomRenderQueue: -1
m_SavedProperties:
serializedVersion: 2
m_TexEnvs:
data:
first:
name: _MainTex
second:
m_Texture: {fileID: 2800000, guid: 19555d7d9d114c7f1100f5ab44295342, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
data:
first:
name: _BumpMap
second:
m_Texture: {fileID: 2800000, guid: 4b8d081e9d114c7f1100f5ab44295342, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
data:
first:
name: _Shininess
second: 1
data:
first:
name: _BumpAmt
second: 128
m_Colors:
data:
first:
name: _Color
second: {r: .423392087, g: .423392087, b: .423392087, a: 0}
data:
first:
name: _SpecColor
second: {r: .981927693, g: .963855445, b: 1, a: 1}
--- !u!1002 &2100001
EditorExtensionImpl:
serializedVersion: 6
@@ -0,0 +1,115 @@
// Per pixel bumped refraction.
// Uses a normal map to distort the image behind, and
// an additional texture to tint the color.

Shader "FX/Glass/Stained BumpDistort" {
Properties {
_BumpAmt ("Distortion", range (0,128)) = 10
_MainTex ("Tint Color (RGB)", 2D) = "white" {}
_BumpMap ("Normalmap", 2D) = "bump" {}
}

Category {

// We must be transparent, so other objects are drawn before this one.
Tags { "Queue"="Transparent" "RenderType"="Opaque" }


SubShader {

// This pass grabs the screen behind the object into a texture.
// We can access the result in the next pass as _GrabTexture
GrabPass {
Name "BASE"
Tags { "LightMode" = "Always" }
}

// Main pass: Take the texture grabbed above and use the bumpmap to perturb it
// on to the screen
Pass {
Name "BASE"
Tags { "LightMode" = "Always" }

CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#include "UnityCG.cginc"

struct appdata_t {
float4 vertex : POSITION;
float2 texcoord: TEXCOORD0;
};

struct v2f {
float4 vertex : SV_POSITION;
float4 uvgrab : TEXCOORD0;
float2 uvbump : TEXCOORD1;
float2 uvmain : TEXCOORD2;
UNITY_FOG_COORDS(3)
};

float _BumpAmt;
float4 _BumpMap_ST;
float4 _MainTex_ST;

v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
#if UNITY_UV_STARTS_AT_TOP
float scale = -1.0;
#else
float scale = 1.0;
#endif
o.uvgrab.xy = (float2(o.vertex.x, o.vertex.y*scale) + o.vertex.w) * 0.5;
o.uvgrab.zw = o.vertex.zw;
o.uvbump = TRANSFORM_TEX( v.texcoord, _BumpMap );
o.uvmain = TRANSFORM_TEX( v.texcoord, _MainTex );
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}

sampler2D _GrabTexture;
float4 _GrabTexture_TexelSize;
sampler2D _BumpMap;
sampler2D _MainTex;

half4 frag (v2f i) : SV_Target
{
#if UNITY_SINGLE_PASS_STEREO
i.uvgrab.xy = TransformStereoScreenSpaceTex(i.uvgrab.xy, i.uvgrab.w);
#endif

// calculate perturbed coordinates
half2 bump = UnpackNormal(tex2D( _BumpMap, i.uvbump )).rg; // we could optimize this by just reading the x & y without reconstructing the Z
float2 offset = bump * _BumpAmt * _GrabTexture_TexelSize.xy;
#ifdef UNITY_Z_0_FAR_FROM_CLIPSPACE //to handle recent standard asset package on older version of unity (before 5.5)
i.uvgrab.xy = offset * UNITY_Z_0_FAR_FROM_CLIPSPACE(i.uvgrab.z) + i.uvgrab.xy;
#else
i.uvgrab.xy = offset * i.uvgrab.z + i.uvgrab.xy;
#endif

half4 col = tex2Dproj( _GrabTexture, UNITY_PROJ_COORD(i.uvgrab));
half4 tint = tex2D(_MainTex, i.uvmain);
col *= tint;
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
}
}

// ------------------------------------------------------------------
// Fallback for older cards and Unity non-Pro

SubShader {
Blend DstColor Zero
Pass {
Name "BASE"
SetTexture [_MainTex] { combine texture }
}
}
}

}
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,177 @@
using System;
using UnityEngine;

namespace UnityStandardAssets.ImageEffects
{
public enum AAMode
{
FXAA2 = 0,
FXAA3Console = 1,
FXAA1PresetA = 2,
FXAA1PresetB = 3,
NFAA = 4,
SSAA = 5,
DLAA = 6,
}

[ExecuteInEditMode]
[RequireComponent(typeof (Camera))]
[AddComponentMenu("Image Effects/Other/Antialiasing")]
public class Antialiasing : PostEffectsBase
{
public AAMode mode = AAMode.FXAA3Console;

public bool showGeneratedNormals = false;
public float offsetScale = 0.2f;
public float blurRadius = 18.0f;

public float edgeThresholdMin = 0.05f;
public float edgeThreshold = 0.2f;
public float edgeSharpness = 4.0f;

public bool dlaaSharp = false;

public Shader ssaaShader;
private Material ssaa;
public Shader dlaaShader;
private Material dlaa;
public Shader nfaaShader;
private Material nfaa;
public Shader shaderFXAAPreset2;
private Material materialFXAAPreset2;
public Shader shaderFXAAPreset3;
private Material materialFXAAPreset3;
public Shader shaderFXAAII;
private Material materialFXAAII;
public Shader shaderFXAAIII;
private Material materialFXAAIII;


public Material CurrentAAMaterial()
{
Material returnValue = null;

switch (mode)
{
case AAMode.FXAA3Console:
returnValue = materialFXAAIII;
break;
case AAMode.FXAA2:
returnValue = materialFXAAII;
break;
case AAMode.FXAA1PresetA:
returnValue = materialFXAAPreset2;
break;
case AAMode.FXAA1PresetB:
returnValue = materialFXAAPreset3;
break;
case AAMode.NFAA:
returnValue = nfaa;
break;
case AAMode.SSAA:
returnValue = ssaa;
break;
case AAMode.DLAA:
returnValue = dlaa;
break;
default:
returnValue = null;
break;
}

return returnValue;
}


public override bool CheckResources()
{
CheckSupport(false);

materialFXAAPreset2 = CreateMaterial(shaderFXAAPreset2, materialFXAAPreset2);
materialFXAAPreset3 = CreateMaterial(shaderFXAAPreset3, materialFXAAPreset3);
materialFXAAII = CreateMaterial(shaderFXAAII, materialFXAAII);
materialFXAAIII = CreateMaterial(shaderFXAAIII, materialFXAAIII);
nfaa = CreateMaterial(nfaaShader, nfaa);
ssaa = CreateMaterial(ssaaShader, ssaa);
dlaa = CreateMaterial(dlaaShader, dlaa);

if (!ssaaShader.isSupported)
{
NotSupported();
ReportAutoDisable();
}

return isSupported;
}


public void OnRenderImage(RenderTexture source, RenderTexture destination)
{
if (CheckResources() == false)
{
Graphics.Blit(source, destination);
return;
}

// ----------------------------------------------------------------
// FXAA antialiasing modes

if (mode == AAMode.FXAA3Console && (materialFXAAIII != null))
{
materialFXAAIII.SetFloat("_EdgeThresholdMin", edgeThresholdMin);
materialFXAAIII.SetFloat("_EdgeThreshold", edgeThreshold);
materialFXAAIII.SetFloat("_EdgeSharpness", edgeSharpness);

Graphics.Blit(source, destination, materialFXAAIII);
}
else if (mode == AAMode.FXAA1PresetB && (materialFXAAPreset3 != null))
{
Graphics.Blit(source, destination, materialFXAAPreset3);
}
else if (mode == AAMode.FXAA1PresetA && materialFXAAPreset2 != null)
{
source.anisoLevel = 4;
Graphics.Blit(source, destination, materialFXAAPreset2);
source.anisoLevel = 0;
}
else if (mode == AAMode.FXAA2 && materialFXAAII != null)
{
Graphics.Blit(source, destination, materialFXAAII);
}
else if (mode == AAMode.SSAA && ssaa != null)
{
// ----------------------------------------------------------------
// SSAA antialiasing
Graphics.Blit(source, destination, ssaa);
}
else if (mode == AAMode.DLAA && dlaa != null)
{
// ----------------------------------------------------------------
// DLAA antialiasing

source.anisoLevel = 0;
RenderTexture interim = RenderTexture.GetTemporary(source.width, source.height);
Graphics.Blit(source, interim, dlaa, 0);
Graphics.Blit(interim, destination, dlaa, dlaaSharp ? 2 : 1);
RenderTexture.ReleaseTemporary(interim);
}
else if (mode == AAMode.NFAA && nfaa != null)
{
// ----------------------------------------------------------------
// nfaa antialiasing

source.anisoLevel = 0;

nfaa.SetFloat("_OffsetScale", offsetScale);
nfaa.SetFloat("_BlurRadius", blurRadius);

Graphics.Blit(source, destination, nfaa, showGeneratedNormals ? 1 : 0);
}
else
{
// none of the AA is supported, fallback to a simple blit
Graphics.Blit(source, destination);
}
}
}
}