fixed_materials.rst 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. .. _doc_fixed_materials:
  2. Fixed Materials
  3. ===============
  4. Introduction
  5. ------------
  6. Fixed materials (originally Fixed Pipeline Materials) are the most
  7. common type of materials, using the most common material options found
  8. in 3D DCCs (such as Maya, 3DS Max or Blender). The big advantage of
  9. using them is that 3D artists are very familiar with this layout. They
  10. also allow to try out different things quickly without the need of
  11. writing shaders. Fixed Materials inherit from
  12. :ref:`Material <class_Material>`,
  13. which also has several options. If you haven't read it before, reading
  14. the :ref:`doc_materials` tutorial is recommended.
  15. Options
  16. -------
  17. Here is the list of all the options available for fixed materials:
  18. .. image:: /img/fixed_materials.png
  19. From this point, every option will be explained in detail:
  20. Fixed Flags
  21. -----------
  22. These are a set of flags that control general aspects of the material.
  23. Use Alpha
  24. ~~~~~~~~~
  25. This flag needs to be active for transparent materials to blend with
  26. what is behind, otherwise display will always be opaque. Do not enable
  27. this flag unless the material really needs it, because it can severely
  28. affect performance and quality. Materials with transparency will also
  29. not cast shadows (unless they contain opaque areas and the "opaque
  30. pre-pass" hint is turned on, see the :ref:`doc_materials` tutorial for more
  31. information).
  32. .. image:: /img/fixed_material_alpha.png
  33. Use Vertex Colors
  34. ~~~~~~~~~~~~~~~~~
  35. Vertex color painting is a very common technique to add detail to
  36. geometry. 3D DCCs all support this, and many even support baking
  37. occlusion to it. Godot allows this information to be used in the fixed
  38. material by modulating the diffuse color when enabled.
  39. .. image:: /img/fixed_material_vcols.png
  40. Point Size
  41. ~~~~~~~~~~
  42. Point size is used to set the point size (in pixels) for when rendering
  43. points. This feature is mostly used in tools and HUDs
  44. Discard Alpha
  45. ~~~~~~~~~~~~~
  46. When alpha is enabled (see above) the invisible pixels are blended
  47. with what is behind them. In some combinations (of using alpha to
  48. render depth) it may be possible that invisible pixels cover other
  49. objects.
  50. If this is the case, enable this option for the material. This option
  51. is often used in combination with "opaque pre-pass" hint (see the
  52. :ref:`doc_materials` tutorial for more information).
  53. Parameters
  54. ----------
  55. Diffuse, Specular, Emission and Specular Exponent
  56. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  57. These are the base colors for the material.
  58. - Diffuse Color is responsible for the light that reaches the material,
  59. then gets diffused around. This color varies by the angle to the
  60. light and the distance (in the case of spot and omni lights). It is
  61. the color that best represents the material. It can also have alpha
  62. (transparency)
  63. - Specular color is the color of the reflected light and responsible
  64. for shines. It is affected by the specular exponent.
  65. - Emission is the color of the light generated within the material
  66. (althought it will not lit anything else around unless baking). This
  67. color is constant.
  68. - Specular Exponent (or "Shininess"/"Intensity" in some 3D DCCs) is the
  69. way light is reflected. If the value is high, light is reflected
  70. completely, otherwise it is diffused more and more.
  71. Below is an example of how they interact:
  72. .. image:: /img/fixed_material_colors.png
  73. Shader & Shader Param
  74. ~~~~~~~~~~~~~~~~~~~~~
  75. Regular shader materials allow custom lighting code. Fixed materials
  76. come with four predefined shader types:
  77. - **Lambert**: The standard diffuse light, where the amount of light is
  78. proportional to the angle with the light emissor.
  79. - **Wrap**: A variation on Lambert, where the "coverage" of the light
  80. can be changed. This is useful for many types of materials such as
  81. wood, clay, hair, etc.
  82. - **Velvet**: This is similar to Lambert, but adds light scattering in
  83. the edges. It's useful for leathers and some types of metals.
  84. - **Toon**: Standard toon shading with a coverage parameter. The
  85. specular component also becomes toon-ized.
  86. .. image:: /img/fixed_material_shader.png
  87. Detail & Detail Mix
  88. ~~~~~~~~~~~~~~~~~~~
  89. Detail is a second diffuse texture which can be mixed with the first one
  90. (more on textures later!). Detail blend and mix control how these are
  91. added together, here's an example of what detail textures are for:
  92. .. image:: /img/fixed_material_detail.png
  93. Normal Depth
  94. ~~~~~~~~~~~~
  95. Normal depth controls the inensity of the normal-mapping as well as the
  96. direction. On 1 (the default) normalmapping applies normaly, on -1 the
  97. map is inverted and on 0 is disabled. Intermediate or greater values are
  98. accepted. Here's how it's supposed to look:
  99. .. image:: /img/fixed_material_normal_depth.png
  100. Glow
  101. ~~~~
  102. This value controls how much of the color is sent to the glow buffer. It
  103. can be greater than 1 for a stronger effect. For glow to work, a
  104. WorldEnvironment must exist with Glow activated.
  105. .. image:: /img/fixed_material_glow.png
  106. Blend Mode
  107. ~~~~~~~~~~
  108. Objects are usually blended in Mix mode. Other blend modes (Add and Sub)
  109. exist for special cases (usually particle effects, light rays, etc) but
  110. materials can be set to them:
  111. .. image:: /img/fixed_material_blend.png
  112. Point Size, Line Width
  113. ~~~~~~~~~~~~~~~~~~~~~~
  114. When drawing points or lines, the size of them can be adjusted here per
  115. material.
  116. Textures
  117. --------
  118. Almost all of the parameters above can have a texture assigned to them.
  119. There are four options to where they can get their UV coordinates:
  120. - **UV Coordinates (UV Array)**: This is the regular UV coordinate
  121. array that was imported with the model.
  122. - **UV x UV XForm**: UV Coordinates multiplied by the UV Xform matrix.
  123. - **UV2 Coordinates**: Some imported models might have come with a
  124. second set of UV coordinates. These are common for detail textures or
  125. for baked light textures.
  126. - **Sphere**: Spherical coordinates (difference of the normal at the
  127. pixel by the camera normal).
  128. The value of every pixel of the texture is multiplied by the original
  129. parameter. This means that if a texture is loaded for diffuse, it will
  130. be multiplied by the color of the diffuse color parameter. Same applies
  131. to all the others except for specular exponent, which is replaced.