├── .gitignore ├── Assets ├── ColorSuite.meta ├── ColorSuite │ ├── ColorSuite.cs │ ├── ColorSuite.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── ColorSuiteEditor.cs │ │ └── ColorSuiteEditor.cs.meta │ ├── Shader.meta │ └── Shader │ │ ├── ColorSuite.shader │ │ └── ColorSuite.shader.meta ├── DeferredAO.meta ├── DeferredAO │ ├── DeferredAO.cs │ ├── DeferredAO.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── DeferredAOEditor.cs │ │ └── DeferredAOEditor.cs.meta │ ├── Shader.meta │ └── Shader │ │ ├── DeferredAO.shader │ │ └── DeferredAO.shader.meta ├── Editor.meta ├── Editor │ ├── ImageEffects.meta │ ├── ImageEffects │ │ ├── VignetteAndChromaticAberrationEditor.cs │ │ └── VignetteAndChromaticAberrationEditor.cs.meta │ ├── PackageTool.cs │ └── PackageTool.cs.meta ├── HexBokeh.meta ├── HexBokeh │ ├── Editor.meta │ ├── Editor │ │ ├── HexBokehEditor.cs │ │ └── HexBokehEditor.cs.meta │ ├── HexBokeh.cs │ ├── HexBokeh.cs.meta │ ├── Shader.meta │ └── Shader │ │ ├── HexBokeh.shader │ │ └── HexBokeh.shader.meta ├── Kino.meta ├── Kino │ ├── Fog.meta │ └── Fog │ │ ├── Editor.meta │ │ ├── Editor │ │ ├── FogEditor.cs │ │ └── FogEditor.cs.meta │ │ ├── Fog.cs │ │ ├── Fog.cs.meta │ │ ├── Shader.meta │ │ └── Shader │ │ ├── Fog.shader │ │ └── Fog.shader.meta ├── Kvant.meta ├── Kvant │ ├── Ribbon.meta │ ├── Ribbon │ │ ├── ClassicNoise3D.cginc │ │ ├── ClassicNoise3D.cginc.meta │ │ ├── Kernels.shader │ │ ├── Kernels.shader.meta │ │ ├── Ribbon.cs │ │ ├── Ribbon.cs.meta │ │ ├── Ribbon.shader │ │ └── Ribbon.shader.meta │ ├── Swarm.meta │ └── Swarm │ │ ├── Editor.meta │ │ ├── Editor │ │ ├── SwarmEditor.cs │ │ └── SwarmEditor.cs.meta │ │ ├── Shaders.meta │ │ ├── Shaders │ │ ├── ClassicNoise3D.cginc │ │ ├── ClassicNoise3D.cginc.meta │ │ ├── Kernel.shader │ │ ├── Kernel.shader.meta │ │ ├── Line.shader │ │ └── Line.shader.meta │ │ ├── Swarm.cs │ │ └── Swarm.cs.meta ├── Reaktion.meta ├── Reaktion │ ├── Editor.meta │ ├── Editor │ │ ├── Utility.meta │ │ └── Utility │ │ │ ├── ConstantMotionEditor.cs │ │ │ ├── ConstantMotionEditor.cs.meta │ │ │ ├── JitterMotionEditor.cs │ │ │ └── JitterMotionEditor.cs.meta │ ├── Internal.meta │ ├── Internal │ │ ├── Perlin.cs │ │ └── Perlin.cs.meta │ ├── Utility.meta │ └── Utility │ │ ├── ConstantMotion.cs │ │ ├── ConstantMotion.cs.meta │ │ ├── JitterMotion.cs │ │ └── JitterMotion.cs.meta ├── Shaders.meta ├── Shaders │ ├── ImageEffects.meta │ └── ImageEffects │ │ ├── Bloom_V2.meta │ │ └── Bloom_V2 │ │ ├── Editor.meta │ │ ├── Editor │ │ ├── VideoBloomEditor.cs │ │ └── VideoBloomEditor.cs.meta │ │ ├── PostEffectsBase.cs │ │ ├── PostEffectsBase.cs.meta │ │ ├── VideoBloom.cs │ │ ├── VideoBloom.cs.meta │ │ ├── VideoBloom.shader │ │ └── VideoBloom.shader.meta ├── Standard Assets.meta ├── Standard Assets │ ├── Effects.meta │ └── Effects │ │ ├── ImageEffects.meta │ │ └── ImageEffects │ │ ├── Scripts.meta │ │ ├── Scripts │ │ ├── PostEffectsBase.cs │ │ ├── PostEffectsBase.cs.meta │ │ ├── VignetteAndChromaticAberration.cs │ │ └── VignetteAndChromaticAberration.cs.meta │ │ ├── Shaders.meta │ │ └── Shaders │ │ ├── ChromaticAberrationShader.shader │ │ ├── ChromaticAberrationShader.shader.meta │ │ ├── VignettingShader.shader │ │ ├── VignettingShader.shader.meta │ │ ├── _DepthOfField.meta │ │ └── _DepthOfField │ │ ├── SeparableBlur.shader │ │ └── SeparableBlur.shader.meta ├── Test.meta └── Test │ ├── Skybox.mat │ ├── Skybox.mat.meta │ ├── Test.unity │ ├── Test.unity.meta │ ├── waterfall_Ref.exr │ └── waterfall_Ref.exr.meta └── ProjectSettings ├── AudioManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset └── TimeManager.asset /.gitignore: -------------------------------------------------------------------------------- 1 | # Unity 2 | Library 3 | Temp 4 | *.pidb 5 | *.userprefs 6 | 7 | # Misc 8 | *.swp 9 | *.lnk 10 | .DS_Store 11 | Thumbs.db 12 | -------------------------------------------------------------------------------- /Assets/ColorSuite.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92b634cb636824bfb98b32d3fc16d5c4 3 | folderAsset: yes 4 | timeCreated: 1437379338 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ColorSuite/ColorSuite.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2014, 2015 Keijiro Takahashi 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | // the Software, and to permit persons to whom the Software is furnished to do so, 9 | // subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | using UnityEngine; 22 | using System.Collections; 23 | 24 | [ExecuteInEditMode] 25 | [ImageEffectTransformsToLDR] 26 | [RequireComponent(typeof(Camera))] 27 | [AddComponentMenu("Image Effects/Color Adjustments/Color Suite")] 28 | public class ColorSuite : MonoBehaviour 29 | { 30 | #region Public Properties 31 | 32 | // White balance. 33 | [SerializeField] float _colorTemp = 0.0f; 34 | [SerializeField] float _colorTint = 0.0f; 35 | 36 | public float colorTemp { 37 | get { return _colorTemp; } 38 | set { _colorTemp = value; } 39 | } 40 | public float colorTint { 41 | get { return _colorTint; } 42 | set { _colorTint = value; } 43 | } 44 | 45 | // Tone mapping. 46 | [SerializeField] bool _toneMapping = false; 47 | [SerializeField] float _exposure = 1.0f; 48 | 49 | public bool toneMapping { 50 | get { return _toneMapping; } 51 | set { _toneMapping = value; } 52 | } 53 | public float exposure { 54 | get { return _exposure; } 55 | set { _exposure = value; } 56 | } 57 | 58 | // Color saturation. 59 | [SerializeField] float _saturation = 1.0f; 60 | 61 | public float saturation { 62 | get { return _saturation; } 63 | set { _saturation = value; } 64 | } 65 | 66 | // Curves. 67 | [SerializeField] AnimationCurve _rCurve = AnimationCurve.Linear(0, 0, 1, 1); 68 | [SerializeField] AnimationCurve _gCurve = AnimationCurve.Linear(0, 0, 1, 1); 69 | [SerializeField] AnimationCurve _bCurve = AnimationCurve.Linear(0, 0, 1, 1); 70 | [SerializeField] AnimationCurve _cCurve = AnimationCurve.Linear(0, 0, 1, 1); 71 | 72 | public AnimationCurve redCurve { 73 | get { return _rCurve; } 74 | set { _rCurve = value; UpdateLUT(); } 75 | } 76 | public AnimationCurve greenCurve { 77 | get { return _gCurve; } 78 | set { _gCurve = value; UpdateLUT(); } 79 | } 80 | public AnimationCurve blueCurve { 81 | get { return _bCurve; } 82 | set { _bCurve = value; UpdateLUT(); } 83 | } 84 | public AnimationCurve rgbCurve { 85 | get { return _cCurve; } 86 | set { _cCurve = value; UpdateLUT(); } 87 | } 88 | 89 | // Dithering. 90 | public enum DitherMode { Off, Ordered, Triangular } 91 | [SerializeField] DitherMode _ditherMode = DitherMode.Off; 92 | 93 | public DitherMode ditherMode { 94 | get { return _ditherMode; } 95 | set { _ditherMode = value; } 96 | } 97 | 98 | #endregion 99 | 100 | #region Internal Properties 101 | 102 | // Reference to the shader. 103 | [SerializeField] Shader shader; 104 | 105 | // Temporary objects. 106 | Material _material; 107 | Texture2D _lutTexture; 108 | 109 | #endregion 110 | 111 | #region Local Functions 112 | 113 | // RGBM encoding. 114 | static Color EncodeRGBM(float r, float g, float b) 115 | { 116 | var a = Mathf.Max(Mathf.Max(r, g), Mathf.Max(b, 1e-6f)); 117 | a = Mathf.Ceil(a * 255) / 255; 118 | return new Color(r / a, g / a, b / a, a); 119 | } 120 | 121 | // An analytical model of chromaticity of the standard illuminant, by Judd et al. 122 | // http://en.wikipedia.org/wiki/Standard_illuminant#Illuminant_series_D 123 | // Slightly modifed to adjust it with the D65 white point (x=0.31271, y=0.32902). 124 | static float StandardIlluminantY(float x) 125 | { 126 | return 2.87f * x - 3.0f * x * x - 0.27509507f; 127 | } 128 | 129 | // CIE xy chromaticity to CAT02 LMS. 130 | // http://en.wikipedia.org/wiki/LMS_color_space#CAT02 131 | static Vector3 CIExyToLMS(float x, float y) 132 | { 133 | var Y = 1.0f; 134 | var X = Y * x / y; 135 | var Z = Y * (1.0f - x - y) / y; 136 | 137 | var L = 0.7328f * X + 0.4296f * Y - 0.1624f * Z; 138 | var M = -0.7036f * X + 1.6975f * Y + 0.0061f * Z; 139 | var S = 0.0030f * X + 0.0136f * Y + 0.9834f * Z; 140 | 141 | return new Vector3(L, M, S); 142 | } 143 | 144 | #endregion 145 | 146 | #region Private Methods 147 | 148 | // Set up the temporary assets. 149 | void Setup() 150 | { 151 | if (_material == null) 152 | { 153 | _material = new Material(shader); 154 | _material.hideFlags = HideFlags.DontSave; 155 | } 156 | 157 | if (_lutTexture == null) 158 | { 159 | _lutTexture = new Texture2D(512, 1, TextureFormat.ARGB32, false, true); 160 | _lutTexture.hideFlags = HideFlags.DontSave; 161 | _lutTexture.wrapMode = TextureWrapMode.Clamp; 162 | UpdateLUT(); 163 | } 164 | } 165 | 166 | // Update the LUT texture. 167 | void UpdateLUT() 168 | { 169 | for (var x = 0; x < _lutTexture.width; x++) 170 | { 171 | var u = 1.0f / (_lutTexture.width - 1) * x; 172 | var r = _cCurve.Evaluate(_rCurve.Evaluate(u)); 173 | var g = _cCurve.Evaluate(_gCurve.Evaluate(u)); 174 | var b = _cCurve.Evaluate(_bCurve.Evaluate(u)); 175 | _lutTexture.SetPixel(x, 0, EncodeRGBM(r, g, b)); 176 | } 177 | _lutTexture.Apply(); 178 | } 179 | 180 | // Calculate the color balance coefficients. 181 | Vector3 CalculateColorBalance() 182 | { 183 | // Get the CIE xy chromaticity of the reference white point. 184 | // Note: 0.31271 = x value on the D65 white point 185 | var x = 0.31271f - _colorTemp * (_colorTemp < 0.0f ? 0.1f : 0.05f); 186 | var y = StandardIlluminantY(x) + _colorTint * 0.05f; 187 | 188 | // Calculate the coefficients in the LMS space. 189 | var w1 = new Vector3(0.949237f, 1.03542f, 1.08728f); // D65 white point 190 | var w2 = CIExyToLMS(x, y); 191 | return new Vector3(w1.x / w2.x, w1.y / w2.y, w1.z / w2.z); 192 | } 193 | 194 | #endregion 195 | 196 | #region Monobehaviour Functions 197 | 198 | void Start() 199 | { 200 | Setup(); 201 | } 202 | 203 | void OnValidate() 204 | { 205 | Setup(); 206 | UpdateLUT(); 207 | } 208 | 209 | void Reset() 210 | { 211 | Setup(); 212 | UpdateLUT(); 213 | } 214 | 215 | void OnRenderImage(RenderTexture source, RenderTexture destination) 216 | { 217 | var linear = QualitySettings.activeColorSpace == ColorSpace.Linear; 218 | 219 | Setup(); 220 | 221 | if (linear) 222 | _material.EnableKeyword("COLORSPACE_LINEAR"); 223 | else 224 | _material.DisableKeyword("COLORSPACE_LINEAR"); 225 | 226 | if (_colorTemp != 0.0f || _colorTint != 0.0f) 227 | { 228 | _material.EnableKeyword("BALANCING_ON"); 229 | _material.SetVector("_Balance", CalculateColorBalance()); 230 | } 231 | else 232 | _material.DisableKeyword("BALANCING_ON"); 233 | 234 | if (_toneMapping && linear) 235 | { 236 | _material.EnableKeyword("TONEMAPPING_ON"); 237 | _material.SetFloat("_Exposure", _exposure); 238 | } 239 | else 240 | _material.DisableKeyword("TONEMAPPING_ON"); 241 | 242 | _material.SetTexture("_Curves", _lutTexture); 243 | _material.SetFloat("_Saturation", _saturation); 244 | 245 | if (_ditherMode == DitherMode.Ordered) 246 | { 247 | _material.EnableKeyword("DITHER_ORDERED"); 248 | _material.DisableKeyword("DITHER_TRIANGULAR"); 249 | } 250 | else if (_ditherMode == DitherMode.Triangular) 251 | { 252 | _material.DisableKeyword("DITHER_ORDERED"); 253 | _material.EnableKeyword("DITHER_TRIANGULAR"); 254 | } 255 | else 256 | { 257 | _material.DisableKeyword("DITHER_ORDERED"); 258 | _material.DisableKeyword("DITHER_TRIANGULAR"); 259 | } 260 | 261 | Graphics.Blit(source, destination, _material); 262 | } 263 | 264 | #endregion 265 | } 266 | -------------------------------------------------------------------------------- /Assets/ColorSuite/ColorSuite.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 10593b7d510b64560a297a8af1356dcb 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: 6 | - shader: {fileID: 4800000, guid: dc9775b65c52747e69fc4c854c00d696, type: 3} 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/ColorSuite/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd386d94948a6489a9baa003c1f5b171 3 | folderAsset: yes 4 | timeCreated: 1437379338 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ColorSuite/Editor/ColorSuiteEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2014, 2015 Keijiro Takahashi 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | // the Software, and to permit persons to whom the Software is furnished to do so, 9 | // subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | using UnityEngine; 22 | using UnityEditor; 23 | using System.Collections; 24 | 25 | [CustomEditor(typeof(ColorSuite)), CanEditMultipleObjects] 26 | public class ColorSuiteEditor : Editor 27 | { 28 | SerializedProperty propColorTemp; 29 | SerializedProperty propColorTint; 30 | 31 | SerializedProperty propToneMapping; 32 | SerializedProperty propExposure; 33 | 34 | SerializedProperty propSaturation; 35 | 36 | SerializedProperty propRCurve; 37 | SerializedProperty propGCurve; 38 | SerializedProperty propBCurve; 39 | SerializedProperty propCCurve; 40 | 41 | SerializedProperty propDitherMode; 42 | 43 | GUIContent labelColorTemp; 44 | GUIContent labelColorTint; 45 | 46 | void OnEnable() 47 | { 48 | propColorTemp = serializedObject.FindProperty("_colorTemp"); 49 | propColorTint = serializedObject.FindProperty("_colorTint"); 50 | 51 | propToneMapping = serializedObject.FindProperty("_toneMapping"); 52 | propExposure = serializedObject.FindProperty("_exposure"); 53 | 54 | propSaturation = serializedObject.FindProperty("_saturation"); 55 | 56 | propRCurve = serializedObject.FindProperty("_rCurve"); 57 | propGCurve = serializedObject.FindProperty("_gCurve"); 58 | propBCurve = serializedObject.FindProperty("_bCurve"); 59 | propCCurve = serializedObject.FindProperty("_cCurve"); 60 | 61 | propDitherMode = serializedObject.FindProperty("_ditherMode"); 62 | 63 | labelColorTemp = new GUIContent("Color Temperature"); 64 | labelColorTint = new GUIContent("Tint (green-purple)"); 65 | } 66 | 67 | public override void OnInspectorGUI() 68 | { 69 | serializedObject.Update(); 70 | 71 | EditorGUILayout.PropertyField(propToneMapping); 72 | if (propToneMapping.hasMultipleDifferentValues || propToneMapping.boolValue) 73 | { 74 | EditorGUILayout.Slider(propExposure, 0, 5); 75 | if (QualitySettings.activeColorSpace != ColorSpace.Linear) 76 | EditorGUILayout.HelpBox("Linear space lighting should be enabled for tone mapping.", MessageType.Warning); 77 | } 78 | 79 | EditorGUILayout.Space(); 80 | 81 | EditorGUILayout.Slider(propColorTemp, -1.0f, 1.0f, labelColorTemp); 82 | EditorGUILayout.Slider(propColorTint, -1.0f, 1.0f, labelColorTint); 83 | 84 | EditorGUILayout.Space(); 85 | 86 | EditorGUILayout.Slider(propSaturation, 0, 2); 87 | 88 | EditorGUILayout.LabelField("Curves (R, G, B, Combined)"); 89 | EditorGUILayout.BeginHorizontal(); 90 | var doubleHeight = GUILayout.Height(EditorGUIUtility.singleLineHeight * 2); 91 | EditorGUILayout.PropertyField(propRCurve, GUIContent.none, doubleHeight); 92 | EditorGUILayout.PropertyField(propGCurve, GUIContent.none, doubleHeight); 93 | EditorGUILayout.PropertyField(propBCurve, GUIContent.none, doubleHeight); 94 | EditorGUILayout.PropertyField(propCCurve, GUIContent.none, doubleHeight); 95 | EditorGUILayout.EndHorizontal(); 96 | 97 | EditorGUILayout.Space(); 98 | 99 | EditorGUILayout.PropertyField(propDitherMode); 100 | 101 | serializedObject.ApplyModifiedProperties(); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /Assets/ColorSuite/Editor/ColorSuiteEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f328b8677255d426a999185016ef88f2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/ColorSuite/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4911ca47559e444a8aa3e74b16a42ce1 3 | folderAsset: yes 4 | timeCreated: 1437379338 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ColorSuite/Shader/ColorSuite.shader: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2014, 2015 Keijiro Takahashi 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | // the Software, and to permit persons to whom the Software is furnished to do so, 9 | // subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | Shader "Hidden/ColorSuite" 23 | { 24 | Properties 25 | { 26 | _MainTex ("-", 2D) = ""{} 27 | _Curves ("-", 2D) = ""{} 28 | _Exposure ("-", Float) = 1.0 29 | _Saturation ("-", Float) = 1.0 30 | _Balance ("-", Vector) = (1, 1, 1, 0) 31 | } 32 | 33 | CGINCLUDE 34 | 35 | // Multi-compilation options. 36 | #pragma multi_compile COLORSPACE_SRGB COLORSPACE_LINEAR 37 | #pragma multi_compile BALANCING_OFF BALANCING_ON 38 | #pragma multi_compile TONEMAPPING_OFF TONEMAPPING_ON 39 | #pragma multi_compile DITHER_OFF DITHER_ORDERED DITHER_TRIANGULAR 40 | 41 | #include "UnityCG.cginc" 42 | 43 | sampler2D _MainTex; 44 | float2 _MainTex_TexelSize; 45 | sampler2D _Curves; 46 | float _Exposure; 47 | float _Saturation; 48 | float4 _Balance; 49 | 50 | #if COLORSPACE_LINEAR 51 | 52 | // Color space conversion between sRGB and linear space. 53 | // http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html 54 | 55 | float3 srgb_to_linear(float3 c) 56 | { 57 | return c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878); 58 | } 59 | 60 | float3 linear_to_srgb(float3 c) 61 | { 62 | return max(1.055 * pow(c, 0.416666667) - 0.055, 0.0); 63 | } 64 | 65 | #endif 66 | 67 | #if BALANCING_ON 68 | 69 | // Color space conversion between linear RGB and LMS 70 | // based on the CIECAM02 model (CAT02). 71 | // http://en.wikipedia.org/wiki/LMS_color_space#CAT02 72 | 73 | float3 lrgb_to_lms(float3 c) 74 | { 75 | float3x3 m = { 76 | 3.90405e-1f, 5.49941e-1f, 8.92632e-3f, 77 | 7.08416e-2f, 9.63172e-1f, 1.35775e-3f, 78 | 2.31082e-2f, 1.28021e-1f, 9.36245e-1f 79 | }; 80 | return mul(m, c); 81 | } 82 | 83 | float3 lms_to_lrgb(float3 c) 84 | { 85 | float3x3 m = { 86 | 2.85847e+0f, -1.62879e+0f, -2.48910e-2f, 87 | -2.10182e-1f, 1.15820e+0f, 3.24281e-4f, 88 | -4.18120e-2f, -1.18169e-1f, 1.06867e+0f 89 | }; 90 | return mul(m, c); 91 | } 92 | 93 | // Color balance function. 94 | // - The gamma compression/expansion equation used in this function 95 | // differs from the standard sRGB-Linear conversion. 96 | 97 | float3 apply_balance(float3 c) 98 | { 99 | #if !COLORSPACE_LINEAR 100 | // Do the gamma expansion before applying the color balance. 101 | c = pow(c, 2.2); 102 | #endif 103 | 104 | // Apply the color balance in the LMS color space. 105 | c = lms_to_lrgb(lrgb_to_lms(c) * _Balance); 106 | 107 | // It may return a minus value, which should be cropped out. 108 | c = max(c, 0.0); 109 | 110 | #if !COLORSPACE_LINEAR 111 | // Gamma compression. 112 | c = pow(c, 1.0 / 2.2); 113 | #endif 114 | 115 | return c; 116 | } 117 | 118 | #endif 119 | 120 | #if TONEMAPPING_ON 121 | 122 | // John Hable's filmic tone mapping operator. 123 | // http://filmicgames.com/archives/6 124 | 125 | float3 hable_op(float3 c) 126 | { 127 | float A = 0.15; 128 | float B = 0.50; 129 | float C = 0.10; 130 | float D = 0.20; 131 | float E = 0.02; 132 | float F = 0.30; 133 | return ((c * (c * A + B * C) + D * E) / (c * (c * A + B) + D * F)) - E / F; 134 | } 135 | 136 | float3 tone_mapping(float3 c) 137 | { 138 | c *= _Exposure * 4; 139 | c = hable_op(c) / hable_op(11.2); 140 | return pow(c, 1 / 2.2); 141 | } 142 | 143 | #endif 144 | 145 | // Color saturation. 146 | 147 | float luma(float3 c) 148 | { 149 | return 0.212 * c.r + 0.701 * c.g + 0.087 * c.b; 150 | } 151 | 152 | float3 apply_saturation(float3 c) 153 | { 154 | return lerp((float3)luma(c), c, _Saturation); 155 | } 156 | 157 | // RGB curves. 158 | 159 | float3 apply_curves(float3 c) 160 | { 161 | float4 r = tex2D(_Curves, float2(c.r, 0)); 162 | float4 g = tex2D(_Curves, float2(c.g, 0)); 163 | float4 b = tex2D(_Curves, float2(c.b, 0)); 164 | return float3(r.r * r.a, g.g * g.a, b.b * b.a); 165 | } 166 | 167 | #if DITHER_ORDERED 168 | 169 | // Interleaved gradient function from CoD AW. 170 | // http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare 171 | 172 | float interleaved_gradient(float2 uv) 173 | { 174 | float3 magic = float3(0.06711056, 0.00583715, 52.9829189); 175 | return frac(magic.z * frac(dot(uv, magic.xy))); 176 | } 177 | 178 | float3 dither(float2 uv) 179 | { 180 | return (float3)(interleaved_gradient(uv / _MainTex_TexelSize) / 255); 181 | } 182 | 183 | #endif 184 | 185 | #if DITHER_TRIANGULAR 186 | 187 | // Triangular PDF. 188 | 189 | float nrand(float2 uv) 190 | { 191 | return frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453); 192 | } 193 | 194 | float3 dither(float2 uv) 195 | { 196 | float r = nrand(uv) + nrand(uv + (float2)1.1) - 0.5; 197 | return (float3)(r / 255); 198 | } 199 | 200 | #endif 201 | 202 | float4 frag(v2f_img i) : SV_Target 203 | { 204 | float4 source = tex2D(_MainTex, i.uv); 205 | float3 rgb = source.rgb; 206 | 207 | #if BALANCING_ON 208 | rgb = apply_balance(rgb); 209 | #endif 210 | 211 | #if COLORSPACE_LINEAR 212 | #if TONEMAPPING_ON 213 | // Apply the tone mapping. 214 | rgb = tone_mapping(rgb); 215 | #else 216 | // Convert the color into the sRGB color space. 217 | rgb = linear_to_srgb(rgb); 218 | #endif 219 | #endif 220 | 221 | // Color saturation. 222 | rgb = apply_saturation(rgb); 223 | 224 | // RGB curves. 225 | rgb = apply_curves(rgb); 226 | 227 | #if !DITHER_OFF 228 | rgb += dither(i.uv); 229 | #endif 230 | 231 | #if COLORSPACE_LINEAR 232 | // Take the color back into the linear color space. 233 | rgb = srgb_to_linear(rgb); 234 | #endif 235 | 236 | return float4(rgb, source.a); 237 | } 238 | 239 | ENDCG 240 | 241 | Subshader 242 | { 243 | Pass 244 | { 245 | ZTest Always Cull Off ZWrite Off 246 | Fog { Mode off } 247 | CGPROGRAM 248 | #pragma target 3.0 249 | #pragma glsl 250 | #pragma vertex vert_img 251 | #pragma fragment frag 252 | ENDCG 253 | } 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /Assets/ColorSuite/Shader/ColorSuite.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc9775b65c52747e69fc4c854c00d696 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/DeferredAO.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9228dd6c5f1bc426abef4bf88e9ce584 3 | folderAsset: yes 4 | timeCreated: 1435398751 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/DeferredAO/DeferredAO.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Deferred AO - G-buffer based SSAO effect 3 | // 4 | // Copyright (C) 2015 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | using UnityEngine; 24 | 25 | [ImageEffectOpaque] 26 | [ExecuteInEditMode] 27 | [RequireComponent(typeof(Camera))] 28 | [AddComponentMenu("Image Effects/Rendering/Deferred AO")] 29 | public class DeferredAO : MonoBehaviour 30 | { 31 | #region Public Properties 32 | 33 | // Effect intensity 34 | 35 | [SerializeField] 36 | float _intensity = 1; 37 | 38 | public float intensity { 39 | get { return _intensity; } 40 | set { _intensity = value; } 41 | } 42 | 43 | // Sample radius 44 | 45 | [SerializeField] 46 | float _sampleRadius = 1; 47 | 48 | public float sampleRadius { 49 | get { return _sampleRadius; } 50 | set { _sampleRadius = value; } 51 | } 52 | 53 | // Range check (rejects distant samples) 54 | 55 | [SerializeField] 56 | bool _rangeCheck = true; 57 | 58 | public bool rangeCheck { 59 | get { return _rangeCheck; } 60 | set { _rangeCheck = value; } 61 | } 62 | 63 | // Fall-off distance 64 | 65 | [SerializeField] 66 | float _fallOffDistance = 100; 67 | 68 | public float fallOffDistance { 69 | get { return _fallOffDistance; } 70 | set { _fallOffDistance = value; } 71 | } 72 | 73 | // Sample count 74 | 75 | public enum SampleCount { Low, Medium, High, Overkill } 76 | 77 | [SerializeField] 78 | SampleCount _sampleCount = SampleCount.Medium; 79 | 80 | public SampleCount sampleCount { 81 | get { return _sampleCount; } 82 | set { _sampleCount = value; } 83 | } 84 | 85 | #endregion 86 | 87 | #region Private Resources 88 | 89 | [SerializeField] 90 | Shader _shader; 91 | 92 | Material _material; 93 | 94 | #endregion 95 | 96 | #region MonoBehaviour Functions 97 | 98 | void OnRenderImage(RenderTexture source, RenderTexture destination) 99 | { 100 | if (_material == null) { 101 | _material = new Material(_shader); 102 | _material.hideFlags = HideFlags.DontSave; 103 | } 104 | 105 | _material.SetFloat("_Radius", _sampleRadius); 106 | _material.SetFloat("_Intensity", _intensity); 107 | _material.SetFloat("_FallOff", _fallOffDistance); 108 | 109 | _material.shaderKeywords = null; 110 | 111 | if (_rangeCheck) 112 | _material.EnableKeyword("_RANGE_CHECK"); 113 | 114 | if (_sampleCount == SampleCount.Medium) 115 | _material.EnableKeyword("_SAMPLE_MEDIUM"); 116 | else if (_sampleCount == SampleCount.High) 117 | _material.EnableKeyword("_SAMPLE_HIGH"); 118 | else if (_sampleCount == SampleCount.Overkill) 119 | _material.EnableKeyword("_SAMPLE_OVERKILL"); 120 | 121 | Graphics.Blit(source, destination, _material, 0); 122 | } 123 | 124 | #endregion 125 | } 126 | -------------------------------------------------------------------------------- /Assets/DeferredAO/DeferredAO.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2f6a516d891854931acf7fb785c812ec 3 | timeCreated: 1435398836 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _shader: {fileID: 4800000, guid: c928e16c12e994a70928a9181450d18c, type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/DeferredAO/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 86aa7a07c1e4f4d8d93c38a39c302fd2 3 | folderAsset: yes 4 | timeCreated: 1435499990 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/DeferredAO/Editor/DeferredAOEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Deferred AO - G-buffer based SSAO effect 3 | // 4 | // Copyright (C) 2015 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | using UnityEngine; 24 | using UnityEditor; 25 | 26 | [CanEditMultipleObjects] 27 | [CustomEditor(typeof(DeferredAO))] 28 | public class DeferredAOEditor : Editor 29 | { 30 | SerializedProperty _intensity; 31 | SerializedProperty _sampleRadius; 32 | SerializedProperty _rangeCheck; 33 | SerializedProperty _fallOffDistance; 34 | SerializedProperty _sampleCount; 35 | 36 | void OnEnable() 37 | { 38 | _intensity = serializedObject.FindProperty("_intensity"); 39 | _sampleRadius = serializedObject.FindProperty("_sampleRadius"); 40 | _rangeCheck = serializedObject.FindProperty("_rangeCheck"); 41 | _fallOffDistance = serializedObject.FindProperty("_fallOffDistance"); 42 | _sampleCount = serializedObject.FindProperty("_sampleCount"); 43 | } 44 | 45 | public override void OnInspectorGUI() 46 | { 47 | serializedObject.Update(); 48 | 49 | EditorGUILayout.PropertyField(_intensity); 50 | EditorGUILayout.PropertyField(_sampleRadius); 51 | EditorGUILayout.PropertyField(_rangeCheck); 52 | EditorGUILayout.PropertyField(_fallOffDistance); 53 | EditorGUILayout.PropertyField(_sampleCount); 54 | 55 | serializedObject.ApplyModifiedProperties(); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Assets/DeferredAO/Editor/DeferredAOEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc11bf4e6f30c46d98811ebcbab0bf98 3 | timeCreated: 1435500000 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/DeferredAO/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f49a98fd01d54b5893810f5bd1bcdd3 3 | folderAsset: yes 4 | timeCreated: 1435499972 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/DeferredAO/Shader/DeferredAO.shader: -------------------------------------------------------------------------------- 1 | // 2 | // Deferred AO - G-buffer based SSAO effect 3 | // 4 | // Copyright (C) 2015 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | Shader "Hidden/DeferredAO" 24 | { 25 | Properties 26 | { 27 | _MainTex("-", 2D) = "" {} 28 | } 29 | CGINCLUDE 30 | 31 | #include "UnityCG.cginc" 32 | 33 | #pragma multi_compile _ _RANGE_CHECK 34 | #pragma multi_compile _SAMPLE_LOW _SAMPLE_MEDIUM _SAMPLE_HIGH _SAMPLE_OVERKILL 35 | 36 | sampler2D _MainTex; 37 | float2 _MainTex_TexelSize; 38 | 39 | sampler2D_float _CameraDepthTexture; 40 | sampler2D _CameraGBufferTexture2; 41 | float4x4 _WorldToCamera; 42 | 43 | float _Intensity; 44 | float _Radius; 45 | float _FallOff; 46 | 47 | #if _SAMPLE_LOW 48 | static const int SAMPLE_COUNT = 8; 49 | #elif _SAMPLE_MEDIUM 50 | static const int SAMPLE_COUNT = 16; 51 | #elif _SAMPLE_HIGH 52 | static const int SAMPLE_COUNT = 24; 53 | #else 54 | static const int SAMPLE_COUNT = 80; 55 | #endif 56 | 57 | float nrand(float2 uv, float dx, float dy) 58 | { 59 | uv += float2(dx, dy + _Time.x); 60 | return frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453); 61 | } 62 | 63 | float3 spherical_kernel(float2 uv, float index) 64 | { 65 | // Uniformaly distributed points 66 | // http://mathworld.wolfram.com/SpherePointPicking.html 67 | float u = nrand(uv, 0, index) * 2 - 1; 68 | float theta = nrand(uv, 1, index) * UNITY_PI * 2; 69 | float u2 = sqrt(1 - u * u); 70 | float3 v = float3(u2 * cos(theta), u2 * sin(theta), u); 71 | // Adjustment for distance distribution. 72 | float l = index / SAMPLE_COUNT; 73 | return v * lerp(0.1, 1.0, l * l); 74 | } 75 | 76 | half4 frag_ao(v2f_img i) : SV_Target 77 | { 78 | half4 src = tex2D(_MainTex, i.uv); 79 | 80 | // Sample a linear depth on the depth buffer. 81 | float depth_o = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv); 82 | depth_o = LinearEyeDepth(depth_o); 83 | 84 | // This early-out flow control is not allowed in HLSL. 85 | // if (depth_o > _FallOff) return src; 86 | 87 | // Sample a view-space normal vector on the g-buffer. 88 | float3 norm_o = tex2D(_CameraGBufferTexture2, i.uv).xyz * 2 - 1; 89 | norm_o = mul((float3x3)_WorldToCamera, norm_o); 90 | 91 | // Reconstruct the view-space position. 92 | float2 p11_22 = float2(unity_CameraProjection._11, unity_CameraProjection._22); 93 | float3 pos_o = float3((i.uv * 2 - 1) / p11_22, 1) * depth_o; 94 | 95 | float3x3 proj = (float3x3)unity_CameraProjection; 96 | 97 | float occ = 0.0; 98 | for (int s = 0; s < SAMPLE_COUNT; s++) 99 | { 100 | float3 delta = spherical_kernel(i.uv, s); 101 | 102 | // Wants a sample in normal oriented hemisphere. 103 | delta *= (dot(norm_o, delta) >= 0) * 2 - 1; 104 | 105 | // Sampling point. 106 | float3 pos_s = pos_o + delta * _Radius; 107 | 108 | // Re-project the sampling point. 109 | float3 pos_sc = mul(proj, pos_s); 110 | float2 uv_s = (pos_sc.xy / pos_s.z + 1) * 0.5; 111 | 112 | // Sample a linear depth at the sampling point. 113 | float depth_s = LinearEyeDepth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, uv_s)); 114 | 115 | // Occlusion test. 116 | float dist = pos_s.z - depth_s; 117 | #if _RANGE_CHECK 118 | occ += (dist > 0.1) * (dist < _Radius); 119 | #else 120 | occ += (dist > 0.1); 121 | #endif 122 | } 123 | 124 | float falloff = 1.0 - depth_o / _FallOff; 125 | occ = saturate(occ * _Intensity * falloff / SAMPLE_COUNT); 126 | 127 | return half4(lerp(src.rgb, (half3)0.0, occ), src.a); 128 | } 129 | 130 | ENDCG 131 | SubShader 132 | { 133 | Pass 134 | { 135 | ZTest Always Cull Off ZWrite Off 136 | CGPROGRAM 137 | #pragma vertex vert_img 138 | #pragma fragment frag_ao 139 | #pragma target 3.0 140 | ENDCG 141 | } 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /Assets/DeferredAO/Shader/DeferredAO.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c928e16c12e994a70928a9181450d18c 3 | timeCreated: 1435398831 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd3b771e2f9df4f6bb8d4b3e01545173 3 | folderAsset: yes 4 | timeCreated: 1432478651 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Editor/ImageEffects.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 225198e07aaae3547a6d1f6e7177555f 3 | folderAsset: yes 4 | timeCreated: 1432478651 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Editor/ImageEffects/VignetteAndChromaticAberrationEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | namespace UnityStandardAssets.ImageEffects 6 | { 7 | [CustomEditor (typeof(VignetteAndChromaticAberration))] 8 | class VignetteAndChromaticAberrationEditor : Editor 9 | { 10 | private SerializedObject m_SerObj; 11 | private SerializedProperty m_Mode; 12 | private SerializedProperty m_Intensity; // intensity == 0 disables pre pass (optimization) 13 | private SerializedProperty m_ChromaticAberration; 14 | private SerializedProperty m_AxialAberration; 15 | private SerializedProperty m_Blur; // blur == 0 disables blur pass (optimization) 16 | private SerializedProperty m_BlurSpread; 17 | private SerializedProperty m_BlurDistance; 18 | private SerializedProperty m_LuminanceDependency; 19 | 20 | 21 | void OnEnable () 22 | { 23 | m_SerObj = new SerializedObject (target); 24 | m_Mode = m_SerObj.FindProperty ("mode"); 25 | m_Intensity = m_SerObj.FindProperty ("intensity"); 26 | m_ChromaticAberration = m_SerObj.FindProperty ("chromaticAberration"); 27 | m_AxialAberration = m_SerObj.FindProperty ("axialAberration"); 28 | m_Blur = m_SerObj.FindProperty ("blur"); 29 | m_BlurSpread = m_SerObj.FindProperty ("blurSpread"); 30 | m_LuminanceDependency = m_SerObj.FindProperty ("luminanceDependency"); 31 | m_BlurDistance = m_SerObj.FindProperty ("blurDistance"); 32 | } 33 | 34 | 35 | public override void OnInspectorGUI () 36 | { 37 | m_SerObj.Update (); 38 | 39 | EditorGUILayout.LabelField("Simulates the common lens artifacts 'Vignette' and 'Aberration'", EditorStyles.miniLabel); 40 | 41 | EditorGUILayout.PropertyField (m_Intensity, new GUIContent("Vignetting")); 42 | EditorGUILayout.PropertyField (m_Blur, new GUIContent(" Blurred Corners")); 43 | if (m_Blur.floatValue>0.0f) 44 | EditorGUILayout.PropertyField (m_BlurSpread, new GUIContent(" Blur Distance")); 45 | 46 | EditorGUILayout.Separator (); 47 | 48 | EditorGUILayout.PropertyField (m_Mode, new GUIContent("Aberration")); 49 | if (m_Mode.intValue>0) 50 | { 51 | EditorGUILayout.PropertyField (m_ChromaticAberration, new GUIContent(" Tangential Aberration")); 52 | EditorGUILayout.PropertyField (m_AxialAberration, new GUIContent(" Axial Aberration")); 53 | m_LuminanceDependency.floatValue = EditorGUILayout.Slider(" Contrast Dependency", m_LuminanceDependency.floatValue, 0.001f, 1.0f); 54 | m_BlurDistance.floatValue = EditorGUILayout.Slider(" Blur Distance", m_BlurDistance.floatValue, 0.001f, 5.0f); 55 | } 56 | else 57 | EditorGUILayout.PropertyField (m_ChromaticAberration, new GUIContent(" Chromatic Aberration")); 58 | 59 | m_SerObj.ApplyModifiedProperties(); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Assets/Editor/ImageEffects/VignetteAndChromaticAberrationEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 08126bf2baa528c4cb9c60340a24e5d6 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Editor/PackageTool.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | public class PackageTool 5 | { 6 | [MenuItem("Package/Update Package")] 7 | static void UpdatePackage() 8 | { 9 | AssetDatabase.ExportPackage("Assets/Kvant", "KvantSwarm.unitypackage", ExportPackageOptions.Recurse); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Assets/Editor/PackageTool.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc644de3901e8432f940390f70075011 3 | timeCreated: 1437574643 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/HexBokeh.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81979a226b48f402cb3757c07d81af35 3 | folderAsset: yes 4 | timeCreated: 1437824961 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/HexBokeh/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d7e4dd4a42f74f798c22c2d05e05c87 3 | folderAsset: yes 4 | timeCreated: 1437824961 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/HexBokeh/Editor/HexBokehEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // HexBokeh - A Fast DOF Shader With Hexagonal Apertures 3 | // 4 | // Copyright (C) 2014 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | 24 | // 25 | // This shader is based on McIntosh's paper "Efficiently Simulating the Bokeh of 26 | // Polygonal Apertures in a Post-Process Depth of Field Shader". For further 27 | // details see the paper below. 28 | // 29 | // http://ivizlab.sfu.ca/media/DiPaolaMcIntoshRiecke2012.pdf 30 | // 31 | 32 | using UnityEngine; 33 | using UnityEditor; 34 | using System.Collections; 35 | 36 | [CustomEditor(typeof(HexBokeh)), CanEditMultipleObjects] 37 | public class HexBokehEditor : Editor 38 | { 39 | SerializedProperty propFocalTarget; 40 | SerializedProperty propFocalLength; 41 | SerializedProperty propFocalSize; 42 | SerializedProperty propAperture; 43 | SerializedProperty propVisualize; 44 | SerializedProperty propNearBlur; 45 | SerializedProperty propSampleCount; 46 | SerializedProperty propSampleDist; 47 | 48 | void OnEnable() 49 | { 50 | propFocalTarget = serializedObject.FindProperty("focalTarget"); 51 | propFocalLength = serializedObject.FindProperty("focalLength"); 52 | propFocalSize = serializedObject.FindProperty("focalSize"); 53 | propAperture = serializedObject.FindProperty("aperture"); 54 | propVisualize = serializedObject.FindProperty("visualize"); 55 | propNearBlur = serializedObject.FindProperty("nearBlur"); 56 | propSampleCount = serializedObject.FindProperty("sampleCount"); 57 | propSampleDist = serializedObject.FindProperty("sampleDist"); 58 | } 59 | 60 | public override void OnInspectorGUI() 61 | { 62 | serializedObject.Update(); 63 | 64 | EditorGUILayout.PropertyField(propFocalTarget); 65 | 66 | if (propFocalTarget.hasMultipleDifferentValues || 67 | propFocalTarget.objectReferenceValue == null) 68 | EditorGUILayout.PropertyField(propFocalLength); 69 | 70 | EditorGUILayout.PropertyField(propFocalSize); 71 | EditorGUILayout.PropertyField(propAperture); 72 | EditorGUILayout.PropertyField(propVisualize, new GUIContent("Visualize CoC")); 73 | EditorGUILayout.PropertyField(propNearBlur); 74 | EditorGUILayout.PropertyField(propSampleCount); 75 | EditorGUILayout.PropertyField(propSampleDist, new GUIContent("Sample Distance")); 76 | 77 | serializedObject.ApplyModifiedProperties(); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Assets/HexBokeh/Editor/HexBokehEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96fdfd4274df84fe080436b0b5c38257 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | assetBundleVariant: 11 | -------------------------------------------------------------------------------- /Assets/HexBokeh/HexBokeh.cs: -------------------------------------------------------------------------------- 1 | // 2 | // HexBokeh - A Fast DOF Shader With Hexagonal Apertures 3 | // 4 | // Copyright (C) 2014 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | 24 | // 25 | // This shader is based on McIntosh's paper "Efficiently Simulating the Bokeh of 26 | // Polygonal Apertures in a Post-Process Depth of Field Shader". For further 27 | // details see the paper below. 28 | // 29 | // http://ivizlab.sfu.ca/media/DiPaolaMcIntoshRiecke2012.pdf 30 | // 31 | 32 | using UnityEngine; 33 | using System.Collections; 34 | 35 | [ExecuteInEditMode] 36 | [RequireComponent(typeof(Camera))] 37 | public class HexBokeh : MonoBehaviour 38 | { 39 | // Reference to the shader. 40 | [SerializeField] Shader shader; 41 | 42 | // Camera parameters. 43 | public Transform focalTarget; 44 | public float focalLength = 10.0f; 45 | public float focalSize = 0.05f; 46 | public float aperture = 11.5f; 47 | public bool visualize; 48 | public bool nearBlur; 49 | 50 | // Blur filter settings. 51 | public enum SampleCount { Low, High } 52 | public SampleCount sampleCount = SampleCount.High; 53 | public float sampleDist = 1; 54 | 55 | // Temporary objects. 56 | Material material; 57 | 58 | // Calculate the focal point. 59 | Vector3 focalPoint { 60 | get { 61 | if (focalTarget != null) 62 | return focalTarget.position; 63 | else 64 | return focalLength * GetComponent().transform.forward + GetComponent().transform.position; 65 | } 66 | } 67 | 68 | void OnEnable() 69 | { 70 | GetComponent().depthTextureMode |= DepthTextureMode.Depth; 71 | } 72 | 73 | void SetUpObjects() 74 | { 75 | if (material != null) return; 76 | material = new Material(shader); 77 | material.hideFlags = HideFlags.DontSave; 78 | } 79 | 80 | void OnRenderImage(RenderTexture source, RenderTexture destination) 81 | { 82 | SetUpObjects(); 83 | 84 | // Apply the shader variant option. 85 | if (nearBlur) 86 | material.EnableKeyword("NEAR_ON"); 87 | else 88 | material.DisableKeyword("NEAR_ON"); 89 | 90 | if (sampleCount == SampleCount.High) 91 | material.EnableKeyword("SAMPLE_HIGH"); 92 | else 93 | material.DisableKeyword("SAMPLE_HIGH"); 94 | 95 | // Update the curve parameter. 96 | var dist01 = GetComponent().WorldToViewportPoint(focalPoint).z / (GetComponent().farClipPlane - GetComponent().nearClipPlane); 97 | material.SetVector("_CurveParams", new Vector4(focalSize, aperture / 10.0f, dist01, 0)); 98 | 99 | // Write CoC into the alpha channel. 100 | Graphics.Blit(source, source, material, 0); 101 | 102 | if (visualize) 103 | { 104 | // Visualize the CoC. 105 | Graphics.Blit(source, destination, material, 1); 106 | } 107 | else 108 | { 109 | var rt1 = RenderTexture.GetTemporary(source.width, source.height, 0, source.format); 110 | var rt2 = RenderTexture.GetTemporary(source.width, source.height, 0, source.format); 111 | var rt3 = RenderTexture.GetTemporary(source.width, source.height, 0, source.format); 112 | 113 | // 1st separable filter: horizontal blur. 114 | material.SetVector("_BlurDisp", new Vector4(1, 0, -1, 0) * sampleDist); 115 | Graphics.Blit(source, rt1, material, 2); 116 | 117 | // 2nd separable filter: skewed vertical blur (left). 118 | material.SetVector("_BlurDisp", new Vector4(-0.5f, -1, 0.5f, 1) * sampleDist); 119 | Graphics.Blit(rt1, rt2, material, 2); 120 | 121 | // 3rd separable filter: skewed vertical blur (right). 122 | material.SetVector("_BlurDisp", new Vector4(0.5f, -1, -0.5f, 1) * sampleDist); 123 | Graphics.Blit(rt1, rt3, material, 2); 124 | 125 | // Combine the result. 126 | material.SetTexture("_BlurTex1", rt2); 127 | material.SetTexture("_BlurTex2", rt3); 128 | 129 | Graphics.Blit(source, destination, material, 3); 130 | 131 | material.SetTexture("_BlurTex1", null); 132 | material.SetTexture("_BlurTex2", null); 133 | 134 | RenderTexture.ReleaseTemporary(rt1); 135 | RenderTexture.ReleaseTemporary(rt2); 136 | RenderTexture.ReleaseTemporary(rt3); 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /Assets/HexBokeh/HexBokeh.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 940d7efa327fe43e69ec63588c14dd0b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: 6 | - shader: {fileID: 4800000, guid: a79ad3c08a37149b68459b8d3b0b432e, type: 3} 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /Assets/HexBokeh/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e8639291a692e4568ad51680e772a287 3 | folderAsset: yes 4 | timeCreated: 1437824961 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/HexBokeh/Shader/HexBokeh.shader: -------------------------------------------------------------------------------- 1 | // 2 | // HexBokeh - A Fast DOF Shader With Hexagonal Apertures 3 | // 4 | // Copyright (C) 2014 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | 24 | // 25 | // This shader is based on McIntosh's paper "Efficiently Simulating the Bokeh of 26 | // Polygonal Apertures in a Post-Process Depth of Field Shader". For further 27 | // details see the paper below. 28 | // 29 | // http://ivizlab.sfu.ca/media/DiPaolaMcIntoshRiecke2012.pdf 30 | // 31 | 32 | Shader "Hidden/HexBokeh" 33 | { 34 | Properties 35 | { 36 | _MainTex("-", 2D) = "black"{} 37 | _BlurTex1("-", 2D) = "black"{} 38 | _BlurTex2("-", 2D) = "black"{} 39 | } 40 | 41 | CGINCLUDE 42 | 43 | #include "UnityCG.cginc" 44 | 45 | // Shader variants. 46 | #pragma multi_compile NEAR_OFF NEAR_ON 47 | #pragma multi_compile SAMPLE_LOW SAMPLE_HIGH 48 | 49 | // Source image. 50 | sampler2D _MainTex; 51 | float4 _MainTex_TexelSize; 52 | 53 | // Blurred image 1 (used only on the combiner) 54 | sampler2D _BlurTex1; 55 | float4 _BlurTex1_TexelSize; 56 | 57 | // Blurred image 2 (used only on the combiner) 58 | sampler2D _BlurTex2; 59 | float4 _BlurTex2_TexelSize; 60 | 61 | // Camera depth texture. 62 | sampler2D_float _CameraDepthTexture; 63 | 64 | // Parameters for the CoC writer. 65 | float3 _CurveParams; // focal_size, 1/aperture, distance01 66 | 67 | // Parameters for the blur filter. 68 | float4 _BlurDisp; 69 | 70 | // 71 | // 1st pass - Write CoC into the alpha channel 72 | // 73 | 74 | float4 frag_write_coc(v2f_img i) : SV_Target 75 | { 76 | float d = Linear01Depth(SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv.xy)); 77 | #ifdef NEAR_ON 78 | float a = _CurveParams.y * abs(d - _CurveParams.z) / (d + 1e-5f); 79 | #else 80 | float a = _CurveParams.y * (d - _CurveParams.z) / (d + 1e-5f); 81 | #endif 82 | return float4(0, 0, 0, saturate(a - _CurveParams.x)); 83 | } 84 | 85 | // 86 | // 2nd pass - Visualize CoC 87 | // 88 | 89 | float4 frag_alpha_to_grayscale(v2f_img i) : SV_Target 90 | { 91 | float a = tex2D(_MainTex, i.uv).a; 92 | return float4(a, a, a, a); 93 | } 94 | 95 | // 96 | // 3rd pass - Separable blur filter 97 | // 98 | 99 | struct v2f_blur 100 | { 101 | float4 pos : SV_POSITION; 102 | float2 uv : TEXCOORD0; 103 | float4 uv_12 : TEXCOORD1; 104 | float4 uv_34 : TEXCOORD2; 105 | float4 uv_56 : TEXCOORD3; 106 | #ifdef SAMPLE_HIGH 107 | float4 uv_78 : TEXCOORD4; 108 | float4 uv_9a : TEXCOORD5; 109 | float4 uv_bc : TEXCOORD6; 110 | #endif 111 | }; 112 | 113 | v2f_blur vert_blur(appdata_img v) 114 | { 115 | v2f_blur o; 116 | 117 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 118 | 119 | float4 uv = v.texcoord.xyxy; 120 | float4 d = _MainTex_TexelSize.xyxy * _BlurDisp; 121 | 122 | o.uv = uv; 123 | o.uv_12 = uv + d; 124 | o.uv_34 = uv + d * 2; 125 | o.uv_56 = uv + d * 3; 126 | #ifdef SAMPLE_HIGH 127 | o.uv_78 = uv + d * 4; 128 | o.uv_9a = uv + d * 5; 129 | o.uv_bc = uv + d * 6; 130 | #endif 131 | 132 | return o; 133 | } 134 | 135 | float4 frag_blur(v2f_blur i) : SV_Target 136 | { 137 | float4 c = tex2D(_MainTex, i.uv); 138 | float4 c1 = tex2D(_MainTex, i.uv_12.xy); 139 | float4 c2 = tex2D(_MainTex, i.uv_12.zw); 140 | float4 c3 = tex2D(_MainTex, i.uv_34.xy); 141 | float4 c4 = tex2D(_MainTex, i.uv_34.zw); 142 | float4 c5 = tex2D(_MainTex, i.uv_56.xy); 143 | float4 c6 = tex2D(_MainTex, i.uv_56.zw); 144 | #ifdef SAMPLE_HIGH 145 | float4 c7 = tex2D(_MainTex, i.uv_78.xy); 146 | float4 c8 = tex2D(_MainTex, i.uv_78.zw); 147 | float4 c9 = tex2D(_MainTex, i.uv_9a.xy); 148 | float4 ca = tex2D(_MainTex, i.uv_9a.zw); 149 | float4 cb = tex2D(_MainTex, i.uv_bc.xy); 150 | float4 cc = tex2D(_MainTex, i.uv_bc.zw); 151 | #endif 152 | 153 | float s = 1; 154 | float a = c.a; 155 | 156 | #ifdef NEAR_ON 157 | 158 | float d = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv); 159 | float d1 = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_12.xy); 160 | float d2 = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_12.zw); 161 | float d3 = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_34.xy); 162 | float d4 = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_34.zw); 163 | float d5 = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_56.xy); 164 | float d6 = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_56.zw); 165 | #ifdef SAMPLE_HIGH 166 | float d7 = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_78.xy); 167 | float d8 = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_78.zw); 168 | float d9 = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_9a.xy); 169 | float da = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_9a.zw); 170 | float db = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_bc.xy); 171 | float dc = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_bc.zw); 172 | #endif 173 | 174 | if ((d1 <= d ? c1.a : min(c1.a, a)) > 1.0 / 7 * 1) { c += c1; s += 1; } 175 | if ((d2 <= d ? c2.a : min(c2.a, a)) > 1.0 / 7 * 1) { c += c2; s += 1; } 176 | if ((d3 <= d ? c3.a : min(c3.a, a)) > 1.0 / 7 * 2) { c += c3; s += 1; } 177 | if ((d4 <= d ? c4.a : min(c4.a, a)) > 1.0 / 7 * 2) { c += c4; s += 1; } 178 | if ((d5 <= d ? c5.a : min(c5.a, a)) > 1.0 / 7 * 3) { c += c5; s += 1; } 179 | if ((d6 <= d ? c6.a : min(c6.a, a)) > 1.0 / 7 * 3) { c += c6; s += 1; } 180 | #ifdef SAMPLE_HIGH 181 | if ((d7 <= d ? c7.a : min(c7.a, a)) > 1.0 / 7 * 4) { c += c7; s += 1; } 182 | if ((d8 <= d ? c8.a : min(c8.a, a)) > 1.0 / 7 * 4) { c += c8; s += 1; } 183 | if ((d9 <= d ? c9.a : min(c9.a, a)) > 1.0 / 7 * 5) { c += c9; s += 1; } 184 | if ((da <= d ? ca.a : min(ca.a, a)) > 1.0 / 7 * 5) { c += ca; s += 1; } 185 | if ((db <= d ? cb.a : min(cb.a, a)) > 1.0 / 7 * 6) { c += cb; s += 1; } 186 | if ((dc <= d ? cc.a : min(cc.a, a)) > 1.0 / 7 * 6) { c += cc; s += 1; } 187 | #endif 188 | 189 | #else // NEAR_ON 190 | 191 | if (min(c1.a, a) > 1.0 / 7 * 1) { c += c1; s += 1; } 192 | if (min(c2.a, a) > 1.0 / 7 * 1) { c += c2; s += 1; } 193 | if (min(c3.a, a) > 1.0 / 7 * 2) { c += c3; s += 1; } 194 | if (min(c4.a, a) > 1.0 / 7 * 2) { c += c4; s += 1; } 195 | if (min(c5.a, a) > 1.0 / 7 * 3) { c += c5; s += 1; } 196 | if (min(c6.a, a) > 1.0 / 7 * 3) { c += c6; s += 1; } 197 | #ifdef SAMPLE_HIGH 198 | if (min(c7.a, a) > 1.0 / 7 * 4) { c += c7; s += 1; } 199 | if (min(c8.a, a) > 1.0 / 7 * 4) { c += c8; s += 1; } 200 | if (min(c9.a, a) > 1.0 / 7 * 5) { c += c9; s += 1; } 201 | if (min(ca.a, a) > 1.0 / 7 * 5) { c += ca; s += 1; } 202 | if (min(cb.a, a) > 1.0 / 7 * 6) { c += cb; s += 1; } 203 | if (min(cc.a, a) > 1.0 / 7 * 6) { c += cc; s += 1; } 204 | #endif 205 | 206 | #endif // NEAR_ON 207 | 208 | return c / s; 209 | } 210 | 211 | // 212 | // 4th pass - Combiner 213 | // 214 | 215 | float4 frag_combiner(v2f_img i) : SV_Target 216 | { 217 | float4 c1 = tex2D(_BlurTex1, i.uv); 218 | float4 c2 = tex2D(_BlurTex2, i.uv); 219 | return min(c1, c2); 220 | } 221 | 222 | ENDCG 223 | 224 | Subshader 225 | { 226 | // 0: CoC 227 | Pass 228 | { 229 | ZTest Always Cull Off ZWrite Off 230 | ColorMask A 231 | Fog { Mode off } 232 | CGPROGRAM 233 | #pragma vertex vert_img 234 | #pragma fragment frag_write_coc 235 | ENDCG 236 | } 237 | 238 | // 1: CoC visualizer 239 | Pass 240 | { 241 | ZTest Always Cull Off ZWrite Off 242 | Fog { Mode off } 243 | CGPROGRAM 244 | #pragma vertex vert_img 245 | #pragma fragment frag_alpha_to_grayscale 246 | ENDCG 247 | } 248 | 249 | // 2: Separable blur filter 250 | Pass 251 | { 252 | ZTest Always Cull Off ZWrite Off 253 | Fog { Mode off } 254 | CGPROGRAM 255 | #pragma glsl 256 | #pragma target 3.0 257 | #pragma vertex vert_blur 258 | #pragma fragment frag_blur 259 | ENDCG 260 | } 261 | 262 | // 3: Combiner 263 | Pass 264 | { 265 | ZTest Always Cull Off ZWrite Off 266 | Fog { Mode off } 267 | CGPROGRAM 268 | #pragma glsl 269 | #pragma target 3.0 270 | #pragma vertex vert_img 271 | #pragma fragment frag_combiner 272 | #pragma glsl 273 | ENDCG 274 | } 275 | } 276 | } 277 | -------------------------------------------------------------------------------- /Assets/HexBokeh/Shader/HexBokeh.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a79ad3c08a37149b68459b8d3b0b432e 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | assetBundleName: 7 | assetBundleVariant: 8 | -------------------------------------------------------------------------------- /Assets/Kino.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 96d6f0c23b5b349a39907f19574573ef 3 | folderAsset: yes 4 | timeCreated: 1435811145 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kino/Fog.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9fba6b0e4a46c4e07a0153904e753df8 3 | folderAsset: yes 4 | timeCreated: 1435838661 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kino/Fog/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 58aa7694ca3de4e8e9cf8cf893804671 3 | folderAsset: yes 4 | timeCreated: 1435838677 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kino/Fog/Editor/FogEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // KinoFog - Deferred fog effect 3 | // 4 | // Copyright (C) 2015 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | using UnityEngine; 24 | using UnityEditor; 25 | 26 | namespace Kino 27 | { 28 | [CanEditMultipleObjects] 29 | [CustomEditor(typeof(Fog))] 30 | public class FogEditor : Editor 31 | { 32 | SerializedProperty _startDistance; 33 | SerializedProperty _useRadialDistance; 34 | SerializedProperty _fadeToSkybox; 35 | 36 | void OnEnable() 37 | { 38 | _startDistance = serializedObject.FindProperty("_startDistance"); 39 | _useRadialDistance = serializedObject.FindProperty("_useRadialDistance"); 40 | _fadeToSkybox = serializedObject.FindProperty("_fadeToSkybox"); 41 | } 42 | 43 | public override void OnInspectorGUI() 44 | { 45 | serializedObject.Update(); 46 | 47 | EditorGUILayout.PropertyField(_startDistance); 48 | EditorGUILayout.PropertyField(_useRadialDistance); 49 | EditorGUILayout.PropertyField(_fadeToSkybox); 50 | 51 | serializedObject.ApplyModifiedProperties(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Assets/Kino/Fog/Editor/FogEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60a60d9e0b29447ed832e2d9aad638b0 3 | timeCreated: 1435838686 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Kino/Fog/Fog.cs: -------------------------------------------------------------------------------- 1 | // 2 | // KinoFog - Deferred fog effect 3 | // 4 | // Copyright (C) 2015 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | using UnityEngine; 24 | 25 | namespace Kino 26 | { 27 | [ExecuteInEditMode] 28 | [RequireComponent(typeof(Camera))] 29 | [AddComponentMenu("Kino Image Effects/Fog")] 30 | public class Fog : MonoBehaviour 31 | { 32 | #region Public Properties 33 | 34 | // Start distance 35 | [SerializeField] 36 | float _startDistance = 1; 37 | 38 | public float startDistance { 39 | get { return _startDistance; } 40 | set { _startDistance = value; } 41 | } 42 | 43 | // Use radial distance 44 | [SerializeField] 45 | bool _useRadialDistance; 46 | 47 | public bool useRadialDistance { 48 | get { return _useRadialDistance; } 49 | set { _useRadialDistance = value; } 50 | } 51 | 52 | // Fade-to-skybox flag 53 | [SerializeField] 54 | bool _fadeToSkybox; 55 | 56 | public bool fadeToSkybox { 57 | get { return _fadeToSkybox; } 58 | set { _fadeToSkybox = value; } 59 | } 60 | 61 | #endregion 62 | 63 | #region Private Properties 64 | 65 | [SerializeField] Shader _shader; 66 | 67 | Material _material; 68 | 69 | #endregion 70 | 71 | #region MonoBehaviour Functions 72 | 73 | void OnEnable() 74 | { 75 | GetComponent().depthTextureMode |= DepthTextureMode.Depth; 76 | } 77 | 78 | [ImageEffectOpaque] 79 | void OnRenderImage(RenderTexture source, RenderTexture destination) 80 | { 81 | if (_material == null) 82 | { 83 | _material = new Material(_shader); 84 | _material.hideFlags = HideFlags.DontSave; 85 | } 86 | 87 | _startDistance = Mathf.Max(_startDistance, 0.0f); 88 | _material.SetFloat("_DistanceOffset", _startDistance); 89 | 90 | var mode = RenderSettings.fogMode; 91 | if (mode == FogMode.Linear) 92 | { 93 | var start = RenderSettings.fogStartDistance; 94 | var end = RenderSettings.fogEndDistance; 95 | var invDiff = 1.0f / Mathf.Max(end - start, 1.0e-6f); 96 | _material.SetFloat("_LinearGrad", -invDiff); 97 | _material.SetFloat("_LinearOffs", end * invDiff); 98 | _material.DisableKeyword("FOG_EXP"); 99 | _material.DisableKeyword("FOG_EXP2"); 100 | } 101 | else if (mode == FogMode.Exponential) 102 | { 103 | const float coeff = 1.4426950408f; // 1/ln(2) 104 | var density = RenderSettings.fogDensity; 105 | _material.SetFloat("_Density", coeff * density); 106 | _material.EnableKeyword("FOG_EXP"); 107 | _material.DisableKeyword("FOG_EXP2"); 108 | } 109 | else // FogMode.ExponentialSquared 110 | { 111 | const float coeff = 1.2011224087f; // 1/sqrt(ln(2)) 112 | var density = RenderSettings.fogDensity; 113 | _material.SetFloat("_Density", coeff * density); 114 | _material.DisableKeyword("FOG_EXP"); 115 | _material.EnableKeyword("FOG_EXP2"); 116 | } 117 | 118 | if (_useRadialDistance) 119 | _material.EnableKeyword("RADIAL_DIST"); 120 | else 121 | _material.DisableKeyword("RADIAL_DIST"); 122 | 123 | if (_fadeToSkybox) 124 | { 125 | _material.EnableKeyword("USE_SKYBOX"); 126 | // Transfer the skybox parameters. 127 | var skybox = RenderSettings.skybox; 128 | _material.SetTexture("_SkyCubemap", skybox.GetTexture("_Tex")); 129 | _material.SetColor("_SkyTint", skybox.GetColor("_Tint")); 130 | _material.SetFloat("_SkyExposure", skybox.GetFloat("_Exposure")); 131 | _material.SetFloat("_SkyRotation", skybox.GetFloat("_Rotation")); 132 | } 133 | else 134 | { 135 | _material.DisableKeyword("USE_SKYBOX"); 136 | _material.SetColor("_FogColor", RenderSettings.fogColor); 137 | } 138 | 139 | // Calculate vectors towards frustum corners. 140 | var cam = GetComponent(); 141 | var camtr = cam.transform; 142 | var camNear = cam.nearClipPlane; 143 | var camFar = cam.farClipPlane; 144 | 145 | var tanHalfFov = Mathf.Tan(cam.fieldOfView * Mathf.Deg2Rad / 2); 146 | var toRight = camtr.right * camNear * tanHalfFov * cam.aspect; 147 | var toTop = camtr.up * camNear * tanHalfFov; 148 | 149 | var v_tl = camtr.forward * camNear - toRight + toTop; 150 | var v_tr = camtr.forward * camNear + toRight + toTop; 151 | var v_br = camtr.forward * camNear + toRight - toTop; 152 | var v_bl = camtr.forward * camNear - toRight - toTop; 153 | 154 | var v_s = v_tl.magnitude * camFar / camNear; 155 | 156 | // Draw screen quad. 157 | RenderTexture.active = destination; 158 | 159 | _material.SetTexture("_MainTex", source); 160 | _material.SetPass(0); 161 | 162 | GL.PushMatrix(); 163 | GL.LoadOrtho(); 164 | GL.Begin(GL.QUADS); 165 | 166 | GL.MultiTexCoord2(0, 0, 0); 167 | GL.MultiTexCoord(1, v_bl.normalized * v_s); 168 | GL.Vertex3(0, 0, 0.1f); 169 | 170 | GL.MultiTexCoord2(0, 1, 0); 171 | GL.MultiTexCoord(1, v_br.normalized * v_s); 172 | GL.Vertex3(1, 0, 0.1f); 173 | 174 | GL.MultiTexCoord2(0, 1, 1); 175 | GL.MultiTexCoord(1, v_tr.normalized * v_s); 176 | GL.Vertex3(1, 1, 0.1f); 177 | 178 | GL.MultiTexCoord2(0, 0, 1); 179 | GL.MultiTexCoord(1, v_tl.normalized * v_s); 180 | GL.Vertex3(0, 1, 0.1f); 181 | 182 | GL.End(); 183 | GL.PopMatrix(); 184 | } 185 | 186 | #endregion 187 | } 188 | } 189 | -------------------------------------------------------------------------------- /Assets/Kino/Fog/Fog.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ee4ab9821096c489f84e50f35b7b9644 3 | timeCreated: 1435839407 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _shader: {fileID: 4800000, guid: 3514cc2676a6c4db294c28459f22c359, type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Kino/Fog/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d17a16d39c5864bf89575ff76ad6667e 3 | folderAsset: yes 4 | timeCreated: 1435838681 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kino/Fog/Shader/Fog.shader: -------------------------------------------------------------------------------- 1 | // 2 | // KinoFog - Deferred fog effect 3 | // 4 | // Copyright (C) 2015 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | Shader "Hidden/Kino/Fog" 24 | { 25 | Properties 26 | { 27 | _MainTex ("-", 2D) = "" {} 28 | _FogColor ("-", Color) = (0, 0, 0, 0) 29 | _SkyTint ("-", Color) = (.5, .5, .5, .5) 30 | [Gamma] _SkyExposure ("-", Range(0, 8)) = 1.0 31 | [NoScaleOffset] _SkyCubemap ("-", Cube) = "" {} 32 | } 33 | CGINCLUDE 34 | 35 | #include "UnityCG.cginc" 36 | 37 | #pragma multi_compile FOG_LINEAR FOG_EXP FOG_EXP2 38 | #pragma multi_compile _ RADIAL_DIST 39 | #pragma multi_compile _ USE_SKYBOX 40 | 41 | sampler2D _MainTex; 42 | float4 _MainTex_TexelSize; 43 | 44 | sampler2D_float _CameraDepthTexture; 45 | 46 | float _DistanceOffset; 47 | float _Density; 48 | float _LinearGrad; 49 | float _LinearOffs; 50 | 51 | // Fog/skybox information 52 | half4 _FogColor; 53 | samplerCUBE _SkyCubemap; 54 | half4 _SkyCubemap_HDR; 55 | half4 _SkyTint; 56 | half _SkyExposure; 57 | float _SkyRotation; 58 | 59 | struct v2f 60 | { 61 | float4 pos : SV_POSITION; 62 | float2 uv : TEXCOORD0; 63 | float2 uv_depth : TEXCOORD1; 64 | float3 ray : TEXCOORD2; 65 | }; 66 | 67 | float3 RotateAroundYAxis(float3 v, float deg) 68 | { 69 | float alpha = deg * UNITY_PI / 180.0; 70 | float sina, cosa; 71 | sincos(alpha, sina, cosa); 72 | float2x2 m = float2x2(cosa, -sina, sina, cosa); 73 | return float3(mul(m, v.xz), v.y).xzy; 74 | } 75 | 76 | v2f vert(appdata_full v) 77 | { 78 | v2f o; 79 | 80 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 81 | o.uv = v.texcoord.xy; 82 | o.uv_depth = v.texcoord.xy; 83 | o.ray = RotateAroundYAxis(v.texcoord1.xyz, -_SkyRotation); 84 | 85 | #if UNITY_UV_STARTS_AT_TOP 86 | if (_MainTex_TexelSize.y < 0.0) o.uv.y = 1.0 - o.uv.y; 87 | #endif 88 | 89 | return o; 90 | } 91 | 92 | // Applies one of standard fog formulas, given fog coordinate (i.e. distance) 93 | half ComputeFogFactor(float coord) 94 | { 95 | float fog = 0.0; 96 | #if FOG_LINEAR 97 | // factor = (end-z)/(end-start) = z * (-1/(end-start)) + (end/(end-start)) 98 | fog = coord * _LinearGrad + _LinearOffs; 99 | #elif FOG_EXP 100 | // factor = exp(-density*z) 101 | fog = _Density * coord; 102 | fog = exp2(-fog); 103 | #else // FOG_EXP2 104 | // factor = exp(-(density*z)^2) 105 | fog = _Density * coord; 106 | fog = exp2(-fog * fog); 107 | #endif 108 | return saturate(fog); 109 | } 110 | 111 | // Distance-based fog 112 | float ComputeDistance(float3 ray, float depth) 113 | { 114 | float dist; 115 | #if RADIAL_DIST 116 | dist = length(ray * depth); 117 | #else 118 | dist = depth * _ProjectionParams.z; 119 | #endif 120 | // Built-in fog starts at near plane, so match that by 121 | // subtracting the near value. Not a perfect approximation 122 | // if near plane is very large, but good enough. 123 | dist -= _ProjectionParams.y; 124 | return dist; 125 | } 126 | 127 | half4 frag(v2f i) : SV_Target 128 | { 129 | half4 sceneColor = tex2D(_MainTex, i.uv); 130 | 131 | // Reconstruct world space position & direction towards this screen pixel. 132 | float zsample = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, i.uv_depth); 133 | float depth = Linear01Depth(zsample * (zsample < 1.0)); 134 | 135 | // Compute fog amount. 136 | float g = ComputeDistance(i.ray, depth) - _DistanceOffset; 137 | half fog = ComputeFogFactor(max(0.0, g)); 138 | 139 | #if USE_SKYBOX 140 | // Look up the skybox color. 141 | half3 skyColor = DecodeHDR(texCUBE(_SkyCubemap, i.ray), _SkyCubemap_HDR); 142 | skyColor *= _SkyTint.rgb * _SkyExposure * unity_ColorSpaceDouble; 143 | // Lerp between source color to skybox color with fog amount. 144 | return lerp(half4(skyColor, 1), sceneColor, fog); 145 | #else 146 | // Lerp between source color to fog color with the fog amount. 147 | return lerp(_FogColor, sceneColor, fog); 148 | #endif 149 | } 150 | 151 | ENDCG 152 | SubShader 153 | { 154 | ZTest Always Cull Off ZWrite Off 155 | Pass 156 | { 157 | CGPROGRAM 158 | #pragma vertex vert 159 | #pragma fragment frag 160 | ENDCG 161 | } 162 | } 163 | Fallback off 164 | } 165 | -------------------------------------------------------------------------------- /Assets/Kino/Fog/Shader/Fog.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3514cc2676a6c4db294c28459f22c359 3 | timeCreated: 1435838691 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kvant.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8be732b80b8b445e5bd196d2b01ed59c 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Kvant/Ribbon.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2734448e017c149febddd82b300af7bc 3 | folderAsset: yes 4 | timeCreated: 1437654364 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kvant/Ribbon/ClassicNoise3D.cginc: -------------------------------------------------------------------------------- 1 | // An HLSL variant of the Gustavson's webgl-noise shader. 2 | // Translated by Keijiro Takahashi 3 | // For further information, see the original notice below. 4 | 5 | // 6 | // GLSL textureless classic 3D noise "cnoise", 7 | // with an RSL-style periodic variant "pnoise". 8 | // Author: Stefan Gustavson (stefan.gustavson@liu.se) 9 | // Version: 2011-10-11 10 | // 11 | // Many thanks to Ian McEwan of Ashima Arts for the 12 | // ideas for permutation and gradient selection. 13 | // 14 | // Copyright (c) 2011 Stefan Gustavson. All rights reserved. 15 | // Distributed under the MIT license. See LICENSE file. 16 | // https://github.com/ashima/webgl-noise 17 | // 18 | 19 | float3 mod(float3 x, float3 y) 20 | { 21 | return x - y * floor(x / y); 22 | } 23 | 24 | float3 mod289(float3 x) 25 | { 26 | return x - floor(x / 289.0) * 289.0; 27 | } 28 | 29 | float4 mod289(float4 x) 30 | { 31 | return x - floor(x / 289.0) * 289.0; 32 | } 33 | 34 | float4 permute(float4 x) 35 | { 36 | return mod289(((x*34.0)+1.0)*x); 37 | } 38 | 39 | float4 taylorInvSqrt(float4 r) 40 | { 41 | return (float4)1.79284291400159 - r * 0.85373472095314; 42 | } 43 | 44 | float3 fade(float3 t) { 45 | return t*t*t*(t*(t*6.0-15.0)+10.0); 46 | } 47 | 48 | // Classic Perlin noise 49 | float cnoise(float3 P) 50 | { 51 | float3 Pi0 = floor(P); // Integer part for indexing 52 | float3 Pi1 = Pi0 + (float3)1.0; // Integer part + 1 53 | Pi0 = mod289(Pi0); 54 | Pi1 = mod289(Pi1); 55 | float3 Pf0 = frac(P); // Fractional part for interpolation 56 | float3 Pf1 = Pf0 - (float3)1.0; // Fractional part - 1.0 57 | float4 ix = float4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); 58 | float4 iy = float4(Pi0.y, Pi0.y, Pi1.y, Pi1.y); 59 | float4 iz0 = (float4)Pi0.z; 60 | float4 iz1 = (float4)Pi1.z; 61 | 62 | float4 ixy = permute(permute(ix) + iy); 63 | float4 ixy0 = permute(ixy + iz0); 64 | float4 ixy1 = permute(ixy + iz1); 65 | 66 | float4 gx0 = ixy0 / 7.0; 67 | float4 gy0 = frac(floor(gx0) / 7.0) - 0.5; 68 | gx0 = frac(gx0); 69 | float4 gz0 = (float4)0.5 - abs(gx0) - abs(gy0); 70 | float4 sz0 = step(gz0, (float4)0.0); 71 | gx0 -= sz0 * (step((float4)0.0, gx0) - 0.5); 72 | gy0 -= sz0 * (step((float4)0.0, gy0) - 0.5); 73 | 74 | float4 gx1 = ixy1 / 7.0; 75 | float4 gy1 = frac(floor(gx1) / 7.0) - 0.5; 76 | gx1 = frac(gx1); 77 | float4 gz1 = (float4)0.5 - abs(gx1) - abs(gy1); 78 | float4 sz1 = step(gz1, (float4)0.0); 79 | gx1 -= sz1 * (step((float4)0.0, gx1) - 0.5); 80 | gy1 -= sz1 * (step((float4)0.0, gy1) - 0.5); 81 | 82 | float3 g000 = float3(gx0.x,gy0.x,gz0.x); 83 | float3 g100 = float3(gx0.y,gy0.y,gz0.y); 84 | float3 g010 = float3(gx0.z,gy0.z,gz0.z); 85 | float3 g110 = float3(gx0.w,gy0.w,gz0.w); 86 | float3 g001 = float3(gx1.x,gy1.x,gz1.x); 87 | float3 g101 = float3(gx1.y,gy1.y,gz1.y); 88 | float3 g011 = float3(gx1.z,gy1.z,gz1.z); 89 | float3 g111 = float3(gx1.w,gy1.w,gz1.w); 90 | 91 | float4 norm0 = taylorInvSqrt(float4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); 92 | g000 *= norm0.x; 93 | g010 *= norm0.y; 94 | g100 *= norm0.z; 95 | g110 *= norm0.w; 96 | 97 | float4 norm1 = taylorInvSqrt(float4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); 98 | g001 *= norm1.x; 99 | g011 *= norm1.y; 100 | g101 *= norm1.z; 101 | g111 *= norm1.w; 102 | 103 | float n000 = dot(g000, Pf0); 104 | float n100 = dot(g100, float3(Pf1.x, Pf0.y, Pf0.z)); 105 | float n010 = dot(g010, float3(Pf0.x, Pf1.y, Pf0.z)); 106 | float n110 = dot(g110, float3(Pf1.x, Pf1.y, Pf0.z)); 107 | float n001 = dot(g001, float3(Pf0.x, Pf0.y, Pf1.z)); 108 | float n101 = dot(g101, float3(Pf1.x, Pf0.y, Pf1.z)); 109 | float n011 = dot(g011, float3(Pf0.x, Pf1.y, Pf1.z)); 110 | float n111 = dot(g111, Pf1); 111 | 112 | float3 fade_xyz = fade(Pf0); 113 | float4 n_z = lerp(float4(n000, n100, n010, n110), float4(n001, n101, n011, n111), fade_xyz.z); 114 | float2 n_yz = lerp(n_z.xy, n_z.zw, fade_xyz.y); 115 | float n_xyz = lerp(n_yz.x, n_yz.y, fade_xyz.x); 116 | return 2.2 * n_xyz; 117 | } 118 | 119 | // Classic Perlin noise, periodic variant 120 | float pnoise(float3 P, float3 rep) 121 | { 122 | float3 Pi0 = mod(floor(P), rep); // Integer part, modulo period 123 | float3 Pi1 = mod(Pi0 + (float3)1.0, rep); // Integer part + 1, mod period 124 | Pi0 = mod289(Pi0); 125 | Pi1 = mod289(Pi1); 126 | float3 Pf0 = frac(P); // Fractional part for interpolation 127 | float3 Pf1 = Pf0 - (float3)1.0; // Fractional part - 1.0 128 | float4 ix = float4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); 129 | float4 iy = float4(Pi0.y, Pi0.y, Pi1.y, Pi1.y); 130 | float4 iz0 = (float4)Pi0.z; 131 | float4 iz1 = (float4)Pi1.z; 132 | 133 | float4 ixy = permute(permute(ix) + iy); 134 | float4 ixy0 = permute(ixy + iz0); 135 | float4 ixy1 = permute(ixy + iz1); 136 | 137 | float4 gx0 = ixy0 / 7.0; 138 | float4 gy0 = frac(floor(gx0) / 7.0) - 0.5; 139 | gx0 = frac(gx0); 140 | float4 gz0 = (float4)0.5 - abs(gx0) - abs(gy0); 141 | float4 sz0 = step(gz0, (float4)0.0); 142 | gx0 -= sz0 * (step((float4)0.0, gx0) - 0.5); 143 | gy0 -= sz0 * (step((float4)0.0, gy0) - 0.5); 144 | 145 | float4 gx1 = ixy1 / 7.0; 146 | float4 gy1 = frac(floor(gx1) / 7.0) - 0.5; 147 | gx1 = frac(gx1); 148 | float4 gz1 = (float4)0.5 - abs(gx1) - abs(gy1); 149 | float4 sz1 = step(gz1, (float4)0.0); 150 | gx1 -= sz1 * (step((float4)0.0, gx1) - 0.5); 151 | gy1 -= sz1 * (step((float4)0.0, gy1) - 0.5); 152 | 153 | float3 g000 = float3(gx0.x,gy0.x,gz0.x); 154 | float3 g100 = float3(gx0.y,gy0.y,gz0.y); 155 | float3 g010 = float3(gx0.z,gy0.z,gz0.z); 156 | float3 g110 = float3(gx0.w,gy0.w,gz0.w); 157 | float3 g001 = float3(gx1.x,gy1.x,gz1.x); 158 | float3 g101 = float3(gx1.y,gy1.y,gz1.y); 159 | float3 g011 = float3(gx1.z,gy1.z,gz1.z); 160 | float3 g111 = float3(gx1.w,gy1.w,gz1.w); 161 | 162 | float4 norm0 = taylorInvSqrt(float4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); 163 | g000 *= norm0.x; 164 | g010 *= norm0.y; 165 | g100 *= norm0.z; 166 | g110 *= norm0.w; 167 | float4 norm1 = taylorInvSqrt(float4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); 168 | g001 *= norm1.x; 169 | g011 *= norm1.y; 170 | g101 *= norm1.z; 171 | g111 *= norm1.w; 172 | 173 | float n000 = dot(g000, Pf0); 174 | float n100 = dot(g100, float3(Pf1.x, Pf0.y, Pf0.z)); 175 | float n010 = dot(g010, float3(Pf0.x, Pf1.y, Pf0.z)); 176 | float n110 = dot(g110, float3(Pf1.x, Pf1.y, Pf0.z)); 177 | float n001 = dot(g001, float3(Pf0.x, Pf0.y, Pf1.z)); 178 | float n101 = dot(g101, float3(Pf1.x, Pf0.y, Pf1.z)); 179 | float n011 = dot(g011, float3(Pf0.x, Pf1.y, Pf1.z)); 180 | float n111 = dot(g111, Pf1); 181 | 182 | float3 fade_xyz = fade(Pf0); 183 | float4 n_z = lerp(float4(n000, n100, n010, n110), float4(n001, n101, n011, n111), fade_xyz.z); 184 | float2 n_yz = lerp(n_z.xy, n_z.zw, fade_xyz.y); 185 | float n_xyz = lerp(n_yz.x, n_yz.y, fade_xyz.x); 186 | return 2.2 * n_xyz; 187 | } 188 | -------------------------------------------------------------------------------- /Assets/Kvant/Ribbon/ClassicNoise3D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c0074baec809e46f0b4150d21f41718a 3 | timeCreated: 1437658180 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kvant/Ribbon/Kernels.shader: -------------------------------------------------------------------------------- 1 | // 2 | // GPGPU kernels for Ribbon 3 | // 4 | // Texture format: 5 | // 6 | // _PositionTex.xyz = position 7 | // _PositionTex.w = random number 8 | // 9 | // _VelocityTex.xyz = velocity vector 10 | // _VelocityTex.w = 0 11 | // 12 | Shader "Hidden/Kvant/Swarm/Kernel" 13 | { 14 | Properties 15 | { 16 | _PositionTex ("-", 2D) = ""{} 17 | _VelocityTex ("-", 2D) = ""{} 18 | } 19 | 20 | CGINCLUDE 21 | 22 | #include "UnityCG.cginc" 23 | #include "ClassicNoise3D.cginc" 24 | 25 | sampler2D _PositionTex; 26 | sampler2D _VelocityTex; 27 | float4 _PositionTex_TexelSize; 28 | float4 _VelocityTex_TexelSize; 29 | 30 | float2 _Acceleration; // (min, max) 31 | float _Damp; 32 | float3 _AttractPos; 33 | float _Spread; 34 | float3 _Flow; 35 | float4 _NoiseParams; // (frequency, amplitude, animation, variance) 36 | float _RandomSeed; 37 | float2 _TimeParams; // (current, delta) 38 | 39 | // Pseudo random number generator 40 | float nrand(float2 uv, float salt) 41 | { 42 | uv += float2(salt, _RandomSeed); 43 | return frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453); 44 | } 45 | 46 | // Position dependant force field 47 | float3 position_force(float3 p, float2 uv) 48 | { 49 | p = p * _NoiseParams.x + _TimeParams.x * _NoiseParams.z + _RandomSeed; 50 | float3 uvc = float3(uv, 7.919) * _NoiseParams.w; 51 | float nx = cnoise(p + uvc.xyz); 52 | float ny = cnoise(p + uvc.yzx); 53 | float nz = cnoise(p + uvc.zxy); 54 | return float3(nx, ny, nz) * _NoiseParams.y; 55 | } 56 | 57 | // Attractor position 58 | float3 attract_point(float2 uv) 59 | { 60 | float3 r = float3(nrand(uv, 0), nrand(uv, 1), nrand(uv, 2)); 61 | return _AttractPos + (r - (float3)0.5) * _Spread; 62 | } 63 | 64 | // Pass 0: position initialization 65 | float4 frag_init_position(v2f_img i) : SV_Target 66 | { 67 | return float4(0, 0, 0, nrand(i.uv.yy, 3)); 68 | } 69 | 70 | // Pass 1: velocity initialization 71 | float4 frag_init_velocity(v2f_img i) : SV_Target 72 | { 73 | return (float4)0; 74 | } 75 | 76 | // Pass 2: position update 77 | float4 frag_update_position(v2f_img i) : SV_Target 78 | { 79 | // Fetch the current position (u=0) or the previous position (u>0). 80 | float2 uv_prev = float2(_PositionTex_TexelSize.x, 0); 81 | float4 p = tex2D(_PositionTex, i.uv - uv_prev); 82 | 83 | // Fetch the velocity vector. 84 | float3 v = tex2D(_VelocityTex, i.uv).xyz; 85 | 86 | // Add the velocity (u=0) or the flow vector (u>0). 87 | float u_0 = i.uv.x < _PositionTex_TexelSize.x; 88 | p.xyz += lerp(_Flow, v, u_0) * _TimeParams.y; 89 | 90 | return p; 91 | } 92 | 93 | // Pass 3: velocity update 94 | float4 frag_update_velocity(v2f_img i) : SV_Target 95 | { 96 | // Only needs the leftmost pixel. 97 | float2 uv = i.uv * float2(0, 1); 98 | 99 | // Fetch the current position/velocity. 100 | float3 p = tex2D(_PositionTex, uv).xyz; 101 | float3 v = tex2D(_VelocityTex, uv).xyz; 102 | 103 | // Acceleration scale factor 104 | float acs = lerp(_Acceleration.x, _Acceleration.y, nrand(uv, 4)); 105 | 106 | // Acceleration force 107 | float3 acf = attract_point(i.uv) - p + position_force(p, uv); 108 | 109 | // Damping 110 | v *= (1.0 - _Damp * _TimeParams.y); 111 | 112 | // Acceleration 113 | v += acs * acf * _TimeParams.y; 114 | 115 | return float4(v, 0); 116 | } 117 | 118 | ENDCG 119 | 120 | SubShader 121 | { 122 | Pass 123 | { 124 | CGPROGRAM 125 | #pragma target 3.0 126 | #pragma vertex vert_img 127 | #pragma fragment frag_init_position 128 | ENDCG 129 | } 130 | Pass 131 | { 132 | CGPROGRAM 133 | #pragma target 3.0 134 | #pragma vertex vert_img 135 | #pragma fragment frag_init_velocity 136 | ENDCG 137 | } 138 | Pass 139 | { 140 | CGPROGRAM 141 | #pragma target 3.0 142 | #pragma vertex vert_img 143 | #pragma fragment frag_update_position 144 | ENDCG 145 | } 146 | Pass 147 | { 148 | CGPROGRAM 149 | #pragma target 3.0 150 | #pragma vertex vert_img 151 | #pragma fragment frag_update_velocity 152 | ENDCG 153 | } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /Assets/Kvant/Ribbon/Kernels.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 93f0d24ee31b74b419c4eff10f27c931 3 | timeCreated: 1437658166 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kvant/Ribbon/Ribbon.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5099e599bb2c14524a94d26db16cf7c2 3 | timeCreated: 1437658738 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _kernelShader: {fileID: 4800000, guid: 93f0d24ee31b74b419c4eff10f27c931, type: 3} 9 | - _ribbonShader: {fileID: 4800000, guid: 33be016226e0148eea3a9a83a2223150, type: 3} 10 | executionOrder: 0 11 | icon: {instanceID: 0} 12 | userData: 13 | assetBundleName: 14 | assetBundleVariant: 15 | -------------------------------------------------------------------------------- /Assets/Kvant/Ribbon/Ribbon.shader: -------------------------------------------------------------------------------- 1 | // 2 | // Surface shader for Ribbon 3 | // 4 | // Texture format: 5 | // 6 | // _PositionTex.xyz = position 7 | // _PositionTex.w = random number 8 | // 9 | Shader "Custom/Ribbon" 10 | { 11 | Properties 12 | { 13 | _PositionTex ("-", 2D) = ""{} 14 | _Color ("-", Color) = (1, 1, 1, 1) 15 | _Color2 ("-", Color) = (1, 1, 1, 1) 16 | } 17 | 18 | CGINCLUDE 19 | 20 | #pragma multi_compile COLOR_RANDOM COLOR_SMOOTH 21 | 22 | sampler2D _PositionTex; 23 | float4 _PositionTex_TexelSize; 24 | 25 | float _RibbonWidth; 26 | half4 _Color; 27 | half4 _Color2; 28 | half _Metallic; 29 | half _Smoothness; 30 | 31 | float2 _BufferOffset; 32 | 33 | struct Input { 34 | half color; 35 | }; 36 | 37 | // pseudo random number generator 38 | float nrand(float2 uv, float salt) 39 | { 40 | uv += float2(salt, 0); 41 | return frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453); 42 | } 43 | 44 | void vert(inout appdata_full v, out Input data, float flip) 45 | { 46 | UNITY_INITIALIZE_OUTPUT(Input, data); 47 | 48 | float4 uv = float4(v.texcoord + _BufferOffset, 0, 0); 49 | float4 duv = float4(_PositionTex_TexelSize.x, 0, 0, 0); 50 | 51 | // line number 52 | float ln = uv.y; 53 | 54 | // adjacent vertices 55 | float3 p1 = tex2Dlod(_PositionTex, uv - duv * 2).xyz; 56 | float3 p2 = tex2Dlod(_PositionTex, uv ).xyz; 57 | float3 p3 = tex2Dlod(_PositionTex, uv + duv * 2).xyz; 58 | 59 | // binormal vector 60 | float3 bn = normalize(cross(p3 - p2, p2 - p1)) * flip; 61 | 62 | v.vertex.xyz = p2 + bn * _RibbonWidth * nrand(ln, 10) * v.vertex.x; 63 | v.normal = normalize(cross(bn, p2 - p1)); 64 | 65 | #if COLOR_RANDOM 66 | data.color = nrand(ln, 11); 67 | #else 68 | data.color = ln; 69 | #endif 70 | } 71 | 72 | ENDCG 73 | 74 | SubShader 75 | { 76 | Tags { "RenderType"="Opaque" } 77 | 78 | CGPROGRAM 79 | 80 | #pragma surface surf Standard vertex:vert_front nolightmap addshadow 81 | #pragma target 3.0 82 | 83 | void vert_front(inout appdata_full v, out Input data) 84 | { 85 | vert(v, data, 1); 86 | } 87 | 88 | void surf(Input IN, inout SurfaceOutputStandard o) 89 | { 90 | o.Albedo = lerp(_Color, _Color2, IN.color); 91 | o.Metallic = _Metallic; 92 | o.Smoothness = _Smoothness; 93 | } 94 | 95 | ENDCG 96 | 97 | CGPROGRAM 98 | 99 | #pragma surface surf Standard vertex:vert_back nolightmap addshadow 100 | #pragma target 3.0 101 | 102 | void vert_back(inout appdata_full v, out Input data) 103 | { 104 | vert(v, data, -1); 105 | } 106 | 107 | void surf(Input IN, inout SurfaceOutputStandard o) 108 | { 109 | o.Albedo = lerp(_Color, _Color2, IN.color); 110 | o.Metallic = _Metallic; 111 | o.Smoothness = _Smoothness; 112 | } 113 | 114 | ENDCG 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Assets/Kvant/Ribbon/Ribbon.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33be016226e0148eea3a9a83a2223150 3 | timeCreated: 1437658223 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kvant/Swarm.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fb1748d9694be4964b9445736edca0f9 3 | folderAsset: yes 4 | timeCreated: 1437052186 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kvant/Swarm/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8dcabc7e37b034ef8a41972702ae7fc8 3 | folderAsset: yes 4 | timeCreated: 1437567619 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kvant/Swarm/Editor/SwarmEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Custom editor class for Swarm 3 | // 4 | using UnityEngine; 5 | using UnityEditor; 6 | 7 | namespace Kvant 8 | { 9 | [CanEditMultipleObjects, CustomEditor(typeof(Swarm))] 10 | public class SwarmEditor : Editor 11 | { 12 | SerializedProperty _lineCount; 13 | SerializedProperty _historyLength; 14 | 15 | SerializedProperty _minAcceleration; 16 | SerializedProperty _maxAcceleration; 17 | SerializedProperty _damp; 18 | 19 | SerializedProperty _attractor; 20 | SerializedProperty _spread; 21 | SerializedProperty _flow; 22 | 23 | SerializedProperty _noiseAmplitude; 24 | SerializedProperty _noiseFrequency; 25 | SerializedProperty _noiseSpeed; 26 | SerializedProperty _noiseVariance; 27 | 28 | SerializedProperty _colorMode; 29 | SerializedProperty _color1; 30 | SerializedProperty _color2; 31 | SerializedProperty _gradientSteepness; 32 | 33 | SerializedProperty _randomSeed; 34 | 35 | static GUIContent _textAcceleration = new GUIContent("Acceleration"); 36 | static GUIContent _textAmplitude = new GUIContent("Amplitude"); 37 | static GUIContent _textFrequency = new GUIContent("Frequency"); 38 | static GUIContent _textSpeed = new GUIContent("Speed"); 39 | static GUIContent _textVariance = new GUIContent("Variance"); 40 | 41 | void OnEnable() 42 | { 43 | _lineCount = serializedObject.FindProperty("_lineCount"); 44 | _historyLength = serializedObject.FindProperty("_historyLength"); 45 | 46 | _minAcceleration = serializedObject.FindProperty("_minAcceleration"); 47 | _maxAcceleration = serializedObject.FindProperty("_maxAcceleration"); 48 | _damp = serializedObject.FindProperty("_damp"); 49 | 50 | _attractor = serializedObject.FindProperty("_attractor"); 51 | _spread = serializedObject.FindProperty("_spread"); 52 | _flow = serializedObject.FindProperty("_flow"); 53 | 54 | _noiseAmplitude = serializedObject.FindProperty("_noiseAmplitude"); 55 | _noiseFrequency = serializedObject.FindProperty("_noiseFrequency"); 56 | _noiseSpeed = serializedObject.FindProperty("_noiseSpeed"); 57 | _noiseVariance = serializedObject.FindProperty("_noiseVariance"); 58 | 59 | _colorMode = serializedObject.FindProperty("_colorMode"); 60 | _color1 = serializedObject.FindProperty("_color1"); 61 | _color2 = serializedObject.FindProperty("_color2"); 62 | _gradientSteepness = serializedObject.FindProperty("_gradientSteepness"); 63 | 64 | _randomSeed = serializedObject.FindProperty("_randomSeed"); 65 | } 66 | 67 | public override void OnInspectorGUI() 68 | { 69 | var instance = target as Swarm; 70 | 71 | serializedObject.Update(); 72 | 73 | EditorGUI.BeginChangeCheck(); 74 | 75 | EditorGUILayout.PropertyField(_lineCount); 76 | EditorGUILayout.PropertyField(_historyLength); 77 | 78 | if (EditorGUI.EndChangeCheck()) instance.NotifyConfigChange(); 79 | 80 | EditorGUILayout.Space(); 81 | 82 | EditorGUILayout.LabelField("Dynamics", EditorStyles.boldLabel); 83 | MinMaxSlider(_textAcceleration, _minAcceleration, _maxAcceleration, 0.01f, 10.0f); 84 | EditorGUILayout.Slider(_damp, 0, 5); 85 | 86 | EditorGUILayout.Space(); 87 | 88 | EditorGUILayout.LabelField("External Forces", EditorStyles.boldLabel); 89 | EditorGUILayout.PropertyField(_attractor); 90 | EditorGUILayout.Slider(_spread, 0, 5); 91 | EditorGUILayout.PropertyField(_flow); 92 | 93 | EditorGUILayout.Space(); 94 | 95 | EditorGUILayout.LabelField("Turbulent Noise", EditorStyles.boldLabel); 96 | EditorGUILayout.Slider(_noiseAmplitude, 0.0f, 10.0f, _textAmplitude); 97 | EditorGUILayout.Slider(_noiseFrequency, 0.01f, 1.0f, _textFrequency); 98 | EditorGUILayout.Slider(_noiseSpeed, 0.0f, 5.0f, _textSpeed); 99 | EditorGUILayout.Slider(_noiseVariance, 0.0f, 10.0f, _textVariance); 100 | 101 | EditorGUILayout.Space(); 102 | 103 | EditorGUILayout.LabelField("Render Settings", EditorStyles.boldLabel); 104 | EditorGUILayout.PropertyField(_colorMode); 105 | EditorGUILayout.PropertyField(_color1); 106 | EditorGUILayout.PropertyField(_color2); 107 | EditorGUILayout.Slider(_gradientSteepness, 1, 10); 108 | 109 | EditorGUILayout.Space(); 110 | 111 | EditorGUILayout.PropertyField(_randomSeed); 112 | 113 | serializedObject.ApplyModifiedProperties(); 114 | } 115 | 116 | void MinMaxSlider(GUIContent label, SerializedProperty propMin, SerializedProperty propMax, float minLimit, float maxLimit) 117 | { 118 | var min = propMin.floatValue; 119 | var max = propMax.floatValue; 120 | 121 | EditorGUI.BeginChangeCheck(); 122 | 123 | // Min-max slider. 124 | EditorGUILayout.MinMaxSlider(label, ref min, ref max, minLimit, maxLimit); 125 | 126 | var prevIndent = EditorGUI.indentLevel; 127 | EditorGUI.indentLevel = 0; 128 | 129 | // Float value boxes. 130 | var rect = EditorGUILayout.GetControlRect(); 131 | rect.x += EditorGUIUtility.labelWidth; 132 | rect.width = (rect.width - EditorGUIUtility.labelWidth) / 2 - 2; 133 | 134 | if (EditorGUIUtility.wideMode) 135 | { 136 | EditorGUIUtility.labelWidth = 28; 137 | min = Mathf.Clamp(EditorGUI.FloatField(rect, "min", min), minLimit, max); 138 | rect.x += rect.width + 4; 139 | max = Mathf.Clamp(EditorGUI.FloatField(rect, "max", max), min, maxLimit); 140 | EditorGUIUtility.labelWidth = 0; 141 | } 142 | else 143 | { 144 | min = Mathf.Clamp(EditorGUI.FloatField(rect, min), minLimit, max); 145 | rect.x += rect.width + 4; 146 | max = Mathf.Clamp(EditorGUI.FloatField(rect, max), min, maxLimit); 147 | } 148 | 149 | EditorGUI.indentLevel = prevIndent; 150 | 151 | if (EditorGUI.EndChangeCheck()) { 152 | propMin.floatValue = min; 153 | propMax.floatValue = max; 154 | } 155 | } 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /Assets/Kvant/Swarm/Editor/SwarmEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 217a1601b5b5742949d0145e01de74c2 3 | timeCreated: 1437568802 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Kvant/Swarm/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bb1472caaa0ec412fac443254c3451a2 3 | folderAsset: yes 4 | timeCreated: 1437138755 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kvant/Swarm/Shaders/ClassicNoise3D.cginc: -------------------------------------------------------------------------------- 1 | // An HLSL variant of the Gustavson's webgl-noise shader. 2 | // Translated by Keijiro Takahashi 3 | // For further information, see the original notice below. 4 | 5 | // 6 | // GLSL textureless classic 3D noise "cnoise", 7 | // with an RSL-style periodic variant "pnoise". 8 | // Author: Stefan Gustavson (stefan.gustavson@liu.se) 9 | // Version: 2011-10-11 10 | // 11 | // Many thanks to Ian McEwan of Ashima Arts for the 12 | // ideas for permutation and gradient selection. 13 | // 14 | // Copyright (c) 2011 Stefan Gustavson. All rights reserved. 15 | // Distributed under the MIT license. See LICENSE file. 16 | // https://github.com/ashima/webgl-noise 17 | // 18 | 19 | float3 mod(float3 x, float3 y) 20 | { 21 | return x - y * floor(x / y); 22 | } 23 | 24 | float3 mod289(float3 x) 25 | { 26 | return x - floor(x / 289.0) * 289.0; 27 | } 28 | 29 | float4 mod289(float4 x) 30 | { 31 | return x - floor(x / 289.0) * 289.0; 32 | } 33 | 34 | float4 permute(float4 x) 35 | { 36 | return mod289(((x*34.0)+1.0)*x); 37 | } 38 | 39 | float4 taylorInvSqrt(float4 r) 40 | { 41 | return (float4)1.79284291400159 - r * 0.85373472095314; 42 | } 43 | 44 | float3 fade(float3 t) { 45 | return t*t*t*(t*(t*6.0-15.0)+10.0); 46 | } 47 | 48 | // Classic Perlin noise 49 | float cnoise(float3 P) 50 | { 51 | float3 Pi0 = floor(P); // Integer part for indexing 52 | float3 Pi1 = Pi0 + (float3)1.0; // Integer part + 1 53 | Pi0 = mod289(Pi0); 54 | Pi1 = mod289(Pi1); 55 | float3 Pf0 = frac(P); // Fractional part for interpolation 56 | float3 Pf1 = Pf0 - (float3)1.0; // Fractional part - 1.0 57 | float4 ix = float4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); 58 | float4 iy = float4(Pi0.y, Pi0.y, Pi1.y, Pi1.y); 59 | float4 iz0 = (float4)Pi0.z; 60 | float4 iz1 = (float4)Pi1.z; 61 | 62 | float4 ixy = permute(permute(ix) + iy); 63 | float4 ixy0 = permute(ixy + iz0); 64 | float4 ixy1 = permute(ixy + iz1); 65 | 66 | float4 gx0 = ixy0 / 7.0; 67 | float4 gy0 = frac(floor(gx0) / 7.0) - 0.5; 68 | gx0 = frac(gx0); 69 | float4 gz0 = (float4)0.5 - abs(gx0) - abs(gy0); 70 | float4 sz0 = step(gz0, (float4)0.0); 71 | gx0 -= sz0 * (step((float4)0.0, gx0) - 0.5); 72 | gy0 -= sz0 * (step((float4)0.0, gy0) - 0.5); 73 | 74 | float4 gx1 = ixy1 / 7.0; 75 | float4 gy1 = frac(floor(gx1) / 7.0) - 0.5; 76 | gx1 = frac(gx1); 77 | float4 gz1 = (float4)0.5 - abs(gx1) - abs(gy1); 78 | float4 sz1 = step(gz1, (float4)0.0); 79 | gx1 -= sz1 * (step((float4)0.0, gx1) - 0.5); 80 | gy1 -= sz1 * (step((float4)0.0, gy1) - 0.5); 81 | 82 | float3 g000 = float3(gx0.x,gy0.x,gz0.x); 83 | float3 g100 = float3(gx0.y,gy0.y,gz0.y); 84 | float3 g010 = float3(gx0.z,gy0.z,gz0.z); 85 | float3 g110 = float3(gx0.w,gy0.w,gz0.w); 86 | float3 g001 = float3(gx1.x,gy1.x,gz1.x); 87 | float3 g101 = float3(gx1.y,gy1.y,gz1.y); 88 | float3 g011 = float3(gx1.z,gy1.z,gz1.z); 89 | float3 g111 = float3(gx1.w,gy1.w,gz1.w); 90 | 91 | float4 norm0 = taylorInvSqrt(float4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); 92 | g000 *= norm0.x; 93 | g010 *= norm0.y; 94 | g100 *= norm0.z; 95 | g110 *= norm0.w; 96 | 97 | float4 norm1 = taylorInvSqrt(float4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); 98 | g001 *= norm1.x; 99 | g011 *= norm1.y; 100 | g101 *= norm1.z; 101 | g111 *= norm1.w; 102 | 103 | float n000 = dot(g000, Pf0); 104 | float n100 = dot(g100, float3(Pf1.x, Pf0.y, Pf0.z)); 105 | float n010 = dot(g010, float3(Pf0.x, Pf1.y, Pf0.z)); 106 | float n110 = dot(g110, float3(Pf1.x, Pf1.y, Pf0.z)); 107 | float n001 = dot(g001, float3(Pf0.x, Pf0.y, Pf1.z)); 108 | float n101 = dot(g101, float3(Pf1.x, Pf0.y, Pf1.z)); 109 | float n011 = dot(g011, float3(Pf0.x, Pf1.y, Pf1.z)); 110 | float n111 = dot(g111, Pf1); 111 | 112 | float3 fade_xyz = fade(Pf0); 113 | float4 n_z = lerp(float4(n000, n100, n010, n110), float4(n001, n101, n011, n111), fade_xyz.z); 114 | float2 n_yz = lerp(n_z.xy, n_z.zw, fade_xyz.y); 115 | float n_xyz = lerp(n_yz.x, n_yz.y, fade_xyz.x); 116 | return 2.2 * n_xyz; 117 | } 118 | 119 | // Classic Perlin noise, periodic variant 120 | float pnoise(float3 P, float3 rep) 121 | { 122 | float3 Pi0 = mod(floor(P), rep); // Integer part, modulo period 123 | float3 Pi1 = mod(Pi0 + (float3)1.0, rep); // Integer part + 1, mod period 124 | Pi0 = mod289(Pi0); 125 | Pi1 = mod289(Pi1); 126 | float3 Pf0 = frac(P); // Fractional part for interpolation 127 | float3 Pf1 = Pf0 - (float3)1.0; // Fractional part - 1.0 128 | float4 ix = float4(Pi0.x, Pi1.x, Pi0.x, Pi1.x); 129 | float4 iy = float4(Pi0.y, Pi0.y, Pi1.y, Pi1.y); 130 | float4 iz0 = (float4)Pi0.z; 131 | float4 iz1 = (float4)Pi1.z; 132 | 133 | float4 ixy = permute(permute(ix) + iy); 134 | float4 ixy0 = permute(ixy + iz0); 135 | float4 ixy1 = permute(ixy + iz1); 136 | 137 | float4 gx0 = ixy0 / 7.0; 138 | float4 gy0 = frac(floor(gx0) / 7.0) - 0.5; 139 | gx0 = frac(gx0); 140 | float4 gz0 = (float4)0.5 - abs(gx0) - abs(gy0); 141 | float4 sz0 = step(gz0, (float4)0.0); 142 | gx0 -= sz0 * (step((float4)0.0, gx0) - 0.5); 143 | gy0 -= sz0 * (step((float4)0.0, gy0) - 0.5); 144 | 145 | float4 gx1 = ixy1 / 7.0; 146 | float4 gy1 = frac(floor(gx1) / 7.0) - 0.5; 147 | gx1 = frac(gx1); 148 | float4 gz1 = (float4)0.5 - abs(gx1) - abs(gy1); 149 | float4 sz1 = step(gz1, (float4)0.0); 150 | gx1 -= sz1 * (step((float4)0.0, gx1) - 0.5); 151 | gy1 -= sz1 * (step((float4)0.0, gy1) - 0.5); 152 | 153 | float3 g000 = float3(gx0.x,gy0.x,gz0.x); 154 | float3 g100 = float3(gx0.y,gy0.y,gz0.y); 155 | float3 g010 = float3(gx0.z,gy0.z,gz0.z); 156 | float3 g110 = float3(gx0.w,gy0.w,gz0.w); 157 | float3 g001 = float3(gx1.x,gy1.x,gz1.x); 158 | float3 g101 = float3(gx1.y,gy1.y,gz1.y); 159 | float3 g011 = float3(gx1.z,gy1.z,gz1.z); 160 | float3 g111 = float3(gx1.w,gy1.w,gz1.w); 161 | 162 | float4 norm0 = taylorInvSqrt(float4(dot(g000, g000), dot(g010, g010), dot(g100, g100), dot(g110, g110))); 163 | g000 *= norm0.x; 164 | g010 *= norm0.y; 165 | g100 *= norm0.z; 166 | g110 *= norm0.w; 167 | float4 norm1 = taylorInvSqrt(float4(dot(g001, g001), dot(g011, g011), dot(g101, g101), dot(g111, g111))); 168 | g001 *= norm1.x; 169 | g011 *= norm1.y; 170 | g101 *= norm1.z; 171 | g111 *= norm1.w; 172 | 173 | float n000 = dot(g000, Pf0); 174 | float n100 = dot(g100, float3(Pf1.x, Pf0.y, Pf0.z)); 175 | float n010 = dot(g010, float3(Pf0.x, Pf1.y, Pf0.z)); 176 | float n110 = dot(g110, float3(Pf1.x, Pf1.y, Pf0.z)); 177 | float n001 = dot(g001, float3(Pf0.x, Pf0.y, Pf1.z)); 178 | float n101 = dot(g101, float3(Pf1.x, Pf0.y, Pf1.z)); 179 | float n011 = dot(g011, float3(Pf0.x, Pf1.y, Pf1.z)); 180 | float n111 = dot(g111, Pf1); 181 | 182 | float3 fade_xyz = fade(Pf0); 183 | float4 n_z = lerp(float4(n000, n100, n010, n110), float4(n001, n101, n011, n111), fade_xyz.z); 184 | float2 n_yz = lerp(n_z.xy, n_z.zw, fade_xyz.y); 185 | float n_xyz = lerp(n_yz.x, n_yz.y, fade_xyz.x); 186 | return 2.2 * n_xyz; 187 | } 188 | -------------------------------------------------------------------------------- /Assets/Kvant/Swarm/Shaders/ClassicNoise3D.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 14816f1cf180b45498e9c0099c959819 3 | timeCreated: 1437139790 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kvant/Swarm/Shaders/Kernel.shader: -------------------------------------------------------------------------------- 1 | // 2 | // GPGPU kernels for Swarm 3 | // 4 | // Texture format: 5 | // 6 | // _PositionTex.xyz = position 7 | // _PositionTex.w = random number 8 | // 9 | // _VelocityTex.xyz = velocity vector 10 | // _VelocityTex.w = 0 11 | // 12 | Shader "Hidden/Kvant/Swarm/Kernel" 13 | { 14 | Properties 15 | { 16 | _PositionTex ("-", 2D) = ""{} 17 | _VelocityTex ("-", 2D) = ""{} 18 | } 19 | 20 | CGINCLUDE 21 | 22 | #include "UnityCG.cginc" 23 | #include "ClassicNoise3D.cginc" 24 | 25 | sampler2D _PositionTex; 26 | sampler2D _VelocityTex; 27 | float4 _PositionTex_TexelSize; 28 | float4 _VelocityTex_TexelSize; 29 | 30 | float3 _AttractPos; 31 | float2 _Acceleration; // (min, max) 32 | float _Spread; 33 | float _Damp; 34 | float4 _NoiseParams; // (frequency, amplitude, animation, variance) 35 | float _RandomSeed; 36 | float3 _Flow; 37 | float _DeltaTime; 38 | 39 | // Pseudo random number generator 40 | float nrand(float2 uv, float salt) 41 | { 42 | uv += float2(salt, _RandomSeed); 43 | return frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453); 44 | } 45 | 46 | // Position dependant force field 47 | float3 position_force(float3 p, float2 uv) 48 | { 49 | p = p * _NoiseParams.x + _Time.y * _NoiseParams.z + _RandomSeed; 50 | float3 uvc = float3(uv, 7.919) * _NoiseParams.w; 51 | float nx = cnoise(p + uvc.xyz); 52 | float ny = cnoise(p + uvc.yzx); 53 | float nz = cnoise(p + uvc.zxy); 54 | return float3(nx, ny, nz) * _NoiseParams.y; 55 | } 56 | 57 | // Attractor position 58 | float3 attract_point(float2 uv) 59 | { 60 | float3 r = float3(nrand(uv, 0), nrand(uv, 1), nrand(uv, 2)); 61 | return _AttractPos + (r - (float3)0.5) * _Spread; 62 | } 63 | 64 | // Pass 0: position initialization 65 | float4 frag_init_position(v2f_img i) : SV_Target 66 | { 67 | return float4(0, 0, 0, nrand(i.uv.yy, 3)); 68 | } 69 | 70 | // Pass 1: velocity initialization 71 | float4 frag_init_velocity(v2f_img i) : SV_Target 72 | { 73 | return (float4)0; 74 | } 75 | 76 | // Pass 2: position update 77 | float4 frag_update_position(v2f_img i) : SV_Target 78 | { 79 | // Fetch the current position (u=0) or the previous position (u>0). 80 | float2 uv_prev = float2(_PositionTex_TexelSize.x, 0); 81 | float4 p = tex2D(_PositionTex, i.uv - uv_prev); 82 | 83 | // Fetch the velocity vector. 84 | float3 v = tex2D(_VelocityTex, i.uv).xyz; 85 | 86 | // Add the velocity (u=0) or the flow vector (u>0). 87 | float u_0 = i.uv.x < _PositionTex_TexelSize.x; 88 | p.xyz += lerp(_Flow, v, u_0) * _DeltaTime; 89 | 90 | return p; 91 | } 92 | 93 | // Pass 3: velocity update 94 | float4 frag_update_velocity(v2f_img i) : SV_Target 95 | { 96 | // Only needs the leftmost pixel. 97 | float2 uv = i.uv * float2(0, 1); 98 | 99 | // Fetch the current position/velocity. 100 | float3 p = tex2D(_PositionTex, uv).xyz; 101 | float3 v = tex2D(_VelocityTex, uv).xyz; 102 | 103 | // Acceleration scale factor 104 | float acs = lerp(_Acceleration.x, _Acceleration.y, nrand(uv, 4)); 105 | 106 | // Acceleration force 107 | float3 acf = attract_point(i.uv) - p + position_force(p, uv); 108 | 109 | // Damping 110 | v *= (1.0 - _Damp * _DeltaTime); 111 | 112 | // Acceleration 113 | v += acs * acf * _DeltaTime; 114 | 115 | return float4(v, 0); 116 | } 117 | 118 | ENDCG 119 | 120 | SubShader 121 | { 122 | Pass 123 | { 124 | CGPROGRAM 125 | #pragma target 3.0 126 | #pragma vertex vert_img 127 | #pragma fragment frag_init_position 128 | ENDCG 129 | } 130 | Pass 131 | { 132 | CGPROGRAM 133 | #pragma target 3.0 134 | #pragma vertex vert_img 135 | #pragma fragment frag_init_velocity 136 | ENDCG 137 | } 138 | Pass 139 | { 140 | CGPROGRAM 141 | #pragma target 3.0 142 | #pragma vertex vert_img 143 | #pragma fragment frag_update_position 144 | ENDCG 145 | } 146 | Pass 147 | { 148 | CGPROGRAM 149 | #pragma target 3.0 150 | #pragma vertex vert_img 151 | #pragma fragment frag_update_velocity 152 | ENDCG 153 | } 154 | } 155 | } 156 | -------------------------------------------------------------------------------- /Assets/Kvant/Swarm/Shaders/Kernel.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab176efa7135a4f038c7b318a0b3c9ef 3 | timeCreated: 1437139790 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kvant/Swarm/Shaders/Line.shader: -------------------------------------------------------------------------------- 1 | // 2 | // Line shader for Swarm 3 | // 4 | // Texture format: 5 | // 6 | // _PositionTex.xyz = position 7 | // _PositionTex.w = random number 8 | // 9 | Shader "Hidden/Kvant/Swarm/Line" 10 | { 11 | Properties 12 | { 13 | _PositionTex ("-", 2D) = ""{} 14 | [HDR] _Color1 ("-", Color) = (1, 1, 1, 1) 15 | [HDR] _Color2 ("-", Color) = (1, 1, 1, 1) 16 | } 17 | 18 | CGINCLUDE 19 | 20 | #pragma multi_compile COLOR_RANDOM COLOR_SMOOTH 21 | #pragma multi_compile_fog 22 | 23 | #include "UnityCG.cginc" 24 | 25 | struct appdata 26 | { 27 | float4 position : POSITION; 28 | float2 texcoord : TEXCOORD0; 29 | }; 30 | 31 | struct v2f 32 | { 33 | float4 position : SV_POSITION; 34 | half4 color : COLOR; 35 | UNITY_FOG_COORDS(0) 36 | }; 37 | 38 | sampler2D _PositionTex; 39 | float4 _PositionTex_TexelSize; 40 | 41 | float2 _BufferOffset; 42 | 43 | half4 _Color1; 44 | half4 _Color2; 45 | half _GradExp; 46 | 47 | v2f vert(appdata v) 48 | { 49 | v2f o; 50 | 51 | float2 uv = v.texcoord.xy + _BufferOffset; 52 | float4 p = tex2Dlod(_PositionTex, float4(uv, 0, 0)); 53 | 54 | float3 vp = v.position.xyz + p.xyz; 55 | o.position = mul(UNITY_MATRIX_MVP, float4(vp, 1)); 56 | 57 | #if COLOR_RANDOM 58 | float4 c = lerp(_Color1, _Color2, p.w); 59 | #else 60 | float4 c = lerp(_Color1, _Color2, uv.y); 61 | #endif 62 | c.a *= pow(1.0 - uv.x, _GradExp); 63 | o.color = c; 64 | 65 | UNITY_TRANSFER_FOG(o, o.position); 66 | return o; 67 | } 68 | 69 | half4 frag(v2f i) : SV_Target 70 | { 71 | fixed4 c = i.color; 72 | UNITY_APPLY_FOG(i.fogCoord, c); 73 | return c; 74 | } 75 | 76 | ENDCG 77 | 78 | SubShader 79 | { 80 | Tags { "RenderType"="Transparent" "Queue"="Transparent" } 81 | Pass 82 | { 83 | Blend SrcAlpha One 84 | ZWrite Off 85 | CGPROGRAM 86 | #pragma target 3.0 87 | #pragma vertex vert 88 | #pragma fragment frag 89 | ENDCG 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /Assets/Kvant/Swarm/Shaders/Line.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c8221b0c66b749e38892c32d2f99546 3 | timeCreated: 1437139986 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Kvant/Swarm/Swarm.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 35cbd57b5b84b46d4bcaeafa15a5f7e5 3 | timeCreated: 1437140000 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _kernelShader: {fileID: 4800000, guid: ab176efa7135a4f038c7b318a0b3c9ef, type: 3} 9 | - _lineShader: {fileID: 4800000, guid: 8c8221b0c66b749e38892c32d2f99546, type: 3} 10 | executionOrder: 0 11 | icon: {instanceID: 0} 12 | userData: 13 | assetBundleName: 14 | assetBundleVariant: 15 | -------------------------------------------------------------------------------- /Assets/Reaktion.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 487429d9beca24ae78ab8ac96eb73dde 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Reaktion/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 263f8cf5a4c1141e6a79dc1c86d69dc2 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Reaktion/Editor/Utility.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1c8c8f5affaaa4616a15e69dda142154 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Reaktion/Editor/Utility/ConstantMotionEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Reaktion - An audio reactive animation toolkit for Unity. 3 | // 4 | // Copyright (C) 2013, 2014 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | using UnityEngine; 24 | using UnityEditor; 25 | using System.Collections; 26 | 27 | namespace Reaktion { 28 | 29 | // Custom property drawer for TransformElement. 30 | [CustomPropertyDrawer(typeof(ConstantMotion.TransformElement))] 31 | class ConstantMotionElementDrawer : PropertyDrawer 32 | { 33 | // Labels and values for TransformMode. 34 | static GUIContent[] modeLabels = { 35 | new GUIContent("Off"), 36 | new GUIContent("X Axis"), 37 | new GUIContent("Y Axis"), 38 | new GUIContent("Z Axis"), 39 | new GUIContent("Arbitrary Vector"), 40 | new GUIContent("Random Vector") 41 | }; 42 | static int[] modeValues = { 0, 1, 2, 3, 4, 5 }; 43 | 44 | static int GetExpansionLevel(SerializedProperty property) 45 | { 46 | var mode = property.FindPropertyRelative("mode"); 47 | // Fully expand if it has different values. 48 | if (mode.hasMultipleDifferentValues) return 2; 49 | // "Off" 50 | if (mode.enumValueIndex == 0) return 0; 51 | // Fully expand if it's in Arbitrary mode. 52 | if (mode.enumValueIndex == (int)ConstantMotion.TransformMode.Arbitrary) return 2; 53 | // Expand one level. 54 | return 1; 55 | } 56 | 57 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 58 | { 59 | int rows = new int[]{1, 3, 4}[GetExpansionLevel(property)]; 60 | return EditorGUIUtility.singleLineHeight * rows + 61 | EditorGUIUtility.standardVerticalSpacing * (rows - 1); 62 | } 63 | 64 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 65 | { 66 | EditorGUI.BeginProperty(position, label, property); 67 | 68 | position.height = EditorGUIUtility.singleLineHeight; 69 | var rowHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; 70 | 71 | // Transform mode selector drop-down. 72 | EditorGUI.IntPopup(position, property.FindPropertyRelative("mode"), modeLabels, modeValues, label); 73 | position.y += rowHeight; 74 | 75 | var expansion = GetExpansionLevel(property); 76 | if (expansion > 0) 77 | { 78 | // Insert an indent. 79 | position.x += 16; 80 | position.width -= 16; 81 | EditorGUIUtility.labelWidth -= 16; 82 | 83 | if (expansion == 2) 84 | { 85 | // Vector box. 86 | EditorGUI.PropertyField(position, property.FindPropertyRelative("arbitraryVector"), GUIContent.none); 87 | position.y += rowHeight; 88 | } 89 | 90 | // Velocity box. 91 | EditorGUI.PropertyField(position, property.FindPropertyRelative("velocity"), new GUIContent("Velocity")); 92 | position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; 93 | 94 | // Randomness slider. 95 | EditorGUI.Slider(position, property.FindPropertyRelative("randomness"), 0, 1, new GUIContent("Randomness")); 96 | } 97 | 98 | EditorGUI.EndProperty(); 99 | } 100 | } 101 | 102 | [CustomEditor(typeof(ConstantMotion)), CanEditMultipleObjects] 103 | public class ConstantMotionEditor : Editor 104 | { 105 | SerializedProperty propPosition; 106 | SerializedProperty propRotation; 107 | SerializedProperty propUseLocalCoordinate; 108 | GUIContent labelLocalCoordinate; 109 | 110 | void OnEnable() 111 | { 112 | propPosition = serializedObject.FindProperty("position"); 113 | propRotation = serializedObject.FindProperty("rotation"); 114 | propUseLocalCoordinate = serializedObject.FindProperty("useLocalCoordinate"); 115 | labelLocalCoordinate = new GUIContent("Local Coordinate"); 116 | } 117 | 118 | public override void OnInspectorGUI() 119 | { 120 | serializedObject.Update(); 121 | EditorGUILayout.PropertyField(propPosition); 122 | EditorGUILayout.PropertyField(propRotation); 123 | EditorGUILayout.PropertyField(propUseLocalCoordinate, labelLocalCoordinate); 124 | serializedObject.ApplyModifiedProperties(); 125 | } 126 | } 127 | 128 | } // namespace Reaktion 129 | -------------------------------------------------------------------------------- /Assets/Reaktion/Editor/Utility/ConstantMotionEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: af7f5def51f424dc4baac2ab376b2c60 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Reaktion/Editor/Utility/JitterMotionEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Reaktion - An audio reactive animation toolkit for Unity. 3 | // 4 | // Copyright (C) 2013, 2014 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | using UnityEngine; 24 | using UnityEditor; 25 | using System.Collections; 26 | 27 | namespace Reaktion { 28 | 29 | [CustomEditor(typeof(JitterMotion)), CanEditMultipleObjects] 30 | public class JitterMotionEditor : Editor 31 | { 32 | SerializedProperty propPositionFrequency; 33 | SerializedProperty propRotationFrequency; 34 | 35 | SerializedProperty propPositionAmount; 36 | SerializedProperty propRotationAmount; 37 | 38 | SerializedProperty propPositionComponents; 39 | SerializedProperty propRotationComponents; 40 | 41 | SerializedProperty propPositionOctave; 42 | SerializedProperty propRotationOctave; 43 | 44 | GUIContent labelFrequency; 45 | GUIContent labelAmount; 46 | GUIContent labelOctave; 47 | 48 | void OnEnable() 49 | { 50 | propPositionFrequency = serializedObject.FindProperty("positionFrequency"); 51 | propRotationFrequency = serializedObject.FindProperty("rotationFrequency"); 52 | 53 | propPositionAmount = serializedObject.FindProperty("positionAmount"); 54 | propRotationAmount = serializedObject.FindProperty("rotationAmount"); 55 | 56 | propPositionComponents = serializedObject.FindProperty("positionComponents"); 57 | propRotationComponents = serializedObject.FindProperty("rotationComponents"); 58 | 59 | propPositionOctave = serializedObject.FindProperty("positionOctave"); 60 | propRotationOctave = serializedObject.FindProperty("rotationOctave"); 61 | 62 | labelFrequency = new GUIContent("Frequency"); 63 | labelAmount = new GUIContent("Noise Strength"); 64 | labelOctave = new GUIContent("Fractal Level"); 65 | } 66 | 67 | public override void OnInspectorGUI() 68 | { 69 | serializedObject.Update(); 70 | 71 | EditorGUILayout.LabelField("Position"); 72 | EditorGUI.indentLevel++; 73 | EditorGUILayout.PropertyField(propPositionAmount, labelAmount); 74 | EditorGUILayout.PropertyField(propPositionComponents, GUIContent.none); 75 | EditorGUILayout.PropertyField(propPositionFrequency, labelFrequency); 76 | EditorGUILayout.IntSlider(propPositionOctave, 1, 8, labelOctave); 77 | EditorGUI.indentLevel--; 78 | 79 | EditorGUILayout.LabelField("Rotation"); 80 | EditorGUI.indentLevel++; 81 | EditorGUILayout.PropertyField(propRotationAmount, labelAmount); 82 | EditorGUILayout.PropertyField(propRotationComponents, GUIContent.none); 83 | EditorGUILayout.PropertyField(propRotationFrequency, labelFrequency); 84 | EditorGUILayout.IntSlider(propRotationOctave, 1, 8, labelOctave); 85 | EditorGUI.indentLevel--; 86 | 87 | serializedObject.ApplyModifiedProperties(); 88 | } 89 | } 90 | 91 | } // namespace Reaktion 92 | -------------------------------------------------------------------------------- /Assets/Reaktion/Editor/Utility/JitterMotionEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 268ea7a40f25a4aca9338ec15fae8021 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Reaktion/Internal.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 326e33d18c9d64154b21ab0147da9239 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Reaktion/Internal/Perlin.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Reaktion - An audio reactive animation toolkit for Unity. 3 | // 4 | // Copyright (C) 2013, 2014 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | 24 | using UnityEngine; 25 | using System.Runtime.InteropServices; 26 | 27 | namespace Reaktion { 28 | 29 | public static class Perlin 30 | { 31 | // 32 | // Based on the original implementation by Ken Perlin 33 | // http://mrl.nyu.edu/~perlin/noise/ 34 | // 35 | 36 | #region Noise functions 37 | 38 | public static float Noise (float x) 39 | { 40 | var X = Mathf.FloorToInt (x) & 0xff; 41 | x -= Mathf.Floor (x); 42 | return Lerp (Fade (x), Grad(X, x), Grad (X + 1, x - 1)); 43 | } 44 | 45 | public static float Noise (float x, float y) 46 | { 47 | var X = Mathf.FloorToInt (x) & 0xff; 48 | var Y = Mathf.FloorToInt (y) & 0xff; 49 | x -= Mathf.Floor (x); 50 | y -= Mathf.Floor (y); 51 | var u = Fade (x); 52 | var v = Fade (y); 53 | var A = (perm [X ] + Y) & 0xff; 54 | var B = (perm [X + 1] + Y) & 0xff; 55 | return Lerp (v, Lerp (u, Grad (A , x, y ), Grad (B, x - 1, y )), 56 | Lerp (u, Grad (A + 1, x, y - 1), Grad (B + 1, x - 1, y - 1))); 57 | } 58 | 59 | public static float Noise (Vector2 coord) 60 | { 61 | return Noise (coord.x, coord.y); 62 | } 63 | 64 | public static float Noise (float x, float y, float z) 65 | { 66 | var X = Mathf.FloorToInt (x) & 0xff; 67 | var Y = Mathf.FloorToInt (y) & 0xff; 68 | var Z = Mathf.FloorToInt (z) & 0xff; 69 | x -= Mathf.Floor (x); 70 | y -= Mathf.Floor (y); 71 | z -= Mathf.Floor (z); 72 | var u = Fade (x); 73 | var v = Fade (y); 74 | var w = Fade (z); 75 | var A = (perm [X ] + Y) & 0xff; 76 | var B = (perm [X + 1] + Y) & 0xff; 77 | var AA = (perm [A ] + Z) & 0xff; 78 | var BA = (perm [B ] + Z) & 0xff; 79 | var AB = (perm [A + 1] + Z) & 0xff; 80 | var BB = (perm [B + 1] + Z) & 0xff; 81 | return Lerp (w, Lerp (v, Lerp (u, Grad (AA , x , y , z ), Grad (BA , x - 1, y , z )), 82 | Lerp (u, Grad (AB , x , y - 1, z ), Grad (BB , x - 1, y - 1, z ))), 83 | Lerp (v, Lerp (u, Grad (AA + 1, x , y , z - 1), Grad (BA + 1, x - 1, y , z - 1)), 84 | Lerp (u, Grad (AB + 1, x , y - 1, z - 1), Grad (BB + 1, x - 1, y - 1, z - 1)))); 85 | } 86 | 87 | public static float Noise (Vector3 coord) 88 | { 89 | return Noise (coord.x, coord.y, coord.z); 90 | } 91 | 92 | #endregion 93 | 94 | #region fBm functions 95 | 96 | public static float Fbm (float x, int octave) 97 | { 98 | var f = 0.0f; 99 | var w = 0.5f; 100 | for (var i = 0; i < octave; i++) { 101 | f += w * Noise (x); 102 | x *= 2.0f; 103 | w *= 0.5f; 104 | } 105 | return f; 106 | } 107 | 108 | public static float Fbm (Vector2 coord, int octave) 109 | { 110 | var f = 0.0f; 111 | var w = 0.5f; 112 | for (var i = 0; i < octave; i++) { 113 | f += w * Noise (coord); 114 | coord *= 2.0f; 115 | w *= 0.5f; 116 | } 117 | return f; 118 | } 119 | 120 | public static float Fbm (Vector3 coord, int octave) 121 | { 122 | var f = 0.0f; 123 | var w = 0.5f; 124 | for (var i = 0; i < octave; i++) { 125 | f += w * Noise (coord); 126 | coord *= 2.0f; 127 | w *= 0.5f; 128 | } 129 | return f; 130 | } 131 | 132 | #endregion 133 | 134 | #region Private functions 135 | 136 | static float Fade (float t) 137 | { 138 | return t * t * t * (t * (t * 6 - 15) + 10); 139 | } 140 | 141 | static float Lerp (float t, float a, float b) 142 | { 143 | return a + t * (b - a); 144 | } 145 | 146 | static float Grad (int i, float x) 147 | { 148 | return (perm [i] & 1) != 0 ? x : -x; 149 | } 150 | 151 | static float Grad (int i, float x, float y) 152 | { 153 | var h = perm [i]; 154 | return ((h & 1) != 0 ? x : -x) + ((h & 2) != 0 ? y : -y); 155 | } 156 | 157 | static float Grad (int i, float x, float y, float z) 158 | { 159 | var h = perm [i] & 15; 160 | var u = h < 8 ? x : y; 161 | var v = h < 4 ? y : (h == 12 || h == 14 ? x : z); 162 | return ((h & 1) != 0 ? u : -u) + ((h & 2) != 0 ? v : -v); 163 | } 164 | 165 | static int[] perm = { 166 | 151,160,137,91,90,15, 167 | 131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23, 168 | 190, 6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33, 169 | 88,237,149,56,87,174,20,125,136,171,168, 68,175,74,165,71,134,139,48,27,166, 170 | 77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244, 171 | 102,143,54, 65,25,63,161, 1,216,80,73,209,76,132,187,208, 89,18,169,200,196, 172 | 135,130,116,188,159,86,164,100,109,198,173,186, 3,64,52,217,226,250,124,123, 173 | 5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42, 174 | 223,183,170,213,119,248,152, 2,44,154,163, 70,221,153,101,155,167, 43,172,9, 175 | 129,22,39,253, 19,98,108,110,79,113,224,232,178,185, 112,104,218,246,97,228, 176 | 251,34,242,193,238,210,144,12,191,179,162,241, 81,51,145,235,249,14,239,107, 177 | 49,192,214, 31,181,199,106,157,184, 84,204,176,115,121,50,45,127, 4,150,254, 178 | 138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180, 179 | 151 180 | }; 181 | 182 | #endregion 183 | } 184 | 185 | } // namespace Reaktion 186 | -------------------------------------------------------------------------------- /Assets/Reaktion/Internal/Perlin.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f982ffe3e8ec84582a4b361630ea004a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Reaktion/Utility.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4d874762c14cf4223bd1bcfc86500326 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Reaktion/Utility/ConstantMotion.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Reaktion - An audio reactive animation toolkit for Unity. 3 | // 4 | // Copyright (C) 2013, 2014 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | using UnityEngine; 24 | 25 | namespace Reaktion { 26 | 27 | public class ConstantMotion : MonoBehaviour 28 | { 29 | public enum TransformMode { 30 | Off, XAxis, YAxis, ZAxis, Arbitrary, Random 31 | }; 32 | 33 | // A class for handling each transformation. 34 | [System.Serializable] 35 | public class TransformElement 36 | { 37 | public TransformMode mode = TransformMode.Off; 38 | public float velocity = 1; 39 | 40 | // Used only in the arbitrary mode. 41 | public Vector3 arbitraryVector = Vector3.up; 42 | 43 | // Affects velocity. 44 | public float randomness = 0; 45 | 46 | // Randomizer states. 47 | Vector3 randomVector; 48 | float randomScalar; 49 | 50 | public void Initialize() 51 | { 52 | randomVector = Random.onUnitSphere; 53 | randomScalar = Random.value; 54 | } 55 | 56 | // Get a vector corresponds to the current transform mode. 57 | public Vector3 Vector { 58 | get { 59 | switch (mode) 60 | { 61 | case TransformMode.XAxis: return Vector3.right; 62 | case TransformMode.YAxis: return Vector3.up; 63 | case TransformMode.ZAxis: return Vector3.forward; 64 | case TransformMode.Arbitrary: return arbitraryVector; 65 | case TransformMode.Random: return randomVector; 66 | } 67 | return Vector3.zero; 68 | } 69 | } 70 | 71 | // Get the current delta value. 72 | public float Delta { 73 | get { 74 | var scale = (1.0f - randomness * randomScalar); 75 | return velocity * scale * Time.deltaTime; 76 | } 77 | } 78 | } 79 | 80 | public TransformElement position = new TransformElement(); 81 | public TransformElement rotation = new TransformElement{ velocity = 30 }; 82 | public bool useLocalCoordinate = true; 83 | 84 | void Awake() 85 | { 86 | position.Initialize(); 87 | rotation.Initialize(); 88 | } 89 | 90 | void Update() 91 | { 92 | if (position.mode != TransformMode.Off) 93 | { 94 | if (useLocalCoordinate) 95 | transform.localPosition += position.Vector * position.Delta; 96 | else 97 | transform.position += position.Vector * position.Delta; 98 | } 99 | 100 | if (rotation.mode != TransformMode.Off) 101 | { 102 | var delta = Quaternion.AngleAxis(rotation.Delta, rotation.Vector); 103 | if (useLocalCoordinate) 104 | transform.localRotation = delta * transform.localRotation; 105 | else 106 | transform.rotation = delta * transform.rotation; 107 | } 108 | } 109 | } 110 | 111 | } // namespace Reaktion 112 | -------------------------------------------------------------------------------- /Assets/Reaktion/Utility/ConstantMotion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f91a6fa75d39940268b68c6204273e22 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Reaktion/Utility/JitterMotion.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Reaktion - An audio reactive animation toolkit for Unity. 3 | // 4 | // Copyright (C) 2013, 2014 Keijiro Takahashi 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 7 | // this software and associated documentation files (the "Software"), to deal in 8 | // the Software without restriction, including without limitation the rights to 9 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 10 | // the Software, and to permit persons to whom the Software is furnished to do so, 11 | // subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in all 14 | // copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 18 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 19 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 20 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 21 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | // 23 | using UnityEngine; 24 | 25 | namespace Reaktion { 26 | 27 | public class JitterMotion : MonoBehaviour 28 | { 29 | public float positionFrequency = 0.2f; 30 | public float rotationFrequency = 0.2f; 31 | 32 | public float positionAmount = 1.0f; 33 | public float rotationAmount = 30.0f; 34 | 35 | public Vector3 positionComponents = Vector3.one; 36 | public Vector3 rotationComponents = new Vector3(1, 1, 0); 37 | 38 | public int positionOctave = 3; 39 | public int rotationOctave = 3; 40 | 41 | float timePosition; 42 | float timeRotation; 43 | 44 | Vector2[] noiseVectors; 45 | 46 | Vector3 initialPosition; 47 | Quaternion initialRotation; 48 | 49 | void Awake() 50 | { 51 | timePosition = Random.value * 10; 52 | timeRotation = Random.value * 10; 53 | 54 | noiseVectors = new Vector2[6]; 55 | 56 | for (var i = 0; i < 6; i++) 57 | { 58 | var theta = Random.value * Mathf.PI * 2; 59 | noiseVectors[i].Set(Mathf.Cos(theta), Mathf.Sin(theta)); 60 | } 61 | 62 | initialPosition = transform.localPosition; 63 | initialRotation = transform.localRotation; 64 | } 65 | 66 | void Update() 67 | { 68 | timePosition += Time.deltaTime * positionFrequency; 69 | timeRotation += Time.deltaTime * rotationFrequency; 70 | 71 | if (positionAmount != 0.0f) 72 | { 73 | var p = new Vector3( 74 | Fbm(noiseVectors[0] * timePosition, positionOctave), 75 | Fbm(noiseVectors[1] * timePosition, positionOctave), 76 | Fbm(noiseVectors[2] * timePosition, positionOctave) 77 | ); 78 | p = Vector3.Scale(p, positionComponents) * positionAmount * 2; 79 | transform.localPosition = initialPosition + p; 80 | } 81 | 82 | if (rotationAmount != 0.0f) 83 | { 84 | var r = new Vector3( 85 | Fbm(noiseVectors[3] * timeRotation, rotationOctave), 86 | Fbm(noiseVectors[4] * timeRotation, rotationOctave), 87 | Fbm(noiseVectors[5] * timeRotation, rotationOctave) 88 | ); 89 | r = Vector3.Scale(r, rotationComponents) * rotationAmount * 2; 90 | transform.localRotation = Quaternion.Euler(r) * initialRotation; 91 | } 92 | } 93 | 94 | static float Fbm(Vector2 coord, int octave) 95 | { 96 | var f = 0.0f; 97 | var w = 1.0f; 98 | for (var i = 0; i < octave; i++) 99 | { 100 | f += w * Perlin.Noise(coord.x, coord.y) * 0.5f; 101 | coord *= 2; 102 | w *= 0.5f; 103 | } 104 | return f; 105 | } 106 | } 107 | 108 | } // namespace Reaktion 109 | -------------------------------------------------------------------------------- /Assets/Reaktion/Utility/JitterMotion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d637268abbbb5428e991dd9ec93136f2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: db5759608f86240768c36ccd7c9fa2b4 3 | folderAsset: yes 4 | timeCreated: 1431955054 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Shaders/ImageEffects.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ecf03591a02f943e1a1b92e69c62ac19 3 | folderAsset: yes 4 | timeCreated: 1431955054 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Shaders/ImageEffects/Bloom_V2.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8423e9098e8634577adae16ef4cd3173 3 | folderAsset: yes 4 | timeCreated: 1431954257 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Shaders/ImageEffects/Bloom_V2/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 828ed72cae1f2104cad9b893763115f2 3 | folderAsset: yes 4 | timeCreated: 1431954257 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Shaders/ImageEffects/Bloom_V2/Editor/VideoBloomEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | using UnityEngine; 4 | 5 | [CustomEditor (typeof(VideoBloom))] 6 | class VideoBloomEditor : Editor 7 | { 8 | SerializedProperty tweakMode; 9 | SerializedProperty Threshold; 10 | SerializedProperty MasterAmount; 11 | SerializedProperty MediumAmount; 12 | SerializedProperty LargeAmount; 13 | SerializedProperty Tint; 14 | SerializedProperty KernelSize; 15 | SerializedProperty MediumKernelScale; 16 | SerializedProperty LargeKernelScale; 17 | SerializedProperty BlendMode; 18 | SerializedProperty HighQuality; 19 | 20 | 21 | 22 | SerializedObject serObj; 23 | 24 | void OnEnable () 25 | { 26 | serObj = new SerializedObject (target); 27 | 28 | tweakMode = serObj.FindProperty("tweakMode"); 29 | Threshold = serObj.FindProperty("Threshold"); 30 | MasterAmount = serObj.FindProperty("MasterAmount"); 31 | MediumAmount = serObj.FindProperty("MediumAmount"); 32 | LargeAmount = serObj.FindProperty("LargeAmount"); 33 | Tint = serObj.FindProperty("Tint"); 34 | KernelSize = serObj.FindProperty("KernelSize"); 35 | MediumKernelScale = serObj.FindProperty("MediumKernelScale"); 36 | LargeKernelScale = serObj.FindProperty("LargeKernelScale"); 37 | BlendMode = serObj.FindProperty("BlendMode"); 38 | HighQuality = serObj.FindProperty("HighQuality"); 39 | } 40 | 41 | 42 | public override void OnInspectorGUI () 43 | { 44 | serObj.Update(); 45 | 46 | EditorGUILayout.LabelField("Bloom for bright screen pixels", EditorStyles.miniLabel); 47 | 48 | EditorGUILayout.Separator (); 49 | 50 | EditorGUILayout.PropertyField (tweakMode, new GUIContent("Mode")); 51 | 52 | EditorGUILayout.Separator (); 53 | 54 | Threshold.floatValue = EditorGUILayout.Slider ("Threshold", Threshold.floatValue, 0.0f, 4.0f); 55 | MasterAmount.floatValue = EditorGUILayout.Slider ("Intensity", MasterAmount.floatValue, 0.0f, 5.0f); 56 | EditorGUILayout.PropertyField (BlendMode, new GUIContent("Blend Mode")); 57 | KernelSize.floatValue = EditorGUILayout.Slider ("Kernel Size", KernelSize.floatValue, 10.0f, 100.0f); 58 | EditorGUILayout.PropertyField(Tint, new GUIContent("Tint")); 59 | 60 | if (tweakMode.intValue == 1) 61 | { 62 | EditorGUILayout.Separator (); 63 | EditorGUILayout.Separator (); 64 | MediumAmount.floatValue = EditorGUILayout.Slider ("Medium Amount", MediumAmount.floatValue, 0.0f, 5.0f); 65 | LargeAmount.floatValue = EditorGUILayout.Slider ("Large Amount", LargeAmount.floatValue, 0.0f, 100.0f); 66 | EditorGUILayout.Separator (); 67 | MediumKernelScale.floatValue = EditorGUILayout.Slider ("Medium Kernel Scale", MediumKernelScale.floatValue, 1.0f, 20.0f); 68 | LargeKernelScale.floatValue = EditorGUILayout.Slider ("Large Kernel Scale", LargeKernelScale.floatValue, 3.0f, 20.0f); 69 | EditorGUILayout.Separator (); 70 | EditorGUILayout.PropertyField (HighQuality, new GUIContent("High Quality")); 71 | } 72 | 73 | EditorGUILayout.Separator (); 74 | 75 | 76 | serObj.ApplyModifiedProperties(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Assets/Shaders/ImageEffects/Bloom_V2/Editor/VideoBloomEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: feb575ac495c04c6081b79dd8549ad3b 3 | timeCreated: 1423298362 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Shaders/ImageEffects/Bloom_V2/PostEffectsBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | [ExecuteInEditMode] 5 | [RequireComponent (typeof(Camera))] 6 | public class PostEffectsBase : MonoBehaviour { 7 | protected bool supportHDRTextures = true; 8 | protected bool supportDX11 = false; 9 | protected bool isSupported = true; 10 | 11 | 12 | protected Material CheckShaderAndCreateMaterial ( Shader s, Material m2Create) { 13 | if (!s) { 14 | Debug.Log("Missing shader in " + ToString ()); 15 | enabled = false; 16 | return null; 17 | } 18 | 19 | if (s.isSupported && m2Create && m2Create.shader == s) 20 | return m2Create; 21 | 22 | if (!s.isSupported) { 23 | NotSupported (); 24 | Debug.Log("The shader " + s.ToString() + " on effect "+ToString()+" is not supported on this platform!"); 25 | return null; 26 | } 27 | else { 28 | m2Create = new Material (s); 29 | m2Create.hideFlags = HideFlags.DontSave; 30 | if (m2Create) 31 | return m2Create; 32 | else return null; 33 | } 34 | } 35 | 36 | 37 | protected Material CreateMaterial ( Shader s, Material m2Create) { 38 | if (!s) { 39 | Debug.Log ("Missing shader in " + ToString ()); 40 | return null; 41 | } 42 | 43 | if (m2Create && (m2Create.shader == s) && (s.isSupported)) 44 | return m2Create; 45 | 46 | if (!s.isSupported) { 47 | return null; 48 | } 49 | else { 50 | m2Create = new Material (s); 51 | m2Create.hideFlags = HideFlags.DontSave; 52 | if (m2Create) 53 | return m2Create; 54 | else return null; 55 | } 56 | } 57 | 58 | void OnEnable () { 59 | isSupported = true; 60 | } 61 | 62 | protected bool CheckSupport () { 63 | return CheckSupport (false); 64 | } 65 | 66 | 67 | public virtual bool CheckResources () { 68 | Debug.LogWarning ("CheckResources () for " + ToString() + " should be overwritten."); 69 | return isSupported; 70 | } 71 | 72 | 73 | protected void Start () { 74 | CheckResources (); 75 | } 76 | 77 | protected bool CheckSupport ( bool needDepth) { 78 | isSupported = true; 79 | supportHDRTextures = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf); 80 | supportDX11 = SystemInfo.graphicsShaderLevel >= 50 && SystemInfo.supportsComputeShaders; 81 | 82 | if (!SystemInfo.supportsImageEffects || !SystemInfo.supportsRenderTextures) { 83 | NotSupported (); 84 | return false; 85 | } 86 | 87 | if (needDepth && !SystemInfo.SupportsRenderTextureFormat (RenderTextureFormat.Depth)) { 88 | NotSupported (); 89 | return false; 90 | } 91 | 92 | if (needDepth) 93 | GetComponent().depthTextureMode |= DepthTextureMode.Depth; 94 | 95 | return true; 96 | } 97 | 98 | protected bool CheckSupport ( bool needDepth, bool needHdr) { 99 | if (!CheckSupport(needDepth)) 100 | return false; 101 | 102 | if (needHdr && !supportHDRTextures) { 103 | NotSupported (); 104 | return false; 105 | } 106 | 107 | return true; 108 | } 109 | 110 | 111 | public bool Dx11Support () { 112 | return supportDX11; 113 | } 114 | 115 | 116 | protected void ReportAutoDisable () { 117 | Debug.LogWarning ("The image effect " + ToString() + " has been disabled as it's not supported on the current platform."); 118 | } 119 | 120 | // deprecated but needed for old effects to survive upgrading 121 | bool CheckShader ( Shader s) { 122 | Debug.Log("The shader " + s.ToString () + " on effect "+ ToString () + " is not part of the Unity 3.2+ effects suite anymore. For best performance and quality, please ensure you are using the latest Standard Assets Image Effects (Pro only) package."); 123 | if (!s.isSupported) { 124 | NotSupported (); 125 | return false; 126 | } 127 | else { 128 | return false; 129 | } 130 | } 131 | 132 | 133 | protected void NotSupported () { 134 | enabled = false; 135 | isSupported = false; 136 | return; 137 | } 138 | 139 | 140 | protected void DrawBorder ( RenderTexture dest, Material material ) { 141 | float x1; 142 | float x2; 143 | float y1; 144 | float y2; 145 | 146 | RenderTexture.active = dest; 147 | bool invertY = true; // source.texelSize.y < 0.0ff; 148 | // Set up the simple Matrix 149 | GL.PushMatrix(); 150 | GL.LoadOrtho(); 151 | 152 | for (int i = 0; i < material.passCount; i++) 153 | { 154 | material.SetPass(i); 155 | 156 | float y1_; float y2_; 157 | if (invertY) 158 | { 159 | y1_ = 1.0f; y2_ = 0.0f; 160 | } 161 | else 162 | { 163 | y1_ = 0.0f; y2_ = 1.0f; 164 | } 165 | 166 | // left 167 | x1 = 0.0f; 168 | x2 = 0.0f + 1.0f/(dest.width*1.0f); 169 | y1 = 0.0f; 170 | y2 = 1.0f; 171 | GL.Begin(GL.QUADS); 172 | 173 | GL.TexCoord2(0.0f, y1_); GL.Vertex3(x1, y1, 0.1f); 174 | GL.TexCoord2(1.0f, y1_); GL.Vertex3(x2, y1, 0.1f); 175 | GL.TexCoord2(1.0f, y2_); GL.Vertex3(x2, y2, 0.1f); 176 | GL.TexCoord2(0.0f, y2_); GL.Vertex3(x1, y2, 0.1f); 177 | 178 | // right 179 | x1 = 1.0f - 1.0f/(dest.width*1.0f); 180 | x2 = 1.0f; 181 | y1 = 0.0f; 182 | y2 = 1.0f; 183 | 184 | GL.TexCoord2(0.0f, y1_); GL.Vertex3(x1, y1, 0.1f); 185 | GL.TexCoord2(1.0f, y1_); GL.Vertex3(x2, y1, 0.1f); 186 | GL.TexCoord2(1.0f, y2_); GL.Vertex3(x2, y2, 0.1f); 187 | GL.TexCoord2(0.0f, y2_); GL.Vertex3(x1, y2, 0.1f); 188 | 189 | // top 190 | x1 = 0.0f; 191 | x2 = 1.0f; 192 | y1 = 0.0f; 193 | y2 = 0.0f + 1.0f/(dest.height*1.0f); 194 | 195 | GL.TexCoord2(0.0f, y1_); GL.Vertex3(x1, y1, 0.1f); 196 | GL.TexCoord2(1.0f, y1_); GL.Vertex3(x2, y1, 0.1f); 197 | GL.TexCoord2(1.0f, y2_); GL.Vertex3(x2, y2, 0.1f); 198 | GL.TexCoord2(0.0f, y2_); GL.Vertex3(x1, y2, 0.1f); 199 | 200 | // bottom 201 | x1 = 0.0f; 202 | x2 = 1.0f; 203 | y1 = 1.0f - 1.0f/(dest.height*1.0f); 204 | y2 = 1.0f; 205 | 206 | GL.TexCoord2(0.0f, y1_); GL.Vertex3(x1, y1, 0.1f); 207 | GL.TexCoord2(1.0f, y1_); GL.Vertex3(x2, y1, 0.1f); 208 | GL.TexCoord2(1.0f, y2_); GL.Vertex3(x2, y2, 0.1f); 209 | GL.TexCoord2(0.0f, y2_); GL.Vertex3(x1, y2, 0.1f); 210 | 211 | GL.End(); 212 | } 213 | 214 | GL.PopMatrix(); 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /Assets/Shaders/ImageEffects/Bloom_V2/PostEffectsBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b608e8d5cf204125a256e8c6edf225b 3 | timeCreated: 1423298361 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Shaders/ImageEffects/Bloom_V2/VideoBloom.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | 4 | [ExecuteInEditMode] 5 | [AddComponentMenu("Image Effects/Other/VideoBloom")] 6 | [RequireComponent(typeof(Camera))] 7 | 8 | public class VideoBloom : PostEffectsBase 9 | { 10 | public enum TweakMode 11 | { 12 | Basic = 0, 13 | Advanced = 1 14 | } 15 | 16 | public enum BlendingMode 17 | { 18 | Add = 0, 19 | Screen = 1, 20 | } 21 | 22 | public TweakMode tweakMode = TweakMode.Basic; 23 | [Range(0.0f, 4.0f)] 24 | public float Threshold = 0.75f; 25 | [Range(0.0f, 5.0f)] 26 | public float MasterAmount = 0.5f; 27 | [Range(0.0f, 5.0f)] 28 | public float MediumAmount = 1.0f; 29 | [Range(0.0f, 100.0f)] 30 | public float LargeAmount = 0.0f; 31 | public Color Tint = new Color(1.0f, 1.0f, 1.0f, 1.0f); 32 | [Range(10.0f, 100.0f)] 33 | public float KernelSize = 50.0f; 34 | [Range(1.0f, 20.0f)] 35 | public float MediumKernelScale = 1.0f; 36 | [Range(3.0f, 20.0f)] 37 | public float LargeKernelScale = 3.0f; 38 | public BlendingMode BlendMode = BlendingMode.Add; 39 | public bool HighQuality = true; 40 | 41 | public float masterAmount { 42 | get { return MasterAmount; } 43 | set { MasterAmount = value; } 44 | } 45 | 46 | public Shader videoBloomShader; 47 | private Material videoBloomMaterial; 48 | 49 | public override bool CheckResources () 50 | { 51 | CheckSupport (false, true); 52 | 53 | videoBloomMaterial = CheckShaderAndCreateMaterial (videoBloomShader, videoBloomMaterial); 54 | 55 | if (!isSupported) 56 | ReportAutoDisable (); 57 | 58 | return isSupported; 59 | } 60 | 61 | 62 | float videoBlurGetMaxScaleFor(float radius) 63 | { 64 | double x = (double)radius; 65 | double sc = x < 10.0 ? (0.1*x * 1.468417):(x < 36.3287 ? (0.127368 * x + 0.194737):(0.8*(float)Math.Sqrt(x))); 66 | return sc <= 0.0 ? 0.0f:(float)sc; 67 | } 68 | 69 | void BloomBlit(RenderTexture source, RenderTexture blur1, RenderTexture blur2, float radius1, float radius2) 70 | { 71 | const float kd0 = (4.0f/3.0f); 72 | const float kd1 = (1.0f/3.0f); 73 | float maxScale = videoBlurGetMaxScaleFor(radius1); 74 | int blurIteration1 = (int)maxScale; 75 | float lerp1 = (maxScale - (float)blurIteration1); 76 | maxScale = videoBlurGetMaxScaleFor(radius2); 77 | int blurIteration2 = (int)maxScale; 78 | float dUV = 1.0f; 79 | int rtW = source.width; 80 | int rtH = source.height; 81 | float s0 = blurIteration1 != 0 ? 1.0f:-1.0f; 82 | Vector4 v; 83 | int i; 84 | 85 | if (radius1 == 0.0f) 86 | { 87 | Graphics.Blit(source, blur1); 88 | return; 89 | } 90 | 91 | RenderTexture rt = RenderTexture.GetTemporary(rtW, rtH, 0, RenderTextureFormat.ARGBHalf); 92 | rt.filterMode = FilterMode.Bilinear; 93 | rt.wrapMode = TextureWrapMode.Clamp; 94 | Graphics.Blit(source, rt); 95 | 96 | for (i = 0; i < blurIteration1; i++) 97 | { 98 | s0 = (i % 2 != 0 ? -1.0f:1.0f); 99 | v = new Vector4(s0 * dUV * kd0, dUV * kd1, s0 * dUV * kd1, -dUV * kd0); 100 | videoBloomMaterial.SetVector("_Param0", v); 101 | RenderTexture rt2 = RenderTexture.GetTemporary(rtW, rtH, 0, RenderTextureFormat.ARGBHalf); 102 | rt2.filterMode = FilterMode.Bilinear; 103 | rt2.wrapMode = TextureWrapMode.Clamp; 104 | videoBloomMaterial.SetTexture("_MainTex", rt); 105 | Graphics.Blit (rt, rt2, videoBloomMaterial, 0); 106 | RenderTexture.ReleaseTemporary(rt); 107 | rt = rt2; 108 | dUV = dUV * 1.414213562373095f; 109 | } 110 | 111 | v = new Vector4(-s0 * dUV * kd0, dUV * kd1, -s0 * dUV * kd1, -dUV * kd0); 112 | videoBloomMaterial.SetVector("_Param0", v); 113 | videoBloomMaterial.SetFloat("_Param2", lerp1); 114 | videoBloomMaterial.SetTexture("_MainTex", rt); 115 | Graphics.Blit (rt, blur1, videoBloomMaterial, 1); 116 | 117 | if (blur2 != null) 118 | { 119 | for ( ; i < blurIteration2; i++) 120 | { 121 | s0 = (i % 2 != 0 ? -1.0f:1.0f); 122 | v = new Vector4(s0 * dUV * kd0, dUV * kd1, s0 * dUV * kd1, -dUV * kd0); 123 | videoBloomMaterial.SetVector("_Param0", v); 124 | RenderTexture rt2 = RenderTexture.GetTemporary(rtW, rtH, 0, RenderTextureFormat.ARGBHalf); 125 | rt2.filterMode = FilterMode.Bilinear; 126 | rt2.wrapMode = TextureWrapMode.Clamp; 127 | videoBloomMaterial.SetTexture("_MainTex", rt); 128 | Graphics.Blit (rt, rt2, videoBloomMaterial, 0); 129 | RenderTexture.ReleaseTemporary(rt); 130 | rt = rt2; 131 | dUV = dUV * 1.414213562373095f; 132 | } 133 | 134 | v = new Vector4(-s0 * dUV * kd0, dUV * kd1, -s0 * dUV * kd1, -dUV * kd0); 135 | videoBloomMaterial.SetVector("_Param0", v); 136 | videoBloomMaterial.SetFloat("_Param2", (maxScale - (float)blurIteration2)); 137 | videoBloomMaterial.SetTexture("_MainTex", rt); 138 | Graphics.Blit (rt, blur2, videoBloomMaterial, 1); 139 | } 140 | 141 | RenderTexture.ReleaseTemporary(rt); 142 | 143 | } 144 | 145 | //[ImageEffectOpaque] 146 | void OnRenderImage (RenderTexture source, RenderTexture destination) 147 | { 148 | 149 | if ((MediumAmount == 0.0f && LargeAmount == 0.0f) || MasterAmount == 0.0f || !CheckResources( )) 150 | { 151 | Graphics.Blit(source, destination); 152 | return; 153 | } 154 | float coe = HighQuality == true ? 1.0f:0.25f; 155 | int rtW = (int)(coe * (float)source.width); 156 | int rtH = (int)(coe * (float)source.height); 157 | Vector4 weight = new Vector4(0.5f * MasterAmount*MediumAmount, 0.5f * MasterAmount*LargeAmount, 0.0f, 0.0f); 158 | Vector4 tint = new Vector4(Tint.r, Tint.g, Tint.b, 1.0f); 159 | float radius1 = KernelSize * MediumKernelScale * coe; 160 | float radius2 = KernelSize * LargeKernelScale * coe; 161 | 162 | RenderTexture tmp1 = RenderTexture.GetTemporary(rtW, rtH, 0, RenderTextureFormat.ARGBHalf); 163 | RenderTexture tmp2 = RenderTexture.GetTemporary(rtW, rtH, 0, RenderTextureFormat.ARGBHalf); 164 | RenderTexture tmp3 = null; 165 | tmp1.filterMode = FilterMode.Bilinear; 166 | tmp1.wrapMode = TextureWrapMode.Clamp; 167 | tmp2.filterMode = FilterMode.Bilinear; 168 | tmp2.wrapMode = TextureWrapMode.Clamp; 169 | 170 | if (HighQuality == true) 171 | { 172 | videoBloomMaterial.SetFloat("_Param2", Threshold); 173 | Graphics.Blit(source, tmp1, videoBloomMaterial, 2); 174 | } 175 | else 176 | { 177 | tmp3 = RenderTexture.GetTemporary(2 * rtW, 2 * rtH, 0, RenderTextureFormat.ARGBHalf); 178 | tmp3.filterMode = FilterMode.Bilinear; 179 | tmp3.wrapMode = TextureWrapMode.Clamp; 180 | Graphics.Blit(source, tmp3); 181 | videoBloomMaterial.SetFloat("_Param2", Threshold); 182 | Graphics.Blit(tmp3, tmp1, videoBloomMaterial, 2); 183 | RenderTexture.ReleaseTemporary(tmp3); 184 | tmp3 = null; 185 | } 186 | 187 | if (LargeAmount != 0.0f) 188 | { 189 | tmp3 = RenderTexture.GetTemporary(rtW, rtH, 0, RenderTextureFormat.ARGBHalf); 190 | tmp3.filterMode = FilterMode.Bilinear; 191 | tmp3.wrapMode = TextureWrapMode.Clamp; 192 | } 193 | 194 | BloomBlit(tmp1, tmp2, tmp3, radius1, radius2 >= radius1 ? radius2:radius1); 195 | 196 | videoBloomMaterial.SetTexture("_MainTex", source); 197 | videoBloomMaterial.SetTexture("_MediumBloom", tmp2); 198 | videoBloomMaterial.SetTexture("_LargeBloom", tmp3); 199 | videoBloomMaterial.SetVector("_Param0", weight); 200 | videoBloomMaterial.SetVector("_Param1", tint); 201 | Graphics.Blit(source, destination, videoBloomMaterial, BlendMode == BlendingMode.Screen ? 4:3); 202 | 203 | RenderTexture.ReleaseTemporary(tmp1); 204 | RenderTexture.ReleaseTemporary(tmp2); 205 | if (tmp3 != null) 206 | RenderTexture.ReleaseTemporary(tmp3); 207 | 208 | } 209 | 210 | } 211 | -------------------------------------------------------------------------------- /Assets/Shaders/ImageEffects/Bloom_V2/VideoBloom.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ffd37938bd1d34558a64a40ff7419815 3 | timeCreated: 1423299358 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - videoBloomShader: {fileID: 4800000, guid: 4da5120001c1945e99d8db7be2c8c652, type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Shaders/ImageEffects/Bloom_V2/VideoBloom.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/VideoBloom" 2 | { 3 | Properties 4 | { 5 | _MainTex ("_MainTex (RGB)", 2D) = "black" 6 | _MediumBloom ("-", 2D) = "" {} 7 | _LargeBloom ("-", 2D) = "black" {} 8 | } 9 | 10 | CGINCLUDE 11 | 12 | #include "UnityCG.cginc" 13 | 14 | sampler2D _MainTex; 15 | sampler2D _MediumBloom; 16 | sampler2D _LargeBloom; 17 | uniform half4 _MainTex_TexelSize; 18 | uniform half4 _Param0; 19 | uniform half4 _Param1; 20 | uniform half _Param2; 21 | 22 | struct v_blurCoords 23 | { 24 | float4 pos : SV_POSITION; 25 | half2 uv0 : TEXCOORD0; 26 | half2 uv1 : TEXCOORD1; 27 | half2 uv2 : TEXCOORD2; 28 | half2 uv3 : TEXCOORD3; 29 | half2 uv4 : TEXCOORD4; 30 | }; 31 | 32 | struct v2f 33 | { 34 | float4 pos : SV_POSITION; 35 | float2 uv : TEXCOORD0; 36 | }; 37 | 38 | uniform float4 _MainTex_ST; 39 | 40 | v_blurCoords vertBlur(appdata_img v) 41 | { 42 | v_blurCoords o; 43 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 44 | o.uv0 = v.texcoord; 45 | o.uv1 = v.texcoord + _MainTex_TexelSize.xy * _Param0.xy; 46 | o.uv2 = v.texcoord - _MainTex_TexelSize.xy * _Param0.xy; 47 | o.uv3 = v.texcoord + _MainTex_TexelSize.xy * _Param0.zw; 48 | o.uv4 = v.texcoord - _MainTex_TexelSize.xy * _Param0.zw; 49 | return o; 50 | } 51 | 52 | half4 fragBlurIter(v_blurCoords i) : COLOR 53 | { 54 | half4 color = half4(0.182h, 0.182h, 0.182h, 0.182h) * tex2D (_MainTex, i.uv0); 55 | color += half4(0.2045h, 0.2045h, 0.2045h, 0.2045h) * (tex2D (_MainTex, i.uv1) + tex2D (_MainTex, i.uv2) + tex2D (_MainTex, i.uv3) + tex2D (_MainTex, i.uv4)); 56 | return color; 57 | } 58 | 59 | half4 fragBlurLerpIter(v_blurCoords i) : COLOR 60 | { 61 | half4 src0 = tex2D (_MainTex, i.uv0); 62 | half4 color = half4(0.182h, 0.182h, 0.182h, 0.182h) * src0; 63 | color += half4(0.2045h, 0.2045h, 0.2045h, 0.2045h) * (tex2D (_MainTex, i.uv1) + tex2D (_MainTex, i.uv2) + tex2D (_MainTex, i.uv3) + tex2D (_MainTex, i.uv4)); 64 | return lerp(src0, color, _Param2); 65 | } 66 | 67 | v2f vert(appdata_img v) 68 | { 69 | v2f o; 70 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 71 | o.uv = v.texcoord.xy; 72 | return o; 73 | } 74 | 75 | half4 fragThresh(v2f i) : SV_Target 76 | { 77 | half4 color = tex2D(_MainTex, i.uv); 78 | half luma = dot(color, half4(0.3h, 0.59h, 0.11h, 0.0h)); 79 | return luma < _Param2 ? half4(0.0h, 0.0h, 0.0h, 0.0h):color; 80 | } 81 | 82 | half4 fragAdd(v2f i) : SV_Target 83 | { 84 | half4 color = tex2D(_MainTex, i.uv); 85 | half4 bloom = tex2D(_MediumBloom, i.uv) * _Param1 * _Param0.x; 86 | bloom += tex2D(_LargeBloom, i.uv) * _Param1 * _Param0.y; 87 | return color + bloom; 88 | } 89 | 90 | half4 fragScreen(v2f i) : SV_Target 91 | { 92 | half4 color = tex2D(_MainTex, i.uv); 93 | half4 bloom = tex2D(_MediumBloom, i.uv) * _Param1 * _Param0.x; 94 | bloom += tex2D(_LargeBloom, i.uv) * _Param1 * _Param0.y; 95 | half4 mr = color + bloom - color * bloom; 96 | return max(color, mr); 97 | } 98 | 99 | ENDCG 100 | 101 | SubShader 102 | { 103 | 104 | ZTest Always Cull Off ZWrite Off Fog { Mode Off } Lighting Off Blend Off 105 | 106 | // 0 107 | Pass 108 | { 109 | 110 | CGPROGRAM 111 | #pragma vertex vertBlur 112 | #pragma fragment fragBlurIter 113 | #pragma fragmentoption ARB_precision_hint_fastest 114 | ENDCG 115 | 116 | } 117 | 118 | // 1 119 | Pass 120 | { 121 | 122 | CGPROGRAM 123 | #pragma vertex vertBlur 124 | #pragma fragment fragBlurLerpIter 125 | #pragma fragmentoption ARB_precision_hint_fastest 126 | ENDCG 127 | 128 | } 129 | 130 | // 2 131 | Pass 132 | { 133 | 134 | CGPROGRAM 135 | #pragma vertex vert 136 | #pragma fragment fragThresh 137 | #pragma fragmentoption ARB_precision_hint_fastest 138 | ENDCG 139 | 140 | } 141 | 142 | // 3 143 | Pass 144 | { 145 | 146 | CGPROGRAM 147 | #pragma vertex vert 148 | #pragma fragment fragAdd 149 | #pragma fragmentoption ARB_precision_hint_fastest 150 | ENDCG 151 | 152 | } 153 | 154 | // 4 155 | Pass 156 | { 157 | 158 | CGPROGRAM 159 | #pragma vertex vert 160 | #pragma fragment fragScreen 161 | #pragma fragmentoption ARB_precision_hint_fastest 162 | ENDCG 163 | 164 | } 165 | } 166 | 167 | FallBack Off 168 | } 169 | 170 | -------------------------------------------------------------------------------- /Assets/Shaders/ImageEffects/Bloom_V2/VideoBloom.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4da5120001c1945e99d8db7be2c8c652 3 | timeCreated: 1423298687 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 238dd03b79f3e954192b0124bd2eca00 3 | folderAsset: yes 4 | timeCreated: 1432478651 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 115d1f9d9bd29064ab981e57c8fc8cdf 3 | folderAsset: yes 4 | timeCreated: 1432478651 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d6e0c95a128e14227939c51b5d9ad74e 3 | folderAsset: yes 4 | timeCreated: 1432478651 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd3e1490c3d9a7a498538315414d5129 3 | folderAsset: yes 4 | timeCreated: 1432478651 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Scripts/PostEffectsBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.ImageEffects 5 | { 6 | [ExecuteInEditMode] 7 | [RequireComponent (typeof(Camera))] 8 | public class PostEffectsBase : MonoBehaviour 9 | { 10 | protected bool supportHDRTextures = true; 11 | protected bool supportDX11 = false; 12 | protected bool isSupported = true; 13 | 14 | protected Material CheckShaderAndCreateMaterial ( Shader s, Material m2Create) 15 | { 16 | if (!s) 17 | { 18 | Debug.Log("Missing shader in " + ToString ()); 19 | enabled = false; 20 | return null; 21 | } 22 | 23 | if (s.isSupported && m2Create && m2Create.shader == s) 24 | return m2Create; 25 | 26 | if (!s.isSupported) 27 | { 28 | NotSupported (); 29 | Debug.Log("The shader " + s.ToString() + " on effect "+ToString()+" is not supported on this platform!"); 30 | return null; 31 | } 32 | else 33 | { 34 | m2Create = new Material (s); 35 | m2Create.hideFlags = HideFlags.DontSave; 36 | if (m2Create) 37 | return m2Create; 38 | else return null; 39 | } 40 | } 41 | 42 | 43 | protected Material CreateMaterial (Shader s, Material m2Create) 44 | { 45 | if (!s) 46 | { 47 | Debug.Log ("Missing shader in " + ToString ()); 48 | return null; 49 | } 50 | 51 | if (m2Create && (m2Create.shader == s) && (s.isSupported)) 52 | return m2Create; 53 | 54 | if (!s.isSupported) 55 | { 56 | return null; 57 | } 58 | else 59 | { 60 | m2Create = new Material (s); 61 | m2Create.hideFlags = HideFlags.DontSave; 62 | if (m2Create) 63 | return m2Create; 64 | else return null; 65 | } 66 | } 67 | 68 | void OnEnable () 69 | { 70 | isSupported = true; 71 | } 72 | 73 | protected bool CheckSupport () 74 | { 75 | return CheckSupport (false); 76 | } 77 | 78 | 79 | public virtual bool CheckResources () 80 | { 81 | Debug.LogWarning ("CheckResources () for " + ToString() + " should be overwritten."); 82 | return isSupported; 83 | } 84 | 85 | 86 | protected void Start () 87 | { 88 | CheckResources (); 89 | } 90 | 91 | protected bool CheckSupport (bool needDepth) 92 | { 93 | isSupported = true; 94 | supportHDRTextures = SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf); 95 | supportDX11 = SystemInfo.graphicsShaderLevel >= 50 && SystemInfo.supportsComputeShaders; 96 | 97 | if (!SystemInfo.supportsImageEffects || !SystemInfo.supportsRenderTextures) 98 | { 99 | NotSupported (); 100 | return false; 101 | } 102 | 103 | if (needDepth && !SystemInfo.SupportsRenderTextureFormat (RenderTextureFormat.Depth)) 104 | { 105 | NotSupported (); 106 | return false; 107 | } 108 | 109 | if (needDepth) 110 | GetComponent().depthTextureMode |= DepthTextureMode.Depth; 111 | 112 | return true; 113 | } 114 | 115 | protected bool CheckSupport (bool needDepth, bool needHdr) 116 | { 117 | if (!CheckSupport(needDepth)) 118 | return false; 119 | 120 | if (needHdr && !supportHDRTextures) 121 | { 122 | NotSupported (); 123 | return false; 124 | } 125 | 126 | return true; 127 | } 128 | 129 | 130 | public bool Dx11Support () 131 | { 132 | return supportDX11; 133 | } 134 | 135 | 136 | protected void ReportAutoDisable () 137 | { 138 | Debug.LogWarning ("The image effect " + ToString() + " has been disabled as it's not supported on the current platform."); 139 | } 140 | 141 | // deprecated but needed for old effects to survive upgrading 142 | bool CheckShader (Shader s) 143 | { 144 | Debug.Log("The shader " + s.ToString () + " on effect "+ ToString () + " is not part of the Unity 3.2+ effects suite anymore. For best performance and quality, please ensure you are using the latest Standard Assets Image Effects (Pro only) package."); 145 | if (!s.isSupported) 146 | { 147 | NotSupported (); 148 | return false; 149 | } 150 | else 151 | { 152 | return false; 153 | } 154 | } 155 | 156 | 157 | protected void NotSupported () 158 | { 159 | enabled = false; 160 | isSupported = false; 161 | return; 162 | } 163 | 164 | 165 | protected void DrawBorder (RenderTexture dest, Material material) 166 | { 167 | float x1; 168 | float x2; 169 | float y1; 170 | float y2; 171 | 172 | RenderTexture.active = dest; 173 | bool invertY = true; // source.texelSize.y < 0.0ff; 174 | // Set up the simple Matrix 175 | GL.PushMatrix(); 176 | GL.LoadOrtho(); 177 | 178 | for (int i = 0; i < material.passCount; i++) 179 | { 180 | material.SetPass(i); 181 | 182 | float y1_; float y2_; 183 | if (invertY) 184 | { 185 | y1_ = 1.0f; y2_ = 0.0f; 186 | } 187 | else 188 | { 189 | y1_ = 0.0f; y2_ = 1.0f; 190 | } 191 | 192 | // left 193 | x1 = 0.0f; 194 | x2 = 0.0f + 1.0f/(dest.width*1.0f); 195 | y1 = 0.0f; 196 | y2 = 1.0f; 197 | GL.Begin(GL.QUADS); 198 | 199 | GL.TexCoord2(0.0f, y1_); GL.Vertex3(x1, y1, 0.1f); 200 | GL.TexCoord2(1.0f, y1_); GL.Vertex3(x2, y1, 0.1f); 201 | GL.TexCoord2(1.0f, y2_); GL.Vertex3(x2, y2, 0.1f); 202 | GL.TexCoord2(0.0f, y2_); GL.Vertex3(x1, y2, 0.1f); 203 | 204 | // right 205 | x1 = 1.0f - 1.0f/(dest.width*1.0f); 206 | x2 = 1.0f; 207 | y1 = 0.0f; 208 | y2 = 1.0f; 209 | 210 | GL.TexCoord2(0.0f, y1_); GL.Vertex3(x1, y1, 0.1f); 211 | GL.TexCoord2(1.0f, y1_); GL.Vertex3(x2, y1, 0.1f); 212 | GL.TexCoord2(1.0f, y2_); GL.Vertex3(x2, y2, 0.1f); 213 | GL.TexCoord2(0.0f, y2_); GL.Vertex3(x1, y2, 0.1f); 214 | 215 | // top 216 | x1 = 0.0f; 217 | x2 = 1.0f; 218 | y1 = 0.0f; 219 | y2 = 0.0f + 1.0f/(dest.height*1.0f); 220 | 221 | GL.TexCoord2(0.0f, y1_); GL.Vertex3(x1, y1, 0.1f); 222 | GL.TexCoord2(1.0f, y1_); GL.Vertex3(x2, y1, 0.1f); 223 | GL.TexCoord2(1.0f, y2_); GL.Vertex3(x2, y2, 0.1f); 224 | GL.TexCoord2(0.0f, y2_); GL.Vertex3(x1, y2, 0.1f); 225 | 226 | // bottom 227 | x1 = 0.0f; 228 | x2 = 1.0f; 229 | y1 = 1.0f - 1.0f/(dest.height*1.0f); 230 | y2 = 1.0f; 231 | 232 | GL.TexCoord2(0.0f, y1_); GL.Vertex3(x1, y1, 0.1f); 233 | GL.TexCoord2(1.0f, y1_); GL.Vertex3(x2, y1, 0.1f); 234 | GL.TexCoord2(1.0f, y2_); GL.Vertex3(x2, y2, 0.1f); 235 | GL.TexCoord2(0.0f, y2_); GL.Vertex3(x1, y2, 0.1f); 236 | 237 | GL.End(); 238 | } 239 | 240 | GL.PopMatrix(); 241 | } 242 | } 243 | } 244 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Scripts/PostEffectsBase.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b6f4318ec6c2bf643a0f9edfeeaba0ec 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | assetBundleName: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Scripts/VignetteAndChromaticAberration.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.ImageEffects 5 | { 6 | [ExecuteInEditMode] 7 | [RequireComponent (typeof(Camera))] 8 | [AddComponentMenu ("Image Effects/Camera/Vignette and Chromatic Aberration")] 9 | public class VignetteAndChromaticAberration : PostEffectsBase 10 | { 11 | public enum AberrationMode 12 | { 13 | Simple = 0, 14 | Advanced = 1, 15 | } 16 | 17 | 18 | public AberrationMode mode = AberrationMode.Simple; 19 | public float intensity = 0.375f; // intensity == 0 disables pre pass (optimization) 20 | public float chromaticAberration = 0.2f; 21 | public float axialAberration = 0.5f; 22 | public float blur = 0.0f; // blur == 0 disables blur pass (optimization) 23 | public float blurSpread = 0.75f; 24 | public float luminanceDependency = 0.25f; 25 | public float blurDistance = 2.5f; 26 | public Shader vignetteShader; 27 | public Shader separableBlurShader; 28 | public Shader chromAberrationShader; 29 | 30 | 31 | private Material m_VignetteMaterial; 32 | private Material m_SeparableBlurMaterial; 33 | private Material m_ChromAberrationMaterial; 34 | 35 | 36 | public override bool CheckResources () 37 | { 38 | CheckSupport (false); 39 | 40 | m_VignetteMaterial = CheckShaderAndCreateMaterial (vignetteShader, m_VignetteMaterial); 41 | m_SeparableBlurMaterial = CheckShaderAndCreateMaterial (separableBlurShader, m_SeparableBlurMaterial); 42 | m_ChromAberrationMaterial = CheckShaderAndCreateMaterial (chromAberrationShader, m_ChromAberrationMaterial); 43 | 44 | if (!isSupported) 45 | ReportAutoDisable (); 46 | return isSupported; 47 | } 48 | 49 | 50 | void OnRenderImage (RenderTexture source, RenderTexture destination) 51 | { 52 | if ( CheckResources () == false) 53 | { 54 | Graphics.Blit (source, destination); 55 | return; 56 | } 57 | 58 | int rtW = source.width; 59 | int rtH = source.height; 60 | 61 | bool doPrepass = (Mathf.Abs(blur)>0.0f || Mathf.Abs(intensity)>0.0f); 62 | 63 | float widthOverHeight = (1.0f * rtW) / (1.0f * rtH); 64 | const float oneOverBaseSize = 1.0f / 512.0f; 65 | 66 | RenderTexture color = null; 67 | RenderTexture color2A = null; 68 | 69 | if (doPrepass) 70 | { 71 | color = RenderTexture.GetTemporary (rtW, rtH, 0, source.format); 72 | 73 | // Blur corners 74 | if (Mathf.Abs (blur)>0.0f) 75 | { 76 | color2A = RenderTexture.GetTemporary (rtW / 2, rtH / 2, 0, source.format); 77 | 78 | Graphics.Blit (source, color2A, m_ChromAberrationMaterial, 0); 79 | 80 | for(int i = 0; i < 2; i++) 81 | { // maybe make iteration count tweakable 82 | m_SeparableBlurMaterial.SetVector ("offsets",new Vector4 (0.0f, blurSpread * oneOverBaseSize, 0.0f, 0.0f)); 83 | RenderTexture color2B = RenderTexture.GetTemporary (rtW / 2, rtH / 2, 0, source.format); 84 | Graphics.Blit (color2A, color2B, m_SeparableBlurMaterial); 85 | RenderTexture.ReleaseTemporary (color2A); 86 | 87 | m_SeparableBlurMaterial.SetVector ("offsets",new Vector4 (blurSpread * oneOverBaseSize / widthOverHeight, 0.0f, 0.0f, 0.0f)); 88 | color2A = RenderTexture.GetTemporary (rtW / 2, rtH / 2, 0, source.format); 89 | Graphics.Blit (color2B, color2A, m_SeparableBlurMaterial); 90 | RenderTexture.ReleaseTemporary (color2B); 91 | } 92 | } 93 | 94 | m_VignetteMaterial.SetFloat ("_Intensity", intensity); // intensity for vignette 95 | m_VignetteMaterial.SetFloat ("_Blur", blur); // blur intensity 96 | m_VignetteMaterial.SetTexture ("_VignetteTex", color2A); // blurred texture 97 | 98 | Graphics.Blit (source, color, m_VignetteMaterial, 0); // prepass blit: darken & blur corners 99 | } 100 | 101 | m_ChromAberrationMaterial.SetFloat ("_ChromaticAberration", chromaticAberration); 102 | m_ChromAberrationMaterial.SetFloat ("_AxialAberration", axialAberration); 103 | m_ChromAberrationMaterial.SetVector ("_BlurDistance", new Vector2 (-blurDistance, blurDistance)); 104 | m_ChromAberrationMaterial.SetFloat ("_Luminance", 1.0f/Mathf.Max(Mathf.Epsilon, luminanceDependency)); 105 | 106 | if (doPrepass) color.wrapMode = TextureWrapMode.Clamp; 107 | else source.wrapMode = TextureWrapMode.Clamp; 108 | Graphics.Blit (doPrepass ? color : source, destination, m_ChromAberrationMaterial, mode == AberrationMode.Advanced ? 2 : 1); 109 | 110 | RenderTexture.ReleaseTemporary (color); 111 | RenderTexture.ReleaseTemporary (color2A); 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Scripts/VignetteAndChromaticAberration.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dd6d4281e5d7cd44d8c6e38bc2c1b8d8 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: 6 | - vignetteShader: {fileID: 4800000, guid: 627943dc7a9a74286b70a4f694a0acd5, type: 3} 7 | - separableBlurShader: {fileID: 4800000, guid: e97c14fbb5ea04c3a902cc533d7fc5d1, 8 | type: 3} 9 | - chromAberrationShader: {fileID: 4800000, guid: 2b4f29398d9484ccfa9fd220449f5eee, 10 | type: 3} 11 | executionOrder: 0 12 | icon: {instanceID: 0} 13 | userData: 14 | assetBundleName: 15 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b2145489f7c704db8acb14a52bddeee9 3 | folderAsset: yes 4 | timeCreated: 1432478651 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Shaders/ChromaticAberrationShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/ChromaticAberration" { 2 | Properties { 3 | _MainTex ("Base", 2D) = "" {} 4 | } 5 | 6 | CGINCLUDE 7 | 8 | #include "UnityCG.cginc" 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 uv : TEXCOORD0; 13 | }; 14 | 15 | sampler2D _MainTex; 16 | 17 | float4 _MainTex_TexelSize; 18 | half _ChromaticAberration; 19 | half _AxialAberration; 20 | half _Luminance; 21 | half2 _BlurDistance; 22 | 23 | v2f vert( appdata_img v ) 24 | { 25 | v2f o; 26 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 27 | o.uv = v.texcoord.xy; 28 | 29 | return o; 30 | } 31 | 32 | half4 fragDs(v2f i) : SV_Target 33 | { 34 | half4 c = tex2D (_MainTex, i.uv.xy + _MainTex_TexelSize.xy * 0.5); 35 | c += tex2D (_MainTex, i.uv.xy - _MainTex_TexelSize.xy * 0.5); 36 | c += tex2D (_MainTex, i.uv.xy + _MainTex_TexelSize.xy * float2(0.5,-0.5)); 37 | c += tex2D (_MainTex, i.uv.xy - _MainTex_TexelSize.xy * float2(0.5,-0.5)); 38 | return c/4.0; 39 | } 40 | 41 | half4 frag(v2f i) : SV_Target 42 | { 43 | half2 coords = i.uv; 44 | half2 uv = i.uv; 45 | 46 | coords = (coords - 0.5) * 2.0; 47 | half coordDot = dot (coords,coords); 48 | 49 | half2 uvG = uv - _MainTex_TexelSize.xy * _ChromaticAberration * coords * coordDot; 50 | half4 color = tex2D (_MainTex, uv); 51 | #if SHADER_API_D3D9 52 | // Work around Cg's code generation bug for D3D9 pixel shaders :( 53 | color.g = color.g * 0.0001 + tex2D (_MainTex, uvG).g; 54 | #else 55 | color.g = tex2D (_MainTex, uvG).g; 56 | #endif 57 | 58 | return color; 59 | } 60 | 61 | // squeezing into SM2.0 with 9 samples: 62 | static const int SmallDiscKernelSamples = 9; 63 | static const half2 SmallDiscKernel[SmallDiscKernelSamples] = 64 | { 65 | half2(-0.926212,-0.40581), 66 | half2(-0.695914,0.457137), 67 | half2(-0.203345,0.820716), 68 | half2(0.96234,-0.194983), 69 | half2(0.473434,-0.480026), 70 | half2(0.519456,0.767022), 71 | half2(0.185461,-0.893124), 72 | half2(0.89642,0.412458), 73 | half2(-0.32194,-0.932615), 74 | }; 75 | 76 | half4 fragComplex(v2f i) : SV_Target 77 | { 78 | half2 coords = i.uv; 79 | half2 uv = i.uv; 80 | 81 | // corner heuristic 82 | coords = (coords - 0.5h) * 2.0h; 83 | half coordDot = dot (coords,coords); 84 | 85 | half4 color = tex2D (_MainTex, uv); 86 | half tangentialStrength = _ChromaticAberration * coordDot * coordDot; 87 | half maxOfs = clamp(max(_AxialAberration, tangentialStrength), _BlurDistance.x, _BlurDistance.y); 88 | 89 | // we need a blurred sample tap for advanced aberration 90 | 91 | // NOTE: it's relatively important that input is HDR 92 | // and if you do have a proper HDR setup, lerping .rb might yield better results than .g 93 | // (see below) 94 | 95 | half4 blurredTap = color * 0.1h; 96 | for(int l=0; l < SmallDiscKernelSamples; l++) 97 | { 98 | half2 sampleUV = uv + SmallDiscKernel[l].xy * _MainTex_TexelSize.xy * maxOfs; 99 | half3 tap = tex2D(_MainTex, sampleUV).rgb; 100 | blurredTap.rgb += tap; 101 | } 102 | blurredTap.rgb /= (float)SmallDiscKernelSamples + 0.2h; 103 | 104 | // debug: 105 | //return blurredTap; 106 | 107 | half lumDiff = Luminance(abs(blurredTap.rgb-color.rgb)); 108 | half isEdge = saturate(_Luminance * lumDiff); 109 | 110 | // debug #2: 111 | //return isEdge; 112 | 113 | color.rb = lerp(color.rb, blurredTap.rb, isEdge); 114 | 115 | return color; 116 | } 117 | 118 | ENDCG 119 | 120 | Subshader { 121 | 122 | // 0: box downsample 123 | Pass { 124 | ZTest Always Cull Off ZWrite Off 125 | 126 | CGPROGRAM 127 | 128 | #pragma vertex vert 129 | #pragma fragment fragDs 130 | 131 | ENDCG 132 | } 133 | // 1: simple chrom aberration 134 | Pass { 135 | ZTest Always Cull Off ZWrite Off 136 | 137 | CGPROGRAM 138 | 139 | #pragma vertex vert 140 | #pragma fragment frag 141 | 142 | ENDCG 143 | } 144 | // 2: simulates more chromatic aberration effects 145 | Pass { 146 | ZTest Always Cull Off ZWrite Off 147 | 148 | CGPROGRAM 149 | 150 | #pragma vertex vert 151 | #pragma fragment fragComplex 152 | 153 | ENDCG 154 | } 155 | } 156 | 157 | Fallback off 158 | 159 | } // shader 160 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Shaders/ChromaticAberrationShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2b4f29398d9484ccfa9fd220449f5eee 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Shaders/VignettingShader.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Vignetting" { 2 | Properties { 3 | _MainTex ("Base", 2D) = "white" {} 4 | _VignetteTex ("Vignette", 2D) = "white" {} 5 | } 6 | 7 | CGINCLUDE 8 | 9 | #include "UnityCG.cginc" 10 | 11 | struct v2f { 12 | float4 pos : SV_POSITION; 13 | float2 uv : TEXCOORD0; 14 | float2 uv2 : TEXCOORD1; 15 | }; 16 | 17 | sampler2D _MainTex; 18 | sampler2D _VignetteTex; 19 | 20 | half _Intensity; 21 | half _Blur; 22 | 23 | float4 _MainTex_TexelSize; 24 | 25 | v2f vert( appdata_img v ) { 26 | v2f o; 27 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 28 | o.uv = v.texcoord.xy; 29 | o.uv2 = v.texcoord.xy; 30 | 31 | #if UNITY_UV_STARTS_AT_TOP 32 | if (_MainTex_TexelSize.y < 0) 33 | o.uv2.y = 1.0 - o.uv2.y; 34 | #endif 35 | 36 | return o; 37 | } 38 | 39 | half4 frag(v2f i) : SV_Target { 40 | half2 coords = i.uv; 41 | half2 uv = i.uv; 42 | 43 | coords = (coords - 0.5) * 2.0; 44 | half coordDot = dot (coords,coords); 45 | half4 color = tex2D (_MainTex, uv); 46 | 47 | float mask = 1.0 - coordDot * _Intensity * 0.1; 48 | 49 | half4 colorBlur = tex2D (_VignetteTex, i.uv2); 50 | color = lerp (color, colorBlur, saturate (_Blur * coordDot)); 51 | 52 | return color * mask; 53 | } 54 | 55 | ENDCG 56 | 57 | Subshader { 58 | Pass { 59 | ZTest Always Cull Off ZWrite Off 60 | 61 | CGPROGRAM 62 | #pragma vertex vert 63 | #pragma fragment frag 64 | ENDCG 65 | } 66 | } 67 | 68 | Fallback off 69 | } 70 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Shaders/VignettingShader.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 627943dc7a9a74286b70a4f694a0acd5 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9cccf980fcb7441d85b8b3b5c2d2c34 3 | folderAsset: yes 4 | timeCreated: 1432478651 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField/SeparableBlur.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/SeparableBlur" { 2 | Properties { 3 | _MainTex ("Base (RGB)", 2D) = "" {} 4 | } 5 | 6 | CGINCLUDE 7 | 8 | #include "UnityCG.cginc" 9 | 10 | struct v2f { 11 | float4 pos : SV_POSITION; 12 | float2 uv : TEXCOORD0; 13 | 14 | float4 uv01 : TEXCOORD1; 15 | float4 uv23 : TEXCOORD2; 16 | float4 uv45 : TEXCOORD3; 17 | }; 18 | 19 | float4 offsets; 20 | 21 | sampler2D _MainTex; 22 | 23 | v2f vert (appdata_img v) { 24 | v2f o; 25 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 26 | 27 | o.uv.xy = v.texcoord.xy; 28 | 29 | o.uv01 = v.texcoord.xyxy + offsets.xyxy * float4(1,1, -1,-1); 30 | o.uv23 = v.texcoord.xyxy + offsets.xyxy * float4(1,1, -1,-1) * 2.0; 31 | o.uv45 = v.texcoord.xyxy + offsets.xyxy * float4(1,1, -1,-1) * 3.0; 32 | 33 | return o; 34 | } 35 | 36 | half4 frag (v2f i) : SV_Target { 37 | half4 color = float4 (0,0,0,0); 38 | 39 | color += 0.40 * tex2D (_MainTex, i.uv); 40 | color += 0.15 * tex2D (_MainTex, i.uv01.xy); 41 | color += 0.15 * tex2D (_MainTex, i.uv01.zw); 42 | color += 0.10 * tex2D (_MainTex, i.uv23.xy); 43 | color += 0.10 * tex2D (_MainTex, i.uv23.zw); 44 | color += 0.05 * tex2D (_MainTex, i.uv45.xy); 45 | color += 0.05 * tex2D (_MainTex, i.uv45.zw); 46 | 47 | return color; 48 | } 49 | 50 | ENDCG 51 | 52 | Subshader { 53 | Pass { 54 | ZTest Always Cull Off ZWrite Off 55 | 56 | CGPROGRAM 57 | #pragma vertex vert 58 | #pragma fragment frag 59 | ENDCG 60 | } 61 | } 62 | 63 | Fallback off 64 | 65 | 66 | } // shader 67 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ImageEffects/Shaders/_DepthOfField/SeparableBlur.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e97c14fbb5ea04c3a902cc533d7fc5d1 3 | ShaderImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/Test.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ef8eb9028bea14093bdded5a6b0a81b4 3 | folderAsset: yes 4 | timeCreated: 1437873636 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Test/Skybox.mat: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!21 &2100000 4 | Material: 5 | serializedVersion: 6 6 | m_ObjectHideFlags: 0 7 | m_PrefabParentObject: {fileID: 0} 8 | m_PrefabInternal: {fileID: 0} 9 | m_Name: Skybox 10 | m_Shader: {fileID: 103, guid: 0000000000000000f000000000000000, type: 0} 11 | m_ShaderKeywords: 12 | m_LightmapFlags: 5 13 | m_CustomRenderQueue: -1 14 | stringTagMap: {} 15 | m_SavedProperties: 16 | serializedVersion: 2 17 | m_TexEnvs: 18 | data: 19 | first: 20 | name: _MainTex 21 | second: 22 | m_Texture: {fileID: 0} 23 | m_Scale: {x: 1, y: 1} 24 | m_Offset: {x: 0, y: 0} 25 | data: 26 | first: 27 | name: _BumpMap 28 | second: 29 | m_Texture: {fileID: 0} 30 | m_Scale: {x: 1, y: 1} 31 | m_Offset: {x: 0, y: 0} 32 | data: 33 | first: 34 | name: _DetailNormalMap 35 | second: 36 | m_Texture: {fileID: 0} 37 | m_Scale: {x: 1, y: 1} 38 | m_Offset: {x: 0, y: 0} 39 | data: 40 | first: 41 | name: _Tex 42 | second: 43 | m_Texture: {fileID: 8900000, guid: 9b368ffd6161d48b1a9eeea72177ea49, type: 3} 44 | m_Scale: {x: 1, y: 1} 45 | m_Offset: {x: 0, y: 0} 46 | data: 47 | first: 48 | name: _ParallaxMap 49 | second: 50 | m_Texture: {fileID: 0} 51 | m_Scale: {x: 1, y: 1} 52 | m_Offset: {x: 0, y: 0} 53 | data: 54 | first: 55 | name: _OcclusionMap 56 | second: 57 | m_Texture: {fileID: 0} 58 | m_Scale: {x: 1, y: 1} 59 | m_Offset: {x: 0, y: 0} 60 | data: 61 | first: 62 | name: _EmissionMap 63 | second: 64 | m_Texture: {fileID: 0} 65 | m_Scale: {x: 1, y: 1} 66 | m_Offset: {x: 0, y: 0} 67 | data: 68 | first: 69 | name: _DetailMask 70 | second: 71 | m_Texture: {fileID: 0} 72 | m_Scale: {x: 1, y: 1} 73 | m_Offset: {x: 0, y: 0} 74 | data: 75 | first: 76 | name: _DetailAlbedoMap 77 | second: 78 | m_Texture: {fileID: 0} 79 | m_Scale: {x: 1, y: 1} 80 | m_Offset: {x: 0, y: 0} 81 | data: 82 | first: 83 | name: _MetallicGlossMap 84 | second: 85 | m_Texture: {fileID: 0} 86 | m_Scale: {x: 1, y: 1} 87 | m_Offset: {x: 0, y: 0} 88 | m_Floats: 89 | data: 90 | first: 91 | name: _SrcBlend 92 | second: 1 93 | data: 94 | first: 95 | name: _DstBlend 96 | second: 0 97 | data: 98 | first: 99 | name: _Cutoff 100 | second: .5 101 | data: 102 | first: 103 | name: _Exposure 104 | second: 1.29999995 105 | data: 106 | first: 107 | name: _Parallax 108 | second: .0199999996 109 | data: 110 | first: 111 | name: _ZWrite 112 | second: 1 113 | data: 114 | first: 115 | name: _Glossiness 116 | second: .5 117 | data: 118 | first: 119 | name: _BumpScale 120 | second: 1 121 | data: 122 | first: 123 | name: _OcclusionStrength 124 | second: 1 125 | data: 126 | first: 127 | name: _DetailNormalMapScale 128 | second: 1 129 | data: 130 | first: 131 | name: _UVSec 132 | second: 0 133 | data: 134 | first: 135 | name: _Mode 136 | second: 0 137 | data: 138 | first: 139 | name: _Metallic 140 | second: 0 141 | data: 142 | first: 143 | name: _Rotation 144 | second: 160 145 | m_Colors: 146 | data: 147 | first: 148 | name: _EmissionColor 149 | second: {r: 0, g: 0, b: 0, a: 1} 150 | data: 151 | first: 152 | name: _Color 153 | second: {r: 1, g: 1, b: 1, a: 1} 154 | data: 155 | first: 156 | name: _Tint 157 | second: {r: .5, g: .5, b: .5, a: .5} 158 | -------------------------------------------------------------------------------- /Assets/Test/Skybox.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5cbce565a87ea47f0993771c82553a4b 3 | timeCreated: 1437662283 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Test/Test.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bc5264cba2cb2447ca5faea42cec3e8e 3 | timeCreated: 1437661600 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Test/waterfall_Ref.exr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/keijiro/KvantRibbon/908c7090e70467dd225f3318e37331c3ae2b3458/Assets/Test/waterfall_Ref.exr -------------------------------------------------------------------------------- /Assets/Test/waterfall_Ref.exr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9b368ffd6161d48b1a9eeea72177ea49 3 | timeCreated: 1437824103 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: 7 | 8900000: generatedCubemap 8 | serializedVersion: 2 9 | mipmaps: 10 | mipMapMode: 0 11 | enableMipMap: 1 12 | linearTexture: 0 13 | correctGamma: 0 14 | fadeOut: 0 15 | borderMipMap: 0 16 | mipMapFadeDistanceStart: 1 17 | mipMapFadeDistanceEnd: 3 18 | bumpmap: 19 | convertToNormalMap: 0 20 | externalNormalMap: 0 21 | heightScale: .25 22 | normalMapFilter: 0 23 | isReadable: 0 24 | grayScaleToAlpha: 0 25 | generateCubemap: 6 26 | cubemapConvolution: 0 27 | cubemapConvolutionSteps: 8 28 | cubemapConvolutionExponent: 1.5 29 | seamlessCubemap: 0 30 | textureFormat: -1 31 | maxTextureSize: 2048 32 | textureSettings: 33 | filterMode: -1 34 | aniso: -1 35 | mipBias: -1 36 | wrapMode: 1 37 | nPOTScale: 1 38 | lightmap: 0 39 | rGBM: 0 40 | compressionQuality: 50 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: .5, y: .5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: 3 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | spritePackingTag: 54 | userData: 55 | assetBundleName: 56 | assetBundleVariant: 57 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!11 &1 4 | AudioManager: 5 | m_ObjectHideFlags: 0 6 | m_Volume: 1 7 | Rolloff Scale: 1 8 | Doppler Factor: 1 9 | Default Speaker Mode: 2 10 | m_SampleRate: 0 11 | m_DSPBufferSize: 0 12 | m_VirtualVoiceCount: 512 13 | m_RealVoiceCount: 32 14 | m_DisableAudio: 0 15 | -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!55 &1 4 | PhysicsManager: 5 | m_ObjectHideFlags: 0 6 | m_Gravity: {x: 0, y: -9.81000042, z: 0} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_BounceThreshold: 2 9 | m_SleepThreshold: .00499999989 10 | m_DefaultContactOffset: .00999999978 11 | m_SolverIterationCount: 6 12 | m_RaycastsHitTriggers: 1 13 | m_EnableAdaptiveForce: 0 14 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 15 | -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1045 &1 4 | EditorBuildSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Scenes: [] 8 | -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!159 &1 4 | EditorSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_ExternalVersionControlSupport: Visible Meta Files 8 | m_SerializationMode: 2 9 | m_WebSecurityEmulationEnabled: 0 10 | m_WebSecurityEmulationHostUrl: http://www.mydomain.com/mygame.unity3d 11 | m_DefaultBehaviorMode: 0 12 | m_SpritePackerMode: 2 13 | m_SpritePackerPaddingPower: 1 14 | -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!30 &1 4 | GraphicsSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 3 7 | m_Deferred: 8 | m_Mode: 1 9 | m_Shader: {fileID: 69, guid: 0000000000000000f000000000000000, type: 0} 10 | m_LegacyDeferred: 11 | m_Mode: 1 12 | m_Shader: {fileID: 63, guid: 0000000000000000f000000000000000, type: 0} 13 | m_AlwaysIncludedShaders: 14 | - {fileID: 7, guid: 0000000000000000f000000000000000, type: 0} 15 | - {fileID: 15104, guid: 0000000000000000f000000000000000, type: 0} 16 | - {fileID: 15105, guid: 0000000000000000f000000000000000, type: 0} 17 | - {fileID: 15106, guid: 0000000000000000f000000000000000, type: 0} 18 | - {fileID: 10770, guid: 0000000000000000f000000000000000, type: 0} 19 | - {fileID: 10782, guid: 0000000000000000f000000000000000, type: 0} 20 | m_PreloadedShaders: [] 21 | m_LightmapStripping: 0 22 | m_LightmapKeepPlain: 1 23 | m_LightmapKeepDirCombined: 1 24 | m_LightmapKeepDirSeparate: 1 25 | m_LightmapKeepDynamic: 1 26 | m_FogStripping: 0 27 | m_FogKeepLinear: 1 28 | m_FogKeepExp: 1 29 | m_FogKeepExp2: 1 30 | -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!13 &1 4 | InputManager: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_Axes: 8 | - serializedVersion: 3 9 | m_Name: Horizontal 10 | descriptiveName: 11 | descriptiveNegativeName: 12 | negativeButton: left 13 | positiveButton: right 14 | altNegativeButton: a 15 | altPositiveButton: d 16 | gravity: 3 17 | dead: .00100000005 18 | sensitivity: 3 19 | snap: 1 20 | invert: 0 21 | type: 0 22 | axis: 0 23 | joyNum: 0 24 | - serializedVersion: 3 25 | m_Name: Vertical 26 | descriptiveName: 27 | descriptiveNegativeName: 28 | negativeButton: down 29 | positiveButton: up 30 | altNegativeButton: s 31 | altPositiveButton: w 32 | gravity: 3 33 | dead: .00100000005 34 | sensitivity: 3 35 | snap: 1 36 | invert: 0 37 | type: 0 38 | axis: 0 39 | joyNum: 0 40 | - serializedVersion: 3 41 | m_Name: Fire1 42 | descriptiveName: 43 | descriptiveNegativeName: 44 | negativeButton: 45 | positiveButton: left ctrl 46 | altNegativeButton: 47 | altPositiveButton: mouse 0 48 | gravity: 1000 49 | dead: .00100000005 50 | sensitivity: 1000 51 | snap: 0 52 | invert: 0 53 | type: 0 54 | axis: 0 55 | joyNum: 0 56 | - serializedVersion: 3 57 | m_Name: Fire2 58 | descriptiveName: 59 | descriptiveNegativeName: 60 | negativeButton: 61 | positiveButton: left alt 62 | altNegativeButton: 63 | altPositiveButton: mouse 1 64 | gravity: 1000 65 | dead: .00100000005 66 | sensitivity: 1000 67 | snap: 0 68 | invert: 0 69 | type: 0 70 | axis: 0 71 | joyNum: 0 72 | - serializedVersion: 3 73 | m_Name: Fire3 74 | descriptiveName: 75 | descriptiveNegativeName: 76 | negativeButton: 77 | positiveButton: left shift 78 | altNegativeButton: 79 | altPositiveButton: mouse 2 80 | gravity: 1000 81 | dead: .00100000005 82 | sensitivity: 1000 83 | snap: 0 84 | invert: 0 85 | type: 0 86 | axis: 0 87 | joyNum: 0 88 | - serializedVersion: 3 89 | m_Name: Jump 90 | descriptiveName: 91 | descriptiveNegativeName: 92 | negativeButton: 93 | positiveButton: space 94 | altNegativeButton: 95 | altPositiveButton: 96 | gravity: 1000 97 | dead: .00100000005 98 | sensitivity: 1000 99 | snap: 0 100 | invert: 0 101 | type: 0 102 | axis: 0 103 | joyNum: 0 104 | - serializedVersion: 3 105 | m_Name: Mouse X 106 | descriptiveName: 107 | descriptiveNegativeName: 108 | negativeButton: 109 | positiveButton: 110 | altNegativeButton: 111 | altPositiveButton: 112 | gravity: 0 113 | dead: 0 114 | sensitivity: .100000001 115 | snap: 0 116 | invert: 0 117 | type: 1 118 | axis: 0 119 | joyNum: 0 120 | - serializedVersion: 3 121 | m_Name: Mouse Y 122 | descriptiveName: 123 | descriptiveNegativeName: 124 | negativeButton: 125 | positiveButton: 126 | altNegativeButton: 127 | altPositiveButton: 128 | gravity: 0 129 | dead: 0 130 | sensitivity: .100000001 131 | snap: 0 132 | invert: 0 133 | type: 1 134 | axis: 1 135 | joyNum: 0 136 | - serializedVersion: 3 137 | m_Name: Mouse ScrollWheel 138 | descriptiveName: 139 | descriptiveNegativeName: 140 | negativeButton: 141 | positiveButton: 142 | altNegativeButton: 143 | altPositiveButton: 144 | gravity: 0 145 | dead: 0 146 | sensitivity: .100000001 147 | snap: 0 148 | invert: 0 149 | type: 1 150 | axis: 2 151 | joyNum: 0 152 | - serializedVersion: 3 153 | m_Name: Horizontal 154 | descriptiveName: 155 | descriptiveNegativeName: 156 | negativeButton: 157 | positiveButton: 158 | altNegativeButton: 159 | altPositiveButton: 160 | gravity: 0 161 | dead: .189999998 162 | sensitivity: 1 163 | snap: 0 164 | invert: 0 165 | type: 2 166 | axis: 0 167 | joyNum: 0 168 | - serializedVersion: 3 169 | m_Name: Vertical 170 | descriptiveName: 171 | descriptiveNegativeName: 172 | negativeButton: 173 | positiveButton: 174 | altNegativeButton: 175 | altPositiveButton: 176 | gravity: 0 177 | dead: .189999998 178 | sensitivity: 1 179 | snap: 0 180 | invert: 1 181 | type: 2 182 | axis: 1 183 | joyNum: 0 184 | - serializedVersion: 3 185 | m_Name: Fire1 186 | descriptiveName: 187 | descriptiveNegativeName: 188 | negativeButton: 189 | positiveButton: joystick button 0 190 | altNegativeButton: 191 | altPositiveButton: 192 | gravity: 1000 193 | dead: .00100000005 194 | sensitivity: 1000 195 | snap: 0 196 | invert: 0 197 | type: 0 198 | axis: 0 199 | joyNum: 0 200 | - serializedVersion: 3 201 | m_Name: Fire2 202 | descriptiveName: 203 | descriptiveNegativeName: 204 | negativeButton: 205 | positiveButton: joystick button 1 206 | altNegativeButton: 207 | altPositiveButton: 208 | gravity: 1000 209 | dead: .00100000005 210 | sensitivity: 1000 211 | snap: 0 212 | invert: 0 213 | type: 0 214 | axis: 0 215 | joyNum: 0 216 | - serializedVersion: 3 217 | m_Name: Fire3 218 | descriptiveName: 219 | descriptiveNegativeName: 220 | negativeButton: 221 | positiveButton: joystick button 2 222 | altNegativeButton: 223 | altPositiveButton: 224 | gravity: 1000 225 | dead: .00100000005 226 | sensitivity: 1000 227 | snap: 0 228 | invert: 0 229 | type: 0 230 | axis: 0 231 | joyNum: 0 232 | - serializedVersion: 3 233 | m_Name: Jump 234 | descriptiveName: 235 | descriptiveNegativeName: 236 | negativeButton: 237 | positiveButton: joystick button 3 238 | altNegativeButton: 239 | altPositiveButton: 240 | gravity: 1000 241 | dead: .00100000005 242 | sensitivity: 1000 243 | snap: 0 244 | invert: 0 245 | type: 0 246 | axis: 0 247 | joyNum: 0 248 | - serializedVersion: 3 249 | m_Name: Submit 250 | descriptiveName: 251 | descriptiveNegativeName: 252 | negativeButton: 253 | positiveButton: return 254 | altNegativeButton: 255 | altPositiveButton: joystick button 0 256 | gravity: 1000 257 | dead: .00100000005 258 | sensitivity: 1000 259 | snap: 0 260 | invert: 0 261 | type: 0 262 | axis: 0 263 | joyNum: 0 264 | - serializedVersion: 3 265 | m_Name: Submit 266 | descriptiveName: 267 | descriptiveNegativeName: 268 | negativeButton: 269 | positiveButton: enter 270 | altNegativeButton: 271 | altPositiveButton: space 272 | gravity: 1000 273 | dead: .00100000005 274 | sensitivity: 1000 275 | snap: 0 276 | invert: 0 277 | type: 0 278 | axis: 0 279 | joyNum: 0 280 | - serializedVersion: 3 281 | m_Name: Cancel 282 | descriptiveName: 283 | descriptiveNegativeName: 284 | negativeButton: 285 | positiveButton: escape 286 | altNegativeButton: 287 | altPositiveButton: joystick button 1 288 | gravity: 1000 289 | dead: .00100000005 290 | sensitivity: 1000 291 | snap: 0 292 | invert: 0 293 | type: 0 294 | axis: 0 295 | joyNum: 0 296 | -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!126 &1 4 | NavMeshAreas: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | areas: 8 | - name: Walkable 9 | cost: 1 10 | - name: Not Walkable 11 | cost: 1 12 | - name: Jump 13 | cost: 2 14 | - name: 15 | cost: 1 16 | - name: 17 | cost: 1 18 | - name: 19 | cost: 1 20 | - name: 21 | cost: 1 22 | - name: 23 | cost: 1 24 | - name: 25 | cost: 1 26 | - name: 27 | cost: 1 28 | - name: 29 | cost: 1 30 | - name: 31 | cost: 1 32 | - name: 33 | cost: 1 34 | - name: 35 | cost: 1 36 | - name: 37 | cost: 1 38 | - name: 39 | cost: 1 40 | - name: 41 | cost: 1 42 | - name: 43 | cost: 1 44 | - name: 45 | cost: 1 46 | - name: 47 | cost: 1 48 | - name: 49 | cost: 1 50 | - name: 51 | cost: 1 52 | - name: 53 | cost: 1 54 | - name: 55 | cost: 1 56 | - name: 57 | cost: 1 58 | - name: 59 | cost: 1 60 | - name: 61 | cost: 1 62 | - name: 63 | cost: 1 64 | - name: 65 | cost: 1 66 | - name: 67 | cost: 1 68 | - name: 69 | cost: 1 70 | - name: 71 | cost: 1 72 | -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!149 &1 4 | NetworkManager: 5 | m_ObjectHideFlags: 0 6 | m_DebugLevel: 0 7 | m_Sendrate: 15 8 | m_AssetToPrefab: {} 9 | -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!19 &1 4 | Physics2DSettings: 5 | m_ObjectHideFlags: 0 6 | m_Gravity: {x: 0, y: -9.81000042} 7 | m_DefaultMaterial: {fileID: 0} 8 | m_VelocityIterations: 8 9 | m_PositionIterations: 3 10 | m_VelocityThreshold: 1 11 | m_MaxLinearCorrection: .200000003 12 | m_MaxAngularCorrection: 8 13 | m_MaxTranslationSpeed: 100 14 | m_MaxRotationSpeed: 360 15 | m_MinPenetrationForPenalty: .00999999978 16 | m_BaumgarteScale: .200000003 17 | m_BaumgarteTimeOfImpactScale: .75 18 | m_TimeToSleep: .5 19 | m_LinearSleepTolerance: .00999999978 20 | m_AngularSleepTolerance: 2 21 | m_RaycastsHitTriggers: 1 22 | m_RaycastsStartInColliders: 1 23 | m_ChangeStopsCallbacks: 0 24 | m_LayerCollisionMatrix: ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff 25 | -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.1.2f1 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!47 &1 4 | QualitySettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 5 7 | m_CurrentQuality: 0 8 | m_QualitySettings: 9 | - serializedVersion: 2 10 | name: Good 11 | pixelLightCount: 2 12 | shadows: 2 13 | shadowResolution: 1 14 | shadowProjection: 1 15 | shadowCascades: 2 16 | shadowDistance: 40 17 | shadowCascade2Split: .333333343 18 | shadowCascade4Split: {x: .0666666701, y: .200000003, z: .466666669} 19 | blendWeights: 2 20 | textureQuality: 0 21 | anisotropicTextures: 1 22 | antiAliasing: 0 23 | softParticles: 0 24 | softVegetation: 1 25 | realtimeReflectionProbes: 1 26 | billboardsFaceCameraPosition: 1 27 | vSyncCount: 1 28 | lodBias: 1 29 | maximumLODLevel: 0 30 | particleRaycastBudget: 256 31 | excludedTargetPlatforms: [] 32 | m_PerPlatformDefaultQuality: 33 | Android: 2 34 | BlackBerry: 2 35 | GLES Emulation: 5 36 | PS3: 5 37 | PS4: 5 38 | PSM: 5 39 | PSP2: 5 40 | Samsung TV: 2 41 | Standalone: 5 42 | Tizen: 2 43 | WP8: 5 44 | Web: 5 45 | WebGL: 3 46 | Windows Store Apps: 5 47 | XBOX360: 5 48 | XboxOne: 5 49 | iPhone: 2 50 | -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!78 &1 4 | TagManager: 5 | serializedVersion: 2 6 | tags: [] 7 | layers: 8 | - Default 9 | - TransparentFX 10 | - Ignore Raycast 11 | - 12 | - Water 13 | - UI 14 | - 15 | - 16 | - 17 | - 18 | - 19 | - 20 | - 21 | - 22 | - 23 | - 24 | - 25 | - 26 | - 27 | - 28 | - 29 | - 30 | - 31 | - 32 | - 33 | - 34 | - 35 | - 36 | - 37 | - 38 | - 39 | - 40 | m_SortingLayers: 41 | - name: Default 42 | uniqueID: 0 43 | locked: 0 44 | -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!5 &1 4 | TimeManager: 5 | m_ObjectHideFlags: 0 6 | Fixed Timestep: .0199999996 7 | Maximum Allowed Timestep: .333333343 8 | m_TimeScale: 1 9 | --------------------------------------------------------------------------------