├── .gitignore ├── Documents ├── AddComponent.png ├── PhysicalCameraComponent.png ├── camera.png ├── description.png └── drag.png ├── LICENSE ├── Project ├── Assets │ └── Vfx-Camera │ │ ├── Cameras │ │ ├── Full Frame - 24mm (default).prefab │ │ └── Full Frame - 24mm (default).prefab.meta │ │ ├── PackageGenerator.cs │ │ ├── Scripts │ │ ├── Editor │ │ │ ├── PhysicalCameraEditor.cs │ │ │ ├── PhysicalCameraPostprocessor.cs │ │ │ └── SerializableObjHelper.cs │ │ ├── Model │ │ │ ├── MathematicalModel.cs │ │ │ ├── PhysicalCameraBodyModel.cs │ │ │ ├── PhysicalCameraLensModel.cs │ │ │ └── PhysicalCameraModel.cs │ │ ├── PhysicalCamera.cs │ │ └── PhysicalCamera.cs.meta │ │ └── testScene.unity └── VFX-PhysicalCameras.unitypackage └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | release/ 2 | debug/ 3 | dependencies/ 4 | ProjectSettings/ 5 | .build/ 6 | *.dblite 7 | excons.cache 8 | 9 | *.csproj 10 | *.sln 11 | *.sdf 12 | *.meta 13 | *.opendb 14 | *.vcxproj.user 15 | .vs/ 16 | Library/ 17 | Temp/ 18 | _tmp/ 19 | _out/ 20 | ipch/ 21 | 22 | -------------------------------------------------------------------------------- /Documents/AddComponent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/Physical-Camera/3f1e0f8542973f5a83c3262923bdb13d51c9da80/Documents/AddComponent.png -------------------------------------------------------------------------------- /Documents/PhysicalCameraComponent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/Physical-Camera/3f1e0f8542973f5a83c3262923bdb13d51c9da80/Documents/PhysicalCameraComponent.png -------------------------------------------------------------------------------- /Documents/camera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/Physical-Camera/3f1e0f8542973f5a83c3262923bdb13d51c9da80/Documents/camera.png -------------------------------------------------------------------------------- /Documents/description.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/Physical-Camera/3f1e0f8542973f5a83c3262923bdb13d51c9da80/Documents/description.png -------------------------------------------------------------------------------- /Documents/drag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/Physical-Camera/3f1e0f8542973f5a83c3262923bdb13d51c9da80/Documents/drag.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 jasonm-unity 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 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/Cameras/Full Frame - 24mm (default).prefab: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!1001 &100100000 4 | Prefab: 5 | m_ObjectHideFlags: 1 6 | serializedVersion: 2 7 | m_Modification: 8 | m_TransformParent: {fileID: 0} 9 | m_Modifications: [] 10 | m_RemovedComponents: [] 11 | m_ParentPrefab: {fileID: 0} 12 | m_RootGameObject: {fileID: 1840544312999118} 13 | m_IsPrefabParent: 1 14 | --- !u!1 &1840544312999118 15 | GameObject: 16 | m_ObjectHideFlags: 0 17 | m_PrefabParentObject: {fileID: 0} 18 | m_PrefabInternal: {fileID: 100100000} 19 | serializedVersion: 5 20 | m_Component: 21 | - component: {fileID: 4494032398450724} 22 | - component: {fileID: 114736796904338916} 23 | m_Layer: 0 24 | m_Name: Full Frame - 24mm (default) 25 | m_TagString: Untagged 26 | m_Icon: {fileID: 0} 27 | m_NavMeshLayer: 0 28 | m_StaticEditorFlags: 0 29 | m_IsActive: 1 30 | --- !u!4 &4494032398450724 31 | Transform: 32 | m_ObjectHideFlags: 1 33 | m_PrefabParentObject: {fileID: 0} 34 | m_PrefabInternal: {fileID: 100100000} 35 | m_GameObject: {fileID: 1840544312999118} 36 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 37 | m_LocalPosition: {x: 0, y: 0, z: 0} 38 | m_LocalScale: {x: 1, y: 1, z: 1} 39 | m_Children: [] 40 | m_Father: {fileID: 0} 41 | m_RootOrder: 0 42 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 43 | --- !u!114 &114736796904338916 44 | MonoBehaviour: 45 | m_ObjectHideFlags: 1 46 | m_PrefabParentObject: {fileID: 0} 47 | m_PrefabInternal: {fileID: 100100000} 48 | m_GameObject: {fileID: 1840544312999118} 49 | m_Enabled: 1 50 | m_EditorHideFlags: 0 51 | m_Script: {fileID: 11500000, guid: 22be42f0897cf4d4daffb985c40c89d5, type: 3} 52 | m_Name: 53 | m_EditorClassIdentifier: 54 | m_Mode: 0 55 | m_Model: 56 | m_ProjectionMode: 0 57 | m_NearClippingPlane: 0.03 58 | m_FarClippingPlane: 1000 59 | m_Body: 60 | m_SensorWidth: 0.036 61 | m_SensorHeight: 0.024 62 | m_Lens: 63 | m_FocalLength: 0.024 64 | m_AssociatedCameraObj: {fileID: 0} 65 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/Cameras/Full Frame - 24mm (default).prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 837da195ec89af645964847601adf512 3 | timeCreated: 1485979232 4 | licenseType: Free 5 | NativeFormatImporter: 6 | mainObjectFileID: -1 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/PackageGenerator.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using UnityEditor; 3 | 4 | namespace Unity.Vfx.Cameras 5 | { 6 | public class PhysicalCameraPackaging 7 | { 8 | [MenuItem("Assets/VFx/Cameras/Make Package")] 9 | public static void MakePackage() 10 | { 11 | string[] files = new string[] 12 | { 13 | "Assets/VFx-Camera/Scripts/PhysicalCamera.cs", 14 | 15 | "Assets/VFx-Camera/Scripts/Model/MathematicalModel.cs", 16 | "Assets/VFx-Camera/Scripts/Model/PhysicalCameraBodyModel.cs", 17 | "Assets/VFx-Camera/Scripts/Model/PhysicalCameraLensModel.cs", 18 | "Assets/VFx-Camera/Scripts/Model/PhysicalCameraModel.cs", 19 | 20 | "Assets/VFx-Camera/Scripts/Editor/PhysicalCameraEditor.cs", 21 | "Assets/VFx-Camera/Scripts/Editor/SerializableObjHelper.cs", 22 | "Assets/Vfx-Camera/Scripts/Editor/PhysicalCameraPostprocessor.cs", 23 | 24 | "Assets/VFx-Camera/Cameras/Full Frame - 24mm (default).prefab" 25 | }; 26 | AssetDatabase.ExportPackage(files, "VFX-PhysicalCameras.unitypackage", ExportPackageOptions.Recurse); 27 | } 28 | } 29 | } 30 | #endif // UNITY_EDITOR 31 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/Scripts/Editor/PhysicalCameraEditor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using UnityEditor; 4 | using Unity.Vfx.Cameras.Model; 5 | 6 | namespace Unity.Vfx.Cameras.Editor 7 | { 8 | [ExecuteInEditMode] 9 | [CustomEditor(typeof(PhysicalCamera))] 10 | public class PhysicalCameraEditor : UnityEditor.Editor 11 | { 12 | public bool m_ShowCamera = true; 13 | public bool m_showLens = true; 14 | public bool m_showBody = true; 15 | 16 | public override void OnInspectorGUI() 17 | { 18 | var physCamera = this.serializedObject; 19 | EditorGUI.BeginChangeCheck(); 20 | physCamera.Update(); 21 | 22 | // Start -------------------------------------------------------- 23 | var camObj = serializedObject.targetObject as PhysicalCamera; 24 | var property = this.serializedObject.FindProperty(() => camObj.m_Mode); 25 | AddEnumPopup(property, "Mode", "Determines if the Physical Camera controls the attached camera or reads from it.", typeof(PhysicalCameraMode)); 26 | 27 | property = this.serializedObject.FindProperty( ()=>camObj.m_AssociatedCameraObj ); 28 | EditorGUILayout.PropertyField(property); 29 | 30 | // models 31 | var camModel = this.serializedObject.FindProperty("m_Model"); 32 | var lensModel = camModel.FindPropertyRelative("m_Lens"); 33 | var bodyModel = camModel.FindPropertyRelative("m_Body"); 34 | 35 | m_ShowCamera = EditorGUILayout.Foldout(m_ShowCamera, "Camera"); 36 | if (m_ShowCamera) 37 | DrawCameraModel(camModel, lensModel); 38 | 39 | m_showLens = EditorGUILayout.Foldout(m_showLens, "Lens"); 40 | if (m_showLens) 41 | DrawLensModel(lensModel); 42 | 43 | m_showBody = EditorGUILayout.Foldout(m_showBody, "Body"); 44 | if (m_showBody) 45 | DrawBodyModel(bodyModel); 46 | 47 | // Done ------------------------------------------------------------- 48 | physCamera.ApplyModifiedProperties(); 49 | EditorGUI.EndChangeCheck(); 50 | } 51 | 52 | private void DrawCameraModel(SerializedProperty camModel, SerializedProperty lensModel) 53 | { 54 | var camObj = serializedObject.targetObject as PhysicalCamera; 55 | var camModelObj = camObj.Model; 56 | 57 | // Projection 58 | { 59 | var projProp = camModel.FindPropertyRelative( () => camModelObj.m_ProjectionMode); 60 | 61 | Rect ourRect = EditorGUILayout.BeginHorizontal(); 62 | EditorGUI.BeginProperty(ourRect, GUIContent.none, projProp); 63 | 64 | int value = projProp.intValue; 65 | string[] enumNamesList = new [] 66 | { 67 | ProjectionMode.Perspective.ToString(), 68 | ProjectionMode.Orthographic.ToString(), 69 | }; 70 | 71 | var newValue = EditorGUILayout.Popup("Projection", value, enumNamesList); 72 | if (newValue != value) 73 | { 74 | projProp.intValue = newValue & 1; 75 | 76 | } 77 | EditorGUI.EndProperty(); 78 | EditorGUILayout.EndHorizontal(); 79 | 80 | } 81 | 82 | // Fake property: FOV 83 | { 84 | EditorGUILayout.BeginHorizontal(); 85 | GUIContent gc; 86 | 87 | if (camObj.Model.m_ProjectionMode < ProjectionMode.Orthographic) 88 | gc = new GUIContent("Vertical FOV", "Vertical angular field of view of the camera."); 89 | else 90 | gc = new GUIContent("Vertical FOV", "Vertical field of view of the camera."); 91 | 92 | var orgValue = camObj.Model.VerticalFOV; 93 | var newValue = EditorGUILayout.FloatField(gc, orgValue); 94 | newValue = camObj.Model.Rules.ClampVerticalFOV(newValue); 95 | 96 | if (orgValue != newValue) 97 | { 98 | var lens = camModelObj.Lens; 99 | var flenProp = lensModel.FindPropertyRelative( () => lens.m_FocalLength); 100 | camObj.Model.VerticalFOV = newValue; 101 | flenProp.floatValue = lens.m_FocalLength; 102 | } 103 | 104 | EditorGUILayout.EndHorizontal(); 105 | } 106 | 107 | var property = camModel.FindPropertyRelative( () => camModelObj.m_NearClippingPlane ); 108 | AddFloatProperty(property, "Near Clipping Plane", "Distance, from camera sensor, to the Near clipping plane.", (oldv, newv) => 109 | { 110 | if (newv < 0.01f) 111 | newv = 0.01f; 112 | 113 | var far = camModel.FindPropertyRelative( () => camModelObj.m_FarClippingPlane ); 114 | 115 | if (far.floatValue - 0.01f < newv) 116 | far.floatValue = newv + 0.01f; 117 | 118 | return newv; 119 | }); 120 | 121 | property = camModel.FindPropertyRelative( () => camModelObj.m_FarClippingPlane ); 122 | AddFloatProperty(property, "Far Clipping Plane", "Distance, from camera sensor, to the Far clipping plane.", (oldv, newv) => { 123 | if (newv < camModelObj.m_NearClippingPlane + 0.01f) 124 | return camModelObj.m_NearClippingPlane + 0.01f; 125 | else 126 | return newv; 127 | }); 128 | } 129 | 130 | private void DrawBodyModel(SerializedProperty bodyModel) 131 | { 132 | var camObj = serializedObject.targetObject as PhysicalCamera; 133 | var bodyModelObj = camObj.Model.Body; 134 | 135 | var sensorWidthProperty = bodyModel.FindPropertyRelative (() => bodyModelObj.m_SensorWidth); 136 | AddFloatProperty (sensorWidthProperty, "Sensor Width", "Width, in millimeters, of the camera sensor.", (o, n) => n < 0.001f ? 0.001f : n > 0.1f ? 0.1f : n, 1000f); 137 | 138 | var sensorHeightProperty = bodyModel.FindPropertyRelative (() => bodyModelObj.m_SensorHeight); 139 | AddFloatProperty (sensorHeightProperty, "Sensor Height", "Height, in millimeters, of the camera sensor.", (o, n) => n < 0.001f ? 0.001f : n > 0.1f ? 0.1f : n, 1000f); 140 | 141 | // Fake property: Aspect Ratio 142 | { 143 | EditorGUILayout.BeginHorizontal (); 144 | var orgValue = camObj.Model.Body.AspectRatio; 145 | var newValue = EditorGUILayout.FloatField (new GUIContent ("Aspect ratio", "Aspect ratio of sensor: width over height"), orgValue); 146 | 147 | if (newValue < camObj.Model.Rules.MaxAspectRatio (camObj.Model)) 148 | newValue = camObj.Model.Rules.MaxAspectRatio (camObj.Model); 149 | 150 | if (newValue > 20f) 151 | newValue = 20f; 152 | 153 | if (orgValue != newValue) 154 | camObj.Model.Body.AspectRatio = newValue; 155 | 156 | EditorGUILayout.EndHorizontal(); 157 | } 158 | } 159 | 160 | private void DrawLensModel(SerializedProperty lensModel) 161 | { 162 | var camObj = serializedObject.targetObject as PhysicalCamera; 163 | var lensModelObj = camObj.Model.Lens; 164 | 165 | GUI.enabled = camObj.Model.m_ProjectionMode == ProjectionMode.Perspective; 166 | 167 | var property = lensModel.FindPropertyRelative( ()=> lensModelObj.m_FocalLength); 168 | AddFloatProperty(property, "Focal Length", "Focal length of the lens in millimeters.", (o, n) => 169 | { 170 | if (n < 0.001f) n = 0.001f; 171 | return n; 172 | }, 1000f); 173 | 174 | GUI.enabled = true; 175 | } 176 | 177 | private delegate T OnValueChangedDelegate(T oldValue, T newValue); 178 | 179 | void AddEnumPopup(SerializedProperty property, string text, string tooltip, Type typeOfEnum, OnValueChangedDelegate onChange = null) 180 | { 181 | Rect ourRect = EditorGUILayout.BeginHorizontal(); 182 | EditorGUI.BeginProperty(ourRect, GUIContent.none, property); 183 | 184 | int selectionFromInspector = property.intValue; 185 | 186 | string[] enumNamesList = System.Enum.GetNames(typeOfEnum); 187 | 188 | var actualSelected = EditorGUILayout.Popup(text, selectionFromInspector, enumNamesList); 189 | if (onChange != null && actualSelected != property.intValue) 190 | actualSelected = onChange(property.intValue, actualSelected); 191 | 192 | property.intValue = actualSelected; 193 | 194 | EditorGUI.EndProperty(); 195 | EditorGUILayout.EndHorizontal(); 196 | } 197 | 198 | void AddFloatProperty(SerializedProperty property, string text, string tooltip, OnValueChangedDelegate onChange = null, float factor = 1f) 199 | { 200 | Rect ourRect = EditorGUILayout.BeginHorizontal(); 201 | EditorGUI.BeginProperty(ourRect, GUIContent.none, property); 202 | 203 | var orgValue = property.floatValue * factor; 204 | var newValue = EditorGUILayout.FloatField(new GUIContent(text, tooltip), orgValue) / factor; 205 | 206 | if (onChange != null && orgValue != newValue) 207 | newValue = onChange(orgValue, newValue); 208 | 209 | property.floatValue = newValue; 210 | 211 | EditorGUI.EndProperty(); 212 | EditorGUILayout.EndHorizontal(); 213 | } 214 | 215 | void AddIntProperty(SerializedProperty property, string text, string tooltip, OnValueChangedDelegate onChange = null) 216 | { 217 | Rect ourRect = EditorGUILayout.BeginHorizontal(); 218 | EditorGUI.BeginProperty(ourRect, GUIContent.none, property); 219 | 220 | var orgValue = property.intValue; 221 | var newValue = EditorGUILayout.IntField(new GUIContent(text, tooltip), orgValue); 222 | 223 | if (onChange != null && orgValue != newValue) 224 | newValue = onChange(orgValue, newValue); 225 | 226 | property.intValue = newValue; 227 | 228 | EditorGUI.EndProperty(); 229 | EditorGUILayout.EndHorizontal(); 230 | } 231 | 232 | void AddFloatSlider(SerializedProperty property, string text, string tooltip, OnValueChangedDelegate onChange = null, float factor = 1f, float min = 0, float max = float.MaxValue) 233 | { 234 | Rect ourRect = EditorGUILayout.BeginHorizontal(); 235 | EditorGUI.BeginProperty(ourRect, GUIContent.none, property); 236 | 237 | var orgValue = property.floatValue * factor; 238 | var newValue = EditorGUILayout.Slider(new GUIContent(text, tooltip), orgValue, min * factor, max * factor) / factor; 239 | 240 | if (onChange != null && orgValue != newValue) 241 | newValue = onChange(orgValue, newValue); 242 | 243 | property.floatValue = newValue; 244 | 245 | EditorGUI.EndProperty(); 246 | EditorGUILayout.EndHorizontal(); 247 | } 248 | 249 | void AddIntSlider(SerializedProperty property, string text, string tooltip, OnValueChangedDelegate onChange = null, int min = 0, int max = int.MaxValue) 250 | { 251 | Rect ourRect = EditorGUILayout.BeginHorizontal(); 252 | EditorGUI.BeginProperty(ourRect, GUIContent.none, property); 253 | 254 | var orgValue = property.intValue; 255 | var newValue = EditorGUILayout.IntSlider(new GUIContent(text, tooltip), orgValue, min, max); 256 | 257 | if (onChange != null && orgValue != newValue) 258 | newValue = onChange(orgValue, newValue); 259 | 260 | property.intValue = newValue; 261 | 262 | EditorGUI.EndProperty(); 263 | EditorGUILayout.EndHorizontal(); 264 | } 265 | 266 | void AddBoolProperty(SerializedProperty property, string text, string tooltip, OnValueChangedDelegate onChange = null) 267 | { 268 | Rect ourRect = EditorGUILayout.BeginHorizontal(); 269 | EditorGUI.BeginProperty(ourRect, GUIContent.none, property); 270 | 271 | var orgValue = property.boolValue; 272 | var newValue = EditorGUILayout.Toggle(new GUIContent(text, tooltip), orgValue); 273 | 274 | if (onChange != null && orgValue != newValue) 275 | newValue = onChange(orgValue, newValue); 276 | 277 | property.boolValue = newValue; 278 | 279 | EditorGUI.EndProperty(); 280 | EditorGUILayout.EndHorizontal(); 281 | } 282 | 283 | } 284 | } 285 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/Scripts/Editor/PhysicalCameraPostprocessor.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using UnityEditor; 3 | using Unity.Vfx.Cameras; 4 | using Unity.Vfx.Cameras.Model; 5 | 6 | public class PhysicalCameraPostprocessor : AssetPostprocessor 7 | { 8 | void OnPreprocessModel() 9 | { 10 | var modelImporter = assetImporter as ModelImporter; 11 | if (modelImporter != null) 12 | { 13 | modelImporter.importCameras = true; 14 | modelImporter.extraUserProperties = new string[] 15 | { 16 | "FocalLength", 17 | "FilmWidth", "FilmHeight", 18 | "NearPlane", "FarPlane", 19 | "CameraProjectionType" 20 | }; 21 | } 22 | } 23 | 24 | void OnPostprocessGameObjectWithUserProperties(GameObject go, string[] propNames, object[] propValues) 25 | { 26 | var camera = go.GetComponent() as Camera; 27 | if (camera == null) 28 | return; 29 | 30 | var physicalCamera = go.GetComponent() as PhysicalCamera ?? 31 | go.AddComponent() as PhysicalCamera; 32 | 33 | for (int i = 0; i < propNames.Length; i++) 34 | { 35 | switch (propNames[i]) 36 | { 37 | case "FocalLength": 38 | // convert mm to m 39 | physicalCamera.Model.Lens.m_FocalLength = (float) propValues[i] / 1000f; 40 | break; 41 | case "FilmWidth": 42 | // convert inches to m 43 | physicalCamera.Model.Body.m_SensorWidth = (float) propValues[i] / 39.3701f; 44 | break; 45 | case "FilmHeight": 46 | // convert inches to m 47 | physicalCamera.Model.Body.m_SensorHeight = (float) propValues[i] / 39.3701f; 48 | break; 49 | case "NearPlane": 50 | // convert mm to m 51 | physicalCamera.Model.m_NearClippingPlane = (float) propValues[i] / 1000f; 52 | break; 53 | case "FarPlane": 54 | // convert mm to m 55 | physicalCamera.Model.m_FarClippingPlane = (float) propValues[i] / 1000f; 56 | break; 57 | case "CameraProjectionType": 58 | physicalCamera.Model.m_ProjectionMode = (int)propValues[i] == 1 ? ProjectionMode.Orthographic : ProjectionMode.Perspective; 59 | physicalCamera.Model.VerticalFOV = camera.fieldOfView; 60 | break; 61 | } 62 | } 63 | 64 | physicalCamera.Update(); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/Scripts/Editor/SerializableObjHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Collections.Generic; 4 | using System.Linq.Expressions; 5 | using UnityEditor; 6 | using UnityEngine; 7 | 8 | public static class SerializableObjHelper 9 | { 10 | public static SerializedProperty FindProperty(this SerializedObject obj, Expression> exp) 11 | { 12 | var body = exp.Body as MemberExpression; 13 | if (body == null) 14 | { 15 | var ubody = (UnaryExpression)exp.Body; 16 | body = ubody.Operand as MemberExpression; 17 | } 18 | 19 | var name = body.Member.Name; 20 | 21 | return obj.FindProperty(name); 22 | } 23 | 24 | public static SerializedProperty FindPropertyRelative(this SerializedProperty obj, Expression> exp) 25 | { 26 | var body = exp.Body as MemberExpression; 27 | if (body == null) 28 | { 29 | var ubody = (UnaryExpression)exp.Body; 30 | body = ubody.Operand as MemberExpression; 31 | } 32 | 33 | var name = body.Member.Name; 34 | 35 | return obj.FindPropertyRelative(name); 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/Scripts/Model/MathematicalModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | using System.Collections; 4 | using Unity.Vfx.Cameras.Model; 5 | 6 | namespace Unity.Vfx.Cameras.Model 7 | { 8 | 9 | /// 10 | /// Thin lense assumptions! 11 | /// 12 | public class MathematicalModel 13 | { 14 | public virtual float MaxVFOV { get { return 179f; } } 15 | public virtual float MinVFOV { get { return 1f; } } 16 | 17 | public virtual float MaxAspectRatio(PhysicalCameraModel camera) 18 | { 19 | return camera.Body.m_SensorWidth/(ToRad(MaxVFOV)*camera.Lens.m_FocalLength); 20 | } 21 | 22 | public float ClampVerticalFOV( float fov ) 23 | { 24 | return fov < MinVFOV ? MinVFOV : fov > MaxVFOV ? MaxVFOV : fov; 25 | } 26 | 27 | 28 | public virtual void ApplyVerticalFOV(float afov, PhysicalCameraModel camera) 29 | { 30 | camera.Lens.m_FocalLength = camera.Body.m_SensorHeight / ToRad(afov); 31 | } 32 | 33 | public float VerticalFOV(PhysicalCameraModel camera ) 34 | { 35 | return ToDeg(camera.Body.m_SensorHeight / camera.Lens.m_FocalLength); 36 | } 37 | 38 | private float ToRad(float rads) 39 | { 40 | return (float)(Math.PI * rads / 180.0); 41 | } 42 | 43 | private float ToDeg(float degrees) 44 | { 45 | return (float)(degrees * 180 / Math.PI); 46 | } 47 | 48 | 49 | 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/Scripts/Model/PhysicalCameraBodyModel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Unity.Vfx.Cameras.Model 4 | { 5 | 6 | [System.Serializable] 7 | public class PhysicalCameraBodyModel 8 | { 9 | public float m_SensorWidth; 10 | public float m_SensorHeight; 11 | 12 | public PhysicalCameraBodyModel() 13 | { 14 | SetupDefaultValues(); 15 | } 16 | 17 | public void SetupDefaultValues() 18 | { 19 | m_SensorWidth = 36/1000f; 20 | m_SensorHeight = 24/1000f; 21 | } 22 | 23 | public bool IsValid() 24 | { 25 | return m_SensorWidth > 0 && m_SensorHeight > 0; 26 | } 27 | 28 | public float AspectRatio 29 | { 30 | get { return m_SensorWidth/m_SensorHeight; } 31 | set 32 | { 33 | if (value != 0f) 34 | m_SensorHeight = m_SensorWidth / value; 35 | 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/Scripts/Model/PhysicalCameraLensModel.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | namespace Unity.Vfx.Cameras.Model 4 | { 5 | 6 | [System.Serializable] 7 | public class PhysicalCameraLensModel 8 | { 9 | public float m_FocalLength; 10 | 11 | public void SetupDefaultValues() 12 | { 13 | m_FocalLength = 24/1000f; 14 | } 15 | 16 | public bool IsValid() 17 | { 18 | return m_FocalLength > 0; 19 | } 20 | 21 | public PhysicalCameraLensModel() 22 | { 23 | SetupDefaultValues(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/Scripts/Model/PhysicalCameraModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using UnityEngine; 3 | 4 | namespace Unity.Vfx.Cameras.Model 5 | { 6 | public enum ProjectionMode 7 | { 8 | Perspective, 9 | Orthographic, 10 | } 11 | 12 | [System.Serializable] 13 | public class PhysicalCameraModel 14 | { 15 | private MathematicalModel m_Rules; 16 | 17 | public ProjectionMode m_ProjectionMode; 18 | public float m_NearClippingPlane; 19 | public float m_FarClippingPlane; 20 | 21 | [SerializeField] private PhysicalCameraBodyModel m_Body; 22 | [SerializeField] private PhysicalCameraLensModel m_Lens; 23 | 24 | public PhysicalCameraBodyModel Body { 25 | get { return m_Body ?? (m_Body = new PhysicalCameraBodyModel()); } 26 | } 27 | public PhysicalCameraLensModel Lens 28 | { 29 | get { return m_Lens ?? (m_Lens = new PhysicalCameraLensModel()); } 30 | } 31 | 32 | public MathematicalModel Rules 33 | { 34 | get { return m_Rules ?? (m_Rules = new MathematicalModel()); } 35 | } 36 | 37 | public float VerticalFOV 38 | { 39 | get { return Rules.VerticalFOV( this ); } 40 | set 41 | { 42 | Rules.ApplyVerticalFOV(value, this); 43 | } 44 | } 45 | 46 | public void SetDefaultValues() 47 | { 48 | m_ProjectionMode = ProjectionMode.Perspective; 49 | m_NearClippingPlane = 0.03f; 50 | m_FarClippingPlane = 1000f; 51 | 52 | Body.SetupDefaultValues(); 53 | Lens.SetupDefaultValues(); 54 | } 55 | 56 | public bool IsValid() 57 | { 58 | return m_Body.IsValid() && m_Lens.IsValid(); 59 | } 60 | 61 | public PhysicalCameraModel() 62 | { 63 | SetDefaultValues(); 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/Scripts/PhysicalCamera.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections; 3 | using Unity.Vfx.Cameras.Model; 4 | 5 | namespace Unity.Vfx.Cameras 6 | { 7 | 8 | public enum PhysicalCameraMode 9 | { 10 | Controller, 11 | Slave 12 | } 13 | 14 | [AddComponentMenu("Camera/Physical Camera")] 15 | [ExecuteInEditMode] 16 | public class PhysicalCamera : MonoBehaviour 17 | { 18 | public PhysicalCameraMode m_Mode; 19 | 20 | [SerializeField] private PhysicalCameraModel m_Model; 21 | public PhysicalCameraModel Model 22 | { 23 | get 24 | { 25 | return m_Model ?? (m_Model = new PhysicalCameraModel()); 26 | } 27 | } 28 | 29 | [Tooltip("The render camera component that is linked to this physical camera model.")] 30 | public Camera m_AssociatedCameraObj; 31 | 32 | 33 | public void Update() 34 | { 35 | if (m_AssociatedCameraObj == null) 36 | { 37 | var camera = transform.GetComponentInParent(); 38 | if (camera != null) 39 | m_AssociatedCameraObj = camera; 40 | else 41 | return; 42 | } 43 | 44 | if (m_Mode == PhysicalCameraMode.Controller) 45 | { 46 | if (m_AssociatedCameraObj.orthographic != (Model.m_ProjectionMode == ProjectionMode.Orthographic)) 47 | m_AssociatedCameraObj.orthographic = Model.m_ProjectionMode == ProjectionMode.Orthographic; 48 | 49 | if (m_AssociatedCameraObj.fieldOfView != Model.VerticalFOV) 50 | m_AssociatedCameraObj.fieldOfView = Model.VerticalFOV; 51 | 52 | if (m_AssociatedCameraObj.nearClipPlane != Model.m_NearClippingPlane) 53 | m_AssociatedCameraObj.nearClipPlane = Model.m_NearClippingPlane; 54 | 55 | if (m_AssociatedCameraObj.farClipPlane != Model.m_FarClippingPlane) 56 | m_AssociatedCameraObj.farClipPlane = Model.m_FarClippingPlane; 57 | } 58 | else 59 | { 60 | if (m_AssociatedCameraObj.orthographic != (Model.m_ProjectionMode == ProjectionMode.Orthographic)) 61 | { 62 | Model.m_ProjectionMode = m_AssociatedCameraObj.orthographic 63 | ? ProjectionMode.Orthographic 64 | : ProjectionMode.Perspective; 65 | } 66 | 67 | if (m_AssociatedCameraObj.fieldOfView != Model.VerticalFOV) 68 | Model.VerticalFOV = m_AssociatedCameraObj.fieldOfView; 69 | 70 | if (m_AssociatedCameraObj.nearClipPlane != Model.m_NearClippingPlane) 71 | Model.m_NearClippingPlane = m_AssociatedCameraObj.nearClipPlane; 72 | 73 | if (m_AssociatedCameraObj.farClipPlane != Model.m_FarClippingPlane) 74 | Model.m_FarClippingPlane = m_AssociatedCameraObj.farClipPlane; 75 | } 76 | } 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/Scripts/PhysicalCamera.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 22be42f0897cf4d4daffb985c40c89d5 3 | timeCreated: 1485979229 4 | licenseType: Free 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Project/Assets/Vfx-Camera/testScene.unity: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | %TAG !u! tag:unity3d.com,2011: 3 | --- !u!29 &1 4 | OcclusionCullingSettings: 5 | m_ObjectHideFlags: 0 6 | serializedVersion: 2 7 | m_OcclusionBakeSettings: 8 | smallestOccluder: 5 9 | smallestHole: 0.25 10 | backfaceThreshold: 100 11 | m_SceneGUID: 00000000000000000000000000000000 12 | m_OcclusionCullingData: {fileID: 0} 13 | --- !u!104 &2 14 | RenderSettings: 15 | m_ObjectHideFlags: 0 16 | serializedVersion: 8 17 | m_Fog: 0 18 | m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} 19 | m_FogMode: 3 20 | m_FogDensity: 0.01 21 | m_LinearFogStart: 0 22 | m_LinearFogEnd: 300 23 | m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} 24 | m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} 25 | m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} 26 | m_AmbientIntensity: 1 27 | m_AmbientMode: 0 28 | m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} 29 | m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} 30 | m_HaloStrength: 0.5 31 | m_FlareStrength: 1 32 | m_FlareFadeSpeed: 3 33 | m_HaloTexture: {fileID: 0} 34 | m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} 35 | m_DefaultReflectionMode: 0 36 | m_DefaultReflectionResolution: 128 37 | m_ReflectionBounces: 1 38 | m_ReflectionIntensity: 1 39 | m_CustomReflection: {fileID: 0} 40 | m_Sun: {fileID: 0} 41 | m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} 42 | --- !u!157 &3 43 | LightmapSettings: 44 | m_ObjectHideFlags: 0 45 | serializedVersion: 11 46 | m_GIWorkflowMode: 0 47 | m_GISettings: 48 | serializedVersion: 2 49 | m_BounceScale: 1 50 | m_IndirectOutputScale: 1 51 | m_AlbedoBoost: 1 52 | m_TemporalCoherenceThreshold: 1 53 | m_EnvironmentLightingMode: 0 54 | m_EnableBakedLightmaps: 1 55 | m_EnableRealtimeLightmaps: 1 56 | m_LightmapEditorSettings: 57 | serializedVersion: 9 58 | m_Resolution: 2 59 | m_BakeResolution: 40 60 | m_TextureWidth: 1024 61 | m_TextureHeight: 1024 62 | m_AO: 0 63 | m_AOMaxDistance: 1 64 | m_CompAOExponent: 1 65 | m_CompAOExponentDirect: 0 66 | m_Padding: 2 67 | m_LightmapParameters: {fileID: 0} 68 | m_LightmapsBakeMode: 1 69 | m_TextureCompression: 1 70 | m_FinalGather: 0 71 | m_FinalGatherFiltering: 1 72 | m_FinalGatherRayCount: 256 73 | m_ReflectionCompression: 2 74 | m_MixedBakeMode: 1 75 | m_BakeBackend: 0 76 | m_PVRSampling: 1 77 | m_PVRDirectSampleCount: 32 78 | m_PVRSampleCount: 500 79 | m_PVRBounces: 2 80 | m_PVRFiltering: 0 81 | m_PVRFilteringMode: 1 82 | m_PVRCulling: 1 83 | m_PVRFilteringGaussRadiusDirect: 1 84 | m_PVRFilteringGaussRadiusIndirect: 5 85 | m_PVRFilteringGaussRadiusAO: 2 86 | m_PVRFilteringAtrousColorSigma: 1 87 | m_PVRFilteringAtrousNormalSigma: 1 88 | m_PVRFilteringAtrousPositionSigma: 1 89 | m_LightingDataAsset: {fileID: 0} 90 | m_UseShadowmask: 0 91 | --- !u!196 &4 92 | NavMeshSettings: 93 | serializedVersion: 2 94 | m_ObjectHideFlags: 0 95 | m_BuildSettings: 96 | serializedVersion: 2 97 | agentTypeID: 0 98 | agentRadius: 0.5 99 | agentHeight: 2 100 | agentSlope: 45 101 | agentClimb: 0.4 102 | ledgeDropHeight: 0 103 | maxJumpAcrossDistance: 0 104 | minRegionArea: 2 105 | manualCellSize: 0 106 | cellSize: 0.16666667 107 | manualTileSize: 0 108 | tileSize: 256 109 | accuratePlacement: 0 110 | m_NavMeshData: {fileID: 0} 111 | --- !u!1 &461684491 112 | GameObject: 113 | m_ObjectHideFlags: 0 114 | m_PrefabParentObject: {fileID: 0} 115 | m_PrefabInternal: {fileID: 0} 116 | serializedVersion: 5 117 | m_Component: 118 | - component: {fileID: 461684496} 119 | - component: {fileID: 461684495} 120 | - component: {fileID: 461684494} 121 | - component: {fileID: 461684493} 122 | - component: {fileID: 461684492} 123 | m_Layer: 0 124 | m_Name: Main Camera 125 | m_TagString: MainCamera 126 | m_Icon: {fileID: 0} 127 | m_NavMeshLayer: 0 128 | m_StaticEditorFlags: 0 129 | m_IsActive: 1 130 | --- !u!81 &461684492 131 | AudioListener: 132 | m_ObjectHideFlags: 0 133 | m_PrefabParentObject: {fileID: 0} 134 | m_PrefabInternal: {fileID: 0} 135 | m_GameObject: {fileID: 461684491} 136 | m_Enabled: 1 137 | --- !u!124 &461684493 138 | Behaviour: 139 | m_ObjectHideFlags: 0 140 | m_PrefabParentObject: {fileID: 0} 141 | m_PrefabInternal: {fileID: 0} 142 | m_GameObject: {fileID: 461684491} 143 | m_Enabled: 1 144 | --- !u!92 &461684494 145 | Behaviour: 146 | m_ObjectHideFlags: 0 147 | m_PrefabParentObject: {fileID: 0} 148 | m_PrefabInternal: {fileID: 0} 149 | m_GameObject: {fileID: 461684491} 150 | m_Enabled: 1 151 | --- !u!20 &461684495 152 | Camera: 153 | m_ObjectHideFlags: 0 154 | m_PrefabParentObject: {fileID: 0} 155 | m_PrefabInternal: {fileID: 0} 156 | m_GameObject: {fileID: 461684491} 157 | m_Enabled: 1 158 | serializedVersion: 2 159 | m_ClearFlags: 1 160 | m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} 161 | m_NormalizedViewPortRect: 162 | serializedVersion: 2 163 | x: 0 164 | y: 0 165 | width: 1 166 | height: 1 167 | near clip plane: 0.03 168 | far clip plane: 1000 169 | field of view: 57.29578 170 | orthographic: 0 171 | orthographic size: 5 172 | m_Depth: -1 173 | m_CullingMask: 174 | serializedVersion: 2 175 | m_Bits: 4294967295 176 | m_RenderingPath: -1 177 | m_TargetTexture: {fileID: 0} 178 | m_TargetDisplay: 0 179 | m_TargetEye: 3 180 | m_HDR: 1 181 | m_AllowMSAA: 1 182 | m_ForceIntoRT: 0 183 | m_OcclusionCulling: 1 184 | m_StereoConvergence: 10 185 | m_StereoSeparation: 0.022 186 | m_StereoMirrorMode: 0 187 | --- !u!4 &461684496 188 | Transform: 189 | m_ObjectHideFlags: 0 190 | m_PrefabParentObject: {fileID: 0} 191 | m_PrefabInternal: {fileID: 0} 192 | m_GameObject: {fileID: 461684491} 193 | m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} 194 | m_LocalPosition: {x: 0, y: 1, z: -10} 195 | m_LocalScale: {x: 1, y: 1, z: 1} 196 | m_Children: 197 | - {fileID: 1048097755} 198 | m_Father: {fileID: 0} 199 | m_RootOrder: 0 200 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 201 | --- !u!1001 &1048097754 202 | Prefab: 203 | m_ObjectHideFlags: 0 204 | serializedVersion: 2 205 | m_Modification: 206 | m_TransformParent: {fileID: 461684496} 207 | m_Modifications: 208 | - target: {fileID: 4494032398450724, guid: 837da195ec89af645964847601adf512, type: 2} 209 | propertyPath: m_LocalPosition.x 210 | value: 0 211 | objectReference: {fileID: 0} 212 | - target: {fileID: 4494032398450724, guid: 837da195ec89af645964847601adf512, type: 2} 213 | propertyPath: m_LocalPosition.y 214 | value: 0 215 | objectReference: {fileID: 0} 216 | - target: {fileID: 4494032398450724, guid: 837da195ec89af645964847601adf512, type: 2} 217 | propertyPath: m_LocalPosition.z 218 | value: 0 219 | objectReference: {fileID: 0} 220 | - target: {fileID: 4494032398450724, guid: 837da195ec89af645964847601adf512, type: 2} 221 | propertyPath: m_LocalRotation.x 222 | value: -0 223 | objectReference: {fileID: 0} 224 | - target: {fileID: 4494032398450724, guid: 837da195ec89af645964847601adf512, type: 2} 225 | propertyPath: m_LocalRotation.y 226 | value: -0 227 | objectReference: {fileID: 0} 228 | - target: {fileID: 4494032398450724, guid: 837da195ec89af645964847601adf512, type: 2} 229 | propertyPath: m_LocalRotation.z 230 | value: -0 231 | objectReference: {fileID: 0} 232 | - target: {fileID: 4494032398450724, guid: 837da195ec89af645964847601adf512, type: 2} 233 | propertyPath: m_LocalRotation.w 234 | value: 1 235 | objectReference: {fileID: 0} 236 | - target: {fileID: 4494032398450724, guid: 837da195ec89af645964847601adf512, type: 2} 237 | propertyPath: m_RootOrder 238 | value: 0 239 | objectReference: {fileID: 0} 240 | m_RemovedComponents: [] 241 | m_ParentPrefab: {fileID: 100100000, guid: 837da195ec89af645964847601adf512, type: 2} 242 | m_RootGameObject: {fileID: 1064927769} 243 | m_IsPrefabParent: 0 244 | --- !u!4 &1048097755 245 | Transform: 246 | m_ObjectHideFlags: 0 247 | m_PrefabParentObject: {fileID: 4494032398450724, guid: 837da195ec89af645964847601adf512, 248 | type: 2} 249 | m_PrefabInternal: {fileID: 1048097754} 250 | m_GameObject: {fileID: 1064927769} 251 | m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} 252 | m_LocalPosition: {x: 0, y: 0, z: 0} 253 | m_LocalScale: {x: 1, y: 1, z: 1} 254 | m_Children: [] 255 | m_Father: {fileID: 461684496} 256 | m_RootOrder: 0 257 | m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} 258 | --- !u!1 &1064927769 259 | GameObject: 260 | m_ObjectHideFlags: 0 261 | m_PrefabParentObject: {fileID: 1840544312999118, guid: 837da195ec89af645964847601adf512, 262 | type: 2} 263 | m_PrefabInternal: {fileID: 1048097754} 264 | serializedVersion: 5 265 | m_Component: 266 | - component: {fileID: 1048097755} 267 | - component: {fileID: 1064927770} 268 | m_Layer: 0 269 | m_Name: Full Frame - 24mm (default) 270 | m_TagString: Untagged 271 | m_Icon: {fileID: 0} 272 | m_NavMeshLayer: 0 273 | m_StaticEditorFlags: 0 274 | m_IsActive: 1 275 | --- !u!114 &1064927770 276 | MonoBehaviour: 277 | m_ObjectHideFlags: 0 278 | m_PrefabParentObject: {fileID: 114736796904338916, guid: 837da195ec89af645964847601adf512, 279 | type: 2} 280 | m_PrefabInternal: {fileID: 1048097754} 281 | m_GameObject: {fileID: 1064927769} 282 | m_Enabled: 1 283 | m_EditorHideFlags: 0 284 | m_Script: {fileID: 11500000, guid: 22be42f0897cf4d4daffb985c40c89d5, type: 3} 285 | m_Name: 286 | m_EditorClassIdentifier: 287 | m_Mode: 0 288 | m_Model: 289 | m_ProjectionMode: 0 290 | m_StereoScopic: 0 291 | m_NearClippingPlane: 0.03 292 | m_FarClippingPlane: 1000 293 | m_AutoFocus: 0 294 | m_Exposure: 0 295 | m_Body: 296 | m_SensorWidth: 0.036 297 | m_SensorHeight: 0.024 298 | m_LensShiftX: 0 299 | m_LensShiftY: 0 300 | m_PerspectiveCorrection: 0 301 | m_ShutterAngle: 180 302 | m_ISO: 800 303 | m_HDR: 0 304 | m_Lens: 305 | m_FocalLength: 0.024 306 | m_FStop: 2.8 307 | m_Aperture: 0 308 | m_ApertureAspectRatio: 1 309 | m_ApertureEdge: 1 310 | m_Distortion: 0 311 | m_FocalDepth: 0 312 | m_Stereo: 313 | m_Mode: 0 314 | m_EyeDistance: 0 315 | m_SwapEyes: 0 316 | m_LeftFilter: {r: 0, g: 0, b: 0, a: 0} 317 | m_RightFilter: {r: 0, g: 0, b: 0, a: 0} 318 | m_AssociatedCameraObj: {fileID: 0} 319 | --- !u!1 &1279286702 320 | GameObject: 321 | m_ObjectHideFlags: 0 322 | m_PrefabParentObject: {fileID: 0} 323 | m_PrefabInternal: {fileID: 0} 324 | serializedVersion: 5 325 | m_Component: 326 | - component: {fileID: 1279286704} 327 | - component: {fileID: 1279286703} 328 | m_Layer: 0 329 | m_Name: Directional Light 330 | m_TagString: Untagged 331 | m_Icon: {fileID: 0} 332 | m_NavMeshLayer: 0 333 | m_StaticEditorFlags: 0 334 | m_IsActive: 1 335 | --- !u!108 &1279286703 336 | Light: 337 | m_ObjectHideFlags: 0 338 | m_PrefabParentObject: {fileID: 0} 339 | m_PrefabInternal: {fileID: 0} 340 | m_GameObject: {fileID: 1279286702} 341 | m_Enabled: 1 342 | serializedVersion: 8 343 | m_Type: 1 344 | m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} 345 | m_Intensity: 1 346 | m_Range: 10 347 | m_SpotAngle: 30 348 | m_CookieSize: 10 349 | m_Shadows: 350 | m_Type: 2 351 | m_Resolution: -1 352 | m_CustomResolution: -1 353 | m_Strength: 1 354 | m_Bias: 0.05 355 | m_NormalBias: 0.4 356 | m_NearPlane: 0.2 357 | m_Cookie: {fileID: 0} 358 | m_DrawHalo: 0 359 | m_Flare: {fileID: 0} 360 | m_RenderMode: 0 361 | m_CullingMask: 362 | serializedVersion: 2 363 | m_Bits: 4294967295 364 | m_Lightmapping: 4 365 | m_AreaSize: {x: 1, y: 1} 366 | m_BounceIntensity: 1 367 | m_FalloffTable: 368 | m_Table[0]: 0 369 | m_Table[1]: 0 370 | m_Table[2]: 0 371 | m_Table[3]: 0 372 | m_Table[4]: 0 373 | m_Table[5]: 0 374 | m_Table[6]: 0 375 | m_Table[7]: 0 376 | m_Table[8]: 0 377 | m_Table[9]: 0 378 | m_Table[10]: 0 379 | m_Table[11]: 0 380 | m_Table[12]: 0 381 | m_ColorTemperature: 6570 382 | m_UseColorTemperature: 0 383 | m_ShadowRadius: 0 384 | m_ShadowAngle: 0 385 | --- !u!4 &1279286704 386 | Transform: 387 | m_ObjectHideFlags: 0 388 | m_PrefabParentObject: {fileID: 0} 389 | m_PrefabInternal: {fileID: 0} 390 | m_GameObject: {fileID: 1279286702} 391 | m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} 392 | m_LocalPosition: {x: 0, y: 3, z: 0} 393 | m_LocalScale: {x: 1, y: 1, z: 1} 394 | m_Children: [] 395 | m_Father: {fileID: 0} 396 | m_RootOrder: 1 397 | m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} 398 | -------------------------------------------------------------------------------- /Project/VFX-PhysicalCameras.unitypackage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Unity-Technologies/Physical-Camera/3f1e0f8542973f5a83c3262923bdb13d51c9da80/Project/VFX-PhysicalCameras.unitypackage -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity's Physical-Camera 2 | 3 | 4 | ## Overview 5 | - A real world physical cameras model that can drive a standard Unity Camera object. 6 | 7 | ## Objectives 8 | - Import and deliver proper lens/FOV/physical camera properties so Unity can be used in VFX and film pipelines. 9 | - Allow people from outside the game world like cinematographers to have a familiar interface. 10 | - Build the foundation for a proper cinematic camera component with appropriate connections to PostFX. 11 | 12 | 13 | ## Usage 14 | - Import this package: [USDForUnity.unitypackage](https://github.com/Unity-Technologies/Physical-Camera/tree/master/Project/VFX-PhysicalCameras.unitypackage ) 15 | - In the scene select the game object that the camera to link with the Physical Camera and add component "Camera/Physical Camera" 16 | 17 | 18 | 19 | - Alternatively, you can drag and drop an existing physical camera prefab onto a camera object. 20 | 21 | 22 | 23 | ## Notes 24 | - Many of the fields, at the moment, have no impact in Unity itself. 25 | - Should work with Unity 5.6 and up. 26 | - Work in progress. 27 | - For the Physical-Camera to synch with a camera, it's needs to be explicitely linked throught it's "Associated Camera" property. This property is auto-set, when not set, to the first camera object that it find on it's parent game object. 28 | 29 | 30 | 31 | ## License 32 | [MIT](USDForUnity/Assets/StreamingAssets/USDForUnity/License.txt) --------------------------------------------------------------------------------