Full Code of Chman/SMAA-Unity for AI

master 8ece2a148027 cached
35 files
101.3 KB
29.9k tokens
22 symbols
1 requests
Download .txt
Repository: Chman/SMAA-Unity
Branch: master
Commit: 8ece2a148027
Files: 35
Total size: 101.3 KB

Directory structure:
gitextract__ohsqf1u/

├── .gitignore
├── LICENSE.txt
├── README.md
└── SMAA/
    ├── Resources/
    │   ├── AreaTex.tga
    │   ├── AreaTex.tga.meta
    │   ├── SearchTex.tga
    │   └── SearchTex.tga.meta
    ├── Resources.meta
    ├── Scripts/
    │   ├── DebugPass.cs
    │   ├── DebugPass.cs.meta
    │   ├── EdgeDetectionMethod.cs
    │   ├── EdgeDetectionMethod.cs.meta
    │   ├── Editor/
    │   │   ├── MinDrawer.cs
    │   │   ├── MinDrawer.cs.meta
    │   │   ├── SMAAEditor.cs
    │   │   └── SMAAEditor.cs.meta
    │   ├── Editor.meta
    │   ├── HDRMode.cs
    │   ├── HDRMode.cs.meta
    │   ├── MinAttribute.cs
    │   ├── MinAttribute.cs.meta
    │   ├── PredicationPreset.cs
    │   ├── PredicationPreset.cs.meta
    │   ├── Preset.cs
    │   ├── Preset.cs.meta
    │   ├── QualityPreset.cs
    │   ├── QualityPreset.cs.meta
    │   ├── SMAA.cs
    │   └── SMAA.cs.meta
    ├── Scripts.meta
    ├── Shaders/
    │   ├── SMAA.cginc
    │   ├── SMAA.cginc.meta
    │   ├── SMAA.shader
    │   └── SMAA.shader.meta
    └── Shaders.meta

================================================
FILE CONTENTS
================================================

================================================
FILE: .gitignore
================================================
# =============== #
# Unity generated #
# =============== #
[Tt]emp/
[Oo]bj/
[Bb]uild
[Ll]ibrary/
sysinfo.txt
LICENSE.txt.meta
README.md.meta
SMAA.meta
 
# ===================================== #
# Visual Studio / MonoDevelop generated #
# ===================================== #
[Ee]xported[Oo]bj/
/*.userprefs
/*.csproj
/*.pidb
/*.suo
/*.sln*
/*.user
/*.unityproj
/*.booproj
 
# ============ #
# OS generated #
# ============ #
.DS_Store*
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
[Tt]humbs.db

================================================
FILE: LICENSE.txt
================================================
Copyright (c) 2015 Thomas Hourdel

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:

   1. The origin of this software must not be misrepresented; you must not
   claim that you wrote the original software. If you use this software
   in a product, an acknowledgment in the product documentation would be
   appreciated but is not required.

   2. Altered source versions must be plainly marked as such, and must not be
   misrepresented as being the original software.

   3. This notice may not be removed or altered from any source
   distribution.
   

================================================
FILE: README.md
================================================
# SMAA for Unity3D

This is a highly customizable implementation of [Subpixel Morphological Antialiasing](http://www.iryoku.com/smaa/) for Unity3D.

Tested with Unity 5+ (Personal or Pro). Works with the deferred & forward rendering paths, in gamma or linear color space, with Directx 9, Directx 11 and OpenGL targets.

It comes with a few quality presets but you can easily build your own in the inspector. Every inspector setting comes with a help popup so you shouldn't have to dig into the (documented) source code.

Right now it implements SMAA 1x (+ predication). Implementing Temporal SMAA (T2x) should be doable, but the spatial (S2x) and spatial + temporal (4x) variants aren't possible in Unity right now.

[Comparison screenshots with FXAA and Supersampling](http://imgur.com/a/J75KB).

## Instructions

Drop the `SMAA` folder in your project and add the `SMAA` script to your camera (or select your camera and use `Component -> Image Effects -> Subpixel Morphological Antialiasing`). The effect should be the first in the post-processing chain (before `Bloom`, `Tonemapping`, `DoF` etc) or it will miss some edges, especially when working in HDR.

## To infinity and beyond

An updated version of this effect is available in Unity's official [Cinematic Image Effects](https://bitbucket.org/Unity-Technologies/cinematic-image-effects) repository (Unity 5.3+ only).

## License

Zlib (see [License.txt](LICENSE.txt))


================================================
FILE: SMAA/Resources/AreaTex.tga.meta
================================================
fileFormatVersion: 2
guid: 7a7a7bb321416fa4d8ba53a700ae8140
timeCreated: 1430506045
licenseType: Free
TextureImporter:
  fileIDToRecycleName: {}
  serializedVersion: 2
  mipmaps:
    mipMapMode: 0
    enableMipMap: 0
    linearTexture: 1
    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: 0
    mipBias: -1
    wrapMode: 1
  nPOTScale: 0
  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: 5
  buildTargetSettings: []
  spriteSheet:
    sprites: []
  spritePackingTag: 
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Resources/SearchTex.tga.meta
================================================
fileFormatVersion: 2
guid: 3e01b396685ee1f48ac664c99ac95201
timeCreated: 1430506045
licenseType: Free
TextureImporter:
  fileIDToRecycleName: {}
  serializedVersion: 2
  mipmaps:
    mipMapMode: 0
    enableMipMap: 0
    linearTexture: 1
    correctGamma: 0
    fadeOut: 0
    borderMipMap: 0
    mipMapFadeDistanceStart: 1
    mipMapFadeDistanceEnd: 3
  bumpmap:
    convertToNormalMap: 0
    externalNormalMap: 0
    heightScale: .25
    normalMapFilter: 0
  isReadable: 0
  grayScaleToAlpha: 1
  generateCubemap: 0
  cubemapConvolution: 0
  cubemapConvolutionSteps: 8
  cubemapConvolutionExponent: 1.5
  seamlessCubemap: 0
  textureFormat: 1
  maxTextureSize: 64
  textureSettings:
    filterMode: 0
    aniso: 0
    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: 5
  buildTargetSettings: []
  spriteSheet:
    sprites: []
  spritePackingTag: 
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Resources.meta
================================================
fileFormatVersion: 2
guid: 9362798305520c448b294dd314a7daff
folderAsset: yes
timeCreated: 1430505545
licenseType: Free
DefaultImporter:
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Scripts/DebugPass.cs
================================================
/*
 * Copyright (c) 2015 Thomas Hourdel
 *
 * This software is provided 'as-is', without any express or implied
 * warranty. In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 * 
 *    1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 
 *    2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 
 *    3. This notice may not be removed or altered from any source
 *    distribution.
 */

namespace Smaa
{
	/// <summary>
	/// Helps debugging and fine tuning settings when working with <see cref="QualityPreset.Custom"/>.
	/// </summary>
	public enum DebugPass
	{
		/// <summary>
		/// Standard rendering, no debug pass is shown.
		/// </summary>
		Off,

		/// <summary>
		/// Shows the detected edges.
		/// </summary>
		Edges,

		/// <summary>
		/// Shows the computed blend weights.
		/// </summary>
		Weights
	}
}


================================================
FILE: SMAA/Scripts/DebugPass.cs.meta
================================================
fileFormatVersion: 2
guid: 3e933ae326e948a44b9662a4675dbcfc
timeCreated: 1431287415
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Scripts/EdgeDetectionMethod.cs
================================================
/*
 * Copyright (c) 2015 Thomas Hourdel
 *
 * This software is provided 'as-is', without any express or implied
 * warranty. In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 * 
 *    1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 
 *    2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 
 *    3. This notice may not be removed or altered from any source
 *    distribution.
 */

namespace Smaa
{
	/// <summary>
	/// You have three edge detection methods to choose from: luma, color or depth.
	/// They represent different quality/performance and anti-aliasing/sharpness tradeoffs, so our recommendation is
	/// for you to choose the one that best suits your particular scenario.
	/// </summary>
	public enum EdgeDetectionMethod
	{
		/// <summary>
		/// Luma edge detection is usually more expensive than depth edge detection, but catches visible edges that
		/// depth edge detection can miss.
		/// </summary>
		Luma = 1,

		/// <summary>
		/// Color edge detection is usually the most expensive one but catches chroma-only edges.
		/// </summary>
		Color = 2,

		/// <summary>
		/// Depth edge detection is usually the fastest but it may miss some edges.
		/// </summary>
		Depth = 3
	}
}


================================================
FILE: SMAA/Scripts/EdgeDetectionMethod.cs.meta
================================================
fileFormatVersion: 2
guid: 15c15283c1eeea24c9a822489a0c579b
timeCreated: 1431287415
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Scripts/Editor/MinDrawer.cs
================================================
/*
 * Copyright (c) 2015 Thomas Hourdel
 *
 * This software is provided 'as-is', without any express or implied
 * warranty. In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 * 
 *    1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 
 *    2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 
 *    3. This notice may not be removed or altered from any source
 *    distribution.
 */

using UnityEngine;
using UnityEditor;
using Smaa;

namespace SmaaEditor
{
	[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.");
			}
		}
	}
}


================================================
FILE: SMAA/Scripts/Editor/MinDrawer.cs.meta
================================================
fileFormatVersion: 2
guid: 4eb60e20a77aac94f92280b99b955c68
timeCreated: 1430588717
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Scripts/Editor/SMAAEditor.cs
================================================
/*
 * Copyright (c) 2015 Thomas Hourdel
 *
 * This software is provided 'as-is', without any express or implied
 * warranty. In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 * 
 *    1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 
 *    2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 
 *    3. This notice may not be removed or altered from any source
 *    distribution.
 */

using UnityEngine;
using UnityEditor;
using Smaa;

namespace SmaaEditor
{
	[CustomEditor(typeof(SMAA))]
	public class SMAAEditor : Editor
	{
		SerializedProperty m_Hdr;
		SerializedProperty m_DebugPass;
		SerializedProperty m_DetectionMethod;
		SerializedProperty m_Quality;

		SerializedProperty m_CustomPreset;
		SerializedProperty m_CustomDiagDetection;
		SerializedProperty m_CustomCornerDetection;
		SerializedProperty m_CustomThreshold;
		SerializedProperty m_CustomDepthThreshold;
		SerializedProperty m_CustomMaxSearchSteps;
		SerializedProperty m_CustomMaxSearchStepsDiag;
		SerializedProperty m_CustomCornerRounding;
		SerializedProperty m_CustomLocalContrastAdaptationFactor;

		SerializedProperty m_UsePredication;
		SerializedProperty m_CustomPredicationPreset;
		SerializedProperty m_PredicationThreshold;
		SerializedProperty m_PredicationScale;
		SerializedProperty m_PredicationStrength;

		void OnEnable()
		{
			m_Hdr = serializedObject.FindProperty("Hdr");
			m_DebugPass = serializedObject.FindProperty("DebugPass");
			m_DetectionMethod = serializedObject.FindProperty("DetectionMethod");
			m_Quality = serializedObject.FindProperty("Quality");

			m_CustomPreset = serializedObject.FindProperty("CustomPreset");
			m_CustomDiagDetection = m_CustomPreset.FindPropertyRelative("DiagDetection");
			m_CustomCornerDetection = m_CustomPreset.FindPropertyRelative("CornerDetection");
			m_CustomThreshold = m_CustomPreset.FindPropertyRelative("Threshold");
			m_CustomDepthThreshold = m_CustomPreset.FindPropertyRelative("DepthThreshold");
			m_CustomMaxSearchSteps = m_CustomPreset.FindPropertyRelative("MaxSearchSteps");
			m_CustomMaxSearchStepsDiag = m_CustomPreset.FindPropertyRelative("MaxSearchStepsDiag");
			m_CustomCornerRounding = m_CustomPreset.FindPropertyRelative("CornerRounding");
			m_CustomLocalContrastAdaptationFactor = m_CustomPreset.FindPropertyRelative("LocalContrastAdaptationFactor");

			m_UsePredication = serializedObject.FindProperty("UsePredication");
			m_CustomPredicationPreset = serializedObject.FindProperty("CustomPredicationPreset");
			m_PredicationThreshold = m_CustomPredicationPreset.FindPropertyRelative("Threshold");
			m_PredicationScale = m_CustomPredicationPreset.FindPropertyRelative("Scale");
			m_PredicationStrength = m_CustomPredicationPreset.FindPropertyRelative("Strength");
		}

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

			EditorGUILayout.PropertyField(m_Hdr, new GUIContent("HDR", "Render target mode. Keep it to Auto unless you know what you're doing."));
			EditorGUILayout.PropertyField(m_DebugPass, new GUIContent("Debug Pass", "Use this to fine tune your settings when working in Custom quality mode."));
			EditorGUILayout.PropertyField(m_DetectionMethod, new GUIContent("Edge Detection Method", "You've three edge detection methods to choose from: luma, color or depth.\nThey represent different quality/performance and anti-aliasing/sharpness tradeoffs, so our recommendation is for you to choose the one that best suits your particular scenario:\n\n- Depth edge detection is usually the fastest but it may miss some edges.\n- Luma edge detection is usually more expensive than depth edge detection, but catches visible edges that depth edge detection can miss.\n- Color edge detection is usually the most expensive one but catches chroma-only edges."));
			EditorGUILayout.PropertyField(m_Quality, new GUIContent("Quality Preset", "Low: 60% of the quality.\nMedium: 80% of the quality.\nHigh: 95% of the quality.\nUltra: 99% of the quality."));

			if ((m_DetectionMethod.enumValueIndex == (int)EdgeDetectionMethod.Depth - 1) && IsOpenGL())
			{
				EditorGUILayout.HelpBox("EdgeDetectionMethod.Depth isn't supported on OpenGL. Please use Luma or Color instead.", MessageType.Warning);
			}

			if (m_Quality.enumValueIndex == (int)QualityPreset.Custom)
			{
				EditorGUILayout.Space();
				EditorGUILayout.LabelField("Custom Settings", EditorStyles.boldLabel);

				EditorGUI.indentLevel++;
				EditorGUILayout.PropertyField(m_CustomDiagDetection, new GUIContent("Diagonal Detection", "Enables/Disables diagonal processing."));
				EditorGUILayout.PropertyField(m_CustomCornerDetection, new GUIContent("Corner Detection", "Enables/Disables corner detection. Leave this on to avoid blurry corners."));

				if (m_DetectionMethod.enumValueIndex != (int)EdgeDetectionMethod.Depth - 1)
					EditorGUILayout.PropertyField(m_CustomThreshold, new GUIContent("Threshold", "Specifies the threshold or sensitivity to edges. Lowering this value you will be able to detect more edges at the expense of performance.\n0.1 is a reasonable value, and allows to catch most visible edges. 0.05 is a rather overkill value, that allows to catch 'em all."));
				else
					EditorGUILayout.PropertyField(m_CustomDepthThreshold, new GUIContent("Depth Threshold", "Specifies the threshold for depth edge detection. Lowering this value you will be able to detect more edges at the expense of performance."));

				EditorGUILayout.PropertyField(m_CustomMaxSearchSteps, new GUIContent("Max Search Steps", "Specifies the maximum steps performed in the horizontal/vertical pattern searches, at each side of the pixel.\nIn number of pixels, it's actually the double. So the maximum line length perfectly handled by, for example 16, is 64 (by perfectly, we meant that longer lines won't look as good, but still antialiased)."));

				if (m_CustomDiagDetection.boolValue)
					EditorGUILayout.PropertyField(m_CustomMaxSearchStepsDiag, new GUIContent("Max Diagonal Search Steps", "Specifies the maximum steps performed in the diagonal pattern searches, at each side of the pixel. In this case we jump one pixel at time, instead of two.\nOn high-end machines it is cheap (between a 0.8x and 0.9x slower for 16 steps), but it can have a significant impact on older machines."));

				if (m_CustomCornerDetection.boolValue)
					EditorGUILayout.PropertyField(m_CustomCornerRounding, new GUIContent("Corner Rounding", "Specifies how much sharp corners will be rounded."));

				if (m_DetectionMethod.enumValueIndex != (int)EdgeDetectionMethod.Depth - 1)
					EditorGUILayout.PropertyField(m_CustomLocalContrastAdaptationFactor, new GUIContent("Local Contrast Adaptation Factor", "If there is an neighbor edge that has a local contrast factor times bigger contrast than current edge, current edge will be discarded.\nThis allows to eliminate spurious crossing edges, and is based on the fact that, if there is too much contrast in a direction, that will hide perceptually contrast in the other neighbors."));

				EditorGUI.indentLevel--;
			}

			if (m_DetectionMethod.enumValueIndex != (int)EdgeDetectionMethod.Depth - 1)
			{
				EditorGUILayout.Space();
				EditorGUILayout.LabelField("Predication", EditorStyles.boldLabel);

				EditorGUI.indentLevel++;
				EditorGUILayout.PropertyField(m_UsePredication, new GUIContent("Use Predication", "Predicated thresholding allows to better preserve texture details and to improve performance, by decreasing the number of detected edges using an additional buffer (the detph buffer).\nIt locally decreases the luma or color threshold if an edge is found in an additional buffer (so the global threshold can be higher)."));

				if (m_UsePredication.boolValue)
				{
					EditorGUILayout.PropertyField(m_PredicationThreshold, new GUIContent("Threshold", "Threshold to be used in the additional predication buffer."));
					EditorGUILayout.PropertyField(m_PredicationScale, new GUIContent("Scale", "How much to scale the global threshold used for luma or color edge detection when using predication."));
					EditorGUILayout.PropertyField(m_PredicationStrength, new GUIContent("Strength", "How much to locally decrease the threshold."));
				}
				EditorGUI.indentLevel--;
			}

			serializedObject.ApplyModifiedProperties();
		}

		bool IsOpenGL()
		{
			return SystemInfo.graphicsDeviceVersion.IndexOf("OpenGL") > -1;
		}
	}
}


================================================
FILE: SMAA/Scripts/Editor/SMAAEditor.cs.meta
================================================
fileFormatVersion: 2
guid: 5c2ffc06b5a6ee64d8e1d9bdf074732c
timeCreated: 1430643832
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Scripts/Editor.meta
================================================
fileFormatVersion: 2
guid: 3ab9eab0d04085b4abd47b6b0657143c
folderAsset: yes
timeCreated: 1430588699
licenseType: Free
DefaultImporter:
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Scripts/HDRMode.cs
================================================
/*
 * Copyright (c) 2015 Thomas Hourdel
 *
 * This software is provided 'as-is', without any express or implied
 * warranty. In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 * 
 *    1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 
 *    2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 
 *    3. This notice may not be removed or altered from any source
 *    distribution.
 */

namespace Smaa
{
	/// <summary>
	/// Render target mode. Keep it to <see cref="HDRMode.Auto"/> unless you know what you're doing.
	/// </summary>
	public enum HDRMode
	{
		Auto,
		On,
		Off
	}
}


================================================
FILE: SMAA/Scripts/HDRMode.cs.meta
================================================
fileFormatVersion: 2
guid: d1c3b49b0d034e44381bd74595c02ca0
timeCreated: 1431606116
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Scripts/MinAttribute.cs
================================================
/*
 * Copyright (c) 2015 Thomas Hourdel
 *
 * This software is provided 'as-is', without any express or implied
 * warranty. In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 * 
 *    1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 
 *    2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 
 *    3. This notice may not be removed or altered from any source
 *    distribution.
 */

using UnityEngine;

namespace Smaa
{
	/// <summary>
	/// Attribute used to make a float or int variable in a script be restricted to a specific minimum value.
	/// </summary>
	public sealed class MinAttribute : PropertyAttribute
	{
		/// <summary>
		/// The minimum value to clamp to.
		/// </summary>
		public readonly float min;

		/// <summary>
		/// Constructor.
		/// </summary>
		/// <param name="min">The minimum value to clamp to.</param>
		public MinAttribute(float min)
		{
			this.min = min;
		}
	}
}


================================================
FILE: SMAA/Scripts/MinAttribute.cs.meta
================================================
fileFormatVersion: 2
guid: a8298e5a2f9a3d441a7ea7fdb59abc47
timeCreated: 1430588352
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Scripts/PredicationPreset.cs
================================================
using UnityEngine;
using System;

namespace Smaa
{
	/// <summary>
	/// Holds a set of settings to use when <see cref="SMAA.UsePredication"/> is enabled.
	/// </summary>
	[Serializable]
	public class PredicationPreset
	{
		/// <summary>
		/// Threshold to be used in the additional predication buffer.
		/// </summary>
		[Min(0.0001f)]
		public float Threshold = 0.01f;

		/// <summary>
		/// How much to scale the global threshold used for luma or color edge detection when using predication.
		/// </summary>
		[Range(1f, 5f)]
		public float Scale = 2f;

		/// <summary>
		/// How much to locally decrease the threshold.
		/// </summary>
		[Range(0f, 1f)]
		public float Strength = 0.4f;
	}
}


================================================
FILE: SMAA/Scripts/PredicationPreset.cs.meta
================================================
fileFormatVersion: 2
guid: 33a1732f95161474781f227bc66bdda6
timeCreated: 1430644344
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Scripts/Preset.cs
================================================
/*
 * Copyright (c) 2015 Thomas Hourdel
 *
 * This software is provided 'as-is', without any express or implied
 * warranty. In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 * 
 *    1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 
 *    2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 
 *    3. This notice may not be removed or altered from any source
 *    distribution.
 */

using UnityEngine;
using System;

namespace Smaa
{
	/// <summary>
	/// Holds a set of settings to use with SMAA passes.
	/// </summary>
	[Serializable]
	public class Preset
	{
		/// <summary>
		/// Enables/Disables diagonal processing.
		/// </summary>
		public bool DiagDetection = true;

		/// <summary>
		/// Enables/Disables corner detection. Leave this on to avoid blurry corners.
		/// </summary>
		public bool CornerDetection = true;

		/// <summary>
		/// Specifies the threshold or sensitivity to edges. Lowering this value you will be able to detect more edges
		/// at the expense of performance.
		/// <c>0.1</c> is a reasonable value, and allows to catch most visible edges. <c>0.05</c> is a rather overkill
		/// value, that allows to catch 'em all.
		/// </summary>
		[Range(0f, 0.5f)]
		public float Threshold = 0.1f;

		/// <summary>
		/// Specifies the threshold for depth edge detection. Lowering this value you will be able to detect more edges
		/// at the expense of performance. Only used with <see cref="SMAAEdgeDetectionMethod.Depth"/>.
		/// </summary>
		[Min(0.0001f)]
		public float DepthThreshold = 0.01f;

		/// <summary>
		/// Specifies the maximum steps performed in the horizontal/vertical pattern searches, at each side of the
		/// pixel. In number of pixels, it's actually the double. So the maximum line length perfectly handled by, for
		/// example <c>16</c> is <c>64</c> (by perfectly, we meant that longer lines won't look as good, but still
		/// antialiased).
		/// </summary>
		[Range(0, 112)]
		public int MaxSearchSteps = 16;

		/// <summary>
		/// Specifies the maximum steps performed in the diagonal pattern searches, at each side of the pixel. In this
		/// case we jump one pixel at time, instead of two.
		/// 
		/// On high-end machines it is cheap (between a 0.8x and 0.9x slower for <c>16</c> steps), but it can have a
		/// significant impact on older machines.
		/// </summary>
		[Range(0, 20)]
		public int MaxSearchStepsDiag = 8;

		/// <summary>
		/// Specifies how much sharp corners will be rounded.
		/// </summary>
		[Range(0, 100)]
		public int CornerRounding = 25;

		/// <summary>
		/// If there is an neighbor edge that has a local contrast factor times bigger contrast than current edge,
		/// current edge will be discarded.
		/// 
		/// This allows to eliminate spurious crossing edges, and is based on the fact that, if there is too much
		/// contrast in a direction, that will hide perceptually contrast in the other neighbors.
		/// 
		/// Currently unused in OpenGL.
		/// </summary>
		[Min(0f)]
		public float LocalContrastAdaptationFactor = 2f;
	}
}


================================================
FILE: SMAA/Scripts/Preset.cs.meta
================================================
fileFormatVersion: 2
guid: a0440e1a7888f194e9c8e35089dc10f5
timeCreated: 1430588349
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Scripts/QualityPreset.cs
================================================
/*
 * Copyright (c) 2015 Thomas Hourdel
 *
 * This software is provided 'as-is', without any express or implied
 * warranty. In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 * 
 *    1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 
 *    2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 
 *    3. This notice may not be removed or altered from any source
 *    distribution.
 */

namespace Smaa
{
	/// <summary>
	/// A bunch of quality presets. Use <see cref="QualityPreset.Custom"/> to fine tune every setting.
	/// </summary>
	public enum QualityPreset
	{
		/// <summary>
		/// 60% of the quality.
		/// </summary>
		Low = 0,

		/// <summary>
		/// 80% of the quality.
		/// </summary>
		Medium = 1,

		/// <summary>
		/// 90% of the quality.
		/// </summary>
		High = 2,

		/// <summary>
		/// 99% of the quality (generally overkill).
		/// </summary>
		Ultra = 3,

		/// <summary>
		/// Custom quality settings.
		/// </summary>
		/// <seealso cref="Preset"/>
		/// <seealso cref="SMAA.CustomPreset"/>
		Custom
	}
}


================================================
FILE: SMAA/Scripts/QualityPreset.cs.meta
================================================
fileFormatVersion: 2
guid: 464c264d2294dc04cbdbc1cbb16257cc
timeCreated: 1431287415
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Scripts/SMAA.cs
================================================
/*
 * Copyright (c) 2015 Thomas Hourdel
 *
 * This software is provided 'as-is', without any express or implied
 * warranty. In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 * 
 *    1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 
 *    2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 
 *    3. This notice may not be removed or altered from any source
 *    distribution.
 */

using UnityEngine;
using System;

namespace Smaa
{
	/// <summary>
	/// Implementation of Subpixel Morphological Antialiasing for Unity.
	/// </summary>
#if UNITY_5_4_OR_NEWER
    [ImageEffectAllowedInSceneView]
#endif
	[ExecuteInEditMode]
	[RequireComponent(typeof(Camera))]
	[AddComponentMenu("Image Effects/Subpixel Morphological Antialiasing")]
	public class SMAA : MonoBehaviour
	{
		/// <summary>
		/// Render target mode. Keep it to <see cref="HDRMode.Auto"/> unless you know what you're doing.
		/// </summary>
		public HDRMode Hdr = HDRMode.Auto;

		/// <summary>
		/// Use this to fine tune your settings when working in Custom quality mode.
		/// </summary>
		/// <seealso cref="DebugPass"/>
		public DebugPass DebugPass = DebugPass.Off;

		/// <summary>
		/// Quality preset to use. Set to <see cref="QualityPreset.Custom"/> to fine tune every setting.
		/// </summary>
		/// <seealso cref="QualityPreset"/>
		public QualityPreset Quality = QualityPreset.High;

		/// <summary>
		/// You have three edge detection methods to choose from: luma, color or depth.
		/// They represent different quality/performance and anti-aliasing/sharpness tradeoffs, so our recommendation is
		/// for you to choose the one that best suits your particular scenario.
		/// </summary>
		/// <seealso cref="EdgeDetectionMethod"/>
		public EdgeDetectionMethod DetectionMethod = EdgeDetectionMethod.Luma;

		/// <summary>
		/// Predicated thresholding allows to better preserve texture details and to improve performance, by decreasing
		/// the number of detected edges using an additional buffer (the detph buffer).
		/// 
		/// It locally decreases the luma or color threshold if an edge is found in an additional buffer (so the global
		/// threshold can be higher).
		/// </summary>
		public bool UsePredication = false; // Unused with EdgeDetectionMethod.Depth

		/// <summary>
		/// Holds the custom preset to use with <see cref="QualityPreset.Custom"/>.
		/// </summary>
		public Preset CustomPreset;

		/// <summary>
		/// Holds the custom preset to use when <see cref="SMAA.UsePredication"/> is enabled.
		/// </summary>
		public PredicationPreset CustomPredicationPreset;

		/// <summary>
		/// The shader used by the processing effect.
		/// </summary>
		public Shader Shader;

		/// <summary>
		/// This texture allows to obtain the area for a certain pattern and distances to the left and to right of the
		/// line. Automatically set by the component if <c>null</c>.
		/// </summary>
		public Texture2D AreaTex;

		/// <summary>
		/// This texture allows to know how many pixels we must advance in the last step of our line search algorithm,
		/// with a single fetch. Automatically set by the component if <c>null</c>.
		/// </summary>
		public Texture2D SearchTex;

		/// <summary>
		/// A reference to the camera this component is added to.
		/// </summary>
		protected Camera m_Camera;

		/// <summary>
		/// The internal <see cref="Preset"/> used for <c>Low</c>, <c>Medium</c>, <c>High</c>, <c>Ultra</c>.
		/// </summary>
		protected Preset[] m_StdPresets;

		/// <summary>
		/// The internal <c>Material</c> instance. Use <see cref="Material"/> instead.
		/// </summary>
		protected Material m_Material;

		/// <summary>
		/// The <c>Material</c> instance used by the post-processing effect.
		/// </summary>
		public Material Material
		{
			get
			{
				if (m_Material == null)
				{
					m_Material = new Material(Shader);
					m_Material.hideFlags = HideFlags.HideAndDontSave;
				}

				return m_Material;
			}
		}

		void OnEnable()
		{
			// Make sure the helper textures are set
			if (AreaTex == null)
				AreaTex = Resources.Load<Texture2D>("AreaTex");

			if (SearchTex == null)
				SearchTex = Resources.Load<Texture2D>("SearchTex");

			// Misc
			m_Camera = GetComponent<Camera>();

			// Create default presets
			CreatePresets();
		}

		void Start()
		{
			// Disable if we don't support image effects
			if (!SystemInfo.supportsImageEffects)
			{
				enabled = false;
				return;
			}

			// Disable the image effect if the shader can't run on the user's graphics card
			if (!Shader || !Shader.isSupported)
				enabled = false;
		}

		void OnDisable()
		{
			// Cleanup
			if (m_Material != null)
			{
				#if UNITY_EDITOR
				DestroyImmediate(m_Material);
				#else
				Destroy(m_Material);
				#endif
			}
		}

		void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			int width = m_Camera.pixelWidth;
			int height = m_Camera.pixelHeight;
			Preset preset = CustomPreset;

			if (Quality != QualityPreset.Custom)
				preset = m_StdPresets[(int)Quality];

			// Pass IDs
			int passEdgeDetection = (int)DetectionMethod;
			int passBlendWeights = 4;
			int passNeighborhoodBlending = 5;

			// Render format
			RenderTextureFormat renderFormat = source.format;

			if (Hdr == HDRMode.Off)
				renderFormat = RenderTextureFormat.ARGB32;
			else if (Hdr == HDRMode.On)
				renderFormat = RenderTextureFormat.ARGBHalf;

			// Uniforms
			Material.SetTexture("_AreaTex", AreaTex);
			Material.SetTexture("_SearchTex", SearchTex);

			Material.SetVector("_Metrics", new Vector4(1f / (float)width, 1f / (float)height, width, height));
			Material.SetVector("_Params1", new Vector4(preset.Threshold, preset.DepthThreshold, preset.MaxSearchSteps, preset.MaxSearchStepsDiag));
			Material.SetVector("_Params2", new Vector2(preset.CornerRounding, preset.LocalContrastAdaptationFactor));

			// Handle predication & depth-based edge detection
			Shader.DisableKeyword("USE_PREDICATION");

			if (DetectionMethod == EdgeDetectionMethod.Depth)
			{
				m_Camera.depthTextureMode |= DepthTextureMode.Depth;
			}
			else if (UsePredication)
			{
				m_Camera.depthTextureMode |= DepthTextureMode.Depth;
				Shader.EnableKeyword("USE_PREDICATION");
				Material.SetVector("_Params3", new Vector3(CustomPredicationPreset.Threshold, CustomPredicationPreset.Scale, CustomPredicationPreset.Strength));
			}

			// Diag search & corner detection
			Shader.DisableKeyword("USE_DIAG_SEARCH");
			Shader.DisableKeyword("USE_CORNER_DETECTION");

			if (preset.DiagDetection)
				Shader.EnableKeyword("USE_DIAG_SEARCH");

			if (preset.CornerDetection)
				Shader.EnableKeyword("USE_CORNER_DETECTION");

			// Temporary render textures
			RenderTexture rt1 = TempRT(width, height, renderFormat);
			RenderTexture rt2 = TempRT(width, height, renderFormat);

			// Clear both temp RTs as they could (and will) be filled with garbage
			Clear(rt1);
			Clear(rt2);

			// Edge Detection
			Graphics.Blit(source, rt1, Material, passEdgeDetection);

			if (DebugPass == DebugPass.Edges)
			{
				Graphics.Blit(rt1, destination);
			}
			else
			{
				// Blend Weights
				Graphics.Blit(rt1, rt2, Material, passBlendWeights);

				if (DebugPass == DebugPass.Weights)
				{
					Graphics.Blit(rt2, destination);
				}
				else
				{
					// Neighborhood Blending
					Material.SetTexture("_BlendTex", rt2);
					Graphics.Blit(source, destination, Material, passNeighborhoodBlending);
				}
			}

			// Cleanup
			RenderTexture.ReleaseTemporary(rt1);
			RenderTexture.ReleaseTemporary(rt2);
		}

		void Clear(RenderTexture rt)
		{
			Graphics.Blit(rt, rt, Material, 0);
		}

		RenderTexture TempRT(int width, int height, RenderTextureFormat format)
		{
			// Skip the depth & stencil buffer creation when DebugPass is set to avoid flickering
			// TODO: Stencil buffer not working for some reason
			// int depthStencilBits = DebugPass == DebugPass.Off ? 24 : 0;
			int depthStencilBits = 0;
			return RenderTexture.GetTemporary(width, height, depthStencilBits, format, RenderTextureReadWrite.Linear);
		}

		void CreatePresets()
		{
			m_StdPresets = new Preset[4];

			// Low
			m_StdPresets[0] = new Preset
			{
				Threshold = 0.15f,
				MaxSearchSteps = 4
			};
			m_StdPresets[0].DiagDetection = false; // Can't use object initializer for bool (weird mono bug ?)
			m_StdPresets[0].CornerDetection = false;

			// Medium
			m_StdPresets[1] = new Preset
			{
				Threshold = 0.1f,
				MaxSearchSteps = 8
			};
			m_StdPresets[1].DiagDetection = false;
			m_StdPresets[1].CornerDetection = false;

			// High
			m_StdPresets[2] = new Preset
			{
				Threshold = 0.1f,
				MaxSearchSteps = 16,
				MaxSearchStepsDiag = 8,
				CornerRounding = 25
			};

			// Ultra
			m_StdPresets[3] = new Preset
			{
				Threshold = 0.05f,
				MaxSearchSteps = 32,
				MaxSearchStepsDiag = 16,
				CornerRounding = 25
			};
		}
	}
}


================================================
FILE: SMAA/Scripts/SMAA.cs.meta
================================================
fileFormatVersion: 2
guid: 1ec5688dc97c94c41a2bf37f0a513c2e
timeCreated: 1430517145
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences:
  - Shader: {fileID: 4800000, guid: 461ad39340fd1bf4e8d9fe310c58be95, type: 3}
  - AreaTex: {fileID: 2800000, guid: 7a7a7bb321416fa4d8ba53a700ae8140, type: 3}
  - SearchTex: {fileID: 2800000, guid: 3e01b396685ee1f48ac664c99ac95201, type: 3}
  executionOrder: 0
  icon: {instanceID: 0}
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Scripts.meta
================================================
fileFormatVersion: 2
guid: f13cc60e1465b9e4da5321b0b73c6849
folderAsset: yes
timeCreated: 1430504509
licenseType: Free
DefaultImporter:
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Shaders/SMAA.cginc
================================================
// Ported to Unity by Thomas Hourdel (thomas.hourdel@gmail.com)

/**
 * Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.com)
 * Copyright (C) 2013 Jose I. Echevarria (joseignacioechevarria@gmail.com)
 * Copyright (C) 2013 Belen Masia (bmasia@unizar.es)
 * Copyright (C) 2013 Fernando Navarro (fernandn@microsoft.com)
 * Copyright (C) 2013 Diego Gutierrez (diegog@unizar.es)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is furnished to
 * do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software. As clarification, there
 * is no requirement that the copyright notice and permission be included in
 * binary distributions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */


/**
 *                  _______  ___  ___       ___           ___
 *                 /       ||   \/   |     /   \         /   \
 *                |   (---- |  \  /  |    /  ^  \       /  ^  \
 *                 \   \    |  |\/|  |   /  /_\  \     /  /_\  \
 *              ----)   |   |  |  |  |  /  _____  \   /  _____  \
 *             |_______/    |__|  |__| /__/     \__\ /__/     \__\
 * 
 *                               E N H A N C E D
 *       S U B P I X E L   M O R P H O L O G I C A L   A N T I A L I A S I N G
 *
 *                         http://www.iryoku.com/smaa/
 *
 * Hi, welcome aboard!
 * 
 * Here you'll find instructions to get the shader up and running as fast as
 * possible.
 *
 * IMPORTANTE NOTICE: when updating, remember to update both this file and the
 * precomputed textures! They may change from version to version.
 *
 * The shader has three passes, chained together as follows:
 *
 *                           |input|------------------
 *                              v                     |
 *                    [ SMAA*EdgeDetection ]          |
 *                              v                     |
 *                          |edgesTex|                |
 *                              v                     |
 *              [ SMAABlendingWeightCalculation ]     |
 *                              v                     |
 *                          |blendTex|                |
 *                              v                     |
 *                [ SMAANeighborhoodBlending ] <------
 *                              v
 *                           |output|
 *
 * Note that each [pass] has its own vertex and pixel shader. Remember to use
 * oversized triangles instead of quads to avoid overshading along the
 * diagonal.
 *
 * You've three edge detection methods to choose from: luma, color or depth.
 * They represent different quality/performance and anti-aliasing/sharpness
 * tradeoffs, so our recommendation is for you to choose the one that best
 * suits your particular scenario:
 *
 * - Depth edge detection is usually the fastest but it may miss some edges.
 *
 * - Luma edge detection is usually more expensive than depth edge detection,
 *   but catches visible edges that depth edge detection can miss.
 *
 * - Color edge detection is usually the most expensive one but catches
 *   chroma-only edges.
 *
 * For quickstarters: just use luma edge detection.
 *
 * The general advice is to not rush the integration process and ensure each
 * step is done correctly (don't try to integrate SMAA T2x with predicated edge
 * detection from the start!). Ok then, let's go!
 *
 *  1. The first step is to create two RGBA temporal render targets for holding
 *     |edgesTex| and |blendTex|.
 *
 *     In DX10 or DX11, you can use a RG render target for the edges texture.
 *     In the case of NVIDIA GPUs, using RG render targets seems to actually be
 *     slower.
 *
 *     On the Xbox 360, you can use the same render target for resolving both
 *     |edgesTex| and |blendTex|, as they aren't needed simultaneously.
 *
 *  2. Both temporal render targets |edgesTex| and |blendTex| must be cleared
 *     each frame. Do not forget to clear the alpha channel!
 *
 *  3. The next step is loading the two supporting precalculated textures,
 *     'areaTex' and 'searchTex'. You'll find them in the 'Textures' folder as
 *     C++ headers, and also as regular DDS files. They'll be needed for the
 *     'SMAABlendingWeightCalculation' pass.
 *
 *     If you use the C++ headers, be sure to load them in the format specified
 *     inside of them.
 *
 *     You can also compress 'areaTex' and 'searchTex' using BC5 and BC4
 *     respectively, if you have that option in your content processor pipeline.
 *     When compressing then, you get a non-perceptible quality decrease, and a
 *     marginal performance increase.
 *
 *  4. All samplers must be set to linear filtering and clamp.
 *
 *     After you get the technique working, remember that 64-bit inputs have
 *     half-rate linear filtering on GCN.
 *
 *     If SMAA is applied to 64-bit color buffers, switching to point filtering
 *     when accesing them will increase the performance. Search for
 *     'SMAASamplePoint' to see which textures may benefit from point
 *     filtering, and where (which is basically the color input in the edge
 *     detection and resolve passes).
 *
 *  5. All texture reads and buffer writes must be non-sRGB, with the exception
 *     of the input read and the output write in
 *     'SMAANeighborhoodBlending' (and only in this pass!). If sRGB reads in
 *     this last pass are not possible, the technique will work anyway, but
 *     will perform antialiasing in gamma space.
 *
 *     IMPORTANT: for best results the input read for the color/luma edge 
 *     detection should *NOT* be sRGB.
 *
 *  6. Before including SMAA.h you'll have to setup the render target metrics,
 *     the target and any optional configuration defines. Optionally you can
 *     use a preset.
 *
 *     You have the following targets available: 
 *         SMAA_HLSL_3
 *         SMAA_HLSL_4
 *         SMAA_HLSL_4_1
 *         SMAA_GLSL_3 *
 *         SMAA_GLSL_4 *
 *
 *         * (See SMAA_INCLUDE_VS and SMAA_INCLUDE_PS below).
 *
 *     And four presets:
 *         SMAA_PRESET_LOW          (%60 of the quality)
 *         SMAA_PRESET_MEDIUM       (%80 of the quality)
 *         SMAA_PRESET_HIGH         (%95 of the quality)
 *         SMAA_PRESET_ULTRA        (%99 of the quality)
 *
 *     For example:
 *         #define SMAA_RT_METRICS float4(1.0 / 1280.0, 1.0 / 720.0, 1280.0, 720.0)
 *         #define SMAA_HLSL_4
 *         #define SMAA_PRESET_HIGH
 *         #include "SMAA.h"
 *
 *     Note that SMAA_RT_METRICS doesn't need to be a macro, it can be a
 *     uniform variable. The code is designed to minimize the impact of not
 *     using a constant value, but it is still better to hardcode it.
 *
 *     Depending on how you encoded 'areaTex' and 'searchTex', you may have to
 *     add (and customize) the following defines before including SMAA.h:
 *          #define SMAA_AREATEX_SELECT(sample) sample.rg
 *          #define SMAA_SEARCHTEX_SELECT(sample) sample.r
 *
 *     If your engine is already using porting macros, you can define
 *     SMAA_CUSTOM_SL, and define the porting functions by yourself.
 *
 *  7. Then, you'll have to setup the passes as indicated in the scheme above.
 *     You can take a look into SMAA.fx, to see how we did it for our demo.
 *     Checkout the function wrappers, you may want to copy-paste them!
 *
 *  8. It's recommended to validate the produced |edgesTex| and |blendTex|.
 *     You can use a screenshot from your engine to compare the |edgesTex|
 *     and |blendTex| produced inside of the engine with the results obtained
 *     with the reference demo.
 *
 *  9. After you get the last pass to work, it's time to optimize. You'll have
 *     to initialize a stencil buffer in the first pass (discard is already in
 *     the code), then mask execution by using it the second pass. The last
 *     pass should be executed in all pixels.
 *
 *
 * After this point you can choose to enable predicated thresholding,
 * temporal supersampling and motion blur integration:
 *
 * a) If you want to use predicated thresholding, take a look into
 *    SMAA_PREDICATION; you'll need to pass an extra texture in the edge
 *    detection pass.
 *
 * b) If you want to enable temporal supersampling (SMAA T2x):
 *
 * 1. The first step is to render using subpixel jitters. I won't go into
 *    detail, but it's as simple as moving each vertex position in the
 *    vertex shader, you can check how we do it in our DX10 demo.
 *
 * 2. Then, you must setup the temporal resolve. You may want to take a look
 *    into SMAAResolve for resolving 2x modes. After you get it working, you'll
 *    probably see ghosting everywhere. But fear not, you can enable the
 *    CryENGINE temporal reprojection by setting the SMAA_REPROJECTION macro.
 *    Check out SMAA_DECODE_VELOCITY if your velocity buffer is encoded.
 *
 * 3. The next step is to apply SMAA to each subpixel jittered frame, just as
 *    done for 1x.
 *
 * 4. At this point you should already have something usable, but for best
 *    results the proper area textures must be set depending on current jitter.
 *    For this, the parameter 'subsampleIndices' of
 *    'SMAABlendingWeightCalculationPS' must be set as follows, for our T2x
 *    mode:
 *
 *    @SUBSAMPLE_INDICES
 *
 *    | S# |  Camera Jitter   |  subsampleIndices    |
 *    +----+------------------+---------------------+
 *    |  0 |  ( 0.25, -0.25)  |  float4(1, 1, 1, 0)  |
 *    |  1 |  (-0.25,  0.25)  |  float4(2, 2, 2, 0)  |
 *
 *    These jitter positions assume a bottom-to-top y axis. S# stands for the
 *    sample number.
 *
 * More information about temporal supersampling here:
 *    http://iryoku.com/aacourse/downloads/13-Anti-Aliasing-Methods-in-CryENGINE-3.pdf
 *
 * c) If you want to enable spatial multisampling (SMAA S2x):
 *
 * 1. The scene must be rendered using MSAA 2x. The MSAA 2x buffer must be
 *    created with:
 *      - DX10:     see below (*)
 *      - DX10.1:   D3D10_STANDARD_MULTISAMPLE_PATTERN or
 *      - DX11:     D3D11_STANDARD_MULTISAMPLE_PATTERN
 *
 *    This allows to ensure that the subsample order matches the table in
 *    @SUBSAMPLE_INDICES.
 *
 *    (*) In the case of DX10, we refer the reader to:
 *      - SMAA::detectMSAAOrder and
 *      - SMAA::msaaReorder
 *
 *    These functions allow to match the standard multisample patterns by
 *    detecting the subsample order for a specific GPU, and reordering
 *    them appropriately.
 *
 * 2. A shader must be run to output each subsample into a separate buffer
 *    (DX10 is required). You can use SMAASeparate for this purpose, or just do
 *    it in an existing pass (for example, in the tone mapping pass, which has
 *    the advantage of feeding tone mapped subsamples to SMAA, which will yield
 *    better results).
 *
 * 3. The full SMAA 1x pipeline must be run for each separated buffer, storing
 *    the results in the final buffer. The second run should alpha blend with
 *    the existing final buffer using a blending factor of 0.5.
 *    'subsampleIndices' must be adjusted as in the SMAA T2x case (see point
 *    b).
 *
 * d) If you want to enable temporal supersampling on top of SMAA S2x
 *    (which actually is SMAA 4x):
 *
 * 1. SMAA 4x consists on temporally jittering SMAA S2x, so the first step is
 *    to calculate SMAA S2x for current frame. In this case, 'subsampleIndices'
 *    must be set as follows:
 *
 *    | F# | S# |   Camera Jitter    |    Net Jitter     |   subsampleIndices   |
 *    +----+----+--------------------+-------------------+----------------------+
 *    |  0 |  0 |  ( 0.125,  0.125)  |  ( 0.375, -0.125) |  float4(5, 3, 1, 3)  |
 *    |  0 |  1 |  ( 0.125,  0.125)  |  (-0.125,  0.375) |  float4(4, 6, 2, 3)  |
 *    +----+----+--------------------+-------------------+----------------------+
 *    |  1 |  2 |  (-0.125, -0.125)  |  ( 0.125, -0.375) |  float4(3, 5, 1, 4)  |
 *    |  1 |  3 |  (-0.125, -0.125)  |  (-0.375,  0.125) |  float4(6, 4, 2, 4)  |
 *
 *    These jitter positions assume a bottom-to-top y axis. F# stands for the
 *    frame number. S# stands for the sample number.
 *
 * 2. After calculating SMAA S2x for current frame (with the new subsample
 *    indices), previous frame must be reprojected as in SMAA T2x mode (see
 *    point b).
 *
 * e) If motion blur is used, you may want to do the edge detection pass
 *    together with motion blur. This has two advantages:
 *
 * 1. Pixels under heavy motion can be omitted from the edge detection process.
 *    For these pixels we can just store "no edge", as motion blur will take
 *    care of them.
 * 2. The center pixel tap is reused.
 *
 * Note that in this case depth testing should be used instead of stenciling,
 * as we have to write all the pixels in the motion blur pass.
 *
 * That's it!
 */

//-----------------------------------------------------------------------------
// SMAA Presets

/**
 * Note that if you use one of these presets, the following configuration
 * macros will be ignored if set in the "Configurable Defines" section.
 */

#if defined(SMAA_PRESET_LOW)
#define SMAA_THRESHOLD 0.15
#define SMAA_MAX_SEARCH_STEPS 4
#define SMAA_DISABLE_DIAG_DETECTION
#define SMAA_DISABLE_CORNER_DETECTION
#elif defined(SMAA_PRESET_MEDIUM)
#define SMAA_THRESHOLD 0.1
#define SMAA_MAX_SEARCH_STEPS 8
#define SMAA_DISABLE_DIAG_DETECTION
#define SMAA_DISABLE_CORNER_DETECTION
#elif defined(SMAA_PRESET_HIGH)
#define SMAA_THRESHOLD 0.1
#define SMAA_MAX_SEARCH_STEPS 16
#define SMAA_MAX_SEARCH_STEPS_DIAG 8
#define SMAA_CORNER_ROUNDING 25
#elif defined(SMAA_PRESET_ULTRA)
#define SMAA_THRESHOLD 0.05
#define SMAA_MAX_SEARCH_STEPS 32
#define SMAA_MAX_SEARCH_STEPS_DIAG 16
#define SMAA_CORNER_ROUNDING 25
#endif

//-----------------------------------------------------------------------------
// Configurable Defines

/**
 * SMAA_THRESHOLD specifies the threshold or sensitivity to edges.
 * Lowering this value you will be able to detect more edges at the expense of
 * performance. 
 *
 * Range: [0, 0.5]
 *   0.1 is a reasonable value, and allows to catch most visible edges.
 *   0.05 is a rather overkill value, that allows to catch 'em all.
 *
 *   If temporal supersampling is used, 0.2 could be a reasonable value, as low
 *   contrast edges are properly filtered by just 2x.
 */
#ifndef SMAA_THRESHOLD
#define SMAA_THRESHOLD 0.1
#endif

/**
 * SMAA_DEPTH_THRESHOLD specifies the threshold for depth edge detection.
 * 
 * Range: depends on the depth range of the scene.
 */
#ifndef SMAA_DEPTH_THRESHOLD
#define SMAA_DEPTH_THRESHOLD (0.1 * SMAA_THRESHOLD)
#endif

/**
 * SMAA_MAX_SEARCH_STEPS specifies the maximum steps performed in the
 * horizontal/vertical pattern searches, at each side of the pixel.
 *
 * In number of pixels, it's actually the double. So the maximum line length
 * perfectly handled by, for example 16, is 64 (by perfectly, we meant that
 * longer lines won't look as good, but still antialiased).
 *
 * Range: [0, 112]
 */
#ifndef SMAA_MAX_SEARCH_STEPS
#define SMAA_MAX_SEARCH_STEPS 16
#endif

/**
 * SMAA_MAX_SEARCH_STEPS_DIAG specifies the maximum steps performed in the
 * diagonal pattern searches, at each side of the pixel. In this case we jump
 * one pixel at time, instead of two.
 *
 * Range: [0, 20]
 *
 * On high-end machines it is cheap (between a 0.8x and 0.9x slower for 16 
 * steps), but it can have a significant impact on older machines.
 *
 * Define SMAA_DISABLE_DIAG_DETECTION to disable diagonal processing.
 */
#ifndef SMAA_MAX_SEARCH_STEPS_DIAG
#define SMAA_MAX_SEARCH_STEPS_DIAG 8
#endif

/**
 * SMAA_CORNER_ROUNDING specifies how much sharp corners will be rounded.
 *
 * Range: [0, 100]
 *
 * Define SMAA_DISABLE_CORNER_DETECTION to disable corner processing.
 */
#ifndef SMAA_CORNER_ROUNDING
#define SMAA_CORNER_ROUNDING 25
#endif

/**
 * If there is an neighbor edge that has SMAA_LOCAL_CONTRAST_FACTOR times
 * bigger contrast than current edge, current edge will be discarded.
 *
 * This allows to eliminate spurious crossing edges, and is based on the fact
 * that, if there is too much contrast in a direction, that will hide
 * perceptually contrast in the other neighbors.
 */
#ifndef SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR
#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR 2.0
#endif

/**
 * Predicated thresholding allows to better preserve texture details and to
 * improve performance, by decreasing the number of detected edges using an
 * additional buffer like the light accumulation buffer, object ids or even the
 * depth buffer (the depth buffer usage may be limited to indoor or short range
 * scenes).
 *
 * It locally decreases the luma or color threshold if an edge is found in an
 * additional buffer (so the global threshold can be higher).
 *
 * This method was developed by Playstation EDGE MLAA team, and used in 
 * Killzone 3, by using the light accumulation buffer. More information here:
 *     http://iryoku.com/aacourse/downloads/06-MLAA-on-PS3.pptx 
 */
#ifndef SMAA_PREDICATION
#define SMAA_PREDICATION 0
#endif

/**
 * Threshold to be used in the additional predication buffer. 
 *
 * Range: depends on the input, so you'll have to find the magic number that
 * works for you.
 */
#ifndef SMAA_PREDICATION_THRESHOLD
#define SMAA_PREDICATION_THRESHOLD 0.01
#endif

/**
 * How much to scale the global threshold used for luma or color edge
 * detection when using predication.
 *
 * Range: [1, 5]
 */
#ifndef SMAA_PREDICATION_SCALE
#define SMAA_PREDICATION_SCALE 2.0
#endif

/**
 * How much to locally decrease the threshold.
 *
 * Range: [0, 1]
 */
#ifndef SMAA_PREDICATION_STRENGTH
#define SMAA_PREDICATION_STRENGTH 0.4
#endif

/**
 * Temporal reprojection allows to remove ghosting artifacts when using
 * temporal supersampling. We use the CryEngine 3 method which also introduces
 * velocity weighting. This feature is of extreme importance for totally
 * removing ghosting. More information here:
 *    http://iryoku.com/aacourse/downloads/13-Anti-Aliasing-Methods-in-CryENGINE-3.pdf
 *
 * Note that you'll need to setup a velocity buffer for enabling reprojection.
 * For static geometry, saving the previous depth buffer is a viable
 * alternative.
 */
#ifndef SMAA_REPROJECTION
#define SMAA_REPROJECTION 0
#endif

/**
 * SMAA_REPROJECTION_WEIGHT_SCALE controls the velocity weighting. It allows to
 * remove ghosting trails behind the moving object, which are not removed by
 * just using reprojection. Using low values will exhibit ghosting, while using
 * high values will disable temporal supersampling under motion.
 *
 * Behind the scenes, velocity weighting removes temporal supersampling when
 * the velocity of the subsamples differs (meaning they are different objects).
 *
 * Range: [0, 80]
 */
#ifndef SMAA_REPROJECTION_WEIGHT_SCALE
#define SMAA_REPROJECTION_WEIGHT_SCALE 30.0
#endif

/**
 * On some compilers, discard cannot be used in vertex shaders. Thus, they need
 * to be compiled separately.
 */
#ifndef SMAA_INCLUDE_VS
#define SMAA_INCLUDE_VS 1
#endif
#ifndef SMAA_INCLUDE_PS
#define SMAA_INCLUDE_PS 1
#endif

//-----------------------------------------------------------------------------
// Texture Access Defines

#ifndef SMAA_AREATEX_SELECT
#if defined(SMAA_HLSL_3)
#define SMAA_AREATEX_SELECT(sample) sample.ra
#else
#define SMAA_AREATEX_SELECT(sample) sample.rg
#endif
#endif

#ifndef SMAA_SEARCHTEX_SELECT
#define SMAA_SEARCHTEX_SELECT(sample) sample.r
#endif

#ifndef SMAA_DECODE_VELOCITY
#define SMAA_DECODE_VELOCITY(sample) sample.rg
#endif

//-----------------------------------------------------------------------------
// Non-Configurable Defines

#define SMAA_AREATEX_MAX_DISTANCE 16
#define SMAA_AREATEX_MAX_DISTANCE_DIAG 20
#define SMAA_AREATEX_PIXEL_SIZE (1.0 / float2(160.0, 560.0))
#define SMAA_AREATEX_SUBTEX_SIZE (1.0 / 7.0)
#define SMAA_SEARCHTEX_SIZE float2(66.0, 33.0)
#define SMAA_SEARCHTEX_PACKED_SIZE float2(64.0, 16.0)
#define SMAA_CORNER_ROUNDING_NORM (float(SMAA_CORNER_ROUNDING) / 100.0)

//-----------------------------------------------------------------------------
// Porting Functions

#if defined(SMAA_HLSL_3)
#define SMAATexture2D(tex) sampler2D tex
#define SMAATexturePass2D(tex) tex
#define SMAASampleLevelZero(tex, coord) tex2Dlod(tex, float4(coord, 0.0, 0.0))
#define SMAASampleLevelZeroPoint(tex, coord) tex2Dlod(tex, float4(coord, 0.0, 0.0))
#define SMAASampleLevelZeroOffset(tex, coord, offset) tex2Dlod(tex, float4(coord + offset * SMAA_RT_METRICS.xy, 0.0, 0.0))
#define SMAASample(tex, coord) tex2D(tex, coord)
#define SMAASamplePoint(tex, coord) tex2D(tex, coord)
#define SMAASampleOffset(tex, coord, offset) tex2D(tex, coord + offset * SMAA_RT_METRICS.xy)
#define SMAA_FLATTEN [flatten]
#define SMAA_BRANCH [branch]
#endif
#if defined(SMAA_HLSL_4) || defined(SMAA_HLSL_4_1)
SamplerState LinearSampler { Filter = MIN_MAG_LINEAR_MIP_POINT; AddressU = Clamp; AddressV = Clamp; };
SamplerState PointSampler { Filter = MIN_MAG_MIP_POINT; AddressU = Clamp; AddressV = Clamp; };
#define SMAATexture2D(tex) Texture2D tex
#define SMAATexturePass2D(tex) tex
#define SMAASampleLevelZero(tex, coord) tex.SampleLevel(LinearSampler, coord, 0)
#define SMAASampleLevelZeroPoint(tex, coord) tex.SampleLevel(PointSampler, coord, 0)
#define SMAASampleLevelZeroOffset(tex, coord, offset) tex.SampleLevel(LinearSampler, coord, 0, offset)
#define SMAASample(tex, coord) tex.Sample(LinearSampler, coord)
#define SMAASamplePoint(tex, coord) tex.Sample(PointSampler, coord)
#define SMAASampleOffset(tex, coord, offset) tex.Sample(LinearSampler, coord, offset)
#define SMAA_FLATTEN [flatten]
#define SMAA_BRANCH [branch]
#define SMAATexture2DMS2(tex) Texture2DMS<float4, 2> tex
#define SMAALoad(tex, pos, sample) tex.Load(pos, sample)
#if defined(SMAA_HLSL_4_1)
#define SMAAGather(tex, coord) tex.Gather(LinearSampler, coord, 0)
#endif
#endif
#if defined(SMAA_GLSL_3) || defined(SMAA_GLSL_4)
#define SMAATexture2D(tex) sampler2D tex
#define SMAATexturePass2D(tex) tex
#define SMAASampleLevelZero(tex, coord) textureLod(tex, coord, 0.0)
#define SMAASampleLevelZeroPoint(tex, coord) textureLod(tex, coord, 0.0)
#define SMAASampleLevelZeroOffset(tex, coord, offset) textureLodOffset(tex, coord, 0.0, offset)
#define SMAASample(tex, coord) texture(tex, coord)
#define SMAASamplePoint(tex, coord) texture(tex, coord)
#define SMAASampleOffset(tex, coord, offset) texture(tex, coord, offset)
#define SMAA_FLATTEN
#define SMAA_BRANCH
#define lerp(a, b, t) mix(a, b, t)
#define saturate(a) clamp(a, 0.0, 1.0)
#if defined(SMAA_GLSL_4)
#define mad(a, b, c) fma(a, b, c)
#define SMAAGather(tex, coord) textureGather(tex, coord)
#else
#define mad(a, b, c) (a * b + c)
#endif
#define float2 vec2
#define float3 vec3
#define float4 vec4
#define int2 ivec2
#define int3 ivec3
#define int4 ivec4
#define bool2 bvec2
#define bool3 bvec3
#define bool4 bvec4
#endif

#if !defined(SMAA_HLSL_3) && !defined(SMAA_HLSL_4) && !defined(SMAA_HLSL_4_1) && !defined(SMAA_GLSL_3) && !defined(SMAA_GLSL_4) && !defined(SMAA_CUSTOM_SL)
#error you must define the shading language: SMAA_HLSL_*, SMAA_GLSL_* or SMAA_CUSTOM_SL
#endif

//-----------------------------------------------------------------------------
// Misc functions

/**
 * Gathers current pixel, and the top-left neighbors.
 */
float3 SMAAGatherNeighbours(float2 texcoord,
                            float4 offset[3],
                            SMAATexture2D(tex)) {
    #ifdef SMAAGather
    return SMAAGather(tex, texcoord + SMAA_RT_METRICS.xy * float2(-0.5, -0.5)).grb;
    #else
    float P = SMAASamplePoint(tex, texcoord).r;
    float Pleft = SMAASamplePoint(tex, offset[0].xy).r;
    float Ptop  = SMAASamplePoint(tex, offset[0].zw).r;
    return float3(P, Pleft, Ptop);
    #endif
}

/**
 * Adjusts the threshold by means of predication.
 */
float2 SMAACalculatePredicatedThreshold(float2 texcoord,
                                        float4 offset[3],
                                        SMAATexture2D(predicationTex)) {
    float3 neighbours = SMAAGatherNeighbours(texcoord, offset, SMAATexturePass2D(predicationTex));
    float2 delta = abs(neighbours.xx - neighbours.yz);
    float2 edges = step(SMAA_PREDICATION_THRESHOLD, delta);
    return SMAA_PREDICATION_SCALE * SMAA_THRESHOLD * (1.0 - SMAA_PREDICATION_STRENGTH * edges);
}

/**
 * Conditional move:
 */
void SMAAMovc(bool2 cond, inout float2 variable, float2 value) {
    SMAA_FLATTEN if (cond.x) variable.x = value.x;
    SMAA_FLATTEN if (cond.y) variable.y = value.y;
}

void SMAAMovc(bool4 cond, inout float4 variable, float4 value) {
    SMAAMovc(cond.xy, variable.xy, value.xy);
    SMAAMovc(cond.zw, variable.zw, value.zw);
}


#if SMAA_INCLUDE_VS
//-----------------------------------------------------------------------------
// Vertex Shaders

/**
 * Edge Detection Vertex Shader
 */
void SMAAEdgeDetectionVS(float2 texcoord,
                         out float4 offset[3]) {
    offset[0] = mad(SMAA_RT_METRICS.xyxy, float4(-1.0, 0.0, 0.0, -1.0), texcoord.xyxy);
    offset[1] = mad(SMAA_RT_METRICS.xyxy, float4( 1.0, 0.0, 0.0,  1.0), texcoord.xyxy);
    offset[2] = mad(SMAA_RT_METRICS.xyxy, float4(-2.0, 0.0, 0.0, -2.0), texcoord.xyxy);
}

/**
 * Blend Weight Calculation Vertex Shader
 */
void SMAABlendingWeightCalculationVS(float2 texcoord,
                                     out float2 pixcoord,
                                     out float4 offset[3]) {
    pixcoord = texcoord * SMAA_RT_METRICS.zw;

    // We will use these offsets for the searches later on (see @PSEUDO_GATHER4):
    offset[0] = mad(SMAA_RT_METRICS.xyxy, float4(-0.25, -0.125,  1.25, -0.125), texcoord.xyxy);
    offset[1] = mad(SMAA_RT_METRICS.xyxy, float4(-0.125, -0.25, -0.125,  1.25), texcoord.xyxy);

    // And these for the searches, they indicate the ends of the loops:
    offset[2] = mad(SMAA_RT_METRICS.xxyy,
                    float4(-2.0, 2.0, -2.0, 2.0) * float(SMAA_MAX_SEARCH_STEPS),
                    float4(offset[0].xz, offset[1].yw));
}

/**
 * Neighborhood Blending Vertex Shader
 */
void SMAANeighborhoodBlendingVS(float2 texcoord,
                                out float4 offset) {
    offset = mad(SMAA_RT_METRICS.xyxy, float4( 1.0, 0.0, 0.0,  1.0), texcoord.xyxy);
}
#endif // SMAA_INCLUDE_VS

#if SMAA_INCLUDE_PS
//-----------------------------------------------------------------------------
// Edge Detection Pixel Shaders (First Pass)

/**
 * Luma Edge Detection
 *
 * IMPORTANT NOTICE: luma edge detection requires gamma-corrected colors, and
 * thus 'colorTex' should be a non-sRGB texture.
 */
float2 SMAALumaEdgeDetectionPS(float2 texcoord,
                               float4 offset[3],
                               SMAATexture2D(colorTex)
                               #if SMAA_PREDICATION
                               , SMAATexture2D(predicationTex)
                               #endif
                               ) {
    // Calculate the threshold:
    #if SMAA_PREDICATION
    float2 threshold = SMAACalculatePredicatedThreshold(texcoord, offset, SMAATexturePass2D(predicationTex));
    #else
    float2 threshold = float2(SMAA_THRESHOLD, SMAA_THRESHOLD);
    #endif

    // Calculate lumas:
    float3 weights = float3(0.2126, 0.7152, 0.0722);
    float L = dot(SMAASamplePoint(colorTex, texcoord).rgb, weights);

    float Lleft = dot(SMAASamplePoint(colorTex, offset[0].xy).rgb, weights);
    float Ltop  = dot(SMAASamplePoint(colorTex, offset[0].zw).rgb, weights);

    // We do the usual threshold:
    float4 delta;
    delta.xy = abs(L - float2(Lleft, Ltop));
    float2 edges = step(threshold, delta.xy);

    // Then discard if there is no edge:
    if (dot(edges, float2(1.0, 1.0)) == 0.0)
        discard;

    // Calculate right and bottom deltas:
    float Lright = dot(SMAASamplePoint(colorTex, offset[1].xy).rgb, weights);
    float Lbottom  = dot(SMAASamplePoint(colorTex, offset[1].zw).rgb, weights);
    delta.zw = abs(L - float2(Lright, Lbottom));

    // Calculate the maximum delta in the direct neighborhood:
    float2 maxDelta = max(delta.xy, delta.zw);

    // Calculate left-left and top-top deltas:
    float Lleftleft = dot(SMAASamplePoint(colorTex, offset[2].xy).rgb, weights);
    float Ltoptop = dot(SMAASamplePoint(colorTex, offset[2].zw).rgb, weights);
    delta.zw = abs(float2(Lleft, Ltop) - float2(Lleftleft, Ltoptop));

    // Calculate the final maximum delta:
    maxDelta = max(maxDelta.xy, delta.zw);
    float finalDelta = max(maxDelta.x, maxDelta.y);

    // Local contrast adaptation:
#if !defined(SHADER_API_OPENGL)
   edges.xy *= step(finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy);
#endif

    return edges;
}

/**
 * Color Edge Detection
 *
 * IMPORTANT NOTICE: color edge detection requires gamma-corrected colors, and
 * thus 'colorTex' should be a non-sRGB texture.
 */
float2 SMAAColorEdgeDetectionPS(float2 texcoord,
                                float4 offset[3],
                                SMAATexture2D(colorTex)
                                #if SMAA_PREDICATION
                                , SMAATexture2D(predicationTex)
                                #endif
                                ) {
    // Calculate the threshold:
    #if SMAA_PREDICATION
    float2 threshold = SMAACalculatePredicatedThreshold(texcoord, offset, predicationTex);
    #else
    float2 threshold = float2(SMAA_THRESHOLD, SMAA_THRESHOLD);
    #endif

    // Calculate color deltas:
    float4 delta;
    float3 C = SMAASamplePoint(colorTex, texcoord).rgb;

    float3 Cleft = SMAASamplePoint(colorTex, offset[0].xy).rgb;
    float3 t = abs(C - Cleft);
    delta.x = max(max(t.r, t.g), t.b);

    float3 Ctop  = SMAASamplePoint(colorTex, offset[0].zw).rgb;
    t = abs(C - Ctop);
    delta.y = max(max(t.r, t.g), t.b);

    // We do the usual threshold:
    float2 edges = step(threshold, delta.xy);

    // Then discard if there is no edge:
    if (dot(edges, float2(1.0, 1.0)) == 0.0)
        discard;

    // Calculate right and bottom deltas:
    float3 Cright = SMAASamplePoint(colorTex, offset[1].xy).rgb;
    t = abs(C - Cright);
    delta.z = max(max(t.r, t.g), t.b);

    float3 Cbottom  = SMAASamplePoint(colorTex, offset[1].zw).rgb;
    t = abs(C - Cbottom);
    delta.w = max(max(t.r, t.g), t.b);

    // Calculate the maximum delta in the direct neighborhood:
    float2 maxDelta = max(delta.xy, delta.zw);

    // Calculate left-left and top-top deltas:
    float3 Cleftleft  = SMAASamplePoint(colorTex, offset[2].xy).rgb;
    t = abs(C - Cleftleft);
    delta.z = max(max(t.r, t.g), t.b);

    float3 Ctoptop = SMAASamplePoint(colorTex, offset[2].zw).rgb;
    t = abs(C - Ctoptop);
    delta.w = max(max(t.r, t.g), t.b);

    // Calculate the final maximum delta:
    maxDelta = max(maxDelta.xy, delta.zw);
    float finalDelta = max(maxDelta.x, maxDelta.y);

    // Local contrast adaptation:
#if !defined(SHADER_API_OPENGL)
    edges.xy *= step(finalDelta, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR * delta.xy);
#endif

    return edges;
}

/**
 * Depth Edge Detection
 */
float2 SMAADepthEdgeDetectionPS(float2 texcoord,
                                float4 offset[3],
                                SMAATexture2D(depthTex)) {
    float3 neighbours = SMAAGatherNeighbours(texcoord, offset, SMAATexturePass2D(depthTex));
    float2 delta = abs(neighbours.xx - float2(neighbours.y, neighbours.z));
    float2 edges = step(SMAA_DEPTH_THRESHOLD, delta);

    if (dot(edges, float2(1.0, 1.0)) == 0.0)
        discard;

    return edges;
}

//-----------------------------------------------------------------------------
// Diagonal Search Functions

#if !defined(SMAA_DISABLE_DIAG_DETECTION)

/**
 * Allows to decode two binary values from a bilinear-filtered access.
 */
float2 SMAADecodeDiagBilinearAccess(float2 e) {
    // Bilinear access for fetching 'e' have a 0.25 offset, and we are
    // interested in the R and G edges:
    //
    // +---G---+-------+
    // |   x o R   x   |
    // +-------+-------+
    //
    // Then, if one of these edge is enabled:
    //   Red:   (0.75 * X + 0.25 * 1) => 0.25 or 1.0
    //   Green: (0.75 * 1 + 0.25 * X) => 0.75 or 1.0
    //
    // This function will unpack the values (mad + mul + round):
    // wolframalpha.com: round(x * abs(5 * x - 5 * 0.75)) plot 0 to 1
    e.r = e.r * abs(5.0 * e.r - 5.0 * 0.75);
    return round(e);
}

float4 SMAADecodeDiagBilinearAccess(float4 e) {
    e.rb = e.rb * abs(5.0 * e.rb - 5.0 * 0.75);
    return round(e);
}

/**
 * These functions allows to perform diagonal pattern searches.
 */
float2 SMAASearchDiag1(SMAATexture2D(edgesTex), float2 texcoord, float2 dir, out float2 e) {
    float4 coord = float4(texcoord, -1.0, 1.0);
    float3 t = float3(SMAA_RT_METRICS.xy, 1.0);
    while (coord.z < float(SMAA_MAX_SEARCH_STEPS_DIAG - 1) &&
           coord.w > 0.9) {
        coord.xyz = mad(t, float3(dir, 1.0), coord.xyz);
        e = SMAASampleLevelZero(edgesTex, coord.xy).rg;
        coord.w = dot(e, float2(0.5, 0.5));
    }
    return coord.zw;
}

float2 SMAASearchDiag2(SMAATexture2D(edgesTex), float2 texcoord, float2 dir, out float2 e) {
    float4 coord = float4(texcoord, -1.0, 1.0);
    coord.x += 0.25 * SMAA_RT_METRICS.x; // See @SearchDiag2Optimization
    float3 t = float3(SMAA_RT_METRICS.xy, 1.0);
    while (coord.z < float(SMAA_MAX_SEARCH_STEPS_DIAG - 1) &&
           coord.w > 0.9) {
        coord.xyz = mad(t, float3(dir, 1.0), coord.xyz);

        // @SearchDiag2Optimization
        // Fetch both edges at once using bilinear filtering:
        e = SMAASampleLevelZero(edgesTex, coord.xy).rg;
        e = SMAADecodeDiagBilinearAccess(e);

        // Non-optimized version:
        // e.g = SMAASampleLevelZero(edgesTex, coord.xy).g;
        // e.r = SMAASampleLevelZeroOffset(edgesTex, coord.xy, int2(1, 0)).r;

        coord.w = dot(e, float2(0.5, 0.5));
    }
    return coord.zw;
}

/** 
 * Similar to SMAAArea, this calculates the area corresponding to a certain
 * diagonal distance and crossing edges 'e'.
 */
float2 SMAAAreaDiag(SMAATexture2D(areaTex), float2 dist, float2 e, float offset) {
    float2 texcoord = mad(float2(SMAA_AREATEX_MAX_DISTANCE_DIAG, SMAA_AREATEX_MAX_DISTANCE_DIAG), e, dist);

    // We do a scale and bias for mapping to texel space:
    texcoord = mad(SMAA_AREATEX_PIXEL_SIZE, texcoord, 0.5 * SMAA_AREATEX_PIXEL_SIZE);

    // Diagonal areas are on the second half of the texture:
    texcoord.x += 0.5;

    // Move to proper place, according to the subpixel offset:
    texcoord.y += SMAA_AREATEX_SUBTEX_SIZE * offset;

    // Do it!
    return SMAA_AREATEX_SELECT(SMAASampleLevelZero(areaTex, texcoord));
}

/**
 * This searches for diagonal patterns and returns the corresponding weights.
 */
float2 SMAACalculateDiagWeights(SMAATexture2D(edgesTex), SMAATexture2D(areaTex), float2 texcoord, float2 e, float4 subsampleIndices) {
    float2 weights = float2(0.0, 0.0);

    // Search for the line ends:
    float4 d;
    float2 end;
    if (e.r > 0.0) {
        d.xz = SMAASearchDiag1(SMAATexturePass2D(edgesTex), texcoord, float2(-1.0,  1.0), end);
        d.x += float(end.y > 0.9);
    } else
        d.xz = float2(0.0, 0.0);
    d.yw = SMAASearchDiag1(SMAATexturePass2D(edgesTex), texcoord, float2(1.0, -1.0), end);

    SMAA_BRANCH
    if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3
        // Fetch the crossing edges:
        float4 coords = mad(float4(-d.x + 0.25, d.x, d.y, -d.y - 0.25), SMAA_RT_METRICS.xyxy, texcoord.xyxy);
        float4 c;
        c.xy = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1,  0)).rg;
        c.zw = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1,  0)).rg;
        c.yxwz = SMAADecodeDiagBilinearAccess(c.xyzw);

        // Non-optimized version:
        // float4 coords = mad(float4(-d.x, d.x, d.y, -d.y), SMAA_RT_METRICS.xyxy, texcoord.xyxy);
        // float4 c;
        // c.x = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1,  0)).g;
        // c.y = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2( 0,  0)).r;
        // c.z = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1,  0)).g;
        // c.w = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1, -1)).r;

        // Merge crossing edges at each side into a single value:
        float2 cc = mad(float2(2.0, 2.0), c.xz, c.yw);

        // Remove the crossing edge if we didn't found the end of the line:
        SMAAMovc(bool2(step(0.9, d.zw)), cc, float2(0.0, 0.0));

        // Fetch the areas for this line:
        weights += SMAAAreaDiag(SMAATexturePass2D(areaTex), d.xy, cc, subsampleIndices.z);
    }

    // Search for the line ends:
    d.xz = SMAASearchDiag2(SMAATexturePass2D(edgesTex), texcoord, float2(-1.0, -1.0), end);
    if (SMAASampleLevelZeroOffset(edgesTex, texcoord, int2(1, 0)).r > 0.0) {
        d.yw = SMAASearchDiag2(SMAATexturePass2D(edgesTex), texcoord, float2(1.0, 1.0), end);
        d.y += float(end.y > 0.9);
    } else
        d.yw = float2(0.0, 0.0);

    SMAA_BRANCH
    if (d.x + d.y > 2.0) { // d.x + d.y + 1 > 3
        // Fetch the crossing edges:
        float4 coords = mad(float4(-d.x, -d.x, d.y, d.y), SMAA_RT_METRICS.xyxy, texcoord.xyxy);
        float4 c;
        c.x  = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2(-1,  0)).g;
        c.y  = SMAASampleLevelZeroOffset(edgesTex, coords.xy, int2( 0, -1)).r;
        c.zw = SMAASampleLevelZeroOffset(edgesTex, coords.zw, int2( 1,  0)).gr;
        float2 cc = mad(float2(2.0, 2.0), c.xz, c.yw);

        // Remove the crossing edge if we didn't found the end of the line:
        SMAAMovc(bool2(step(0.9, d.zw)), cc, float2(0.0, 0.0));

        // Fetch the areas for this line:
        weights += SMAAAreaDiag(SMAATexturePass2D(areaTex), d.xy, cc, subsampleIndices.w).gr;
    }

    return weights;
}
#endif

//-----------------------------------------------------------------------------
// Horizontal/Vertical Search Functions

/**
 * This allows to determine how much length should we add in the last step
 * of the searches. It takes the bilinearly interpolated edge (see 
 * @PSEUDO_GATHER4), and adds 0, 1 or 2, depending on which edges and
 * crossing edges are active.
 */
float SMAASearchLength(SMAATexture2D(searchTex), float2 e, float offset) {
    // The texture is flipped vertically, with left and right cases taking half
    // of the space horizontally:
    float2 scale = SMAA_SEARCHTEX_SIZE * float2(0.5, -1.0);
    float2 bias = SMAA_SEARCHTEX_SIZE * float2(offset, 1.0);

    // Scale and bias to access texel centers:
    scale += float2(-1.0,  1.0);
    bias  += float2( 0.5, -0.5);

    // Convert from pixel coordinates to texcoords:
    // (We use SMAA_SEARCHTEX_PACKED_SIZE because the texture is cropped)
    scale *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE;
    bias *= 1.0 / SMAA_SEARCHTEX_PACKED_SIZE;

    // Lookup the search texture:
    return SMAA_SEARCHTEX_SELECT(SMAASampleLevelZero(searchTex, mad(scale, e, bias)));
}

/**
 * Horizontal/vertical search functions for the 2nd pass.
 */
float SMAASearchXLeft(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) {
    /**
     * @PSEUDO_GATHER4
     * This texcoord has been offset by (-0.25, -0.125) in the vertex shader to
     * sample between edge, thus fetching four edges in a row.
     * Sampling with different offsets in each direction allows to disambiguate
     * which edges are active from the four fetched ones.
     */
    float2 e = float2(0.0, 1.0);
    while (texcoord.x > end && 
           e.g > 0.8281 && // Is there some edge not activated?
           e.r == 0.0) { // Or is there a crossing edge that breaks the line?
        e = SMAASampleLevelZero(edgesTex, texcoord).rg;
        texcoord = mad(-float2(2.0, 0.0), SMAA_RT_METRICS.xy, texcoord);
    }

    float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.0), 3.25);
    return mad(SMAA_RT_METRICS.x, offset, texcoord.x);

    // Non-optimized version:
    // We correct the previous (-0.25, -0.125) offset we applied:
    // texcoord.x += 0.25 * SMAA_RT_METRICS.x;

    // The searches are bias by 1, so adjust the coords accordingly:
    // texcoord.x += SMAA_RT_METRICS.x;

    // Disambiguate the length added by the last step:
    // texcoord.x += 2.0 * SMAA_RT_METRICS.x; // Undo last step
    // texcoord.x -= SMAA_RT_METRICS.x * (255.0 / 127.0) * SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.0);
    // return mad(SMAA_RT_METRICS.x, offset, texcoord.x);
}

float SMAASearchXRight(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) {
    float2 e = float2(0.0, 1.0);
    while (texcoord.x < end && 
           e.g > 0.8281 && // Is there some edge not activated?
           e.r == 0.0) { // Or is there a crossing edge that breaks the line?
        e = SMAASampleLevelZero(edgesTex, texcoord).rg;
        texcoord = mad(float2(2.0, 0.0), SMAA_RT_METRICS.xy, texcoord);
    }
    float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e, 0.5), 3.25);
    return mad(-SMAA_RT_METRICS.x, offset, texcoord.x);
}

float SMAASearchYUp(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) {
    float2 e = float2(1.0, 0.0);
    while (texcoord.y > end && 
           e.r > 0.8281 && // Is there some edge not activated?
           e.g == 0.0) { // Or is there a crossing edge that breaks the line?
        e = SMAASampleLevelZero(edgesTex, texcoord).rg;
        texcoord = mad(-float2(0.0, 2.0), SMAA_RT_METRICS.xy, texcoord);
    }
    float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e.gr, 0.0), 3.25);
    return mad(SMAA_RT_METRICS.y, offset, texcoord.y);
}

float SMAASearchYDown(SMAATexture2D(edgesTex), SMAATexture2D(searchTex), float2 texcoord, float end) {
    float2 e = float2(1.0, 0.0);
    while (texcoord.y < end && 
           e.r > 0.8281 && // Is there some edge not activated?
           e.g == 0.0) { // Or is there a crossing edge that breaks the line?
        e = SMAASampleLevelZero(edgesTex, texcoord).rg;
        texcoord = mad(float2(0.0, 2.0), SMAA_RT_METRICS.xy, texcoord);
    }
    float offset = mad(-(255.0 / 127.0), SMAASearchLength(SMAATexturePass2D(searchTex), e.gr, 0.5), 3.25);
    return mad(-SMAA_RT_METRICS.y, offset, texcoord.y);
}

/** 
 * Ok, we have the distance and both crossing edges. So, what are the areas
 * at each side of current edge?
 */
float2 SMAAArea(SMAATexture2D(areaTex), float2 dist, float e1, float e2, float offset) {
    // Rounding prevents precision errors of bilinear filtering:
    float2 texcoord = mad(float2(SMAA_AREATEX_MAX_DISTANCE, SMAA_AREATEX_MAX_DISTANCE), round(4.0 * float2(e1, e2)), dist);
    
    // We do a scale and bias for mapping to texel space:
    texcoord = mad(SMAA_AREATEX_PIXEL_SIZE, texcoord, 0.5 * SMAA_AREATEX_PIXEL_SIZE);

    // Move to proper place, according to the subpixel offset:
    texcoord.y = mad(SMAA_AREATEX_SUBTEX_SIZE, offset, texcoord.y);

    // Do it!
    return SMAA_AREATEX_SELECT(SMAASampleLevelZero(areaTex, texcoord));
}

//-----------------------------------------------------------------------------
// Corner Detection Functions

void SMAADetectHorizontalCornerPattern(SMAATexture2D(edgesTex), inout float2 weights, float4 texcoord, float2 d) {
    #if !defined(SMAA_DISABLE_CORNER_DETECTION)
    float2 leftRight = step(d.xy, d.yx);
    float2 rounding = (1.0 - SMAA_CORNER_ROUNDING_NORM) * leftRight;

    rounding /= leftRight.x + leftRight.y; // Reduce blending for pixels in the center of a line.

    float2 factor = float2(1.0, 1.0);
    factor.x -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2(0,  1)).r;
    factor.x -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2(1,  1)).r;
    factor.y -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2(0, -2)).r;
    factor.y -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2(1, -2)).r;

    weights *= saturate(factor);
    #endif
}

void SMAADetectVerticalCornerPattern(SMAATexture2D(edgesTex), inout float2 weights, float4 texcoord, float2 d) {
    #if !defined(SMAA_DISABLE_CORNER_DETECTION)
    float2 leftRight = step(d.xy, d.yx);
    float2 rounding = (1.0 - SMAA_CORNER_ROUNDING_NORM) * leftRight;

    rounding /= leftRight.x + leftRight.y;

    float2 factor = float2(1.0, 1.0);
    factor.x -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2( 1, 0)).g;
    factor.x -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2( 1, 1)).g;
    factor.y -= rounding.x * SMAASampleLevelZeroOffset(edgesTex, texcoord.xy, int2(-2, 0)).g;
    factor.y -= rounding.y * SMAASampleLevelZeroOffset(edgesTex, texcoord.zw, int2(-2, 1)).g;

    weights *= saturate(factor);
    #endif
}

//-----------------------------------------------------------------------------
// Blending Weight Calculation Pixel Shader (Second Pass)

float4 SMAABlendingWeightCalculationPS(float2 texcoord,
                                       float2 pixcoord,
                                       float4 offset[3],
                                       SMAATexture2D(edgesTex),
                                       SMAATexture2D(areaTex),
                                       SMAATexture2D(searchTex),
                                       float4 subsampleIndices) { // Just pass zero for SMAA 1x, see @SUBSAMPLE_INDICES.
    float4 weights = float4(0.0, 0.0, 0.0, 0.0);

    float2 e = SMAASample(edgesTex, texcoord).rg;

    SMAA_BRANCH
    if (e.g > 0.0) { // Edge at north
        #if !defined(SMAA_DISABLE_DIAG_DETECTION)
        // Diagonals have both north and west edges, so searching for them in
        // one of the boundaries is enough.
        weights.rg = SMAACalculateDiagWeights(SMAATexturePass2D(edgesTex), SMAATexturePass2D(areaTex), texcoord, e, subsampleIndices);

        // We give priority to diagonals, so if we find a diagonal we skip 
        // horizontal/vertical processing.
        SMAA_BRANCH
        if (weights.r == -weights.g) { // weights.r + weights.g == 0.0
        #endif

        float2 d;

        // Find the distance to the left:
        float3 coords;
        coords.x = SMAASearchXLeft(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[0].xy, offset[2].x);
        coords.y = offset[1].y; // offset[1].y = texcoord.y - 0.25 * SMAA_RT_METRICS.y (@CROSSING_OFFSET)
        d.x = coords.x;

        // Now fetch the left crossing edges, two at a time using bilinear
        // filtering. Sampling at -0.25 (see @CROSSING_OFFSET) enables to
        // discern what value each edge has:
        float e1 = SMAASampleLevelZero(edgesTex, coords.xy).r;

        // Find the distance to the right:
        coords.z = SMAASearchXRight(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[0].zw, offset[2].y);
        d.y = coords.z;

        // We want the distances to be in pixel units (doing this here allow to
        // better interleave arithmetic and memory accesses):
        d = abs(round(mad(SMAA_RT_METRICS.zz, d, -pixcoord.xx)));

        // SMAAArea below needs a sqrt, as the areas texture is compressed
        // quadratically:
        float2 sqrt_d = sqrt(d);

        // Fetch the right crossing edges:
        float e2 = SMAASampleLevelZeroOffset(edgesTex, coords.zy, int2(1, 0)).r;

        // Ok, we know how this pattern looks like, now it is time for getting
        // the actual area:
        weights.rg = SMAAArea(SMAATexturePass2D(areaTex), sqrt_d, e1, e2, subsampleIndices.y);

        // Fix corners:
        coords.y = texcoord.y;
        SMAADetectHorizontalCornerPattern(SMAATexturePass2D(edgesTex), weights.rg, coords.xyzy, d);

        #if !defined(SMAA_DISABLE_DIAG_DETECTION)
        } else
            e.r = 0.0; // Skip vertical processing.
        #endif
    }

    SMAA_BRANCH
    if (e.r > 0.0) { // Edge at west
        float2 d;

        // Find the distance to the top:
        float3 coords;
        coords.y = SMAASearchYUp(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[1].xy, offset[2].z);
        coords.x = offset[0].x; // offset[1].x = texcoord.x - 0.25 * SMAA_RT_METRICS.x;
        d.x = coords.y;

        // Fetch the top crossing edges:
        float e1 = SMAASampleLevelZero(edgesTex, coords.xy).g;

        // Find the distance to the bottom:
        coords.z = SMAASearchYDown(SMAATexturePass2D(edgesTex), SMAATexturePass2D(searchTex), offset[1].zw, offset[2].w);
        d.y = coords.z;

        // We want the distances to be in pixel units:
        d = abs(round(mad(SMAA_RT_METRICS.ww, d, -pixcoord.yy)));

        // SMAAArea below needs a sqrt, as the areas texture is compressed 
        // quadratically:
        float2 sqrt_d = sqrt(d);

        // Fetch the bottom crossing edges:
        float e2 = SMAASampleLevelZeroOffset(edgesTex, coords.xz, int2(0, 1)).g;

        // Get the area for this direction:
        weights.ba = SMAAArea(SMAATexturePass2D(areaTex), sqrt_d, e1, e2, subsampleIndices.x);

        // Fix corners:
        coords.x = texcoord.x;
        SMAADetectVerticalCornerPattern(SMAATexturePass2D(edgesTex), weights.ba, coords.xyxz, d);
    }

    return weights;
}

//-----------------------------------------------------------------------------
// Neighborhood Blending Pixel Shader (Third Pass)

float4 SMAANeighborhoodBlendingPS(float2 texcoord,
                                  float4 offset,
                                  SMAATexture2D(colorTex),
                                  SMAATexture2D(blendTex)
                                  #if SMAA_REPROJECTION
                                  , SMAATexture2D(velocityTex)
                                  #endif
                                  ) {
    // Fetch the blending weights for current pixel:
    float4 a;
    a.x = SMAASample(blendTex, offset.xy).a; // Right
    a.y = SMAASample(blendTex, offset.zw).g; // Top
    a.wz = SMAASample(blendTex, texcoord).xz; // Bottom / Left

    // Is there any blending weight with a value greater than 0.0?
    SMAA_BRANCH
    if (dot(a, float4(1.0, 1.0, 1.0, 1.0)) < 1e-5) {
        float4 color = SMAASampleLevelZero(colorTex, texcoord);

        #if SMAA_REPROJECTION
        float2 velocity = SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, texcoord));

        // Pack velocity into the alpha channel:
        color.a = sqrt(5.0 * length(velocity));
        #endif

        return color;
    } else {
        bool h = max(a.x, a.z) > max(a.y, a.w); // max(horizontal) > max(vertical)

        // Calculate the blending offsets:
        float4 blendingOffset = float4(0.0, a.y, 0.0, a.w);
        float2 blendingWeight = a.yw;
        SMAAMovc(bool4(h, h, h, h), blendingOffset, float4(a.x, 0.0, a.z, 0.0));
        SMAAMovc(bool2(h, h), blendingWeight, a.xz);
        blendingWeight /= dot(blendingWeight, float2(1.0, 1.0));

        // Calculate the texture coordinates:
        float4 blendingCoord = mad(blendingOffset, float4(SMAA_RT_METRICS.xy, -SMAA_RT_METRICS.xy), texcoord.xyxy);

        // We exploit bilinear filtering to mix current pixel with the chosen
        // neighbor:
        float4 color = blendingWeight.x * SMAASampleLevelZero(colorTex, blendingCoord.xy);
        color += blendingWeight.y * SMAASampleLevelZero(colorTex, blendingCoord.zw);

        #if SMAA_REPROJECTION
        // Antialias velocity for proper reprojection in a later stage:
        float2 velocity = blendingWeight.x * SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, blendingCoord.xy));
        velocity += blendingWeight.y * SMAA_DECODE_VELOCITY(SMAASampleLevelZero(velocityTex, blendingCoord.zw));

        // Pack velocity into the alpha channel:
        color.a = sqrt(5.0 * length(velocity));
        #endif

        return color;
    }
}

//-----------------------------------------------------------------------------
// Temporal Resolve Pixel Shader (Optional Pass)

float4 SMAAResolvePS(float2 texcoord,
                     SMAATexture2D(currentColorTex),
                     SMAATexture2D(previousColorTex)
                     #if SMAA_REPROJECTION
                     , SMAATexture2D(velocityTex)
                     #endif
                     ) {
    #if SMAA_REPROJECTION
    // Velocity is assumed to be calculated for motion blur, so we need to
    // inverse it for reprojection:
    float2 velocity = -SMAA_DECODE_VELOCITY(SMAASamplePoint(velocityTex, texcoord).rg);

    // Fetch current pixel:
    float4 current = SMAASamplePoint(currentColorTex, texcoord);

    // Reproject current coordinates and fetch previous pixel:
    float4 previous = SMAASamplePoint(previousColorTex, texcoord + velocity);

    // Attenuate the previous pixel if the velocity is different:
    float delta = abs(current.a * current.a - previous.a * previous.a) / 5.0;
    float weight = 0.5 * saturate(1.0 - sqrt(delta) * SMAA_REPROJECTION_WEIGHT_SCALE);

    // Blend the pixels according to the calculated weight:
    return lerp(current, previous, weight);
    #else
    // Just blend the pixels:
    float4 current = SMAASamplePoint(currentColorTex, texcoord);
    float4 previous = SMAASamplePoint(previousColorTex, texcoord);
    return lerp(current, previous, 0.5);
    #endif
}

//-----------------------------------------------------------------------------
// Separate Multisamples Pixel Shader (Optional Pass)

#ifdef SMAALoad
void SMAASeparatePS(float4 position,
                    float2 texcoord,
                    out float4 target0,
                    out float4 target1,
                    SMAATexture2DMS2(colorTexMS)) {
    int2 pos = int2(position.xy);
    target0 = SMAALoad(colorTexMS, pos, 0);
    target1 = SMAALoad(colorTexMS, pos, 1);
}
#endif

//-----------------------------------------------------------------------------
#endif // SMAA_INCLUDE_PS


================================================
FILE: SMAA/Shaders/SMAA.cginc.meta
================================================
fileFormatVersion: 2
guid: 74597699f47d8ae458dca68f79f1b21f
timeCreated: 1430504573
licenseType: Free
ShaderImporter:
  defaultTextures: []
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Shaders/SMAA.shader
================================================
/*
 * Copyright (c) 2015 Thomas Hourdel
 *
 * This software is provided 'as-is', without any express or implied
 * warranty. In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 * 
 *    1. The origin of this software must not be misrepresented; you must not
 *    claim that you wrote the original software. If you use this software
 *    in a product, an acknowledgment in the product documentation would be
 *    appreciated but is not required.
 * 
 *    2. Altered source versions must be plainly marked as such, and must not be
 *    misrepresented as being the original software.
 * 
 *    3. This notice may not be removed or altered from any source
 *    distribution.
 */

Shader "Hidden/Subpixel Morphological Antialiasing"
{
	Properties
	{
		_MainTex ("Base (RGB)", 2D) = "white" {}
	}

	CGINCLUDE
	
		#pragma fragmentoption ARB_precision_hint_fastest 
		#pragma target 3.0
		#pragma glsl
		#pragma exclude_renderers flash
		
		sampler2D _MainTex;
		sampler2D _BlendTex;
		sampler2D _AreaTex;
		sampler2D _SearchTex;

		sampler2D _CameraDepthTexture;
		
		float4 _MainTex_TexelSize;

		float4 _Metrics; // 1f / width, 1f / height, width, height
		float4 _Params1; // SMAA_THRESHOLD, SMAA_DEPTH_THRESHOLD, SMAA_MAX_SEARCH_STEPS, SMAA_MAX_SEARCH_STEPS_DIAG
		float2 _Params2; // SMAA_CORNER_ROUNDING, SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR
		float3 _Params3; // SMAA_PREDICATION_THRESHOLD, SMAA_PREDICATION_SCALE, SMAA_PREDICATION_STRENGTH

		#define SMAA_RT_METRICS _Metrics
		#define SMAA_THRESHOLD _Params1.x
		#define SMAA_DEPTH_THRESHOLD _Params1.y
		#define SMAA_MAX_SEARCH_STEPS _Params1.z
		#define SMAA_MAX_SEARCH_STEPS_DIAG _Params1.w
		#define SMAA_CORNER_ROUNDING _Params2.x
		#define SMAA_LOCAL_CONTRAST_ADAPTATION_FACTOR _Params2.y
		#define SMAA_PREDICATION_THRESHOLD _Params3.x
		#define SMAA_PREDICATION_SCALE _Params3.y
		#define SMAA_PREDICATION_STRENGTH _Params3.z

		// Can't use SMAA_HLSL_3 as it won't compile with OpenGL, so lets make our own set of defines for Unity
		#define SMAA_CUSTOM_SL

		#define mad(a, b, c) (a * b + c)
		#define SMAATexture2D(tex) sampler2D tex
		#define SMAATexturePass2D(tex) tex
		#define SMAASampleLevelZero(tex, coord) tex2Dlod(tex, float4(coord, 0.0, 0.0))
		#define SMAASampleLevelZeroPoint(tex, coord) tex2Dlod(tex, float4(coord, 0.0, 0.0))
		#define SMAASampleLevelZeroOffset(tex, coord, offset) tex2Dlod(tex, float4(coord + offset * SMAA_RT_METRICS.xy, 0.0, 0.0))
		#define SMAASample(tex, coord) tex2D(tex, coord)
		#define SMAASamplePoint(tex, coord) tex2D(tex, coord)
		#define SMAASampleOffset(tex, coord, offset) tex2D(tex, coord + offset * SMAA_RT_METRICS.xy)

		#define SMAA_FLATTEN UNITY_FLATTEN
		#define SMAA_BRANCH UNITY_BRANCH
		// SMAA_CUSTOM_SL

		#define SMAA_AREATEX_SELECT(sample) sample.rg
		#define SMAA_SEARCHTEX_SELECT(sample) sample.a
		#define SMAA_INCLUDE_VS 0

		struct vInput
		{
			float4 pos : POSITION;
			float2 uv : TEXCOORD0;
		};

		struct fInput_edge
		{
			float4 pos : SV_POSITION;
			float2 uv : TEXCOORD0;
			float4 offset[3] : TEXCOORD1;
		};

		fInput_edge vert_edge(vInput i)
		{
			fInput_edge o;
			o.pos = mul(UNITY_MATRIX_MVP, i.pos);
			o.uv = i.uv;

			#if UNITY_UV_STARTS_AT_TOP
			if (_MainTex_TexelSize.y < 0)
				o.uv.y = 1.0 - o.uv.y;
			#endif

			o.offset[0] = mad(SMAA_RT_METRICS.xyxy, float4(-1.0, 0.0, 0.0, -1.0), o.uv.xyxy);
			o.offset[1] = mad(SMAA_RT_METRICS.xyxy, float4( 1.0, 0.0, 0.0,  1.0), o.uv.xyxy);
			o.offset[2] = mad(SMAA_RT_METRICS.xyxy, float4(-2.0, 0.0, 0.0, -2.0), o.uv.xyxy);
			return o;
		}

	ENDCG

	SubShader
	{
		ZTest Always Cull Off ZWrite Off
		Fog { Mode off }

		// (0) Clear
		Pass
		{
			CGPROGRAM

				#pragma vertex vert_img
				#pragma fragment frag
				#include "UnityCG.cginc"

				float4 frag(v2f_img i) : COLOR
				{
					return float4(0.0, 0.0, 0.0, 0.0);
				}

			ENDCG
		}


		// -----------------------------------------------------------------------------
		// Edge Detection

		// (1) Luma
		Pass
		{
			// TODO: Stencil not working
		//	Stencil
		//	{
		//		Pass replace
		//		Ref 1
		//	}

			CGPROGRAM

				#pragma vertex vert_edge
				#pragma fragment frag
				#pragma multi_compile __ USE_PREDICATION

				#if USE_PREDICATION
				#define SMAA_PREDICATION 1
				#else
				#define SMAA_PREDICATION 0
				#endif

				#include "UnityCG.cginc"
				#include "SMAA.cginc"

				float4 frag(fInput_edge i) : COLOR
				{
					#if SMAA_PREDICATION
					return float4(SMAALumaEdgeDetectionPS(i.uv, i.offset, _MainTex, _CameraDepthTexture), 0.0, 0.0);
					#else
					return float4(SMAALumaEdgeDetectionPS(i.uv, i.offset, _MainTex), 0.0, 0.0);
					#endif
				}

			ENDCG
		}

		// (2) Color
		Pass
		{
			// TODO: Stencil not working
		//	Stencil
		//	{
		//		Pass replace
		//		Ref 1
		//	}

			CGPROGRAM

				#pragma vertex vert_edge
				#pragma fragment frag
				#pragma multi_compile __ USE_PREDICATION

				#if USE_PREDICATION
				#define SMAA_PREDICATION 1
				#else
				#define SMAA_PREDICATION 0
				#endif

				#include "UnityCG.cginc"
				#include "SMAA.cginc"

				float4 frag(fInput_edge i) : COLOR
				{
					#if SMAA_PREDICATION
					return float4(SMAAColorEdgeDetectionPS(i.uv, i.offset, _MainTex, _CameraDepthTexture), 0.0, 0.0);
					#else
					return float4(SMAAColorEdgeDetectionPS(i.uv, i.offset, _MainTex), 0.0, 0.0);
					#endif
				}

			ENDCG
		}

		// (3) Depth
		Pass
		{
			// TODO: Stencil not working
		//	Stencil
		//	{
		//		Pass replace
		//		Ref 1
		//	}

			CGPROGRAM

				#pragma vertex vert_edge
				#pragma fragment frag

				#define SMAA_PREDICATION 0

				#include "UnityCG.cginc"
				#include "SMAA.cginc"

				float4 frag(fInput_edge i) : COLOR
				{
					return float4(SMAADepthEdgeDetectionPS(i.uv, i.offset, _CameraDepthTexture), 0.0, 0.0);
				}

			ENDCG
		}


		// -----------------------------------------------------------------------------
		// Blend Weights Calculation

		// (4) 
		Pass
		{
			// TODO: Stencil not working
		//	Stencil
		//	{
		//		Pass keep
		//		Comp equal
		//		Ref 1
		//	}

			CGPROGRAM

				#pragma vertex vert
				#pragma fragment frag
				#pragma multi_compile __ USE_DIAG_SEARCH
				#pragma multi_compile __ USE_CORNER_DETECTION

				#if !defined(USE_DIAG_SEARCH)
				#define SMAA_DISABLE_DIAG_DETECTION
				#endif

				#if !defined(USE_CORNER_DETECTION)
				#define SMAA_DISABLE_CORNER_DETECTION
				#endif

				#include "UnityCG.cginc"
				#include "SMAA.cginc"

				struct fInput
				{
					float4 pos : SV_POSITION;
					float2 uv : TEXCOORD0;
					float2 pixcoord : TEXCOORD1;
					float4 offset[3] : TEXCOORD2;
				};

				fInput vert(vInput i)
				{
					fInput o;
					o.pos = mul(UNITY_MATRIX_MVP, i.pos);
					o.uv = i.uv;
					o.pixcoord = o.uv * SMAA_RT_METRICS.zw;
	
					// We will use these offsets for the searches later on (see @PSEUDO_GATHER4):
					o.offset[0] = mad(SMAA_RT_METRICS.xyxy, float4(-0.25, -0.125,  1.25, -0.125), o.uv.xyxy);
					o.offset[1] = mad(SMAA_RT_METRICS.xyxy, float4(-0.125, -0.25, -0.125,  1.25), o.uv.xyxy);
	
					// And these for the searches, they indicate the ends of the loops:
					o.offset[2] = mad(SMAA_RT_METRICS.xxyy, float4(-2.0, 2.0, -2.0, 2.0) * float(SMAA_MAX_SEARCH_STEPS),
									float4(o.offset[0].xz, o.offset[1].yw));

					return o;
				}

				float4 frag(fInput i) : COLOR
				{
					return SMAABlendingWeightCalculationPS(i.uv, i.pixcoord, i.offset, _MainTex, _AreaTex, _SearchTex,
									float4(0.0, 0.0, 0.0, 0.0));
				}

			ENDCG
		}


		// -----------------------------------------------------------------------------
		// Neighborhood Blending

		// (5)
		Pass
		{
			CGPROGRAM

				#pragma vertex vert
				#pragma fragment frag
				#include "UnityCG.cginc"
				#include "SMAA.cginc"

				struct fInput
				{
					float4 pos : SV_POSITION;
					float2 uv : TEXCOORD0;
					float4 offset : TEXCOORD1;
				};

				fInput vert(vInput i)
				{
					fInput o;
					o.pos = mul(UNITY_MATRIX_MVP, i.pos);
					o.uv = i.uv;
					o.offset = mad(SMAA_RT_METRICS.xyxy, float4(1.0, 0.0, 0.0, 1.0), o.uv.xyxy);
					return o;
				}

				float4 frag(fInput i) : COLOR
				{
					return SMAANeighborhoodBlendingPS(i.uv, i.offset, _MainTex, _BlendTex);
				}

			ENDCG
		}
	}

	FallBack off
}

================================================
FILE: SMAA/Shaders/SMAA.shader.meta
================================================
fileFormatVersion: 2
guid: 461ad39340fd1bf4e8d9fe310c58be95
timeCreated: 1430516548
licenseType: Free
ShaderImporter:
  defaultTextures: []
  userData: 
  assetBundleName: 
  assetBundleVariant: 


================================================
FILE: SMAA/Shaders.meta
================================================
fileFormatVersion: 2
guid: a1279565d377eb14fbb35abda9a2af97
folderAsset: yes
timeCreated: 1430504512
licenseType: Free
DefaultImporter:
  userData: 
  assetBundleName: 
  assetBundleVariant: 
Download .txt
gitextract__ohsqf1u/

├── .gitignore
├── LICENSE.txt
├── README.md
└── SMAA/
    ├── Resources/
    │   ├── AreaTex.tga
    │   ├── AreaTex.tga.meta
    │   ├── SearchTex.tga
    │   └── SearchTex.tga.meta
    ├── Resources.meta
    ├── Scripts/
    │   ├── DebugPass.cs
    │   ├── DebugPass.cs.meta
    │   ├── EdgeDetectionMethod.cs
    │   ├── EdgeDetectionMethod.cs.meta
    │   ├── Editor/
    │   │   ├── MinDrawer.cs
    │   │   ├── MinDrawer.cs.meta
    │   │   ├── SMAAEditor.cs
    │   │   └── SMAAEditor.cs.meta
    │   ├── Editor.meta
    │   ├── HDRMode.cs
    │   ├── HDRMode.cs.meta
    │   ├── MinAttribute.cs
    │   ├── MinAttribute.cs.meta
    │   ├── PredicationPreset.cs
    │   ├── PredicationPreset.cs.meta
    │   ├── Preset.cs
    │   ├── Preset.cs.meta
    │   ├── QualityPreset.cs
    │   ├── QualityPreset.cs.meta
    │   ├── SMAA.cs
    │   └── SMAA.cs.meta
    ├── Scripts.meta
    ├── Shaders/
    │   ├── SMAA.cginc
    │   ├── SMAA.cginc.meta
    │   ├── SMAA.shader
    │   └── SMAA.shader.meta
    └── Shaders.meta
Download .txt
SYMBOL INDEX (22 symbols across 10 files)

FILE: SMAA/Scripts/DebugPass.cs
  type DebugPass (line 29) | public enum DebugPass

FILE: SMAA/Scripts/EdgeDetectionMethod.cs
  type EdgeDetectionMethod (line 31) | public enum EdgeDetectionMethod

FILE: SMAA/Scripts/Editor/MinDrawer.cs
  class MinDrawer (line 30) | [CustomPropertyDrawer(typeof(MinAttribute))]
    method OnGUI (line 33) | public override void OnGUI(Rect position, SerializedProperty property,...

FILE: SMAA/Scripts/Editor/SMAAEditor.cs
  class SMAAEditor (line 30) | [CustomEditor(typeof(SMAA))]
    method OnEnable (line 54) | void OnEnable()
    method OnInspectorGUI (line 78) | public override void OnInspectorGUI()
    method IsOpenGL (line 140) | bool IsOpenGL()

FILE: SMAA/Scripts/HDRMode.cs
  type HDRMode (line 29) | public enum HDRMode

FILE: SMAA/Scripts/MinAttribute.cs
  class MinAttribute (line 31) | public sealed class MinAttribute : PropertyAttribute
    method MinAttribute (line 42) | public MinAttribute(float min)

FILE: SMAA/Scripts/PredicationPreset.cs
  class PredicationPreset (line 9) | [Serializable]

FILE: SMAA/Scripts/Preset.cs
  class Preset (line 32) | [Serializable]

FILE: SMAA/Scripts/QualityPreset.cs
  type QualityPreset (line 29) | public enum QualityPreset

FILE: SMAA/Scripts/SMAA.cs
  class SMAA (line 32) | #if UNITY_5_4_OR_NEWER
    method OnEnable (line 133) | void OnEnable()
    method Start (line 149) | void Start()
    method OnDisable (line 163) | void OnDisable()
    method OnRenderImage (line 176) | void OnRenderImage(RenderTexture source, RenderTexture destination)
    method Clear (line 267) | void Clear(RenderTexture rt)
    method TempRT (line 272) | RenderTexture TempRT(int width, int height, RenderTextureFormat format)
    method CreatePresets (line 281) | void CreatePresets()
Condensed preview — 35 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (111K chars).
[
  {
    "path": ".gitignore",
    "chars": 500,
    "preview": "# =============== #\n# Unity generated #\n# =============== #\n[Tt]emp/\n[Oo]bj/\n[Bb]uild\n[Ll]ibrary/\nsysinfo.txt\nLICENSE.tx"
  },
  {
    "path": "LICENSE.txt",
    "chars": 870,
    "preview": "Copyright (c) 2015 Thomas Hourdel\n\nThis software is provided 'as-is', without any express or implied\nwarranty. In no eve"
  },
  {
    "path": "README.md",
    "chars": 1427,
    "preview": "# SMAA for Unity3D\n\nThis is a highly customizable implementation of [Subpixel Morphological Antialiasing](http://www.iry"
  },
  {
    "path": "SMAA/Resources/AreaTex.tga.meta",
    "chars": 1160,
    "preview": "fileFormatVersion: 2\nguid: 7a7a7bb321416fa4d8ba53a700ae8140\ntimeCreated: 1430506045\nlicenseType: Free\nTextureImporter:\n "
  },
  {
    "path": "SMAA/Resources/SearchTex.tga.meta",
    "chars": 1156,
    "preview": "fileFormatVersion: 2\nguid: 3e01b396685ee1f48ac664c99ac95201\ntimeCreated: 1430506045\nlicenseType: Free\nTextureImporter:\n "
  },
  {
    "path": "SMAA/Resources.meta",
    "chars": 192,
    "preview": "fileFormatVersion: 2\nguid: 9362798305520c448b294dd314a7daff\nfolderAsset: yes\ntimeCreated: 1430505545\nlicenseType: Free\nD"
  },
  {
    "path": "SMAA/Scripts/DebugPass.cs",
    "chars": 1362,
    "preview": "/*\n * Copyright (c) 2015 Thomas Hourdel\n *\n * This software is provided 'as-is', without any express or implied\n * warr"
  },
  {
    "path": "SMAA/Scripts/DebugPass.cs.meta",
    "chars": 263,
    "preview": "fileFormatVersion: 2\nguid: 3e933ae326e948a44b9662a4675dbcfc\ntimeCreated: 1431287415\nlicenseType: Free\nMonoImporter:\n  se"
  },
  {
    "path": "SMAA/Scripts/EdgeDetectionMethod.cs",
    "chars": 1746,
    "preview": "/*\n * Copyright (c) 2015 Thomas Hourdel\n *\n * This software is provided 'as-is', without any express or implied\n * warr"
  },
  {
    "path": "SMAA/Scripts/EdgeDetectionMethod.cs.meta",
    "chars": 263,
    "preview": "fileFormatVersion: 2\nguid: 15c15283c1eeea24c9a822489a0c579b\ntimeCreated: 1431287415\nlicenseType: Free\nMonoImporter:\n  se"
  },
  {
    "path": "SMAA/Scripts/Editor/MinDrawer.cs",
    "chars": 1772,
    "preview": "/*\n * Copyright (c) 2015 Thomas Hourdel\n *\n * This software is provided 'as-is', without any express or implied\n * warr"
  },
  {
    "path": "SMAA/Scripts/Editor/MinDrawer.cs.meta",
    "chars": 263,
    "preview": "fileFormatVersion: 2\nguid: 4eb60e20a77aac94f92280b99b955c68\ntimeCreated: 1430588717\nlicenseType: Free\nMonoImporter:\n  se"
  },
  {
    "path": "SMAA/Scripts/Editor/SMAAEditor.cs",
    "chars": 8887,
    "preview": "/*\n * Copyright (c) 2015 Thomas Hourdel\n *\n * This software is provided 'as-is', without any express or implied\n * warr"
  },
  {
    "path": "SMAA/Scripts/Editor/SMAAEditor.cs.meta",
    "chars": 263,
    "preview": "fileFormatVersion: 2\nguid: 5c2ffc06b5a6ee64d8e1d9bdf074732c\ntimeCreated: 1430643832\nlicenseType: Free\nMonoImporter:\n  se"
  },
  {
    "path": "SMAA/Scripts/Editor.meta",
    "chars": 192,
    "preview": "fileFormatVersion: 2\nguid: 3ab9eab0d04085b4abd47b6b0657143c\nfolderAsset: yes\ntimeCreated: 1430588699\nlicenseType: Free\nD"
  },
  {
    "path": "SMAA/Scripts/HDRMode.cs",
    "chars": 1129,
    "preview": "/*\n * Copyright (c) 2015 Thomas Hourdel\n *\n * This software is provided 'as-is', without any express or implied\n * warr"
  },
  {
    "path": "SMAA/Scripts/HDRMode.cs.meta",
    "chars": 263,
    "preview": "fileFormatVersion: 2\nguid: d1c3b49b0d034e44381bd74595c02ca0\ntimeCreated: 1431606116\nlicenseType: Free\nMonoImporter:\n  se"
  },
  {
    "path": "SMAA/Scripts/MinAttribute.cs",
    "chars": 1446,
    "preview": "/*\n * Copyright (c) 2015 Thomas Hourdel\n *\n * This software is provided 'as-is', without any express or implied\n * warr"
  },
  {
    "path": "SMAA/Scripts/MinAttribute.cs.meta",
    "chars": 263,
    "preview": "fileFormatVersion: 2\nguid: a8298e5a2f9a3d441a7ea7fdb59abc47\ntimeCreated: 1430588352\nlicenseType: Free\nMonoImporter:\n  se"
  },
  {
    "path": "SMAA/Scripts/PredicationPreset.cs",
    "chars": 695,
    "preview": "using UnityEngine;\nusing System;\n\nnamespace Smaa\n{\n\t/// <summary>\n\t/// Holds a set of settings to use when <see cref=\"S"
  },
  {
    "path": "SMAA/Scripts/PredicationPreset.cs.meta",
    "chars": 263,
    "preview": "fileFormatVersion: 2\nguid: 33a1732f95161474781f227bc66bdda6\ntimeCreated: 1430644344\nlicenseType: Free\nMonoImporter:\n  se"
  },
  {
    "path": "SMAA/Scripts/Preset.cs",
    "chars": 3562,
    "preview": "/*\n * Copyright (c) 2015 Thomas Hourdel\n *\n * This software is provided 'as-is', without any express or implied\n * warr"
  },
  {
    "path": "SMAA/Scripts/Preset.cs.meta",
    "chars": 263,
    "preview": "fileFormatVersion: 2\nguid: a0440e1a7888f194e9c8e35089dc10f5\ntimeCreated: 1430588349\nlicenseType: Free\nMonoImporter:\n  se"
  },
  {
    "path": "SMAA/Scripts/QualityPreset.cs",
    "chars": 1574,
    "preview": "/*\n * Copyright (c) 2015 Thomas Hourdel\n *\n * This software is provided 'as-is', without any express or implied\n * warr"
  },
  {
    "path": "SMAA/Scripts/QualityPreset.cs.meta",
    "chars": 263,
    "preview": "fileFormatVersion: 2\nguid: 464c264d2294dc04cbdbc1cbb16257cc\ntimeCreated: 1431287415\nlicenseType: Free\nMonoImporter:\n  se"
  },
  {
    "path": "SMAA/Scripts/SMAA.cs",
    "chars": 9368,
    "preview": "/*\n * Copyright (c) 2015 Thomas Hourdel\n *\n * This software is provided 'as-is', without any express or implied\n * warr"
  },
  {
    "path": "SMAA/Scripts/SMAA.cs.meta",
    "chars": 501,
    "preview": "fileFormatVersion: 2\nguid: 1ec5688dc97c94c41a2bf37f0a513c2e\ntimeCreated: 1430517145\nlicenseType: Free\nMonoImporter:\n  se"
  },
  {
    "path": "SMAA/Scripts.meta",
    "chars": 192,
    "preview": "fileFormatVersion: 2\nguid: f13cc60e1465b9e4da5321b0b73c6849\nfolderAsset: yes\ntimeCreated: 1430504509\nlicenseType: Free\nD"
  },
  {
    "path": "SMAA/Shaders/SMAA.cginc",
    "chars": 54585,
    "preview": "// Ported to Unity by Thomas Hourdel (thomas.hourdel@gmail.com)\n\n/**\n * Copyright (C) 2013 Jorge Jimenez (jorge@iryoku.c"
  },
  {
    "path": "SMAA/Shaders/SMAA.cginc.meta",
    "chars": 196,
    "preview": "fileFormatVersion: 2\nguid: 74597699f47d8ae458dca68f79f1b21f\ntimeCreated: 1430504573\nlicenseType: Free\nShaderImporter:\n  "
  },
  {
    "path": "SMAA/Shaders/SMAA.shader",
    "chars": 8448,
    "preview": "/*\n * Copyright (c) 2015 Thomas Hourdel\n *\n * This software is provided 'as-is', without any express or implied\n * warr"
  },
  {
    "path": "SMAA/Shaders/SMAA.shader.meta",
    "chars": 196,
    "preview": "fileFormatVersion: 2\nguid: 461ad39340fd1bf4e8d9fe310c58be95\ntimeCreated: 1430516548\nlicenseType: Free\nShaderImporter:\n  "
  },
  {
    "path": "SMAA/Shaders.meta",
    "chars": 192,
    "preview": "fileFormatVersion: 2\nguid: a1279565d377eb14fbb35abda9a2af97\nfolderAsset: yes\ntimeCreated: 1430504512\nlicenseType: Free\nD"
  }
]

// ... and 2 more files (download for full content)

About this extraction

This page contains the full source code of the Chman/SMAA-Unity GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 35 files (101.3 KB), approximately 29.9k tokens, and a symbol index with 22 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.

Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.

Copied to clipboard!