CompositorEffect
Base callback resource for a compositor stage.
Create a C# subclass, override _RenderCallback and add the resource to Compositor.CompositorEffects. Defaults are enabled, PostTransparent and all additional-data flags false. Without a custom callback the base resource produces no visual result.
Forward+ dispatches five stages; current Mobile only PreOpaque, PreTransparent and PostTransparent. Requesting PostOpaque on Mobile warns; PostSky is not dispatched there. PostTransparent runs before subsequent postprocessing and tonemapping. Do not use Max as a stage.
Complete executed diagnostic class. It counts callbacks and frames with valid RIDs for every view, but does not run a compute shader or change the image:
using System.Threading;
using Reckfell;
[GlobalClass]
public partial class BufferProbeEffect : CompositorEffect
{
private int callbacks;
private int validFrames;
public int CallbackCount => Volatile.Read(ref callbacks);
public int ValidFrameCount => Volatile.Read(ref validFrames);
public BufferProbeEffect()
{
EffectCallbackType = EffectCallbackTypeEnum.PostTransparent;
}
public override void _RenderCallback(int effectCallbackType, RenderData renderData)
{
if (effectCallbackType != (int)EffectCallbackTypeEnum.PostTransparent)
return;
Interlocked.Increment(ref callbacks);
if (renderData.GetRenderSceneBuffers() is not RenderSceneBuffersRD buffers)
return;
Vector2I size = buffers.GetInternalSize();
if (size.X <= 0 || size.Y <= 0 || buffers.GetViewCount() == 0)
return;
for (uint view = 0; view < buffers.GetViewCount(); view++)
{
if (!buffers.GetColorLayer(view).IsValid || !buffers.GetDepthLayer(view).IsValid)
return;
}
Interlocked.Increment(ref validFrames);
}
}RenderData and buffers are borrowed from the renderer. Do not retain them after the callback, free borrowed RIDs or change the Entity tree from the render thread. Use GetInternalSize() and process all GetViewCount() layers. GPU work requires the main RenderingDevice; a local device does not own frame RIDs.
Dispatch, valid RIDs and Enabled were checked on Windows/Vulkan Forward+ and Mobile. The unsupported PostOpaque warning remains in the raw report. Additional buffers and MSAA were source-reviewed; their contents, shaders, XR, resizing and performance were not tested in this run.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
CompositorEffectConstructor
public CompositorEffect();Creates an enabled base effect at PostTransparent with all additional flags false. The base callback does not change the image; override _RenderCallback in a subclass.
Properties7
AccessResolvedColorProperty
public bool AccessResolvedColor { get; set; }Requests ordinary resolved color before an intermediate stage with MSAA; initially false. It neither disables MSAA nor converts the format to LDR. Hidden in Inspector for PostTransparent. Request only when needed; a valid RID does not mean an early stage contains completed scene color.
AccessResolvedDepthProperty
public bool AccessResolvedDepth { get; set; }Requests resolved MSAA depth; initially false. Support depends on renderer and device; true does not guarantee resolved depth in every configuration. Hidden in Inspector for PostTransparent. This is neither linearized depth nor a reverse-Z switch.
EffectCallbackTypeProperty
public CompositorEffect.EffectCallbackTypeEnum EffectCallbackType { get; set; }Callback stage, initially PostTransparent. Forward+ dispatches PreOpaque, PostOpaque, PostSky, PreTransparent and PostTransparent. Current Mobile dispatches only PreOpaque, PreTransparent and PostTransparent: PostOpaque warns and PostSky is not called. PostTransparent precedes subsequent postprocessing and tonemapping. Max is a sentinel, not a valid stage.
EnabledProperty
public bool Enabled { get; set; }Whether the effect is enabled; defaults to true. False excludes it from dispatch without deleting the resource or GPU objects it created. No CompositorEffects array reassignment is needed; queued frames can finish with the previous state.
NeedsMotionVectorsProperty
public bool NeedsMotionVectors { get; set; }Requests motion-vector preparation in Forward+; initially false. Describes the effect’s requirement, not guaranteed buffer availability in every renderer. Enabling it can change rendering preparation; do not request unused data.
NeedsNormalRoughnessProperty
public bool NeedsNormalRoughness { get; set; }Requests normal/roughness in Forward+ and affects prepass preparation; initially false. Does not automatically make those data available in Mobile. Check the appropriate buffer and stage before use.
NeedsSeparateSpecularProperty
public bool NeedsSeparateSpecular { get; set; }Requests separate specular in Forward+ at PostSky; initially false. Inspector hides this property for other stages. Current Mobile does not dispatch PostSky. This requests data rather than automatically producing a visual effect.
Methods15
GetAccessResolvedColorbool
public bool GetAccessResolvedColor();Returns the value of CompositorEffect.AccessResolvedColor.
boolThe current CompositorEffect.AccessResolvedColor value; reading a request flag does not establish corresponding buffer availability.
GetAccessResolvedDepthbool
public bool GetAccessResolvedDepth();Returns the value of CompositorEffect.AccessResolvedDepth.
boolThe current CompositorEffect.AccessResolvedDepth value; reading a request flag does not establish corresponding buffer availability.
GetEffectCallbackTypeCompositorEffect.EffectCallbackTypeEnum
public CompositorEffect.EffectCallbackTypeEnum GetEffectCallbackType();Returns the value of CompositorEffect.EffectCallbackType.
CompositorEffect.EffectCallbackTypeEnumThe selected stage. Execution depends on the renderer and compositor attachment.
GetEnabledbool
public bool GetEnabled();Returns the value of CompositorEffect.Enabled.
boolTrue when the effect is enabled; this does not establish actual callback dispatch for the active camera.
GetNeedsMotionVectorsbool
public bool GetNeedsMotionVectors();Returns the value of CompositorEffect.NeedsMotionVectors.
boolThe current CompositorEffect.NeedsMotionVectors value; reading a request flag does not establish corresponding buffer availability.
GetNeedsNormalRoughnessbool
public bool GetNeedsNormalRoughness();Returns the value of CompositorEffect.NeedsNormalRoughness.
boolThe current CompositorEffect.NeedsNormalRoughness value; reading a request flag does not establish corresponding buffer availability.
GetNeedsSeparateSpecularbool
public bool GetNeedsSeparateSpecular();Returns the value of CompositorEffect.NeedsSeparateSpecular.
boolThe current CompositorEffect.NeedsSeparateSpecular value; reading a request flag does not establish corresponding buffer availability.
SetAccessResolvedColorvoid
public void SetAccessResolvedColor(bool enable);Assigns the value of CompositorEffect.AccessResolvedColor.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enableNew request value for CompositorEffect.AccessResolvedColor.
SetAccessResolvedDepthvoid
public void SetAccessResolvedDepth(bool enable);Assigns the value of CompositorEffect.AccessResolvedDepth.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enableNew request value for CompositorEffect.AccessResolvedDepth.
SetEffectCallbackTypevoid
public void SetEffectCallbackType(CompositorEffect.EffectCallbackTypeEnum effectCallbackType);Assigns the value of CompositorEffect.EffectCallbackType.
| Name | Type | Default |
|---|---|---|
effectCallbackType | CompositorEffect.EffectCallbackTypeEnum | — |
effectCallbackTypeA stage supported by the selected renderer; not Max. Current Mobile does not execute PostOpaque or PostSky.
SetEnabledvoid
public void SetEnabled(bool enabled);Assigns the value of CompositorEffect.Enabled.
| Name | Type | Default |
|---|---|---|
enabled | bool | — |
enabledTrue to enable, false to exclude from callbacks; property CompositorEffect.Enabled.
SetNeedsMotionVectorsvoid
public void SetNeedsMotionVectors(bool enable);Assigns the value of CompositorEffect.NeedsMotionVectors.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enableNew request value for CompositorEffect.NeedsMotionVectors.
SetNeedsNormalRoughnessvoid
public void SetNeedsNormalRoughness(bool enable);Assigns the value of CompositorEffect.NeedsNormalRoughness.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enableNew request value for CompositorEffect.NeedsNormalRoughness.
SetNeedsSeparateSpecularvoid
public void SetNeedsSeparateSpecular(bool enable);Assigns the value of CompositorEffect.NeedsSeparateSpecular.
| Name | Type | Default |
|---|---|---|
enable | bool | — |
enableNew request value for CompositorEffect.NeedsSeparateSpecular.
_RenderCallbackvoid
public virtual void _RenderCallback(int effectCallbackType, RenderData renderData);Renderer hook for the selected stage. Override in a subclass; do not call it manually as a substitute for rendering. Use RenderData and its buffers only during the callback; neither retain them for another frame nor release borrowed RIDs. Do not modify the Entity tree or UI on the render thread. Process every XR view and obtain dimensions from RenderSceneBuffersRD.GetInternalSize().
| Name | Type | Default |
|---|---|---|
effectCallbackType | int | — |
renderData | RenderData | — |
effectCallbackTypeThe dispatched stage number; compare with EffectCallbackTypeEnum. It is neither effect count nor frame index.
renderDataBorrowed data for the current pass, valid only inside the callback. Obtain RenderSceneBuffers and check its concrete type.
CompositorEffect.EffectCallbackTypeEnum
| Value | Description |
|---|---|
Max = 5 | Represents the size of the |
PostOpaque = 1 | The callback is called after our opaque rendering pass, but before our sky is rendered. |
PostSky = 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). |
PostTransparent = 4 | The callback is called after our transparent rendering pass, but before any built-in post-processing effects and output to our render target. |
PreOpaque = 0 | The callback is called before our opaque rendering pass, but after depth prepass (if applicable). |
PreTransparent = 3 | The callback is called before our transparent rendering pass, but after our sky is rendered and we've created our back buffers. |