Given the cost of shadow casting, i was wondering if there is a feature or a possible/experimental way to render a shadowmap only once in three.js (even in webgl), for static objects positionned dynamically (ex: a procedural city). So the result can be used in next frames for static objects, at no cost. The shadow rendering would be done only when something moves.
问问题
709 次
1 回答
3
编辑
mrdoobs 批准:
renderer.shadowMap.autoUpdate = false;
renderer.shadowMap.needsUpdate = true; // when scene changes
原始答案:
我找到了自己的方式:我复制了工作方式verticesNeedUpdate
。我向shadowMapNeedsUpdate = true
WebGLRenderer 添加了一个参数。在 ShadowMapPlugin 的渲染函数中,我检查此参数是否为真,并在之后将其设置为假:
如果(_renderer.shadowMapEnabled===false || _renderer.shadowMapNeedsUpdate===false)返回; _renderer.shadowMapNeedsUpdate = false
这样,阴影贴图在第一次渲染时渲染一次,如果场景需要实时阴影贴图,则必须在渲染循环中对其进行精确处理。否则计算能力被释放
于 2015-07-08T14:08:39.930 回答