Getting shadows to work in Three.js custom shader

2019-02-23 01:44发布

I'm trying to get shadows to work in a custom shader in Three.js. I've tried to add these into my codes:

In uniforms:

THREE.UniformsLib["shadowmap"]

In the fragment shader:

THREE.ShaderChunk["shadowmap_pars_fragment"]
THREE.ShaderChunk["shadowmap_fragment"]

In the vertex shader:

THREE.ShaderChunk["shadowmap_pars_vertex"]
THREE.ShaderChunk["shadowmap_vertex"]

which works. The object can receive shadows.

However, it cannot cast shadows. Does anyone know what other bits of codes are needed?

1条回答
We Are One
2楼-- · 2019-02-23 01:53

I believe that you need to mark each object as casting and receiving shadows

I think its just

obj.castShadow = true;
obj.recieveShadow = true;
查看更多
登录 后发表回答