0

I imported an object from blender, set every mesh of it to cast and receive shadows, but the shadows rendered are incorrect. I also merged the meshes of the object thinking this will resolve the problem, but the result is the same. The problem seems to be resolved when using side: THREE.DoubleSide, but that makes the materials darken.

LIGHT SETTINGS

light = new THREE.DirectionalLight( 0x666666, 1 );
light.position.set(  2*400, 2*300.75, 2*400);
light.position.multiplyScalar( 1.3 );
light.castShadow=true;
light.shadowMapWidth = 2048;
light.shadowMapHeight =2048;
var d = 1300;
light.shadowCameraLeft = -d;
light.shadowCameraRight = d;
light.shadowCameraTop = d;
light.shadowCameraBottom = -d;

light.shadowCameraFar = 10000;
light.shadowBias = 0.0001;
light.shadowDarkness = 0.5;

MATERIAL SETTINGS

var childTilesTexture = THREE.ImageUtils.loadTexture('texture/wood_t.jpg?v1');
childTilesTexture.wrapS = childTilesTexture.wrapT = THREE.RepeatWrapping;
child.material = new THREE.MeshPhongMaterial( { map:childTilesTexture, shininess:5, metal: false} );

SCREENSHOTS

https://i.stack.imgur.com/bsKnU.jpg

ANOTHER SCREENSHOT

As you can see, the handles are casting a shadow through the object box.

https://i.stack.imgur.com/aLMgL.jpg

culeaalex
  • 47
  • 1
  • 7
  • can you pinpoint on your images where the problems are? – gaitat Jul 27 '15 at 13:52
  • what do you mean with 'shadows rendered are incorrect'? Show an example of that problems – Ale_32 Jul 27 '15 at 14:06
  • Look at the images I linked (on the first mainly). The shadows on the back of the objects should be full, but as you can see, parts without shadow apear. The light is in front of the objects, so the back of them should be covered in shadow. Instead, you can see parts with light. – culeaalex Jul 27 '15 at 14:10
  • Try setting `shadowBias ` to a small negative value. – WestLangley Jul 27 '15 at 16:08
  • @WestLangley: I set it to 0.0003 and works great! Post it as answer so others can view it properly :) – culeaalex Jul 27 '15 at 16:25

1 Answers1

0

The property shadowBias can be used to remedy self-shadowing problems. Try varying it.

Try both small negative values, and small positive values.

three.js r.71

WestLangley
  • 102,557
  • 10
  • 276
  • 276