Dad72 Posted July 7, 2018 Share Posted July 7, 2018 Hello, When I cast shadows to my character the shadows are perfect. But now if I add shadows to all my buildings, the shadows of the buildings are perfect, but the shadow of the character become horrible without my understanding why. For precision: my scene contains a lot of objects instance and in total almost 300 objects. So I have in 3ds max group in "containers" the elements of the same type of ways to have a more organized hierarchy. I do not know if this can cause the problem, I do not think it's binding. I absolutely need to group models by type in 3ds max otherwise it's a mess. Containers give this in my hierarchy : I add them like this: And I see that they are exporting with the Babylon exporter, but that should not be a problem I think, they are not dealing like meshes. That's what it gives in pictures: Here just the shadows of my character, it's perfect: Now, if I also add the shadows of my buildings, the shadow of the character is bad. (The settings are the same as before.) Shadows of buildings are always perfect, whether with the shadows of the characters or not. but if the buildings are add, the character always project a bad shadows. Does not that come from making it an animating object, I do not know, I do not find what can cause that. Thank you in advance. Quote Link to comment Share on other sites More sharing options...
Dad72 Posted July 7, 2018 Author Share Posted July 7, 2018 What I'm starting to understand is that when building shadows are generated, it calculates in relation to the size of buildings that are larger than the character and small objects of the scene. so the shadow of the character and other small objects become very pixelated. So I was wondering if I should not create a shadow map for large objects and another for small objects to get the desired result? If I have to do that it's annoying because I have to use 2 identical directional lights. So maybe this is not a bug, but maybe it has one because it's an unexpected behavior. Quote Link to comment Share on other sites More sharing options...
Guest Posted July 9, 2018 Share Posted July 9, 2018 You got it. The light will evaluate the best position to capture all the shadow casters in the shadow map. Which will force it to move farther and then reduce the precision of tiny objects. I will highly recommend to create at least two lights (with inclusion lists so you can affect them to the objects you want): - One for the building - One for the tiny objects This will help you keep a good definition for everyone. Btw this is how it works in almost all engines (when they don't support cascading shadow maps). Quote Link to comment Share on other sites More sharing options...
Dad72 Posted July 9, 2018 Author Share Posted July 9, 2018 Okay, that's what I thought I should do, but I wanted confirmation. I will do like that then. Thank you DK Quote Link to comment Share on other sites More sharing options...
Guest Posted July 9, 2018 Share Posted July 9, 2018 My pleasure! Quote Link to comment Share on other sites More sharing options...
Dad72 Posted July 9, 2018 Author Share Posted July 9, 2018 It does not work DK. With two shadows, even if I include or exclude models of light for a shadow map, it creates problems. Let's say that for a light I include a building and for the other light I only include the character. I would have a shadow on the building but not on the character. In addition, I used a directional light and a hemispherical to avoid having a black direction. But with this hemispherical light I have no shadow at all using two shadows. I'm completely dump I will try to make a PG Quote Link to comment Share on other sites More sharing options...
Guest Posted July 9, 2018 Share Posted July 9, 2018 please repro with a SIMPLE PG and I will fix that for you Quote Link to comment Share on other sites More sharing options...
Dad72 Posted July 9, 2018 Author Share Posted July 9, 2018 It looks like I managed to do it with this PG, so I'm now trying to figure out what's wrong with my project that uses a complete import scene, so it's less obvious. So it works. http://www.babylonjs-playground.com/#IFYDRS#2 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted July 9, 2018 Author Share Posted July 9, 2018 No, if I use includedOnlyMeshes, it does not work anymore http://www.babylonjs-playground.com/#IFYDRS#3 only works with excludedMeshes Quote Link to comment Share on other sites More sharing options...
Guest Posted July 9, 2018 Share Posted July 9, 2018 You forgot the ground: http://www.babylonjs-playground.com/#IFYDRS#4 Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted July 9, 2018 Author Share Posted July 9, 2018 Thank you Deltakosh. I managed to have the best on my scene, but it remains a weird problem when I add a third light. In this image, I have two directional lights placed in the same place so that the shadow of my character and buildings go in the same direction. until then it's okay. But if we look, the shading is very dark, see black: So, I tell myself that I will add a hemispherical light to avoid this by adjusting its intensity to 0.1 or 0.2. But that's what happens: I have more shade, finally if I have on the ground so above the sidewalk of the roads as can be seen in the following picture which has the hemispherical light in addition: So I do not understand that when I add the hemispherical light or another, the shadows pass below my sidewalk and road. (below the mesh in fact. Maybe you have a track of what can cause this annoyance (not to call it a bug, lol) Thanks again DK Quote Link to comment Share on other sites More sharing options...
Guest Posted July 10, 2018 Share Posted July 10, 2018 Well this is weird for sure But unfortunately (as expected) I will need a simple repro to track it down Quote Link to comment Share on other sites More sharing options...
Dad72 Posted July 10, 2018 Author Share Posted July 10, 2018 Ok, I was tired yesterday. I just understand why. Before I used 2 lights and I imported my scene like this: BABYLON.SceneLoader.Append("data/scenes/"+sceneName+"/", sceneName+".babylon?"+Date.now(), this.scene, (newScene) => { newScene.lights[2].dispose(); ... }); But now that I have two shadow generator, so I add a light, I have 3. When exporting with 3ds max a hemispherical light is automatically added, and in my code above, I did not remove the good light. I simply correct by doing: newScene.lights[3].dispose(); It works better. I still wonder how I could not see him yesterday. Thank you for everything Deltakosh Quote Link to comment Share on other sites More sharing options...
Guest Posted July 10, 2018 Share Posted July 10, 2018 Well this is perfect then! Please tag the bug as solved Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.