Skip to content

Commit a665bb2

Browse files
committed
fix: don't override the render target of an effect pass if it already exists
1 parent 74e203d commit a665bb2

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lib/src/hooks/useCompositeEffectPass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function useCompositeEffectPass<P extends Record<string, EffectPass<any>>
2828
for (const [index, pass] of effectPasses.entries()) {
2929
pass.initialize(gl);
3030

31-
if (index < effectPasses.length - 1) {
31+
if (index < effectPasses.length - 1 && pass.target == undefined) {
3232
pass.setTarget(createRenderTarget(gl));
3333
}
3434

lib/src/hooks/useCompositor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import type { CompositeEffectPass, EffectPass, RenderPass } from "../types";
66
* The compositor handles the combination of the render pass and the effects:
77
* - initialize the gl context and create render targets for all effects
88
* - provide each effect with its previousPass and inputPass to use in uniforms
9-
* - fill the texture uniforms with the previous pass if they are not provided in uniforms
109
* - detect the first texture uniform of each effect and, if it has no value provided, fill it with the previous pass
1110
* - render all passes in the correct order
1211
*/
@@ -23,7 +22,10 @@ export function useCompositor(
2322

2423
for (const [index, effect] of effects.entries()) {
2524
effect.initialize(gl);
26-
effect.setTarget(index === effects.length - 1 ? null : createRenderTarget(gl));
25+
26+
if (index < effects.length - 1 && effect.target == undefined) {
27+
effect.setTarget(createRenderTarget(gl));
28+
}
2729

2830
if (isCompositeEffectPass(effect)) {
2931
const inputPass = previousPass;

0 commit comments

Comments
 (0)