https://catlikecoding.com/unity/tutorials/custom-srp/point-and-spot-shadows/
Spot Shadow texelSize 计算,以及 normalBias 的使用


添加偏移值,避免采样到边界


Point 如果需要实时阴影,他所投射的是一个Cubemap,需要六个面,计算量是 SpotLight的六倍

优化的写法如下。原因是 Cubemap的fov总是90度。

结合下面这个图片解释

因为我们没有渲染到标准的Cubemap中,而是使用 tile 作为cubemap,我们采样的时候不能使用采样cubemap的标准模式。
使用CubeMapFaceID 计算面 ID

面 ID 对应 C# 层的索引。+X,-X,+Y,-Y,+Z,-Z

The plane normals have to point in the opposite direction as the faces, like the spot direction points toward the light。
灯光方向是从物体表面指向灯光,和 Cubmap Face 是相反的方向

通过在渲染阴影时,增大FOV角度,避免采样 tile 的 cubemap 时,采样到边界的问题

point light 和 spot light 在mixed选项下,才会烘焙阴影到 shadowmask
不理解的地方:
- SpotLight
- 不同角度所应用的法线偏移量不相同?为什么需要计算纹素?

- 不同角度所应用的法线偏移量不相同?为什么需要计算纹素?
- 反转矩阵

反转前效果

反转后效果
