Sign in to follow this  
jacquesr

Displaced Shadows

Recommended Posts

Hi guys,

I recently started with some visual fidelity stuff in my scene and I wanted to add shadows.

 

Now, I load a mesh that I exported from blender and I do this

 

BABYLON.SceneLoader.ImportMesh("", "lib/orteclbvis/themes/defaulttheme/models/","yard.babylon", this.scene, (newMeshes, ParticleSystem, skeletons ) =>
{ 

    newMeshes[0].rotate(BABYLON.Axis.Y, BABYLON.Tools.ToRadians(180), BABYLON.Space.LOCAL);
    newMeshes[0].position.y = this.getEnvironmentHeight();
    newMeshes[0].position.z = 0; 
    newMeshes[0].position.x = 30000; 

    if(this.sceneObjects.sunLight)
    {
        var shadowGenerator = new BABYLON.ShadowGenerator(1024*16, this.sceneObjects.sunLight);                                        
        shadowGenerator.setDarkness(.3);
        SceneManagerHelper.enableMeshShadowsRecursively(
            <BABYLON.Mesh[]>newMeshes, 
            shadowGenerator);
    }
 });



// recursive shadow enabler method code:

static enableMeshShadowsRecursively(meshes : BABYLON.Mesh[], shadowGenerator : BABYLON.ShadowGenerator)
{
    for(var i = 0; i < meshes.length; i++)
    {
        var m = meshes[i];
        shadowGenerator.getShadowMap().renderList.push(m);                
        m.receiveShadows = true;
        var childs = m.getChildMeshes();
        if(childs && childs.length > 0)
        {
            this.enableMeshShadowsRecursively(<BABYLON.Mesh[]>childs, shadowGenerator);
            }
        }
    }
}

 

And my shadows are weirdly offset. See attached images.

 

Any idea how that can happen?

 

My scene scale is quiet big (1 babylon unit = 1mm)

 

 

shadows_1.jpg

shadows_2.jpg

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.