Skip to content

Commit

Permalink
add : OutputPass with PostProcessRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
MasatoMakino committed Jan 29, 2024
1 parent 46a9185 commit 2417c3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 2 additions & 3 deletions demoSrc/demoBloom.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from "../esm/index.js";
import GUI from "lil-gui";
import { RenderPass } from "three/examples/jsm/postprocessing/RenderPass.js";
import { OutputPass } from "three/examples/jsm/postprocessing/OutputPass.js";
import { RAFTicker } from "@masatomakino/raf-ticker";

export class StudyBloom {
Expand All @@ -25,7 +24,7 @@ export class StudyBloom {
const H = 480;

const scene = Common.initScene();
Common.initLight(scene, 1.6);
Common.initLight(scene);
const camera = Common.initCamera(scene, W, H);
const renderer = Common.initRenderer(W, H);
const control = Common.initControl(camera, renderer);
Expand All @@ -45,7 +44,7 @@ export class StudyBloom {
const mixPass = new MixShaderPass(this.bloom.result);

this.postRenderer.composers.push(this.bloom);
this.postRenderer.addComposer([mixPass, new OutputPass()], renderPass);
this.postRenderer.addComposer([mixPass], renderPass);
RAFTicker.on("tick", this.postRenderer.render);

this.initGUI();
Expand Down
9 changes: 9 additions & 0 deletions src/postprocess/PostProcessRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Camera,
} from "three";
import { RenderPass } from "three/examples/jsm/postprocessing/RenderPass.js";
import { OutputPass } from "three/examples/jsm/postprocessing/OutputPass.js";
import { Pass } from "three/examples/jsm/postprocessing/Pass.js";
import { PostProcessEffectComposer } from "./PostProcessEffectComposer.js";
import { RAFTickerEventContext } from "@masatomakino/raf-ticker";
Expand Down Expand Up @@ -66,10 +67,18 @@ export class PostProcessRenderer {
): PostProcessEffectComposer {
RenderPassOption.init(renderPassOption);
const composer = new PostProcessEffectComposer(renderer);

//先頭にレンダーパスを挿入
composer.addPass(renderPassOption.renderPass);

//中間にエフェクトパスを挿入
passes.forEach((p) => {
composer.addPass(p);
});

//末端にOutputPassを挿入
composer.addPass(new OutputPass());

return composer;
}

Expand Down

0 comments on commit 2417c3d

Please sign in to comment.