2
0

fixed_materials.rst 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  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 also won't
  29. 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 a
  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 transparent pixels are blended
  47. with what is behind them. In some combinations (of using alpha to
  48. render depth) it may be possible that transparent 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. and is diffusely back-scattered then. This color varies by the angle between
  60. the face and the light and the distance to the light source
  61. (in the case of spot and omni lights). It is
  62. the color that best represents the material. It can also have alpha
  63. (transparency).
  64. - Specular color is the color of the reflected light and responsible
  65. for shines. It is affected by the specular exponent.
  66. - Emission is the color of the light generated within the material
  67. (although it will not lit anything else around unless baking). This
  68. color is constant.
  69. - Specular Exponent (or "Shininess"/"Intensity" in some 3D DCCs) is the
  70. way light is reflected. If the value is high, light is reflected
  71. completely, otherwise it is diffused more and more.
  72. Below is an example of how they interact:
  73. .. image:: /img/fixed_material_colors.png
  74. Shader & shader param
  75. ~~~~~~~~~~~~~~~~~~~~~
  76. Regular shader materials allow custom lighting code. Fixed materials
  77. come with four predefined shader types:
  78. - **Lambert**: The standard diffuse light, where the amount of light is
  79. proportional to the angle from the light emitter.
  80. - **Wrap**: A variation on Lambert, where the "coverage" of the light
  81. can be changed. This is useful for many types of materials such as
  82. wood, clay, hair, etc.
  83. - **Velvet**: This is similar to Lambert, but adds light scattering in
  84. the edges. It's useful for leathers and some types of metals.
  85. - **Toon**: Standard toon shading with a coverage parameter. The
  86. specular component also becomes toon-ized.
  87. .. image:: /img/fixed_material_shader.png
  88. Detail & detail mix
  89. ~~~~~~~~~~~~~~~~~~~
  90. Detail is a second diffuse texture which can be mixed with the first one
  91. (more on textures later!). Detail blend and mix control how these are
  92. added together, here's an example of what detail textures are for:
  93. .. image:: /img/fixed_material_detail.png
  94. Normal depth
  95. ~~~~~~~~~~~~
  96. Normal depth controls the strength and the direction of normal-mapping.
  97. If it is set to 1 (the default), the un-scaled normal map is applied.
  98. Values larger than 1 make normal-mapping more pronounced (dents and bumps
  99. become larger), while values smaller than 1 reduce the effect. A normal
  100. depth of 0 disables normal-mapping. Negative values invert the normal map
  101. so dents become bumps and vice versa. Here is an example showing the
  102. influence of the normal depth on the outcome:
  103. .. image:: /img/fixed_material_normal_depth.png
  104. Glow
  105. ~~~~
  106. This value controls how much of the color is sent to the glow buffer. It
  107. can be greater than 1 for a stronger effect. For glow to work, a
  108. WorldEnvironment must exist with Glow activated.
  109. .. image:: /img/fixed_material_glow.png
  110. Blend mode
  111. ~~~~~~~~~~
  112. Objects are usually blended in Mix mode. Other blend modes (Add and Sub)
  113. exist for special cases (usually particle effects, light rays, etc.) but
  114. materials can be set to them:
  115. .. image:: /img/fixed_material_blend.png
  116. Point size, line width
  117. ~~~~~~~~~~~~~~~~~~~~~~
  118. When drawing points or lines, the size of them can be adjusted here per
  119. material.
  120. Textures
  121. --------
  122. Almost all of the parameters above can have a texture assigned to them.
  123. There are four options to where they can get their UV coordinates:
  124. - **UV Coordinates (UV Array)**: This is the regular UV coordinate
  125. array that was imported with the model.
  126. - **UV x UV XForm**: UV Coordinates multiplied by the UV Xform matrix.
  127. - **UV2 Coordinates**: Some imported models might have come with a
  128. second set of UV coordinates. These are common for detail textures or
  129. for baked light textures.
  130. - **Sphere**: Spherical coordinates (difference of the normal at the
  131. pixel by the camera normal).
  132. The value of every pixel of the texture is multiplied by the original
  133. parameter. This means that if a texture is loaded for diffuse, it will
  134. be multiplied by the color of the diffuse color parameter. Same applies
  135. to all the others except for specular exponent, which is replaced.