:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/stag-toolkit/sphinx/gen/gdscript/PreprocessorShaderMaterial.xml. .. _class_PreprocessorShaderMaterial: PreprocessorShaderMaterial ========================== **Inherits:** ``ShaderMaterial`` A ``ShaderMaterial`` that generates its ``Shader`` using a list of defines and includes. Useful for shaders that you want to be highly-configurable, but optimized, by using preprocessors. .. rst-class:: classref-introduction-group Description ----------- The **PreprocessorShaderMaterial** is primarily intended for automatic handling of preprocessor defines within a ``ShaderMaterial``. The bulk of your shader code is expected to be written in ``ShaderInclude``\ s. A new ``Shader`` resource is created when any preprocessors (flags, constants, includes) are modified in the inspector, in order to force Godot to recompile the shader. You can also manually rebuild the shader with the :ref:`build_shader()` method.. Generated shaders are laid out in this order: **Shader Type**, **Defined Constants** (sorted alphabetically), **Defined Flags** (sorted alphabetically), **Prelude**, **Includes** (using the provided order). .. rst-class:: classref-reftable-group Properties ---------- .. table:: :widths: auto +----------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------------------------+ | ``bool`` | :ref:`_initialized` | ``false`` | +----------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------------------------+ | ``Variant`` | :ref:`_build_shader` | ``build_shader`` | +----------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------------------------+ | Shader.Mode | :ref:`shader_type` | ``0`` | +----------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------------------------+ | ``String`` | :ref:`prelude` | ``""`` | +----------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------------------------+ | :ref:`Array`\[``ShaderInclude``\] | :ref:`includes` | ``[]`` | +----------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------------------------+ | ``PackedStringArray`` | :ref:`flags_available` | ``PackedStringArray()`` | +----------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------------------------+ | :ref:`Dictionary`\[``String``, ``Variant``\] | :ref:`constants` | ``{}`` | +----------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------------------------+ | ``PackedStringArray`` | :ref:`flags_enabled` | ``PackedStringArray()`` | +----------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------------------------+ | ``Variant`` | :ref:`_fetch_defines` | ``_update_flags_available`` | +----------------------------------------------------------------+-----------------------------------------------------------------------------------+-----------------------------+ .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_update_flags_available`\ (\ ) | +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | ``bool`` | :ref:`set_flag`\ (\ flag\: ``String``, enabled\: ``bool``\ ) | +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_constant`\ (\ constant\: ``String``, value\: ``Variant``\ ) | +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | ``bool`` | :ref:`remove_constant`\ (\ constant\: ``String``\ ) | +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | :ref:`Array`\[``Dictionary``\] | :ref:`_get_property_list`\ (\ ) | +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_get`\ (\ property\: ``StringName``\ ) | +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | ``Variant`` | :ref:`_set`\ (\ property\: ``StringName``, value\: ``Variant``\ ) | +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | ``String`` | :ref:`shader_type_string`\ (\ st\: Shader.Mode\ ) |static| | +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_init`\ (\ ) | +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`_postinit`\ (\ ) | +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`build_shader`\ (\ ) | +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ | ``PackedStringArray`` | :ref:`fetch_available_defines`\ (\ ) | +---------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Signals ------- .. _class_PreprocessorShaderMaterial_signal_rebuilt: .. rst-class:: classref-signal **rebuilt**\ (\ ) :ref:`🔗` Emitted when the shader is initially built or rebuilt. .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Constants --------- .. _class_PreprocessorShaderMaterial_constant__FLAG_PREFIX: .. rst-class:: classref-constant **_FLAG_PREFIX** = ``"flag_"`` :ref:`🔗` .. container:: contribute There is currently no description for this constant. Please help us by `contributing one `__! .. _class_PreprocessorShaderMaterial_constant__STRUCTURE: .. rst-class:: classref-constant **_STRUCTURE** = ``"shader_type {shader_type};\n// Constants\n{constants}\n// Flags\n{defines}\n// Prelude\n{prelude}\n//Includes\n{includes}\n"`` :ref:`🔗` .. container:: contribute There is currently no description for this constant. Please help us by `contributing one `__! .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Property Descriptions --------------------- .. _class_PreprocessorShaderMaterial_property__initialized: .. rst-class:: classref-property ``bool`` **_initialized** = ``false`` :ref:`🔗` .. container:: contribute There is currently no description for this property. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_property__build_shader: .. rst-class:: classref-property ``Variant`` **_build_shader** = ``build_shader`` :ref:`🔗` .. container:: contribute There is currently no description for this property. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_property_shader_type: .. rst-class:: classref-property Shader.Mode **shader_type** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **@shader_type_setter**\ (\ value\: Shader.Mode\ ) The shader type to generate. .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_property_prelude: .. rst-class:: classref-property ``String`` **prelude** = ``""`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **@prelude_setter**\ (\ value\: ``String``\ ) Any code you want to include in the shader before the list of includes. Placed after the defines. .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_property_includes: .. rst-class:: classref-property :ref:`Array`\[``ShaderInclude``\] **includes** = ``[]`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **@includes_setter**\ (\ value\: :ref:`Array`\[``ShaderInclude``\]\ ) An ordered list of shader includes to include in the shader, after defines. .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_property_flags_available: .. rst-class:: classref-property ``PackedStringArray`` **flags_available** = ``PackedStringArray()`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **@flags_available_setter**\ (\ value\: ``PackedStringArray``\ ) A list of shader defines that can be toggled under the Flags group. **Note:** The returned array is *copied* and any changes to it will not update the original property value. See ``PackedStringArray`` for more details. .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_property_constants: .. rst-class:: classref-property :ref:`Dictionary`\[``String``, ``Variant``\] **constants** = ``{}`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **@constants_setter**\ (\ value\: :ref:`Dictionary`\[``String``, ``Variant``\]\ ) Constant values to be used as defines in the shader. Currently only ``int``, ``float``, ``bool``, and ``String`` types are supported. .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_property_flags_enabled: .. rst-class:: classref-property ``PackedStringArray`` **flags_enabled** = ``PackedStringArray()`` :ref:`🔗` A list of all defines that should be enabled in the shader. If changed from code, remember to call :ref:`build_shader()` to rebuild the shader. **Note:** The returned array is *copied* and any changes to it will not update the original property value. See ``PackedStringArray`` for more details. .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_property__fetch_defines: .. rst-class:: classref-property ``Variant`` **_fetch_defines** = ``_update_flags_available`` :ref:`🔗` .. container:: contribute There is currently no description for this property. Please help us by `contributing one `__! .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_PreprocessorShaderMaterial_private_method__update_flags_available: .. rst-class:: classref-method |void| **_update_flags_available**\ (\ ) :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_method_set_flag: .. rst-class:: classref-method ``bool`` **set_flag**\ (\ flag\: ``String``, enabled\: ``bool``\ ) :ref:`🔗` Sets the given flag as enabled or disabled. Returns ``true`` if the preprocessor list changed. Call :ref:`build_shader()` afterward to force a recompile. .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_method_set_constant: .. rst-class:: classref-method |void| **set_constant**\ (\ constant\: ``String``, value\: ``Variant``\ ) :ref:`🔗` Sets the named constant to the given value. Call :ref:`build_shader()` afterward to force a recompile. .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_method_remove_constant: .. rst-class:: classref-method ``bool`` **remove_constant**\ (\ constant\: ``String``\ ) :ref:`🔗` Removes the named constant. Returns ``true`` if the given constant existed in the dictionary. Call :ref:`build_shader()` afterward to force a recompile. .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_private_method__get_property_list: .. rst-class:: classref-method :ref:`Array`\[``Dictionary``\] **_get_property_list**\ (\ ) :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_private_method__get: .. rst-class:: classref-method |void| **_get**\ (\ property\: ``StringName``\ ) :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_private_method__set: .. rst-class:: classref-method ``Variant`` **_set**\ (\ property\: ``StringName``, value\: ``Variant``\ ) :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_method_shader_type_string: .. rst-class:: classref-method ``String`` **shader_type_string**\ (\ st\: Shader.Mode\ ) |static| :ref:`🔗` Returns a string for the given shader type. .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_private_method__init: .. rst-class:: classref-method |void| **_init**\ (\ ) :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_private_method__postinit: .. rst-class:: classref-method |void| **_postinit**\ (\ ) :ref:`🔗` .. container:: contribute There is currently no description for this method. Please help us by `contributing one `__! .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_method_build_shader: .. rst-class:: classref-method |void| **build_shader**\ (\ ) :ref:`🔗` Rebuilds the shader from scratch. In order for Godot to recompile the shader code, a new ``Shader`` is created. Frequently rebuilding the shader can have a negative impact on performance, so only call this when necessary. .. rst-class:: classref-item-separator ---- .. _class_PreprocessorShaderMaterial_method_fetch_available_defines: .. rst-class:: classref-method ``PackedStringArray`` **fetch_available_defines**\ (\ ) :ref:`🔗` Searches through all provided shader includes, and returns a list of toggleable shader defines. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |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.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`