RaananW Posted October 23, 2014 Share Posted October 23, 2014 Hi guys, I am trying to understand the fundamental concepts of direction light and the shadow generator, and how to combine them both. I am playing with the shadows demo from the playground - I have removed light2 (well, commented it ) I have added another sphere to show me the direction's position (the new sphere's position is light.direction) Light direction is -1, -2, -1 . So far so good. Example here - http://playground.babylonjs.com/#XOOY7 , and everything is working fine. Now I do the following - I change the light's direction to -1,-1,-1. I wouldn't have expected Any major difference (shadow should move a bit, it should still be generated for the entire object). What happens is this - http://playground.babylonjs.com/#XOOY7#1 . Part of the shadow is simply cut out (Lower right corner, in case you haven't changed the camera perspective). Ok, I then decided to keep on experimenting. I have changed the direction to -1, -20, -1 . Once again, I have expected that there won't be a major difference in the shadow (I have just moved the light's y a few units (well, 18 ) down. This is how it looks like - http://playground.babylonjs.com/#XOOY7#2 This time, the upper left corner is somehow filtered out. I have continued to change the direction property a few more time, but the only time a real full shadow appeared was when it was -1, -2, -1. I have also played with the light's position, it was still very hard to get the shadows working with different configuration. I do believe my major misunderstanding is about the direction property of the directional light. The direction is the point to which the light source is directed to. Light is emitted from everywhere, which means that technically objects should be lit from the bottom as well. The position property of the light is just for the shadow generation. Otherwise it is not really used (I hope I got that right). What am I missing? Why is the shadow not working correctly? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 23, 2014 Share Posted October 23, 2014 I have to admit that shadow maps are not clear enough. Your assumption is right for lighting. But for shadows, I need to create a shadow map and to do so I need a position (the point of view of the light). So for shadows, you have to consider that I'm taking a snapshot of the scene from the position of the light. This snapshot uses the direction to know where to look Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 23, 2014 Share Posted October 23, 2014 So for instance when in your scene you see the shadow disappearing this is because the object is out of the shadow map. To fix that you have to move the light backwards to allow it to see more things Quote Link to comment Share on other sites More sharing options...
RaananW Posted October 24, 2014 Author Share Posted October 24, 2014 That did the trick Changing the y position of the light in http://babylonjs-pla...es.net/#XOOY7#2 to 90 worked.So, in general, it would be wise to put the light up high in any case, right? or does it damage performance? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 24, 2014 Share Posted October 24, 2014 No that's perfectly fine Quote Link to comment Share on other sites More sharing options...
Dinkelborg Posted October 24, 2014 Share Posted October 24, 2014 Wouldn't it be possible to check inside the directional light script, if any object is outside of the shadowMap so if any object is not inside the 'view field' of the directional light "Camera" and then Log at least a warning to the console?I think it would help people who are new to the field... Quote Link to comment Share on other sites More sharing options...
Baker Xiao Posted August 23, 2017 Share Posted August 23, 2017 @Deltakosh it seems moving the light up high will cause the shadows to look more blurry. it can be seen in https://www.babylonjs-playground.com/?15 if you adjust the y value of the light1 position to 400 you will see the shadows change. how do we cast a shadow from a directional light onto every object in the scene without losing shadow quality? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted August 24, 2017 Share Posted August 24, 2017 There is always a trade-off If you want to embrace all the scene, you will have to move the light as it defines the point of view. To avoid losing shadow quality you will have to increase the texture size Baker Xiao 1 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.