Help with post processing volumetric clouds

I’m attempting to render spherical volumetric clouds using post-processing. I believe I’m 90% of the way there; I just have three issues that are hindering my progress:

  1. Performance
  2. Washed-out colors from previous scenes (the cube should be red)
  3. Clouds that are behind the object showing through the object.

For this post I would appreciate assistance in addressing problem 3. The ray-marched clouds that are drawn behind the object can be seen through it. I have a feeling that using the depth buffer might fix this problem, but I’m not sure how to go about doing that.

Here is a simplified working demo:

This may help. The only thing you need to avoid rendering clouds that are hidden behind objects is to pass a depthTexture to the shader and exit early as soon as the distance from the viewer is farther than the world depth.

This seems to work! I just have to figure out why the framerate is so bad and how to fix the washed color of the cube