Jump to content

[Beginner] Shadows and directionnal light questions


Recommended Posts



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




Link to comment
Share on other sites

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.


Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...