mirror of
https://github.com/godotengine/godot.git
synced 2024-11-25 13:43:15 +00:00
97 lines
6.5 KiB
XML
97 lines
6.5 KiB
XML
<?xml version="1.0" encoding="UTF-8" ?>
|
|
<class name="CompositorEffect" inherits="Resource" experimental="The implementation may change as more of the rendering internals are exposed over time." xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
|
|
<brief_description>
|
|
This resource allows for creating a custom rendering effect.
|
|
</brief_description>
|
|
<description>
|
|
This resource defines a custom rendering effect that can be applied to [Viewport]s through the viewports' [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.
|
|
</description>
|
|
<tutorials>
|
|
<link title="The Compositor">$DOCS_URL/tutorials/rendering/compositor.html</link>
|
|
</tutorials>
|
|
<methods>
|
|
<method name="_render_callback" qualifiers="virtual">
|
|
<return type="void" />
|
|
<param index="0" name="effect_callback_type" type="int" />
|
|
<param index="1" name="render_data" type="RenderData" />
|
|
<description>
|
|
Implement this function with your custom rendering code. [param effect_callback_type] should always match the effect callback type you've specified in [member effect_callback_type]. [param render_data] provides access to the rendering state, it is only valid during rendering and should not be stored.
|
|
</description>
|
|
</method>
|
|
</methods>
|
|
<members>
|
|
<member name="access_resolved_color" type="bool" setter="set_access_resolved_color" getter="get_access_resolved_color">
|
|
If [code]true[/code] and MSAA is enabled, this will trigger a color buffer resolve before the effect is run.
|
|
[b]Note:[/b] In [method _render_callback], to access the resolved buffer use:
|
|
[codeblock]
|
|
var render_scene_buffers : RenderSceneBuffersRD = render_data.get_render_scene_buffers()
|
|
var color_buffer = render_scene_buffers.get_texture("render_buffers", "color")
|
|
[/codeblock]
|
|
</member>
|
|
<member name="access_resolved_depth" type="bool" setter="set_access_resolved_depth" getter="get_access_resolved_depth">
|
|
If [code]true[/code] and MSAA is enabled, this will trigger a depth buffer resolve before the effect is run.
|
|
[b]Note:[/b] In [method _render_callback], to access the resolved buffer use:
|
|
[codeblock]
|
|
var render_scene_buffers : RenderSceneBuffersRD = render_data.get_render_scene_buffers()
|
|
var depth_buffer = render_scene_buffers.get_texture("render_buffers", "depth")
|
|
[/codeblock]
|
|
</member>
|
|
<member name="effect_callback_type" type="int" setter="set_effect_callback_type" getter="get_effect_callback_type" enum="CompositorEffect.EffectCallbackType">
|
|
The type of effect that is implemented, determines at what stage of rendering the callback is called.
|
|
</member>
|
|
<member name="enabled" type="bool" setter="set_enabled" getter="get_enabled">
|
|
If [code]true[/code] this rendering effect is applied to any viewport it is added to.
|
|
</member>
|
|
<member name="needs_motion_vectors" type="bool" setter="set_needs_motion_vectors" getter="get_needs_motion_vectors">
|
|
If [code]true[/code] this triggers motion vectors being calculated during the opaque render state.
|
|
[b]Note:[/b] In [method _render_callback], to access the motion vector buffer use:
|
|
[codeblock]
|
|
var render_scene_buffers : RenderSceneBuffersRD = render_data.get_render_scene_buffers()
|
|
var motion_buffer = render_scene_buffers.get_velocity_texture()
|
|
[/codeblock]
|
|
</member>
|
|
<member name="needs_normal_roughness" type="bool" setter="set_needs_normal_roughness" getter="get_needs_normal_roughness">
|
|
If [code]true[/code] this triggers normal and roughness data to be output during our depth pre-pass, only applicable for the Forward+ renderer.
|
|
[b]Note:[/b] In [method _render_callback], to access the roughness buffer use:
|
|
[codeblock]
|
|
var render_scene_buffers : RenderSceneBuffersRD = render_data.get_render_scene_buffers()
|
|
var roughness_buffer = render_scene_buffers.get_texture("forward_clustered", "normal_roughness")
|
|
[/codeblock]
|
|
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 [url=https://github.com/godotengine/godot/blob/da5f39889f155658cef7f7ec3cc1abb94e17d815/servers/rendering/renderer_rd/shaders/forward_clustered/scene_forward_clustered_inc.glsl#L334-L341]here[/url]:
|
|
[codeblock]
|
|
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);
|
|
}
|
|
[/codeblock]
|
|
</member>
|
|
<member name="needs_separate_specular" type="bool" setter="set_needs_separate_specular" getter="get_needs_separate_specular">
|
|
If [code]true[/code] this triggers specular data being rendered to a separate buffer and combined after effects have been applied, only applicable for the Forward+ renderer.
|
|
</member>
|
|
</members>
|
|
<constants>
|
|
<constant name="EFFECT_CALLBACK_TYPE_PRE_OPAQUE" value="0" enum="EffectCallbackType">
|
|
The callback is called before our opaque rendering pass, but after depth prepass (if applicable).
|
|
</constant>
|
|
<constant name="EFFECT_CALLBACK_TYPE_POST_OPAQUE" value="1" enum="EffectCallbackType">
|
|
The callback is called after our opaque rendering pass, but before our sky is rendered.
|
|
</constant>
|
|
<constant name="EFFECT_CALLBACK_TYPE_POST_SKY" value="2" enum="EffectCallbackType">
|
|
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).
|
|
</constant>
|
|
<constant name="EFFECT_CALLBACK_TYPE_PRE_TRANSPARENT" value="3" enum="EffectCallbackType">
|
|
The callback is called before our transparent rendering pass, but after our sky is rendered and we've created our back buffers.
|
|
</constant>
|
|
<constant name="EFFECT_CALLBACK_TYPE_POST_TRANSPARENT" value="4" enum="EffectCallbackType">
|
|
The callback is called after our transparent rendering pass, but before any built-in post-processing effects and output to our render target.
|
|
</constant>
|
|
<constant name="EFFECT_CALLBACK_TYPE_MAX" value="5" enum="EffectCallbackType">
|
|
Represents the size of the [enum EffectCallbackType] enum.
|
|
</constant>
|
|
</constants>
|
|
</class>
|