├── .gitignore ├── .vs └── config │ └── applicationhost.config ├── Assets ├── Fractal.meta ├── Fractal │ ├── Materials.meta │ ├── Materials │ │ ├── JuliaSet.mat │ │ ├── JuliaSet.mat.meta │ │ ├── MandelbrotSet.mat │ │ └── MandelbrotSet.mat.meta │ ├── Resources.meta │ ├── Resources │ │ ├── BranchCube.prefab │ │ ├── BranchCube.prefab.meta │ │ ├── RobotCube.prefab │ │ └── RobotCube.prefab.meta │ ├── Scenes.meta │ ├── Scenes │ │ ├── 2D Fractals.unity │ │ ├── 2D Fractals.unity.meta │ │ ├── Fractal Tree.unity │ │ └── Fractal Tree.unity.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── DetatchAndHinge.cs │ │ ├── DetatchAndHinge.cs.meta │ │ ├── Grower.cs │ │ ├── Grower.cs.meta │ │ ├── MaterialAnimator.meta │ │ ├── MaterialAnimator │ │ │ ├── AnimationController.cs │ │ │ ├── AnimationController.cs.meta │ │ │ ├── MaterialAnimator.cs │ │ │ ├── MaterialAnimator.cs.meta │ │ │ ├── Publisher.cs │ │ │ ├── Publisher.cs.meta │ │ │ ├── SinPublisher.cs │ │ │ └── SinPublisher.cs.meta │ │ ├── RecursiveBundle.cs │ │ ├── RecursiveBundle.cs.meta │ │ ├── RecursiveInstantiator.cs │ │ ├── RecursiveInstantiator.cs.meta │ │ ├── Rotation.cs │ │ ├── Rotation.cs.meta │ │ ├── Scale.cs │ │ └── Scale.cs.meta │ ├── Shaders.meta │ └── Shaders │ │ ├── Julia.shader │ │ ├── Julia.shader.meta │ │ ├── Mandelbrot.shader │ │ └── Mandelbrot.shader.meta ├── Standard Assets.meta └── Standard Assets │ ├── Effects.meta │ └── Effects │ ├── AmbientOcclusion.meta │ ├── AmbientOcclusion │ ├── AmbientOcclusion.cs │ ├── AmbientOcclusion.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── AmbientOcclusionEditor.cs │ │ └── AmbientOcclusionEditor.cs.meta │ ├── Helpers.meta │ ├── Helpers │ │ ├── PropertyObserver.cs │ │ ├── PropertyObserver.cs.meta │ │ ├── Settings.cs │ │ └── Settings.cs.meta │ ├── Resources.meta │ └── Resources │ │ ├── AmbientOcclusion.cginc │ │ ├── AmbientOcclusion.cginc.meta │ │ ├── AmbientOcclusion.shader │ │ └── AmbientOcclusion.shader.meta │ ├── AntiAliasing.meta │ ├── AntiAliasing │ ├── AntiAliasing.cs │ ├── AntiAliasing.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── AntiAliasingEditor.cs │ │ ├── AntiAliasingEditor.cs.meta │ │ ├── IAntiAliasingEditor.cs │ │ └── IAntiAliasingEditor.cs.meta │ ├── FXAA.meta │ ├── FXAA │ │ ├── Editor.meta │ │ ├── Editor │ │ │ ├── FXAAEditor.cs │ │ │ └── FXAAEditor.cs.meta │ │ ├── FXAA.cs │ │ ├── FXAA.cs.meta │ │ ├── Resources.meta │ │ └── Resources │ │ │ ├── FXAA.shader │ │ │ ├── FXAA.shader.meta │ │ │ ├── FXAA3.cginc │ │ │ └── FXAA3.cginc.meta │ ├── IAntiAliasing.cs │ ├── IAntiAliasing.cs.meta │ ├── SMAA.meta │ └── SMAA │ │ ├── Editor.meta │ │ ├── Editor │ │ ├── SMAAEditor.cs │ │ └── SMAAEditor.cs.meta │ │ ├── Resources.meta │ │ ├── Resources │ │ ├── AreaTex.tga │ │ ├── AreaTex.tga.meta │ │ ├── SMAA.cginc │ │ ├── SMAA.cginc.meta │ │ ├── SMAA.shader │ │ ├── SMAA.shader.meta │ │ ├── SearchTex.tga │ │ └── SearchTex.tga.meta │ │ ├── SMAA.cs │ │ └── SMAA.cs.meta │ ├── Bloom.meta │ ├── Bloom │ ├── Bloom.cs │ ├── Bloom.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── BloomEditor.cs │ │ ├── BloomEditor.cs.meta │ │ ├── BloomGraphDrawer.cs │ │ └── BloomGraphDrawer.cs.meta │ ├── Resources.meta │ └── Resources │ │ ├── Bloom.cginc │ │ ├── Bloom.cginc.meta │ │ ├── Bloom.shader │ │ └── Bloom.shader.meta │ ├── Common.meta │ ├── Common │ ├── Editor.meta │ ├── Editor │ │ ├── EditorGUIHelper.cs │ │ ├── EditorGUIHelper.cs.meta │ │ ├── FieldFinder.cs │ │ ├── FieldFinder.cs.meta │ │ ├── MinDrawer.cs │ │ └── MinDrawer.cs.meta │ ├── ImageEffectHelper.cs │ ├── ImageEffectHelper.cs.meta │ ├── MinAttribute.cs │ ├── MinAttribute.cs.meta │ ├── RenderTextureUtility.cs │ └── RenderTextureUtility.cs.meta │ ├── DepthOfField.meta │ ├── DepthOfField │ ├── DepthOfField.cs │ ├── DepthOfField.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── DepthOfFieldEditor.cs │ │ └── DepthOfFieldEditor.cs.meta │ ├── Helpers.meta │ ├── Helpers │ │ ├── HexShape.psd │ │ ├── HexShape.psd.meta │ │ ├── RoundedHexShape.tif │ │ ├── RoundedHexShape.tif.meta │ │ ├── SphereShape.psd │ │ └── SphereShape.psd.meta │ ├── Resources.meta │ └── Resources │ │ ├── BokehSplatting.shader │ │ ├── BokehSplatting.shader.meta │ │ ├── DepthOfField.shader │ │ ├── DepthOfField.shader.meta │ │ ├── MedianFilter.shader │ │ └── MedianFilter.shader.meta │ ├── LensAberrations.meta │ ├── LensAberrations │ ├── Editor.meta │ ├── Editor │ │ ├── LensAberrationsEditor.cs │ │ └── LensAberrationsEditor.cs.meta │ ├── LensAberrations.cs │ ├── LensAberrations.cs.meta │ ├── Resources.meta │ └── Resources │ │ ├── LensAberrations.shader │ │ └── LensAberrations.shader.meta │ ├── ScreenSpaceReflection.meta │ ├── ScreenSpaceReflection │ ├── Editor.meta │ ├── Editor │ │ ├── ScreenSpaceReflectionEditor.cs │ │ └── ScreenSpaceReflectionEditor.cs.meta │ ├── Resources.meta │ ├── Resources │ │ ├── ScreenSpaceRaytrace.cginc │ │ ├── ScreenSpaceRaytrace.cginc.meta │ │ ├── ScreenSpaceReflection.shader │ │ └── ScreenSpaceReflection.shader.meta │ ├── ScreenSpaceReflection.cs │ └── ScreenSpaceReflection.cs.meta │ ├── TonemappingColorGrading.meta │ └── TonemappingColorGrading │ ├── Editor.meta │ ├── Editor │ ├── TonemappingColorGradingEditor.cs │ └── TonemappingColorGradingEditor.cs.meta │ ├── Helpers.meta │ ├── Helpers │ ├── NeutralLUT16.png │ ├── NeutralLUT16.png.meta │ ├── NeutralLUT32.png │ └── NeutralLUT32.png.meta │ ├── Resources.meta │ ├── Resources │ ├── HistogramCompute.compute │ ├── HistogramCompute.compute.meta │ ├── HistogramRender.shader │ ├── HistogramRender.shader.meta │ ├── TonemappingColorGrading.cginc │ ├── TonemappingColorGrading.cginc.meta │ ├── TonemappingColorGrading.shader │ └── TonemappingColorGrading.shader.meta │ ├── TonemappingColorGrading.cs │ └── TonemappingColorGrading.cs.meta ├── LICENSE ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.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 ├── UnityAdsSettings.asset └── UnityConnectSettings.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | /[Ll]ibrary/ 2 | /[Tt]emp/ 3 | /[Oo]bj/ 4 | /[Bb]uild/ 5 | /[Bb]uilds/ 6 | /Assets/AssetStoreTools* 7 | 8 | # Autogenerated VS/MD solution and project files 9 | ExportedObj/ 10 | *.csproj 11 | *.unityproj 12 | *.sln 13 | *.suo 14 | *.tmp 15 | *.user 16 | *.userprefs 17 | *.pidb 18 | *.booproj 19 | *.svd 20 | 21 | 22 | # Unity3D generated meta files 23 | *.pidb.meta 24 | 25 | # Unity3D Generated File On Crash Reports 26 | sysinfo.txt 27 | 28 | # Builds 29 | *.apk 30 | *.unitypackage 31 | -------------------------------------------------------------------------------- /Assets/Fractal.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0d0e8f91468e97f4e86eb9c251ce26e0 3 | folderAsset: yes 4 | timeCreated: 1474819875 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Fractal/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6cd4c2e5551d3df4e95010c5220078cc 3 | folderAsset: yes 4 | timeCreated: 1475190916 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Fractal/Materials/JuliaSet.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Fractal/Materials/JuliaSet.mat -------------------------------------------------------------------------------- /Assets/Fractal/Materials/JuliaSet.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f66cdd3554ef4f14f8e6871508ed68d0 3 | timeCreated: 1475191404 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Fractal/Materials/MandelbrotSet.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Fractal/Materials/MandelbrotSet.mat -------------------------------------------------------------------------------- /Assets/Fractal/Materials/MandelbrotSet.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8734d0f69c6cc2e458506804045fe826 3 | timeCreated: 1475190925 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Fractal/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4a1e03a4ee62d8d44bd866adccb428da 3 | folderAsset: yes 4 | timeCreated: 1474819898 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Fractal/Resources/BranchCube.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Fractal/Resources/BranchCube.prefab -------------------------------------------------------------------------------- /Assets/Fractal/Resources/BranchCube.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: df6015b0685e968449e56badacaba949 3 | timeCreated: 1474819990 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Fractal/Resources/RobotCube.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Fractal/Resources/RobotCube.prefab -------------------------------------------------------------------------------- /Assets/Fractal/Resources/RobotCube.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 017bee478d252fa4bba1771dd6be13cb 3 | timeCreated: 1474822620 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Fractal/Scenes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9f49f5712df31754d8fa33463a573936 3 | folderAsset: yes 4 | timeCreated: 1474822708 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Fractal/Scenes/2D Fractals.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Fractal/Scenes/2D Fractals.unity -------------------------------------------------------------------------------- /Assets/Fractal/Scenes/2D Fractals.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 705fd5fad7b657f44acebe3d88b43ba4 3 | timeCreated: 1475189584 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Fractal/Scenes/Fractal Tree.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Fractal/Scenes/Fractal Tree.unity -------------------------------------------------------------------------------- /Assets/Fractal/Scenes/Fractal Tree.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 99544213969743d46abc7f4e1df4e6ca 3 | timeCreated: 1474822708 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 2d98932398466264cb5738c21362190f 3 | folderAsset: yes 4 | timeCreated: 1474944320 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts/DetatchAndHinge.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class DetatchAndHinge : MonoBehaviour { 5 | public Rigidbody rigidbody; 6 | public HingeJoint hinge; 7 | 8 | public void Generated(RecursiveBundle bundle) 9 | { 10 | var parentBody = bundle.Parent.GetComponent(); 11 | rigidbody.isKinematic = false; 12 | hinge.connectedBody = parentBody; 13 | hinge.autoConfigureConnectedAnchor = false; 14 | hinge.connectedAnchor = bundle.Parent.pivotPosition;// * bundle.Parent.transform.localScale.y; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts/DetatchAndHinge.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8c4de80124dd82144b62083e69108d50 3 | timeCreated: 1475119573 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/Fractal/Scripts/Grower.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Grower : MonoBehaviour { 5 | public void Generated(RecursiveBundle bundle) 6 | { 7 | this.transform.position += this.transform.up * this.transform.localScale.y; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts/Grower.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9717a0bb4826f4f47be3f93baacb95ce 3 | timeCreated: 1474945922 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/Fractal/Scripts/MaterialAnimator.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 297e73163c298654da5b99cb35ab0c3b 3 | folderAsset: yes 4 | timeCreated: 1476406612 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts/MaterialAnimator/AnimationController.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using UnityEngine; 5 | 6 | public class AnimationController : MonoBehaviour { 7 | 8 | private Dictionary> animatorsMap; 9 | 10 | public void Start() 11 | { 12 | animatorsMap = new Dictionary>(); 13 | var animators = GetComponents(); 14 | foreach (var animator in animators) 15 | { 16 | UpdateMaterialAnimator(String.Empty, animator.key, animator); 17 | } 18 | } 19 | 20 | public void UpdateMaterialAnimator(String oldKey, String newKey, MaterialAnimator animator) 21 | { 22 | if (animatorsMap.ContainsKey(oldKey)) 23 | { 24 | var oldAnimatorList = animatorsMap[oldKey]; 25 | oldAnimatorList.Remove(animator); 26 | } 27 | ICollection animatorList; 28 | if (!animatorsMap.ContainsKey(newKey)) 29 | { 30 | animatorList = new LinkedList(); 31 | animatorsMap.Add(newKey, animatorList); 32 | } 33 | else 34 | { 35 | animatorList = animatorsMap[newKey]; 36 | } 37 | animatorList.Add(animator); 38 | } 39 | 40 | public void PublishToAnimators(String key, float value) 41 | { 42 | 43 | if (animatorsMap.ContainsKey(key)) 44 | { 45 | var animators = animatorsMap[key]; 46 | foreach (var animator in animators) 47 | { 48 | animator.UpdateMaterial(value); 49 | } 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts/MaterialAnimator/AnimationController.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6d0a0bf14bb148c488a7b1a6869821ff 3 | timeCreated: 1480991569 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/Fractal/Scripts/MaterialAnimator/MaterialAnimator.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using System.Runtime.CompilerServices; 4 | 5 | public enum MaterialTarget 6 | { 7 | Zoom, 8 | ZoomX, 9 | ZoomY, 10 | PanX, 11 | PanY, 12 | SeedX, 13 | SeedY, 14 | Aspect 15 | } 16 | 17 | public class MaterialAnimator : MonoBehaviour { 18 | 19 | public string key; 20 | 21 | public Material modifiedMaterial; 22 | public MaterialTarget materialProperty; 23 | 24 | public void UpdateMaterial(float value) 25 | { 26 | var currentZoom = modifiedMaterial.GetVector("_Zoom"); 27 | var currentPan = modifiedMaterial.GetVector("_Pan"); 28 | var currentSeed = modifiedMaterial.GetVector("_Seed"); 29 | switch (materialProperty) 30 | { 31 | case MaterialTarget.Zoom: 32 | modifiedMaterial.SetVector("_Zoom", new Vector4(value, value, value, value)); 33 | break; 34 | case MaterialTarget.ZoomX: 35 | modifiedMaterial.SetVector("_Zoom", new Vector4(value, currentZoom.y, currentZoom.z, currentZoom.w)); 36 | break; 37 | case MaterialTarget.ZoomY: 38 | modifiedMaterial.SetVector("_Zoom", new Vector4(currentZoom.x, value, currentZoom.z, currentZoom.w)); 39 | break; 40 | case MaterialTarget.Aspect: 41 | modifiedMaterial.SetFloat("_Aspect", value); 42 | break; 43 | case MaterialTarget.PanX: 44 | modifiedMaterial.SetVector("_Pan", new Vector4(value, currentPan.y, currentPan.z, currentPan.w)); 45 | break; 46 | case MaterialTarget.PanY: 47 | modifiedMaterial.SetVector("_Pan", new Vector4(currentPan.x, value, currentPan.z, currentPan.w)); 48 | break; 49 | case MaterialTarget.SeedX: 50 | modifiedMaterial.SetVector("_Seed", new Vector4(value, currentSeed.y, currentSeed.z, currentSeed.w)); 51 | break; 52 | case MaterialTarget.SeedY: 53 | modifiedMaterial.SetVector("_Seed", new Vector4(currentSeed.x, value, currentSeed.z, currentSeed.w)); 54 | break; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts/MaterialAnimator/MaterialAnimator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b24065553024548498ae3f69be0fc6ed 3 | timeCreated: 1476406625 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/Fractal/Scripts/MaterialAnimator/Publisher.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using UnityEngine; 5 | 6 | [RequireComponent(typeof(AnimationController))] 7 | public class Publisher : MonoBehaviour { 8 | 9 | public string key; 10 | private IEnumerable animators; 11 | 12 | private AnimationController controller; 13 | 14 | public void Start() 15 | { 16 | controller = GetComponent(); 17 | } 18 | public void PublishChange(float value) 19 | { 20 | controller.PublishToAnimators(key, value); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts/MaterialAnimator/Publisher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e08de3491758a6f40a0f48c69a584aa0 3 | timeCreated: 1480989850 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/Fractal/Scripts/MaterialAnimator/SinPublisher.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class SinPublisher : Publisher 5 | { 6 | 7 | public float zeroValue = 1; 8 | public float amplitude = 1; 9 | public float timeScale = 0.25f; 10 | 11 | // Use this for initialization 12 | void Start () { 13 | base.Start(); 14 | } 15 | 16 | // Update is called once per frame 17 | void Update () { 18 | PublishChange(zeroValue + Mathf.Sin(Time.time * timeScale) * amplitude); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts/MaterialAnimator/SinPublisher.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dbc724e434507d344a8f8213e1b0ae7e 3 | timeCreated: 1476407171 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/Fractal/Scripts/RecursiveBundle.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class RecursiveBundle { 5 | public int Index { get; set; } 6 | public RecursiveInstantiator Parent { get; set; } 7 | } 8 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts/RecursiveBundle.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b8cb098b64e5e314495ae668b48e941b 3 | timeCreated: 1475120468 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/Fractal/Scripts/RecursiveInstantiator.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class RecursiveInstantiator : MonoBehaviour { 5 | 6 | public int recurse = 5; 7 | public int splitNumber = 2; 8 | public Vector3 pivotPosition; 9 | 10 | // Use this for initialization 11 | void Start () { 12 | recurse -= 1; 13 | 14 | for (int i = 0; i < splitNumber; ++i) 15 | { 16 | if (recurse > 0) 17 | { 18 | var copy = Instantiate(gameObject); 19 | var recursive = copy.GetComponent(); 20 | recursive.SendMessage("Generated", new RecursiveBundle() { Index = i, Parent = this }); 21 | } 22 | } 23 | } 24 | 25 | // Update is called once per frame 26 | void Update () { 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts/RecursiveInstantiator.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 887b9402802200442a948c9dfe309cc3 3 | timeCreated: 1474944360 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/Fractal/Scripts/Rotation.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Rotation : MonoBehaviour { 5 | 6 | public float angle = 30; 7 | 8 | public void Generated(RecursiveBundle bundle) 9 | { 10 | this.transform.rotation *= Quaternion.Euler(angle * ((bundle.Index * 2) - 1), 0, 0); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts/Rotation.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b0dd6bf6954809448114975663d9e34 3 | timeCreated: 1474946218 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/Fractal/Scripts/Scale.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class Scale : MonoBehaviour { 5 | public float scalar = 0.5f; 6 | 7 | public void Generated(RecursiveBundle bundle) 8 | { 9 | this.transform.localScale *= scalar; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Assets/Fractal/Scripts/Scale.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a167258f6e617234db07afb15acc00a7 3 | timeCreated: 1474946534 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/Fractal/Shaders.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 68b14e325e6d7aa4580f3ddef2747f99 3 | folderAsset: yes 4 | timeCreated: 1475190000 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Fractal/Shaders/Julia.shader: -------------------------------------------------------------------------------- 1 | Shader "Fractal/Julia" { 2 | Properties{ 3 | _Seed("Seed", Vector) = (0.5, 0.5, 0.5, 0.5) 4 | _MainTex("Albedo (RGB)", 2D) = "white" {} 5 | _Zoom("Zoom", Vector) = (1,1,1,1) 6 | _Pan("Pan", Vector) = (0,0,0,0) 7 | _Aspect("Aspect Ratio", Float) = 1 8 | _Iterations("Iterations", Range(1,256)) = 128 9 | } 10 | SubShader{ 11 | Tags{ "RenderType" = "Opaque" } 12 | LOD 200 13 | 14 | CGPROGRAM 15 | // Physically based Standard lighting model, and enable shadows on all light types 16 | #pragma surface surf Standard fullforwardshadows 17 | 18 | // Use shader model 3.0 target, to get nicer looking lighting 19 | #pragma target 3.0 20 | 21 | sampler2D _MainTex; 22 | 23 | struct Input { 24 | float2 uv_MainTex; 25 | }; 26 | 27 | float4 _Seed; 28 | float4 _Zoom; 29 | float4 _Pan; 30 | float _Iterations; 31 | float _Aspect; 32 | 33 | void surf(Input IN, inout SurfaceOutputStandard o) { 34 | // Albedo comes from a texture tinted by color 35 | //fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 36 | 37 | float2 c = _Seed; 38 | float2 v = (IN.uv_MainTex - 0.5) * _Zoom.xy * float2(1, _Aspect) - _Pan.xy; 39 | float m = 0; 40 | const float r = 5; 41 | 42 | for (int n = 0; n < _Iterations; ++n) { 43 | v = float2(v.x * v.x - v.y * v.y, v.x * v.y * 2) + c; 44 | 45 | if (dot(v, v) < (r * r - 1)) 46 | { 47 | m++; 48 | } 49 | 50 | v = clamp(v, -r, r); 51 | } 52 | 53 | float4 color; 54 | if (m == floor(_Iterations)) { 55 | color = float4(0,0,0,1); 56 | } 57 | else { 58 | color = float4(sin(m / 4), sin(m / 5), sin(m / 7), 1) / 4 + 0.75; 59 | } 60 | 61 | o.Albedo = color; 62 | //o.Emission = color; 63 | // Metallic and smoothness come from slider variables 64 | o.Alpha = color.a; 65 | } 66 | ENDCG 67 | } 68 | FallBack "Diffuse" 69 | } 70 | -------------------------------------------------------------------------------- /Assets/Fractal/Shaders/Julia.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e50ae727533f54345a8860d8e99422b8 3 | timeCreated: 1475191227 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Fractal/Shaders/Mandelbrot.shader: -------------------------------------------------------------------------------- 1 | Shader "Fractal/Mandelbrot" { 2 | Properties { 3 | _MainTex ("Albedo (RGB)", 2D) = "white" {} 4 | _Zoom ("Zoom", Vector) = (1,1,1,1) 5 | _Pan ("Pan", Vector) = (0,0,0,0) 6 | _Aspect ("Aspect Ratio", Float) = 1 7 | _Iterations ("Iterations", Range(1,256)) = 128 8 | } 9 | SubShader { 10 | Tags { "RenderType"="Opaque" } 11 | LOD 200 12 | 13 | CGPROGRAM 14 | // Physically based Standard lighting model, and enable shadows on all light types 15 | #pragma surface surf Standard fullforwardshadows 16 | 17 | // Use shader model 3.0 target, to get nicer looking lighting 18 | #pragma target 3.0 19 | 20 | sampler2D _MainTex; 21 | 22 | struct Input { 23 | float2 uv_MainTex; 24 | }; 25 | 26 | float4 _Zoom; 27 | float4 _Pan; 28 | float _Iterations; 29 | float _Aspect; 30 | 31 | void surf (Input IN, inout SurfaceOutputStandard o) { 32 | // Albedo comes from a texture tinted by color 33 | //fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; 34 | 35 | float2 c = (IN.uv_MainTex - 0.5) * _Zoom.xy * float2(1, _Aspect) - _Pan.xy; 36 | float2 v = 0; 37 | float m = 0; 38 | const float r = 5; 39 | 40 | for (int n = 0; n < _Iterations; ++n) { 41 | v = float2(v.x * v.x - v.y * v.y, v.x * v.y * 2) + c; 42 | 43 | if (dot(v, v) < (r * r - 1)) 44 | { 45 | m++; 46 | } 47 | 48 | v = clamp(v, -r, r); 49 | } 50 | 51 | float4 color; 52 | if (m == floor(_Iterations)) { 53 | color = float4(0,0,0,1); 54 | } else { 55 | color = float4(sin(m / 4), sin(m / 5), sin(m / 7), 1) / 4 + 0.75; 56 | } 57 | 58 | o.Albedo = color; 59 | //o.Emission = color; 60 | // Metallic and smoothness come from slider variables 61 | o.Alpha = color.a; 62 | } 63 | ENDCG 64 | } 65 | FallBack "Diffuse" 66 | } 67 | -------------------------------------------------------------------------------- /Assets/Fractal/Shaders/Mandelbrot.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a7c2b80587b4164fa4f698e4caf3d2e 3 | timeCreated: 1475190018 4 | licenseType: Pro 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6558df050c3791f43aa825e5a625d60d 3 | folderAsset: yes 4 | timeCreated: 1448959325 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0755a2659a5ae8641aad257bcb3ea630 3 | folderAsset: yes 4 | timeCreated: 1448959325 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AmbientOcclusion.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ed6d7947a564a4dd1987f60392be4349 3 | folderAsset: yes 4 | timeCreated: 1457326591 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AmbientOcclusion/AmbientOcclusion.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e89654dcf6db746d2a57aeaaa14f5e83 3 | timeCreated: 1457327177 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _aoShader: {fileID: 4800000, guid: 65e203e5acda447acbf9dc1ef78c4a39, type: 3} 9 | - _quadMesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} 10 | executionOrder: 0 11 | icon: {instanceID: 0} 12 | userData: 13 | assetBundleName: 14 | assetBundleVariant: 15 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AmbientOcclusion/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c1589efc0706e448d9a0af709e2c99cc 3 | folderAsset: yes 4 | timeCreated: 1457326964 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AmbientOcclusion/Editor/AmbientOcclusionEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | namespace UnityStandardAssets.CinematicEffects 5 | { 6 | [CanEditMultipleObjects] 7 | [CustomEditor(typeof(AmbientOcclusion))] 8 | public class AmbientOcclusionEditor : Editor 9 | { 10 | SerializedProperty _intensity; 11 | SerializedProperty _radius; 12 | SerializedProperty _sampleCount; 13 | SerializedProperty _sampleCountValue; 14 | SerializedProperty _downsampling; 15 | SerializedProperty _occlusionSource; 16 | SerializedProperty _ambientOnly; 17 | SerializedProperty _debug; 18 | 19 | static GUIContent _textValue = new GUIContent("Value"); 20 | 21 | static string _textNoGBuffer = 22 | "G-buffer is currently unavailable. " + 23 | "Change Renderring Path in camera settings to Deferred."; 24 | 25 | static string _textNoAmbientOnly = 26 | "The ambient-only mode is currently disabled; " + 27 | "it requires G-buffer source and HDR rendering."; 28 | 29 | static string _textGBufferNote = 30 | "Forward opaque objects don't go in the G-buffer. " + 31 | "This may lead to artifacts."; 32 | 33 | void OnEnable() 34 | { 35 | _intensity = serializedObject.FindProperty("settings.intensity"); 36 | _radius = serializedObject.FindProperty("settings.radius"); 37 | _sampleCount = serializedObject.FindProperty("settings.sampleCount"); 38 | _sampleCountValue = serializedObject.FindProperty("settings.sampleCountValue"); 39 | _downsampling = serializedObject.FindProperty("settings.downsampling"); 40 | _occlusionSource = serializedObject.FindProperty("settings.occlusionSource"); 41 | _ambientOnly = serializedObject.FindProperty("settings.ambientOnly"); 42 | _debug = serializedObject.FindProperty("settings.debug"); 43 | } 44 | 45 | public override void OnInspectorGUI() 46 | { 47 | var targetInstance = (AmbientOcclusion)target; 48 | 49 | serializedObject.Update(); 50 | 51 | EditorGUILayout.PropertyField(_intensity); 52 | EditorGUILayout.PropertyField(_radius); 53 | EditorGUILayout.PropertyField(_sampleCount); 54 | 55 | if (_sampleCount.hasMultipleDifferentValues || 56 | _sampleCount.enumValueIndex == (int)AmbientOcclusion.SampleCount.Variable) 57 | { 58 | EditorGUI.indentLevel++; 59 | EditorGUILayout.PropertyField(_sampleCountValue, _textValue); 60 | EditorGUI.indentLevel--; 61 | } 62 | 63 | EditorGUILayout.PropertyField(_downsampling); 64 | EditorGUILayout.PropertyField(_occlusionSource); 65 | 66 | if (!_occlusionSource.hasMultipleDifferentValues && 67 | _occlusionSource.enumValueIndex == (int)AmbientOcclusion.OcclusionSource.GBuffer) 68 | { 69 | if (!targetInstance.isGBufferAvailable) 70 | EditorGUILayout.HelpBox(_textNoGBuffer, MessageType.Warning); 71 | else if (!_ambientOnly.hasMultipleDifferentValues && !_ambientOnly.boolValue) 72 | EditorGUILayout.HelpBox(_textGBufferNote, MessageType.Info); 73 | } 74 | 75 | EditorGUILayout.PropertyField(_ambientOnly); 76 | 77 | if (!_ambientOnly.hasMultipleDifferentValues && 78 | _ambientOnly.boolValue && 79 | !targetInstance.isAmbientOnlySupported) 80 | { 81 | EditorGUILayout.HelpBox(_textNoAmbientOnly, MessageType.Warning); 82 | } 83 | 84 | EditorGUILayout.PropertyField(_debug); 85 | 86 | serializedObject.ApplyModifiedProperties(); 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AmbientOcclusion/Editor/AmbientOcclusionEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05ea8e27ed8e74e67a9220b4f4119e51 3 | timeCreated: 1457327141 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/Standard Assets/Effects/AmbientOcclusion/Helpers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d775599023574a39befabe47bdfddde 3 | folderAsset: yes 4 | timeCreated: 1457326936 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AmbientOcclusion/Helpers/PropertyObserver.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityStandardAssets.CinematicEffects 4 | { 5 | public partial class AmbientOcclusion : MonoBehaviour 6 | { 7 | // Observer class that detects changes on properties 8 | struct PropertyObserver 9 | { 10 | // AO properties 11 | bool _downsampling; 12 | OcclusionSource _occlusionSource; 13 | bool _ambientOnly; 14 | bool _debug; 15 | 16 | // Camera properties 17 | int _pixelWidth; 18 | int _pixelHeight; 19 | 20 | // Check if it has to reset itself for property changes. 21 | public bool CheckNeedsReset(Settings setting, Camera camera) 22 | { 23 | return 24 | _downsampling != setting.downsampling || 25 | _occlusionSource != setting.occlusionSource || 26 | _ambientOnly != setting.ambientOnly || 27 | _debug != setting.debug || 28 | _pixelWidth != camera.pixelWidth || 29 | _pixelHeight != camera.pixelHeight; 30 | } 31 | 32 | // Update the internal state. 33 | public void Update(Settings setting, Camera camera) 34 | { 35 | _downsampling = setting.downsampling; 36 | _occlusionSource = setting.occlusionSource; 37 | _ambientOnly = setting.ambientOnly; 38 | _debug = setting.debug; 39 | _pixelWidth = camera.pixelWidth; 40 | _pixelHeight = camera.pixelHeight; 41 | } 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AmbientOcclusion/Helpers/PropertyObserver.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1d9548d9a173a40e4b758ecf6e4fed49 3 | timeCreated: 1457326885 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/Standard Assets/Effects/AmbientOcclusion/Helpers/Settings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.CinematicEffects 5 | { 6 | public partial class AmbientOcclusion : MonoBehaviour 7 | { 8 | /// Values for Settings.sampleCount, determining the number of sample points. 9 | public enum SampleCount 10 | { 11 | Lowest, Low, Medium, High, Variable 12 | } 13 | 14 | /// Values for Settings.occlusionSource, determining the source buffer of occlusion. 15 | public enum OcclusionSource 16 | { 17 | DepthTexture, DepthNormalsTexture, GBuffer 18 | } 19 | 20 | /// Class used for storing settings of AmbientOcclusion. 21 | [Serializable] 22 | public class Settings 23 | { 24 | /// Degree of darkness produced by the effect. 25 | [SerializeField, Range(0, 4)] 26 | [Tooltip("Degree of darkness produced by the effect.")] 27 | public float intensity; 28 | 29 | /// Radius of sample points, which affects extent of darkened areas. 30 | [SerializeField] 31 | [Tooltip("Radius of sample points, which affects extent of darkened areas.")] 32 | public float radius; 33 | 34 | /// Number of sample points, which affects quality and performance. 35 | [SerializeField] 36 | [Tooltip("Number of sample points, which affects quality and performance.")] 37 | public SampleCount sampleCount; 38 | 39 | /// Determines the sample count when SampleCount.Variable is used. 40 | [SerializeField] 41 | [Tooltip("Determines the sample count when SampleCount.Variable is used.")] 42 | public int sampleCountValue; 43 | 44 | /// Halves the resolution of the effect to increase performance. 45 | [SerializeField] 46 | [Tooltip("Halves the resolution of the effect to increase performance.")] 47 | public bool downsampling; 48 | 49 | /// Enables the ambient-only mode in that the effect only affects 50 | /// ambient lighting. This mode is only available with G-buffer 51 | /// source and HDR rendering. 52 | [SerializeField] 53 | [Tooltip("If checked, the effect only affects ambient lighting.")] 54 | public bool ambientOnly; 55 | 56 | /// Source buffer on which the occlusion estimator is based. 57 | [SerializeField] 58 | [Tooltip("Source buffer on which the occlusion estimator is based.")] 59 | public OcclusionSource occlusionSource; 60 | 61 | /// Displays occlusion for debug purpose. 62 | [SerializeField] 63 | [Tooltip("Displays occlusion for debug purpose.")] 64 | public bool debug; 65 | 66 | /// Returns the default settings. 67 | public static Settings defaultSettings 68 | { 69 | get 70 | { 71 | return new Settings 72 | { 73 | intensity = 1, 74 | radius = 0.3f, 75 | sampleCount = SampleCount.Medium, 76 | sampleCountValue = 24, 77 | downsampling = false, 78 | ambientOnly = false, 79 | occlusionSource = OcclusionSource.DepthNormalsTexture 80 | }; 81 | } 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AmbientOcclusion/Helpers/Settings.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e952a344c72354904a417d27abe6f55e 3 | timeCreated: 1457331804 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/Standard Assets/Effects/AmbientOcclusion/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ae08100d29090452888e1b6a7b5a7170 3 | folderAsset: yes 4 | timeCreated: 1457326958 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AmbientOcclusion/Resources/AmbientOcclusion.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7bbc8f354c22e447dbd9deb502530d91 3 | timeCreated: 1463553768 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AmbientOcclusion/Resources/AmbientOcclusion.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Image Effects/Cinematic/AmbientOcclusion" 2 | { 3 | Properties 4 | { 5 | _MainTex("", 2D) = ""{} 6 | _OcclusionTexture("", 2D) = ""{} 7 | } 8 | SubShader 9 | { 10 | // 0: Occlusion estimation with CameraDepthTexture 11 | Pass 12 | { 13 | ZTest Always Cull Off ZWrite Off 14 | CGPROGRAM 15 | #define SOURCE_DEPTH 1 16 | #include "AmbientOcclusion.cginc" 17 | #pragma vertex vert_img 18 | #pragma fragment frag_ao 19 | #pragma target 3.0 20 | ENDCG 21 | } 22 | // 1: Occlusion estimation with CameraDepthNormalsTexture 23 | Pass 24 | { 25 | ZTest Always Cull Off ZWrite Off 26 | CGPROGRAM 27 | #define SOURCE_DEPTHNORMALS 1 28 | #include "AmbientOcclusion.cginc" 29 | #pragma vertex vert_img 30 | #pragma fragment frag_ao 31 | #pragma target 3.0 32 | ENDCG 33 | } 34 | // 2: Occlusion estimation with G-Buffer 35 | Pass 36 | { 37 | ZTest Always Cull Off ZWrite Off 38 | CGPROGRAM 39 | #define SOURCE_GBUFFER 1 40 | #include "AmbientOcclusion.cginc" 41 | #pragma vertex vert_img 42 | #pragma fragment frag_ao 43 | #pragma target 3.0 44 | ENDCG 45 | } 46 | // 3: Noise reduction (first pass) with CameraDepthNormalsTexture 47 | Pass 48 | { 49 | ZTest Always Cull Off ZWrite Off 50 | CGPROGRAM 51 | #define SOURCE_DEPTHNORMALS 1 52 | #include "AmbientOcclusion.cginc" 53 | #pragma vertex vert_img 54 | #pragma fragment frag_blur1 55 | #pragma target 3.0 56 | ENDCG 57 | } 58 | // 4: Noise reduction (first pass) with G Buffer 59 | Pass 60 | { 61 | ZTest Always Cull Off ZWrite Off 62 | CGPROGRAM 63 | #define SOURCE_GBUFFER 1 64 | #include "AmbientOcclusion.cginc" 65 | #pragma vertex vert_img 66 | #pragma fragment frag_blur1 67 | #pragma target 3.0 68 | ENDCG 69 | } 70 | // 5: Noise reduction (second pass) with CameraDepthNormalsTexture 71 | Pass 72 | { 73 | ZTest Always Cull Off ZWrite Off 74 | CGPROGRAM 75 | #define SOURCE_DEPTHNORMALS 1 76 | #include "AmbientOcclusion.cginc" 77 | #pragma vertex vert_img 78 | #pragma fragment frag_blur2 79 | #pragma target 3.0 80 | ENDCG 81 | } 82 | // 6: Noise reduction (second pass) with G Buffer 83 | Pass 84 | { 85 | ZTest Always Cull Off ZWrite Off 86 | CGPROGRAM 87 | #define SOURCE_GBUFFER 1 88 | #include "AmbientOcclusion.cginc" 89 | #pragma vertex vert_img 90 | #pragma fragment frag_blur2 91 | #pragma target 3.0 92 | ENDCG 93 | } 94 | // 7: Occlusion combiner 95 | Pass 96 | { 97 | ZTest Always Cull Off ZWrite Off 98 | CGPROGRAM 99 | #include "AmbientOcclusion.cginc" 100 | #pragma vertex vert_multitex 101 | #pragma fragment frag_combine 102 | #pragma target 3.0 103 | ENDCG 104 | } 105 | // 8: Occlusion combiner for the ambient-only mode 106 | Pass 107 | { 108 | Blend Zero OneMinusSrcColor, Zero OneMinusSrcAlpha 109 | ZTest Always Cull Off ZWrite Off 110 | CGPROGRAM 111 | #include "AmbientOcclusion.cginc" 112 | #pragma vertex vert_gbuffer 113 | #pragma fragment frag_gbuffer_combine 114 | #pragma target 3.0 115 | ENDCG 116 | } 117 | // 9: Debug blit 118 | Pass 119 | { 120 | ZTest Always Cull Off ZWrite Off 121 | CGPROGRAM 122 | #include "AmbientOcclusion.cginc" 123 | #pragma vertex vert_multitex 124 | #pragma fragment frag_blit_ao 125 | #pragma target 3.0 126 | ENDCG 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AmbientOcclusion/Resources/AmbientOcclusion.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 65e203e5acda447acbf9dc1ef78c4a39 3 | timeCreated: 1457327141 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4b15f777774297b4f91455d3353a0c40 3 | folderAsset: yes 4 | timeCreated: 1454589502 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/AntiAliasing.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityStandardAssets.CinematicEffects 4 | { 5 | [ExecuteInEditMode] 6 | [RequireComponent(typeof(Camera))] 7 | [AddComponentMenu("Image Effects/Anti-aliasing")] 8 | #if UNITY_5_4_OR_NEWER 9 | [ImageEffectAllowedInSceneView] 10 | #endif 11 | public class AntiAliasing : MonoBehaviour 12 | { 13 | public enum Method 14 | { 15 | Smaa, 16 | Fxaa 17 | } 18 | 19 | [SerializeField] 20 | private SMAA m_SMAA = new SMAA(); 21 | 22 | [SerializeField] 23 | private FXAA m_FXAA = new FXAA(); 24 | 25 | [SerializeField, HideInInspector] 26 | private int m_Method = (int)Method.Smaa; 27 | public int method 28 | { 29 | get { return m_Method; } 30 | 31 | set 32 | { 33 | if (m_Method == value) 34 | return; 35 | 36 | m_Method = value; 37 | } 38 | } 39 | 40 | public IAntiAliasing current 41 | { 42 | get 43 | { 44 | if (method == (int)Method.Smaa) 45 | return m_SMAA; 46 | else 47 | return m_FXAA; 48 | } 49 | } 50 | 51 | private Camera m_Camera; 52 | public Camera cameraComponent 53 | { 54 | get 55 | { 56 | if (m_Camera == null) 57 | m_Camera = GetComponent(); 58 | 59 | return m_Camera; 60 | } 61 | } 62 | 63 | private void OnEnable() 64 | { 65 | m_SMAA.OnEnable(this); 66 | m_FXAA.OnEnable(this); 67 | } 68 | 69 | private void OnDisable() 70 | { 71 | m_SMAA.OnDisable(); 72 | m_FXAA.OnDisable(); 73 | } 74 | 75 | private void OnPreCull() 76 | { 77 | current.OnPreCull(cameraComponent); 78 | } 79 | 80 | private void OnPostRender() 81 | { 82 | current.OnPostRender(cameraComponent); 83 | } 84 | 85 | private void OnRenderImage(RenderTexture source, RenderTexture destination) 86 | { 87 | current.OnRenderImage(cameraComponent, source, destination); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/AntiAliasing.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fdc35e0180670ab4e8d2f9439137791f 3 | timeCreated: 1454589503 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/Standard Assets/Effects/AntiAliasing/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 738f82ccf57b5974cb672f8032c72169 3 | folderAsset: yes 4 | timeCreated: 1454595975 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/Editor/AntiAliasingEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEditor; 3 | 4 | namespace UnityStandardAssets.CinematicEffects 5 | { 6 | [CustomEditor(typeof(AntiAliasing))] 7 | public class AntiAliasingEditor : Editor 8 | { 9 | private string[] methodNames = 10 | { 11 | "Subpixel Morphological Anti-aliasing", 12 | "Fast Approximate Anti-aliasing" 13 | }; 14 | 15 | private int m_SelectedMethod; 16 | 17 | private SMAAEditor m_SMAAEditor = new SMAAEditor(); 18 | private FXAAEditor m_FXAAEditor = new FXAAEditor(); 19 | 20 | IAntiAliasingEditor m_AntiAliasingEditor; 21 | 22 | private void OnEnable() 23 | { 24 | m_SMAAEditor.OnEnable(serializedObject, "m_SMAA"); 25 | m_FXAAEditor.OnEnable(serializedObject, "m_FXAA"); 26 | } 27 | 28 | public override void OnInspectorGUI() 29 | { 30 | var antiAliasingTarget = (AntiAliasing)target; 31 | 32 | m_SelectedMethod = antiAliasingTarget.method; 33 | 34 | EditorGUI.BeginChangeCheck(); 35 | m_SelectedMethod = EditorGUILayout.Popup("Method", m_SelectedMethod, methodNames); 36 | 37 | bool dirty = false; 38 | 39 | if (EditorGUI.EndChangeCheck()) 40 | { 41 | if (m_SelectedMethod < 0) 42 | m_SelectedMethod = 0; 43 | else if (m_SelectedMethod > 1) 44 | m_SelectedMethod = 1; 45 | 46 | antiAliasingTarget.method = m_SelectedMethod; 47 | dirty = true; 48 | } 49 | 50 | if (m_SelectedMethod == 0) 51 | m_AntiAliasingEditor = m_SMAAEditor; 52 | else 53 | m_AntiAliasingEditor = m_FXAAEditor; 54 | 55 | dirty |= m_AntiAliasingEditor.OnInspectorGUI(antiAliasingTarget.current); 56 | 57 | if (dirty) 58 | { 59 | EditorUtility.SetDirty(antiAliasingTarget); 60 | serializedObject.ApplyModifiedProperties(); 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/Editor/AntiAliasingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6bd9375ab74a65448b556b0452e8c6af 3 | timeCreated: 1454593885 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/Standard Assets/Effects/AntiAliasing/Editor/IAntiAliasingEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UnityStandardAssets.CinematicEffects 4 | { 5 | public interface IAntiAliasingEditor 6 | { 7 | void OnEnable(SerializedObject serializedObject, string path); 8 | bool OnInspectorGUI(IAntiAliasing target); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/Editor/IAntiAliasingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 015ee83e537e9e4438f403e2149c69ae 3 | timeCreated: 1454595240 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/Standard Assets/Effects/AntiAliasing/FXAA.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7629f5693f26f34448aa9c713d257e26 3 | folderAsset: yes 4 | timeCreated: 1453733554 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/FXAA/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 880813d23951c624d9d5c3e6d2a4e93c 3 | folderAsset: yes 4 | timeCreated: 1454331861 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/FXAA/Editor/FXAAEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | 3 | namespace UnityStandardAssets.CinematicEffects 4 | { 5 | public class FXAAEditor : IAntiAliasingEditor 6 | { 7 | private string[] presetNames = 8 | { 9 | "Extreme performance", 10 | "Performance", 11 | "Default", 12 | "Quality", 13 | "Extreme quality" 14 | }; 15 | 16 | 17 | public void OnEnable(SerializedObject serializedObject, string path) 18 | { 19 | } 20 | 21 | public bool OnInspectorGUI(IAntiAliasing target) 22 | { 23 | var fxaaTarget = (FXAA)target; 24 | 25 | if (!fxaaTarget.validSourceFormat) 26 | EditorGUILayout.HelpBox("FXAA should be used at the end of the post-processing stack after conversion to LDR (after Tonemapping) to maximize quality and avoid artifacts.", MessageType.Warning); 27 | 28 | int selectedPreset = 2; 29 | 30 | if (fxaaTarget.preset.Equals(FXAA.Preset.extremePerformancePreset)) 31 | selectedPreset = 0; 32 | else if (fxaaTarget.preset.Equals(FXAA.Preset.performancePreset)) 33 | selectedPreset = 1; 34 | else if (fxaaTarget.preset.Equals(FXAA.Preset.defaultPreset)) 35 | selectedPreset = 2; 36 | else if (fxaaTarget.preset.Equals(FXAA.Preset.qualityPreset)) 37 | selectedPreset = 3; 38 | else if (fxaaTarget.preset.Equals(FXAA.Preset.extremeQualityPreset)) 39 | selectedPreset = 4; 40 | 41 | EditorGUI.BeginChangeCheck(); 42 | selectedPreset = EditorGUILayout.Popup("Preset", selectedPreset, presetNames); 43 | 44 | if (EditorGUI.EndChangeCheck()) 45 | { 46 | if (selectedPreset < 0) 47 | selectedPreset = 0; 48 | else if (selectedPreset > 4) 49 | selectedPreset = 4; 50 | 51 | fxaaTarget.preset = FXAA.availablePresets[selectedPreset]; 52 | return true; 53 | } 54 | return false; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/FXAA/Editor/FXAAEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 60bfb637c85e3e04ea76962349fee327 3 | timeCreated: 1454331861 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/Standard Assets/Effects/AntiAliasing/FXAA/FXAA.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System; 3 | 4 | using Object = UnityEngine.Object; 5 | 6 | namespace UnityStandardAssets.CinematicEffects 7 | { 8 | [Serializable] 9 | public class FXAA : IAntiAliasing 10 | { 11 | private Shader m_Shader; 12 | private Shader shader 13 | { 14 | get 15 | { 16 | if (m_Shader == null) 17 | m_Shader = Shader.Find("Hidden/Fast Approximate Anti-aliasing"); 18 | 19 | return m_Shader; 20 | } 21 | } 22 | 23 | private Material m_Material; 24 | public Material material 25 | { 26 | get 27 | { 28 | if (m_Material == null) 29 | m_Material = ImageEffectHelper.CheckShaderAndCreateMaterial(shader); 30 | 31 | return m_Material; 32 | } 33 | } 34 | 35 | [Serializable] 36 | public struct QualitySettings 37 | { 38 | [Tooltip("The amount of desired sub-pixel aliasing removal. Effects the sharpeness of the output.")] 39 | [Range(0.0f, 1.0f)] 40 | public float subpixelAliasingRemovalAmount; 41 | 42 | [Tooltip("The minimum amount of local contrast required to qualify a region as containing an edge.")] 43 | [Range(0.063f, 0.333f)] 44 | public float edgeDetectionThreshold; 45 | 46 | [Tooltip("Local contrast adaptation value to disallow the algorithm from executing on the darker regions.")] 47 | [Range(0.0f, 0.0833f)] 48 | public float minimumRequiredLuminance; 49 | } 50 | 51 | [Serializable] 52 | public struct ConsoleSettings 53 | { 54 | [Tooltip("The amount of spread applied to the sampling coordinates while sampling for subpixel information.")] 55 | [Range(0.33f, 0.5f)] 56 | public float subpixelSpreadAmount; 57 | 58 | [Tooltip("This value dictates how sharp the edges in the image are kept; a higher value implies sharper edges.")] 59 | [Range(2.0f, 8.0f)] 60 | public float edgeSharpnessAmount; 61 | 62 | [Tooltip("The minimum amount of local contrast required to qualify a region as containing an edge.")] 63 | [Range(0.125f, 0.25f)] 64 | public float edgeDetectionThreshold; 65 | 66 | [Tooltip("Local contrast adaptation value to disallow the algorithm from executing on the darker regions.")] 67 | [Range(0.04f, 0.06f)] 68 | public float minimumRequiredLuminance; 69 | } 70 | 71 | [Serializable] 72 | public struct Preset 73 | { 74 | [AttributeUsage(AttributeTargets.Field)] 75 | public class LayoutAttribute : PropertyAttribute 76 | {} 77 | 78 | [Layout] 79 | public QualitySettings qualitySettings; 80 | 81 | [Layout] 82 | public ConsoleSettings consoleSettings; 83 | 84 | private static readonly Preset s_ExtremePerformance = new Preset 85 | { 86 | qualitySettings = new QualitySettings 87 | { 88 | subpixelAliasingRemovalAmount = 0.0f, 89 | edgeDetectionThreshold = 0.333f, 90 | minimumRequiredLuminance = 0.0833f 91 | }, 92 | 93 | consoleSettings = new ConsoleSettings 94 | { 95 | subpixelSpreadAmount = 0.33f, 96 | edgeSharpnessAmount = 8.0f, 97 | edgeDetectionThreshold = 0.25f, 98 | minimumRequiredLuminance = 0.06f 99 | } 100 | }; 101 | 102 | private static readonly Preset s_Performance = new Preset 103 | { 104 | qualitySettings = new QualitySettings 105 | { 106 | subpixelAliasingRemovalAmount = 0.25f, 107 | edgeDetectionThreshold = 0.25f, 108 | minimumRequiredLuminance = 0.0833f 109 | }, 110 | 111 | consoleSettings = new ConsoleSettings 112 | { 113 | subpixelSpreadAmount = 0.33f, 114 | edgeSharpnessAmount = 8.0f, 115 | edgeDetectionThreshold = 0.125f, 116 | minimumRequiredLuminance = 0.06f 117 | } 118 | }; 119 | 120 | private static readonly Preset s_Default = new Preset 121 | { 122 | qualitySettings = new QualitySettings 123 | { 124 | subpixelAliasingRemovalAmount = 0.75f, 125 | edgeDetectionThreshold = 0.166f, 126 | minimumRequiredLuminance = 0.0833f 127 | }, 128 | 129 | consoleSettings = new ConsoleSettings 130 | { 131 | subpixelSpreadAmount = 0.5f, 132 | edgeSharpnessAmount = 8.0f, 133 | edgeDetectionThreshold = 0.125f, 134 | minimumRequiredLuminance = 0.05f 135 | } 136 | }; 137 | 138 | private static readonly Preset s_Quality = new Preset 139 | { 140 | qualitySettings = new QualitySettings 141 | { 142 | subpixelAliasingRemovalAmount = 1.0f, 143 | edgeDetectionThreshold = 0.125f, 144 | minimumRequiredLuminance = 0.0625f 145 | }, 146 | 147 | consoleSettings = new ConsoleSettings 148 | { 149 | subpixelSpreadAmount = 0.5f, 150 | edgeSharpnessAmount = 4.0f, 151 | edgeDetectionThreshold = 0.125f, 152 | minimumRequiredLuminance = 0.04f 153 | } 154 | }; 155 | 156 | private static readonly Preset s_ExtremeQuality = new Preset 157 | { 158 | qualitySettings = new QualitySettings 159 | { 160 | subpixelAliasingRemovalAmount = 1.0f, 161 | edgeDetectionThreshold = 0.063f, 162 | minimumRequiredLuminance = 0.0312f 163 | }, 164 | 165 | consoleSettings = new ConsoleSettings 166 | { 167 | subpixelSpreadAmount = 0.5f, 168 | edgeSharpnessAmount = 2.0f, 169 | edgeDetectionThreshold = 0.125f, 170 | minimumRequiredLuminance = 0.04f 171 | } 172 | }; 173 | 174 | public static Preset extremePerformancePreset 175 | { 176 | get { return s_ExtremePerformance; } 177 | } 178 | 179 | public static Preset performancePreset 180 | { 181 | get { return s_Performance; } 182 | } 183 | 184 | public static Preset defaultPreset 185 | { 186 | get { return s_Default; } 187 | } 188 | 189 | public static Preset qualityPreset 190 | { 191 | get { return s_Quality; } 192 | } 193 | 194 | public static Preset extremeQualityPreset 195 | { 196 | get { return s_ExtremeQuality; } 197 | } 198 | } 199 | 200 | [SerializeField, HideInInspector] 201 | public Preset preset = Preset.defaultPreset; 202 | 203 | public static Preset[] availablePresets = 204 | { 205 | Preset.extremePerformancePreset, 206 | Preset.performancePreset, 207 | Preset.defaultPreset, 208 | Preset.qualityPreset, 209 | Preset.extremeQualityPreset 210 | }; 211 | 212 | public bool validSourceFormat { get; private set; } 213 | 214 | public void OnEnable(AntiAliasing owner) 215 | { 216 | if (!ImageEffectHelper.IsSupported(shader, true, false, owner)) 217 | owner.enabled = false; 218 | } 219 | 220 | public void OnDisable() 221 | { 222 | if (m_Material != null) 223 | Object.DestroyImmediate(m_Material); 224 | } 225 | 226 | public void OnPreCull(Camera camera) 227 | { 228 | } 229 | 230 | public void OnPostRender(Camera camera) 231 | { 232 | } 233 | 234 | public void OnRenderImage(Camera camera, RenderTexture source, RenderTexture destination) 235 | { 236 | #if UNITY_EDITOR 237 | validSourceFormat = true; 238 | 239 | if (source.format == RenderTextureFormat.ARGBHalf 240 | || source.format == RenderTextureFormat.ARGBFloat 241 | || source.format == RenderTextureFormat.ARGB2101010) 242 | validSourceFormat = false; 243 | #endif 244 | 245 | material.SetVector("_QualitySettings", new Vector3(preset.qualitySettings.subpixelAliasingRemovalAmount, 246 | preset.qualitySettings.edgeDetectionThreshold, preset.qualitySettings.minimumRequiredLuminance)); 247 | 248 | material.SetVector("_ConsoleSettings", new Vector4(preset.consoleSettings.subpixelSpreadAmount, 249 | preset.consoleSettings.edgeSharpnessAmount, preset.consoleSettings.edgeDetectionThreshold, 250 | preset.consoleSettings.minimumRequiredLuminance)); 251 | 252 | Graphics.Blit(source, destination, material, 0); 253 | } 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/FXAA/FXAA.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8ca0fe85db4ef594fb0771b250c00e23 3 | timeCreated: 1453738651 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - shader: {fileID: 4800000, guid: 3eaaee164ee0fed4d9a0bbe8434805a6, type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/FXAA/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3f7cc4a9005f5f846957997471c28f2b 3 | folderAsset: yes 4 | timeCreated: 1455022968 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/FXAA/Resources/FXAA.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Fast Approximate Anti-aliasing" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Texture", 2D) = "white" {} 6 | } 7 | 8 | CGINCLUDE 9 | #pragma fragmentoption ARB_precision_hint_fastest 10 | 11 | #if defined(SHADER_API_PS3) 12 | #define FXAA_PS3 1 13 | 14 | // Shaves off 2 cycles from the shader 15 | #define FXAA_EARLY_EXIT 0 16 | #elif defined(SHADER_API_XBOX360) 17 | #define FXAA_360 1 18 | 19 | // Shaves off 10ms from the shader's execution time 20 | #define FXAA_EARLY_EXIT 1 21 | #else 22 | #define FXAA_PC 1 23 | #endif 24 | 25 | #define FXAA_HLSL_3 1 26 | #define FXAA_QUALITY__PRESET 39 27 | 28 | #define FXAA_GREEN_AS_LUMA 1 29 | 30 | #pragma target 3.0 31 | #include "FXAA3.cginc" 32 | 33 | float4 _MainTex_TexelSize; 34 | 35 | float3 _QualitySettings; 36 | float4 _ConsoleSettings; 37 | 38 | struct Input 39 | { 40 | float4 position : POSITION; 41 | float2 uv : TEXCOORD0; 42 | }; 43 | 44 | struct Varying 45 | { 46 | float4 position : SV_POSITION; 47 | float2 uv : TEXCOORD0; 48 | }; 49 | 50 | Varying vertex(Input input) 51 | { 52 | Varying output; 53 | 54 | output.position = mul(UNITY_MATRIX_MVP, input.position); 55 | output.uv = input.uv; 56 | 57 | return output; 58 | } 59 | 60 | sampler2D _MainTex; 61 | 62 | float calculateLuma(float4 color) 63 | { 64 | return color.g * 1.963211 + color.r; 65 | } 66 | 67 | fixed4 fragment(Varying input) : SV_Target 68 | { 69 | const float4 consoleUV = input.uv.xyxy + .5 * float4(-_MainTex_TexelSize.xy, _MainTex_TexelSize.xy); 70 | const float4 consoleSubpixelFrame = _ConsoleSettings.x * float4(-1., -1., 1., 1.) * 71 | _MainTex_TexelSize.xyxy; 72 | 73 | const float4 consoleSubpixelFramePS3 = float4(-2., -2., 2., 2.) * _MainTex_TexelSize.xyxy; 74 | const float4 consoleSubpixelFrameXBOX = float4(8., 8., -4., -4.) * _MainTex_TexelSize.xyxy; 75 | 76 | #if defined(SHADER_API_XBOX360) 77 | const float4 consoleConstants = float4(1., -1., .25, -.25); 78 | #else 79 | const float4 consoleConstants = float4(0., 0., 0., 0.); 80 | #endif 81 | 82 | return FxaaPixelShader(input.uv, consoleUV, _MainTex, _MainTex, _MainTex, _MainTex_TexelSize.xy, 83 | consoleSubpixelFrame, consoleSubpixelFramePS3, consoleSubpixelFrameXBOX, 84 | _QualitySettings.x, _QualitySettings.y, _QualitySettings.z, _ConsoleSettings.y, _ConsoleSettings.z, 85 | _ConsoleSettings.w, consoleConstants); 86 | } 87 | ENDCG 88 | 89 | SubShader 90 | { 91 | ZTest Always Cull Off ZWrite Off 92 | Fog { Mode off } 93 | 94 | Pass 95 | { 96 | CGPROGRAM 97 | #pragma vertex vertex 98 | #pragma fragment fragment 99 | 100 | #include "UnityCG.cginc" 101 | ENDCG 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/FXAA/Resources/FXAA.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3eaaee164ee0fed4d9a0bbe8434805a6 3 | timeCreated: 1453736553 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/FXAA/Resources/FXAA3.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b44d2ca11a7157e4db9f1e02f5249f95 3 | timeCreated: 1453990603 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/IAntiAliasing.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace UnityStandardAssets.CinematicEffects 4 | { 5 | public interface IAntiAliasing 6 | { 7 | void OnEnable(AntiAliasing owner); 8 | void OnDisable(); 9 | void OnPreCull(Camera camera); 10 | void OnPostRender(Camera camera); 11 | void OnRenderImage(Camera camera, RenderTexture source, RenderTexture destination); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/IAntiAliasing.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 90329fa7c7a616243a47de84e6e5c041 3 | timeCreated: 1454590083 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/Standard Assets/Effects/AntiAliasing/SMAA.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d958f8498dd28db459dc41b661331fc8 3 | folderAsset: yes 4 | timeCreated: 1446717353 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/SMAA/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3ab9eab0d04085b4abd47b6b0657143c 3 | folderAsset: yes 4 | timeCreated: 1430588699 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/SMAA/Editor/SMAAEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using System.Collections.Generic; 3 | using System; 4 | using System.Linq; 5 | using UnityEngine; 6 | using System.Reflection; 7 | using UnityEngine.Serialization; 8 | 9 | namespace UnityStandardAssets.CinematicEffects 10 | { 11 | public class SMAAEditor : IAntiAliasingEditor 12 | { 13 | private List m_TopLevelFields = new List(); 14 | 15 | [Serializable] 16 | class InfoMap 17 | { 18 | public string name; 19 | public bool experimental; 20 | public bool quality; 21 | public List properties; 22 | } 23 | private List m_GroupFields = new List(); 24 | 25 | public void OnEnable(SerializedObject serializedObject, string path) 26 | { 27 | var topLevelSettings = typeof(SMAA).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Where(x => x.GetCustomAttributes(typeof(SMAA.TopLevelSettings), false).Any()); 28 | var settingsGroups = typeof(SMAA).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Where(x => x.GetCustomAttributes(typeof(SMAA.SettingsGroup), false).Any()); 29 | 30 | foreach (var group in topLevelSettings) 31 | { 32 | var searchPath = path + "." + group.Name + "."; 33 | 34 | foreach (var setting in group.FieldType.GetFields(BindingFlags.Instance | BindingFlags.Public)) 35 | { 36 | var property = serializedObject.FindProperty(searchPath + setting.Name); 37 | if (property != null) 38 | m_TopLevelFields.Add(property); 39 | } 40 | } 41 | 42 | foreach (var group in settingsGroups) 43 | { 44 | var searchPath = path + "." + group.Name + "."; 45 | 46 | foreach (var setting in group.FieldType.GetFields(BindingFlags.Instance | BindingFlags.Public)) 47 | { 48 | var infoGroup = m_GroupFields.FirstOrDefault(x => x.name == group.Name); 49 | if (infoGroup == null) 50 | { 51 | infoGroup = new InfoMap(); 52 | infoGroup.properties = new List(); 53 | infoGroup.name = group.Name; 54 | infoGroup.quality = group.FieldType == typeof(SMAA.QualitySettings); 55 | infoGroup.experimental = group.GetCustomAttributes(typeof(SMAA.ExperimentalGroup), false).Length > 0; 56 | m_GroupFields.Add(infoGroup); 57 | } 58 | 59 | var property = serializedObject.FindProperty(searchPath + setting.Name); 60 | if (property != null) 61 | { 62 | infoGroup.properties.Add(property); 63 | } 64 | } 65 | } 66 | } 67 | 68 | public bool OnInspectorGUI(IAntiAliasing target) 69 | { 70 | EditorGUI.BeginChangeCheck(); 71 | 72 | foreach (var setting in m_TopLevelFields) 73 | EditorGUILayout.PropertyField(setting); 74 | 75 | foreach (var group in m_GroupFields) 76 | { 77 | if (group.quality && (target as SMAA).settings.quality != SMAA.QualityPreset.Custom) 78 | { 79 | continue; 80 | } 81 | 82 | string title = ObjectNames.NicifyVariableName(group.name); 83 | if (group.experimental) 84 | title += " (Experimental)"; 85 | 86 | EditorGUILayout.Space(); 87 | EditorGUILayout.LabelField(title, EditorStyles.boldLabel); 88 | EditorGUI.indentLevel++; 89 | 90 | var enabledField = group.properties.FirstOrDefault(x => x.propertyPath == "m_SMAA." + group.name + ".enabled"); 91 | if (enabledField != null && !enabledField.boolValue) 92 | { 93 | EditorGUILayout.PropertyField(enabledField); 94 | EditorGUI.indentLevel--; 95 | continue; 96 | } 97 | 98 | foreach (var field in group.properties) 99 | EditorGUILayout.PropertyField(field); 100 | 101 | EditorGUI.indentLevel--; 102 | } 103 | return EditorGUI.EndChangeCheck(); 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/SMAA/Editor/SMAAEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5c2ffc06b5a6ee64d8e1d9bdf074732c 3 | timeCreated: 1430643832 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/Standard Assets/Effects/AntiAliasing/SMAA/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9362798305520c448b294dd314a7daff 3 | folderAsset: yes 4 | timeCreated: 1430505545 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/SMAA/Resources/AreaTex.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Standard Assets/Effects/AntiAliasing/SMAA/Resources/AreaTex.tga -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/SMAA/Resources/AreaTex.tga.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e62aa7035ea66c94b90b2d8774d02cca 3 | timeCreated: 1432601000 4 | licenseType: Store 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | linearTexture: 1 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 8 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -3 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: 1 33 | aniso: 0 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 0 37 | lightmap: 0 38 | rGBM: 2 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: 5 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/SMAA/Resources/SMAA.cginc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Standard Assets/Effects/AntiAliasing/SMAA/Resources/SMAA.cginc -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/SMAA/Resources/SMAA.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 74597699f47d8ae458dca68f79f1b21f 3 | timeCreated: 1430504573 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/SMAA/Resources/SMAA.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4505fec7a81214243b8e59edf89e3a53 3 | timeCreated: 1432603500 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/SMAA/Resources/SearchTex.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Standard Assets/Effects/AntiAliasing/SMAA/Resources/SearchTex.tga -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/SMAA/Resources/SearchTex.tga.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 387ed7c38eb63554db846987adb98e68 3 | timeCreated: 1432601000 4 | licenseType: Store 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | linearTexture: 1 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 1 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 8 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: 1 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: 0 33 | aniso: -1 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 0 37 | lightmap: 0 38 | rGBM: 2 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: 5 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/AntiAliasing/SMAA/SMAA.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c2502951f8f3e743917c441eba57d1c 3 | timeCreated: 1454511067 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - m_Shader: {fileID: 4800000, guid: 4505fec7a81214243b8e59edf89e3a53, type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Bloom.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 193f90bb87f484c62ad73788d9cb2d44 3 | folderAsset: yes 4 | timeCreated: 1454052266 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Bloom/Bloom.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.CinematicEffects 5 | { 6 | [ExecuteInEditMode] 7 | [RequireComponent(typeof(Camera))] 8 | [AddComponentMenu("Image Effects/Cinematic/Bloom")] 9 | #if UNITY_5_4_OR_NEWER 10 | [ImageEffectAllowedInSceneView] 11 | #endif 12 | public class Bloom : MonoBehaviour 13 | { 14 | [Serializable] 15 | public struct Settings 16 | { 17 | [SerializeField] 18 | [Tooltip("Filters out pixels under this level of brightness.")] 19 | public float threshold; 20 | 21 | public float thresholdGamma 22 | { 23 | set { threshold = value; } 24 | get { return Mathf.Max(0.0f, threshold); } 25 | } 26 | 27 | public float thresholdLinear 28 | { 29 | set { threshold = Mathf.LinearToGammaSpace(value); } 30 | get { return Mathf.GammaToLinearSpace(thresholdGamma); } 31 | } 32 | 33 | [SerializeField, Range(0, 1)] 34 | [Tooltip("Makes transition between under/over-threshold gradual.")] 35 | public float softKnee; 36 | 37 | [SerializeField, Range(1, 7)] 38 | [Tooltip("Changes extent of veiling effects in a screen resolution-independent fashion.")] 39 | public float radius; 40 | 41 | [SerializeField] 42 | [Tooltip("Blend factor of the result image.")] 43 | public float intensity; 44 | 45 | [SerializeField] 46 | [Tooltip("Controls filter quality and buffer resolution.")] 47 | public bool highQuality; 48 | 49 | [SerializeField] 50 | [Tooltip("Reduces flashing noise with an additional filter.")] 51 | public bool antiFlicker; 52 | 53 | public static Settings defaultSettings 54 | { 55 | get 56 | { 57 | var settings = new Settings 58 | { 59 | threshold = 0.9f, 60 | softKnee = 0.5f, 61 | radius = 2.0f, 62 | intensity = 0.7f, 63 | highQuality = true, 64 | antiFlicker = false 65 | }; 66 | return settings; 67 | } 68 | } 69 | } 70 | 71 | #region Public Properties 72 | 73 | [SerializeField] 74 | public Settings settings = Settings.defaultSettings; 75 | 76 | #endregion 77 | 78 | [SerializeField, HideInInspector] 79 | private Shader m_Shader; 80 | 81 | public Shader shader 82 | { 83 | get 84 | { 85 | if (m_Shader == null) 86 | { 87 | const string shaderName = "Hidden/Image Effects/Cinematic/Bloom"; 88 | m_Shader = Shader.Find(shaderName); 89 | } 90 | 91 | return m_Shader; 92 | } 93 | } 94 | 95 | private Material m_Material; 96 | public Material material 97 | { 98 | get 99 | { 100 | if (m_Material == null) 101 | m_Material = ImageEffectHelper.CheckShaderAndCreateMaterial(shader); 102 | 103 | return m_Material; 104 | } 105 | } 106 | 107 | #region Private Members 108 | 109 | const int kMaxIterations = 16; 110 | RenderTexture[] m_blurBuffer1 = new RenderTexture[kMaxIterations]; 111 | RenderTexture[] m_blurBuffer2 = new RenderTexture[kMaxIterations]; 112 | 113 | private void OnEnable() 114 | { 115 | if (!ImageEffectHelper.IsSupported(shader, true, false, this)) 116 | enabled = false; 117 | } 118 | 119 | private void OnDisable() 120 | { 121 | if (m_Material != null) 122 | DestroyImmediate(m_Material); 123 | 124 | m_Material = null; 125 | } 126 | 127 | private void OnRenderImage(RenderTexture source, RenderTexture destination) 128 | { 129 | var useRGBM = Application.isMobilePlatform; 130 | 131 | // source texture size 132 | var tw = source.width; 133 | var th = source.height; 134 | 135 | // halve the texture size for the low quality mode 136 | if (!settings.highQuality) 137 | { 138 | tw /= 2; 139 | th /= 2; 140 | } 141 | 142 | // blur buffer format 143 | var rtFormat = useRGBM ? RenderTextureFormat.Default : RenderTextureFormat.DefaultHDR; 144 | 145 | // determine the iteration count 146 | var logh = Mathf.Log(th, 2) + settings.radius - 8; 147 | var logh_i = (int)logh; 148 | var iterations = Mathf.Clamp(logh_i, 1, kMaxIterations); 149 | 150 | // update the shader properties 151 | var threshold = settings.thresholdLinear; 152 | material.SetFloat("_Threshold", threshold); 153 | 154 | var knee = threshold * settings.softKnee + 1e-5f; 155 | var curve = new Vector3(threshold - knee, knee * 2, 0.25f / knee); 156 | material.SetVector("_Curve", curve); 157 | 158 | var pfo = !settings.highQuality && settings.antiFlicker; 159 | material.SetFloat("_PrefilterOffs", pfo ? -0.5f : 0.0f); 160 | 161 | material.SetFloat("_SampleScale", 0.5f + logh - logh_i); 162 | material.SetFloat("_Intensity", Mathf.Max(0.0f, settings.intensity)); 163 | 164 | // prefilter pass 165 | var prefiltered = RenderTexture.GetTemporary(tw, th, 0, rtFormat); 166 | Graphics.Blit(source, prefiltered, material, settings.antiFlicker ? 1 : 0); 167 | 168 | // construct a mip pyramid 169 | var last = prefiltered; 170 | for (var level = 0; level < iterations; level++) 171 | { 172 | m_blurBuffer1[level] = RenderTexture.GetTemporary(last.width / 2, last.height / 2, 0, rtFormat); 173 | Graphics.Blit(last, m_blurBuffer1[level], material, level == 0 ? (settings.antiFlicker ? 3 : 2) : 4); 174 | last = m_blurBuffer1[level]; 175 | } 176 | 177 | // upsample and combine loop 178 | for (var level = iterations - 2; level >= 0; level--) 179 | { 180 | var basetex = m_blurBuffer1[level]; 181 | material.SetTexture("_BaseTex", basetex); 182 | m_blurBuffer2[level] = RenderTexture.GetTemporary(basetex.width, basetex.height, 0, rtFormat); 183 | Graphics.Blit(last, m_blurBuffer2[level], material, settings.highQuality ? 6 : 5); 184 | last = m_blurBuffer2[level]; 185 | } 186 | 187 | // finish process 188 | material.SetTexture("_BaseTex", source); 189 | Graphics.Blit(last, destination, material, settings.highQuality ? 8 : 7); 190 | 191 | // release the temporary buffers 192 | for (var i = 0; i < kMaxIterations; i++) 193 | { 194 | if (m_blurBuffer1[i] != null) RenderTexture.ReleaseTemporary(m_blurBuffer1[i]); 195 | if (m_blurBuffer2[i] != null) RenderTexture.ReleaseTemporary(m_blurBuffer2[i]); 196 | m_blurBuffer1[i] = null; 197 | m_blurBuffer2[i] = null; 198 | } 199 | 200 | RenderTexture.ReleaseTemporary(prefiltered); 201 | } 202 | 203 | #endregion 204 | } 205 | } 206 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Bloom/Bloom.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 32187365ced0c42219cde2b57c99b323 3 | timeCreated: 1454052338 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - _shader: {fileID: 4800000, guid: e45d4f28262b04d10a075856ab5fdb5e, type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Bloom/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92a024b1f1430409eb656f65969aa3d5 3 | folderAsset: yes 4 | timeCreated: 1454052266 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Bloom/Editor/BloomEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using UnityEngine; 4 | using UnityEditor; 5 | 6 | namespace UnityStandardAssets.CinematicEffects 7 | { 8 | [CanEditMultipleObjects] 9 | [CustomEditor(typeof(Bloom))] 10 | public class BloomEditor : Editor 11 | { 12 | [NonSerialized] 13 | private List m_Properties = new List(); 14 | 15 | BloomGraphDrawer _graph; 16 | 17 | bool CheckHdr(Bloom target) 18 | { 19 | var camera = target.GetComponent(); 20 | return camera != null && camera.hdr; 21 | } 22 | 23 | void OnEnable() 24 | { 25 | var settings = FieldFinder.GetField(x => x.settings); 26 | foreach (var setting in settings.FieldType.GetFields()) 27 | { 28 | var prop = settings.Name + "." + setting.Name; 29 | m_Properties.Add(serializedObject.FindProperty(prop)); 30 | } 31 | 32 | _graph = new BloomGraphDrawer(); 33 | } 34 | 35 | public override void OnInspectorGUI() 36 | { 37 | serializedObject.Update(); 38 | 39 | if (!serializedObject.isEditingMultipleObjects) 40 | { 41 | EditorGUILayout.Space(); 42 | var bloom = (Bloom)target; 43 | _graph.Prepare(bloom.settings, CheckHdr(bloom)); 44 | _graph.DrawGraph(); 45 | EditorGUILayout.Space(); 46 | } 47 | 48 | foreach (var property in m_Properties) 49 | EditorGUILayout.PropertyField(property); 50 | 51 | serializedObject.ApplyModifiedProperties(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Bloom/Editor/BloomEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 38020a6029a85434a95a6f725a5aae5f 3 | timeCreated: 1454052266 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/Standard Assets/Effects/Bloom/Editor/BloomGraphDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | 4 | namespace UnityStandardAssets.CinematicEffects 5 | { 6 | // Class used for drawing the brightness response curve 7 | public class BloomGraphDrawer 8 | { 9 | #region Public Methods 10 | 11 | // Update internal state from given settings. 12 | public void Prepare(Bloom.Settings settings, bool isHdr) 13 | { 14 | if (isHdr) 15 | { 16 | _rangeX = 6; 17 | _rangeY = 1.5f; 18 | } 19 | else 20 | { 21 | _rangeX = 1; 22 | _rangeY = 1; 23 | } 24 | 25 | _threshold = settings.thresholdLinear; 26 | _knee = settings.softKnee * _threshold + 1e-5f; 27 | 28 | // Intensity is capped to prevent sampling errors. 29 | _intensity = Mathf.Min(settings.intensity, 10); 30 | } 31 | 32 | // Draw the graph at the current position. 33 | public void DrawGraph() 34 | { 35 | _rectGraph = GUILayoutUtility.GetRect(128, 80); 36 | 37 | // Background 38 | DrawRect(0, 0, _rangeX, _rangeY, 0.1f, 0.4f); 39 | 40 | // Soft-knee range 41 | DrawRect(_threshold - _knee, 0, _threshold + _knee, _rangeY, 0.25f, -1); 42 | 43 | // Horizontal lines 44 | for (var i = 1; i < _rangeY; i++) 45 | DrawLine(0, i, _rangeX, i, 0.4f); 46 | 47 | // Vertical lines 48 | for (var i = 1; i < _rangeX; i++) 49 | DrawLine(i, 0, i, _rangeY, 0.4f); 50 | 51 | // Label 52 | Handles.Label( 53 | PointInRect(0, _rangeY) + Vector3.right, 54 | "Brightness Response (linear)", EditorStyles.miniLabel 55 | ); 56 | 57 | // Threshold line 58 | DrawLine(_threshold, 0, _threshold, _rangeY, 0.6f); 59 | 60 | // Response curve 61 | var vcount = 0; 62 | while (vcount < _curveResolution) 63 | { 64 | var x = _rangeX * vcount / (_curveResolution - 1); 65 | var y = ResponseFunction(x); 66 | if (y < _rangeY) 67 | { 68 | _curveVertices[vcount++] = PointInRect(x, y); 69 | } 70 | else 71 | { 72 | if (vcount > 1) 73 | { 74 | // Extend the last segment to the top edge of the rect. 75 | var v1 = _curveVertices[vcount - 2]; 76 | var v2 = _curveVertices[vcount - 1]; 77 | var clip = (_rectGraph.y - v1.y) / (v2.y - v1.y); 78 | _curveVertices[vcount - 1] = v1 + (v2 - v1) * clip; 79 | } 80 | break; 81 | } 82 | } 83 | 84 | if (vcount > 1) 85 | { 86 | Handles.color = Color.white * 0.9f; 87 | Handles.DrawAAPolyLine(2.0f, vcount, _curveVertices); 88 | } 89 | } 90 | 91 | #endregion 92 | 93 | #region Response Function 94 | 95 | float _threshold; 96 | float _knee; 97 | float _intensity; 98 | 99 | float ResponseFunction(float x) 100 | { 101 | var rq = Mathf.Clamp(x - _threshold + _knee, 0, _knee * 2); 102 | rq = rq * rq * 0.25f / _knee; 103 | return Mathf.Max(rq, x - _threshold) * _intensity; 104 | } 105 | 106 | #endregion 107 | 108 | #region Graph Functions 109 | 110 | // Number of vertices in curve 111 | const int _curveResolution = 96; 112 | 113 | // Vertex buffers 114 | Vector3[] _rectVertices = new Vector3[4]; 115 | Vector3[] _lineVertices = new Vector3[2]; 116 | Vector3[] _curveVertices = new Vector3[_curveResolution]; 117 | 118 | Rect _rectGraph; 119 | float _rangeX; 120 | float _rangeY; 121 | 122 | // Transform a point into the graph rect. 123 | Vector3 PointInRect(float x, float y) 124 | { 125 | x = Mathf.Lerp(_rectGraph.x, _rectGraph.xMax, x / _rangeX); 126 | y = Mathf.Lerp(_rectGraph.yMax, _rectGraph.y, y / _rangeY); 127 | return new Vector3(x, y, 0); 128 | } 129 | 130 | // Draw a line in the graph rect. 131 | void DrawLine(float x1, float y1, float x2, float y2, float grayscale) 132 | { 133 | _lineVertices[0] = PointInRect(x1, y1); 134 | _lineVertices[1] = PointInRect(x2, y2); 135 | Handles.color = Color.white * grayscale; 136 | Handles.DrawAAPolyLine(2.0f, _lineVertices); 137 | } 138 | 139 | // Draw a rect in the graph rect. 140 | void DrawRect(float x1, float y1, float x2, float y2, float fill, float line) 141 | { 142 | _rectVertices[0] = PointInRect(x1, y1); 143 | _rectVertices[1] = PointInRect(x2, y1); 144 | _rectVertices[2] = PointInRect(x2, y2); 145 | _rectVertices[3] = PointInRect(x1, y2); 146 | 147 | Handles.DrawSolidRectangleWithOutline( 148 | _rectVertices, 149 | fill < 0 ? Color.clear : Color.white * fill, 150 | line < 0 ? Color.clear : Color.white * line 151 | ); 152 | } 153 | 154 | #endregion 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Bloom/Editor/BloomGraphDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e2d62b6f4e4eb4c6783477b5d99abdff 3 | timeCreated: 1465439082 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/Standard Assets/Effects/Bloom/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4af3202dbe79e460e9be42bcb6509fe0 3 | folderAsset: yes 4 | timeCreated: 1454052266 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Bloom/Resources/Bloom.cginc: -------------------------------------------------------------------------------- 1 | #include "UnityCG.cginc" 2 | 3 | // Mobile: use RGBM instead of float/half RGB 4 | #define USE_RGBM defined(SHADER_API_MOBILE) 5 | 6 | sampler2D _MainTex; 7 | sampler2D _BaseTex; 8 | float2 _MainTex_TexelSize; 9 | float2 _BaseTex_TexelSize; 10 | half4 _MainTex_ST; 11 | half4 _BaseTex_ST; 12 | 13 | float _PrefilterOffs; 14 | half _Threshold; 15 | half3 _Curve; 16 | float _SampleScale; 17 | half _Intensity; 18 | 19 | // Brightness function 20 | half Brightness(half3 c) 21 | { 22 | return max(max(c.r, c.g), c.b); 23 | } 24 | 25 | // 3-tap median filter 26 | half3 Median(half3 a, half3 b, half3 c) 27 | { 28 | return a + b + c - min(min(a, b), c) - max(max(a, b), c); 29 | } 30 | 31 | // Clamp HDR value within a safe range 32 | half3 SafeHDR(half3 c) { return min(c, 65000); } 33 | half4 SafeHDR(half4 c) { return min(c, 65000); } 34 | 35 | // RGBM encoding/decoding 36 | half4 EncodeHDR(float3 rgb) 37 | { 38 | #if USE_RGBM 39 | rgb *= 1.0 / 8; 40 | float m = max(max(rgb.r, rgb.g), max(rgb.b, 1e-6)); 41 | m = ceil(m * 255) / 255; 42 | return half4(rgb / m, m); 43 | #else 44 | return half4(rgb, 0); 45 | #endif 46 | } 47 | 48 | float3 DecodeHDR(half4 rgba) 49 | { 50 | #if USE_RGBM 51 | return rgba.rgb * rgba.a * 8; 52 | #else 53 | return rgba.rgb; 54 | #endif 55 | } 56 | 57 | // Downsample with a 4x4 box filter 58 | half3 DownsampleFilter(float2 uv) 59 | { 60 | float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1); 61 | 62 | half3 s; 63 | s = DecodeHDR(tex2D(_MainTex, uv + d.xy)); 64 | s += DecodeHDR(tex2D(_MainTex, uv + d.zy)); 65 | s += DecodeHDR(tex2D(_MainTex, uv + d.xw)); 66 | s += DecodeHDR(tex2D(_MainTex, uv + d.zw)); 67 | 68 | return s * (1.0 / 4); 69 | } 70 | 71 | // Downsample with a 4x4 box filter + anti-flicker filter 72 | half3 DownsampleAntiFlickerFilter(float2 uv) 73 | { 74 | float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1); 75 | 76 | half3 s1 = DecodeHDR(tex2D(_MainTex, uv + d.xy)); 77 | half3 s2 = DecodeHDR(tex2D(_MainTex, uv + d.zy)); 78 | half3 s3 = DecodeHDR(tex2D(_MainTex, uv + d.xw)); 79 | half3 s4 = DecodeHDR(tex2D(_MainTex, uv + d.zw)); 80 | 81 | // Karis's luma weighted average (using brightness instead of luma) 82 | half s1w = 1 / (Brightness(s1) + 1); 83 | half s2w = 1 / (Brightness(s2) + 1); 84 | half s3w = 1 / (Brightness(s3) + 1); 85 | half s4w = 1 / (Brightness(s4) + 1); 86 | half one_div_wsum = 1 / (s1w + s2w + s3w + s4w); 87 | 88 | return (s1 * s1w + s2 * s2w + s3 * s3w + s4 * s4w) * one_div_wsum; 89 | } 90 | 91 | half3 UpsampleFilter(float2 uv) 92 | { 93 | #if HIGH_QUALITY 94 | // 9-tap bilinear upsampler (tent filter) 95 | float4 d = _MainTex_TexelSize.xyxy * float4(1, 1, -1, 0) * _SampleScale; 96 | 97 | half3 s; 98 | s = DecodeHDR(tex2D(_MainTex, uv - d.xy)); 99 | s += DecodeHDR(tex2D(_MainTex, uv - d.wy)) * 2; 100 | s += DecodeHDR(tex2D(_MainTex, uv - d.zy)); 101 | 102 | s += DecodeHDR(tex2D(_MainTex, uv + d.zw)) * 2; 103 | s += DecodeHDR(tex2D(_MainTex, uv )) * 4; 104 | s += DecodeHDR(tex2D(_MainTex, uv + d.xw)) * 2; 105 | 106 | s += DecodeHDR(tex2D(_MainTex, uv + d.zy)); 107 | s += DecodeHDR(tex2D(_MainTex, uv + d.wy)) * 2; 108 | s += DecodeHDR(tex2D(_MainTex, uv + d.xy)); 109 | 110 | return s * (1.0 / 16); 111 | #else 112 | // 4-tap bilinear upsampler 113 | float4 d = _MainTex_TexelSize.xyxy * float4(-1, -1, +1, +1) * (_SampleScale * 0.5); 114 | 115 | half3 s; 116 | s = DecodeHDR(tex2D(_MainTex, uv + d.xy)); 117 | s += DecodeHDR(tex2D(_MainTex, uv + d.zy)); 118 | s += DecodeHDR(tex2D(_MainTex, uv + d.xw)); 119 | s += DecodeHDR(tex2D(_MainTex, uv + d.zw)); 120 | 121 | return s * (1.0 / 4); 122 | #endif 123 | } 124 | 125 | // 126 | // Vertex shader 127 | // 128 | 129 | v2f_img vert(appdata_img v) 130 | { 131 | v2f_img o; 132 | #if UNITY_VERSION >= 540 133 | o.pos = UnityObjectToClipPos(v.vertex); 134 | o.uv = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST); 135 | #else 136 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 137 | o.uv = v.texcoord; 138 | #endif 139 | return o; 140 | } 141 | 142 | struct v2f_multitex 143 | { 144 | float4 pos : SV_POSITION; 145 | float2 uvMain : TEXCOORD0; 146 | float2 uvBase : TEXCOORD1; 147 | }; 148 | 149 | v2f_multitex vert_multitex(appdata_img v) 150 | { 151 | v2f_multitex o; 152 | #if UNITY_VERSION >= 540 153 | o.pos = UnityObjectToClipPos(v.vertex); 154 | o.uvMain = UnityStereoScreenSpaceUVAdjust(v.texcoord, _MainTex_ST); 155 | o.uvBase = UnityStereoScreenSpaceUVAdjust(v.texcoord, _BaseTex_ST); 156 | #else 157 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 158 | o.uvMain = v.texcoord; 159 | o.uvBase = v.texcoord; 160 | #endif 161 | #if UNITY_UV_STARTS_AT_TOP 162 | if (_BaseTex_TexelSize.y < 0.0) 163 | o.uvBase.y = 1.0 - v.texcoord.y; 164 | #endif 165 | return o; 166 | } 167 | 168 | // 169 | // fragment shader 170 | // 171 | 172 | half4 frag_prefilter(v2f_img i) : SV_Target 173 | { 174 | float2 uv = i.uv + _MainTex_TexelSize.xy * _PrefilterOffs; 175 | 176 | #if ANTI_FLICKER 177 | float3 d = _MainTex_TexelSize.xyx * float3(1, 1, 0); 178 | half4 s0 = SafeHDR(tex2D(_MainTex, uv)); 179 | half3 s1 = SafeHDR(tex2D(_MainTex, uv - d.xz).rgb); 180 | half3 s2 = SafeHDR(tex2D(_MainTex, uv + d.xz).rgb); 181 | half3 s3 = SafeHDR(tex2D(_MainTex, uv - d.zy).rgb); 182 | half3 s4 = SafeHDR(tex2D(_MainTex, uv + d.zy).rgb); 183 | half3 m = Median(Median(s0.rgb, s1, s2), s3, s4); 184 | #else 185 | half4 s0 = SafeHDR(tex2D(_MainTex, uv)); 186 | half3 m = s0.rgb; 187 | #endif 188 | 189 | #if UNITY_COLORSPACE_GAMMA 190 | m = GammaToLinearSpace(m); 191 | #endif 192 | // Pixel brightness 193 | half br = Brightness(m); 194 | 195 | // Under-threshold part: quadratic curve 196 | half rq = clamp(br - _Curve.x, 0, _Curve.y); 197 | rq = _Curve.z * rq * rq; 198 | 199 | // Combine and apply the brightness response curve. 200 | m *= max(rq, br - _Threshold) / max(br, 1e-5); 201 | 202 | return EncodeHDR(m); 203 | } 204 | 205 | half4 frag_downsample1(v2f_img i) : SV_Target 206 | { 207 | #if ANTI_FLICKER 208 | return EncodeHDR(DownsampleAntiFlickerFilter(i.uv)); 209 | #else 210 | return EncodeHDR(DownsampleFilter(i.uv)); 211 | #endif 212 | } 213 | 214 | half4 frag_downsample2(v2f_img i) : SV_Target 215 | { 216 | return EncodeHDR(DownsampleFilter(i.uv)); 217 | } 218 | 219 | half4 frag_upsample(v2f_multitex i) : SV_Target 220 | { 221 | half3 base = DecodeHDR(tex2D(_BaseTex, i.uvBase)); 222 | half3 blur = UpsampleFilter(i.uvMain); 223 | return EncodeHDR(base + blur); 224 | } 225 | 226 | half4 frag_upsample_final(v2f_multitex i) : SV_Target 227 | { 228 | half4 base = tex2D(_BaseTex, i.uvBase); 229 | half3 blur = UpsampleFilter(i.uvMain); 230 | #if UNITY_COLORSPACE_GAMMA 231 | base.rgb = GammaToLinearSpace(base.rgb); 232 | #endif 233 | half3 cout = base.rgb + blur * _Intensity; 234 | #if UNITY_COLORSPACE_GAMMA 235 | cout = LinearToGammaSpace(cout); 236 | #endif 237 | return half4(cout, base.a); 238 | } 239 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Bloom/Resources/Bloom.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 386a80fc77a074d2ca8e6f097dd68ea3 3 | timeCreated: 1463538726 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Bloom/Resources/Bloom.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/Image Effects/Cinematic/Bloom" 2 | { 3 | Properties 4 | { 5 | _MainTex("", 2D) = "" {} 6 | _BaseTex("", 2D) = "" {} 7 | } 8 | SubShader 9 | { 10 | // 0: Prefilter 11 | Pass 12 | { 13 | ZTest Always Cull Off ZWrite Off 14 | CGPROGRAM 15 | #pragma multi_compile _ UNITY_COLORSPACE_GAMMA 16 | #include "Bloom.cginc" 17 | #pragma vertex vert 18 | #pragma fragment frag_prefilter 19 | #pragma target 3.0 20 | ENDCG 21 | } 22 | // 1: Prefilter with anti-flicker 23 | Pass 24 | { 25 | ZTest Always Cull Off ZWrite Off 26 | CGPROGRAM 27 | #define ANTI_FLICKER 1 28 | #pragma multi_compile _ UNITY_COLORSPACE_GAMMA 29 | #include "Bloom.cginc" 30 | #pragma vertex vert 31 | #pragma fragment frag_prefilter 32 | #pragma target 3.0 33 | ENDCG 34 | } 35 | // 2: First level downsampler 36 | Pass 37 | { 38 | ZTest Always Cull Off ZWrite Off 39 | CGPROGRAM 40 | #include "Bloom.cginc" 41 | #pragma vertex vert 42 | #pragma fragment frag_downsample1 43 | #pragma target 3.0 44 | ENDCG 45 | } 46 | // 3: First level downsampler with anti-flicker 47 | Pass 48 | { 49 | ZTest Always Cull Off ZWrite Off 50 | CGPROGRAM 51 | #define ANTI_FLICKER 1 52 | #include "Bloom.cginc" 53 | #pragma vertex vert 54 | #pragma fragment frag_downsample1 55 | #pragma target 3.0 56 | ENDCG 57 | } 58 | // 4: Second level downsampler 59 | Pass 60 | { 61 | ZTest Always Cull Off ZWrite Off 62 | CGPROGRAM 63 | #include "Bloom.cginc" 64 | #pragma vertex vert 65 | #pragma fragment frag_downsample2 66 | #pragma target 3.0 67 | ENDCG 68 | } 69 | // 5: Upsampler 70 | Pass 71 | { 72 | ZTest Always Cull Off ZWrite Off 73 | CGPROGRAM 74 | #include "Bloom.cginc" 75 | #pragma vertex vert_multitex 76 | #pragma fragment frag_upsample 77 | #pragma target 3.0 78 | ENDCG 79 | } 80 | // 6: High quality upsampler 81 | Pass 82 | { 83 | ZTest Always Cull Off ZWrite Off 84 | CGPROGRAM 85 | #define HIGH_QUALITY 1 86 | #include "Bloom.cginc" 87 | #pragma vertex vert_multitex 88 | #pragma fragment frag_upsample 89 | #pragma target 3.0 90 | ENDCG 91 | } 92 | // 7: Combiner 93 | Pass 94 | { 95 | ZTest Always Cull Off ZWrite Off 96 | CGPROGRAM 97 | #pragma multi_compile _ UNITY_COLORSPACE_GAMMA 98 | #include "Bloom.cginc" 99 | #pragma vertex vert_multitex 100 | #pragma fragment frag_upsample_final 101 | #pragma target 3.0 102 | ENDCG 103 | } 104 | // 8: High quality combiner 105 | Pass 106 | { 107 | ZTest Always Cull Off ZWrite Off 108 | CGPROGRAM 109 | #define HIGH_QUALITY 1 110 | #pragma multi_compile _ UNITY_COLORSPACE_GAMMA 111 | #include "Bloom.cginc" 112 | #pragma vertex vert_multitex 113 | #pragma fragment frag_upsample_final 114 | #pragma target 3.0 115 | ENDCG 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Bloom/Resources/Bloom.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e45d4f28262b04d10a075856ab5fdb5e 3 | timeCreated: 1454052270 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 88d2f1c604c7f6d4bb80a72b2f0219a7 3 | folderAsset: yes 4 | timeCreated: 1449044555 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Common/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e862ecde714eb154ca2d86a9a0809732 3 | folderAsset: yes 4 | timeCreated: 1453372226 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Common/Editor/EditorGUIHelper.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using System; 4 | using System.Linq.Expressions; 5 | using System.Reflection; 6 | 7 | namespace UnityStandardAssets.CinematicEffects 8 | { 9 | public static class EditorGUIHelper 10 | { 11 | private static Styles s_Styles; 12 | private class Styles 13 | { 14 | public GUIStyle header = "ShurikenModuleTitle"; 15 | public GUIStyle headerCheckbox = "ShurikenCheckMark"; 16 | 17 | internal Styles() 18 | { 19 | header.font = (new GUIStyle("Label")).font; 20 | header.border = new RectOffset(15, 7, 4, 4); 21 | header.fixedHeight = 22; 22 | header.contentOffset = new Vector2(20f, -2f); 23 | } 24 | } 25 | 26 | static EditorGUIHelper() 27 | { 28 | s_Styles = new Styles(); 29 | } 30 | 31 | public static bool Header(SerializedProperty group, SerializedProperty enabledField) 32 | { 33 | var display = group == null || group.isExpanded; 34 | var enabled = enabledField != null && enabledField.boolValue; 35 | var title = group == null ? "Unknown Group" : ObjectNames.NicifyVariableName(group.displayName); 36 | 37 | Rect rect = GUILayoutUtility.GetRect(16f, 22f, s_Styles.header); 38 | GUI.Box(rect, title, s_Styles.header); 39 | 40 | Rect toggleRect = new Rect(rect.x + 4f, rect.y + 4f, 13f, 13f); 41 | if (Event.current.type == EventType.Repaint) 42 | s_Styles.headerCheckbox.Draw(toggleRect, false, false, enabled, false); 43 | 44 | Event e = Event.current; 45 | if (e.type == EventType.MouseDown) 46 | { 47 | if (toggleRect.Contains(e.mousePosition) && enabledField != null) 48 | { 49 | enabledField.boolValue = !enabledField.boolValue; 50 | e.Use(); 51 | } 52 | else if (rect.Contains(e.mousePosition) && group != null) 53 | { 54 | display = !display; 55 | group.isExpanded = !group.isExpanded; 56 | e.Use(); 57 | } 58 | } 59 | return display; 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Common/Editor/EditorGUIHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5b995f06a3ed14d449823cf7ab1c5a58 3 | timeCreated: 1454681943 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/Standard Assets/Effects/Common/Editor/FieldFinder.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | using System.Reflection; 4 | 5 | namespace UnityStandardAssets.CinematicEffects 6 | { 7 | public static class FieldFinder 8 | { 9 | public static FieldInfo GetField(Expression> selector) 10 | { 11 | Expression body = selector; 12 | if (body is LambdaExpression) 13 | { 14 | body = ((LambdaExpression)body).Body; 15 | } 16 | switch (body.NodeType) 17 | { 18 | case ExpressionType.MemberAccess: 19 | return (FieldInfo)((MemberExpression)body).Member; 20 | default: 21 | throw new InvalidOperationException(); 22 | } 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Common/Editor/FieldFinder.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 39e54cb37a3a81a40b248f1cc25c4619 3 | timeCreated: 1454073160 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/Standard Assets/Effects/Common/Editor/MinDrawer.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.CinematicEffects 5 | { 6 | [CustomPropertyDrawer(typeof(MinAttribute))] 7 | internal sealed class MinDrawer : PropertyDrawer 8 | { 9 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 10 | { 11 | MinAttribute attribute = (MinAttribute) base.attribute; 12 | 13 | if (property.propertyType == SerializedPropertyType.Integer) 14 | { 15 | int v = EditorGUI.IntField(position, label, property.intValue); 16 | property.intValue = (int)Mathf.Max(v, attribute.min); 17 | } 18 | else if (property.propertyType == SerializedPropertyType.Float) 19 | { 20 | float v = EditorGUI.FloatField(position, label, property.floatValue); 21 | property.floatValue = Mathf.Max(v, attribute.min); 22 | } 23 | else 24 | { 25 | EditorGUI.LabelField(position, label.text, "Use Min with float or int."); 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Common/Editor/MinDrawer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c615a85f13c6764fa4496d1d7f75f52 3 | timeCreated: 1453220014 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/Standard Assets/Effects/Common/ImageEffectHelper.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | #if UNITY_EDITOR 3 | using UnityEditor; 4 | #endif 5 | 6 | namespace UnityStandardAssets.CinematicEffects 7 | { 8 | public static class ImageEffectHelper 9 | { 10 | public static bool IsSupported(Shader s, bool needDepth, bool needHdr, MonoBehaviour effect) 11 | { 12 | #if UNITY_EDITOR 13 | // Don't check for shader compatibility while it's building as it would disable most effects 14 | // on build farms without good-enough gaming hardware. 15 | if (!BuildPipeline.isBuildingPlayer) 16 | { 17 | #endif 18 | if (s == null || !s.isSupported) 19 | { 20 | Debug.LogWarningFormat("Missing shader for image effect {0}", effect); 21 | return false; 22 | } 23 | 24 | if (!SystemInfo.supportsImageEffects || !SystemInfo.supportsRenderTextures) 25 | { 26 | Debug.LogWarningFormat("Image effects aren't supported on this device ({0})", effect); 27 | return false; 28 | } 29 | 30 | if (needDepth && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.Depth)) 31 | { 32 | Debug.LogWarningFormat("Depth textures aren't supported on this device ({0})", effect); 33 | return false; 34 | } 35 | 36 | if (needHdr && !SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.ARGBHalf)) 37 | { 38 | Debug.LogWarningFormat("Floating point textures aren't supported on this device ({0})", effect); 39 | return false; 40 | } 41 | #if UNITY_EDITOR 42 | } 43 | #endif 44 | 45 | return true; 46 | } 47 | 48 | public static Material CheckShaderAndCreateMaterial(Shader s) 49 | { 50 | if (s == null || !s.isSupported) 51 | return null; 52 | 53 | var material = new Material(s); 54 | material.hideFlags = HideFlags.DontSave; 55 | return material; 56 | } 57 | 58 | public static bool supportsDX11 59 | { 60 | get { return SystemInfo.graphicsShaderLevel >= 50 && SystemInfo.supportsComputeShaders; } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Common/ImageEffectHelper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ab6a3f50deeee984c88794eeeb901226 3 | timeCreated: 1448544124 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/Standard Assets/Effects/Common/MinAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace UnityStandardAssets.CinematicEffects 2 | { 3 | using UnityEngine; 4 | 5 | public sealed class MinAttribute : PropertyAttribute 6 | { 7 | public readonly float min; 8 | 9 | public MinAttribute(float min) 10 | { 11 | this.min = min; 12 | } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Common/MinAttribute.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b07292ae638766047a6751da7552e566 3 | timeCreated: 1453220005 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/Standard Assets/Effects/Common/RenderTextureUtility.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.CinematicEffects 5 | { 6 | public class RenderTextureUtility 7 | { 8 | //Temporary render texture handling 9 | private List m_TemporaryRTs = new List(); 10 | 11 | public RenderTexture GetTemporaryRenderTexture(int width, int height, int depthBuffer = 0, RenderTextureFormat format = RenderTextureFormat.ARGBHalf, FilterMode filterMode = FilterMode.Bilinear) 12 | { 13 | var rt = RenderTexture.GetTemporary(width, height, depthBuffer, format); 14 | rt.filterMode = filterMode; 15 | rt.wrapMode = TextureWrapMode.Clamp; 16 | rt.name = "RenderTextureUtilityTempTexture"; 17 | m_TemporaryRTs.Add(rt); 18 | return rt; 19 | } 20 | 21 | public void ReleaseTemporaryRenderTexture(RenderTexture rt) 22 | { 23 | if (rt == null) 24 | return; 25 | 26 | if (!m_TemporaryRTs.Contains(rt)) 27 | { 28 | Debug.LogErrorFormat("Attempting to remove texture that was not allocated: {0}", rt); 29 | return; 30 | } 31 | 32 | m_TemporaryRTs.Remove(rt); 33 | RenderTexture.ReleaseTemporary(rt); 34 | } 35 | 36 | public void ReleaseAllTemporaryRenderTextures() 37 | { 38 | for (int i = 0; i < m_TemporaryRTs.Count; ++i) 39 | RenderTexture.ReleaseTemporary(m_TemporaryRTs[i]); 40 | 41 | m_TemporaryRTs.Clear(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/Common/RenderTextureUtility.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 054e694bae00c374a97c2bc495fca66b 3 | timeCreated: 1449148391 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/Standard Assets/Effects/DepthOfField.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 34369cdf66de04c65a8cef766bb1797b 3 | folderAsset: yes 4 | timeCreated: 1429220270 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/DepthOfField.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8a338d679868f45439ea43c7ae035e36 3 | timeCreated: 1453985420 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - m_FilmicDepthOfFieldShader: {fileID: 4800000, guid: bff0e5458fb914f5c9985ba4f09171d2, 9 | type: 3} 10 | - m_MedianFilterShader: {fileID: 4800000, guid: a058b22d4123add4b807e832604e5e7b, 11 | type: 3} 12 | - m_TextureBokehShader: {fileID: 4800000, guid: c961b8ed1f00f924d804ada5143bd0e8, 13 | type: 3} 14 | executionOrder: 0 15 | icon: {instanceID: 0} 16 | userData: 17 | assetBundleName: 18 | assetBundleVariant: 19 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a8273952ce5743428d8c42b25cb0458 3 | folderAsset: yes 4 | timeCreated: 1449046242 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Editor/DepthOfFieldEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | 4 | namespace UnityStandardAssets.CinematicEffects 5 | { 6 | [CustomEditor(typeof(DepthOfField))] 7 | class DepthOfFieldEditor : Editor 8 | { 9 | private SerializedProperty m_VisualizeFocus; 10 | private SerializedProperty m_TweakMode; 11 | private SerializedProperty m_FilteringQuality; 12 | private SerializedProperty m_ApertureShape; 13 | private SerializedProperty m_ApertureOrientation; 14 | 15 | private SerializedProperty m_Transform; 16 | private SerializedProperty m_FocusPlane; 17 | private SerializedProperty m_Range; 18 | private SerializedProperty m_NearPlane; 19 | private SerializedProperty m_NearFalloff; 20 | private SerializedProperty m_FarPlane; 21 | private SerializedProperty m_FarFalloff; 22 | private SerializedProperty m_NearBlurRadius; 23 | private SerializedProperty m_FarBlurRadius; 24 | 25 | private SerializedProperty m_Texture; 26 | private SerializedProperty m_Scale; 27 | private SerializedProperty m_Intensity; 28 | private SerializedProperty m_Threshold; 29 | private SerializedProperty m_SpawnHeuristic; 30 | 31 | private void OnEnable() 32 | { 33 | var o = serializedObject; 34 | 35 | m_VisualizeFocus = o.FindProperty("settings.visualizeFocus"); 36 | m_TweakMode = o.FindProperty("settings.tweakMode"); 37 | m_FilteringQuality = o.FindProperty("settings.filteringQuality"); 38 | m_ApertureShape = o.FindProperty("settings.apertureShape"); 39 | m_ApertureOrientation = o.FindProperty("settings.apertureOrientation"); 40 | 41 | m_Transform = o.FindProperty("focus.transform"); 42 | m_FocusPlane = o.FindProperty("focus.focusPlane"); 43 | m_Range = o.FindProperty("focus.range"); 44 | m_NearPlane = o.FindProperty("focus.nearPlane"); 45 | m_NearFalloff = o.FindProperty("focus.nearFalloff"); 46 | m_FarPlane = o.FindProperty("focus.farPlane"); 47 | m_FarFalloff = o.FindProperty("focus.farFalloff"); 48 | m_NearBlurRadius = o.FindProperty("focus.nearBlurRadius"); 49 | m_FarBlurRadius = o.FindProperty("focus.farBlurRadius"); 50 | 51 | m_Texture = o.FindProperty("bokehTexture.texture"); 52 | m_Scale = o.FindProperty("bokehTexture.scale"); 53 | m_Intensity = o.FindProperty("bokehTexture.intensity"); 54 | m_Threshold = o.FindProperty("bokehTexture.threshold"); 55 | m_SpawnHeuristic = o.FindProperty("bokehTexture.spawnHeuristic"); 56 | } 57 | 58 | public override void OnInspectorGUI() 59 | { 60 | serializedObject.Update(); 61 | 62 | EditorGUILayout.PropertyField(m_VisualizeFocus); 63 | EditorGUILayout.PropertyField(m_TweakMode); 64 | EditorGUILayout.PropertyField(m_FilteringQuality); 65 | EditorGUILayout.PropertyField(m_ApertureShape); 66 | 67 | if (m_ApertureShape.intValue != (int)DepthOfField.ApertureShape.Circular) 68 | { 69 | EditorGUI.indentLevel++; 70 | EditorGUILayout.PropertyField(m_ApertureOrientation, new GUIContent("Orientation")); 71 | EditorGUI.indentLevel--; 72 | } 73 | 74 | EditorGUILayout.Space(); 75 | EditorGUILayout.LabelField("Focus", EditorStyles.boldLabel); 76 | 77 | var falloff = new GUIContent("Falloff"); 78 | var blurRadius = new GUIContent("Blur Radius"); 79 | 80 | EditorGUI.indentLevel++; 81 | 82 | if (m_TweakMode.intValue == (int)DepthOfField.TweakMode.Range) 83 | { 84 | EditorGUILayout.PropertyField(m_Transform); 85 | 86 | using (new EditorGUI.DisabledGroupScope(m_Transform.objectReferenceValue != null)) 87 | { 88 | EditorGUILayout.PropertyField(m_FocusPlane); 89 | } 90 | 91 | EditorGUILayout.PropertyField(m_Range); 92 | 93 | EditorGUILayout.LabelField(m_NearPlane.displayName); 94 | EditorGUI.indentLevel++; 95 | EditorGUILayout.PropertyField(m_NearFalloff, falloff); 96 | EditorGUILayout.PropertyField(m_NearBlurRadius, blurRadius); 97 | EditorGUI.indentLevel--; 98 | 99 | EditorGUILayout.LabelField(m_FarPlane.displayName); 100 | EditorGUI.indentLevel++; 101 | EditorGUILayout.PropertyField(m_FarFalloff, falloff); 102 | EditorGUILayout.PropertyField(m_FarBlurRadius, blurRadius); 103 | EditorGUI.indentLevel--; 104 | } 105 | else 106 | { 107 | EditorGUILayout.PropertyField(m_NearPlane); 108 | EditorGUI.indentLevel++; 109 | EditorGUILayout.PropertyField(m_NearFalloff, falloff); 110 | EditorGUILayout.PropertyField(m_NearBlurRadius, blurRadius); 111 | EditorGUI.indentLevel--; 112 | 113 | EditorGUILayout.PropertyField(m_FarPlane); 114 | EditorGUI.indentLevel++; 115 | EditorGUILayout.PropertyField(m_FarFalloff, falloff); 116 | EditorGUILayout.PropertyField(m_FarBlurRadius, blurRadius); 117 | EditorGUI.indentLevel--; 118 | } 119 | 120 | EditorGUI.indentLevel--; 121 | 122 | EditorGUILayout.Space(); 123 | EditorGUILayout.LabelField("Bokeh", EditorStyles.boldLabel); 124 | 125 | EditorGUI.indentLevel++; 126 | EditorGUILayout.PropertyField(m_Texture); 127 | if (m_Texture.objectReferenceValue != null) 128 | { 129 | EditorGUILayout.PropertyField(m_Scale); 130 | EditorGUILayout.PropertyField(m_Intensity); 131 | EditorGUILayout.PropertyField(m_Threshold); 132 | EditorGUILayout.PropertyField(m_SpawnHeuristic); 133 | } 134 | EditorGUI.indentLevel--; 135 | 136 | serializedObject.ApplyModifiedProperties(); 137 | } 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Editor/DepthOfFieldEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3eb07ef5681934662814cc768bcdb60c 3 | timeCreated: 1429220270 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/Standard Assets/Effects/DepthOfField/Helpers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5427d9a5126366c42b9509de8233bff7 3 | folderAsset: yes 4 | timeCreated: 1453985653 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Helpers/HexShape.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Standard Assets/Effects/DepthOfField/Helpers/HexShape.psd -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Helpers/HexShape.psd.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a4cdca73d61814d33ac1587f6c163bca 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: 0.25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 7 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 64 29 | textureSettings: 30 | filterMode: -1 31 | aniso: 0 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 1 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | allowsAlphaSplitting: 0 39 | spriteMode: 0 40 | spriteExtrude: 1 41 | spriteMeshType: 1 42 | alignment: 0 43 | spritePivot: {x: 0.5, y: 0.5} 44 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 45 | spritePixelsToUnits: 100 46 | alphaIsTransparency: 0 47 | textureType: -1 48 | buildTargetSettings: [] 49 | spriteSheet: 50 | sprites: [] 51 | outline: [] 52 | spritePackingTag: 53 | userData: 54 | assetBundleName: 55 | assetBundleVariant: 56 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Helpers/RoundedHexShape.tif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Standard Assets/Effects/DepthOfField/Helpers/RoundedHexShape.tif -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Helpers/RoundedHexShape.tif.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9014ef007a9a1d545b0fba20daa0fc7c 3 | timeCreated: 1454425451 4 | licenseType: Store 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | linearTexture: 0 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 1 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: -1 30 | maxTextureSize: 64 31 | textureSettings: 32 | filterMode: -1 33 | aniso: 0 34 | mipBias: -1 35 | wrapMode: 1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: -1 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Helpers/SphereShape.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Standard Assets/Effects/DepthOfField/Helpers/SphereShape.psd -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Helpers/SphereShape.psd.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fc00ec05a89da4ff695a4273715cd5ce 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 1 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: 0.25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | cubemapConvolution: 0 24 | cubemapConvolutionSteps: 7 25 | cubemapConvolutionExponent: 1.5 26 | seamlessCubemap: 0 27 | textureFormat: -1 28 | maxTextureSize: 64 29 | textureSettings: 30 | filterMode: -1 31 | aniso: 0 32 | mipBias: -1 33 | wrapMode: 1 34 | nPOTScale: 1 35 | lightmap: 0 36 | rGBM: 0 37 | compressionQuality: 50 38 | allowsAlphaSplitting: 0 39 | spriteMode: 0 40 | spriteExtrude: 1 41 | spriteMeshType: 1 42 | alignment: 0 43 | spritePivot: {x: 0.5, y: 0.5} 44 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 45 | spritePixelsToUnits: 100 46 | alphaIsTransparency: 0 47 | textureType: -1 48 | buildTargetSettings: [] 49 | spriteSheet: 50 | sprites: [] 51 | outline: [] 52 | spritePackingTag: 53 | userData: 54 | assetBundleName: 55 | assetBundleVariant: 56 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: aa2234edaeebe8b4fb5d67be342dbac9 3 | folderAsset: yes 4 | timeCreated: 1453906992 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Resources/BokehSplatting.shader: -------------------------------------------------------------------------------- 1 | /* 2 | DX11 Bokeh splatting 3 | 4 | Basic algorithm: 5 | * Find bright spots 6 | * Verify high frequency (otherwise dont care) 7 | * If positive, replace with black pixel and add to append buffer 8 | * Blend bokeh texture sprites via append buffer on top of blurred buffer 9 | */ 10 | 11 | Shader "Hidden/DepthOfField/BokehSplatting" 12 | { 13 | Properties 14 | { 15 | _MainTex ("", 2D) = "white" {} 16 | _BlurredColor ("", 2D) = "white" {} 17 | _FgCocMask ("", 2D) = "white" {} 18 | } 19 | 20 | CGINCLUDE 21 | 22 | #include "UnityCG.cginc" 23 | 24 | #define BOKEH_ZERO_VEC (float4(0.0,0.0,0.0,0.0)) 25 | #define BOKEH_ONE_VEC (float4(1.0,1.0,1.0,1.0)) 26 | 27 | float4 _BokehParams; // dx11BokehScale, dx11BokehIntensity,dx11BokehThreshhold, internalBlurWidth 28 | float4 _MainTex_TexelSize; 29 | float3 _Screen; 30 | float _SpawnHeuristic; 31 | 32 | sampler2D_float _CameraDepthTexture; 33 | sampler2D _BlurredColor; 34 | sampler2D _MainTex; 35 | sampler2D _FgCocMask; 36 | 37 | struct appendStruct 38 | { 39 | float3 pos; 40 | float4 color; 41 | }; 42 | 43 | struct gs_out 44 | { 45 | float4 pos : SV_POSITION; 46 | float3 uv : TEXCOORD0; 47 | float4 color : TEXCOORD1; 48 | float4 misc : TEXCOORD2; 49 | }; 50 | 51 | // TODO: activate border clamp tex sampler state instead? 52 | inline float4 clampBorderColor(float2 uv) 53 | { 54 | #if 1 55 | if(uv.x <= 0.0) return BOKEH_ZERO_VEC; if(uv.x >= 1.0) return BOKEH_ZERO_VEC; 56 | if(uv.y <= 0.0) return BOKEH_ZERO_VEC; if(uv.y >= 1.0) return BOKEH_ZERO_VEC; 57 | #endif 58 | return BOKEH_ONE_VEC; 59 | } 60 | 61 | struct vs_out 62 | { 63 | float4 pos : SV_POSITION; 64 | float2 uv : TEXCOORD0; 65 | float4 color : TEXCOORD1; 66 | float cocOverlap : TEXCOORD2; 67 | }; 68 | 69 | struct appdata 70 | { 71 | float4 vertex : POSITION; 72 | float2 texcoord : TEXCOORD0; 73 | }; 74 | 75 | struct v2f 76 | { 77 | float4 pos : SV_POSITION; 78 | float2 uv_flip : TEXCOORD0; 79 | float2 uv : TEXCOORD1; 80 | }; 81 | 82 | AppendStructuredBuffer pointBufferOutput : register(u1); 83 | StructuredBuffer pointBuffer; 84 | 85 | vs_out vertApply (uint id : SV_VertexID) 86 | { 87 | vs_out o = (vs_out)0; 88 | float2 pos = pointBuffer[id].pos.xy ; 89 | o.pos = float4(pos * 2.0 - 1.0, 0.0, 1.0); 90 | o.color = pointBuffer[id].color; 91 | 92 | #if UNITY_UV_STARTS_AT_TOP 93 | o.pos.y *= -1.0; 94 | #endif 95 | 96 | o.cocOverlap = pointBuffer[id].pos.z; 97 | 98 | return o; 99 | } 100 | 101 | v2f vertCollect (appdata v) 102 | { 103 | v2f o; 104 | o.pos = mul (UNITY_MATRIX_MVP, v.vertex); 105 | o.uv = v.texcoord; 106 | o.uv_flip = v.texcoord; 107 | 108 | #if UNITY_UV_STARTS_AT_TOP 109 | if (_MainTex_TexelSize.y < 0.0) 110 | { 111 | o.uv_flip.y = 1.0 - o.uv_flip.y; 112 | o.pos.y *= -1.0; 113 | } 114 | #endif 115 | 116 | return o; 117 | } 118 | 119 | [maxvertexcount(4)] 120 | void geom (point vs_out input[1], inout TriangleStream outStream) 121 | { 122 | // NEW ENERGY CONSERVATION: 123 | float2 scale2 = _BokehParams.ww * input[0].color.aa * _BokehParams.xx; 124 | float4 offs = 0.0; 125 | offs.xy = float2(3.0, 3.0) + 2.0 * floor(scale2 + float2(0.5, 0.5)); 126 | 127 | float2 rs = ((float2(1.0, 1.0) + 2.0 * (scale2 + float2(0.5, 0.5))));; 128 | float2 f2 = offs.xy / rs; 129 | 130 | float energyAdjustment = (_BokehParams.y) / (rs.x * rs.y); 131 | offs.xy *= _Screen.xy; 132 | 133 | gs_out output; 134 | 135 | output.pos = input[0].pos + offs * float4(-1.0, 1.0, 0.0, 0.0); 136 | output.misc = float4(f2, 0.0, 0.0); 137 | output.uv = float3(0.0, 1.0, input[0].cocOverlap); 138 | output.color = input[0].color * energyAdjustment; 139 | outStream.Append (output); 140 | 141 | output.pos = input[0].pos + offs*float4(1.0, 1.0, 0.0, 0.0); 142 | output.misc = float4(f2, 0.0, 0.0); 143 | output.uv = float3(1.0, 1.0, input[0].cocOverlap); 144 | output.color = input[0].color * energyAdjustment; 145 | outStream.Append (output); 146 | 147 | output.pos = input[0].pos + offs*float4(-1.0, -1.0, 0.0, 0.0); 148 | output.misc = float4(f2, 0.0, 0.0); 149 | output.uv = float3(0.0, 0.0, input[0].cocOverlap); 150 | output.color = input[0].color * energyAdjustment; 151 | outStream.Append (output); 152 | 153 | output.pos = input[0].pos + offs*float4(1.0, -1.0, 0.0, 0.0); 154 | output.misc = float4(f2, 0.0, 0.0); 155 | output.uv = float3(1.0, 0.0, input[0].cocOverlap); 156 | output.color = input[0].color * energyAdjustment; 157 | outStream.Append (output); 158 | 159 | outStream.RestartStrip(); 160 | } 161 | 162 | float4 collectBrightPixel(half2 uv) 163 | { 164 | half4 c = tex2D(_MainTex, uv); 165 | half coc = abs(c.a); 166 | half lumc = Luminance(c.rgb); 167 | 168 | half4 cblurred = tex2D(_BlurredColor, uv); 169 | half cocBlurred = abs(cblurred.a); 170 | half lumblurred = Luminance(cblurred.rgb); 171 | half fgCoc = -min(c.a, 0.0); 172 | 173 | [branch] 174 | if (coc * _BokehParams.w > 1.0 && cocBlurred > 0.1 && lumc > _BokehParams.z && abs(lumc - lumblurred) > _SpawnHeuristic) 175 | { 176 | appendStruct append = (appendStruct)0; 177 | append.pos = float3(uv, fgCoc); 178 | append.color.rgba = half4(c.rgb * saturate(coc * 4.0), coc); 179 | pointBufferOutput.Append(append); 180 | c = half4(c.rgb * saturate(1.0 - coc * 4.0), c.a); 181 | } 182 | 183 | return c; 184 | } 185 | 186 | ENDCG 187 | 188 | SubShader 189 | { 190 | // Pass 0: bokeh splatting 191 | Pass 192 | { 193 | ZWrite Off ZTest Always Cull Off 194 | BlendOp Add, Add 195 | Blend DstAlpha One, Zero One 196 | ColorMask RGBA 197 | 198 | CGPROGRAM 199 | 200 | #pragma target 5.0 201 | #pragma vertex vertApply 202 | #pragma geometry geom 203 | #pragma fragment frag 204 | 205 | fixed4 frag (gs_out i) : SV_Target 206 | { 207 | float2 uv = (i.uv.xy) * i.misc.xy + (float2(1,1)-i.misc.xy) * 0.5; // smooth uv scale 208 | return float4(i.color.rgb, 1) * float4(tex2D(_MainTex, uv.xy).rgb, i.uv.z) * clampBorderColor (uv); 209 | } 210 | 211 | ENDCG 212 | } 213 | 214 | // Pass 1: append buffer "collect" 215 | Pass 216 | { 217 | ZWrite Off ZTest Always Cull Off 218 | 219 | CGPROGRAM 220 | 221 | #pragma vertex vertCollect 222 | #pragma fragment frag 223 | #pragma target 5.0 224 | 225 | float4 frag (v2f i) : SV_Target 226 | { 227 | return collectBrightPixel(i.uv); 228 | } 229 | 230 | ENDCG 231 | } 232 | } 233 | 234 | Fallback Off 235 | } 236 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Resources/BokehSplatting.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c961b8ed1f00f924d804ada5143bd0e8 3 | timeCreated: 1449750679 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Resources/DepthOfField.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bff0e5458fb914f5c9985ba4f09171d2 3 | timeCreated: 1447081022 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Resources/MedianFilter.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/DepthOfField/MedianFilter" 2 | { 3 | Properties 4 | { 5 | _MainTex ("-", 2D) = "black" 6 | } 7 | 8 | CGINCLUDE 9 | 10 | #pragma target 3.0 11 | #pragma fragmentoption ARB_precision_hint_fastest 12 | #include "UnityCG.cginc" 13 | 14 | sampler2D _MainTex; 15 | uniform half4 _MainTex_TexelSize; 16 | uniform half4 _MainTex_ST; 17 | uniform float4 _Offsets; 18 | 19 | /////////////////////////////////////////////////////////////////////////////// 20 | // Verter Shaders and declaration 21 | /////////////////////////////////////////////////////////////////////////////// 22 | 23 | struct v2f 24 | { 25 | half4 pos : SV_POSITION; 26 | half2 uv : TEXCOORD0; 27 | }; 28 | 29 | v2f vert(appdata_img v) 30 | { 31 | v2f o; 32 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 33 | o.uv = v.texcoord.xy; 34 | 35 | #if UNITY_UV_STARTS_AT_TOP 36 | if (_MainTex_TexelSize.y < 0.0) 37 | o.uv.y = 1.0 - o.uv.y; 38 | #endif 39 | 40 | return o; 41 | } 42 | 43 | /////////////////////////////////////////////////////////////////////////////// 44 | 45 | float4 fragCocMedian3 (v2f i) : SV_Target 46 | { 47 | // TODO: Use med3 on GCN architecture. 48 | half4 A = tex2Dlod(_MainTex, half4(i.uv, 0.0, 0.0)); 49 | half3 B = tex2Dlod(_MainTex, half4(i.uv + _Offsets.xy * _MainTex_TexelSize.xy, 0.0, 0.0)).rgb; 50 | half3 C = tex2Dlod(_MainTex, half4(i.uv - _Offsets.xy * _MainTex_TexelSize.xy, 0.0, 0.0)).rgb; 51 | 52 | half3 minAB = min(A.rgb,B); 53 | half3 maxAB = max(A.rgb,B); 54 | half3 temp = min(C, maxAB); 55 | half3 median = max(minAB, temp); 56 | 57 | return half4(lerp(A.rgb, median, A.a * A.a), A.a); 58 | } 59 | 60 | /*///////////////////////////////////////////////////////////////////////////// 61 | 3x3 Median 62 | Morgan McGuire and Kyle Whitson 63 | http://graphics.cs.williams.edu 64 | 65 | Copyright (c) Morgan McGuire and Williams College, 2006 66 | All rights reserved. 67 | 68 | Redistribution and use in source and binary forms, with or without 69 | modification, are permitted provided that the following conditions are 70 | met: 71 | 72 | Redistributions of source code must retain the above copyright notice, 73 | this list of conditions and the following disclaimer. 74 | 75 | Redistributions in binary form must reproduce the above copyright 76 | notice, this list of conditions and the following disclaimer in the 77 | documentation and/or other materials provided with the distribution. 78 | 79 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 80 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 81 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 82 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 83 | HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 84 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 85 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 86 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 87 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 88 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 89 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 90 | */ 91 | #define s2(a, b) temp = a; a = min(a, b); b = max(temp, b); 92 | #define mn3(a, b, c) s2(a, b); s2(a, c); 93 | #define mx3(a, b, c) s2(b, c); s2(a, c); 94 | #define mnmx3(a, b, c) mx3(a, b, c); s2(a, b); 95 | #define mnmx4(a, b, c, d) s2(a, b); s2(c, d); s2(a, c); s2(b, d); 96 | #define mnmx5(a, b, c, d, e) s2(a, b); s2(c, d); mn3(a, c, e); mx3(b, d, e); 97 | #define mnmx6(a, b, c, d, e, f) s2(a, d); s2(b, e); s2(c, f); mn3(a, b, c); mx3(d, e, f); 98 | 99 | float4 fragCocMedian3x3 (v2f i) : SV_Target 100 | { 101 | half4 center = tex2Dlod(_MainTex, half4(i.uv + half2(0, 0) * _MainTex_TexelSize.xy,0,0)); 102 | 103 | half3 v[9]; 104 | // Add the pixels which make up our window to the pixel array. 105 | v[0] = tex2Dlod(_MainTex, half4(i.uv + half2(-1, -1) * _MainTex_TexelSize.xy, 0, 0)).rgb; 106 | v[1] = tex2Dlod(_MainTex, half4(i.uv + half2(-1, 0) * _MainTex_TexelSize.xy, 0, 0)).rgb; 107 | v[2] = tex2Dlod(_MainTex, half4(i.uv + half2(-1, 1) * _MainTex_TexelSize.xy, 0, 0)).rgb; 108 | v[3] = tex2Dlod(_MainTex, half4(i.uv + half2( 0, -1) * _MainTex_TexelSize.xy, 0, 0)).rgb; 109 | v[4] = center.rgb; 110 | v[5] = tex2Dlod(_MainTex, half4(i.uv + half2( 0, 1) * _MainTex_TexelSize.xy, 0, 0)).rgb; 111 | v[6] = tex2Dlod(_MainTex, half4(i.uv + half2( 1, -1) * _MainTex_TexelSize.xy, 0, 0)).rgb; 112 | v[7] = tex2Dlod(_MainTex, half4(i.uv + half2( 1, 0) * _MainTex_TexelSize.xy, 0, 0)).rgb; 113 | v[8] = tex2Dlod(_MainTex, half4(i.uv + half2( 1, 1) * _MainTex_TexelSize.xy, 0, 0)).rgb; 114 | 115 | half3 temp; 116 | // TODO: use med3 on GCN architecture. 117 | // Starting with a subset of size 6, remove the min and max each time 118 | mnmx6(v[0], v[1], v[2], v[3], v[4], v[5]); 119 | mnmx5(v[1], v[2], v[3], v[4], v[6]); 120 | mnmx4(v[2], v[3], v[4], v[7]); 121 | mnmx3(v[3], v[4], v[8]); 122 | 123 | return half4(lerp(center.rgb, v[4], center.a*center.a), center.a); 124 | } 125 | 126 | #undef s2 127 | #undef mn3 128 | #undef mx3 129 | #undef mnmx3 130 | #undef mnmx4 131 | #undef mnmx5 132 | #undef mnmx6 133 | 134 | /////////////////////////////////////////////////////////////////////////////// 135 | 136 | ENDCG 137 | 138 | SubShader 139 | { 140 | ZTest Always Cull Off ZWrite Off Fog { Mode Off } Lighting Off Blend Off 141 | 142 | // 0 143 | Pass 144 | { 145 | CGPROGRAM 146 | #pragma vertex vert 147 | #pragma fragment fragCocMedian3 148 | ENDCG 149 | } 150 | 151 | // 1 152 | Pass 153 | { 154 | CGPROGRAM 155 | #pragma vertex vert 156 | #pragma fragment fragCocMedian3x3 157 | ENDCG 158 | } 159 | } 160 | 161 | FallBack Off 162 | } 163 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/DepthOfField/Resources/MedianFilter.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a058b22d4123add4b807e832604e5e7b 3 | timeCreated: 1449046205 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/LensAberrations.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1192c072f52ab9847a530ab4e58aa099 3 | folderAsset: yes 4 | timeCreated: 1454582772 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/LensAberrations/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5435043fbf77f174cb99bce89629af82 3 | folderAsset: yes 4 | timeCreated: 1454583125 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/LensAberrations/Editor/LensAberrationsEditor.cs: -------------------------------------------------------------------------------- 1 | using UnityEditor; 2 | using UnityEngine; 3 | using System.Linq; 4 | using System.Reflection; 5 | using System.Collections.Generic; 6 | 7 | namespace UnityStandardAssets.CinematicEffects 8 | { 9 | [CustomEditor(typeof(LensAberrations))] 10 | public class LensAberrationsEditor : Editor 11 | { 12 | private Dictionary> m_GroupFields = new Dictionary>(); 13 | 14 | private LensAberrations concreteTarget 15 | { 16 | get { return target as LensAberrations; } 17 | } 18 | 19 | private void PopulateMap(FieldInfo group) 20 | { 21 | var searchPath = group.Name + "."; 22 | foreach (var setting in group.FieldType.GetFields(BindingFlags.Instance | BindingFlags.Public)) 23 | { 24 | List settingsGroup; 25 | if (!m_GroupFields.TryGetValue(group, out settingsGroup)) 26 | { 27 | settingsGroup = new List(); 28 | m_GroupFields[group] = settingsGroup; 29 | } 30 | 31 | var property = serializedObject.FindProperty(searchPath + setting.Name); 32 | if (property != null) 33 | settingsGroup.Add(property); 34 | } 35 | } 36 | 37 | private void OnEnable() 38 | { 39 | var settingsGroups = typeof(LensAberrations).GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance).Where(x => x.GetCustomAttributes(typeof(LensAberrations.SettingsGroup), false).Any()); 40 | 41 | foreach (var settingGroup in settingsGroups) 42 | PopulateMap(settingGroup); 43 | } 44 | 45 | private void DrawFields() 46 | { 47 | foreach (var group in m_GroupFields) 48 | { 49 | var enabledField = group.Value.FirstOrDefault(x => x.propertyPath == group.Key.Name + ".enabled"); 50 | var groupProperty = serializedObject.FindProperty(group.Key.Name); 51 | 52 | GUILayout.Space(5); 53 | bool display = EditorGUIHelper.Header(groupProperty, enabledField); 54 | if (!display) 55 | continue; 56 | 57 | GUILayout.BeginHorizontal(); 58 | { 59 | GUILayout.Space(10); 60 | GUILayout.BeginVertical(); 61 | { 62 | GUILayout.Space(3); 63 | foreach (var field in group.Value.Where(x => x.propertyPath != group.Key.Name + ".enabled")) 64 | { 65 | EditorGUILayout.PropertyField(field); 66 | } 67 | } 68 | GUILayout.EndVertical(); 69 | } 70 | GUILayout.EndHorizontal(); 71 | } 72 | } 73 | 74 | public override void OnInspectorGUI() 75 | { 76 | serializedObject.Update(); 77 | DrawFields(); 78 | serializedObject.ApplyModifiedProperties(); 79 | } 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/LensAberrations/Editor/LensAberrationsEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8becb41f431ef90468376f6c5845e0bd 3 | timeCreated: 1454680396 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/Standard Assets/Effects/LensAberrations/LensAberrations.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ff5335a7357baa3489a469d0ca0f40f3 3 | timeCreated: 1454589487 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - m_Shader: {fileID: 4800000, guid: 136ab50fe2b9ad64d9c22adc3668abb7, type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/LensAberrations/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6580025651e0f284489694492cf3ce61 3 | folderAsset: yes 4 | timeCreated: 1454583120 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/LensAberrations/Resources/LensAberrations.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/LensAberrations" 2 | { 3 | Properties 4 | { 5 | _MainTex ("Texture", 2D) = "white" {} 6 | } 7 | SubShader 8 | { 9 | ZTest Always Cull Off ZWrite Off 10 | Fog { Mode off } 11 | 12 | CGINCLUDE 13 | 14 | #pragma fragmentoption ARB_precision_hint_fastest 15 | #include "UnityCG.cginc" 16 | #pragma target 3.0 17 | 18 | sampler2D _MainTex; 19 | float4 _MainTex_TexelSize; 20 | 21 | half4 _ChromaticAberration; 22 | 23 | half4 chromaticAberration(half2 uv) 24 | { 25 | half2 coords = 2.0 * uv - 1.0; 26 | half2 cd = coords * dot(coords, coords); 27 | half4 color = tex2D(_MainTex, uv); 28 | half3 fringe = tex2D(_MainTex, uv - cd * _ChromaticAberration.a).rgb; 29 | color.rgb = lerp(color.rgb, fringe, _ChromaticAberration.rgb); 30 | return color; 31 | } 32 | 33 | half4 _DistCenterScale; 34 | half3 _DistAmount; 35 | 36 | half2 distort(half2 uv) 37 | { 38 | uv = (uv - 0.5) * _DistAmount.z + 0.5; 39 | half2 ruv = _DistCenterScale.zw * (uv - 0.5 - _DistCenterScale.xy); 40 | half ru = length(ruv); 41 | 42 | #if DISTORT 43 | 44 | half wu = ru * _DistAmount.x; 45 | ru = tan(wu) * (1.0 / (ru * _DistAmount.y)); 46 | uv = uv + ruv * (ru - 1.0); 47 | 48 | #elif UNDISTORT 49 | 50 | ru = (1.0 / ru) * _DistAmount.x * atan(ru * _DistAmount.y); 51 | uv = uv + ruv * (ru - 1.0); 52 | 53 | #endif 54 | 55 | return uv; 56 | } 57 | 58 | half3 _VignetteColor; 59 | half3 _VignetteSettings; 60 | half2 _VignetteCenter; 61 | half _VignetteBlur; 62 | half _VignetteDesat; 63 | sampler2D _BlurTex; 64 | 65 | half4 vignette(half4 color, half2 uv) 66 | { 67 | #define _Intensity _VignetteSettings.x 68 | #define _Smoothness _VignetteSettings.y 69 | #define _Roundness _VignetteSettings.z 70 | 71 | half vfactor = 1.0; 72 | 73 | #if VIGNETTE_CLASSIC 74 | 75 | half2 d = (uv - _VignetteCenter) * _Intensity; 76 | vfactor = pow(saturate(1.0 - dot(d, d)), _Smoothness); 77 | 78 | #else 79 | 80 | half2 d = abs(uv - _VignetteCenter) * _Intensity; 81 | d = pow(d, _Roundness); 82 | 83 | #endif 84 | 85 | vfactor = pow(saturate(1.0 - dot(d, d)), _Smoothness); 86 | 87 | #if VIGNETTE_BLUR 88 | 89 | half2 coords = 2.0 * uv - 1.0; 90 | half3 blur = tex2D(_BlurTex, uv).rgb; 91 | color.rgb = lerp(color.rgb, blur, saturate(_VignetteBlur * dot(coords, coords))); 92 | 93 | #endif 94 | 95 | #if VIGNETTE_DESAT 96 | 97 | half lum = Luminance(color); 98 | color.rgb = lerp(lerp(lum.xxx, color.rgb, _VignetteDesat), color.rgb, vfactor); 99 | 100 | #endif 101 | 102 | color.rgb *= lerp(_VignetteColor, (1.0).xxx, vfactor); 103 | 104 | return color; 105 | } 106 | 107 | ENDCG 108 | 109 | // (0) Blur pre-pass 110 | Pass 111 | { 112 | CGPROGRAM 113 | #pragma vertex vert_blur_prepass 114 | #pragma fragment frag_blur_prepass 115 | #pragma multi_compile __ CHROMATIC_ABERRATION 116 | #pragma multi_compile __ DISTORT UNDISTORT 117 | #pragma 118 | 119 | half2 _BlurPass; 120 | 121 | struct v2f 122 | { 123 | half4 pos : SV_POSITION; 124 | half2 uv : TEXCOORD0; 125 | half4 uv1 : TEXCOORD1; 126 | half4 uv2 : TEXCOORD2; 127 | }; 128 | 129 | v2f vert_blur_prepass(appdata_img v) 130 | { 131 | v2f o; 132 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 133 | o.uv = v.texcoord.xy; 134 | 135 | #if UNITY_UV_STARTS_AT_TOP 136 | if (_MainTex_TexelSize.y < 0) 137 | o.uv.y = 1.0 - o.uv.y; 138 | #endif 139 | 140 | half2 d1 = 1.3846153846 * _BlurPass; 141 | half2 d2 = 3.2307692308 * _BlurPass; 142 | o.uv1 = half4(o.uv + d1, o.uv - d1); 143 | o.uv2 = half4(o.uv + d2, o.uv - d2); 144 | return o; 145 | } 146 | 147 | half4 fetch(half2 uv) 148 | { 149 | #if (DISTORT || UNDISTORT) 150 | uv = distort(uv); 151 | #endif 152 | 153 | #if CHROMATIC_ABERRATION 154 | return chromaticAberration(uv); 155 | #else 156 | return tex2D(_MainTex, uv); 157 | #endif 158 | } 159 | 160 | half4 frag_blur_prepass(v2f i) : SV_Target 161 | { 162 | half4 c = fetch(i.uv) * 0.2270270270; 163 | c += fetch(i.uv1.xy) * 0.3162162162; 164 | c += fetch(i.uv1.zw) * 0.3162162162; 165 | c += fetch(i.uv2.xy) * 0.0702702703; 166 | c += fetch(i.uv2.zw) * 0.0702702703; 167 | return c; 168 | } 169 | ENDCG 170 | } 171 | 172 | // (1) Chroma 173 | Pass 174 | { 175 | CGPROGRAM 176 | #pragma vertex vert_img 177 | #pragma fragment frag 178 | 179 | half4 frag(v2f_img i) : SV_Target 180 | { 181 | return chromaticAberration(i.uv); 182 | } 183 | ENDCG 184 | } 185 | 186 | // (2) Distort 187 | Pass 188 | { 189 | CGPROGRAM 190 | #pragma vertex vert_img 191 | #pragma fragment frag 192 | #pragma multi_compile DISTORT UNDISTORT 193 | 194 | half4 frag(v2f_img i) : SV_Target 195 | { 196 | half2 uv = distort(i.uv); 197 | return tex2D(_MainTex, uv); 198 | } 199 | ENDCG 200 | } 201 | 202 | // (3) Vignette 203 | Pass 204 | { 205 | CGPROGRAM 206 | #pragma vertex vert_img 207 | #pragma fragment frag 208 | #pragma multi_compile VIGNETTE_CLASSIC VIGNETTE_FILMIC 209 | #pragma multi_compile __ VIGNETTE_BLUR 210 | #pragma multi_compile __ VIGNETTE_DESAT 211 | 212 | half4 frag(v2f_img i) : SV_Target 213 | { 214 | half4 color = tex2D(_MainTex, i.uv); 215 | return vignette(color, i.uv); 216 | } 217 | ENDCG 218 | } 219 | 220 | // (4) Chroma / Distort 221 | Pass 222 | { 223 | CGPROGRAM 224 | #pragma vertex vert_img 225 | #pragma fragment frag 226 | #pragma multi_compile DISTORT UNDISTORT 227 | 228 | half4 frag(v2f_img i) : SV_Target 229 | { 230 | half2 uv = distort(i.uv); 231 | return chromaticAberration(uv); 232 | } 233 | ENDCG 234 | } 235 | 236 | // (5) Chroma / Vignette 237 | Pass 238 | { 239 | CGPROGRAM 240 | #pragma vertex vert_img 241 | #pragma fragment frag 242 | #pragma multi_compile VIGNETTE_CLASSIC VIGNETTE_FILMIC 243 | #pragma multi_compile __ VIGNETTE_BLUR 244 | #pragma multi_compile __ VIGNETTE_DESAT 245 | 246 | half4 frag(v2f_img i) : SV_Target 247 | { 248 | return vignette(chromaticAberration(i.uv), i.uv); 249 | } 250 | ENDCG 251 | } 252 | 253 | // (6) Distort / Vignette 254 | Pass 255 | { 256 | CGPROGRAM 257 | #pragma vertex vert_img 258 | #pragma fragment frag 259 | #pragma multi_compile DISTORT UNDISTORT 260 | #pragma multi_compile VIGNETTE_CLASSIC VIGNETTE_FILMIC 261 | #pragma multi_compile __ VIGNETTE_BLUR 262 | #pragma multi_compile __ VIGNETTE_DESAT 263 | 264 | half4 frag(v2f_img i) : SV_Target 265 | { 266 | half2 uv = distort(i.uv); 267 | return vignette(tex2D(_MainTex, uv), i.uv); 268 | } 269 | ENDCG 270 | } 271 | 272 | // (6) Chroma / Distort / Vignette 273 | Pass 274 | { 275 | CGPROGRAM 276 | #pragma vertex vert_img 277 | #pragma fragment frag 278 | #pragma multi_compile DISTORT UNDISTORT 279 | #pragma multi_compile VIGNETTE_CLASSIC VIGNETTE_FILMIC 280 | #pragma multi_compile __ VIGNETTE_BLUR 281 | #pragma multi_compile __ VIGNETTE_DESAT 282 | 283 | half4 frag(v2f_img i) : SV_Target 284 | { 285 | half2 uv = distort(i.uv); 286 | half4 chroma = chromaticAberration(uv); 287 | return vignette(chroma, i.uv); 288 | } 289 | ENDCG 290 | } 291 | } 292 | FallBack off 293 | } 294 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/LensAberrations/Resources/LensAberrations.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 136ab50fe2b9ad64d9c22adc3668abb7 3 | timeCreated: 1454583143 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ScreenSpaceReflection.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0190f05cacbdca84c932a2f2e0035c51 3 | folderAsset: yes 4 | timeCreated: 1448358989 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ScreenSpaceReflection/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4834a3e1213004b48b14703e6723c17c 3 | folderAsset: yes 4 | timeCreated: 1448359076 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ScreenSpaceReflection/Editor/ScreenSpaceReflectionEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Linq.Expressions; 5 | using System.Reflection; 6 | using UnityEditor; 7 | using UnityEngine; 8 | 9 | namespace UnityStandardAssets.CinematicEffects 10 | { 11 | [CustomPropertyDrawer(typeof(ScreenSpaceReflection.SSRSettings.LayoutAttribute))] 12 | public class LayoutDrawer : PropertyDrawer 13 | { 14 | private const float kHeadingSpace = 22.0f; 15 | 16 | static Styles m_Styles; 17 | 18 | private class Styles 19 | { 20 | public readonly GUIStyle header = "ShurikenModuleTitle"; 21 | 22 | internal Styles() 23 | { 24 | header.font = (new GUIStyle("Label")).font; 25 | header.border = new RectOffset(15, 7, 4, 4); 26 | header.fixedHeight = kHeadingSpace; 27 | header.contentOffset = new Vector2(20f, -2f); 28 | } 29 | } 30 | 31 | public override float GetPropertyHeight(SerializedProperty property, GUIContent label) 32 | { 33 | if (!property.isExpanded) 34 | return kHeadingSpace; 35 | 36 | var count = property.CountInProperty(); 37 | return EditorGUIUtility.singleLineHeight * count + 15; 38 | } 39 | 40 | public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) 41 | { 42 | if (m_Styles == null) 43 | m_Styles = new Styles(); 44 | 45 | position.height = EditorGUIUtility.singleLineHeight; 46 | property.isExpanded = Header(position, property.displayName, property.isExpanded); 47 | position.y += kHeadingSpace; 48 | 49 | if (!property.isExpanded) 50 | return; 51 | 52 | foreach (SerializedProperty child in property) 53 | { 54 | EditorGUI.PropertyField(position, child); 55 | position.y += EditorGUIUtility.singleLineHeight; 56 | } 57 | } 58 | 59 | private bool Header(Rect position, String title, bool display) 60 | { 61 | Rect rect = position; 62 | position.height = EditorGUIUtility.singleLineHeight; 63 | GUI.Box(rect, title, m_Styles.header); 64 | 65 | Rect toggleRect = new Rect(rect.x + 4f, rect.y + 2f, 13f, 13f); 66 | if (Event.current.type == EventType.Repaint) 67 | EditorStyles.foldout.Draw(toggleRect, false, false, display, false); 68 | 69 | Event e = Event.current; 70 | if (e.type == EventType.MouseDown && rect.Contains(e.mousePosition)) 71 | { 72 | display = !display; 73 | e.Use(); 74 | } 75 | return display; 76 | } 77 | } 78 | 79 | [CustomEditor(typeof(ScreenSpaceReflection))] 80 | internal class ScreenSpaceReflectionEditor : Editor 81 | { 82 | [NonSerialized] 83 | private List m_Properties = new List(); 84 | 85 | void OnEnable() 86 | { 87 | var settings = FieldFinder.GetField(x => x.settings); 88 | foreach (var setting in settings.FieldType.GetFields()) 89 | { 90 | var prop = settings.Name + "." + setting.Name; 91 | m_Properties.Add(serializedObject.FindProperty(prop)); 92 | } 93 | } 94 | 95 | public override void OnInspectorGUI() 96 | { 97 | serializedObject.Update(); 98 | 99 | EditorGUILayout.Space(); 100 | 101 | // move into the m_Settings fields... 102 | foreach (var property in m_Properties) 103 | EditorGUILayout.PropertyField(property); 104 | 105 | serializedObject.ApplyModifiedProperties(); 106 | } 107 | 108 | private void Apply(ScreenSpaceReflection.SSRSettings settings) 109 | { 110 | var validTargets = targets.Where(x => x is ScreenSpaceReflection).Cast().ToArray(); 111 | 112 | Undo.RecordObjects(validTargets, "Apply SSR Settings"); 113 | foreach (var validTarget in validTargets) 114 | validTarget.settings = settings; 115 | } 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ScreenSpaceReflection/Editor/ScreenSpaceReflectionEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: eb0236f80884a1f4793c96b4d2da5c68 3 | timeCreated: 1446039760 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/Standard Assets/Effects/ScreenSpaceReflection/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a19e50b158b32e6458d43c13406863ff 3 | folderAsset: yes 4 | timeCreated: 1453972687 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ScreenSpaceReflection/Resources/ScreenSpaceRaytrace.cginc: -------------------------------------------------------------------------------- 1 | /** 2 | \author Michael Mara and Morgan McGuire, Casual Effects. 2015. 3 | */ 4 | 5 | #ifndef SCREEN_SPACE_RAYTRACE_INCLUDED 6 | #define SCREEN_SPACE_RAYTRACE_INCLUDED 7 | 8 | 9 | sampler2D_float _CameraDepthTexture; 10 | 11 | 12 | float distanceSquared(float2 A, float2 B) 13 | { 14 | A -= B; 15 | return dot(A, A); 16 | } 17 | 18 | float distanceSquared(float3 A, float3 B) 19 | { 20 | A -= B; 21 | return dot(A, A); 22 | } 23 | 24 | void swap(inout float v0, inout float v1) 25 | { 26 | float temp = v0; 27 | v0 = v1; 28 | v1 = temp; 29 | } 30 | 31 | 32 | bool isIntersecting(float rayZMin, float rayZMax, float sceneZ, float layerThickness) 33 | { 34 | return (rayZMax >= sceneZ - layerThickness) && (rayZMin <= sceneZ); 35 | } 36 | 37 | void rayIterations(in bool traceBehindObjects, inout float2 P, inout float stepDirection, inout float end, inout int stepCount, inout int maxSteps, inout bool intersecting, 38 | inout float sceneZ, inout float2 dP, inout float3 Q, inout float3 dQ, inout float k, inout float dk, 39 | inout float rayZMin, inout float rayZMax, inout float prevZMaxEstimate, inout bool permute, inout float2 hitPixel, 40 | inout float2 invSize, inout float layerThickness) 41 | { 42 | bool stop = intersecting; 43 | 44 | UNITY_LOOP 45 | 46 | for (; (P.x * stepDirection) <= end && stepCount < maxSteps && !stop; P += dP, Q.z += dQ.z, k += dk, stepCount += 1) 47 | { 48 | // The depth range that the ray covers within this loop iteration. 49 | // Assume that the ray is moving in increasing z and swap if backwards. 50 | rayZMin = prevZMaxEstimate; 51 | //rayZMin = (dQ.z * -0.5 + Q.z) / (dk * -0.5 + k); 52 | // Compute the value at 1/2 pixel into the future 53 | rayZMax = (dQ.z * 0.5 + Q.z) / (dk * 0.5 + k); 54 | prevZMaxEstimate = rayZMax; 55 | 56 | if (rayZMin > rayZMax) 57 | { 58 | swap(rayZMin, rayZMax); 59 | } 60 | 61 | // Undo the homogeneous operation to obtain the camera-space 62 | // Q at each point 63 | hitPixel = permute ? P.yx : P; 64 | 65 | sceneZ = tex2Dlod(_CameraDepthTexture, float4(hitPixel * invSize,0,0)).r; 66 | sceneZ = -LinearEyeDepth(sceneZ); 67 | 68 | bool isBehind = (rayZMin <= sceneZ); 69 | intersecting = isBehind && (rayZMax >= sceneZ - layerThickness); 70 | stop = traceBehindObjects ? intersecting : isBehind; 71 | 72 | } // pixel on ray 73 | 74 | P -= dP, Q.z -= dQ.z, k -= dk; 75 | } 76 | 77 | /** 78 | \param csOrigin must have z < -0.01, and project within the valid screen rectangle 79 | \param stepRate Set to 1.0 by default, higher to step faster 80 | */ 81 | bool castDenseScreenSpaceRay 82 | (float3 csOrigin, 83 | float3 csDirection, 84 | float4x4 projectToPixelMatrix, 85 | float2 csZBufferSize, 86 | float3 clipInfo, 87 | float jitterFraction, 88 | int maxSteps, 89 | float layerThickness, 90 | float maxRayTraceDistance, 91 | out float2 hitPixel, 92 | int stepRate, 93 | bool traceBehindObjects, 94 | out float3 csHitPoint, 95 | out float stepCount) { 96 | 97 | float2 invSize = float2(1.0 / csZBufferSize.x, 1.0 / csZBufferSize.y); 98 | 99 | // Initialize to off screen 100 | hitPixel = float2(-1, -1); 101 | 102 | float nearPlaneZ = -0.01; 103 | // Clip ray to a near plane in 3D (doesn't have to be *the* near plane, although that would be a good idea) 104 | float rayLength = ((csOrigin.z + csDirection.z * maxRayTraceDistance) > nearPlaneZ) ? 105 | ((nearPlaneZ - csOrigin.z) / csDirection.z) : 106 | maxRayTraceDistance; 107 | 108 | float3 csEndPoint = csDirection * rayLength + csOrigin; 109 | 110 | // Project into screen space 111 | // This matrix has a lot of zeroes in it. We could expand 112 | // out these multiplies to avoid multiplying by zero 113 | // ...but 16 MADDs are not a big deal compared to what's ahead 114 | float4 H0 = mul(projectToPixelMatrix, float4(csOrigin, 1.0)); 115 | float4 H1 = mul(projectToPixelMatrix, float4(csEndPoint, 1.0)); 116 | 117 | // There are a lot of divisions by w that can be turned into multiplications 118 | // at some minor precision loss...and we need to interpolate these 1/w values 119 | // anyway. 120 | // 121 | // Because the caller was required to clip to the near plane, 122 | // this homogeneous division (projecting from 4D to 2D) is guaranteed 123 | // to succeed. 124 | float k0 = 1.0 / H0.w; 125 | float k1 = 1.0 / H1.w; 126 | 127 | // Screen-space endpoints 128 | float2 P0 = H0.xy * k0; 129 | float2 P1 = H1.xy * k1; 130 | 131 | // Switch the original points to values that interpolate linearly in 2D: 132 | float3 Q0 = csOrigin * k0; 133 | float3 Q1 = csEndPoint * k1; 134 | 135 | #if 1 // Clipping to the screen coordinates. We could simply modify maxSteps instead 136 | float yMax = csZBufferSize.y - 0.5; 137 | float yMin = 0.5; 138 | float xMax = csZBufferSize.x - 0.5; 139 | float xMin = 0.5; 140 | 141 | // 2D interpolation parameter 142 | float alpha = 0.0; 143 | // P0 must be in bounds 144 | if (P1.y > yMax || P1.y < yMin) { 145 | float yClip = (P1.y > yMax) ? yMax : yMin; 146 | float yAlpha = (P1.y - yClip) / (P1.y - P0.y); // Denominator is not zero, since P0 != P1 (or P0 would have been clipped!) 147 | alpha = yAlpha; 148 | } 149 | 150 | // P0 must be in bounds 151 | if (P1.x > xMax || P1.x < xMin) { 152 | float xClip = (P1.x > xMax) ? xMax : xMin; 153 | float xAlpha = (P1.x - xClip) / (P1.x - P0.x); // Denominator is not zero, since P0 != P1 (or P0 would have been clipped!) 154 | alpha = max(alpha, xAlpha); 155 | } 156 | 157 | // These are all in homogeneous space, so they interpolate linearly 158 | P1 = lerp(P1, P0, alpha); 159 | k1 = lerp(k1, k0, alpha); 160 | Q1 = lerp(Q1, Q0, alpha); 161 | #endif 162 | 163 | // We're doing this to avoid divide by zero (rays exactly parallel to an eye ray) 164 | P1 = (distanceSquared(P0, P1) < 0.0001) ? P0 + float2(0.01, 0.01) : P1; 165 | 166 | float2 delta = P1 - P0; 167 | 168 | // Assume horizontal 169 | bool permute = false; 170 | if (abs(delta.x) < abs(delta.y)) { 171 | // More-vertical line. Create a permutation that swaps x and y in the output 172 | permute = true; 173 | 174 | // Directly swizzle the inputs 175 | delta = delta.yx; 176 | P1 = P1.yx; 177 | P0 = P0.yx; 178 | } 179 | 180 | // From now on, "x" is the primary iteration direction and "y" is the secondary one 181 | 182 | float stepDirection = sign(delta.x); 183 | float invdx = stepDirection / delta.x; 184 | float2 dP = float2(stepDirection, invdx * delta.y); 185 | 186 | // Track the derivatives of Q and k 187 | float3 dQ = (Q1 - Q0) * invdx; 188 | float dk = (k1 - k0) * invdx; 189 | 190 | dP *= stepRate; 191 | dQ *= stepRate; 192 | dk *= stepRate; 193 | 194 | P0 += dP * jitterFraction; 195 | Q0 += dQ * jitterFraction; 196 | k0 += dk * jitterFraction; 197 | 198 | // Slide P from P0 to P1, (now-homogeneous) Q from Q0 to Q1, and k from k0 to k1 199 | float3 Q = Q0; 200 | float k = k0; 201 | 202 | // We track the ray depth at +/- 1/2 pixel to treat pixels as clip-space solid 203 | // voxels. Because the depth at -1/2 for a given pixel will be the same as at 204 | // +1/2 for the previous iteration, we actually only have to compute one value 205 | // per iteration. 206 | float prevZMaxEstimate = csOrigin.z; 207 | stepCount = 0.0; 208 | float rayZMax = prevZMaxEstimate, rayZMin = prevZMaxEstimate; 209 | float sceneZ = 100000; 210 | 211 | // P1.x is never modified after this point, so pre-scale it by 212 | // the step direction for a signed comparison 213 | float end = P1.x * stepDirection; 214 | 215 | bool intersecting = isIntersecting(rayZMin, rayZMax, sceneZ, layerThickness); 216 | // We only advance the z field of Q in the inner loop, since 217 | // Q.xy is never used until after the loop terminates 218 | 219 | //int rayIterations = min(maxSteps, stepsToGetOffscreen); 220 | 221 | 222 | float2 P = P0; 223 | 224 | int originalStepCount = 0; 225 | rayIterations(traceBehindObjects, P, stepDirection, end, originalStepCount, maxSteps, intersecting, 226 | sceneZ, dP, Q, dQ, k, dk, 227 | rayZMin, rayZMax, prevZMaxEstimate, permute, hitPixel, 228 | invSize, layerThickness); 229 | 230 | 231 | stepCount = originalStepCount; 232 | 233 | // Loop only advanced the Z component. Now that we know where we are going 234 | // update xy 235 | Q.xy += dQ.xy * stepCount; 236 | // Q is a vector, so we are trying to get by with 1 division instead of 3. 237 | csHitPoint = Q * (1.0 / k); 238 | 239 | return intersecting; 240 | } 241 | 242 | 243 | #endif // SCREEN_SPACE_RAYTRACE_INCLUDED 244 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ScreenSpaceReflection/Resources/ScreenSpaceRaytrace.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6f70a4658ebf5f947abc302c6b49a6ba 3 | timeCreated: 1449750676 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ScreenSpaceReflection/Resources/ScreenSpaceReflection.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 7e2fcc83af19e744787647ec0ac5d42c 3 | timeCreated: 1449750821 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/ScreenSpaceReflection/ScreenSpaceReflection.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: da3ff4a1bef2e8d47a1dfb734aa54de1 3 | timeCreated: 1433488439 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - ssrShader: {fileID: 4800000, guid: 7e2fcc83af19e744787647ec0ac5d42c, type: 3} 9 | executionOrder: 0 10 | icon: {instanceID: 0} 11 | userData: 12 | assetBundleName: 13 | assetBundleVariant: 14 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 33083b2f3c4953846890c256af8cc606 3 | folderAsset: yes 4 | timeCreated: 1435676891 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a232fdc401b30b549b2ac3a54d76f6cc 3 | folderAsset: yes 4 | timeCreated: 1448359112 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Editor/TonemappingColorGradingEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 64bb64b30a05a0d4b8afe58a356fc8fb 3 | timeCreated: 1441354689 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/Standard Assets/Effects/TonemappingColorGrading/Helpers.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 54915b6fdd14fd042add2d153a8b892d 3 | folderAsset: yes 4 | timeCreated: 1454073138 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Helpers/NeutralLUT16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Standard Assets/Effects/TonemappingColorGrading/Helpers/NeutralLUT16.png -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Helpers/NeutralLUT16.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 36c322ded1667bc4a867aea5e662c51b 3 | timeCreated: 1454073156 4 | licenseType: Store 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | linearTexture: 1 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: 3 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: 0 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: 5 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Helpers/NeutralLUT32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/Assets/Standard Assets/Effects/TonemappingColorGrading/Helpers/NeutralLUT32.png -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Helpers/NeutralLUT32.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6ac6980bae76ac241971e97191b6c30c 3 | timeCreated: 1454073159 4 | licenseType: Store 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 2 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 0 11 | linearTexture: 1 12 | correctGamma: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 0 25 | cubemapConvolution: 0 26 | cubemapConvolutionSteps: 7 27 | cubemapConvolutionExponent: 1.5 28 | seamlessCubemap: 0 29 | textureFormat: 3 30 | maxTextureSize: 2048 31 | textureSettings: 32 | filterMode: -1 33 | aniso: 0 34 | mipBias: -1 35 | wrapMode: -1 36 | nPOTScale: 1 37 | lightmap: 0 38 | rGBM: 0 39 | compressionQuality: 50 40 | allowsAlphaSplitting: 0 41 | spriteMode: 0 42 | spriteExtrude: 1 43 | spriteMeshType: 1 44 | alignment: 0 45 | spritePivot: {x: 0.5, y: 0.5} 46 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 47 | spritePixelsToUnits: 100 48 | alphaIsTransparency: 0 49 | textureType: 5 50 | buildTargetSettings: [] 51 | spriteSheet: 52 | sprites: [] 53 | outline: [] 54 | spritePackingTag: 55 | userData: 56 | assetBundleName: 57 | assetBundleVariant: 58 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 710c12a933657234f859808d82c5dd8b 3 | folderAsset: yes 4 | timeCreated: 1453901184 5 | licenseType: Store 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Resources/HistogramCompute.compute: -------------------------------------------------------------------------------- 1 | #include "UnityCG.cginc" 2 | 3 | RWStructuredBuffer _Histogram; 4 | Texture2D _Source; 5 | 6 | CBUFFER_START (Params) 7 | uint4 _Channels; 8 | uint _IsLinear; 9 | float _Height; 10 | CBUFFER_END 11 | 12 | // Gathering pass 13 | groupshared uint4 gs_histogram[256]; 14 | 15 | #pragma kernel KHistogramGather 16 | [numthreads(32,32,1)] // Needs at least 256 threads per group 17 | void KHistogramGather(uint3 id : SV_DispatchThreadID, uint3 _group_thread_id : SV_GroupThreadID) 18 | { 19 | const uint thread_id = _group_thread_id.y * 32 + _group_thread_id.x; 20 | 21 | if (thread_id < 256) 22 | gs_histogram[thread_id] = uint4(0, 0, 0, 0); 23 | 24 | uint sw, sh; 25 | _Source.GetDimensions(sw, sh); 26 | 27 | GroupMemoryBarrierWithGroupSync(); 28 | 29 | if (id.x < sw && id.y < sh) 30 | { 31 | // We want a gamma histogram (like Photoshop & all) 32 | float3 color = saturate(_Source[id.xy].xyz); 33 | if (_IsLinear > 0) 34 | color = LinearToGammaSpace(color); 35 | 36 | // Convert color & luminance to histogram bin 37 | uint3 idx_c = (uint3)(round(color * 255.0)); 38 | uint idx_l = (uint)(round(dot(color.rgb, float3(0.2126, 0.7152, 0.0722)) * 255.0)); 39 | 40 | // Fill the group shared histogram 41 | if (_Channels.r > 0) InterlockedAdd(gs_histogram[idx_c.x].x, 1); // Red 42 | if (_Channels.g > 0) InterlockedAdd(gs_histogram[idx_c.y].y, 1); // Green 43 | if (_Channels.b > 0) InterlockedAdd(gs_histogram[idx_c.z].z, 1); // Blue 44 | if (_Channels.a > 0) InterlockedAdd(gs_histogram[idx_l].w, 1); // Luminance 45 | } 46 | 47 | GroupMemoryBarrierWithGroupSync(); 48 | 49 | // Merge 50 | if (thread_id < 256) 51 | { 52 | uint4 h = gs_histogram[thread_id]; 53 | InterlockedAdd(_Histogram[thread_id].x, h.x); // Red 54 | InterlockedAdd(_Histogram[thread_id].y, h.y); // Green 55 | InterlockedAdd(_Histogram[thread_id].z, h.z); // Blue 56 | InterlockedAdd(_Histogram[thread_id].w, h.w); // Luminance 57 | } 58 | } 59 | 60 | // Scaling pass 61 | groupshared uint4 gs_pyramid[256]; 62 | 63 | #pragma kernel KHistogramScale 64 | [numthreads(16,16,1)] 65 | void KHistogramScale(uint3 _group_thread_id : SV_GroupThreadID) 66 | { 67 | const uint thread_id = _group_thread_id.y * 16 + _group_thread_id.x; 68 | gs_pyramid[thread_id] = _Histogram[thread_id]; 69 | 70 | GroupMemoryBarrierWithGroupSync(); 71 | 72 | // Parallel reduction to find the max value 73 | [unroll] 74 | for(uint i = 256 >> 1; i > 0; i >>= 1) 75 | { 76 | if(thread_id < i) 77 | gs_pyramid[thread_id] = max(gs_pyramid[thread_id], gs_pyramid[thread_id + i]); 78 | 79 | GroupMemoryBarrierWithGroupSync(); 80 | } 81 | 82 | // Actual scaling 83 | float4 factor = _Height / (float4)gs_pyramid[0]; 84 | _Histogram[thread_id] = (uint4)round(_Histogram[thread_id] * factor); 85 | } 86 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Resources/HistogramCompute.compute.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 5ee4b74fa28a3e74e89423dd49705fc5 3 | timeCreated: 1436170077 4 | licenseType: Store 5 | ComputeShaderImporter: 6 | currentBuildTarget: 5 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Resources/HistogramRender.shader: -------------------------------------------------------------------------------- 1 | Shader "Hidden/TonemappingColorGradingHistogram" 2 | { 3 | SubShader 4 | { 5 | ZTest Always Cull Off ZWrite Off 6 | Fog { Mode off } 7 | 8 | CGINCLUDE 9 | 10 | #pragma fragmentoption ARB_precision_hint_fastest 11 | #pragma target 5.0 12 | #include "UnityCG.cginc" 13 | 14 | struct v_data 15 | { 16 | float4 pos : SV_POSITION; 17 | float2 uv : TEXCOORD0; 18 | }; 19 | 20 | StructuredBuffer _Histogram; 21 | float2 _Size; 22 | uint _Channel; 23 | float4 _ColorR; 24 | float4 _ColorG; 25 | float4 _ColorB; 26 | float4 _ColorL; 27 | 28 | v_data vert(appdata_img v) 29 | { 30 | v_data o; 31 | o.pos = mul(UNITY_MATRIX_MVP, v.vertex); 32 | o.uv = v.texcoord; 33 | return o; 34 | } 35 | 36 | float4 frag_channel(v_data i) : SV_Target 37 | { 38 | const float4 COLORS[4] = { _ColorR, _ColorG, _ColorB, _ColorL }; 39 | 40 | float remapI = i.uv.x * 255.0; 41 | uint index = floor(remapI); 42 | float delta = frac(remapI); 43 | float v1 = _Histogram[index][_Channel]; 44 | float v2 = _Histogram[min(index + 1, 255)][_Channel]; 45 | float h = v1 * (1.0 - delta) + v2 * delta; 46 | uint y = (uint)round(i.uv.y * _Size.y); 47 | 48 | float4 color = float4(0.0, 0.0, 0.0, 0.0); 49 | float fill = step(y, h); 50 | color = lerp(color, COLORS[_Channel], fill); 51 | return color; 52 | } 53 | 54 | float4 frag_rgb(v_data i) : SV_Target 55 | { 56 | const float4 COLORS[3] = { _ColorR, _ColorG, _ColorB }; 57 | 58 | float4 targetColor = float4(0.0, 0.0, 0.0, 0.0); 59 | float4 emptyColor = float4(0.0, 0.0, 0.0, 0.0); 60 | float fill = 0; 61 | 62 | for (int j = 0; j < 3; j++) 63 | { 64 | float remapI = i.uv.x * 255.0; 65 | uint index = floor(remapI); 66 | float delta = frac(remapI); 67 | float v1 = _Histogram[index][j]; 68 | float v2 = _Histogram[min(index + 1, 255)][j]; 69 | float h = v1 * (1.0 - delta) + v2 * delta; 70 | uint y = (uint)round(i.uv.y * _Size.y); 71 | float fill = step(y, h); 72 | float4 color = lerp(emptyColor, COLORS[j], fill); 73 | targetColor += color; 74 | } 75 | 76 | return saturate(targetColor); 77 | } 78 | 79 | ENDCG 80 | 81 | // (0) Channel 82 | Pass 83 | { 84 | CGPROGRAM 85 | 86 | #pragma vertex vert 87 | #pragma fragment frag_channel 88 | 89 | ENDCG 90 | } 91 | 92 | // (1) RGB 93 | Pass 94 | { 95 | CGPROGRAM 96 | 97 | #pragma vertex vert 98 | #pragma fragment frag_rgb 99 | 100 | ENDCG 101 | } 102 | } 103 | FallBack off 104 | } 105 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Resources/HistogramRender.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9a8e838691462194482a43a02e424876 3 | timeCreated: 1436173774 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Resources/TonemappingColorGrading.cginc: -------------------------------------------------------------------------------- 1 | #include "UnityCG.cginc" 2 | 3 | sampler2D _MainTex; 4 | half4 _MainTex_TexelSize; 5 | 6 | half _Exposure; 7 | half _ToneCurveRange; 8 | sampler2D _ToneCurve; 9 | half4 _NeutralTonemapperParams1; 10 | half4 _NeutralTonemapperParams2; 11 | 12 | sampler2D _InternalLutTex; 13 | half3 _InternalLutParams; 14 | 15 | sampler2D _UserLutTex; 16 | half4 _UserLutParams; 17 | 18 | sampler2D _LumTex; 19 | half _AdaptationSpeed; 20 | half _MiddleGrey; 21 | half _AdaptationMin; 22 | half _AdaptationMax; 23 | 24 | inline half LinToPerceptual(half3 color) 25 | { 26 | half lum = Luminance(color); 27 | return log(max(lum, 0.001)); 28 | } 29 | 30 | inline half PerceptualToLin(half f) 31 | { 32 | return exp(f); 33 | } 34 | 35 | half4 frag_log(v2f_img i) : SV_Target 36 | { 37 | half sum = 0.0; 38 | sum += LinToPerceptual(tex2D(_MainTex, i.uv + _MainTex_TexelSize.xy * half2(-1,-1)).rgb); 39 | sum += LinToPerceptual(tex2D(_MainTex, i.uv + _MainTex_TexelSize.xy * half2( 1, 1)).rgb); 40 | sum += LinToPerceptual(tex2D(_MainTex, i.uv + _MainTex_TexelSize.xy * half2(-1, 1)).rgb); 41 | sum += LinToPerceptual(tex2D(_MainTex, i.uv + _MainTex_TexelSize.xy * half2( 1,-1)).rgb); 42 | half avg = sum / 4.0; 43 | return half4(avg, avg, avg, avg); 44 | } 45 | 46 | half4 frag_exp(v2f_img i) : SV_Target 47 | { 48 | half sum = 0.0; 49 | sum += tex2D(_MainTex, i.uv + _MainTex_TexelSize.xy * half2(-1,-1)).x; 50 | sum += tex2D(_MainTex, i.uv + _MainTex_TexelSize.xy * half2( 1, 1)).x; 51 | sum += tex2D(_MainTex, i.uv + _MainTex_TexelSize.xy * half2( 1,-1)).x; 52 | sum += tex2D(_MainTex, i.uv + _MainTex_TexelSize.xy * half2(-1, 1)).x; 53 | half avg = PerceptualToLin(sum / 4.0); 54 | return half4(avg, avg, avg, saturate(0.0125 * _AdaptationSpeed)); 55 | } 56 | 57 | half3 apply_lut(sampler2D tex, half3 uvw, half3 scaleOffset) 58 | { 59 | // Strip format where `height = sqrt(width)` 60 | uvw.z *= scaleOffset.z; 61 | half shift = floor(uvw.z); 62 | uvw.xy = uvw.xy * scaleOffset.z * scaleOffset.xy + scaleOffset.xy * 0.5; 63 | uvw.x += shift * scaleOffset.y; 64 | uvw.xyz = lerp(tex2D(tex, uvw.xy).rgb, tex2D(tex, uvw.xy + half2(scaleOffset.y, 0)).rgb, uvw.z - shift); 65 | return uvw; 66 | } 67 | 68 | half3 ToCIE(half3 color) 69 | { 70 | // RGB -> XYZ conversion 71 | // http://www.w3.org/Graphics/Color/sRGB 72 | // The official sRGB to XYZ conversion matrix is (following ITU-R BT.709) 73 | // 0.4125 0.3576 0.1805 74 | // 0.2126 0.7152 0.0722 75 | // 0.0193 0.1192 0.9505 76 | half3x3 RGB2XYZ = { 0.5141364, 0.3238786, 0.16036376, 0.265068, 0.67023428, 0.06409157, 0.0241188, 0.1228178, 0.84442666 }; 77 | half3 XYZ = mul(RGB2XYZ, color.rgb); 78 | 79 | // XYZ -> Yxy conversion 80 | half3 Yxy; 81 | Yxy.r = XYZ.g; 82 | half temp = dot(half3(1.0, 1.0, 1.0), XYZ.rgb); 83 | Yxy.gb = XYZ.rg / temp; 84 | return Yxy; 85 | } 86 | 87 | half3 FromCIE(half3 Yxy) 88 | { 89 | // Yxy -> XYZ conversion 90 | half3 XYZ; 91 | XYZ.r = Yxy.r * Yxy.g / Yxy.b; 92 | XYZ.g = Yxy.r; 93 | 94 | // Copy luminance Y 95 | XYZ.b = Yxy.r * (1 - Yxy.g - Yxy.b) / Yxy.b; 96 | 97 | // XYZ -> RGB conversion 98 | // The official XYZ to sRGB conversion matrix is (following ITU-R BT.709) 99 | // 3.2410 -1.5374 -0.4986 100 | // -0.9692 1.8760 0.0416 101 | // 0.0556 -0.2040 1.0570 102 | half3x3 XYZ2RGB = { 2.5651, -1.1665, -0.3986, -1.0217, 1.9777, 0.0439, 0.0753, -0.2543, 1.1892 }; 103 | return mul(XYZ2RGB, XYZ); 104 | } 105 | 106 | half3 tonemapACES(half3 color) 107 | { 108 | color *= _Exposure; 109 | 110 | // See https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ 111 | const half a = 2.51; 112 | const half b = 0.03; 113 | const half c = 2.43; 114 | const half d = 0.59; 115 | const half e = 0.14; 116 | return saturate((color * (a * color + b)) / (color * (c * color + d) + e)); 117 | } 118 | 119 | half3 tonemapPhotographic(half3 color) 120 | { 121 | color *= _Exposure; 122 | return 1.0 - exp2(-color); 123 | } 124 | 125 | half3 tonemapHable(half3 color) 126 | { 127 | const half a = 0.15; 128 | const half b = 0.50; 129 | const half c = 0.10; 130 | const half d = 0.20; 131 | const half e = 0.02; 132 | const half f = 0.30; 133 | const half w = 11.2; 134 | 135 | color *= _Exposure * 2.0; 136 | half3 curr = ((color * (a * color + c * b) + d * e) / (color * (a * color + b) + d * f)) - e / f; 137 | color = w; 138 | half3 whiteScale = 1.0 / (((color * (a * color + c * b) + d * e) / (color * (a * color + b) + d * f)) - e / f); 139 | return curr * whiteScale; 140 | } 141 | 142 | half3 tonemapHejlDawson(half3 color) 143 | { 144 | const half a = 6.2; 145 | const half b = 0.5; 146 | const half c = 1.7; 147 | const half d = 0.06; 148 | 149 | color *= _Exposure; 150 | color = max((0.0).xxx, color - (0.004).xxx); 151 | color = (color * (a * color + b)) / (color * (a * color + c) + d); 152 | return color * color; 153 | } 154 | 155 | half3 tonemapReinhard(half3 color) 156 | { 157 | half lum = Luminance(color); 158 | half lumTm = lum * _Exposure; 159 | half scale = lumTm / (1.0 + lumTm); 160 | return color * scale / lum; 161 | } 162 | 163 | half3 tonemapCurve(half3 color) 164 | { 165 | color *= _Exposure; 166 | half3 cie = ToCIE(color); 167 | half newLum = tex2D(_ToneCurve, half2(cie.r * _ToneCurveRange, 0.5)).r; 168 | cie.r = newLum; 169 | return FromCIE(cie); 170 | } 171 | 172 | half3 neutralCurve(half3 x, half a, half b, half c, half d, half e, half f) 173 | { 174 | return ((x * (a * x + c * b) + d * e) / (x * (a * x + b) + d * f)) - e / f; 175 | } 176 | 177 | half3 tonemapNeutral(half3 color) 178 | { 179 | color *= _Exposure; 180 | 181 | // Tonemap 182 | half a = _NeutralTonemapperParams1.x; 183 | half b = _NeutralTonemapperParams1.y; 184 | half c = _NeutralTonemapperParams1.z; 185 | half d = _NeutralTonemapperParams1.w; 186 | half e = _NeutralTonemapperParams2.x; 187 | half f = _NeutralTonemapperParams2.y; 188 | half whiteLevel = _NeutralTonemapperParams2.z; 189 | half whiteClip = _NeutralTonemapperParams2.w; 190 | 191 | half3 whiteScale = (1.0).xxx / neutralCurve(whiteLevel, a, b, c, d, e, f); 192 | color = neutralCurve(color * whiteScale, a, b, c, d, e, f); 193 | color *= whiteScale; 194 | 195 | // Post-curve white point adjustment 196 | color = color / whiteClip.xxx; 197 | 198 | return color; 199 | } 200 | 201 | half4 frag_tcg(v2f_img i) : SV_Target 202 | { 203 | half4 color = tex2D(_MainTex, i.uv); 204 | 205 | #if UNITY_COLORSPACE_GAMMA 206 | color.rgb = GammaToLinearSpace(color.rgb); 207 | #endif 208 | 209 | #if ENABLE_EYE_ADAPTATION 210 | // Fast eye adaptation 211 | half avg_luminance = tex2D(_LumTex, i.uv).x; 212 | half linear_exposure = _MiddleGrey / avg_luminance; 213 | color.rgb *= max(_AdaptationMin, min(_AdaptationMax, linear_exposure)); 214 | #endif 215 | 216 | #if defined(TONEMAPPING_ACES) 217 | color.rgb = tonemapACES(color.rgb); 218 | #elif defined(TONEMAPPING_CURVE) 219 | color.rgb = tonemapCurve(color.rgb); 220 | #elif defined(TONEMAPPING_HABLE) 221 | color.rgb = tonemapHable(color.rgb); 222 | #elif defined(TONEMAPPING_HEJL_DAWSON) 223 | color.rgb = tonemapHejlDawson(color.rgb); 224 | #elif defined(TONEMAPPING_PHOTOGRAPHIC) 225 | color.rgb = tonemapPhotographic(color.rgb); 226 | #elif defined(TONEMAPPING_REINHARD) 227 | color.rgb = tonemapReinhard(color.rgb); 228 | #elif defined(TONEMAPPING_NEUTRAL) 229 | color.rgb = tonemapNeutral(color.rgb); 230 | #endif 231 | 232 | #if ENABLE_COLOR_GRADING 233 | // LUT color grading 234 | color.rgb = apply_lut(_InternalLutTex, saturate(color.rgb), _InternalLutParams); 235 | #endif 236 | 237 | #if ENABLE_DITHERING 238 | // Interleaved Gradient Noise from http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare (slide 122) 239 | half3 magic = float3(0.06711056, 0.00583715, 52.9829189); 240 | half gradient = frac(magic.z * frac(dot(i.uv / _MainTex_TexelSize, magic.xy))) / 255.0; 241 | color.rgb -= gradient.xxx; 242 | #endif 243 | 244 | #if UNITY_COLORSPACE_GAMMA 245 | color.rgb = LinearToGammaSpace(color.rgb); 246 | #endif 247 | 248 | #if ENABLE_USER_LUT 249 | #if !UNITY_COLORSPACE_GAMMA 250 | half3 lc = apply_lut(_UserLutTex, saturate(LinearToGammaSpace(color.rgb)), _UserLutParams.xyz); 251 | lc = GammaToLinearSpace(lc); 252 | #else 253 | half3 lc = apply_lut(_UserLutTex, saturate(color.rgb), _UserLutParams.xyz); 254 | #endif 255 | 256 | color.rgb = lerp(color.rgb, lc, _UserLutParams.w); 257 | #endif 258 | 259 | return color; 260 | } 261 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Resources/TonemappingColorGrading.cginc.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a7e68b07525bc7f459ff03bf6cba782a 3 | timeCreated: 1453723607 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/Resources/TonemappingColorGrading.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 964b34bbab7f5e64fa40f37eaccac1ad 3 | timeCreated: 1435513939 4 | licenseType: Store 5 | ShaderImporter: 6 | defaultTextures: [] 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/Standard Assets/Effects/TonemappingColorGrading/TonemappingColorGrading.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 58a7625302996c94ba07a8ca3351f668 3 | timeCreated: 1453901501 4 | licenseType: Store 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: 8 | - m_HistogramComputeShader: {fileID: 7200000, guid: 5ee4b74fa28a3e74e89423dd49705fc5, 9 | type: 3} 10 | - m_HistogramShader: {fileID: 4800000, guid: 9a8e838691462194482a43a02e424876, type: 3} 11 | - m_Shader: {fileID: 4800000, guid: 964b34bbab7f5e64fa40f37eaccac1ad, type: 3} 12 | executionOrder: 0 13 | icon: {instanceID: 0} 14 | userData: 15 | assetBundleName: 16 | assetBundleVariant: 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 World of Zero 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.5.0f3 2 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WorldOfZero/FractalGenerator/3eb747997301182e0ba6eb7dbdb56b0c43f28ad3/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Fractal Generator 2 | Unity 3D project for generating fractals and exploring components and messaging. 3 | 4 | # How It Was Made 5 | This Fractal Generator was made as a part of my World of Zero project. The code is open source, and how it was written was recorded. Below is a link to the videos demonstrating how it was made. 6 | [![Fractals All The Way Down! - YouTube Video](https://img.youtube.com/vi/VXegg-HGT0s/0.jpg)](https://www.youtube.com/watch?v=VXegg-HGT0s) 7 | 8 | Part two of the series includes the addition of physics to our Fractal. Everything is better with physically simulated movement! 9 | 10 | [![Physically Simulating the Generated Fractals - YouTube Video](https://img.youtube.com/vi/EMQOhrN453g/0.jpg)](https://www.youtube.com/watch?v=EMQOhrN453g) 11 | 12 | # Extending the Project 13 | This project is extremely simple to extend. Create a new component in Unity in Unity and add a function to accept the message. The function just needs to be named and have arguments similar to this `Generated(int index)` 14 | 15 | Once you have that done simply use your script to modify your element. Once that is done, attach the component to the root element and hit play. It's that easy. If you need more help watch the video above to see how it is done. 16 | 17 | Once you have your component finished create a pull request and let's get it added back in to the project so others can see it! 18 | --------------------------------------------------------------------------------