Casting shadow on MeshPhongMaterial or MeshLambertMaterial in Three.js
Asked Answered
P

1

9

I feel like I'm missing something simple here.

I used JSFiddle by @WestLangley, which demonstrates how to cast a shadow from an object onto a plane.

Everything works as expected when the plane is filled with just color:

var groundMaterial = new THREE.MeshLambertMaterial({
  color: 0xFF0000
});

enter image description here

Then I change it to use texture instead:

var groundMaterial = new THREE.MeshLambertMaterial({
  // color: 0xFF0000,
  map: texture
});

..all of a sudden, shadow is gone:

enter image description here

This happens with both MeshPhongMaterial and MeshLambertMaterial.

Note that neither camera position nor shadow configuration is changed. Everything stays the same, yet shadow is gone.

Should texture be "told" to receive light or is this something else?

Tested on r61, r66, r67.

Pad answered 14/7, 2014 at 19:24 Comment(8)
hmm, i just clicked on your fiddle link and for me, the shadows do work.....*scratchesHead*Handoff
I can duplicate the problem on OSX 10.9.4 with Chrome 35.0.1916.153. Works OK with Safari.Gemmulation
Ugh, I didn't even think to check in another browser! Works in Safari indeed. Fails in Chrome 37.0.2062.3 dev and in FF nightly (33.0a1). I'm on OSX 10.9.4. Interesting...Pad
Works fine on ChromeOS 35.0.1916.155.Afrika
@Afrika do you want me to open an issue for three.js on github?Pad
I am having a similar problem with the current version of node-webkit (v0.10.5) which is running Chromium 35.0.1916.157. Textured geometries are not casting shadows :( edit: they seem to get lit/unlit via directional light however, but no shadows are castKowalski
Now that it's v81, has this been resolved? i'm having the same problem in Chrome - in this fiddle and also in my own projectIndrawn
Works fine on Chrome 63.0.3239.84 on OSXAlongside
U
1

This is a pretty old question, but just to provide some closure, I'd like to point out that the version that was having this issue has since been fixed. The fiddle used Three.js r66, but the most recent (r107 as of this writing) no longer has this problem:

enter image description here

Ustulation answered 5/8, 2019 at 18:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.