Getting shadows to work in Three.js custom shader

有些话、适合烂在心里 提交于 2019-12-01 17:48:11

问题


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:


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

I think its just

obj.castShadow = true;
obj.recieveShadow = true;


来源:https://stackoverflow.com/questions/18962155/getting-shadows-to-work-in-three-js-custom-shader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!