question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How does masking with EffectComposer work?

See original GitHub issue

I spent awful lot of time with examples/webgl_postprocessing.html but I cannot figure out how to work with masks (EffectComposer, MaskPass, etc.). Maybe I think of them the wrong way - the photoshop way. I’m trying to achieve this:

Example of masking

I would expect usage like this


function init() {
    // ...

    // full render
    renderSceneA = new THREE.RenderPass(sceneA, cameraA);
    renderSceneB = new THREE.RenderPass(sceneB, cameraB);

    // rendering masks
    renderMaskA = new THREE.RenderPass(maskA, maskCameraA);
    renderMaskB = new THREE.RenderPass(maskB, maskCameraB);

    // MaskPass would crop the rendered scene with mask
    // finalComposer would layer up the passes on each other
    finalComposer.addPass(new THREE.MaskPass(renderSceneA, renderMaskA));
    finalComposer.addPass(new THREE.MaskPass(renderSceneB, renderMaskB));

    // ... render to screen etc.
}

function render() {
    finalComposer.render();
}

When I understand this, I would be happy to write some example / tutorial / blogpost about it.

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

5reactions
mrdoobcommented, Dec 4, 2015

The newly added webgl_postprocessing_masking.html should be a easier example to follow.

0reactions
tripdragoncommented, Dec 5, 2015

Perfect! Thank you. For others at this time its in the dev branch

Read more comments on GitHub >

github_iconTop Results From Across the Web

EffectComposer – three.js docs
The class manages a chain of post-processing passes to produce the final visual result. Post-processing passes are executed in order of their addition/insertion ......
Read more >
three.js - Hide a part of an object using masks (EffectComposer)
The idea is the following : Create two scenes, the first containing the objects playing the role of the mask, the other with...
Read more >
WebGL Masking & Composition - Medium
This works because the mask image is grayscale, so the RGB values are all equal. In shaders, color channels are interpreted as numbers ......
Read more >
Masking with Stencil - CGwith3JS - Google Sites
In graphics, this operation (right) is called masking. In art work (left), this is called stenciling. Thus, OpenGL chooses the word "stencil" to...
Read more >
EffectComposer masks + background image+ - Popular Blocks
EffectComposer masks + background image+ ... var stats = initStats(); // create a scene, that will hold all our elements such as objects, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found