Jump to content

Is it possible to both cast and recive shadows without self shadowing?


JonVarner
 Share

Recommended Posts

I have a situation where I have three meshes: "A, B, C". What I would like to do is have mesh "A" cast a shadow on mesh "B" and meshes "A and B" to cast shadow on mesh "C". But I do not want mesh "B" to cast shadows on itself. What I have so far:

window.shadowGenerator = new BABYLON.ShadowGenerator(512, light, true,true);
window.shadowGenerator.getShadowMap().renderList.push(window.mesh_A);
window.mesh_B.receiveShadows = true;

 

Link to comment
Share on other sites

So yes this is possible but a bit tricky

You may need to create multiple lights and shadow generators. light #1 would be from A to B for instance (and thus you will add A to the shadowgenerator but exclude it from the lith with light.addExcludedMesh), etc...

Link to comment
Share on other sites

Thanks Deltakosh, that was the ticket. For those who might run into a similar situation here is what I came up with.

light2.excludedMeshes.push(mesh_A,mesh_B);

shadowGenerator = new BABYLON.ShadowGenerator(1024, light1, true,true);
shadowGenerator.getShadowMap().renderList.push(window.mesh_A);
mesh_B.receiveShadows = true;    

var shadowGenerator2 = new BABYLON.ShadowGenerator(1024, light2);                  
var shadowGenerator2.getShadowMap().renderList.push(mesh_A,mesh_B);
mesh_C.receiveShadows = true;

 

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.

Guest
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.

Loading...
 Share

  • Recently Browsing   0 members

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