当前位置: 首页 > news >正文

Shadowmask和Distance Shadowmask的区别

https://catlikecoding.com/unity/tutorials/rendering/part-17/

想了一会,发现这个知识点还是盲点,所以特此记录下。
在官网中:https://docs.unity3d.com/Manual/LightMode-Mixed-Shadowmask.html

首先看看官网是怎么介绍的,主要的区别是在两个表格上,细看如下:

1、shadowmask

shadowmask is a version of the Shadowmask lighting mode shared by all mixed lights in a scene. to set mixed lighting to Shadowmask.

open the lighting window (menu: Window->Rendering->Lighting Settings), click the scene tab, navigate to Mixed Lighting and set the lighting mode to Shadowmask.

这个好操作,但是接下的我还是第一次见到。
next, open the quality settings(menu: edit->project settings, then select the quality category), navigate to shadowmask mode and set it to shadowmask.
在这里插入图片描述

see documentation on mixed lighting to learn more about this lighting mode, https://docs.unity3d.com/Manual/LightMode-Mixed.html

and see documentation on light modes to lean more about the other modes available.https://docs.unity3d.com/Manual/LightModes.html

a shadow mask is a texture that shares the same uv layout and resolution with its corresponding lightmap. it stores occlusion information for up to 4 lights per texel, because textures are limited to up to 4 channels on current gpus.

unity pre-computes shadows cast from static gameobjects onto other static gameobjects, and stores them in a separate shadowmask texture for up to 4 overlapping lights. if more than 4 lights overlap, any additional lights fall back to baked lighting. which of the lights fall back to baked lighting is determined by the baking system and stays consistent across bakes, 又系统决定哪个是baked的,而且一直保持到烘焙的整个过程,除非, unless one of the lights overlapping is modified. light probes also receive the same information for up to 4 lights.

in shadowmask mode:
static gameobjects receive shadows from other static gameobjects via the shadow mask, regardless of the shadow distance (menu: edit->project settings, then select the quality category, and navigate to the shadows section). they also receive shadows from dynamic gameobjects, but only those within the shadow distance.

dynamic gameobjects receive shadows from other dynamic gameobjects within the shadow distance via shadow maps. they also receive shadows from static gameobjects, via light probes. the shadow fidelity 真实度 depends on the density of light probes in the scene, and the light probes mode selected on the mesh render.

note : light probes store information about how light passes through space in your scene. a collection of light probes arranged within a given space can improve lighting on moving objects and static LOD senery within that space.

a good example of when shadowmask mode might be useful is if u are building an almost fully static scene, using specular materials, soft baked shadows and a dynamic shadow caster, not to close to the camera. another good example is an open-world scene with baked shadows up to the horizon, but without dynamic lighting such as a day/night cycle.

shadows

the following table shows how static and dynamic gameobjects cast and receive shadows when using shadowmask mode:
在这里插入图片描述

这里shadow map 和shadow mask的区别是啥???

advantages and disadvantages of shadowmask mode

the performance requirements of shadowmask mode make it a good option for building to low and mid-range pcs, and mobile devices. these are the most significant advantages and disadvantages of using shadowmask mdoe:

advantages:
1/ it offers the same visual effect as realtime lighting.
2/ it provides real-time shadows from dynamic gameobjects onto static gameobjects.
3/ one texture operation in the shader handles all lighting and shadows between static gameobjects.
4/ it automatically composites overlapping shadows from static and dynamic gameobjects.
5/ it has mid-to-low performance requirements, because it does not render static gameobjects into shadow maps???这个不对吧
6/ it provides indirect lighting.

disadvantages:
1/ it only provides low-resolution shadows from static gameobjects onto dynamic gameobjects, via light probes.
2/ it only allows up to 4 overlapping light volumes.
3/ it has increased memory requirements for the light map texture set.
4/ it has increased memory requirements for the shadow mask texture.

2、Distance Shadowmask

https://docs.unity3d.com/Manual/LightMode-Mixed-DistanceShadowmask.html

在这篇文章的上部分都是和shadowmask那一节类似的,下面是不同的地方。

the distance shadowmask mode is a version of the shadowmask lighting mode that includes high quality shadows cast from static game objects onto dynamic game objects.

within the shadow distance (menu:Edit->Project settings, then select the quality category, and navigate to the shadows section), unity renders both dynamic and static game objects into the shadow map, allowing static game objects to cast sharp shadows onto dynamic game objects. for this reason, distance shadowmask mode has higher performance requirements than shadowmask mode, because all static game objects in the scene are rendered into the shadow map.

beyond the shadow distance:
1/ static game objects receive high-resolution shadows from other static game objects via the pre-computed shadow mask.
2/ dynamic game objects receive low-resolution shadows from static game objects via light probes.

a good example of when distance shadow mask mode might be useful is if u are building an open world scene with shadows up to the horizon, and complex static meshes casting real-time shadows on moving characters.

shadows
the following table shadows how static and dynamic game objects cast and receive shadows when using distance shadow mask mode.
在这里插入图片描述

advantages and disadvantages of distance shadow mask mode.
the performance requirements of distance shadow mask mode make it a good option for building to high-end pcs and current generation consoles. these are the most significant advantages and disadvantages of using distance shadow mask mode:

advantages:
1/ it provides the same visual effect as real time lighting.
2/ it provides real-time shadows from dynamic game objects onto static game objects, and static game object onto dynamic game objects.
3/ one texture operation in the shader handles all lighting and shadows between static game objects.
4/ it automatically composites dynamic and static shadows.

disadvantages:
1/ it only allows up to 4 overlapping light volumes.
2/ it has increased memory requirements for light map texture sets.
3/ it has increased memory requirements for light mask textures.

总结上面的两个文章可以得到如下的结论:
无论是shadowmask还是distance shadowmask他们都是针对mixed light的,对其他的模式的灯是无效的。
其实我这里还想继续说一句:
baked的模式,是把直接光光、间接光都烘焙到一张贴图上去,所有的东西都是死的,针对阴影,只有静态物体对静态物体有阴影,因为烘焙的时候,静态物体都是静止的,灯光是baked模式,也是死的。

mixed的模式,间接光是死的,直接光是实时的,性能稍减弱。

realtime的模式,间接光和直接光都是实时的。

不知道总结对不对,但是也就先说几句看看。

举例:
在这里插入图片描述
主光源:平行光,mode=Mixed
plane:静态物体
cubeA:静态物体(高度比较CubeB大)
cubeB:动态物体

shadowmask模式:
在这里插入图片描述
烘焙设置:
在这里插入图片描述
烘焙之后:
在这里插入图片描述
高的为CubeA(静态物体),矮的为CubeB(动态物体)。可以看到CubeA并未对CubeB形成阴影,箭头所指地方本应该有点阴影才对,因为CubeB被CubeA遮挡了。

我们此时看看shadowmask模型下的表格:
在这里插入图片描述
静态物体对动态物体使用的是light probes方式。
所以我们添加一个light probe group试试:
在这里插入图片描述
如图所示,建立一个空物体GameObject,在其身上添加Light Probe Group组件,调整位置到CubeA的位置处,收集光源信息,那么在此烘焙之后:

而如果Light Probe Group离的太远的话,则CubeA还是对CubeB未造成阴影。
在这里插入图片描述

所以light probe 也要放在距离CubeB较为近的地方,用于记录周围的光源的信息。
在这里插入图片描述
可以看到烘焙之后,此时的CubeB接收到了CubeA投放的阴影了。
同时你在场景中也可以移动CubeB,看看其受到阴影的变化,能看到其受到light probe的哪些球的影响。

上面的所说的是,静态物体对动态物体的投影是通过light probe实现的。还有没有别的方法呢?上面的方法有什么不好的地方呢?
接下来我们就来把shadowmask的模式改为distance shadowmask模式,并且隐藏掉上面的light probe,以保证只使用distance shadowmask模式。

在如下设置的时候:
在这里插入图片描述
此时影子距离为50,也就是接收阴影的物体与摄像机的距离在50之内,根据distance shadowmask的表格中,静态物体对动态物体的影子影响列来看,如果在50之内,则使用shadowmap(也就是实时阴影),在大于50之外则使用light probe。
在这里插入图片描述
可以看到这个影子是和未烘焙的时候一样的,比较清晰、锐利。
而如果我们将影子的距离改为5试试:
在这里插入图片描述
此时,CubeB上的影子消失了:
在这里插入图片描述
原因是此时物体的距离与摄像机的距离大于5,但是又没有light probe所以就没有阴影了。那么我们此时不妨再把light probe显示出来,再次烘焙试试:
在这里插入图片描述
可以看到,这个影子又回来了,只是它被light probe影响了而已,而且可以看到使用light probe的方式,影子的质量不高。
以上是对这两种模式的比较分析。

下面我们再总结下:
1、distance shadow mask比shadow mask要耗费些,因为它更想使用的是实时阴影。而什么实时阴影就是shadowmap,它是基于光源之处的深度图的,而shadowmask是死的,是静态的阴影,是预先计算的遮挡信息。

2、我们要注意影子的距离对于distance shadow mask下的实时阴影的影响,只有在影子距离之内,才会使用实时阴影,之外的则要参考表格,使用light probe或者是shadow mask。

3、最后放上两种模式下的对比表格:
在这里插入图片描述

最后附上参考的网址:
https://www.cnblogs.com/lijiajia/p/7231605.html
https://blog.uwa4d.com/archives/sparkle_shadow.html
https://www.sohu.com/a/144292126_280780
https://www.jianshu.com/p/9aba453c2dab
http://blog.sina.com.cn/s/blog_155a1f2470102xww6.html
https://cloud.tencent.com/developer/article/1005933
https://www.cnblogs.com/murongxiaopifu/p/8553367.html
https://blog.csdn.net/qq_40229737/article/details/89500079

相关文章:

  • Angular7_获取异步方法里面的数据
  • maven tomcat jstl 异常
  • maven下载及配置(win7 64位系统)
  • 寒假一:打印沙漏
  • unity depth texture-01
  • LinearEyeDepth和Linear01Depth
  • 打印沙漏
  • SQLAlchemy增删改查 一对多 多对多
  • 体积光,体积雾——链接
  • python 变量搜寻顺序法则LEGB之E注意事项
  • 体积雾
  • Java线程池详解(一)
  • 穷人为什么穷?
  • 【bzoj4567】[Scoi2016]背单词
  • Python基础python是如何进行内存管理的
  • 【跃迁之路】【733天】程序员高效学习方法论探索系列(实验阶段490-2019.2.23)...
  • ComponentOne 2017 V2版本正式发布
  • ECMAScript入门(七)--Module语法
  • pdf文件如何在线转换为jpg图片
  • React Native移动开发实战-3-实现页面间的数据传递
  • spring-boot List转Page
  • Vue官网教程学习过程中值得记录的一些事情
  • 得到一个数组中任意X个元素的所有组合 即C(n,m)
  • 对象引论
  • 前端
  • 数据可视化之 Sankey 桑基图的实现
  • 数据库写操作弃用“SELECT ... FOR UPDATE”解决方案
  • 它承受着该等级不该有的简单, leetcode 564 寻找最近的回文数
  • 物联网链路协议
  • 容器镜像
  • 正则表达式-基础知识Review
  • #FPGA(基础知识)
  • (4)logging(日志模块)
  • (C#)Windows Shell 外壳编程系列9 - QueryInfo 扩展提示
  • (poj1.3.2)1791(构造法模拟)
  • (分享)自己整理的一些简单awk实用语句
  • (六)Hibernate的二级缓存
  • (续)使用Django搭建一个完整的项目(Centos7+Nginx)
  • (转) RFS+AutoItLibrary测试web对话框
  • .NET 4.0中的泛型协变和反变
  • .NET CORE Aws S3 使用
  • .net core webapi 大文件上传到wwwroot文件夹
  • .NET/ASP.NETMVC 深入剖析 Model元数据、HtmlHelper、自定义模板、模板的装饰者模式(二)...
  • .NET/C# 使窗口永不激活(No Activate 永不获得焦点)
  • @ 代码随想录算法训练营第8周(C语言)|Day53(动态规划)
  • @Conditional注解详解
  • @FeignClient注解,fallback和fallbackFactory
  • @NestedConfigurationProperty 注解用法
  • @Service注解让spring找到你的Service bean
  • [20171113]修改表结构删除列相关问题4.txt
  • [C#基础知识系列]专题十七:深入理解动态类型
  • [C++] 默认构造函数、参数化构造函数、拷贝构造函数、移动构造函数及其使用案例
  • [hive] 窗口函数 ROW_NUMBER()
  • [iOS]Win8下iTunes无法连接iPhone版本的解决方法
  • [ISITDTU 2019]EasyPHP