├── .gitignore ├── Assets ├── ColorSuite.meta ├── ColorSuite │ ├── ColorSuite.cs │ ├── ColorSuite.cs.meta │ ├── Editor.meta │ ├── Editor │ │ ├── ColorSuiteEditor.cs │ │ └── ColorSuiteEditor.cs.meta │ ├── Shader.meta │ └── Shader │ │ ├── ColorSuite.shader │ │ └── ColorSuite.shader.meta ├── MyGame.meta ├── MyGame │ ├── Materials.meta │ ├── Materials │ │ ├── MovieMat.mat │ │ └── MovieMat.mat.meta │ ├── Models.meta │ ├── Models │ │ ├── Materials.meta │ │ ├── Materials │ │ │ ├── phong1.mat │ │ │ └── phong1.mat.meta │ │ ├── Sphere100.fbx │ │ └── Sphere100.fbx.meta │ ├── Movies.meta │ ├── Scripts.meta │ ├── Scripts │ │ ├── MouseLook.cs │ │ ├── MouseLook.cs.meta │ │ ├── MoviePlay.cs │ │ └── MoviePlay.cs.meta │ ├── Test.unity │ └── Test.unity.meta ├── StreamingAssets.meta └── StreamingAssets │ ├── IMG_4865.MP4 │ └── IMG_4865.MP4.meta ├── LICENSE ├── ProjectSettings ├── AudioManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset ├── UnityAdsSettings.asset └── UnityAnalyticsManager.asset └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | [Ll]ibrary/ 2 | [Tt]emp/ 3 | [Oo]bj/ 4 | [Bb]uild/ 5 | [Oo]ut/ 6 | 7 | # Autogenerated VS/MD solution and project files 8 | *.csproj 9 | *.unityproj 10 | *.sln 11 | *.suo 12 | *.tmp 13 | *.user 14 | *.userprefs 15 | *.pidb 16 | *.booproj 17 | 18 | # Unity3D generated meta files 19 | *.pidb.meta 20 | 21 | # Unity3D Generated File On Crash Reports 22 | sysinfo.txt 23 | -------------------------------------------------------------------------------- /Assets/ColorSuite.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49223daaf567b486db70f812b484f1af 3 | folderAsset: yes 4 | timeCreated: 1445250484 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/ColorSuite/ColorSuite.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2014, 2015 Keijiro Takahashi 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | // the Software, and to permit persons to whom the Software is furnished to do so, 9 | // subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | using UnityEngine; 22 | using System.Collections; 23 | 24 | [ExecuteInEditMode] 25 | [ImageEffectTransformsToLDR] 26 | [RequireComponent(typeof(Camera))] 27 | [AddComponentMenu("Image Effects/Color Adjustments/Color Suite")] 28 | public class ColorSuite : MonoBehaviour 29 | { 30 | #region Public Properties 31 | 32 | // White balance. 33 | [SerializeField] float _colorTemp = 0.0f; 34 | [SerializeField] float _colorTint = 0.0f; 35 | 36 | public float colorTemp { 37 | get { return _colorTemp; } 38 | set { _colorTemp = value; } 39 | } 40 | public float colorTint { 41 | get { return _colorTint; } 42 | set { _colorTint = value; } 43 | } 44 | 45 | // Tone mapping. 46 | [SerializeField] bool _toneMapping = false; 47 | [SerializeField] float _exposure = 1.0f; 48 | 49 | public bool toneMapping { 50 | get { return _toneMapping; } 51 | set { _toneMapping = value; } 52 | } 53 | public float exposure { 54 | get { return _exposure; } 55 | set { _exposure = value; } 56 | } 57 | 58 | // Color saturation. 59 | [SerializeField] float _saturation = 1.0f; 60 | 61 | public float saturation { 62 | get { return _saturation; } 63 | set { _saturation = value; } 64 | } 65 | 66 | // Curves. 67 | [SerializeField] AnimationCurve _rCurve = AnimationCurve.Linear(0, 0, 1, 1); 68 | [SerializeField] AnimationCurve _gCurve = AnimationCurve.Linear(0, 0, 1, 1); 69 | [SerializeField] AnimationCurve _bCurve = AnimationCurve.Linear(0, 0, 1, 1); 70 | [SerializeField] AnimationCurve _cCurve = AnimationCurve.Linear(0, 0, 1, 1); 71 | 72 | public AnimationCurve redCurve { 73 | get { return _rCurve; } 74 | set { _rCurve = value; UpdateLUT(); } 75 | } 76 | public AnimationCurve greenCurve { 77 | get { return _gCurve; } 78 | set { _gCurve = value; UpdateLUT(); } 79 | } 80 | public AnimationCurve blueCurve { 81 | get { return _bCurve; } 82 | set { _bCurve = value; UpdateLUT(); } 83 | } 84 | public AnimationCurve rgbCurve { 85 | get { return _cCurve; } 86 | set { _cCurve = value; UpdateLUT(); } 87 | } 88 | 89 | // Dithering. 90 | public enum DitherMode { Off, Ordered, Triangular } 91 | [SerializeField] DitherMode _ditherMode = DitherMode.Off; 92 | 93 | public DitherMode ditherMode { 94 | get { return _ditherMode; } 95 | set { _ditherMode = value; } 96 | } 97 | 98 | #endregion 99 | 100 | #region Internal Properties 101 | 102 | // Reference to the shader. 103 | [SerializeField] Shader shader; 104 | 105 | // Temporary objects. 106 | Material _material; 107 | Texture2D _lutTexture; 108 | 109 | #endregion 110 | 111 | #region Local Functions 112 | 113 | // RGBM encoding. 114 | static Color EncodeRGBM(float r, float g, float b) 115 | { 116 | var a = Mathf.Max(Mathf.Max(r, g), Mathf.Max(b, 1e-6f)); 117 | a = Mathf.Ceil(a * 255) / 255; 118 | return new Color(r / a, g / a, b / a, a); 119 | } 120 | 121 | // An analytical model of chromaticity of the standard illuminant, by Judd et al. 122 | // http://en.wikipedia.org/wiki/Standard_illuminant#Illuminant_series_D 123 | // Slightly modifed to adjust it with the D65 white point (x=0.31271, y=0.32902). 124 | static float StandardIlluminantY(float x) 125 | { 126 | return 2.87f * x - 3.0f * x * x - 0.27509507f; 127 | } 128 | 129 | // CIE xy chromaticity to CAT02 LMS. 130 | // http://en.wikipedia.org/wiki/LMS_color_space#CAT02 131 | static Vector3 CIExyToLMS(float x, float y) 132 | { 133 | var Y = 1.0f; 134 | var X = Y * x / y; 135 | var Z = Y * (1.0f - x - y) / y; 136 | 137 | var L = 0.7328f * X + 0.4296f * Y - 0.1624f * Z; 138 | var M = -0.7036f * X + 1.6975f * Y + 0.0061f * Z; 139 | var S = 0.0030f * X + 0.0136f * Y + 0.9834f * Z; 140 | 141 | return new Vector3(L, M, S); 142 | } 143 | 144 | #endregion 145 | 146 | #region Private Methods 147 | 148 | // Set up the temporary assets. 149 | void Setup() 150 | { 151 | if (_material == null) 152 | { 153 | _material = new Material(shader); 154 | _material.hideFlags = HideFlags.DontSave; 155 | } 156 | 157 | if (_lutTexture == null) 158 | { 159 | _lutTexture = new Texture2D(512, 1, TextureFormat.ARGB32, false, true); 160 | _lutTexture.hideFlags = HideFlags.DontSave; 161 | _lutTexture.wrapMode = TextureWrapMode.Clamp; 162 | UpdateLUT(); 163 | } 164 | } 165 | 166 | // Update the LUT texture. 167 | void UpdateLUT() 168 | { 169 | for (var x = 0; x < _lutTexture.width; x++) 170 | { 171 | var u = 1.0f / (_lutTexture.width - 1) * x; 172 | var r = _cCurve.Evaluate(_rCurve.Evaluate(u)); 173 | var g = _cCurve.Evaluate(_gCurve.Evaluate(u)); 174 | var b = _cCurve.Evaluate(_bCurve.Evaluate(u)); 175 | _lutTexture.SetPixel(x, 0, EncodeRGBM(r, g, b)); 176 | } 177 | _lutTexture.Apply(); 178 | } 179 | 180 | // Calculate the color balance coefficients. 181 | Vector3 CalculateColorBalance() 182 | { 183 | // Get the CIE xy chromaticity of the reference white point. 184 | // Note: 0.31271 = x value on the D65 white point 185 | var x = 0.31271f - _colorTemp * (_colorTemp < 0.0f ? 0.1f : 0.05f); 186 | var y = StandardIlluminantY(x) + _colorTint * 0.05f; 187 | 188 | // Calculate the coefficients in the LMS space. 189 | var w1 = new Vector3(0.949237f, 1.03542f, 1.08728f); // D65 white point 190 | var w2 = CIExyToLMS(x, y); 191 | return new Vector3(w1.x / w2.x, w1.y / w2.y, w1.z / w2.z); 192 | } 193 | 194 | #endregion 195 | 196 | #region Monobehaviour Functions 197 | 198 | void Start() 199 | { 200 | Setup(); 201 | } 202 | 203 | void OnValidate() 204 | { 205 | Setup(); 206 | UpdateLUT(); 207 | } 208 | 209 | void Reset() 210 | { 211 | Setup(); 212 | UpdateLUT(); 213 | } 214 | 215 | void OnRenderImage(RenderTexture source, RenderTexture destination) 216 | { 217 | var linear = QualitySettings.activeColorSpace == ColorSpace.Linear; 218 | 219 | Setup(); 220 | 221 | if (linear) 222 | _material.EnableKeyword("COLORSPACE_LINEAR"); 223 | else 224 | _material.DisableKeyword("COLORSPACE_LINEAR"); 225 | 226 | if (_colorTemp != 0.0f || _colorTint != 0.0f) 227 | { 228 | _material.EnableKeyword("BALANCING_ON"); 229 | _material.SetVector("_Balance", CalculateColorBalance()); 230 | } 231 | else 232 | _material.DisableKeyword("BALANCING_ON"); 233 | 234 | if (_toneMapping && linear) 235 | { 236 | _material.EnableKeyword("TONEMAPPING_ON"); 237 | _material.SetFloat("_Exposure", _exposure); 238 | } 239 | else 240 | _material.DisableKeyword("TONEMAPPING_ON"); 241 | 242 | _material.SetTexture("_Curves", _lutTexture); 243 | _material.SetFloat("_Saturation", _saturation); 244 | 245 | if (_ditherMode == DitherMode.Ordered) 246 | { 247 | _material.EnableKeyword("DITHER_ORDERED"); 248 | _material.DisableKeyword("DITHER_TRIANGULAR"); 249 | } 250 | else if (_ditherMode == DitherMode.Triangular) 251 | { 252 | _material.DisableKeyword("DITHER_ORDERED"); 253 | _material.EnableKeyword("DITHER_TRIANGULAR"); 254 | } 255 | else 256 | { 257 | _material.DisableKeyword("DITHER_ORDERED"); 258 | _material.DisableKeyword("DITHER_TRIANGULAR"); 259 | } 260 | 261 | Graphics.Blit(source, destination, _material); 262 | } 263 | 264 | #endregion 265 | } 266 | -------------------------------------------------------------------------------- /Assets/ColorSuite/ColorSuite.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 10593b7d510b64560a297a8af1356dcb 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: 6 | - shader: {fileID: 4800000, guid: dc9775b65c52747e69fc4c854c00d696, type: 3} 7 | executionOrder: 0 8 | icon: {instanceID: 0} 9 | userData: 10 | -------------------------------------------------------------------------------- /Assets/ColorSuite/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cd386d94948a6489a9baa003c1f5b171 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/ColorSuite/Editor/ColorSuiteEditor.cs: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2014, 2015 Keijiro Takahashi 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | // the Software, and to permit persons to whom the Software is furnished to do so, 9 | // subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | using UnityEngine; 22 | using UnityEditor; 23 | using System.Collections; 24 | 25 | [CustomEditor(typeof(ColorSuite)), CanEditMultipleObjects] 26 | public class ColorSuiteEditor : Editor 27 | { 28 | SerializedProperty propColorTemp; 29 | SerializedProperty propColorTint; 30 | 31 | SerializedProperty propToneMapping; 32 | SerializedProperty propExposure; 33 | 34 | SerializedProperty propSaturation; 35 | 36 | SerializedProperty propRCurve; 37 | SerializedProperty propGCurve; 38 | SerializedProperty propBCurve; 39 | SerializedProperty propCCurve; 40 | 41 | SerializedProperty propDitherMode; 42 | 43 | GUIContent labelColorTemp; 44 | GUIContent labelColorTint; 45 | 46 | void OnEnable() 47 | { 48 | propColorTemp = serializedObject.FindProperty("_colorTemp"); 49 | propColorTint = serializedObject.FindProperty("_colorTint"); 50 | 51 | propToneMapping = serializedObject.FindProperty("_toneMapping"); 52 | propExposure = serializedObject.FindProperty("_exposure"); 53 | 54 | propSaturation = serializedObject.FindProperty("_saturation"); 55 | 56 | propRCurve = serializedObject.FindProperty("_rCurve"); 57 | propGCurve = serializedObject.FindProperty("_gCurve"); 58 | propBCurve = serializedObject.FindProperty("_bCurve"); 59 | propCCurve = serializedObject.FindProperty("_cCurve"); 60 | 61 | propDitherMode = serializedObject.FindProperty("_ditherMode"); 62 | 63 | labelColorTemp = new GUIContent("Color Temperature"); 64 | labelColorTint = new GUIContent("Tint (green-purple)"); 65 | } 66 | 67 | public override void OnInspectorGUI() 68 | { 69 | serializedObject.Update(); 70 | 71 | EditorGUILayout.PropertyField(propToneMapping); 72 | if (propToneMapping.hasMultipleDifferentValues || propToneMapping.boolValue) 73 | { 74 | EditorGUILayout.Slider(propExposure, 0, 5); 75 | if (QualitySettings.activeColorSpace != ColorSpace.Linear) 76 | EditorGUILayout.HelpBox("Linear space lighting should be enabled for tone mapping.", MessageType.Warning); 77 | } 78 | 79 | EditorGUILayout.Space(); 80 | 81 | EditorGUILayout.Slider(propColorTemp, -1.0f, 1.0f, labelColorTemp); 82 | EditorGUILayout.Slider(propColorTint, -1.0f, 1.0f, labelColorTint); 83 | 84 | EditorGUILayout.Space(); 85 | 86 | EditorGUILayout.Slider(propSaturation, 0, 2); 87 | 88 | EditorGUILayout.LabelField("Curves (R, G, B, Combined)"); 89 | EditorGUILayout.BeginHorizontal(); 90 | var doubleHeight = GUILayout.Height(EditorGUIUtility.singleLineHeight * 2); 91 | EditorGUILayout.PropertyField(propRCurve, GUIContent.none, doubleHeight); 92 | EditorGUILayout.PropertyField(propGCurve, GUIContent.none, doubleHeight); 93 | EditorGUILayout.PropertyField(propBCurve, GUIContent.none, doubleHeight); 94 | EditorGUILayout.PropertyField(propCCurve, GUIContent.none, doubleHeight); 95 | EditorGUILayout.EndHorizontal(); 96 | 97 | EditorGUILayout.Space(); 98 | 99 | EditorGUILayout.PropertyField(propDitherMode); 100 | 101 | serializedObject.ApplyModifiedProperties(); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /Assets/ColorSuite/Editor/ColorSuiteEditor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f328b8677255d426a999185016ef88f2 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/ColorSuite/Shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4911ca47559e444a8aa3e74b16a42ce1 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/ColorSuite/Shader/ColorSuite.shader: -------------------------------------------------------------------------------- 1 | // 2 | // Copyright (C) 2014, 2015 Keijiro Takahashi 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | // this software and associated documentation files (the "Software"), to deal in 6 | // the Software without restriction, including without limitation the rights to 7 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 8 | // the Software, and to permit persons to whom the Software is furnished to do so, 9 | // subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in all 12 | // copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 16 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 17 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 18 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | // 21 | 22 | Shader "Hidden/ColorSuite" 23 | { 24 | Properties 25 | { 26 | _MainTex ("-", 2D) = ""{} 27 | _Curves ("-", 2D) = ""{} 28 | _Exposure ("-", Float) = 1.0 29 | _Saturation ("-", Float) = 1.0 30 | _Balance ("-", Vector) = (1, 1, 1, 0) 31 | } 32 | 33 | CGINCLUDE 34 | 35 | // Multi-compilation options. 36 | #pragma multi_compile COLORSPACE_SRGB COLORSPACE_LINEAR 37 | #pragma multi_compile BALANCING_OFF BALANCING_ON 38 | #pragma multi_compile TONEMAPPING_OFF TONEMAPPING_ON 39 | #pragma multi_compile DITHER_OFF DITHER_ORDERED DITHER_TRIANGULAR 40 | 41 | #include "UnityCG.cginc" 42 | 43 | sampler2D _MainTex; 44 | float2 _MainTex_TexelSize; 45 | sampler2D _Curves; 46 | float _Exposure; 47 | float _Saturation; 48 | float4 _Balance; 49 | 50 | #if COLORSPACE_LINEAR 51 | 52 | // Color space conversion between sRGB and linear space. 53 | // http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html 54 | 55 | float3 srgb_to_linear(float3 c) 56 | { 57 | return c * (c * (c * 0.305306011 + 0.682171111) + 0.012522878); 58 | } 59 | 60 | float3 linear_to_srgb(float3 c) 61 | { 62 | return max(1.055 * pow(c, 0.416666667) - 0.055, 0.0); 63 | } 64 | 65 | #endif 66 | 67 | #if BALANCING_ON 68 | 69 | // Color space conversion between linear RGB and LMS 70 | // based on the CIECAM02 model (CAT02). 71 | // http://en.wikipedia.org/wiki/LMS_color_space#CAT02 72 | 73 | float3 lrgb_to_lms(float3 c) 74 | { 75 | float3x3 m = { 76 | 3.90405e-1f, 5.49941e-1f, 8.92632e-3f, 77 | 7.08416e-2f, 9.63172e-1f, 1.35775e-3f, 78 | 2.31082e-2f, 1.28021e-1f, 9.36245e-1f 79 | }; 80 | return mul(m, c); 81 | } 82 | 83 | float3 lms_to_lrgb(float3 c) 84 | { 85 | float3x3 m = { 86 | 2.85847e+0f, -1.62879e+0f, -2.48910e-2f, 87 | -2.10182e-1f, 1.15820e+0f, 3.24281e-4f, 88 | -4.18120e-2f, -1.18169e-1f, 1.06867e+0f 89 | }; 90 | return mul(m, c); 91 | } 92 | 93 | // Color balance function. 94 | // - The gamma compression/expansion equation used in this function 95 | // differs from the standard sRGB-Linear conversion. 96 | 97 | float3 apply_balance(float3 c) 98 | { 99 | #if !COLORSPACE_LINEAR 100 | // Do the gamma expansion before applying the color balance. 101 | c = pow(c, 2.2); 102 | #endif 103 | 104 | // Apply the color balance in the LMS color space. 105 | c = lms_to_lrgb(lrgb_to_lms(c) * _Balance); 106 | 107 | // It may return a minus value, which should be cropped out. 108 | c = max(c, 0.0); 109 | 110 | #if !COLORSPACE_LINEAR 111 | // Gamma compression. 112 | c = pow(c, 1.0 / 2.2); 113 | #endif 114 | 115 | return c; 116 | } 117 | 118 | #endif 119 | 120 | #if TONEMAPPING_ON 121 | 122 | // John Hable's filmic tone mapping operator. 123 | // http://filmicgames.com/archives/6 124 | 125 | float3 hable_op(float3 c) 126 | { 127 | float A = 0.15; 128 | float B = 0.50; 129 | float C = 0.10; 130 | float D = 0.20; 131 | float E = 0.02; 132 | float F = 0.30; 133 | return ((c * (c * A + B * C) + D * E) / (c * (c * A + B) + D * F)) - E / F; 134 | } 135 | 136 | float3 tone_mapping(float3 c) 137 | { 138 | c *= _Exposure * 4; 139 | c = hable_op(c) / hable_op(11.2); 140 | return pow(c, 1 / 2.2); 141 | } 142 | 143 | #endif 144 | 145 | // Color saturation. 146 | 147 | float luma(float3 c) 148 | { 149 | return 0.212 * c.r + 0.701 * c.g + 0.087 * c.b; 150 | } 151 | 152 | float3 apply_saturation(float3 c) 153 | { 154 | return lerp((float3)luma(c), c, _Saturation); 155 | } 156 | 157 | // RGB curves. 158 | 159 | float3 apply_curves(float3 c) 160 | { 161 | float4 r = tex2D(_Curves, float2(c.r, 0)); 162 | float4 g = tex2D(_Curves, float2(c.g, 0)); 163 | float4 b = tex2D(_Curves, float2(c.b, 0)); 164 | return float3(r.r * r.a, g.g * g.a, b.b * b.a); 165 | } 166 | 167 | #if DITHER_ORDERED 168 | 169 | // Interleaved gradient function from CoD AW. 170 | // http://www.iryoku.com/next-generation-post-processing-in-call-of-duty-advanced-warfare 171 | 172 | float interleaved_gradient(float2 uv) 173 | { 174 | float3 magic = float3(0.06711056, 0.00583715, 52.9829189); 175 | return frac(magic.z * frac(dot(uv, magic.xy))); 176 | } 177 | 178 | float3 dither(float2 uv) 179 | { 180 | return (float3)(interleaved_gradient(uv / _MainTex_TexelSize) / 255); 181 | } 182 | 183 | #endif 184 | 185 | #if DITHER_TRIANGULAR 186 | 187 | // Triangular PDF. 188 | 189 | float nrand(float2 uv) 190 | { 191 | return frac(sin(dot(uv, float2(12.9898, 78.233))) * 43758.5453); 192 | } 193 | 194 | float3 dither(float2 uv) 195 | { 196 | float r = nrand(uv) + nrand(uv + (float2)1.1) - 0.5; 197 | return (float3)(r / 255); 198 | } 199 | 200 | #endif 201 | 202 | float4 frag(v2f_img i) : SV_Target 203 | { 204 | float4 source = tex2D(_MainTex, i.uv); 205 | float3 rgb = source.rgb; 206 | 207 | #if BALANCING_ON 208 | rgb = apply_balance(rgb); 209 | #endif 210 | 211 | #if COLORSPACE_LINEAR 212 | #if TONEMAPPING_ON 213 | // Apply the tone mapping. 214 | rgb = tone_mapping(rgb); 215 | #else 216 | // Convert the color into the sRGB color space. 217 | rgb = linear_to_srgb(rgb); 218 | #endif 219 | #endif 220 | 221 | // Color saturation. 222 | rgb = apply_saturation(rgb); 223 | 224 | // RGB curves. 225 | rgb = apply_curves(rgb); 226 | 227 | #if !DITHER_OFF 228 | rgb += dither(i.uv); 229 | #endif 230 | 231 | #if COLORSPACE_LINEAR 232 | // Take the color back into the linear color space. 233 | rgb = srgb_to_linear(rgb); 234 | #endif 235 | 236 | return float4(rgb, source.a); 237 | } 238 | 239 | ENDCG 240 | 241 | Subshader 242 | { 243 | Pass 244 | { 245 | ZTest Always Cull Off ZWrite Off 246 | Fog { Mode off } 247 | CGPROGRAM 248 | #pragma target 3.0 249 | #pragma glsl 250 | #pragma vertex vert_img 251 | #pragma fragment frag 252 | ENDCG 253 | } 254 | } 255 | } 256 | -------------------------------------------------------------------------------- /Assets/ColorSuite/Shader/ColorSuite.shader.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dc9775b65c52747e69fc4c854c00d696 3 | ShaderImporter: 4 | defaultTextures: [] 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/MyGame.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 15f1ad14850584d8cb32e0d4616877f4 3 | folderAsset: yes 4 | timeCreated: 1445089800 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/MyGame/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c870a3d7792ab486ca18d79a94a7b28d 3 | folderAsset: yes 4 | timeCreated: 1445089812 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/MyGame/Materials/MovieMat.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/Assets/MyGame/Materials/MovieMat.mat -------------------------------------------------------------------------------- /Assets/MyGame/Materials/MovieMat.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6be894794712c4711bd666298415c2cd 3 | timeCreated: 1445004423 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MyGame/Models.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9eb4d0595c864475bb6e6f523bfffa0a 3 | folderAsset: yes 4 | timeCreated: 1445089823 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/MyGame/Models/Materials.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8884bdba6773f434da44c6d8d690d701 3 | folderAsset: yes 4 | timeCreated: 1445246001 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/MyGame/Models/Materials/phong1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/Assets/MyGame/Models/Materials/phong1.mat -------------------------------------------------------------------------------- /Assets/MyGame/Models/Materials/phong1.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 89a4387d44fe94d3185a2782e060e10c 3 | timeCreated: 1445246001 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/MyGame/Models/Sphere100.fbx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/Assets/MyGame/Models/Sphere100.fbx -------------------------------------------------------------------------------- /Assets/MyGame/Models/Sphere100.fbx.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9c21e3028b69640aaaef9b6550db2649 3 | timeCreated: 1445004409 4 | licenseType: Pro 5 | ModelImporter: 6 | serializedVersion: 18 7 | fileIDToRecycleName: 8 | 100000: //RootNode 9 | 400000: //RootNode 10 | 2300000: //RootNode 11 | 3300000: //RootNode 12 | 4300000: pSphere1 13 | 9500000: //RootNode 14 | materials: 15 | importMaterials: 1 16 | materialName: 0 17 | materialSearch: 1 18 | animations: 19 | legacyGenerateAnimations: 4 20 | bakeSimulation: 0 21 | optimizeGameObjects: 0 22 | motionNodeName: 23 | animationImportErrors: 24 | animationImportWarnings: 25 | animationRetargetingWarnings: 26 | animationDoRetargetingWarnings: 0 27 | animationCompression: 1 28 | animationRotationError: .5 29 | animationPositionError: .5 30 | animationScaleError: .5 31 | animationWrapMode: 0 32 | extraExposedTransformPaths: [] 33 | clipAnimations: [] 34 | isReadable: 1 35 | meshes: 36 | lODScreenPercentages: [] 37 | globalScale: 1 38 | meshCompression: 0 39 | addColliders: 0 40 | importBlendShapes: 1 41 | swapUVChannels: 0 42 | generateSecondaryUV: 0 43 | useFileUnits: 1 44 | optimizeMeshForGPU: 1 45 | keepQuads: 0 46 | weldVertices: 1 47 | secondaryUVAngleDistortion: 8 48 | secondaryUVAreaDistortion: 15.000001 49 | secondaryUVHardAngle: 88 50 | secondaryUVPackMargin: 4 51 | useFileScale: 1 52 | tangentSpace: 53 | normalSmoothAngle: 60 54 | splitTangentsAcrossUV: 1 55 | normalImportMode: 0 56 | tangentImportMode: 1 57 | importAnimation: 1 58 | copyAvatar: 0 59 | humanDescription: 60 | human: [] 61 | skeleton: [] 62 | armTwist: .5 63 | foreArmTwist: .5 64 | upperLegTwist: .5 65 | legTwist: .5 66 | armStretch: .0500000007 67 | legStretch: .0500000007 68 | feetSpacing: 0 69 | rootMotionBoneName: 70 | hasTranslationDoF: 0 71 | lastHumanDescriptionAvatarSource: {instanceID: 0} 72 | animationType: 2 73 | humanoidOversampling: 1 74 | additionalBone: 0 75 | userData: 76 | assetBundleName: 77 | assetBundleVariant: 78 | -------------------------------------------------------------------------------- /Assets/MyGame/Movies.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 589bb4afc61a94a66ac1d662832032ef 3 | folderAsset: yes 4 | timeCreated: 1445089841 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/MyGame/Scripts.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 554c724ea00af49eaa0591cd2d1c0dd7 3 | folderAsset: yes 4 | timeCreated: 1445089805 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/MyGame/Scripts/MouseLook.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | /// MouseLook rotates the transform based on the mouse delta. 5 | /// Minimum and Maximum values can be used to constrain the possible rotation 6 | 7 | /// To make an FPS style character: 8 | /// - Create a capsule. 9 | /// - Add a rigid body to the capsule 10 | /// - Add the MouseLook script to the capsule. 11 | /// -> Set the mouse look to use LookX. (You want to only turn character but not tilt it) 12 | /// - Add FPSWalker script to the capsule 13 | 14 | /// - Create a camera. Make the camera a child of the capsule. Reset it's transform. 15 | /// - Add a MouseLook script to the camera. 16 | /// -> Set the mouse look to use LookY. (You want the camera to tilt up and down like a head. The character already turns.) 17 | /// 18 | [AddComponentMenu("Camera-Control/Mouse Look")] 19 | public class MouseLook : MonoBehaviour { 20 | 21 | public enum RotationAxes { MouseXAndY = 0, MouseX = 1, MouseY = 2 } 22 | public RotationAxes axes = RotationAxes.MouseXAndY; 23 | public float sensitivityX = 15F; 24 | public float sensitivityY = 15F; 25 | public float minimumX = -360F; 26 | public float maximumX = 360F; 27 | public float minimumY = -60F; 28 | public float maximumY = 60F; 29 | float rotationX = 0F; 30 | float rotationY = 0F; 31 | Quaternion originalRotation; 32 | void Update () 33 | { 34 | if (axes == RotationAxes.MouseXAndY) 35 | { 36 | // Read the mouse input axis 37 | rotationX += Input.GetAxis("Mouse X") * sensitivityX; 38 | rotationY += Input.GetAxis("Mouse Y") * sensitivityY; 39 | rotationX = ClampAngle (rotationX, minimumX, maximumX); 40 | rotationY = ClampAngle (rotationY, minimumY, maximumY); 41 | Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up); 42 | Quaternion yQuaternion = Quaternion.AngleAxis (rotationY, -Vector3.right); 43 | transform.localRotation = originalRotation * xQuaternion * yQuaternion; 44 | } 45 | else if (axes == RotationAxes.MouseX) 46 | { 47 | rotationX += Input.GetAxis("Mouse X") * sensitivityX; 48 | rotationX = ClampAngle (rotationX, minimumX, maximumX); 49 | Quaternion xQuaternion = Quaternion.AngleAxis (rotationX, Vector3.up); 50 | transform.localRotation = originalRotation * xQuaternion; 51 | } 52 | else 53 | { 54 | rotationY += Input.GetAxis("Mouse Y") * sensitivityY; 55 | rotationY = ClampAngle (rotationY, minimumY, maximumY); 56 | Quaternion yQuaternion = Quaternion.AngleAxis (-rotationY, Vector3.right); 57 | transform.localRotation = originalRotation * yQuaternion; 58 | } 59 | } 60 | void Start () 61 | { 62 | // Make the rigid body not change rotation 63 | if (GetComponent()) 64 | GetComponent().freezeRotation = true; 65 | originalRotation = transform.localRotation; 66 | } 67 | public static float ClampAngle (float angle, float min, float max) 68 | { 69 | if (angle < -360F) 70 | angle += 360F; 71 | if (angle > 360F) 72 | angle -= 360F; 73 | return Mathf.Clamp (angle, min, max); 74 | } 75 | } -------------------------------------------------------------------------------- /Assets/MyGame/Scripts/MouseLook.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 05a86f2399f0a47238493ee62d05a368 3 | timeCreated: 1445092552 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/MyGame/Scripts/MoviePlay.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | 4 | public class MoviePlay : MonoBehaviour { 5 | 6 | // Use this for initialization 7 | void Start () { 8 | #if UNITY_EDITOR || UNITY_STANDALONE 9 | MovieTexture movie = (GetComponent().material.mainTexture as MovieTexture); 10 | movie.loop = true; 11 | movie.Play(); 12 | #endif 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Assets/MyGame/Scripts/MoviePlay.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1ee88dba8edcf45c28dcbe6150fbae91 3 | timeCreated: 1445004528 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/MyGame/Test.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/Assets/MyGame/Test.unity -------------------------------------------------------------------------------- /Assets/MyGame/Test.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d9f7cf5bd4df8402aae3d0025d248d40 3 | timeCreated: 1445005103 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/StreamingAssets.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: ce1933d13dd6348858a1f13caa2bc230 3 | folderAsset: yes 4 | timeCreated: 1445313554 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/StreamingAssets/IMG_4865.MP4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/Assets/StreamingAssets/IMG_4865.MP4 -------------------------------------------------------------------------------- /Assets/StreamingAssets/IMG_4865.MP4.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: e48fec36e9a94476089a27b75542910c 3 | timeCreated: 1445247033 4 | licenseType: Pro 5 | MovieImporter: 6 | serializedVersion: 1 7 | quality: 1 8 | linearTexture: 1 9 | userData: 10 | assetBundleName: 11 | assetBundleVariant: 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Makoto Ito 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 | 23 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.2.1p2 2 | m_StandardAssetsVersion: 0 3 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAdsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/UnityAdsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityAnalyticsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/makoto-unity/PanoramaVideoWithUnity/03f8f042fb27d988bb00609bb4aee94e44379347/ProjectSettings/UnityAnalyticsManager.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnityとOculusで360度パノラマ全天周動画を見る方法【無料編】 2 | 3 | 「UnityとOculusで360度パノラマ全天周動画を見る方法」のシリーズとしては第3回目なのですが、今までの2回は全て有料アセットを使ったりしていてイマイチ一般性がなかったのではないかと思います。今回は「無料」ということにこだわり(Oculus をUnityで使うのも無料になりましたし)、パノラマ動画アプリを作ってみたいと思います。 4 | 5 | ## 素材作り 6 | まずは RICOH Theta でパノラマ動画を撮影します。最近発売される(2015/10/19現在)、「RICOH Theta S」いいですね!これはマストバイですよ!奥さん!パノラマ好きだったらしのごの言わずに買いましょう。今のところこれ以上のモノは世界中にはないでしょう。
7 | iPhone/Androidアプリでパノラマ動画を持ってきます。Theta Sからアプリで持ってくるだけで、正距円筒図法の動画になるので楽です。
8 | Theta m-15の方はMac/Windows 側で正距円筒図法にステッチ(複数カメラからの映像を一つのパノラマ映像にする作業)をする必要があります。専用Mac/Winアプリで自動ステッチしてください。
9 | Theta Sなんてないよ、とかいう人はとりあえず、このこの動画をダウンロードして使ってください。
10 | 11 | ## Unity で動画を扱うための準備 12 | 13 | Windows はQuick Time をインストールすることを忘れないで下さい。Quick Time がないとUnityに動画をインポート出来ません。始めてのQuickTimeインストールした際は一度Windowsを再起動した方がいいかもしれません。 14 | 動画ファイルのQuickTimeへの関連付けも大事です。もし一回Reimport。再起動。 15 | 16 | 17 | ## 投影する天球をシーンに置く 18 | Unity を立ち上げてください。
19 | とりあえずUnity エディタの説明をしようと思いましたが、面倒なので「Unity仮面が教える! ラクしてゲームを作るためのAssetStore超活用術」を参考にしてください。
20 | とりあえずシーンを保存しましょう。File → Save Scene とすると、名前を聞かれるので、適当に「 Sphere Movie 」とかにしましょうか。
21 | だいたいエディタの使い方を学んだところで、先ほどのパノラマ動画をUnityのProject ビュー にドラッグアンドドロップ(以下D&D)します。するとインポート処理が始まります。インポート処理が終わると、画像のように音声と動画が分離されます。
22 | 天球モデルは 「Sphere100.fbx」 を私の方で提供しているので、そちらをお使いください。 Blender から作るやり方 は天球の極点で動画が歪んでしまうので、あまりお勧めしません。そして、「 Sphere100 」を Hierarchy ビューにD&Dします
23 | 24 | ## マテリアルを作る 25 | Project ビューで右クリックしてメニューを出し、 Create → Material を選択して新しいマテリアル(素材)を作ります。適当な名前をつけます。ここでは「SampleMovieMat」とかにしましょうか。
26 | 「 MovieMat 」を選択して、Inspector ビューで Shader を Unlit → Texture にします。これで、影つかなくなりました。ムービーに天球の影がついたらおかしいですからね。
27 | 先ほどインポートした ムービーファイルを Inspector の None (Texture) という箇所にD&Dします。
28 | そしてこのマテリアルを先ほど Hierarchy ビュー の 「 Sphere100 」にD&Dします。
29 | 30 | ## 再生スクリプトを作る 31 | ただ、このままでは再生してくれません。再生するスクリプトを作らなくてはいけないのです。
32 | Project ビューで Create → C# Script でC#スクリプトを作成します。名前はなんでもいいのですが、「 SampleMoviePlay 」にしましょうか。
33 | 作ったC# スクリプトをダブルクリックすると、スクリプトを書けるエディタが立ち上がります。
34 | 35 | void Start () { 36 | 37 | の次の行に以下の行を追加します
38 | 39 | (GetComponent().material.mainTexture as MovieTexture).Play(); 40 | 41 | 書けたら保存します。そしてUnityに戻ってみます。左下に赤いエラーが出ていなければokです。出ていたらよーく見比べてみましょう。
42 | 問題ないようなら、このスクリプト「 SampleMoviePlay 」を動画が貼っている「 Sphere100 」にD&Dします。
43 | これでプレイボタン(画面中央上の▲)を押してみて、動画が動くか確認しましょう。確認したらもう一度プレイボタンを押して止めましょう。
44 | 45 | ## 音声をつける 46 | Project ビューのムービーの▲をクリックして、サウンドを表示します。
47 | このサウンドを Hierarchy ビューの「 Sphere100 」にD&Dします。
48 | またプレイボタンを押してみて、音が再生されるか確認します
49 | 50 | ## マウスで方向が向けるように 51 | MouseLook.csというスクリプトを利用しましょう。
52 | これをダウンロードして、「Camera」オブジェクトにD&Dでいけます。 53 | 54 | ## エフェクト 55 | カラーコレクションをかけて、色調整をしましょう。
56 | 57 | https://github.com/keijiro/ColorSuite 58 | 59 | keijiroさんの「ColorSuite」を使います。こちらをダウンロードして、「ColorSuite」フォルダをプロジェクトにD&Dします。
60 | そして、CameraオブジェクトにD&Dしたら、色調整が可能になります。各色を変更して調整しましょう。
61 | 62 | ## Oculus Rift 対応 63 | メニューから Edit → Project Settings → Player を選択して、PlayerSettings を開きます。ここで、 Virtual Reality Supported にチェックを入れたらオーケーです。あとは Oculus を繋いで、Editor プレイするだけで、トラッキングできるはずです。簡単ですよね! 64 | 65 | ## デスクトップアプリとしてのビルド 66 | File → Build Settings でビルド設定画面を表示します。
67 | 最初はアプリとしてはいるシーンが一つもないので、現在作っているシーン 「 SphereMovie 」を追加します。追加する方法は Scene In Build にシーンファイルをD&Dする方法と、Add Current で現在開いているシーンを追加する方法があります。
68 | そして、出力したいターゲットを選んで、Buildすればアプリが作られます。Build And Run すればそのまま立ち上がります。どうです?アプリとして立ち上がりましたか? 69 | 70 | ## AVProの紹介 71 | 正直、フレームレートが低くて実際の運用(展示会とか)はなかなか厳しいと思います。 72 | そういう際は、AssetStore の「AVPro」シリーズがオススメです。こちらのブログで紹介しているので、 73 | 興味あったらそれを参考に実装してください。基本的に実装方法は同じです。 74 | 75 | # ーーー以下スマホ対応ーーー 76 | 77 | ## Easy Movie Texture 78 | スマホでパノラマ動画をやりたい時は、Unityの機能だけでは実装できません。
79 | そこで、AssetStoreにある「 Easy Movie Texture 」を購入して、利用しましょう。$45です。自力でプログラム組むより遥かに楽なので、是非時間をお金で買いましょう。
80 | 81 | ## iOSパッチ 82 | このままだとXcode でビルド時にエラーが出てしまうので、 83 | EasyMovieTexture/Unity5_Patch_IOS/Untiy5_Patch_iOS 84 | をダブルクリックして、パッチを適応しましょう。Unity5用ですので、4.6系は適宜対応してください。 85 | 86 | ## 準備 87 | 88 | 「 Sperer100 」を選択して、Inspector から先ほど自分で付けた、「Movie Play」スクリプトがあると思うのですけど、それのチェックボックスを外します。これでオフになるはずです。一旦オフにしましょう。
89 | そして、今度は以下の場所のスクリプト 90 | 91 | EasyMovieTexture/Scripts/MediaPlayerCtrl 92 | 93 | を 「 Sphere100 」にD&Dして、その機能を付加します。
94 | 「 Spherer100 」 の 「 Media Player Ctrl 」の項目で Target Material というところには自分自身つまり 「 Spherer100 」自体をD&Dします。Hierarchy ビューから「 Spherer100 」をD&Dしましょう。
95 | 96 | ## StreamingAssets について 97 | 98 | Str File Name というところにムービーファイル名を書くのですけど、実はこの場所は StreamingAssets フォルダ以下にないといけないのです。なので、先ほど置いたムービーファイルを StreamingAssets フォルダの下に移動させてください。
99 | そうした上で、Str File Name に先ほど置いたファイル名を書きましょう。「.mp4」等の拡張子も忘れずに書いておきましょう。(Unity エディタ内は拡張子が表示されないので気をつけてください) 100 | 101 | ## とりあえず、サンプルシーンをやってみる 102 | 103 | 実は Easy Movie Player はエディタ上から再生できません。ですので、イチイチ確認のために書き出す必要があるのです。
104 | File → Build Settings でビルド設定画面を表示します。一旦現在のシーンは捨てて、Assets/EasyMovieTexture/Scene/Demo をD&D します。まずはデモで正常に動くか確認しましょう。 105 | 106 | ## iOSビルド 107 | iOS 7.0以上 108 | では順番に行きましょう。まずはiOSビルド。引き続き Build Settings 画面でPlatform を iOS に変更して、Switch Platform と押すと変換が始まります。そして、Build ボタンを押すと、プロジェクト名を聞かれるので、適当な名前を付けてください。MovieDemo とかでしょうか。
109 | Code Sign を入れておきます。 110 | おっと、ビルドエラーがでますので、先ほどMoviePlay.cs の中で書いたコードがモバイルでは動かないということなので、 111 | 112 | (GetComponent().material.mainTexture as MovieTexture).Play(); 113 | 114 | というコードを 115 | 116 | #if UNITY_EDITOR || UNITY_STANDALONE 117 | (GetComponent().material.mainTexture as MovieTexture).Play(); 118 | #endif 119 | 120 | と、上下で #if〜 と #endif を加えてください。
121 | 122 | そして出来たプロジェクトファイルの Unity-iPhone.xcodeproj をダブルクリックしてXcode を立ち上げてください。
123 | それで、iPhone を繋げてビルドして動くことを確認してください。真ん中に二つのムービーが再生されたら成功です。
124 | 125 | ## Androidビルド 126 | Android 4.0 以上です。 127 | Androidはもっと簡単です。引き続き Build Settings 画面でPlatform を Android に変更して、Switch Platform と押すと変換が始まります。
128 | すぐにビルド、と行きたいですが、その前に設定するところがあります。Unity → Preference (Mac) /Edit → Preference (Winの場合) でPreference を表示させます。
129 | External Tools を選んでいただいて、Android の SDK の項目を Browse でAndroid SDKのパスを入力すればOKです。
130 | Graphics Level → Open GLES2 131 | Internal Access → Require 132 | Write Access External(SDCard) 133 | 134 | ## Google Cardboard SDK 135 | このままではスマホで書き出しても、ハコスコやCardboardで見ても画面に追従してくれないんですよね。
136 | なので、Google Cardboard SDK を利用します。これは無料なので使いやすいです。iOSも使えますのでご安心ください。
137 | ここからSDKをダウンロードしてください。
138 | ダウンロードした CardboardSDKForUnity.unitypackage をUnity エディタ の Project ビューにD&Dします。すると、Import するか旨を聞かれるので、インポートしてください。
139 | インポート終了すると、エラーが表示されるかもしれませんが無視してください。Console で Clear して何も出ていないのならOKです。
140 | で早速、 Cardboard/Prefab/CardboardMain を Hierarchy ビューにD&Dします。これでスマホがカメラと連動するような挙動になります。あ、既存のCamera を一旦オフ(Camera を選択して、Inspector ビューの一番上のチェックボックスをオフに)にしておきましょう。
141 | --------------------------------------------------------------------------------