当前位置:网站首页>[TA-Frost Wolf_may-"Hundred Talents Project"] Graphics 4.3 Real-time Shadow Introduction
[TA-Frost Wolf_may-"Hundred Talents Project"] Graphics 4.3 Real-time Shadow Introduction
2022-08-05 03:25:00 【zczplus】
4.3.1 Real-time shadow technology based on pictures
The pictures in it mean:Render shadows to images
平面投影阴影
- 根据光的方向,Projects each vertex of the object onto the flat ground.
- 数学原理:相似三角形
- 缺点:
- 只能投影到平面;
- 投影物体必须在光线和平面之间;
投影阴影
- 为每个阴影投影体设置一个相机
- 把阴影投影体渲染到阴影纹理中
- 渲染阴影接收者,并且与阴影纹理进行混合
Unity中的实现
- Projector组件:
- 可以设置它的参数生成一个视锥体
- Projector会使用提供给它的材质,Draws all objects inside the frustum
- 使用Render Texture生成阴影映射图,Draw the shadow cast volume into the shadow texture
- 给Project设置物体和阴影映射图混合的材质
阴影映射
On the right is the depth map,Black is close,White is the principle
- First get a depth map of the light position
- Each pixel is processed at the viewing angle position
- Convert the coordinates of the current position to the depth map obtained from the light position and compare the size
- If it is greater than the previous depth value,Indicates the farther away from the light source,Description is blocked,thus forming a shadow
The third step is the process of comparison and comparison mentioned above;
4.3.2 Real-time shadow optimization
Shadow mapping problem – 自阴影
由于阴影映射的分辨率有限,Discrete sampling points and numerical deviations can cause incorrect shadowing.This is self-shadowing,也被称为Z-Fighting或者阴影粉刺(Surface Acne)
解决方法:当比较深度时,为了避免表面自阴影,需要设置容错阈值:
- 深度偏移(Depth Bias)
- 法线偏移(Normal Bias)
But if the depth cheap is set too large,会导致漏光现象.即阴影与投影者之间发生脱节,也叫做Peter Panning问题.
Offset optimization
The left half of the figure below explains it in great detail,
Points picked during sampling may be red points,as the texel depth in the shadow map,但是在ViewThe dark blue dots during sampling clearly correspond to the same line segment,But it is deeper in comparison,So it will be regarded as a shadow.The solution is to apply an offset,Try to respond correctly to the context.
Unity中的Offset optimization
- Shadow Caster 阶段基于顶点的Normal Bias;
- 在Shadow Caster阶段, 让遮蔽物进行反向偏移;
优点:性能高
Shadow mapping problem ——走样
View shadow mapping from the process of signal reconstruction:
- 初始采样:渲染阴影映射;
- 重采样:从摄像机视角对采样信号(阴影映射)重采样;
Aliasing problems occur in both stages.
- 阴影映射在世界空间均匀分配;
- 视锥体内物体经过透视投影后,近大远小,近平面和远平面的像素一样;
- Elements close to the observer use significantly fewer sampling points;
- This error is called perspective aliasing;
级联阴影映射(Cascaded Shadow Map)
The most efficient solution for perspective aliasing;
把视锥体分割为多个子视锥体;
为每个子视锥体计算独立的相等大小的阴影映射;
其中的shadow distanceCustomizes the range of shadows generated(Originally from the near plane to the far plane),Some overhead is reduced;
重采样误差
A mapped texture is a dynamically generated texture;
滤波 —— 纹理采样误差的解决方案;
滤波
- 图像处理中,通过滤波强调一些特征或者去除图像中一些不需要的部分;
- 滤波是一个邻域操作算子,Use the values of the pixels surrounding a given pixel to determine the last output value for that pixel;
阴影的滤波
- 使用一部分阴影映射采样点来计算某个指定View采样点的最终阴影结果的方法.
PCF滤波
- 从光方向生成阴影映射;
- Depth testing from a camera perspective;
- 当该着色点通过深度测试时,取该像素周围指定大小(滤波核)的范围.Calculate their visible average as output.
blockedIndicates that the surrounding pixels are not visible42个,visibleIndicates that the surrounding pixels are visible7个,The shadow value is finally calculated
PCF滤波的不同实现
- 采样数K
- 规则滤波,33 或者 55;
- 采用Poisson Disk的形式来分布一定数量的采样点.
- Filter kernel hash number
- Gaussian function as filter function etc;
作业
An optimized solution for real-time shadows
- Use depth offset or normal offset to adjust for self-shadowing problems;
- The cascaded mapping method is used to optimize the results for aliasing problems;
- Use for sampling problemsPCFFiltering is optimized,Achieve better soft shadow effect;
- 利用PCSS(Percetage closer soft shadows)Do a soft shadow implementation;
- 针对PCSSIt's optimized againVSSM(Variance Soft Shadow Mapping)
- 由于VSSMSuppose there are too many constraints,出现了MSM(Moment shadow mapping Matrix shadow mapping)
There is still a lot, a lot, a lot to learn!Games101后半部分+202,继续加油吧!
边栏推荐
- YYGH-13-客服中心
- Syntax basics (variables, input and output, expressions and sequential statements)
- 905. 区间选点
- This year's Qixi Festival, "love vegetables" are more loving than gifts
- Web3.0 Dapps - the road to the future financial world
- 达梦8数据库导出导入
- STM32 uses stm32cubemx LL library series tutorial
- How to simulate the background API call scene, very detailed!
- .NET Application -- Helloworld (C#)
- After the large pixel panorama is completed, what are the promotion methods?
猜你喜欢
2022高处安装、维护、拆除考试题模拟考试题库及在线模拟考试
用Unity发布APP到Hololens2无坑教程
public static
List asList(T... a) What is the prototype? 告白数字化转型时代,时速云镌刻价值新起点
Principle and Technology of Virtual Memory
Initial solution of the structure
.NET Application -- Helloworld (C#)
Details such as compiling pretreatment
YYGH-13-客服中心
.NET应用程序--Helloworld(C#)
随机推荐
Call Alibaba Cloud oss and sms services
Use SuperMap iDesktopX data migration tool to migrate ArcGIS data
word分栏小记
(11) Metaclass
Beidou no. 3 short message terminal high slope in open-pit mine monitoring programme
【软件测试】自动化测试之unittest框架
Why is the pca component not associated
Queue Topic: Recent Requests
Developing Hololens encountered The type or namespace name 'HandMeshVertex' could not be found..
用Unity发布APP到Hololens2无坑教程
Simple description of linked list and simple implementation of code
How Jin Cang database correctness verification platform installation file
Question about #sql shell#, how to solve it?
Details such as compiling pretreatment
语法基础(变量、输入输出、表达式与顺序语句完成情况)
mysql can't Execute, please solve it
Distributed systems revisited: there will never be a perfect consistency scheme...
How to transfer a single node of Youxuan database to a cluster
Open Source License Description LGPL
YYGH-13-Customer Service Center