# The shadow does not work with object .babylon

**URL:** <https://forum.babylonjs.com/t/the-shadow-does-not-work-with-object-babylon/1756>\
**Category:** Questions\
**Tags:** documentation, blender, lighting, material, shader\
**Created:** [March 7, 2019, 2:36pm UTC](https://forum.babylonjs.com/t/the-shadow-does-not-work-with-object-babylon/1756 "2019-03-07T14:36:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eduardo\_Araujo](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@Eduardo\_Araujo](https://forum.babylonjs.com/u/Eduardo_Araujo)\
**Post date:** [March 7, 2019, 2:36pm UTC](https://forum.babylonjs.com/t/the-shadow-does-not-work-with-object-babylon/1756/1 "2019-03-07T14:36:29Z")

</div>

The shadow does not work with object .babylon

I have a problem, I have a scene with an exported .babylon file, I can not make all objects shadow and the ground receives shadows, I need help with this, please someone has an idea?

sorry for my english, is bit bad.

 ![PNG](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/7/78ab2ddca5678a17e15c0dca42a29527cf92a6b2.jpeg)

and her the code

> Blockquote

 Babylon - Getting Started !-- Babylon.js --\> html, body { overflow: hidden; width : 100%; height : 100%; margin : 0; padding : 0; }

```
    #renderCanvas {
        width : 100%;
        height : 100%;
        touch-action: none;
    }
    </style>

```

 var canvas = document.getElementById("renderCanvas");

```
    // <reference path="../../dist/preview release/babylon.d.ts"/>
    // <reference path="../../dist/preview release/materialsLibrary/babylon.cellMaterial.d.ts"/>
    
    var createScene = function() {
    	var scene = new BABYLON.Scene(engine);
    	scene.clearColor = new BABYLON.Color4(0, 0, 0, 0)
        scene.ambientColor = new BABYLON.Color3(0.4, 0.4, 0.4)
    
    	var camera = new BABYLON.ArcRotateCamera("Camera", 0, Math.PI / 2, 12, BABYLON.Vector3.Zero(), scene);
    	camera.attachControl(canvas, true, true);
        
        var light = new BABYLON.DirectionalLight('light', new BABYLON.Vector3(0, -1, 1), scene)
        
        var SphereTexture = new BABYLON.StandardMaterial("ground", scene);
        SphereTexture.diffuseTexture = new BABYLON.Texture("textures/amiga.jpg", scene);
        SphereTexture.diffuseTexture.uScale = 1;
        SphereTexture.diffuseTexture.vScale = 1;
        SphereTexture.specularColor = new BABYLON.Color3(0, 0, 0);
        
        

        var shadowGenerator = new BABYLON.ShadowGenerator(1024, light);
        shadowGenerator.useExponentialShadowMap = true;
        shadowGenerator.useBlurExponentialShadowMap = true;
        shadowGenerator.useKernelBlur = true;
        shadowGenerator.blurKernel = 500;
        shadowGenerator.setDarkness(0.5);
    
    	//var knot = BABYLON.Mesh.CreateTorusKnot("knot", 2, 0.5, 128, 64, 2, 3, scene);
        BABYLON.SceneLoader.Append("./", "bobermaneditor1.babylon", scene, function (newMeshes) {
        shadowGenerator.addShadowCaster(newMeshes[1]);
        });
        
        
        
    	var cell = new BABYLON.CellMaterial("cell", scene);
    	cell.diffuseTexture = new BABYLON.Texture("textures/amiga.jpg", scene);
    	cell.diffuseTexture.uScale = cell.diffuseTexture.vScale = 3;
    	cell.computeHighLevel = true;
    
    	return scene;
    };
    
    var engine = new BABYLON.Engine(canvas, true, { preserveDrawingBuffer: true, stencil: true });
    var scene = createScene();

    engine.runRenderLoop(function () {
        if (scene) {
            scene.render();
        }
    });

    // Resize
    window.addEventListener("resize", function () {
        engine.resize();
    });
</script>

```

---

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [March 7, 2019, 2:40pm UTC](https://forum.babylonjs.com/t/the-shadow-does-not-work-with-object-babylon/1756/2 "2019-03-07T14:40:21Z")

</div>

Hi.

I am not sure but, try setting the position of the directional light.

light.position = new BABYLON.Vector3(x,y,z).

Here is a little playground to test it out.

[https://www.babylonjs-playground.com/#20OAV9#480](https://www.babylonjs-playground.com/#20OAV9#480) (uncomment line 8 to see what happen)

---

<div class="post-metadata">

**Author:** ![Eduardo\_Araujo](https://avatars.discourse-cdn.com/v4/letter/e/9fc348/32.png) [@Eduardo\_Araujo](https://forum.babylonjs.com/u/Eduardo_Araujo)\
**Post date:** [March 7, 2019, 2:58pm UTC](https://forum.babylonjs.com/t/the-shadow-does-not-work-with-object-babylon/1756/3 "2019-03-07T14:58:18Z")

</div>

nothing dude :c my .babylon is this

> Blockquote

```auto
BABYLON.SceneLoader.Append("./", "bobermaneditor1.babylon", scene, function (newMeshes) {
        shadowGenerator.addShadowCaster(newMeshes[1]);
        });

```

---

<div class="post-metadata">

**Author:** ![nogalo](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/nogalo/32/120_2.png) [@nogalo](https://forum.babylonjs.com/u/nogalo)\
**Post date:** [March 7, 2019, 3:10pm UTC](https://forum.babylonjs.com/t/the-shadow-does-not-work-with-object-babylon/1756/4 "2019-03-07T15:10:35Z")

</div>

Hmm. I am not sure then. Long shot guess xD -\> maybe set newMeshes[0] instead of newMeshes[1];  
In any case I believe that you have to define position for directional light if you want shadows from it. So whatever is a problem, set that position.

But without some testing and tweaking I cannot help you more (if you can set some playground example would be nice).

Or wait for someone more experienced than me for proper answer. 🙂

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [March 7, 2019, 3:32pm UTC](https://forum.babylonjs.com/t/the-shadow-does-not-work-with-object-babylon/1756/5 "2019-03-07T15:32:39Z")

</div>

A PG would help, is there more than one mesh loaded with your function?
