当前位置:网站首页>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)
边栏推荐
猜你喜欢
随机推荐
三种素数筛总结——(朴素筛,埃氏筛,线性筛)
【接口自动化】
常用模块封装-pymysql、pymongo(可优化)
hanLP探索-语义距离计算的实现
废水中氟离子去除方法
酸回收工艺原理
qemu和主机共享磁盘
【fiddler2】使用fiddler mock response 数据
工业废酸回收工艺
STM32F407ZG 串口通信+固定帧头帧尾传输数据帧
作为测试,常用的adb命令
链表、栈、队列
浅谈游戏中3种常用阴影渲染技术(3):阴影贴图
LruCache与DiskLruCache结合简单实现ImageLoader
lua循环
浅谈游戏中3种常用阴影渲染技术(1):平面阴影
开源游戏服务器框架NoahGameFrame(NF)简介(一)
A*Pathfinding插件(3D)
STM32F407ZG 看门狗 IWDG & WWDG
Flutter Package 插件开发








