physical_light_and_camera_units.rst 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280
  1. .. _doc_physical_light_and_camera_units:
  2. Physical light and camera units
  3. ===============================
  4. Why use physical light and camera units?
  5. ----------------------------------------
  6. Godot uses arbitrary units for many physical properties that apply to light like
  7. color, energy, camera field of view, and exposure. By default, these properties
  8. use arbitrary units, because using accurate physical units comes with a few
  9. tradeoffs that aren't worth it for many games. As Godot favors ease of use by
  10. default, physical light units are disabled by default.
  11. Advantages of physical units
  12. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  13. If you aim for photorealism in your project, using real world units as a basis
  14. can help make things easier to adjust. References for real world materials,
  15. lights and scene brightness are wildly available on websites such as
  16. `Physically Based <https://physicallybased.info/>`__.
  17. Using real world units in Godot can also be useful when porting a scene from
  18. other 3D software that uses physical light units (such as Blender).
  19. Disadvantages of physical units
  20. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  21. The biggest disadvantage of using physical light units is you will have to pay
  22. close attention to the dynamic range in use at a given time. You can run into
  23. floating point precision errors when mixing very high light intensities with
  24. very low light intensities.
  25. In practice, this means that you will have to manually manage your exposure
  26. settings to ensure that you aren't over-exposing or under-exposing your scene
  27. too much. Auto-exposure can help you balance the light in a scene to bring it
  28. into a normal range, but it can't recover lost precision from a dynamic range
  29. that is too high.
  30. Using physical light and camera units will not automatically make your project
  31. look *better*. Sometimes, moving away from realism can actually make a scene
  32. look better to the human eye. Also, using physical units requires a greater
  33. amount of rigor compared to non-physical units. Most benefits of physical units
  34. can only be obtained if the units are correctly set to match real world
  35. reference.
  36. .. note::
  37. Physical light units are only available in 3D rendering, not 2D.
  38. Setting up physical light units
  39. -------------------------------
  40. Physical light units can be enabled separately from physical camera units.
  41. To enable physical light units correctly, there are 4 steps required:
  42. 1. Enable the project setting.
  43. 2. Configure the camera.
  44. 3. Configure the environment.
  45. 4. Configure Light3D nodes.
  46. Since physical light and camera units only require a handful of calculations to
  47. handle unit conversion, enabling them doesn't have any noticeable performance
  48. impact on the CPU. However, on the GPU side, physical camera units currently
  49. enforce depth of field. This has a moderate performance impact. To alleviate
  50. this performance impact, depth of field quality can be decreased in the advanced
  51. Project Settings.
  52. Enable the project setting
  53. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  54. Open the Project Settings, enable the **Advanced** toggle then enable
  55. **Rendering > Lights And Shadows > Use Physical Light Units**. Restart the editor.
  56. Configure the camera
  57. ^^^^^^^^^^^^^^^^^^^^
  58. .. warning::
  59. When physical light units are enabled and if you have a WorldEnvironment
  60. node in your scene (i.e. the editor Environment is disabled), you **must**
  61. have a :ref:`class_CameraAttributes` resource assigned to the
  62. WorldEnvironment node. Otherwise, the 3D editor viewport will appear
  63. extremely bright if you have a visible DirectionalLight3D node.
  64. On the Camera3D node, you can add a :ref:`class_CameraAttributes`
  65. resource to its **Attributes** property. This resource is used to control the
  66. camera's depth of field and exposure. When using
  67. :ref:`class_CameraAttributesPhysical`, its focal length property is also used to
  68. adjust the camera's field of view.
  69. When physical light units are enabled, the following additional properties
  70. become available in CameraAttributesPhysical's **Exposure** section:
  71. - **Aperture:** The size of the aperture of the camera, measured in f-stops. An
  72. f-stop is a unitless ratio between the focal length of the camera and the
  73. diameter of the aperture. A high aperture setting will result in a smaller
  74. aperture which leads to a dimmer image and sharper focus. A low aperture
  75. results in a wide aperture which lets in more light resulting in a brighter,
  76. less-focused image.
  77. - **Shutter Speed:** The time for shutter to open and close, measured in
  78. *inverse seconds* (``1/N``). A lower value will let in more light leading to a
  79. brighter image, while a higher value will let in less light leading to a
  80. darker image. *When getting or setting this property with a script, the unit
  81. is in seconds instead of inverse seconds.*
  82. - **Sensitivity:** The sensitivity of camera sensors, measured in ISO. A higher
  83. sensitivity results in a brighter image. When auto exposure is enabled, this
  84. can be used as a method of exposure compensation. Doubling the value will
  85. increase the exposure value (measured in EV100) by 1 stop.
  86. - **Multiplier:** A *non-physical* exposure multiplier. Higher values will
  87. increase the scene's brightness. This can be used for post-processing
  88. adjustments or for animation purposes.
  89. The default **Aperture** value of 16 f-stops is appropriate for outdoors at
  90. daytime (i.e. for use with a default DirectionalLight3D). For indoor lighting, a
  91. value between 2 and 4 is more appropriate.
  92. Typical shutter speed used in photography and movie production is 1/50 (0.02
  93. seconds). Night-time photography generally uses a shutter around 1/10 (0.1
  94. seconds), while sports photography uses a shutter speed between 1/250 (0.004
  95. seconds) and 1/1000 (0.001 seconds) to reduce motion blur.
  96. In real life, sensitivity is usually set between 50 ISO and 400 ISO for daytime
  97. outdoor photography depending on weather conditions. Higher values are used for
  98. indoor or night-time photography.
  99. .. note::
  100. Unlike real life cameras, the adverse effects of increasing ISO sensitivity
  101. or decreasing shutter speed (such as visible grain or light trails) are not
  102. simulated in Godot.
  103. See :ref:`doc_physical_light_and_camera_units_setting_up_physical_camera_units`
  104. for a description of CameraAttributesPhysical properties that are also available when
  105. **not** using physical light units.
  106. Configure the environment
  107. ^^^^^^^^^^^^^^^^^^^^^^^^^
  108. .. warning::
  109. The default configuration is designed for daytime outdoor scenes. Night-time
  110. and indoor scenes will need adjustments to the DirectionalLight3D and
  111. WorldEnvironment background intensity to look correct. Otherwise, positional
  112. lights will be barely visible at their default intensity.
  113. If you haven't added a :ref:`class_WorldEnvironment` and :ref:`class_Camera3D`
  114. node to the current scene yet, do so now by clicking the 3 vertical dots at the
  115. top of the 3D editor viewport. Click **Add Sun to Scene**, open the dialog again
  116. then click **Add Environment to Scene**.
  117. After enabling physical light units, a new property becomes available to edit in
  118. the :ref:`class_Environment` resource:
  119. - **Background Intensity:** The background sky's intensity in
  120. `nits <https://en.wikipedia.org/wiki/Candela_per_square_metre>`__
  121. (candelas per square meter). This also affects ambient and reflected light if
  122. their respective modes are set to **Background**. If a custom **Background Energy**
  123. is set, this energy is multiplied by the intensity.
  124. Configure the light nodes
  125. ^^^^^^^^^^^^^^^^^^^^^^^^^
  126. After enabling physical light units, 2 new properties become available in Light3D nodes:
  127. - **Intensity:** The light's intensity in `lux
  128. <https://en.wikipedia.org/wiki/Lux>`__ (DirectionalLight3D) or
  129. `lumens <https://en.wikipedia.org/wiki/Lumen_(unit)>`__ (OmniLight3D/SpotLight3D).
  130. If a custom **Energy** is set, this energy is multiplied by the intensity.
  131. - **Temperature:** The light's *color temperature* defined in Kelvin.
  132. If a custom **Color** is set, this color is multiplied by the color temperature.
  133. **OmniLight3D/SpotLight3D intensity**
  134. Lumens are a measure of luminous flux, which is the total amount of visible
  135. light emitted by a light source per unit of time.
  136. For SpotLight3Ds, we assume that the area outside the visible cone is surrounded
  137. by a perfect light absorbing material. Accordingly, the apparent brightness of
  138. the cone area does *not* change as the cone increases and decreases in size.
  139. A typical household lightbulb can range from around 600 lumens to 1200 lumens.
  140. A candle is about 13 lumens, while a streetlight can be approximately 60000 lumens.
  141. **DirectionalLight3D intensity**
  142. Lux is a measure pf luminous flux per unit area, it is equal to one lumen per
  143. square metre. Lux is the measure of how much light hits a surface at a given
  144. time.
  145. With DirectionalLight3D, on a clear sunny day, a surface in direct sunlight may
  146. receive approximately 100000 lux. A typical room in a home may receive
  147. approximately 50 lux, while the moonlit ground may receive approximately 0.1
  148. lux.
  149. **Color temperature**
  150. 6500 Kelvin is white. Higher values result in colder (bluer) colors, while lower
  151. values result in warmer (more orange) colors.
  152. The sun on a cloudy day is approximately 6500 Kelvin. On a clear day, the sun is
  153. between 5500 to 6000 Kelvin. On a clear day at sunrise or sunset, the sun ranges
  154. to around 1850 Kelvin.
  155. .. figure:: img/physical_light_units_color_temperature_chart.webp
  156. :align: center
  157. :alt: Color temperature chart from 1,000 Kelvin (left) to 12,500 Kelvin (right)
  158. Color temperature chart from 1,000 Kelvin (left) to 12,500 Kelvin (right)
  159. Other Light3D properties such as **Energy** and **Color** remain editable for
  160. animation purposes, and when you occasionally need to create lights with
  161. non-realistic properties.
  162. .. _doc_physical_light_and_camera_units_setting_up_physical_camera_units:
  163. Setting up physical camera units
  164. --------------------------------
  165. Physical camera units can be enabled separately from physical light units.
  166. After adding a :ref:`class_CameraAttributesPhysical` resource to the **Camera
  167. Attributes** property of a Camera3D nodes, some properties such as **FOV** will
  168. no longer be editable. Instead, these properties are now governed by the
  169. CameraAttributesPhysical's properties, such as focal length and aperture.
  170. CameraAttributesPhysical offers the following properties in its **Frustum** section:
  171. - **Focus Distance:** Distance from camera of object that will be in focus,
  172. measured in meters. Internally, this will be clamped to be at least 1
  173. millimeter larger than the **Focal Length**.
  174. - **Focal Length:** Distance between camera lens and camera aperture, measured
  175. in millimeters. Controls field of view and depth of field. A larger focal
  176. length will result in a smaller field of view and a narrower depth of field
  177. meaning fewer objects will be in focus. A smaller focal length will result in
  178. a wider field of view and a larger depth of field, which means more objects will be
  179. in focus. This property overrides the Camera3D's **FOV** and **Keep Aspect**
  180. properties, making them read-only in the inspector.
  181. - **Near/Far:** The near and far clip distances in meters. These behave the same
  182. as the Camera3D properties of the same name. Lower **Near** values allow the
  183. camera to display objects that are very close, at the cost of potential
  184. precision (Z-fighting) issues in the distance. Higher **Far** values allow the
  185. camera to see further away, also at the cost of potential precision
  186. (Z-fighting) issues in the distance.
  187. The default focal length of 35 mm corresponds to a wide angle lens. It still
  188. results in a field of view that is noticeably narrower compared to the default
  189. "practical" vertical FOV of 75 degrees. This is because non-gaming use cases
  190. such as filmmaking and photography favor using a narrower field of view for a
  191. more cinematic appearance.
  192. Common focal length values used in filmmaking and photography are:
  193. - **Fisheye (ultrawide angle):** Below 15 mm. Nearly no depth of field visible.
  194. - **Wide angle:** Between 15 mm and 50 mm. Reduced depth of field.
  195. - **Standard:** Between 50 mm and 100 mm. Standard depth of field.
  196. - **Telephoto:** Greater than 100 mm. Increased depth of field.
  197. Like when using the **Keep Height** aspect mode, the effective field of view
  198. depends on the viewport's aspect ratio, with wider aspect ratios automatically
  199. resulting in a wider *horizontal* field of view.
  200. Automatic exposure adjustment based on the camera's average brightness level can
  201. also be enabled in the **Auto Exposure** section, with the following properties:
  202. - **Min Sensitivity:** The darkest brightness the camera is allowed to get to,
  203. measured in EV100.
  204. - **Max Sensitivity:** The brightest the camera is allowed to get to, measured in EV100.
  205. - **Speed:** The speed of the auto exposure effect. Affects the time needed for
  206. the camera to perform auto exposure. Higher values allow for faster
  207. transitions, but the resulting adjustments may look distracting depending on
  208. the scene.
  209. - **Scale:** The scale of the auto exposure effect. Affects the intensity of
  210. auto exposure.
  211. EV100 is an exposure value (EV) measured at an ISO sensitivity of 100. See
  212. `this table <https://en.wikipedia.org/wiki/Exposure_value#Tabulated_exposure_values>`__
  213. for common EV100 values found in real life.