All works as expected, I get proper reflections on PBR materials and some environment “illumination” but…
Whenever I try to add any lights, even the simplest spotlight or hemisphere, it doesn’t affect the scene?
I wanted to add lights to then be able to cast shadows with the ShadowGenerator.
I tried to add many lights of different intensities with a ShadowGenerator adding all meshes or not to be affected by light but the whole scene seems unaffected.
I also tagged all the meshes’ properties with mesh.receiveShadows = true but nothing.
Have had that before. Found that the HDR “Lighting” overwhelmed the shadows, which were really faint. First test is to lower the environmentIntensity of the material of the mesh receiving the shadows. Maybe to 0.1. If you then see shadows, then polish as desired.
Even thought I tried to change the intensity of the environment texture (envText.intesity = 0.1 or whatever) to no luck but that might be something different.
You are saying I should change the environment intensity of the materials of the meshes?
Ive just run into this issue, is there any way to make it work without reducing the environmentIntensity to 0.1? Because it looks really bad at 0.1.
Thanks
EDIT:
So it really seems as if the solution here is to use the prefiltered DDS
Can’t seem to make it work otherwise with the HDRCubeTexture.
Albeit the shadows are still quite weak looking, any advice on strengthening it?
Playground here:
Any advice on making HDR work? My whole background system relies on HDR at the moment. Adding a pre-filtering IBL tool step might be reasonable but would affect my stack.
There are no shadows in your scene or at least not some generated by the shadow generator so I am not too sure about which part you are speaking about ?
Okay theres some confusion here on my part with this example but the original point stands. Is there a solution for shadows not being received on meshes with a scene that has a HDR environment texture?
I did have some luck with dds on my project, the shadows did show with dds based environment texture which is what i was trying to show with this dragon example. On other models with clearer edges the shadows do come through although not as strong as it should be.
Only mixing with analytical lights (usually directional outside to mimic the sun or spot inside the simulate a ceiling light for instance) can create shadows with a ShadowGenerator. The thing is if your environment is too bright, you wont notice the impact of the analytical light making shadows fade a lot.
Balancing the lighting of a scene is not smthg easy. @PatrickRyan can add more on this.
Shadows do work, they’re just very light, as Seb said. If you tone down the environment intensity a lot (I moved to 0.1 here), and add a ground plane, you’ll see the shadows are indeed casted: sss | Babylon.js Playground (babylonjs.com)
If you set it to 1.0 you cant see the shadows. Is there any way we can get this to work without lowering the environment intensity? Would it help to change the “blending-mode” of shadows on the shade when taking into account environment texture?
@Baktrian, there are several things going on here that are complicating the scene and they are all affecting your shadows. Here is an update on the scene with a shadow rendering. This works for this particular scene, but if you take this process into another scene with different requirements, it may not work. Here are the concerns from the original scene:
The environment texture was overclocked, so lighting in the scene was really intense. While the environment intensity was only at 1.0, increasing the contrast to 3.0 and the exposure to 2.5 really puts a lot of light in the scene. While this may help the SSS in the model, it can have an adverse effect on the ground plane which is just a PBR with a white albedo. This white albedo can also cause an issue since there is little room for highlight on the material.
The directional light was far away from the scene, with a large frustrum. This can cause issues with the shadow map and should be as small as needed for the highest quality of shadow.
There are several ways to fix the scene here, which will need to be tailored to your scene.
If you really need to overclock your environment lighting, you need to balance all materials within the scene to accommodate. And you may also need to create extra materials or custom shaders to balance out all elements in the scene. In this case I split the material for the ground to a standard material rather than a PBR. This will make the ground ignore the environment light since it is already so bright. I also set the diffuse color for the ground to a color that wasn’t white to give us some headroom. If you need the environment on the ground, then you will likely either need a custom shader on the object to boost the environment light or on the ground to reduce the environment intensity.
Cull the model from the directional light meshes so that the intensity of the directional light isn’t interfering with your model’s lighting. The overclocked environment is already putting a lot of light on the model, so adding in the directional light probably isn’t needed here.
Move the light closer to the models and reduce the frustrum to get the shadows to render at quality.
Dial in the shadow darkness value to make the shadows feel realistic to the scene.
This really is a balancing act and you need to make sure that all of your materials can handle the mixture of lighting. Additionally, individual models may have different needs such as SSS on one material or a bright base color on another. Each of these materials need to be balanced with the light in the scene. I hope this helps.
Thanks for the response.
In your PG I’m not seeing any shadows on the dragon itself in the scene, the ground seems to have some.
While I see your point about the image having too much exposure and so on but the crux of it is still that the shadows are not present in the scene on the actual main model ( i.e dragon )
I would do a balancing act if there was a working act to follow.