当前位置:网站首页>Talking about 3 Common Shadow Rendering Techniques in Games (3): Shadow Mapping
Talking about 3 Common Shadow Rendering Techniques in Games (3): Shadow Mapping
2022-08-10 06:14:00 【Youmeng Maker】
Talking about 3 common shadow rendering techniques in games (3): shadow map
Copyright Notice
- This article is an original article of "Youmeng Maker", you can reprint it freely, but you must add a complete copyright statement
- For more learning resources, please add QQ: 1517069595 (enterprise-level performance optimization/hot update/Shader special effects/server/commercial project combat/weekly live broadcast/one-to-one guidance)
Third, shadow map
3.1 Shadow Map Features
- Shadow mapping is a shadow rendering method officially adopted by Unity. The official has done a lot of work in order to integrate the shadow mapping method. As developers, we only need to set the lights in the scene and set the in-game lighting.Whether the gameobject can generate shadows can be completed
- An additional ShadowCaster channel is required
- Easy to implement soft shadows
3.2 Shadow Map Implementation
- The first step: generate a depth map at the position of the light, and render the depth value in the scene into the depth map, as shown in the following figure, the part of the ground and the place where the block is illuminated by the light need to be rendered, then we willRender their depth values into our depth map.The information of these scenes will be stored in an additional pass called ShadowCaster.
ShadowCaster is a pass specially used to obtain the depth information of the scene. The depth information of this Pass is obtained from the position of the light
- Step 2:
- If we want to render the ground plane, and the ground plane is composed of points, if we want to render point P, if we look at it with our naked eyes, then it is easy to see that point P is in shadow,But how does the computer know if point P should be rendered?
- Compare the rendered depth map with the depth value of point P in the light space, which involves converting the depth value of the camera space of point P into the light space (this involves a lot of low-level knowledge points, you canWatch our open class to learn more).After the point P is transferred to the light space, it can be understood that the point P is 0.9 away from the light and 0.4 away from the camera. Because 0.9>0.4, the point P is in the shadow and does not need to be rendered.
- More about the underlying knowledge, such as the underlying API, the implementation details of the spatial transformation of point P at the engine level, are also explained in our open courses.
3.3 Soft Shadows
- ShadowMap can also achieve the effect of soft shadow. Soft shadow is an important shadow effect in the game. A shadow is composed of umbra and penumbra. Soft shadow is the so-called penumbra, such as the picture in the lower right corner, around the shadowWith the blurred shadow, how to achieve the effect of soft shadow, you can pay attention to our ShadowMap course, we will tell you the specific implementation method

Summary
- Further study content:
- The solution to the depth jitter problem.
- A plane on the left of the picture is parked on the runway, because the depth value of the runway map and the shadow of the plane is the same, so there will be jitter.
- Multi-light real-time shadowing and its performance optimization.
- If there are multiple light sources in the scene, it will cause multiple shadows to the same object. How to realize real-time shadowing of multiple light sources and its performance optimization, you can continue to pay attention to our course.
- The solution to the depth jitter problem.
- In this article, I mainly explain two aspects of knowledge, the implementation of plane shadows and the use of stencil buffers, and the implementation principles of shadow cones and shadow maps, as well as the realization of shadow effects in some commercial projects.possible problems.
- If you want to learn more about shadow rendering and the learning route in TA, you can scan the QR code to join our open class and receive relevant materials.

For more learning resources, please add QQ: 1517069595 (/enterprise-level performance optimization/hot update/Shader special effects/server/commercial project combat/weekly live broadcast/one-to-one guidance)
边栏推荐
- 废酸回收再利用
- 为什么游戏需要热更新
- Explore the origin of the garbled problem: the association between GBK, UTF8, UTF16, UTF8BOM, and ASN1
- 浅谈游戏中3种常用阴影渲染技术(2):阴影锥
- 抛光树脂应用
- 在Unity中让物体围绕自身的x、y、z轴进行旋转(亲测有效)
- 浅谈《帧同步网络游戏》之“框架”实现思路
- mysql连接报错:Cannot get a connection, pool error Timeout waiting for idle object
- Kernel performance analysis summary
- Unity对象池实现
猜你喜欢
随机推荐
mysql使用常见问题和解决
剑指 Offer(第 2 版)7/6 9-13
超纯水抛光树脂
hanLP探索-语义距离计算的实现
计算数字区间中数字出现次数
动态规划、背包问题 6/23 101-105
lua循环
初学者也能看懂的Ray March体积云
常用模块封装-pymysql、pymongo(可优化)
A*Pathfinding插件(3D)
动态规划、背包问题 6/22 96-100
Gradle学习(二)Groovy
动态规划、背包问题 6/25 110-115
开源游戏服务器框架NoahGameFrame(NF)服务器端环境搭建(二)
Unity导航与寻路系统的基本使用
以STM32F103C6TA为例通过配置CubeMX实现GPIO输出完成点灯实例
KDE框架介绍
mysql分组排序并取各分组前几个数据
酸回收工艺讲解
51单片机AD590温度测量ADC0832运放2.73V减法电压变换








