Adding simple rectangular or circular shadows is very easy with this asset! The shadow volume geometry can be moved, rotated, and scaled. Just drop the material onto a cube or sphere mesh, place it in the world, and adjust the color, sharpness, and intensity as needed. For dynamic objects, you can position it with a simple script or constraint. The shadows can be useful even in situations when full shadows are enabled but a little bit of cheap extra occlusion is desired. The material can be GPU instanced, but static and dynamic batching do not work, because batching removes transformation information necessary for the shader to function.
The primary advantage this asset has over the standard Unity projector is that the projector will re-render all of the objects it affects, which can potentially increase the number of draw calls and overall cost of a scene dramatically, especially if there are multiple objects casting shadows on multiple environment objects, or the objects receiving the shadows are large or complex. The FVBS shader doesn't suffer from this issue, and will have the same cost regardless of the complexity of the scene being shadowed.
Note: For the shader to work, there must be a depth texture enabled on the camera, either in the pipeline asset for the URP, or with an included script for Builtin. If the depth texture is not already enabled in your project you will see an increase in draw calls due to Unity needing to render the depth pass. If draw calls are the primary bottleneck this asset is likely not the right solution.
使用此资源,添加简单的矩形或圆形阴影非常容易!阴影体积几何体可以移动、旋转和缩放。只需将材质拖放到立方体或球体网格上,将其放置在世界场景中,然后根据需要调整颜色、锐度和强度即可。对于动态对象,您可以使用简单的脚本或约束来定位它。即使在启用了完整阴影但需要少量额外遮挡的情况下,阴影仍然非常有用。材质可以进行 GPU 实例化,但静态和动态批处理不起作用,因为批处理会删除着色器运行所需的变换信息。
与标准 Unity 投影仪相比,此资源的主要优势在于投影仪将重新渲染其影响的所有对象,这可能会显著增加绘制调用次数和场景的总体成本,尤其是在多个对象向多个环境对象投射阴影,或者接收阴影的对象很大或很复杂的情况下。FVBS 着色器不会受到此问题的影响,并且无论阴影场景的复杂程度如何,其成本都相同。
注意:要使着色器正常工作,必须在摄像机上启用深度纹理,该纹理可以在 URP 的管线资源中启用,也可以在 Builtin 的内置脚本中启用。如果您的项目中尚未启用深度纹理,则由于 Unity 需要渲染深度通道,您将看到绘制调用次数增加。如果绘制调用是主要瓶颈,那么该资源可能不是正确的解决方案。
|