lighting.rst 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. .. _doc_lighting:
  2. Lighting
  3. ========
  4. Introduction
  5. ------------
  6. Lights emit light that mix with the materials and produces a visible
  7. result. Light can come from several types of sources in a scene:
  8. - From the Material itself, in the form of the emission color (though
  9. it does not affect nearby objects unless baked).
  10. - Light Nodes: Directional, Omni and Spot.
  11. - Ambient Light in the
  12. :ref:`Environment <class_Environment>`.
  13. - Baked Light (read :ref:`doc_light_baking`).
  14. The emission color is a material property. You can read more about it
  15. in the :ref:`doc_fixed_materials` tutorial.
  16. Light nodes
  17. -----------
  18. As mentioned before, there are three types of light nodes: Directional,
  19. Omni and Spot. Each has different uses and will be described in
  20. detail below, but first let's take a look at the common parameters for
  21. lights:
  22. .. image:: /img/light_params.png
  23. Each one has a specific function:
  24. - **Enabled**: Light is emitted only if this flag is set.
  25. - **Bake Mode**: When using the light baker, the role of this light can
  26. be defined in this enumerator. The role will be followed even if the
  27. light is disabled, which allows to configure a light and then disable
  28. it for baking.
  29. - **Energy**: This value is a multiplier for the light, it's specially
  30. useful for :ref:`doc_high_dynamic_range` and for Spot and Omni lights, because it can
  31. create very bright spots near the emitter.
  32. - **Diffuse and Specular**: These light values get multiplied by the
  33. material light and diffuse colors. A white value does not mean
  34. that light will be white, but that the material color will be kept.
  35. - **Operator**: It is possible to make some lights negative for a
  36. darkening effect.
  37. - **Projector**: Lights can project a texture for the diffuse light
  38. (currently only supported in Spot light).
  39. Directional light
  40. ~~~~~~~~~~~~~~~~~
  41. This is the most common type of light and represents a light source
  42. very far away (such as the sun). It is also
  43. the cheapest light to compute and should be used whenever possible
  44. (although it's not the cheapest shadow-map to compute, but more on that
  45. later).
  46. Directional light models an infinite number of parallel light rays
  47. covering the whole scene. The directional light node is represented by a big arrow, which
  48. indicates the direction of the light rays. However, the position of the node
  49. does not affect the lighting at all, and can be anywhere.
  50. .. image:: /img/light_directional.png
  51. Every face whose front-side is hit by the light rays is lit, the others stay dark.
  52. Most light types
  53. have specific parameters but directional lights are pretty simple in
  54. nature so they don't.
  55. Omni light
  56. ~~~~~~~~~~
  57. Omni light is a point source that emits light spherically in all directions up to a given
  58. radius (distance from the node's position). The radius is a parameter of the light and
  59. can be controlled by the user. Just as in real life, the intensity of omni light
  60. decreases with the distance and vanishes at the defined radius. Omni light sources
  61. should be used to represent lamps or bulbs or any other light source that originates
  62. approximately in a point.
  63. .. image:: /img/light_omni.png
  64. In reality, the attenuation of omni light is proportional to the squared distance
  65. from the point source. This can be easily understood if you imagine a sphere around
  66. the omni light with a certain radius. No matter how large the sphere is, the number
  67. of rays passing through it is always the same. If the radius of the sphere is doubled,
  68. the area of the sphere increases by four. In other words, the density of rays
  69. (the number of rays per square area) decreases quadratically with the distance.
  70. Inverse-quadratic attenuation curves are inconvenient for artists: they
  71. never reach zero and have almost infinitely large values near the emitter.
  72. So Godot simulates omni light with an artist-controlled exponential curve
  73. instead.
  74. .. image:: /img/light_attenuation.png
  75. Spot light
  76. ~~~~~~~~~~
  77. Spot lights are similar to omni lights, except they emit light only into a cone
  78. (or "cutoff"). They are useful to simulate flashlights,
  79. car lights, etc. This kind of light is also attenuated towards the
  80. opposite direction it points to.
  81. .. image:: /img/light_spot.png
  82. Ambient light
  83. -------------
  84. Ambient light can be found in the properties of a WorldEnvironment
  85. (remember only one of such can be instanced per scene). Ambient light
  86. consists of a uniform light and energy. This light is applied the same
  87. to every single pixel of the rendered scene, except to objects that used
  88. baked light.
  89. Baked light
  90. -----------
  91. Baked light stands for pre-computed ambient light. It can serve multiple
  92. purposes, such as baking light emitters that are not going to be used in
  93. real-time, and baking light bounces from real-time lights to add more
  94. realism to a scene (see :ref:`doc_light_baking` tutorial for more information).