Skip to content

EffectComposer: Add option for custom render pass #336

@shotamatsuda

Description

@shotamatsuda

I've been trying MRT with EffectComposer in order to avoid additional render passes to output normals, masks, and so on. Extensibility is always a problem with pure components, but in this case, having a RenderPass prop in EffectComposer to accept a class implementing the same interface as RenderPass would allow us to use a custom render pass. Otherwise, and this is my current workaround, we must maintain a modified copy of EffectComposer, which is suboptimal in terms of maintainability.

Like:

export const EffectComposer = memo(
  forwardRef<EffectComposerImpl, EffectComposerProps>(
    (
      {
        ...,
        RenderPass = RenderPass
      },
      ref
    ) => {
      ...
      const [composer, normalPass, downSamplingPass] = useMemo(() => {
        ...
        // Add render pass
        effectComposer.addPass(new RenderPass(scene, camera))
        ...
      }, [
        ...,
        RenderPass
      ])
      ...
    }
  )
)

I'd like to hear your opinion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions