CN115526977A - Game picture rendering method and device - Google Patents
Game picture rendering method and device Download PDFInfo
- Publication number
- CN115526977A CN115526977A CN202211285899.7A CN202211285899A CN115526977A CN 115526977 A CN115526977 A CN 115526977A CN 202211285899 A CN202211285899 A CN 202211285899A CN 115526977 A CN115526977 A CN 115526977A
- Authority
- CN
- China
- Prior art keywords
- rendering
- information
- light
- screen
- list
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 238000009877 rendering Methods 0.000 title claims abstract description 246
- 238000000034 method Methods 0.000 title claims abstract description 56
- 239000000463 material Substances 0.000 claims abstract description 79
- 230000000694 effects Effects 0.000 claims abstract description 52
- 239000000872 buffer Substances 0.000 claims abstract description 40
- 230000003111 delayed effect Effects 0.000 claims abstract description 30
- 230000001795 light effect Effects 0.000 claims description 17
- 238000010276 construction Methods 0.000 claims description 10
- 238000005192 partition Methods 0.000 claims description 6
- 238000000605 extraction Methods 0.000 claims description 3
- 230000008569 process Effects 0.000 description 11
- 238000012545 processing Methods 0.000 description 8
- 238000004364 calculation method Methods 0.000 description 4
- 238000012986 modification Methods 0.000 description 3
- 230000004048 modification Effects 0.000 description 3
- 230000009286 beneficial effect Effects 0.000 description 2
- 238000004040 coloring Methods 0.000 description 2
- 238000010586 diagram Methods 0.000 description 2
- 238000005070 sampling Methods 0.000 description 2
- 101100257682 Homo sapiens SRARP gene Proteins 0.000 description 1
- 241001465754 Metazoa Species 0.000 description 1
- 102100029291 Steroid receptor-associated and regulated protein Human genes 0.000 description 1
- 238000011161 development Methods 0.000 description 1
- 238000005516 engineering process Methods 0.000 description 1
- 230000006870 function Effects 0.000 description 1
- 238000005286 illumination Methods 0.000 description 1
- 239000002184 metal Substances 0.000 description 1
- 239000000203 mixture Substances 0.000 description 1
- 238000012805 post-processing Methods 0.000 description 1
- 238000002360 preparation method Methods 0.000 description 1
- 230000000750 progressive effect Effects 0.000 description 1
- 238000011160 research Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T15/00—3D [Three Dimensional] image rendering
- G06T15/10—Geometric effects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T1/00—General purpose image data processing
- G06T1/20—Processor architectures; Processor configuration, e.g. pipelining
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T15/00—3D [Three Dimensional] image rendering
- G06T15/50—Lighting effects
- G06T15/506—Illumination models
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Computer Graphics (AREA)
- Geometry (AREA)
- Image Generation (AREA)
Abstract
Description
技术领域technical field
本申请涉及图像处理技术领域,尤其涉及一种游戏画面渲染方法和装置。The present application relates to the technical field of image processing, in particular to a game screen rendering method and device.
背景技术Background technique
随着游戏技术的不断发展,在手机等移动终端上运行的游戏种类也日益增多。With the continuous development of game technology, the types of games running on mobile terminals such as mobile phones are also increasing day by day.
对于一些在移动终端运行的游戏应用而言,移动终端需要对游戏应用的游戏画面进行渲染,并最终输出到移动终端的显示屏中。然而,游戏画面渲染对移动终端的显存等硬件的要求较高,而移动终端的显存等硬件性能相对较低,可能无法满足高性能的渲染要求,因此,经常会出现为了兼顾性能而影响到游戏画面渲染效果的情况出现。For some game applications running on the mobile terminal, the mobile terminal needs to render the game screen of the game application and finally output it to the display screen of the mobile terminal. However, game screen rendering has high requirements on the video memory and other hardware of the mobile terminal, and the performance of the hardware such as the video memory of the mobile terminal is relatively low, which may not be able to meet the high-performance rendering requirements. The screen rendering effect appears.
发明内容Contents of the invention
本申请提供了一种游戏画面渲染方法和装置,以兼顾渲染性能的前提下,提高游戏画面的渲染效果。The present application provides a game screen rendering method and device to improve the rendering effect of the game screen on the premise of taking into account the rendering performance.
一方面,本申请提供了一种游戏画面渲染方法,应用于移动终端,包括:On the one hand, the present application provides a game screen rendering method applied to a mobile terminal, including:
获得游戏中待渲染的画面数据,所述画面数据包括:游戏画面中光源的光源数据和至少一个非透明的对象的渲染属性信息;Obtaining picture data to be rendered in the game, the picture data including: light source data of light sources in the game picture and rendering attribute information of at least one non-transparent object;
基于屏幕划分出的多个第一分块以及所述光源数据,利用灯光剔除算法,构建各所述第一分块的第一灯光列表;Constructing a first light list for each of the first blocks based on a plurality of first blocks divided by the screen and the light source data, using a light culling algorithm;
从所述对象的渲染属性信息中提取出所述对象的材质信息;extracting material information of the object from the rendering attribute information of the object;
如果基于所述对象的材质信息确定出所述对象为第一类型对象,从所述对象的渲染属性信息中提取出所述对象的深度信息和法线信息,基于各所述第一分块的第一灯光列表以及所述对象的深度信息、法线信息和材质信息,采用前向渲染方式渲染所述对象;If it is determined based on the material information of the object that the object is a first-type object, extract the depth information and normal line information of the object from the rendering attribute information of the object, and based on each of the first blocks The first light list and the depth information, normal information, and material information of the object, and render the object in a forward rendering manner;
如果基于所述对象的材质信息确定出所述对象为第二类型对象,将所述对象的渲染属性信息缓存到多个几何缓冲区,基于各所述第一分块的第一灯光列表以及所述多个几何缓冲区内缓存的信息,采用延迟渲染方式渲染所述对象。If it is determined based on the material information of the object that the object is an object of the second type, cache the rendering attribute information of the object in multiple geometry buffers, and based on the first light list of each of the first blocks and the The information cached in the plurality of geometry buffers is used to render the object in a deferred rendering manner.
在一种可能的实现方式中,在所述构建各所述第一分块的第一灯光列表之前,还包括:In a possible implementation manner, before constructing the first light list of each of the first blocks, the method further includes:
确定所述移动终端中图形处理器的类型;determining the type of graphics processor in the mobile terminal;
按照配置的不同类型的图形处理器适合的灯光剔除算法,确定所述移动终端中的图形处理器适合的目标灯光剔除算法;According to the light culling algorithm suitable for different types of graphics processors configured, determine the target light culling algorithm suitable for the graphics processor in the mobile terminal;
所述基于屏幕划分出的多个第一分块以及所述光源数据,利用灯光剔除算法,构建各所述第一分块的第一灯光列表,包括:The plurality of first blocks divided based on the screen and the light source data are constructed using a light culling algorithm to construct a first light list for each of the first blocks, including:
基于屏幕划分出的多个第一分块以及所述光源数据,在所述移动终端的图形处理器中利用所述目标灯光剔除算法,构建各所述第一分块的第一灯光列表。Based on the plurality of first blocks divided by the screen and the light source data, the graphics processor of the mobile terminal utilizes the target light culling algorithm to construct a first light list for each of the first blocks.
在又一种可能的实现方式中,所述基于各所述第一分块的第一灯光列表以及所述多个几何缓冲区内缓存的信息,采用延迟渲染方式渲染所述对象,包括:In yet another possible implementation manner, the rendering of the object in a deferred rendering manner based on the first light list of each of the first blocks and the information cached in the plurality of geometry buffers includes:
基于多套延迟渲染代码各自适合的对象材质,结合所述对象的材质信息,确定所述对象适用的目标延迟渲染代码,所述目标延迟渲染代码属于所述多套延迟渲染代码;Based on the object materials suitable for each of the multiple sets of deferred rendering codes, combined with the material information of the object, determine the target deferred rendering code applicable to the object, and the target deferred rendering code belongs to the multiple sets of deferred rendering codes;
基于各所述第一分块的第一灯光列表以及所述多个几何缓冲区内缓存的信息,调用所述目标延迟渲染代码执行所述对象的延迟渲染。Based on the first light list of each of the first blocks and the information cached in the plurality of geometry buffers, the target deferred rendering code is called to perform deferred rendering of the object.
在又一种可能的实现方式中,所述画面数据还包括:所述游戏画面中各像素点对应的用于体积雾渲染的体积雾数据;In yet another possible implementation manner, the picture data further includes: volumetric fog data used for volumetric fog rendering corresponding to each pixel in the game picture;
在所述获得游戏中待渲染的画面数据之后,还包括:After obtaining the picture data to be rendered in the game, it also includes:
基于屏幕划分出的多个第二分块以及所述光源数据,利用灯光剔除算法,构建各所述第二分块的第二灯光列表,所述第二分块的面积大于所述第一分块的面积;Based on the plurality of second blocks divided by the screen and the light source data, a light culling algorithm is used to construct a second light list for each of the second blocks, and the area of the second block is larger than that of the first block. block area;
基于游戏画面中各像素点的体积雾数据,生成初始体积纹理图像,所述初始体积纹理图像中各像素点关联有体积雾数据;Based on the volume fog data of each pixel in the game screen, an initial volume texture image is generated, and each pixel in the initial volume texture image is associated with volume fog data;
基于所述初始纹理图像、所述第二灯光列表以及所述光源数据,确定屏幕的体积光效果。Based on the initial texture image, the second light list and the light source data, determine a volumetric light effect of the screen.
在又一种可能的实现方式中,还包括:In yet another possible implementation, it also includes:
基于所述游戏画面中各像素点的体积雾数据,确定屏幕的体积雾颜色;Determine the volumetric fog color of the screen based on the volumetric fog data of each pixel in the game screen;
在所述屏幕的体积光效果上叠加所述体积雾颜色。Overlays the volumetric fog color on top of the screen's volumetric light effect.
在又一种可能的实现方式中,画面数据还包括:所述游戏画面的深度信息和法线信息;In yet another possible implementation manner, the picture data further includes: depth information and normal line information of the game picture;
在所述确定屏幕的体积光效果之前,还包括:Before determining the volumetric light effect of the screen, it also includes:
基于所述游戏画面的深度信息,构建多张不同分辨率的深度图;Constructing a plurality of depth maps with different resolutions based on the depth information of the game screen;
结合所述多张深度图以及所述游戏画面的法线信息,确定屏幕的空间反射效果;Combining the multiple depth maps and the normal information of the game screen, determine the spatial reflection effect of the screen;
基于所述游戏画面的深度信息,确定屏幕中各像素点的环境光遮蔽效果。Based on the depth information of the game screen, the ambient light shading effect of each pixel in the screen is determined.
在又一种可能的实现方式中,所述画面数据还包括:游戏画面中天空的天空数据以及至少一个透明对象的渲染属性信息;In yet another possible implementation manner, the picture data further includes: sky data of the sky in the game picture and rendering attribute information of at least one transparent object;
所述方法还包括:The method also includes:
基于所述天空数据渲染所述游戏画面的天空;rendering the sky of the game screen based on the sky data;
基于所述透明对象的渲染属性信息渲染所述透明对象。The transparent object is rendered based on the rendering attribute information of the transparent object.
又一方面,本申请还提供了一种游戏画面渲染装置,应用于移动终端,包括:In yet another aspect, the present application also provides a game screen rendering device applied to a mobile terminal, including:
数据获得单元,用于获得游戏中待渲染的画面数据,所述画面数据包括:游戏画面中光源的光源数据和至少一个非透明的对象的渲染属性信息;A data obtaining unit, configured to obtain picture data to be rendered in the game, the picture data including: light source data of light sources in the game picture and rendering attribute information of at least one non-transparent object;
第一构建单元,用于基于屏幕划分出的多个第一分块以及所述光源数据,利用灯光剔除算法,构建各所述第一分块的第一灯光列表;The first construction unit is configured to construct a first light list for each of the first blocks based on a plurality of first blocks divided by the screen and the light source data by using a light culling algorithm;
材质提取单元,用于从所述对象的渲染属性信息中提取出所述对象的材质信息;a material extraction unit, configured to extract material information of the object from the rendering attribute information of the object;
第一对象渲染单元,用于如果基于所述对象的材质信息确定出所述对象为第一类型对象,从所述对象的渲染属性信息中提取出所述对象的深度信息和法线信息,基于各所述第一分块的第一灯光列表以及所述对象的深度信息、法线信息和材质信息,采用前向渲染方式渲染所述对象;The first object rendering unit is configured to extract the depth information and normal line information of the object from the rendering attribute information of the object if it is determined based on the material information of the object that the object is a first type object, based on The first light list of each of the first blocks and the depth information, normal information and material information of the object are used to render the object in a forward rendering manner;
第二对象渲染单元,用于如果基于所述对象的材质信息确定出所述对象为第二类型对象,将所述对象的渲染属性信息缓存到多个几何缓冲区,基于各所述第一分块的第一灯光列表以及所述多个几何缓冲区内缓存的信息,采用延迟渲染方式渲染所述对象。The second object rendering unit is configured to cache the rendering attribute information of the object in a plurality of geometry buffers if it is determined that the object is a second type of object based on the material information of the object, and based on each of the first points The first light list of the block and the information cached in the plurality of geometry buffers are used to render the object in a deferred rendering manner.
在一种可能的实现方式中,还包括:In a possible implementation, it also includes:
类型确定单元,用于第一构建单元构建各所述第一分块的第一灯光列表之前,确定所述移动终端中图形处理器的类型;a type determination unit, configured to determine the type of the graphics processor in the mobile terminal before the first construction unit constructs the first light list of each of the first blocks;
剔除算法确定单元,用于按照配置的不同类型的图形处理器适合的灯光剔除算法,确定所述移动终端中的图形处理器适合的目标灯光剔除算法;The culling algorithm determination unit is configured to determine the target light culling algorithm suitable for the graphics processor in the mobile terminal according to the light culling algorithm suitable for different types of graphics processors configured;
所述第一构建单元,包括:The first building unit includes:
第一构建子单元,用于基于屏幕划分出的多个第一分块以及所述光源数据,在所述移动终端的图形处理器中利用所述目标灯光剔除算法,构建各所述第一分块的第一灯光列表。The first construction subunit is configured to use the target light culling algorithm in the graphics processor of the mobile terminal to construct each of the first sub-blocks based on the plurality of first sub-blocks divided by the screen and the light source data. List of first lights for the block.
在又一种可能的实现方式中,所述第二对象渲染单元,包括:In yet another possible implementation manner, the second object rendering unit includes:
代码确定单元,用于基于多套延迟渲染代码各自适合的对象材质,结合所述对象的材质信息,确定所述对象适用的目标延迟渲染代码,所述目标延迟渲染代码属于所述多套延迟渲染代码;A code determining unit, configured to determine a target delayed rendering code applicable to the object based on the object material suitable for each of the multiple sets of delayed rendering codes, in combination with the material information of the object, and the target delayed rendering code belongs to the multiple sets of delayed rendering code;
渲染代码调用单元,用于基于各所述第一分块的第一灯光列表以及所述多个几何缓冲区内缓存的信息,调用所述目标延迟渲染代码执行所述对象的延迟渲染。The rendering code calling unit is configured to call the target deferred rendering code to perform deferred rendering of the object based on the first light list of each first block and the information cached in the plurality of geometry buffers.
由以上可知,本申请在获得游戏中待渲染的画面数据之后,会基于屏幕划分出的多个分块以及画面数据中的光源数据,利用灯光剔除算法,构建各分块的灯光列表。在此基础上,对于待渲染的游戏画面中的非透明的对象,如果基于对象的材质信息确定出该对象为适合前向渲染的第一类型对象,会结合灯光列表采用前向渲染方式渲染该对象;如果基于对象的材质信息确定出对象为适合延迟渲染的第二类型对象,会结合灯光列表采用延迟渲染方式渲染该对象,从而实现了结合不同对象的渲染需求合理选择不同的渲染方式,能够有效保证游戏画面中对象的渲染效果;而且,相对仅单一采用基于分块的前向渲染或者延迟渲染渲染对所有对象进行渲染,本申请在移动终端中采用分块的前向渲染和延迟渲染这两种渲染管线对不同对象进行渲染,有效利用两种渲染方式各自的优势,既可以兼顾渲染性能,又有利于保证游戏画面的渲染效果。As can be seen from the above, after the application obtains the image data to be rendered in the game, it will use the light culling algorithm to construct the light list of each block based on the multiple blocks divided by the screen and the light source data in the image data. On this basis, for a non-transparent object in the game screen to be rendered, if it is determined based on the material information of the object that the object is the first type of object suitable for forward rendering, the forward rendering method will be used to render the object in combination with the light list. Object; if the object is determined to be the second type of object suitable for deferred rendering based on the material information of the object, the object will be rendered in the deferred rendering mode combined with the light list, so as to realize the reasonable selection of different rendering methods according to the rendering requirements of different objects, and can Effectively guarantee the rendering effect of objects in the game screen; moreover, compared with only using block-based forward rendering or delayed rendering to render all objects, this application uses block-based forward rendering and delayed rendering in mobile terminals. The two rendering pipelines render different objects, effectively using the respective advantages of the two rendering methods, which can not only take into account the rendering performance, but also help ensure the rendering effect of the game screen.
附图说明Description of drawings
为了更清楚地说明本申请实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据提供的附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application, the accompanying drawings that need to be used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings in the following description are only the embodiments of the present application. For Those of ordinary skill in the art can also obtain other drawings based on the provided drawings without making creative efforts.
图1示出了本申请实施例提供的游戏画面渲染方法的一种流程示意图;FIG. 1 shows a schematic flow chart of a game screen rendering method provided by an embodiment of the present application;
图2示出了本申请实施例提供的游戏画面渲染方法的又一种流程示意图;Fig. 2 shows another schematic flow chart of the game screen rendering method provided by the embodiment of the present application;
图3示出了本申请实施例提供的游戏画面渲染装置的一种组成结构示意图。FIG. 3 shows a schematic diagram of the composition and structure of the game screen rendering device provided by the embodiment of the present application.
具体实施方式detailed description
下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有付出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the application with reference to the drawings in the embodiments of the application. Apparently, the described embodiments are only some of the embodiments of the application, not all of them. Based on the embodiments in this application, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the scope of protection of this application.
如图1,其示出了本申请实施例提供的游戏画面渲染方法的一种流程示意图,本实施例的方法应用于移动终端,该移动终端可以为手机或者平板电脑等,对此不加限制。As shown in Figure 1, it shows a schematic flow chart of the game screen rendering method provided by the embodiment of the present application. The method of this embodiment is applied to a mobile terminal, and the mobile terminal can be a mobile phone or a tablet computer, etc., without limitation .
本实施例的方法可以包括:The method of this embodiment may include:
S101,获得游戏中待渲染的画面数据。S101. Obtain image data to be rendered in the game.
可以理解的是,待渲染的画面数据是指待输出的游戏画面的画面数据。该画面数据可以包括渲染出游戏画面所需的各种数据。It can be understood that the picture data to be rendered refers to the picture data of the game picture to be output. The picture data may include various data required for rendering a game picture.
如,该游戏画面的画面数据可以是游戏模型的模型数据,还可以是包含游戏场景的相关信息等,对此不加限制。For example, the picture data of the game picture may be the model data of the game model, and may also include relevant information of the game scene, etc., without limitation.
可以理解的是,游戏画面中包含游戏中的人物、动物或者物品等对象,因此,该画面数据至少包括游戏中对象的渲染属性信息。该对象的渲染属性信息为渲染该对象所需的基础信息,如对象的渲染属性信息可以包括对象的类型、名称、深度信息、法线信息以及材质信息等信息中的部分或者全部,对此不加限制。It can be understood that the game screen contains objects such as characters, animals or items in the game, so the screen data at least includes rendering attribute information of the objects in the game. The rendering attribute information of the object is the basic information required for rendering the object. For example, the rendering attribute information of the object may include some or all of the object's type, name, depth information, normal information, and material information. Add restrictions.
可以理解的是,渲染游戏画面中透明对象之外的非透明对象需要考虑的因素较多,基于此,本实施例主要对游戏画面中非透明的对象进行介绍。相应的,本实施例中,画面数据中至少包括游戏画面中至少一个非透明的对象的渲染属性信息。非透明的对象的渲染属性信息包括:对象的材质信息,如,对象的材质标识等能够表征对象材质的相关信息。当然,该渲染属性信息还可以包括上面提到的其他信息,对此不加限制。It can be understood that there are many factors to be considered in rendering non-transparent objects other than transparent objects in the game screen. Based on this, this embodiment mainly introduces the non-transparent objects in the game screen. Correspondingly, in this embodiment, the screen data at least includes rendering attribute information of at least one non-transparent object in the game screen. The rendering attribute information of the non-transparent object includes: material information of the object, such as material identification of the object and other relevant information that can characterize the material of the object. Of course, the rendering attribute information may also include other information mentioned above, without limitation.
另外,画面数据还包括:游戏画面中光源的光源数据,如光源的数量,每种光源的种类以及位置等等信息,对此不加限制。In addition, the picture data also includes: light source data of the light sources in the game picture, such as information such as the number of light sources, the type and position of each light source, etc., without limitation.
当然,画面数据中还包括游戏画面对应场景的其他信息,在此不再赘述。Of course, the screen data also includes other information about the scene corresponding to the game screen, which will not be repeated here.
S102,基于屏幕划分出的多个第一分块以及光源数据,利用灯光剔除算法,构建各第一分块的第一灯光列表。S102. Based on the plurality of first blocks divided by the screen and the light source data, a light culling algorithm is used to construct a first light list of each first block.
屏幕划分出的分块是从逻辑上将屏幕划分得到的多个分块(tile)。每个分块也称为瓦片,是指屏幕从逻辑上进行划分得到的各个小块。The partitions divided by the screen are a plurality of partitions (tiles) obtained by logically dividing the screen. Each block is also called a tile, which refers to each small block obtained by logically dividing the screen.
在本申请中,为了便于区分,将本实施例中渲染非透明的对象所涉及到分块称为第一分块,相应的,将针对第一分块构建的灯光列表称为第一灯光列表。In this application, for the convenience of distinction, the block involved in rendering non-transparent objects in this embodiment is called the first block, and correspondingly, the light list constructed for the first block is called the first light list .
其中,每个第一分块的第一灯光列表可以包括对该第一分块产生影响的光源的灯光信息,灯光信息可以为光源的光源数据中的部分或者全部信息。Wherein, the first light list of each first block may include light information of light sources that affect the first block, and the light information may be part or all of the light source data of the light sources.
可以理解的是,利用灯光剔除算法构建各第一分块的第一灯光列表可以不再盲目对每一个光源(即灯光)均执行一次渲染通道的着色等处理,只需要遍历哪些对游戏场景产生影响的灯光,并将这些存在影响的灯光的效果叠加到各个分块上,从而可以减少着色过程中需要处理的灯光数量,降低数据处理量。It is understandable that using the light culling algorithm to construct the first light list of each first block can no longer blindly perform coloring and other processing on each light source (that is, light) in the rendering pass, and only need to traverse which effects on the game scene. Influenced lights, and superimpose the effects of these affected lights on each block, which can reduce the number of lights that need to be processed in the shading process and reduce the amount of data processing.
在本申请中,灯光剔除算法可以有多种可能,如,灯光剔除算法可以为精细删减的分块光照(Fine Prued Tiled Light,FPTL)算法,或者是,基于簇(Cluster)的灯光剔除算法等,对此不加限制。In this application, there are many possibilities for the light culling algorithm. For example, the light culling algorithm can be a Fine Prued Tiled Light (FPTL) algorithm, or a cluster-based light culling algorithm. Etc. No restrictions on this.
可以理解的是,相对于图形处理器(Graphics Processing Unit,GPU),在中央处理器(central processing unit,CPU)中完成灯光剔除以及灯光列表的构建,并行化程度较低,效率相对较低。基于此,本申请中可以在移动终端的图形处理器(GraphicsProcessing Unit,GPU)中执行该运行灯光剔除算法并构建各第一分块的第一灯光列表。It can be understood that, compared with a Graphics Processing Unit (GPU), light culling and light list construction are completed in a central processing unit (CPU), and the degree of parallelization is relatively low, and the efficiency is relatively low. Based on this, in the present application, the running light culling algorithm may be executed in a graphics processing unit (Graphics Processing Unit, GPU) of the mobile terminal and a first light list of each first block may be constructed.
经过本申请的发明人研究发现:在构建灯光列表过程中,需要构建用于着色器的缓冲器所需的多个线程和线程组,这就需要考虑GPU作为并行处理器与GPU处理复杂的数据计算的能力之间的兼容性问题。The inventors of this application found that in the process of building the light list, multiple threads and thread groups needed to build the buffer for the shader need to be considered as a parallel processor and GPU to process complex data Compatibility issues between computing capabilities.
而发明人通过大量研究进一步发现:不同GPU适合的灯光剔除算法也会有所不同,通过选择合理的灯光剔除算法,有利于减少移动终端对于复杂的数据计算与作为并行处理器之间的不兼容问题。在此基础上,本申请通过大量实现确定出不同类型的GPU所适合的灯光剔除算法。The inventor further found through a lot of research that different GPUs are suitable for different lighting culling algorithms. By choosing a reasonable lighting culling algorithm, it is beneficial to reduce the incompatibility between mobile terminals for complex data calculations and parallel processors. question. On this basis, the present application determines suitable light culling algorithms for different types of GPUs through a large number of implementations.
例如,对于厂家A的GPU更适合FPTL算法,而厂家B的GPU可能更适合基于Cluster算法来进行灯光剔除。For example, the GPU of manufacturer A is more suitable for the FPTL algorithm, while the GPU of manufacturer B may be more suitable for light culling based on the Cluster algorithm.
在此基础上,本申请可以先确定移动终端中图形处理器的类型。然后,按照配置的不同类型的图形处理器适合的灯光剔除算法,确定移动终端中的图形处理器适合的目标灯光剔除算法。相应的,基于屏幕划分出的多个第一分块以及所述光源数据,可以在移动终端的GPU中利用该目标灯光剔除算法,构建各第一分块的第一灯光列表。On this basis, the present application can first determine the type of graphics processor in the mobile terminal. Then, a target light culling algorithm suitable for the graphics processor in the mobile terminal is determined according to the suitable light culling algorithm for different types of configured graphics processors. Correspondingly, based on the plurality of first blocks divided by the screen and the light source data, the target light culling algorithm may be used in the GPU of the mobile terminal to construct a first light list of each first block.
S103,针对待渲染的每个非透明的对象,从对象的渲染属性信息中提取出对象的材质信息。S103. For each non-transparent object to be rendered, extract material information of the object from rendering attribute information of the object.
其中,对象的材质信息可以包括表征对象的材质的相关信息,如对象的材质信息可以为对象的材质标识,如对象的材质的名称或者编号等唯一标识。当然,该对象的材质信息还可以包括:对象的材质特征等信息,对此不加限制。The material information of the object may include relevant information representing the material of the object, for example, the material information of the object may be a material identifier of the object, such as a unique identifier such as a name or number of the material of the object. Of course, the material information of the object may also include information such as material characteristics of the object, without limitation.
S104,如果基于对象的材质信息确定出对象为第一类型对象,从对象的渲染属性信息中提取出对象的深度信息和法线信息,基于各第一分块的第一灯光列表以及对象的深度信息、法线信息和材质信息,采用前向渲染方式渲染对象。S104, if it is determined based on the material information of the object that the object is the first type of object, extract the depth information and normal line information of the object from the rendering attribute information of the object, based on the first light list of each first block and the depth of the object information, normal information, and material information, and use forward rendering to render the object.
在本申请中,考虑到对象的材质不同时,对象渲染所需实现的达到的效果以及一些特殊要求也会有所不同,因此,不同对象适合的渲染方式自然也就有所不同。基于此,在本申请中为了能够兼顾硬件性能与渲染效果,本申请需要结合对象的材质合理确定渲染对象的渲染方式。与现有仅仅部署单个渲染方式对应的渲染管线不同,本申请中可以采用延迟渲染与前向渲染两种渲染方式对应的渲染管线进行并行渲染。In this application, it is considered that when the material of the object is different, the effect to be achieved and some special requirements for object rendering will also be different. Therefore, the suitable rendering methods for different objects are naturally different. Based on this, in order to take into account both hardware performance and rendering effect in this application, this application needs to reasonably determine the rendering method of the rendering object in combination with the material of the object. Different from existing rendering pipelines that only deploy a single rendering mode, in this application, rendering pipelines corresponding to two rendering modes, deferred rendering and forward rendering, can be used for parallel rendering.
在此基础上,本申请可以预先确定出不同材质的对象适合的渲染方式。在此基础上,对于待渲染的非透明的对象而言,基于该对象的材质信息可以确定对象的类型。其中,第一类型对象为适合前向渲染的对象,而第二类型对象为适合延迟渲染的对象。On this basis, the present application can predetermine suitable rendering methods for objects of different materials. On this basis, for a non-transparent object to be rendered, the type of the object can be determined based on the material information of the object. Wherein, the first type object is an object suitable for forward rendering, and the second type object is an object suitable for delayed rendering.
如果对象的材质信息表征该对象为第一类型对象,那么可以基于该对象的深度信息、法线信息和材质信息,结合各第一分块的第一灯光列表对该对象进行前向渲染。可以理解的是,对第一类型对象的渲染本质上基于tile的前向渲染,该种渲染方式是结合了前向渲染和基于tile灯光剔除以减少着色过程中灯光数量的一种渲染技术,由于通过灯光剔除可以减少了每个对象所需迭代计算的光照,因此,该种渲染方式既可以保证渲染效果,又可以提升性能。If the material information of the object indicates that the object is a first-type object, forward rendering of the object may be performed based on the depth information, normal information, and material information of the object in combination with the first light list of each first block. It can be understood that the rendering of the first type of objects is essentially based on tile forward rendering, which is a rendering technique that combines forward rendering and tile-based light culling to reduce the number of lights in the coloring process. Through light culling, the lighting required for iterative calculation of each object can be reduced. Therefore, this rendering method can not only guarantee the rendering effect, but also improve performance.
可以理解的是,在提取出第一类型对象的深度信息和法线信息之后,本申请向将该对象的深度信息、法线信息和材质信息缓存到待渲染的游戏画面关联的缓存区,以便在需要渲染该对象时,基于这些信息进行前向渲染。It can be understood that after extracting the depth information and normal line information of the first type of object, the present application caches the depth information, normal line information and material information of the object in the buffer area associated with the game screen to be rendered, so that When the object needs to be rendered, forward rendering is performed based on this information.
S105,如果基于对象的材质信息确定出对象为第二类型对象,将对象的渲染属性信息缓存到多个几何缓冲区,基于各第一分块的第一灯光列表以及多个几何缓冲区内缓存的信息,采用延迟渲染方式渲染对象。S105, if it is determined based on the material information of the object that the object is a second type object, cache the rendering attribute information of the object in multiple geometry buffers, based on the first light list of each first block and cache in multiple geometry buffers information, the object is rendered in deferred rendering.
其中,不同几何缓冲区(Geometry Buffer,G-Buffer)存储该对象的不同种渲染属性信息。Wherein, different geometry buffers (Geometry Buffer, G-Buffer) store different types of rendering attribute information of the object.
如,在一种可能的实现方式中,对于第二类型对象,本申请可以构建四个几何缓冲区,分别为第一几何缓冲区、第二几何缓冲区、第三几何缓冲区和第四几何缓冲区。在第一几何缓冲区缓存有:对象的基色和镜面遮挡信息;第二几何缓冲区缓存该对象对应的法线信息以及粗糙度信息。在第三几何缓冲区缓存对象的金属信息、渲染层信息、阴影遮挡罩信息和材质标识码的信息;第四几何缓冲区缓存对象的烘焙漫反射光照信息或者自发光颜色信息。For example, in a possible implementation, for the second type of object, the application can construct four geometry buffers, namely the first geometry buffer, the second geometry buffer, the third geometry buffer and the fourth geometry buffer buffer. The first geometry buffer cache contains: the base color and specular occlusion information of the object; the second geometry buffer caches the normal information and roughness information corresponding to the object. The metal information, rendering layer information, shadow mask information and material identification code information of the object are cached in the third geometry buffer; the baked diffuse lighting information or self-illumination color information of the object is cached in the fourth geometry buffer.
其中,这四个几何缓存区中缓存的信息都属于该对象的渲染属性信息。Wherein, the information cached in the four geometry buffer areas all belong to the rendering attribute information of the object.
可以理解的是,如果对象的材质信息表征该对象为第二类型对象,本申请可以基于各第一分块tile的灯光列表的延迟渲染。由于延迟渲染能有效减少光照计算,可以大大提升对象的渲染性能,而结合tile的灯光列表的延迟渲染能更进一步减少光照计算,且每次仅仅针对一个分块进行计算,可以减少无效输入与输出。It can be understood that, if the material information of the object indicates that the object is a second type object, the present application may be based on deferred rendering of the light list of each first tile. Since deferred rendering can effectively reduce lighting calculations, it can greatly improve the rendering performance of objects. Delayed rendering combined with tile light lists can further reduce lighting calculations, and only calculate for one block at a time, which can reduce invalid input and output. .
基于此,对于一些渲染要求不高或者不需要特殊渲染要求的材质的对象,本申请采用延迟渲染进行渲染而非前向渲染,有利于提升渲染性能。Based on this, for some objects that do not have high rendering requirements or do not require materials with special rendering requirements, this application uses deferred rendering instead of forward rendering for rendering, which is beneficial to improve rendering performance.
可以理解的是,对于第二类型对象而言,不同对象的材质也会有所差别,而不同材质的对象适合延迟渲染过程也会有所差别。基于此,为了能够更为更为高效且合理地进行对象的延迟渲染,本申请还可以预先配置多套延迟渲染代码,并预先配置多套延迟渲染代码各自适合的至少一种对象材质。It can be understood that, for the second type of objects, the materials of different objects are also different, and the objects of different materials are suitable for the deferred rendering process. Based on this, in order to perform deferred rendering of objects more efficiently and reasonably, the present application may also pre-configure multiple sets of deferred rendering codes, and pre-configure at least one object material suitable for each of the multiple sets of deferred rendering codes.
在此基础上,针对属于第二类型对象的每个对象,本申请可以先基于多套延迟渲染代码各自适合的对象材质,结合对象的材质信息,确定该对象适用的目标延迟渲染代码。该目标延迟渲染代码属于该多套延迟渲染代码。相应的,可以基于各第一分块的第一灯光列表以及多个几何缓冲区内缓存的信息,调用该目标延迟渲染代码执行该对象的延迟渲染。On this basis, for each object belonging to the second type of object, the application can firstly determine the target deferred rendering code applicable to the object based on the object material suitable for each set of deferred rendering codes, combined with the material information of the object. The target deferred rendering code belongs to the multiple sets of deferred rendering codes. Correspondingly, based on the first light list of each first block and the information cached in multiple geometry buffers, the target deferred rendering code can be called to perform deferred rendering of the object.
由以上可知,本申请在获得游戏中待渲染的画面数据之后,会基于屏幕划分出的多个分块以及画面数据中的光源数据,利用灯光剔除算法,构建各分块的灯光列表。在此基础上,对于待渲染的游戏画面中的非透明的对象,如果基于对象的材质信息确定出该对象为适合前向渲染的第一类型对象,会结合灯光列表采用前向渲染方式渲染该对象;如果基于对象的材质信息确定出对象为适合延迟渲染的第二类型对象,会结合灯光列表采用延迟渲染方式渲染该对象,从而实现了结合不同对象的渲染需求合理选择不同的渲染方式,能够有效保证游戏画面中对象的渲染效果;而且,相对仅单一采用基于分块的前向渲染或者延迟渲染渲染对所有对象进行渲染,本申请在移动终端中采用分块的前向渲染和延迟渲染这两种渲染管线并行对不同对象进行渲染,有效利用两种渲染方式各自的优势,从而可以兼顾渲染性能与提升游戏画面的渲染效果。As can be seen from the above, after the application obtains the image data to be rendered in the game, it will use the light culling algorithm to construct the light list of each block based on the multiple blocks divided by the screen and the light source data in the image data. On this basis, for a non-transparent object in the game screen to be rendered, if it is determined based on the material information of the object that the object is the first type of object suitable for forward rendering, the forward rendering method will be used to render the object in combination with the light list. Object; if the object is determined to be the second type of object suitable for deferred rendering based on the material information of the object, the object will be rendered in the deferred rendering mode combined with the light list, so as to realize the reasonable selection of different rendering methods according to the rendering requirements of different objects, and can Effectively guarantee the rendering effect of objects in the game screen; moreover, compared with only using block-based forward rendering or delayed rendering to render all objects, this application uses block-based forward rendering and delayed rendering in mobile terminals. The two rendering pipelines render different objects in parallel, effectively utilizing the respective advantages of the two rendering methods, so as to take into account rendering performance and improve the rendering effect of the game screen.
可以理解的是,游戏画面中除了非透明的对象之外,还可能会涉及到一些透明对象。基于此,画面数据中还包括透明对象的渲染属性信息。相应的,本申请中在渲染完非透明的对象之后,还可以包括:基于透明对象的渲染属性渲染该透明对象。It is understandable that in addition to non-transparent objects, some transparent objects may also be involved in the game screen. Based on this, the rendering attribute information of the transparent object is also included in the picture data. Correspondingly, in this application, after rendering the non-transparent object, it may further include: rendering the transparent object based on the rendering attribute of the transparent object.
可以理解的是,游戏画面中除了物品以及人物等对象之外,还涉及到一些天空以及背景等游戏场景环境的渲染。It is understandable that in addition to objects such as items and characters, the game screen also involves the rendering of some game scene environments such as the sky and the background.
基于此,本申请还可以涉及到画面数据中还可以包括体积雾渲染所需的体积雾数据,相应的,本申请中游戏画面的渲染还可以包括屏幕的体积雾效果等渲染。进一步的,游戏画面的渲染还可以包括屏幕的空间反射效果以及环境光遮蔽效果等渲染。Based on this, this application may also involve that the screen data may also include volumetric fog data required for volumetric fog rendering. Correspondingly, the rendering of game screens in this application may also include rendering such as volumetric fog effects on the screen. Further, the rendering of the game screen may also include the rendering of the spatial reflection effect of the screen and the ambient light occlusion effect.
下面结合一种实现方式对本申请的游戏画面的渲染进行介绍。The rendering of the game screen of the present application will be introduced below in conjunction with an implementation manner.
如图2所示,其示出了本申请实施例提供游戏画面渲染方法的又一种流程示意图,本实施例的方法可以包括:As shown in Figure 2, it shows another schematic flow chart of the game screen rendering method provided by the embodiment of the present application. The method of this embodiment may include:
S201,获得游戏中待渲染的画面数据。S201. Obtain image data to be rendered in the game.
其中,画面数据包括游戏画面中光源的光源数据、游戏画面中透明对象和不透明的对象的渲染属性信息。Wherein, the picture data includes light source data of light sources in the game picture, rendering attribute information of transparent objects and opaque objects in the game picture.
该画面数据还包括:游戏画面中各像素点对应的用于体积雾渲染的体积雾数据、游戏画面的深度信息、法线信息以及游戏画面中天空的天空数据。The picture data also includes: volumetric fog data for volumetric fog rendering corresponding to each pixel in the game picture, depth information, normal information of the game picture, and sky data of the sky in the game picture.
其中,体积雾数据是向游戏画面中渲染体积雾所需的相关数据。天空数据是指完成游戏画面对应场景中天空所需的相关数据,如天空中白云大小以及数量,天空颜色模式等等数据,对此不加限制。Among them, the volumetric fog data is related data required to render the volumetric fog to the game screen. The sky data refers to the relevant data required to complete the sky in the scene corresponding to the game screen, such as the size and number of white clouds in the sky, the color mode of the sky, etc., without limitation.
S202,从对象的渲染属性信息中提取出对象的材质信息。S202. Extract material information of the object from the rendering attribute information of the object.
S203,如果对象的材质信息表征对象属于非透明的第一类型对象,从对象的渲染属性信息中提取对象的深度信息和法线信息,缓存对象的深度信息、法线信息和材质信息。S203, if the material information of the object indicates that the object belongs to the non-transparent first type object, extract the depth information and normal line information of the object from the rendering attribute information of the object, and cache the depth information, normal line information and material information of the object.
S204,如果对象的材质信息表征对象属于非透明的第二类型对象,将对象的渲染属性信息缓存到多个几何缓存区。S204. If the material information of the object indicates that the object belongs to a non-transparent second type object, cache the rendering attribute information of the object in multiple geometry buffer areas.
需要说明的是,本实施例是以提取出对象的材质信息后,基于对象的材质信息确定出对象是否为透明对象为例说明。但是如果通过其他方式确定出对象是否为透明对象也同样适用于本实施例。It should be noted that, in this embodiment, after the material information of the object is extracted, it is described as an example to determine whether the object is a transparent object based on the material information of the object. However, it is also applicable to this embodiment if it is determined whether the object is a transparent object through other methods.
以上步骤S203和S204可以参见前面实施例的相关介绍,在此不再赘述。For the above steps S203 and S204, reference may be made to the relevant introduction of the previous embodiments, and details are not repeated here.
S205,基于游戏画面的深度信息,构建多张不同分辨率的深度图。S205. Construct multiple depth maps with different resolutions based on the depth information of the game screen.
其中,此处构建的深度图可以有多种可能,对此不加限制。Wherein, the depth map constructed here may have many possibilities, which is not limited.
如,在一种可能的实现方式中,基于游戏画面的深度信息,生成至少一张分层Z剔除(Hierarchical Z-buffer,HIZ)深度图。For example, in a possible implementation manner, at least one Hierarchical Z-buffer (HIZ) depth map is generated based on the depth information of the game screen.
在本实施例中,构建深度图的目的是为了后续确定屏幕的空间反射效果和环境光遮挡效果,如果游戏中未开启这两种效果,那么也可以不执行该步骤S205。In this embodiment, the purpose of constructing the depth map is to subsequently determine the spatial reflection effect and ambient light occlusion effect of the screen. If these two effects are not enabled in the game, step S205 may not be performed.
S206,基于屏幕划分出的多个第一分块以及光源数据,利用灯光剔除算法,构建各第一分块的第一灯光列表。S206. Based on the plurality of first blocks divided by the screen and the light source data, a light culling algorithm is used to construct a first light list of each first block.
该步骤S206可以参见前面实施例的相关介绍,在此不再赘述。For this step S206, reference may be made to the relevant introduction of the previous embodiments, and details are not repeated here.
S207,基于屏幕划分出的多个第二分块以及光源数据,利用灯光剔除算法,构建各该第二分块的第二灯光列表。S207. Based on the plurality of second blocks divided by the screen and the light source data, use a light culling algorithm to construct a second light list for each of the second blocks.
其中,第二分块的面积大于第一分块的面积,或者说第二分块的尺寸大于第一分块的尺寸。Wherein, the area of the second block is larger than the area of the first block, or the size of the second block is larger than the size of the first block.
如,第二分块可以由四个或者更多个第一分块组成。例如,第一分块的大小可以为32*32个像素点,而第二个栅格的大小可以为64*64个像素点。For example, the second segment may consist of four or more first segments. For example, the size of the first block may be 32*32 pixels, and the size of the second grid may be 64*64 pixels.
可以理解的是,在该步骤S207中除了第二分块的大小与第一分块的大小不同之外,构建各第二分块的第二灯光列表的过程与构建各第一分块的第一灯光列表的过程是相似的,具体可以参见前面的相关介绍,在此不再赘述。It can be understood that, in this step S207, except that the size of the second block is different from that of the first block, the process of constructing the second light list of each second block is the same as that of constructing the first light list of each first block. The process of a light list is similar, please refer to the previous related introduction for details, and will not repeat them here.
可选的,本申请还可以确定屏幕对应的视椎体划分出的多个三维单元,每个三维单元就是一个簇(Cluster),在此基础上,基于画面数据中的光源数据,构建各三维单元的立体像素光源列表,以用于后续确定体积雾效果等。Optionally, the present application can also determine a plurality of three-dimensional units divided by the viewing frustum corresponding to the screen, each three-dimensional unit is a cluster (Cluster), on this basis, based on the light source data in the picture data, construct each three-dimensional The voxel light source list of the unit, which is used for subsequent determination of volumetric fog effects, etc.
S208,基于游戏画面中各像素点的体积雾数据,生成初始体积纹理图像。S208. Generate an initial volumetric texture image based on the volumetric fog data of each pixel in the game screen.
其中,初始体积纹理图像中各像素点关联有体积雾数据。Wherein, each pixel in the initial volume texture image is associated with volume fog data.
初始体积纹理图像中各个像素点与游戏画面(或者说屏幕)中各像素点具有一一对象关系,因此,本申请生成一个初始体积纹理图像中可以将游戏画面中各个像素点的体积雾数据关联到该初始体积纹理图像中。Each pixel in the initial volume texture image has a one-to-one relationship with each pixel in the game screen (or screen). Therefore, the application generates an initial volume texture image that can associate the volumetric fog data of each pixel in the game screen. into that initial volume texture image.
其中,生成初始体积纹理图像是为了后续体积雾效果渲染。Wherein, the initial volume texture image is generated for subsequent volume fog effect rendering.
可以理解的是,在实际应用中,可以检测游戏是否开启了体积光效果或者体积雾效果,如果游戏中未开启体积雾效果或者体积光效果,则无需执行该步骤S208以及后续确定体积光效果等相关操作。It can be understood that, in practical applications, it can be detected whether the volumetric light effect or the volumetric fog effect is enabled in the game. If the volumetric fog effect or the volumetric light effect is not enabled in the game, there is no need to perform step S208 and the subsequent determination of the volumetric light effect, etc. related operations.
以上步骤S202到S208是为了后面对象、体积雾渲染或者屏幕空间反射等相关渲染所进行一些基础准备工作,在实际应用中以上几个步骤的先后顺序可以不加限制。The above steps S202 to S208 are for some basic preparations for subsequent rendering of objects, volumetric fog rendering, or screen space reflection. In practical applications, the order of the above steps can be unlimited.
S209,结合该多张深度图以及游戏画面中法线信息,确定屏幕的空间反射效果。S209. Combining the multiple depth maps and the normal information in the game screen, determine the spatial reflection effect of the screen.
其中,屏幕的空间反射效果可以包括屏幕中各像素点(即对应到游戏画面的各像素点)对应的空间反射效果。Wherein, the spatial reflection effect of the screen may include the spatial reflection effect corresponding to each pixel point in the screen (that is, each pixel point corresponding to the game screen).
如,可以结合多张深度图以及游戏画面的法线信息进行光线步进处理,确定光线反射的采样在屏幕中的颜色等。For example, multiple depth maps and the normal information of the game screen can be combined to perform ray stepping processing, and determine the color of the sample of light reflection on the screen, etc.
其中,确定屏幕的空间反射效果可以有多种不同的算法,对此不加限制。There may be many different algorithms for determining the spatial reflection effect of the screen, and there is no limitation on this.
例如,可以基于屏幕空间反射(Screen Space Reflection,SSR)算法,确定屏幕的空间反射效果,或者是,基于屏幕空间平面反射(Screen Space Planar Reflections,SSPR)算法,确定屏幕的空间反射效果。For example, the space reflection effect of the screen may be determined based on a screen space reflection (Screen Space Reflection, SSR) algorithm, or the space reflection effect of the screen may be determined based on a screen space planar reflection (Screen Space Planar Reflections, SSPR) algorithm.
可以理解的是,如果检测到游戏中未开启屏幕反射效果,也可以不执行该步骤S209,而仅仅在确定游戏中开启屏幕反射效果的情况下,执行该步骤S209以及前面确定深度图的相关操作。It can be understood that, if it is detected that the screen reflection effect is not enabled in the game, this step S209 may not be performed, but only when it is determined that the screen reflection effect is enabled in the game, this step S209 and the previous related operations of determining the depth map are performed .
S210,基于该游戏画面的深度信息,确定屏幕中各像素点的环境光遮蔽效果。S210. Based on the depth information of the game screen, determine the ambient light shading effect of each pixel in the screen.
其中,环境光遮蔽效果表现的是游戏画面中周围环境对环境光的遮挡效果。Wherein, the ambient light occlusion effect represents the occlusion effect of the surrounding environment on the ambient light in the game screen.
在本申请中,确定屏幕中各像素点的环境光遮蔽效果的具体实现方式可以有多种可能,对此不加限制。In the present application, there may be many specific implementation manners for determining the ambient light shading effect of each pixel in the screen, which is not limited.
为了能够使得加载环境光遮蔽效果的游戏画面更为真实,本申请可以基于地面实况的环境光遮蔽(Ground Truth-based Ambient Occlusion,GTAO)算法来计算屏幕中各像素点的环境光遮蔽效果。GTAO在水平基准环境光遮蔽(Horizon Based AmbientOcclusion,HBAO)算法的基础上,新增了Cosine Weight(Cosine-Weighted是一种对球面进行采样的算法,常用于路径追踪时对入射方向进行采样等领域),以实现更为真实的环境光遮蔽效果。In order to make the game screen loaded with ambient light occlusion effects more realistic, the application can calculate the ambient light occlusion effects of each pixel in the screen based on the ground truth-based ambient light occlusion (Ground Truth-based Ambient Occlusion, GTAO) algorithm. Based on the Horizon Based Ambient Occlusion (HBAO) algorithm, GTAO adds Cosine Weight (Cosine-Weighted is an algorithm for sampling a spherical surface, which is often used in the field of sampling the incident direction during path tracing. ) for a more realistic ambient occlusion effect.
S211,基于该初始纹理图像、第二灯光列表以及光源数据,确定屏幕的体积光效果。S211. Based on the initial texture image, the second light list and light source data, determine a volumetric light effect of the screen.
在游戏中体积光是很常用的一种光照特效,主要用来表现光线照射到遮蔽物体时,在物体透光部分泄露出的光柱。由于视觉上给人很强的体积感,所以称之为体积光。Volumetric light is a very commonly used lighting effect in games. It is mainly used to express the beam of light leaking from the light-transmitting part of the object when the light hits the occluded object. Because it gives people a strong sense of volume visually, it is called volume light.
在一种可选方式,如果确认游戏中开启了体积光或者体积雾效果,则执行该步骤S211;如果游戏中未开启体积光或者体积雾效果,则无需执行该步骤S211。In an optional manner, if it is confirmed that the volumetric light or volumetric fog effect is enabled in the game, then step S211 is performed; if the volumetric light or volumetric fog effect is not enabled in the game, this step S211 does not need to be performed.
S212,基于游戏画面中各像素点的体积雾数据,确定屏幕的体积雾颜色,在屏幕的体积光效果上叠加该体积雾颜色。S212. Based on the volumetric fog data of each pixel in the game screen, determine the volumetric fog color of the screen, and superimpose the volumetric fog color on the volumetric light effect of the screen.
可以理解的是,体积光效果中没有体现雾气颜色,通过在体积光效果上叠加体积雾颜色,可以得到具有雾气颜色的体积雾颜色效果。It can be understood that the volumetric light effect does not reflect the fog color, and the volumetric fog color effect with the foggy color can be obtained by superimposing the volumetric fog color on the volumetric light effect.
在体积光效果上叠加体积雾颜色实际上就是渲染了体积雾效果。体积雾的作用是可以让游戏中的云雾呈现出更自然的效果而不再是贴图,使得光线质感和云雾质感都更真实。Overlaying the volumetric fog color on the volumetric light effect is actually rendering the volumetric fog effect. The function of volumetric fog is to make the clouds and fog in the game present a more natural effect instead of a texture, making the texture of light and fog more realistic.
S213,针对非透明的且属于第一类型对象的对象,基于各第一分块的第一灯光列表以及缓存的对象的深度信息、法线信息和材质信息,采用前向渲染方式渲染对象。S213. For an object that is non-transparent and belongs to the first type of object, render the object in a forward rendering manner based on the first light list of each first block and the cached depth information, normal information, and material information of the object.
S214,针对非透明的且属于第二类型对象的对象,基于各第一分块的第一灯光列表以及多个几何缓冲区内缓存的信息,采用延迟渲染方式渲染对象。S214. For an object that is non-transparent and belongs to the second type of object, render the object in a deferred rendering manner based on the first light list of each first block and the information cached in multiple geometry buffers.
该步骤S213和S214可以参见前面实施例的相关介绍,对此不加限制。For the steps S213 and S214, reference may be made to the relevant introduction of the foregoing embodiments, and there is no limitation thereto.
可以理解的是,该步骤S213和S214的先后顺序并不限定。同时,该步骤S213和S214与前面步骤S209到S212的先后顺序也不限于图2所示,在实际应用中,也可以先执行步骤S13和S214再执行步骤S209到S214。It can be understood that the sequence of steps S213 and S214 is not limited. At the same time, the sequence of steps S213 and S214 and the preceding steps S209 to S212 is not limited to that shown in FIG. 2 . In practical applications, steps S13 and S214 may be executed first and then steps S209 to S214 are executed.
S215,基于该天空数据渲染游戏画面的天空。S215. Render the sky of the game screen based on the sky data.
可以理解的是,在实际应用中,对于游戏画面中对象之外的场景的渲染还可以涉及到确定游戏画面中的颜色层级图,该颜色层级图用于折射与反射,以保证低分辨率下亮度不丢失,当然,还可能会涉及到其他渲染处理,对此不加限制。It can be understood that in practical applications, the rendering of scenes other than objects in the game screen may also involve determining the color hierarchy map in the game screen, and the color hierarchy map is used for refraction and reflection to ensure Brightness is not lost, of course, other rendering processes may be involved, there is no limit to this.
S216,对于基于对象的材质信息确定出的透明对象,基于透明对象的对象数据渲染该透明对象。S216. For the transparent object determined based on the material information of the object, render the transparent object based on the object data of the transparent object.
对于透明对象的具体渲染可以根据需要设定,如可以采用常规的前向渲染等,对此不加限制。The specific rendering of the transparent object can be set as required, for example, conventional forward rendering can be used, and there is no limitation on this.
可以理解的是,在该步骤S216之后还可以执行后处理渲染,并最终加载以上渲染结果,以呈现出游戏画面。It can be understood that post-processing rendering may also be performed after step S216, and the above rendering results are finally loaded to present the game screen.
可以理解的是,在本申请实施例中屏幕的空间反射效果以及体积雾效果等都可以根据需要在游戏中开启或者不开启,以灵活配置相应的渲染管线,根据实际需要呈现或者不呈现相应的渲染效果。It can be understood that in the embodiment of the present application, the spatial reflection effect of the screen and the volumetric fog effect can be enabled or disabled in the game according to the needs, so as to flexibly configure the corresponding rendering pipeline, and display or not render the corresponding images according to actual needs. rendering effect.
对应本申请的一种游戏画面渲染方法,本申请还提供了一种游戏画面渲染装置。如图3所示,其示出了本申请实施例提供的游戏画面渲染装置的一种组成结构示意图,该装置应用于移动终端。本实施例的装置可以包括:Corresponding to the game screen rendering method of the present application, the present application also provides a game screen rendering device. As shown in FIG. 3 , it shows a schematic structural diagram of a game screen rendering device provided by an embodiment of the present application, and the device is applied to a mobile terminal. The device of this embodiment may include:
数据获得单元301,用于获得游戏中待渲染的画面数据,所述画面数据包括:游戏画面中光源的光源数据和至少一个非透明的对象的渲染属性信息;A
第一构建单元302,用于基于屏幕划分出的多个第一分块以及所述光源数据,利用灯光剔除算法,构建各所述第一分块的第一灯光列表;The
材质提取单元303,用于从所述对象的渲染属性信息中提取出所述对象的材质信息;a
第一对象渲染单元304,用于如果基于所述对象的材质信息确定出所述对象为第一类型对象,从所述对象的渲染属性信息中提取出所述对象的深度信息和法线信息,基于各所述第一分块的第一灯光列表以及所述对象的深度信息、法线信息和材质信息,采用前向渲染方式渲染所述对象;The first
第二对象渲染单元305,用于如果基于所述对象的材质信息确定出所述对象为第二类型对象,将所述对象的渲染属性信息缓存到多个几何缓冲区,基于各所述第一分块的第一灯光列表以及所述多个几何缓冲区内缓存的信息,采用延迟渲染方式渲染所述对象。The second
在一种可能的实现方式中,该装置还包括:In a possible implementation manner, the device also includes:
类型确定单元,用于第一构建单元构建各所述第一分块的第一灯光列表之前,确定所述移动终端中图形处理器的类型;a type determination unit, configured to determine the type of the graphics processor in the mobile terminal before the first construction unit constructs the first light list of each of the first blocks;
剔除算法确定单元,用于按照配置的不同类型的图形处理器适合的灯光剔除算法,确定所述移动终端中的图形处理器适合的目标灯光剔除算法;The culling algorithm determination unit is configured to determine the target light culling algorithm suitable for the graphics processor in the mobile terminal according to the light culling algorithm suitable for different types of graphics processors configured;
所述第一构建单元,包括:The first building unit includes:
第一构建子单元,用于基于屏幕划分出的多个第一分块以及所述光源数据,在所述移动终端的图形处理器中利用所述目标灯光剔除算法,构建各所述第一分块的第一灯光列表。The first construction subunit is configured to use the target light culling algorithm in the graphics processor of the mobile terminal to construct each of the first sub-blocks based on the plurality of first sub-blocks divided by the screen and the light source data. List of first lights for the block.
在又一种可能的实现方式中,所述第二对象渲染单元,包括:In yet another possible implementation manner, the second object rendering unit includes:
代码确定单元,用于基于多套延迟渲染代码各自适合的对象材质,结合所述对象的材质信息,确定所述对象适用的目标延迟渲染代码,所述目标延迟渲染代码属于所述多套延迟渲染代码;A code determining unit, configured to determine a target delayed rendering code applicable to the object based on the object material suitable for each of the multiple sets of delayed rendering codes, in combination with the material information of the object, and the target delayed rendering code belongs to the multiple sets of delayed rendering code;
渲染代码调用单元,用于基于各所述第一分块的第一灯光列表以及所述多个几何缓冲区内缓存的信息,调用所述目标延迟渲染代码执行所述对象的延迟渲染。The rendering code calling unit is configured to call the target deferred rendering code to perform deferred rendering of the object based on the first light list of each first block and the information cached in the plurality of geometry buffers.
在又一种可能的实现方式中,该数据获得单元获得的画面数据还包括:所述游戏画面中各像素点对应的用于体积雾渲染的体积雾数据;In yet another possible implementation manner, the picture data obtained by the data obtaining unit further includes: volumetric fog data used for volumetric fog rendering corresponding to each pixel in the game picture;
该装置还包括:The unit also includes:
第二构建单元,用于在数据获得单元获得游戏中待渲染的画面数据之后,基于屏幕划分出的多个第二分块以及所述光源数据,利用灯光剔除算法,构建各所述第二分块的第二灯光列表,所述第二分块的面积大于所述第一分块的面积;The second construction unit is configured to, after the data obtaining unit obtains the picture data to be rendered in the game, based on the plurality of second sub-blocks divided by the screen and the light source data, use a light culling algorithm to construct each of the second sub-blocks a second light list of blocks, the area of the second block is larger than the area of the first block;
纹理生成单元,用于基于游戏画面中各像素点的体积雾数据,生成初始体积纹理图像,所述初始体积纹理图像中各像素点关联有体积雾数据;A texture generating unit, configured to generate an initial volumetric texture image based on the volumetric fog data of each pixel in the game screen, where each pixel in the initial volumetric texture image is associated with volumetric fog data;
体积光确定单元,用于基于所述初始纹理图像、所述第二灯光列表以及所述光源数据,确定屏幕的体积光效果。A volumetric light determining unit, configured to determine a volumetric light effect of the screen based on the initial texture image, the second light list, and the light source data.
进一步的,该装置还可以包括:Further, the device may also include:
雾颜色确定单元,用于基于所述游戏画面中各像素点的体积雾数据,确定屏幕的体积雾颜色;A fog color determination unit, configured to determine the volumetric fog color of the screen based on the volumetric fog data of each pixel in the game screen;
体积雾确定单元,用于在所述屏幕的体积光效果上叠加所述体积雾颜色。A volumetric fog determining unit, configured to superimpose the volumetric fog color on the volumetric light effect of the screen.
在又一种可能的实现方式中,该数据获得单元获得的画面数据还包括:所述游戏画面的深度信息和法线信息;In yet another possible implementation manner, the picture data obtained by the data obtaining unit further includes: depth information and normal line information of the game picture;
该装置还包括:The unit also includes:
深度图构建单元,用于在体积光确定单元确定屏幕的体积光效果之前,基于所述游戏画面的深度信息,构建多张不同分辨率的深度图;The depth map construction unit is used to construct multiple depth maps with different resolutions based on the depth information of the game screen before the volume light determination unit determines the volume light effect of the screen;
发射确定单元,用于结合所述多张深度图以及所述游戏画面的法线信息,确定屏幕的空间反射效果;An emission determining unit, configured to combine the multiple depth maps and the normal information of the game screen to determine the spatial reflection effect of the screen;
遮蔽确定单元,用于基于所述游戏画面的深度信息,确定屏幕中各像素点的环境光遮蔽效果。The shading determination unit is configured to determine the ambient light shading effect of each pixel in the screen based on the depth information of the game screen.
进一步的,该数据获得单元获得的画面数据还包括:游戏画面中天空的天空数据以及至少一个透明对象的渲染属性信息;Further, the picture data obtained by the data obtaining unit also includes: sky data of the sky in the game picture and rendering attribute information of at least one transparent object;
该装置还包括:The unit also includes:
天空渲染单元,用于基于所述天空数据渲染所述游戏画面的天空;a sky rendering unit, configured to render the sky of the game screen based on the sky data;
第三对象渲染单元,用于基于所述透明对象的渲染属性信息渲染所述透明对象。A third object rendering unit, configured to render the transparent object based on the rendering attribute information of the transparent object.
需要说明的是,本说明书中的各个实施例均采用递进的方式描述,每个实施例重点说明的都是与其他实施例的不同之处,各个实施例之间相同相似的部分互相参见即可。同时,本说明书中各实施例中记载的特征可以相互替换或者组合,使本领域专业技术人员能够实现或使用本申请。对于装置类实施例而言,由于其与方法实施例基本相似,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。It should be noted that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the difference from other embodiments. For the same and similar parts in each embodiment, refer to each other, that is, Can. At the same time, the features recorded in the various embodiments in this specification can be replaced or combined with each other, so that those skilled in the art can realize or use the present application. As for the device-type embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for related parts, please refer to part of the description of the method embodiments.
最后,还需要说明的是,在本文中,诸如第一和第二等之类的关系术语仅仅用来将一个实体或者操作与另一个实体或操作区分开来,而不一定要求或者暗示这些实体或操作之间存在任何这种实际的关系或者顺序。而且,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、物品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、物品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括要素的过程、方法、物品或者设备中还存在另外的相同要素。Finally, it should also be noted that in this text, relational terms such as first and second etc. are only used to distinguish one entity or operation from another, and do not necessarily require or imply that these entities or operations, any such actual relationship or order exists. Furthermore, the term "comprises", "comprises" or any other variation thereof is intended to cover a non-exclusive inclusion such that a process, method, article, or apparatus comprising a set of elements includes not only those elements, but also includes elements not expressly listed. other elements of or also include elements inherent in such a process, method, article, or device. Without further limitations, an element defined by the phrase "comprising a ..." does not preclude the presence of additional identical elements in the process, method, article, or apparatus that includes the element.
对所公开的实施例的上述说明,使本领域技术人员能够实现或使用本申请。对这些实施例的多种修改对本领域技术人员来说将是显而易见的,本文中所定义的一般原理可以在不脱离本申请的精神或范围的情况下,在其它实施例中实现。因此,本申请将不会被限制于本文所示的这些实施例,而是要符合与本文所公开的原理和新颖特点相一致的最宽的范围。The above description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the application. Therefore, the present application will not be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
以上仅是本申请的优选实施方式,应当指出,对于本技术领域的普通技术人员来说,在不脱离本申请原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本申请的保护范围。The above are only the preferred embodiments of the present application. It should be pointed out that for those of ordinary skill in the art, without departing from the principle of the application, some improvements and modifications can also be made, and these improvements and modifications should also be considered as For the scope of protection of this application.
Claims (10)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211285899.7A CN115526977B (en) | 2022-10-20 | 2022-10-20 | Game picture rendering method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202211285899.7A CN115526977B (en) | 2022-10-20 | 2022-10-20 | Game picture rendering method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN115526977A true CN115526977A (en) | 2022-12-27 |
CN115526977B CN115526977B (en) | 2023-07-21 |
Family
ID=84703071
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202211285899.7A Active CN115526977B (en) | 2022-10-20 | 2022-10-20 | Game picture rendering method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115526977B (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116168587A (en) * | 2023-02-21 | 2023-05-26 | 北京千种幻影科技有限公司 | Driving simulation scene generation method and device and display equipment |
CN118203842A (en) * | 2024-03-20 | 2024-06-18 | 北京畅游创想软件技术有限公司 | A server data processing method and related equipment, double loop buffer system |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130328873A1 (en) * | 2012-06-08 | 2013-12-12 | Advanced Micro Devices, Inc. | Forward rendering pipeline with light culling |
CN108236783A (en) * | 2018-01-09 | 2018-07-03 | 网易(杭州)网络有限公司 | The method, apparatus of illumination simulation, terminal device and storage medium in scene of game |
CN108564646A (en) * | 2018-03-28 | 2018-09-21 | 腾讯科技(深圳)有限公司 | Rendering intent and device, storage medium, the electronic device of object |
CN114782613A (en) * | 2022-04-29 | 2022-07-22 | 北京字跳网络技术有限公司 | Image rendering method, device and equipment and storage medium |
-
2022
- 2022-10-20 CN CN202211285899.7A patent/CN115526977B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20130328873A1 (en) * | 2012-06-08 | 2013-12-12 | Advanced Micro Devices, Inc. | Forward rendering pipeline with light culling |
CN108236783A (en) * | 2018-01-09 | 2018-07-03 | 网易(杭州)网络有限公司 | The method, apparatus of illumination simulation, terminal device and storage medium in scene of game |
CN108564646A (en) * | 2018-03-28 | 2018-09-21 | 腾讯科技(深圳)有限公司 | Rendering intent and device, storage medium, the electronic device of object |
CN114782613A (en) * | 2022-04-29 | 2022-07-22 | 北京字跳网络技术有限公司 | Image rendering method, device and equipment and storage medium |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116168587A (en) * | 2023-02-21 | 2023-05-26 | 北京千种幻影科技有限公司 | Driving simulation scene generation method and device and display equipment |
CN118203842A (en) * | 2024-03-20 | 2024-06-18 | 北京畅游创想软件技术有限公司 | A server data processing method and related equipment, double loop buffer system |
CN118203842B (en) * | 2024-03-20 | 2024-10-18 | 北京畅游创想软件技术有限公司 | Server data processing method, related equipment and double-circulation buffer system |
Also Published As
Publication number | Publication date |
---|---|
CN115526977B (en) | 2023-07-21 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20230053462A1 (en) | Image rendering method and apparatus, device, medium, and computer program product | |
WO2022111619A1 (en) | Image processing method and related apparatus | |
US10049486B2 (en) | Sparse rasterization | |
US10311548B2 (en) | Scaling render targets to a higher rendering resolution to display higher quality video frames | |
CN115526977B (en) | Game picture rendering method and device | |
CN113900797B (en) | Three-dimensional oblique photography data processing method, device and equipment based on illusion engine | |
KR101681056B1 (en) | Method and Apparatus for Processing Vertex | |
KR20010085424A (en) | Graphics processor with deferred shading | |
WO2021249091A1 (en) | Image processing method and apparatus, computer storage medium, and electronic device | |
KR102140387B1 (en) | Storage of bandwidth-compressed graphics data | |
CN107392836B (en) | Stereoscopic multi-projection using a graphics processing pipeline | |
CN108805971B (en) | An Ambient Occlusion Method | |
CN113674389A (en) | Scene rendering method and device, electronic equipment and storage medium | |
US20230230311A1 (en) | Rendering Method and Apparatus, and Device | |
CN105550973B (en) | Graphics processing unit, graphics processing system and anti-aliasing processing method | |
WO2022143367A1 (en) | Image rendering method and related device therefor | |
CN107392990B (en) | Global illumination to render 3D scenes | |
CN112652046B (en) | Game picture generation method, device, equipment and storage medium | |
Kilgard | Improving shadows and reflections via the stencil buffer | |
CN112001993A (en) | A multi-GPU city simulation system for large scenes | |
WO2024027237A1 (en) | Rendering optimization method, and electronic device and computer-readable storage medium | |
WO2023142607A1 (en) | Image rendering method and apparatus, and device and medium | |
CN112884874A (en) | Method, apparatus, device and medium for applying decals on virtual model | |
CN103679818B (en) | A kind of real-time scene method for drafting based on virtual surface light source | |
KR20230013099A (en) | Geometry-aware augmented reality effects using real-time depth maps |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |