Files
godot-docs/classes/class_compositoreffect.rst
2024-05-31 13:54:35 +00:00

302 lines
13 KiB
ReStructuredText

: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.
.. 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 build in post 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")
.. 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.)`