找回密码
 立即注册
搜索

[纹理/着色] Fast Volumetric Blob Shadows 1.2

[复制链接]
126 |0
发表于 2024-3-27 14:38:51 | 显示全部楼层 |阅读模式










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的管道资产中,要么在内置的脚本中。如果深度纹理还没有在你的项目中启用,你会看到由于Unity需要渲染深度通道而增加的绘制调用。如果draw调用是主要瓶颈,那么这个资产可能不是正确的解决方案。





回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表