shader_materials.rst 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. .. _doc_shader_materials:
  2. Shader materials
  3. ================
  4. Introduction
  5. ------------
  6. For the most common cases, Godot provides ready to use materials for
  7. most types of shaders, such as :ref:`StandardMaterial3D <class_StandardMaterial3D>`,
  8. :ref:`CanvasItemMaterial <class_CanvasItemMaterial>` and :ref:`ParticleProcessMaterial <class_ParticleProcessMaterial>`.
  9. They are flexible implementations that cover most use cases.
  10. Shader materials allow writing a custom shader directly, for maximum flexibility.
  11. Examples of this are:
  12. - Create procedural textures.
  13. - Create complex texture blending effects.
  14. - Create animated materials, or materials that change over time.
  15. - Create refractive effects or other advanced effects.
  16. - Create special lighting shaders for more exotic materials.
  17. - Animate vertices, like tree leaves or grass.
  18. - Create custom particle code.
  19. - And much more!
  20. Godot provides built-in functionality to make frequent operations
  21. easier. Additionally, Godot's shader editor will detect errors as you
  22. type, so you can see your edited shaders in real-time. It is also
  23. possible to edit shaders using a visual, node-based graph editor.
  24. Creating a ShaderMaterial
  25. -------------------------
  26. Create a new ShaderMaterial in some object of your choice. Go to the
  27. "Material" property and create a ShaderMaterial.
  28. .. image:: img/shader_material_create.png
  29. Next, click on the shader material to see its properties. From here you
  30. can create a shader or visual shader. Regular shaders use code to set
  31. their properties while a visual shader uses a node based workflow.
  32. If you need to you can convert a visual shader to a text shader.
  33. However you can't convert a text shader to a visual shader.
  34. Choose one of them and you can start editing your shader.
  35. .. image:: img/shader_create.png
  36. If you create a regular shader click on it and the shader editor will open.
  37. .. image:: img/shader_material_editor.png
  38. If you create a visual shader the visual shader editor will open automatically.
  39. .. image:: img/visual_shader_editor.png
  40. In the visual shader editor you can click a button and see what your visual
  41. shader looks like as shader code. This can be useful if you're trying to
  42. replicate a text shader as nodes, or it can be used as a preview for converting
  43. your visual shader to a text shader.
  44. .. image:: img/visual_shader_code.png
  45. .. note::
  46. To learn more about visual shaders, read :ref:`doc_visual_shaders`.
  47. Converting to ShaderMaterial
  48. ----------------------------
  49. It is possible to convert from StandardMaterial3D, CanvasItemMaterial and
  50. ParticleProcessMaterial to ShaderMaterial. To do so, go to the material properties
  51. and select the convert option.
  52. .. image:: img/shader_material_convert.png
  53. .. note::
  54. Using the convert option will turn the StandardMaterial3D into a ShaderMaterial
  55. with a text shader, not a visual shader.