当前位置:网站首页>[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,继续加油吧!
边栏推荐
- 腾讯云【Hiflow】新时代自动化工具
- Confessing the era of digital transformation, Speed Cloud engraves a new starting point for value
- 毕设-基于SSM房屋租赁管理系统
- QT: The Magical QVarient
- Call Alibaba Cloud oss and sms services
- Common open source databases under Linux, how many do you know?
- Tencent Cloud [Hiflow] New Era Automation Tool
- Open Source License Description LGPL
- STM32 uses stm32cubemx LL library series tutorial
- (11) Metaclass
猜你喜欢

CPDA|How Operators Learn Data Analysis (SQL) from Negative Foundations

今年七夕,「情蔬」比礼物更有爱

为什么pca分量没有关联

public static <T> List<T> asList(T... a) 原型是怎么回事?

Shell script: for loop and the while loop

The linear table lookup

Step by step how to perform data risk assessment

Why is the pca component not associated

Ice Scorpion V4.0 attack, security dog products can be fully detected

Never put off till tomorrow what you can put - house lease management system based on the SSM
随机推荐
【 genius_platform software platform development 】 : seventy-six vs the preprocessor definitions written cow force!!!!!!!!!!(in the other groups conding personnel told so cow force configuration to can
On governance and innovation, the 2022 OpenAtom Global Open Source Summit OpenAnolis sub-forum came to a successful conclusion
How to find all fields with empty data in sql
ffmpeg 枚举decoders, encoders 分析
2022-08-04 The sixth group, hidden from spring, study notes
Dynamic management of massive service instances
YYGH-13-客服中心
Why did they choose to fall in love with AI?
Syntax basics (variables, input and output, expressions and sequential statements)
QT: The Magical QVarient
Burp installation and proxy settings
(十一)元类
Use @Mapper to query the partition status of oracle and report an error
In 2022, you still can't "low code"?Data science can also play with Low-Code!
Queue Topic: Recent Requests
Physical backup issues caused by soft links
Android实战开发-Kotlin教程(入门篇-登录功能实现 3.3)
Use SuperMap iDesktopX data migration tool to migrate map documents and symbols
This year's Qixi Festival, "love vegetables" are more loving than gifts
静态方法获取配置文件数据