mirror of
https://github.com/Relintai/pandemonium_engine_docs.git
synced 2025-01-21 15:07:22 +01:00
148 lines
6.5 KiB
ReStructuredText
148 lines
6.5 KiB
ReStructuredText
:github_url: hide
|
|
|
|
.. Generated automatically by doc/tools/make_rst.py in Godot's source tree.
|
|
.. DO NOT EDIT THIS FILE, but the Shader.xml source instead.
|
|
.. The source is found in doc/classes or modules/<name>/doc_classes.
|
|
|
|
.. _class_Shader:
|
|
|
|
Shader
|
|
======
|
|
|
|
**Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`Reference<class_Reference>` **<** :ref:`Object<class_Object>`
|
|
|
|
**Inherited By:** :ref:`VisualShader<class_VisualShader>`
|
|
|
|
A custom shader program.
|
|
|
|
Description
|
|
-----------
|
|
|
|
This class allows you to define a custom shader program that can be used by a :ref:`ShaderMaterial<class_ShaderMaterial>`. Shaders allow you to write your own custom behavior for rendering objects or updating particle information. For a detailed explanation and usage, please see the tutorials linked below.
|
|
|
|
Tutorials
|
|
---------
|
|
|
|
- :doc:`../tutorials/shaders/index`
|
|
|
|
- :doc:`../tutorials/shaders/introduction_to_shaders`
|
|
|
|
Properties
|
|
----------
|
|
|
|
+-----------------------------+-------------------------------------------------------------+--------+
|
|
| :ref:`String<class_String>` | :ref:`code<class_Shader_property_code>` | ``""`` |
|
|
+-----------------------------+-------------------------------------------------------------+--------+
|
|
| :ref:`String<class_String>` | :ref:`custom_defines<class_Shader_property_custom_defines>` | ``""`` |
|
|
+-----------------------------+-------------------------------------------------------------+--------+
|
|
|
|
Methods
|
|
-------
|
|
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Texture<class_Texture>` | :ref:`get_default_texture_param<class_Shader_method_get_default_texture_param>` **(** :ref:`String<class_String>` param **)** |const| |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`Mode<enum_Shader_Mode>` | :ref:`get_mode<class_Shader_method_get_mode>` **(** **)** |const| |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| :ref:`bool<class_bool>` | :ref:`has_param<class_Shader_method_has_param>` **(** :ref:`String<class_String>` name **)** |const| |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
| void | :ref:`set_default_texture_param<class_Shader_method_set_default_texture_param>` **(** :ref:`String<class_String>` param, :ref:`Texture<class_Texture>` texture **)** |
|
|
+-------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
|
|
|
Enumerations
|
|
------------
|
|
|
|
.. _enum_Shader_Mode:
|
|
|
|
.. _class_Shader_constant_MODE_SPATIAL:
|
|
|
|
.. _class_Shader_constant_MODE_CANVAS_ITEM:
|
|
|
|
.. _class_Shader_constant_MODE_PARTICLES:
|
|
|
|
enum **Mode**:
|
|
|
|
- **MODE_SPATIAL** = **0** --- Mode used to draw all 3D objects.
|
|
|
|
- **MODE_CANVAS_ITEM** = **1** --- Mode used to draw all 2D objects.
|
|
|
|
- **MODE_PARTICLES** = **2** --- Mode used to calculate particle information on a per-particle basis. Not used for drawing.
|
|
|
|
Property Descriptions
|
|
---------------------
|
|
|
|
.. _class_Shader_property_code:
|
|
|
|
- :ref:`String<class_String>` **code**
|
|
|
|
+-----------+-----------------+
|
|
| *Default* | ``""`` |
|
|
+-----------+-----------------+
|
|
| *Setter* | set_code(value) |
|
|
+-----------+-----------------+
|
|
| *Getter* | get_code() |
|
|
+-----------+-----------------+
|
|
|
|
Returns the shader's code as the user has written it, not the full generated code used internally.
|
|
|
|
----
|
|
|
|
.. _class_Shader_property_custom_defines:
|
|
|
|
- :ref:`String<class_String>` **custom_defines**
|
|
|
|
+-----------+---------------------------+
|
|
| *Default* | ``""`` |
|
|
+-----------+---------------------------+
|
|
| *Setter* | set_custom_defines(value) |
|
|
+-----------+---------------------------+
|
|
| *Getter* | get_custom_defines() |
|
|
+-----------+---------------------------+
|
|
|
|
Returns the shader's custom defines. Custom defines can be used in Godot to add GLSL preprocessor directives (e.g: extensions) required for the shader logic.
|
|
|
|
**Note:** Custom defines are not validated by the Godot shader parser, so care should be taken when using them.
|
|
|
|
Method Descriptions
|
|
-------------------
|
|
|
|
.. _class_Shader_method_get_default_texture_param:
|
|
|
|
- :ref:`Texture<class_Texture>` **get_default_texture_param** **(** :ref:`String<class_String>` param **)** |const|
|
|
|
|
Returns the texture that is set as default for the specified parameter.
|
|
|
|
**Note:** ``param`` must match the name of the uniform in the code exactly.
|
|
|
|
----
|
|
|
|
.. _class_Shader_method_get_mode:
|
|
|
|
- :ref:`Mode<enum_Shader_Mode>` **get_mode** **(** **)** |const|
|
|
|
|
Returns the shader mode for the shader, either :ref:`MODE_CANVAS_ITEM<class_Shader_constant_MODE_CANVAS_ITEM>`, :ref:`MODE_SPATIAL<class_Shader_constant_MODE_SPATIAL>` or :ref:`MODE_PARTICLES<class_Shader_constant_MODE_PARTICLES>`.
|
|
|
|
----
|
|
|
|
.. _class_Shader_method_has_param:
|
|
|
|
- :ref:`bool<class_bool>` **has_param** **(** :ref:`String<class_String>` name **)** |const|
|
|
|
|
Returns ``true`` if the shader has this param defined as a uniform in its code.
|
|
|
|
**Note:** ``param`` must match the name of the uniform in the code exactly.
|
|
|
|
----
|
|
|
|
.. _class_Shader_method_set_default_texture_param:
|
|
|
|
- void **set_default_texture_param** **(** :ref:`String<class_String>` param, :ref:`Texture<class_Texture>` texture **)**
|
|
|
|
Sets the default texture to be used with a texture uniform. The default is used if a texture is not set in the :ref:`ShaderMaterial<class_ShaderMaterial>`.
|
|
|
|
**Note:** ``param`` must match the name of the uniform in the code exactly.
|
|
|
|
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
|
|
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
|
|
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
|