AllForum Posted August 21, 2014 Share Posted August 21, 2014 Hello, I tried to add shadows in a test scene. But the objects do not generate shadows. And if a shadow is drawn it has no sense : it is not generated by a scene object. Here is my light and my shadow generator :var light1 = new BABYLON.DirectionalLight("DirLight", new BABYLON.Vector3(-1, -1, -1), scene);light1.position = new BABYLON.Vector3(2, 3, 2);light1.diffuse = new BABYLON.Color3(1, 1, 1);light1.specular = new BABYLON.Color3(0.6, 0.6, 0.6);light1.intensity = 1.0;var shadowGenerator = new BABYLON.ShadowGenerator(1024, light1);shadowGenerator.useVarianceShadowMap = true;For each mesh :shadowGenerator.getShadowMap().renderList.push(mesh);mesh.receiveShadows = true;My questions :- Is something missing in my code ?- A directional light with a position is unusual : what is the rule to set the position properly ? Thanks for your advices Quote Link to comment Share on other sites More sharing options...
eucly2 Posted August 21, 2014 Share Posted August 21, 2014 Hi, I don't what you doing wrong but you can see a full example of shadows here: http://www.babylonjs.com/playground/#9SNI5And also you can attach the light to the camera to have "dynamic" shadows : http://www.babylonjs.com/playground/#9SNI5#1 Quote Link to comment Share on other sites More sharing options...
AllForum Posted August 21, 2014 Author Share Posted August 21, 2014 Thanks for the links. I played with them.The directionnal light seems to be like a spot light. I think that it is a problem for an easy use : objects that are not in the cone of the light will not generate shadow. And putting the light very far seems to generate inaccurate shadows.On my test scene the "shadows" look like the cone of the light ; it is very strange.As it is only for testing I will not debug my test and I will use your links.Thanks 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.