-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Description
What problem does this solve or what need does it fill?
Say I am creating an outdoor 3d scene. I have my beautiful HDR skybox cubemap. I can process it into diffuse+specular textures to use with Bevy's EnvironmentMapLight. I set up my camera accordingly. Everything looks super pretty...
... But there are no shadows. And there is no way to get any shadows.
Additional context
The "proper" photorealistic way to get shadows from environment map lighting would be to implement some form of Global Illumination, ideally Raytracing. That way, all the light is accounted for, everything is lit accurately and has all the beautiful soft shadows from all directions.
If I use my HDRI skybox panorama in Blender and render in Cycles, I don't need to have any lights in my scene (not even a directional light). Everything will automagically get shadows based on the environment lighting. The sun is not special in any way.
But Bevy does not have Global Illumination or Raytracing. So we need some cheaper way to approximate the shadows caused by the sun in outdoor scenes that use environment map lighting.
What alternative(s) have you considered?
The "old-school" way to get shadows from the sun is to use a Directional Light. Bevy already supports this. If I were to use a SDR skybox and no environment map lighting, this is what I would use.
However, when there is already EnvironmentMapLight on the camera, spawning an additional DirectionalLight entity would add extra light to the scene and make everything overly bright. The sun is already part of the HDR environment map texture and all the objects are already lit as they should be.
I experimented a little bit with spawning a DirectionalLight anyway, hoping to somehow configure it to only give me shadows without actually illuminating the scene, but that is not possible. If I set the light's color to Color::NONE or the intensity to zero, the shadows disappear.
What solution would you like?
The simplest possible solution would be to make it possible to spawn a DirectionalLight that only does shadows and does not contribute to the PBR shading. Just like we can enable/disable shadows on a light entity, we should also be able to disable its contribution to lighting. Basically: implement shadow-only "light" entities.
Further: the user-friendly solution would be if Bevy could automatically detect the sun's parameters (direction, intensity, color) based on the brightest pixel in the skybox / environment light specular cube map texture. This would save the user the hassle of having to spawn a DirectionalLight and figure out how to rotate its transform and what parameters to give it.
tl;dr: Since we don't have raytracing or global illumination, we could at least get some approximate shadows from the skybox / environment map light by detecting where the sun is (the brightest spot in the texture) and generating shadow cascades as if it were a DirectionalLight.