I want volumetric clouds Generate shadows

bug url
https://playground.babylonjs.com/#CUFI3B

i want volumetric clouds Generate shadows

Hey,

Here the cloud box is just a plain box, added “as-is” on the Shadow Caster, so I would say it’s not a bug that the shadow is dark. Your volumetric cloud here is just a custom post-process which runs after render, on the box only :

vec2 tBox = boxIntersection(rayOrigin, rayDir, boxMin, boxMax);
if (tBox.x < 0.0) {
    gl_FragColor = baseColor;
    return;
}

You are testing if the fragment is hitting the cloud box, and if not you return baseColor so your post-process won’t affect the ground is anyway here


Considering your level of GLSL dev here, I would say the best for you would be to :

  • Remove the cloud box from the shadowCaster
  • Edit the previous code where you check ray collision, and deal with these 3 cases :
      1. Box hit → your cloud color
      1. Box shadow hit → darken the output to mimic cloud shadow (no cloud color here)
      1. return baseColor as previously

NB: 2. Box shadow hit means, a ray from this point toward the light collides with the box. So you need to send light pos to the frag shader as well