mirco Posted March 22, 2017 Share Posted March 22, 2017 Hi, i have a litte problem (hopefully). I try to implement a basic day-night lighting, including a small visualizing of it, to see whats going on. Now there is the problem that the light is under the ground, but the objects get the light through the ground. For the Light I use a "DirectionalLight" with the current position of x:4.33, y:-1.61, z:1.92 ( ground is at y:0 ) The direction of the light is set this way: light.setDirectionToTarget( new BABYLON.Vector3(0,0,0) ); I don't no if it matter but I have already deactivate "backFaceCulling = false" for the ground Maybe someone can give me a hint how to solve my issue. Attached i have a picture with my lightning issue. The yellow point is the light. Quote Link to comment Share on other sites More sharing options...
V!nc3r Posted March 22, 2017 Share Posted March 22, 2017 The simplest is to activate shadows Quote Link to comment Share on other sites More sharing options...
jerome Posted March 22, 2017 Share Posted March 22, 2017 Why don't you just switch the light off when it's under the ground ? Quote Link to comment Share on other sites More sharing options...
mirco Posted March 22, 2017 Author Share Posted March 22, 2017 V!nc3r Thanks, you are right, i only gave the tree the option to produce shadow, but not "receiveShadows" @jerome because I don't now when the light is under the ground. Here in this example the ground is plane, but later it will be a HeightMap or something like that. Quote Link to comment Share on other sites More sharing options...
jerome Posted March 22, 2017 Share Posted March 22, 2017 If you use a GroundMesh, you may know what is the current ground altitude at any (x, z) coordinates with http://doc.babylonjs.com/classes/2.5/groundmesh#getheightatcoordinates-x-z-rarr-number whatever its shape Quote Link to comment Share on other sites More sharing options...
mirco Posted March 22, 2017 Author Share Posted March 22, 2017 mh, thats good to now. but I think with a DirectionalLight its not possible to calculate it ? Quote Link to comment Share on other sites More sharing options...
mirco Posted March 22, 2017 Author Share Posted March 22, 2017 sorry I have a next problem, I have activate receiveShadows on the tree to remove the lightings from under the ground now I have a black tree all the time instead of the pink one. Maybe its related to my other problem, but I have tried it already without "flat shadings", but no better result. without receiveShadows with receiveShadows Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 22, 2017 Share Posted March 22, 2017 Of memory, an object can: receive the shadow or projected, but not both. But this may be changing. I know this was the case. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 22, 2017 Share Posted March 22, 2017 A mesh can receive and cast shadows but you will have to play with shadowGenerator.bias to help with precision Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 22, 2017 Share Posted March 22, 2017 @Deltakosh Ah, this changed ? because I remember that that was before, or one or the other. But long ago, it had to change. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 22, 2017 Share Posted March 22, 2017 Yep it changed when I introduced the new shadows (I guess it was for 2.4) We also added support for float textures recently (2.5) which helps for precision Dad72 1 Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 22, 2017 Share Posted March 22, 2017 Cool, I did not know. GameMonetize 1 Quote Link to comment Share on other sites More sharing options...
mirco Posted March 22, 2017 Author Share Posted March 22, 2017 I have tried shadowGenerator.bias but it doesn't help. Quote Link to comment Share on other sites More sharing options...
mirco Posted March 22, 2017 Author Share Posted March 22, 2017 here i created a playground: http://www.babylonjs-playground.com/#16XKTO#33 the cone is complete dark, I don't no what I have to adjust to get I back "pink" because there is no shadow that should produce on the cone. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 22, 2017 Share Posted March 22, 2017 ok I've tried and bias is not enough for BlurVSM. So I suggest that your object should not receive shadows and you can then turn off the light when light is under the ground? Quote Link to comment Share on other sites More sharing options...
mirco Posted March 22, 2017 Author Share Posted March 22, 2017 mh, I played around, but I don't no how I can calculate when a "DirectionalLight" is complete under the ground Quote Link to comment Share on other sites More sharing options...
mirco Posted March 22, 2017 Author Share Posted March 22, 2017 so useBlurVarianceShadowMap currently doesn't work with mesh`s that generate and receive shadows at the same time? I tested the other options for the ShadowGenerator, but first I think its only the "quality" of the borders of the shadow, but I see that changing the option also reduce the realistic shadows. shadowGenerator.useBlurVarianceShadowMap = true; shadowGenerator.useBlurVarianceShadowMap = false; Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted March 23, 2017 Share Posted March 23, 2017 What you see with second image can be controlled with bias or really near to 0 Quote Link to comment Share on other sites More sharing options...
mirco Posted March 23, 2017 Author Share Posted March 23, 2017 Ok, so I played around with Bias and disabled Blur but i don't find a good value for multiple different meshes and I don't can fix the problem with the light through the ground. Maybe some other ideas to work around this problem? Or do you think its possible to fix this problem ? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 23, 2017 Share Posted March 23, 2017 For the lights under the ground, I put the intensity 0 for to whether the light is under the ground, you know that the + is above the ground and the in - is under the ground if light.position.y > 0 // day light.position < 0 // night Quote Link to comment Share on other sites More sharing options...
mirco Posted March 23, 2017 Author Share Posted March 23, 2017 yes, this works easy if you have a plane ground. But maybe not if I have a "sphere" world A other problem when I don't activate receive shadows on objects, how can i handle a "cameras" moves inside a house. All Items inside the house will get light through the walls but it should be dark in there? Quote Link to comment Share on other sites More sharing options...
Dad72 Posted March 23, 2017 Share Posted March 23, 2017 Put your houses with isBlocked = true property for the light does not come on the inside. Quote Link to comment Share on other sites More sharing options...
mirco Posted July 17, 2017 Author Share Posted July 17, 2017 On 23.3.2017 at 0:03 AM, mirco said: so useBlurVarianceShadowMap currently doesn't work with mesh`s that generate and receive shadows at the same time? I tested the other options for the ShadowGenerator, but first I think its only the "quality" of the borders of the shadow, but I see that changing the option also reduce the realistic shadows. shadowGenerator.useBlurVarianceShadowMap = true; shadowGenerator.useBlurVarianceShadowMap = false; Hi, is there something new in Babylon.js 3.0 that help me fixing this problem? I read the changelog but doesn't find something that can help me here? Mirco Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted July 18, 2017 Share Posted July 18, 2017 Hello just change the bias of your shadowGenerator to 0 (IF this does not help, please provide a repro on the playground) Quote Link to comment Share on other sites More sharing options...
mirco Posted July 18, 2017 Author Share Posted July 18, 2017 I tried to play with my playground, but it look like I don't get the shadows work at all. Not on the ground and not on the object. Some other playgrounds don't show shadows too. https://www.babylonjs-playground.com/#IIZ9UU found in the shadow tutorial ( http://doc.babylonjs.com/tutorials/shadows ). The Playground 2.5 is broken. https://cdn.babylonjs.com/babylon.2.5.js returns with 404 Sorry for my questions about the shadows but I don't get it work, i like this framework and would love to build my project with Babylon. Thanks for your help. 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.