手机游戏开发的照明技巧

Lighting is one of the most important visual elements of your game. Our partners at Arm have provided some handy tips to help you optimize your mobile game lighting.

照明是游戏中最重要的视觉元素之一。 我们Arm的合作伙伴提供了一些方便的提示,可帮助您优化手机游戏的照明效果。

When it comes to rendering a mobile game, lighting can be one of the biggest performance considerations. It is also one of the most important for completing a visual style. However, artistic goals and performance often find themselves at odds with each other. 

在渲染手机游戏时,照明可能是最大的性能考量之一。 这也是完成视觉样式的最重要步骤之一。 但是,艺术目标和表演常常彼此矛盾。

Fortunately, there are ways to bridge the gap and work within the constraints of mobile hardware. Here, our partners at Arm, the world’s largest mobile chip design company, share some of their tips for lightning from their best practice guide

幸运的是,有许多方法可以缩小差距并在移动硬件的限制内工作。 在这里,我们是全球最大的移动芯片设计公司Arm的合作伙伴, 从他们的最佳实践指南中分享了一些有关闪电的技巧

渲染管线 (Rendering pipeline)

Within Unity’s Built-in Render Pipeline you can choose between two render paths, Forward Rendering and Deferred Shading. In Forward Rendering, real-time lights are very expensive, but to clamp this cost you can choose how many lights should be rendered per pixel. Deferred Shading requires GPU support, but on enabled hardware it can render a large number of real-time lights and offer a high level of lighting fidelity. 

在Unity的内置渲染管线中,您可以在两个渲染路径之间进行选择,即正向渲染和延迟着色。 在正向渲染中,实时光源非常昂贵,但是要限制此成本,您可以选择每个像素应渲染多少光源。 延迟着色需要GPU支持,但是在启用的硬件上,它可以渲染大量的实时灯光并提供高水平的灯光保真度。

While Deferred Shading is very attractive for light-intensive games for PC or console, it is not very performant on mobile GPUs. This is due to the lower bandwidth of mass market devices. When you’re making a mobile title, it’s important that it runs smoothly on as many devices as possible. To optimize your mobile lighting projects, we suggest you use the Universal Render Pipeline.

尽管Deferred Shading在PC或控制台的光密集型游戏中非常有吸引力,但在移动GPU上却不是很出色。 这是由于大众市场设备的带宽较低。 制作移动标题时,重要的一点是,它应在尽可能多的设备上流畅运行。 为了优化您的移动照明项目,建议您使用通用渲染管线。

Unity’s Universal Render Pipeline, a prebuilt Scriptable Render Pipeline, is tuned for performance. Universal Render Pipeline by default is Forward Rendering and has a slew of features to help your app be as performant as it can be (you can read more about it here). 

Unity的通用渲染管道 ( Universal Render Pipeline )是一种预建的可脚本化渲染管道,其性能经过了调整。 Universal Render Pipeline默认情况下是Forward Rendering,它具有一系列功能来帮助您的应用程序达到最佳性能(您可以 在此处 了解更多信息 )。

照明烘烤 (Lighting bake-off)

Regardless of platform, one of the biggest performance upgrades for rendering is to bake lighting into lightmaps and Light Probes. When you use real-time lights, features such as direct lighting and shadows need to be calculated uniquely for every frame that is rendered. Depending on the number of lights on screen, this can get computationally expensive. Performance budget will drastically limit how much content you can have on screen. To work around these limitations, many of the calculations can be precomputed offline in a process called “lightmap baking.”

无论使用哪种平台,渲染的最大性能升级之一就是将照明烘焙到光照贴图和光探针中。 使用实时光源时,需要为渲染的每个帧唯一地计算诸如直接照明和阴影之类的功能。 根据屏幕上的灯光数量,这可能会增加计算量。 效果预算将极大地限制您可以在屏幕上显示的内容。 为了解决这些限制,许多计算可以在称为“ 光照贴图烘焙 ” 的过程中离线进行预先计算 。

Lightmap baking stores lighting and shadow information in textures, or “lightmaps.” This technique can capture computationally intensive lighting characteristics, such as bounced light and soft shadows, which can heighten realism. However, lightmaps have some limitations that are important to understand. Fully baked lighting cannot update in relation to dynamic elements of your Scene. Therefore, any dynamic objects will not be added to the lightmap. But not to worry: your dynamic objects have a pre-calculated solution as well, “Light Probes.” 

光照贴图烘焙将光照和阴影信息存储在纹理或“光照贴图”中。 该技术可以捕获计算强度大的照明特征,例如反射光和柔和阴影,可以增强真实感。 但是,光照贴图具有一些必须理解的限制。 完全烘焙的灯光无法根据场景的动态元素进行更新。 因此,任何动态对象都不会添加到光照贴图。 但请放心:您的动态对象也具有预先计算的解决方案“ Light Probes”

Light Probes have a lot of the same benefits as lightmaps, in that they store lighting data that can be calculated offline. Much of the computational costs are incurred at edit time, rather than runtime. While a lightmap encodes lighting received at a given texel for surfaces in your Scene, a Light Probe stores the light that passes through empty space in your Scene. This data can then be used to light moving (dynamic) objects, which helps integrate them visually with lightmapped objects throughout your Scene. 

光源探针与光照贴图具有很多相同的优点,因为它们存储可以离线计算的光照数据。 许多计算成本是在编辑时而不是运行时发生的。 光照贴图对场景中的表面在给定纹理像素处接收到的照明进行编码时,光探针会存储穿过场景中空白空间的光。 然后,该数据可用于照亮移动的(动态)对象,这有助于在视觉上将它们与整个场景中的光照对象进行集成。

特塞尔 (Texels)

A texel, texture element, is an individual pixel in a texture map. These texels are therefore the units that make up a lightmap and encode lighting information. Your control over texels can influence the quality of your lighting, computation time for the bake, disk storage costs, and the video RAM (VRAM) cost of your lightmaps. 

纹理元素texel是纹理贴图中的单个像素。 因此,这些纹理像素是组成光照图并编码光照信息的单位。 对纹理像素的控制可能会影响照明的质量,烘烤的计算时间,磁盘存储成本以及光照贴图的视频RAM(VRAM)成本。

When you are setting up your light bakes, you need to define the resolution of your lightmaps and specify the number of texels per unit. In this case, a unit is a definition of area in Unity’s default units (most frequently a meter). You can find the Lightmap Resolution property in Unity’s Lighting window. To view how texels are laid out in your Scene, either you can, in Scene view, click the first drop-down menu, which sets the Draw Mode, and check “Show Lightmap Resolution,” or you can click Lightmap Indices in the same menu.

设置光烘焙时,需要定义光贴图的分辨率,并指定每单位的纹理像素数量。 在这种情况下,单位是Unity默认单位(最常见的是米)中的区域定义。 您可以在Unity的“光照”窗口中找到“光照贴图分辨率”属性。 要查看场景中纹理像素的布局,可以在“场景”视图中单击第一个下拉菜单,该菜单设置了“绘制模式”,然后选中“显示光照贴图分辨率”,或者可以在同一视图中单击光照贴图索引。菜单。

Baked objects will now be covered in a checkerboard overlay. This is how your texels are distributed when you bake the lights. Below you can see an example of two different settings on the same cube. The left cube has a setting of 5 and the right of 2.5. The higher the variable, the more computation that will need to be done. The lower the resolution, the less lightmap space that is required and the fewer lightmaps needed. But keep in mind that the lower the resolution, the lower the quality will be as well. Experiment to find what will work best for your project. 

现在,已烘焙的对象将被覆盖在棋盘格覆盖中。 烘烤灯时,这就是您的纹理像素的分布方式。 在下面,您可以看到同一多维数据集上两个不同设置的示例。 左侧多维数据集的设置为5,右侧为2.5。 变量越高,将需要执行的计算越多。 分辨率越低,所需的光照贴图空间就越少,所需的光照贴图就越少。 但是请记住,分辨率越低,质量也会越低。 尝试找出最适合您的项目的方法。

当你不能烤的时候,把它假 (When you can’t bake it, fake it)

Even with offline baking for most elements, you will probably want to include some real-time effects in your game, such as a character shadow. Real-time shadows are usually generated using a technique known as a “shadow map.” The cost of Scene geometry being rendered to the shadow map is proportional to the number of vertices drawn to it. So it’s important to limit the shadow-casting geometry, as well as the number of real-time shadow-casting lights. 

即使对大多数元素进行离线烘焙,您也可能希望在游戏中包含一些实时效果,例如角色阴影。 实时阴影通常是使用称为“阴影贴图”的技术生成的。 渲染到阴影贴图的场景几何体的成本与绘制到其上的顶点数量成正比。 因此,限制阴影投射几何图形以及实时阴影投射灯的数量非常重要。

To achieve a real-time effect you can place a small 3D mesh under the character and apply a blurry texture to it. This is a simple yet effective way to get a shadow without the potentially prohibitive cost of true shadow mapping. 

要获得实时效果,您可以在角色下放置一个小的3D网格,并对其应用模糊的纹理。 这是一种获得阴影的简单而有效的方法,而不会产生真正阴影映射的潜在高昂成本。

-

Whether you are setting up lighting and baking it, helping to optimize your project, or just curious about game lighting, everyone has skills to contribute to making a game look amazing. Games are a unique showcase of interdisciplinary expertise. Share what you have learned about lighting with your team – it might just brighten up their day.

无论您是设置照明并进行烘焙,帮助优化项目,还是只是对游戏照明感到好奇,每个人都有技能可以使游戏看起来更出色。 游戏是跨学科专业知识的独特展示。 与您的团队分享您在照明方面学到的知识,这可能会点亮他们的生活。

翻译自: https://blogs.unity3d.com/2020/06/15/lighting-tips-for-mobile-game-development/

This book is designed to help you create applications and content that make the best use of Unity on mobile platforms, especially those with Mali GPUs. Chapter 1 Introduction This chapter introduces the Arm Guide for Unity Developers Optimizing Mobile Gaming Graphics. Chapter 2 Optimizing applications This chapter describes how to optimize applications in Unity. Chapter 3 Profiling your application This chapter describes profiling your application. Chapter 4 Optimization lists This chapter lists a number of optimizations for your Unity application. Chapter 5 Real time 3D art best practices: Geometry This chapter highlights some key geometry optimizations for 3D assets. Geometry optimizations can make a game both more efficient, and achieve the overall goal of getting your game to perform better on mobile platforms. Chapter 6 Real time 3D art best practices: Texturing This chapter covers several texture optimizations that can help your games to run more smoothly and look better. Chapter 7 Real time 3D art best practices: Materials and shaders This chapter covers multiple different material and shader optimizations that can help your games to run more efficiently and look better. Chapter 8 Advanced graphics techniques This chapter lists a number of advanced graphics techniques that you can use. Chapter 9 Virtual Reality This chapter describes the process of adapting an application or game to run on virtual reality hardware, and some differences in the implementation of reflections in virtual reality. Chapter 10 Advanced VR graphics techniques This chapter describes various techniques that you can use to improve the graphical performance of your Virtual Reality application. Chapter 11 Vulkan This chapter describes Vulkan and how you enable it. Chapter 12 Arm Mobile Studio This chapter describes the Graphics Analyzer and the Streamline tool.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值