Files
godot-docs-l10n/classes/zh_CN/class_compositoreffect.rst

302 lines
13 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

: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
================
**实验性:** The implementation may change as more of the rendering internals are exposed over time.
**继承:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
用于创建自定义渲染效果的资源。
.. rst-class:: classref-introduction-group
描述
----
这种资源定义的是自定义渲染效果,可以通过视口的 :ref:`Environment<class_Environment>` 应用到 :ref:`Viewport<class_Viewport>` 上。可以实现在渲染管道的给定阶段进行渲染期间调用的回调,并允许插入其他阶段。请注意,该回调是在渲染线程上执行的。
.. rst-class:: classref-reftable-group
属性
----
.. 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
方法
----
.. 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
枚举
----
.. _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``
该回调在我们的不透明渲染阶段之前、在深度前置阶段之后(如果适用)调用。
.. _class_CompositorEffect_constant_EFFECT_CALLBACK_TYPE_POST_OPAQUE:
.. rst-class:: classref-enumeration-constant
:ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **EFFECT_CALLBACK_TYPE_POST_OPAQUE** = ``1``
该回调在我们的不透明渲染阶段之后、天空渲染之前调用。
.. _class_CompositorEffect_constant_EFFECT_CALLBACK_TYPE_POST_SKY:
.. rst-class:: classref-enumeration-constant
:ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **EFFECT_CALLBACK_TYPE_POST_SKY** = ``2``
在渲染天空之后、创建后台缓冲区之前(如果启用,则在次表面散射和/或屏幕空间反射之前)调用回调。
.. _class_CompositorEffect_constant_EFFECT_CALLBACK_TYPE_PRE_TRANSPARENT:
.. rst-class:: classref-enumeration-constant
:ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **EFFECT_CALLBACK_TYPE_PRE_TRANSPARENT** = ``3``
在我们的透明渲染阶段之前、渲染天空并且创建了后台缓冲区之后,调用回调。
.. _class_CompositorEffect_constant_EFFECT_CALLBACK_TYPE_POST_TRANSPARENT:
.. rst-class:: classref-enumeration-constant
:ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **EFFECT_CALLBACK_TYPE_POST_TRANSPARENT** = ``4``
该回调在我们的透明渲染阶段之后、任何构建后期效果和输出到渲染目标之前调用。
.. _class_CompositorEffect_constant_EFFECT_CALLBACK_TYPE_MAX:
.. rst-class:: classref-enumeration-constant
:ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` **EFFECT_CALLBACK_TYPE_MAX** = ``5``
代表 :ref:`EffectCallbackType<enum_CompositorEffect_EffectCallbackType>` 枚举的大小。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
属性说明
--------
.. _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**\ (\ )
如果为 ``true`` 并且启用了 MSAA则会在执行该效果之前触发颜色缓冲的解析。
\ **注意:**\ 要在 :ref:`_render_callback<class_CompositorEffect_private_method__render_callback>` 中访问解析后的缓冲,请使用:
::
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**\ (\ )
如果为 ``true`` 并且启用了 MSAA则会在执行该效果之前触发深度缓冲的解析。
\ **注意:**\ 要在 :ref:`_render_callback<class_CompositorEffect_private_method__render_callback>` 中访问解析后的缓冲,请使用:
::
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**\ (\ )
实现的效果类型,决定在渲染的哪个阶段调用回调。
.. 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**\ (\ )
如果为 ``true``\ ,则该渲染效果会应用到所有相关视口。
.. 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**\ (\ )
如果为 ``true``\ ,则会在不透明渲染状态下触发运动向量的计算。
**\ **注意:**\ 要在 :ref:`_render_callback<class_CompositorEffect_private_method__render_callback>` 中访问运动向量缓冲,请使用:
::
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**\ (\ )
如果为 ``true``\ ,则会在深度预阶段触发法线和粗糙度数据的输出,仅适用于 Forward+ 渲染器。
**\ **注意:**\ 要在 :ref:`_render_callback<class_CompositorEffect_private_method__render_callback>` 中访问粗糙度缓冲,请使用:
::
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**\ (\ )
如果为 ``true``\ ,则会触发镜面反射数据渲染至独立缓冲,在应用效果后进行混合,仅适用于 Forward+ 渲染器。
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
方法说明
--------
.. _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>`
请使用自定义的渲染代码实现该方法。\ ``effect_callback_type`` 应当与 :ref:`effect_callback_type<class_CompositorEffect_property_effect_callback_type>` 中指定的效果回调类型一致。可以通过 ``render_data`` 访问渲染状态,这个状态只有在渲染时有效,不应该存储。
.. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)`
.. |const| replace:: :abbr:`const (本方法无副作用,不会修改该实例的任何成员变量。)`
.. |vararg| replace:: :abbr:`vararg (本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。)`
.. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)`
.. |static| replace:: :abbr:`static (调用本方法无需实例,可直接使用类名进行调用。)`
.. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效运算符。)`
.. |bitfield| replace:: :abbr:`BitField (这个值是由下列位标志构成位掩码的整数。)`
.. |void| replace:: :abbr:`void (无返回值。)`