123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- :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/doc/classes/CompositorEffect.xml.
- .. _class_CompositorEffect:
- CompositorEffect
- ================
- **Experimental:** The implementation may change as more of the rendering internals are exposed over time.
- **Inherits:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
- This resource allows for creating a custom rendering effect.
- .. rst-class:: classref-introduction-group
- Description
- -----------
- This resource defines a custom rendering effect that can be applied to :ref:`Viewport<class_Viewport>`\ s through the viewports' :ref:`Environment<class_Environment>`. You can implement a callback that is called during rendering at a given stage of the rendering pipeline and allows you to insert additional passes. Note that this callback happens on the rendering thread. CompositorEffect is an abstract base class and must be extended to implement specific rendering logic.
- .. rst-class:: classref-introduction-group
- Tutorials
- ---------
- - :doc:`The Compositor <../tutorials/rendering/compositor>`
- .. rst-class:: classref-reftable-group
- Properties
- ----------
- .. table::
- :widths: auto
- +---------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`access_resolved_color<class_CompositorEffect_property_access_resolved_color>` |
- +---------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`access_resolved_depth<class_CompositorEffect_property_access_resolved_depth>` |
- +---------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
- | :ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` | :ref:`effect_callback_type<class_CompositorEffect_property_effect_callback_type>` |
- +---------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`enabled<class_CompositorEffect_property_enabled>` |
- +---------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`needs_motion_vectors<class_CompositorEffect_property_needs_motion_vectors>` |
- +---------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`needs_normal_roughness<class_CompositorEffect_property_needs_normal_roughness>` |
- +---------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`needs_separate_specular<class_CompositorEffect_property_needs_separate_specular>` |
- +---------------------------------------------------------------------+-----------------------------------------------------------------------------------------+
- .. rst-class:: classref-reftable-group
- Methods
- -------
- .. table::
- :widths: auto
- +--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`_render_callback<class_CompositorEffect_private_method__render_callback>`\ (\ effect_callback_type\: :ref:`int<class_int>`, render_data\: :ref:`RenderData<class_RenderData>`\ ) |virtual| |
- +--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Enumerations
- ------------
- .. _enum_CompositorEffect_EffectCallbackType:
- .. rst-class:: classref-enumeration
- enum **EffectCallbackType**: :ref:`🔗<enum_CompositorEffect_EffectCallbackType>`
- .. _class_CompositorEffect_constant_EFFECT_CALLBACK_TYPE_PRE_OPAQUE:
- .. rst-class:: classref-enumeration-constant
- :ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **EFFECT_CALLBACK_TYPE_PRE_OPAQUE** = ``0``
- The callback is called before our opaque rendering pass, but after depth prepass (if applicable).
- .. _class_CompositorEffect_constant_EFFECT_CALLBACK_TYPE_POST_OPAQUE:
- .. rst-class:: classref-enumeration-constant
- :ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **EFFECT_CALLBACK_TYPE_POST_OPAQUE** = ``1``
- The callback is called after our opaque rendering pass, but before our sky is rendered.
- .. _class_CompositorEffect_constant_EFFECT_CALLBACK_TYPE_POST_SKY:
- .. rst-class:: classref-enumeration-constant
- :ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **EFFECT_CALLBACK_TYPE_POST_SKY** = ``2``
- The callback is called after our sky is rendered, but before our back buffers are created (and if enabled, before subsurface scattering and/or screen space reflections).
- .. _class_CompositorEffect_constant_EFFECT_CALLBACK_TYPE_PRE_TRANSPARENT:
- .. rst-class:: classref-enumeration-constant
- :ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **EFFECT_CALLBACK_TYPE_PRE_TRANSPARENT** = ``3``
- The callback is called before our transparent rendering pass, but after our sky is rendered and we've created our back buffers.
- .. _class_CompositorEffect_constant_EFFECT_CALLBACK_TYPE_POST_TRANSPARENT:
- .. rst-class:: classref-enumeration-constant
- :ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **EFFECT_CALLBACK_TYPE_POST_TRANSPARENT** = ``4``
- The callback is called after our transparent rendering pass, but before any built-in post-processing effects and output to our render target.
- .. _class_CompositorEffect_constant_EFFECT_CALLBACK_TYPE_MAX:
- .. rst-class:: classref-enumeration-constant
- :ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **EFFECT_CALLBACK_TYPE_MAX** = ``5``
- Represents the size of the :ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` enum.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Property Descriptions
- ---------------------
- .. _class_CompositorEffect_property_access_resolved_color:
- .. rst-class:: classref-property
- :ref:`bool<class_bool>` **access_resolved_color** :ref:`🔗<class_CompositorEffect_property_access_resolved_color>`
- .. rst-class:: classref-property-setget
- - |void| **set_access_resolved_color**\ (\ value\: :ref:`bool<class_bool>`\ )
- - :ref:`bool<class_bool>` **get_access_resolved_color**\ (\ )
- If ``true`` and MSAA is enabled, this will trigger a color buffer resolve before the effect is run.
- \ **Note:** In :ref:`_render_callback<class_CompositorEffect_private_method__render_callback>`, to access the resolved buffer use:
- ::
- var render_scene_buffers : RenderSceneBuffersRD = render_data.get_render_scene_buffers()
- var color_buffer = render_scene_buffers.get_texture("render_buffers", "color")
- .. rst-class:: classref-item-separator
- ----
- .. _class_CompositorEffect_property_access_resolved_depth:
- .. rst-class:: classref-property
- :ref:`bool<class_bool>` **access_resolved_depth** :ref:`🔗<class_CompositorEffect_property_access_resolved_depth>`
- .. rst-class:: classref-property-setget
- - |void| **set_access_resolved_depth**\ (\ value\: :ref:`bool<class_bool>`\ )
- - :ref:`bool<class_bool>` **get_access_resolved_depth**\ (\ )
- If ``true`` and MSAA is enabled, this will trigger a depth buffer resolve before the effect is run.
- \ **Note:** In :ref:`_render_callback<class_CompositorEffect_private_method__render_callback>`, to access the resolved buffer use:
- ::
- var render_scene_buffers : RenderSceneBuffersRD = render_data.get_render_scene_buffers()
- var depth_buffer = render_scene_buffers.get_texture("render_buffers", "depth")
- .. rst-class:: classref-item-separator
- ----
- .. _class_CompositorEffect_property_effect_callback_type:
- .. rst-class:: classref-property
- :ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **effect_callback_type** :ref:`🔗<class_CompositorEffect_property_effect_callback_type>`
- .. rst-class:: classref-property-setget
- - |void| **set_effect_callback_type**\ (\ value\: :ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>`\ )
- - :ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **get_effect_callback_type**\ (\ )
- The type of effect that is implemented, determines at what stage of rendering the callback is called.
- .. rst-class:: classref-item-separator
- ----
- .. _class_CompositorEffect_property_enabled:
- .. rst-class:: classref-property
- :ref:`bool<class_bool>` **enabled** :ref:`🔗<class_CompositorEffect_property_enabled>`
- .. rst-class:: classref-property-setget
- - |void| **set_enabled**\ (\ value\: :ref:`bool<class_bool>`\ )
- - :ref:`bool<class_bool>` **get_enabled**\ (\ )
- If ``true`` this rendering effect is applied to any viewport it is added to.
- .. rst-class:: classref-item-separator
- ----
- .. _class_CompositorEffect_property_needs_motion_vectors:
- .. rst-class:: classref-property
- :ref:`bool<class_bool>` **needs_motion_vectors** :ref:`🔗<class_CompositorEffect_property_needs_motion_vectors>`
- .. rst-class:: classref-property-setget
- - |void| **set_needs_motion_vectors**\ (\ value\: :ref:`bool<class_bool>`\ )
- - :ref:`bool<class_bool>` **get_needs_motion_vectors**\ (\ )
- If ``true`` this triggers motion vectors being calculated during the opaque render state.
- \ **Note:** In :ref:`_render_callback<class_CompositorEffect_private_method__render_callback>`, to access the motion vector buffer use:
- ::
- var render_scene_buffers : RenderSceneBuffersRD = render_data.get_render_scene_buffers()
- var motion_buffer = render_scene_buffers.get_velocity_texture()
- .. rst-class:: classref-item-separator
- ----
- .. _class_CompositorEffect_property_needs_normal_roughness:
- .. rst-class:: classref-property
- :ref:`bool<class_bool>` **needs_normal_roughness** :ref:`🔗<class_CompositorEffect_property_needs_normal_roughness>`
- .. rst-class:: classref-property-setget
- - |void| **set_needs_normal_roughness**\ (\ value\: :ref:`bool<class_bool>`\ )
- - :ref:`bool<class_bool>` **get_needs_normal_roughness**\ (\ )
- If ``true`` this triggers normal and roughness data to be output during our depth pre-pass, only applicable for the Forward+ renderer.
- \ **Note:** In :ref:`_render_callback<class_CompositorEffect_private_method__render_callback>`, to access the roughness buffer use:
- ::
- var render_scene_buffers : RenderSceneBuffersRD = render_data.get_render_scene_buffers()
- var roughness_buffer = render_scene_buffers.get_texture("forward_clustered", "normal_roughness")
- The raw normal and roughness buffer is stored in an optimized format, different than the one available in Spatial shaders. When sampling the buffer, a conversion function must be applied. Use this function, copied from `here <https://github.com/godotengine/godot/blob/da5f39889f155658cef7f7ec3cc1abb94e17d815/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered_inc.glsl#L334-L341>`__:
- ::
- vec4 normal_roughness_compatibility(vec4 p_normal_roughness) {
- float roughness = p_normal_roughness.w;
- if (roughness > 0.5) {
- roughness = 1.0 - roughness;
- }
- roughness /= (127.0 / 255.0);
- return vec4(normalize(p_normal_roughness.xyz * 2.0 - 1.0) * 0.5 + 0.5, roughness);
- }
- .. rst-class:: classref-item-separator
- ----
- .. _class_CompositorEffect_property_needs_separate_specular:
- .. rst-class:: classref-property
- :ref:`bool<class_bool>` **needs_separate_specular** :ref:`🔗<class_CompositorEffect_property_needs_separate_specular>`
- .. rst-class:: classref-property-setget
- - |void| **set_needs_separate_specular**\ (\ value\: :ref:`bool<class_bool>`\ )
- - :ref:`bool<class_bool>` **get_needs_separate_specular**\ (\ )
- If ``true`` this triggers specular data being rendered to a separate buffer and combined after effects have been applied, only applicable for the Forward+ renderer.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Method Descriptions
- -------------------
- .. _class_CompositorEffect_private_method__render_callback:
- .. rst-class:: classref-method
- |void| **_render_callback**\ (\ effect_callback_type\: :ref:`int<class_int>`, render_data\: :ref:`RenderData<class_RenderData>`\ ) |virtual| :ref:`🔗<class_CompositorEffect_private_method__render_callback>`
- Implement this function with your custom rendering code. ``effect_callback_type`` should always match the effect callback type you've specified in :ref:`effect_callback_type<class_CompositorEffect_property_effect_callback_type>`. ``render_data`` provides access to the rendering state, it is only valid during rendering and should not be stored.
- .. |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.)`
- .. |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.)`
|