I am trying to mask a 3D scene with another 3D scene. I managed to get it working with regular THREE.Mesh objects as shown below:
The main scene has a bunch of low poly spheres. The mask scene has a red cube. Both scenes are passed as textures to a custom shader that checks the red pixels on the mask and draws the pixels of the main.
It works. Here is a fiddle: http://jsfiddle.net/at4rumn6/3/
// please check source on jsfiddle
--
However, if I replace the bunch of spheres by blobs like in the Marching Cubes example, it stops working. The problem is shown below:
It seems like something is not getting cleared in the renderer. It might be related to THREE.ImmediateRenderObject, but I don't understand what it is doing. This seems like a very specific case, I might have found a limitation in the library. Or maybe I'm just doing something wrong.
Here is another fiddle showing the error: http://jsfiddle.net/Lwm93rxr/2/
Is there a way to clear the buffer and get my mask working without any 'dirt' from other scenes?