Light map generation method and device, storage medium and electronic equipment
Patent Information
- Application Number
- CN202510573298.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-30
- Publication Date
- 2026-10-30
AI Technical Summary
[0006]本申请实施例提供了一种光照贴图的生成方法和装置、存储介质及电子设备,以至少解决虚拟对象模型的原始显示位置分散导致光照贴图的空间利用率低的技术问题
[0028]在本申请实施例中,在确定出目标游戏画面中包含的至少两个静态虚拟对象后,将至少两个静态虚拟对象各自对应的对象模型网格信息进行合并,得到全局对象模型网格信息,这里的全局对象模型网格信息用于构建包含至少两个静态虚拟对象的全局静态虚拟对象;从全局对象模型网格信息中获取上述全局静态虚拟对象中每个局部虚拟对象各自对应的对象模型网格统计信息,其中,每个局部虚拟对象分别与每个静态虚拟对象各自对应;基于获取到的对象模型网格统计信息,确定出每个局部虚拟对象各自的光照信息所要存储的贴图位置区域的区域描述信息,并利用区域描述信息生成与全局对象模型网格信息对应的全局光照贴图,其中,上述不同的局部虚拟对象各自对应的贴图位置区域具有相同的区域图形,但具有不同的区域尺寸。通过合并多个静态虚拟对象得到全局静态虚拟对象,并从全局对象模型网格信息中获取上述全局静态虚拟对象中每个局部虚拟对象各自对应的对象模型网格统计信息,从而能够基于获取到的对象模型网格统计信息确定出每个局部虚拟对象各自光照信息所要存储的贴图位置区域的区域描述信息,进而实现基于合并多个静态虚拟对象所得到的全局静态虚拟对象,确定全局静态虚拟对象中每个局部虚拟对象的光照信息在全局光照贴图中的贴图位置区域,避免了所生成的光照贴图中存在大量不被利用的存储空间所导致的空间浪费的问题,达到在光照贴图生成过程中灵活改变虚拟对象模型在光照贴图中的存储位置,以提高所生成的光照贴图的空间利用率的目的,进而解决了虚拟对象模型的原始显示位置分散导致光照贴图的空间利用率低的技术问题。
Smart Images

Figure CN123015810A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more specifically, to a method and apparatus for generating lightmaps, a storage medium, and an electronic device. Background Technology
[0002] To enhance the immersive experience for players during gameplay, game developers are constantly investing resources in optimizing the visual effects of their games. Among these, the most important element affecting the visual effects is the lighting.
[0003] Currently, in the rendering process of game visuals, considering the global illumination rendering of virtual scenes, the common approach is to call the rendering engine's lightmap baking function to perform lightmap baking calculations on the entire scene. This involves pre-calculating the lighting information for each pixel in the game visuals, mapping this information onto a lightmap for storage, and then using this lightmap to render complex lighting effects onto virtual object models in real time, thereby reducing the performance burden on the rendering engine.
[0004] However, in the lightmaps generated using the aforementioned technologies, the storage location of the lighting information for each virtual object model is often determined based on the original display location of that virtual object model in the virtual scene. In other words, the lighting information of virtual object models with relatively dispersed original display locations is also stored discretely in the lightmap. This results in some storage space in the lightmap not being occupied by actual, effective lighting information, leading to low space utilization of the generated lightmap.
[0005] There is currently no effective solution to the above problems. Summary of the Invention
[0006] This application provides a method and apparatus for generating lightmaps, a storage medium, and an electronic device to at least solve the technical problem of low space utilization of lightmaps caused by the dispersed original display positions of virtual object models.
[0007] According to one aspect of the embodiments of this application, a method for generating a lightmap is provided, comprising: determining at least two static virtual objects contained in a target game screen; merging the object model mesh information corresponding to each of the at least two static virtual objects to obtain global object model mesh information, wherein the global object model mesh information is used to construct a global static virtual object containing the at least two static virtual objects; obtaining object model mesh statistical information corresponding to each local virtual object in the global static virtual object from the global object model mesh information, wherein each local virtual object corresponds to each of the static virtual objects; determining, based on the object model mesh statistical information, region description information of the texture location area to be stored for the lighting information of each local virtual object, wherein the texture location areas corresponding to different local virtual objects have the same region graphic but different region sizes; and generating a global lightmap corresponding to the global object model mesh information using the region description information.
[0008] As an optional implementation, the region description information for determining the texture location region for storing the lighting information of each of the local virtual objects based on the object model mesh statistics includes: assigning an object space matching the object model mesh statistics to each of the local virtual objects, wherein different object spaces have the same spatial shape but different spatial dimensions, and the spatial dimensions are linearly related to the object model mesh statistics; mapping each object space according to the spatial dimensions to obtain the region description information of the texture location region of the lighting information of the local virtual object in the global illumination map, wherein each object space is mapped to a texture location region in the global illumination map, and the region description information includes region size and region offset.
[0009] As an optional implementation, allocating an object space matching the object model mesh statistics for each of the aforementioned local virtual objects includes one of the following: using the object model mesh statistics as the spatial description parameter of the object space; allocating the object space matching the spatial description parameter to the aforementioned local virtual objects; or linearly scaling the object model mesh statistics to obtain the spatial description parameter of the object space; and allocating the object space matching the spatial description parameter to the aforementioned local virtual objects.
[0010] As an optional implementation, the above-described mapping of each object space according to the aforementioned spatial dimensions to obtain the region description information of the local virtual object's lighting information in the texture location region of the global illumination map includes: sorting each object space according to the aforementioned spatial dimensions to obtain an object space sequence; sequentially determining the current object space from the aforementioned object space sequence, and performing the following operations: adjusting the spatial dimensions of the current object space according to the mapping scaling ratio to obtain the current region size of the texture location region where the lighting information of the current local virtual object corresponding to the current object space is to be stored, wherein the aforementioned mapping scaling ratio is determined based on the texture size of the global illumination map and the global object space size, and the aforementioned global object space size is the region description information of each object space. The result of accumulating the spatial dimensions of the object space; in the candidate lightmap in the idle state, a current candidate region matching the current region size is assigned to the current local virtual object, and the region position coordinates of the current candidate region are obtained. Here, the candidate lightmap in the idle state has not yet been mapped with lighting information, and the region position coordinates are used to indicate the region offset of the current candidate region in the candidate lightmap; when the local virtual objects corresponding to each object space in the object space sequence have been assigned candidate regions in the candidate lightmap, the region description information of the texture position region of each local virtual object in the global lightmap is determined based on the region size and region position coordinates of each candidate region in the candidate lightmap.
[0011] As an optional implementation, the method of determining the region description information of the texture location region of each local virtual object in the global lightmap based on the region size and region position coordinates of each candidate region in the candidate lightmap includes: obtaining the region mapping rate of the candidate lightmap; if the region mapping rate reaches a preset condition, using the candidate lightmap as the global lightmap, and using the region size and region position coordinates of each candidate region in the candidate lightmap as the region description information of the texture location region of each local virtual object in the global lightmap; if the region mapping rate does not reach the preset condition, adjusting the region position coordinates of each candidate region in the candidate lightmap until the region mapping rate of the adjusted candidate lightmap reaches the preset condition.
[0012] As an optional implementation, the above-mentioned merging of the object model mesh information corresponding to each of the at least two static virtual objects to obtain global object model mesh information includes: merging the vertices of the object model mesh corresponding to each of the at least two static virtual objects to obtain a vertex set, and storing the vertex set in a vertex list; merging the object model mesh indices corresponding to each of the at least two static virtual objects to obtain an index merge array; transforming the normal vectors of the object model mesh corresponding to each of the at least two static virtual objects using a normal transformation matrix to obtain normal transformation vectors; merging the normal transformation vectors to obtain a normal transformation vector set; storing the normal transformation vector set in a normal list; and determining the global object model mesh information based on the vertex list, the index merge array, and the normal list.
[0013] As an optional implementation, when merging the object model mesh indices corresponding to the at least two static virtual objects to obtain an index merge array, one of the following is further included: separately counting the number of meshes of the object model mesh corresponding to each of the local virtual objects in the index merge array to obtain the object model mesh statistics of each of the local virtual objects; or separately counting the square root of the mesh area of the object model mesh corresponding to each of the local virtual objects in the index merge array to obtain the object model mesh statistics of each of the local virtual objects.
[0014] As an optional implementation, the above-mentioned method of generating a global illumination map corresponding to the global object model mesh information using the aforementioned region description information includes: hiding the aforementioned at least two static virtual objects and retaining the aforementioned global static virtual object created using the aforementioned global object model mesh information; adding the lighting information of each local virtual object in the aforementioned global static virtual object to the texture position area corresponding to the aforementioned region description information, so as to generate the aforementioned global illumination map of the aforementioned global static virtual object.
[0015] As an optional implementation, after generating a global illumination map corresponding to the global object model mesh information using the aforementioned region description information, the method further includes: deleting the aforementioned global static virtual object and displaying the aforementioned at least two static virtual objects; determining the current static virtual object from the aforementioned at least two static virtual objects, and performing the following operations respectively: configuring the aforementioned global illumination map for the aforementioned current static virtual object; assigning the lighting information stored in the texture position area of the aforementioned global illumination map that matches the aforementioned current static virtual object to the aforementioned current static virtual object for rendering.
[0016] According to another aspect of the embodiments of this application, a lightmap generation apparatus is also provided, comprising: a first determining unit, configured to determine at least two static virtual objects contained in a target game screen; a merging unit, configured to merge the object model mesh information corresponding to each of the at least two static virtual objects to obtain global object model mesh information, wherein the global object model mesh information is used to construct a global static virtual object containing the at least two static virtual objects; an obtaining unit, configured to obtain object model mesh statistical information corresponding to each local virtual object in the global static virtual object from the global object model mesh information, wherein each local virtual object corresponds to each of the static virtual objects; a second determining unit, configured to determine, based on the object model mesh statistical information, region description information of the texture location area to be stored for the lighting information of each local virtual object, wherein the texture location areas corresponding to different local virtual objects have the same region graphic but different region sizes; and a generating unit, configured to generate a global lightmap corresponding to the global object model mesh information using the region description information.
[0017] As an optional implementation, the second determining unit includes: an allocation module, configured to allocate an object space matching the object model mesh statistics for each of the local virtual objects, wherein different object spaces have the same spatial shape but different spatial dimensions, and the spatial dimensions are linearly related to the object model mesh statistics; and a mapping module, configured to map each of the object spaces according to the spatial dimensions to obtain region description information of the local virtual object's lighting information in the global illumination map, wherein each object space is mapped to a texture location region in the global illumination map, and the region description information includes region size and region offset.
[0018] As an optional implementation, the allocation module includes one of the following: a processing submodule, used to use the object model mesh statistics as spatial description parameters of the object space; a first allocation submodule, used to allocate the object space matching the spatial description parameters to the local virtual object; a scaling submodule, used to either linearly scale the object model mesh statistics to obtain the spatial description parameters of the object space; and a second allocation submodule, used to allocate the object space matching the spatial description parameters to the local virtual object.
[0019] As an optional implementation, the mapping module includes: a sorting submodule, used to sort the object spaces according to their spatial dimensions to obtain an object space sequence; and a determining submodule, used to sequentially determine the current object space from the object space sequence and perform the following operations: adjusting the spatial dimensions of the current object space according to a mapping scaling ratio to obtain the current region size of the texture location area where the lighting information of the current local virtual object corresponding to the current object space is to be stored, wherein the mapping scaling ratio is determined based on the texture size of the global lighting map and the global object space size, and the global object space size is the result of summing the spatial dimensions of the object spaces; when idle... In the candidate lightmap of the current state, a current candidate region matching the current region size is assigned to the current local virtual object, and the region position coordinates of the current candidate region are obtained. In the idle state, the candidate lightmap has not yet been mapped with lighting information, and the region position coordinates are used to indicate the region offset of the current candidate region in the candidate lightmap. When the local virtual objects corresponding to each object space in the object space sequence have been assigned candidate regions in the candidate lightmap, the region description information of the texture position region of each local virtual object in the global lightmap is determined based on the region size and region position coordinates of each candidate region in the candidate lightmap.
[0020] As an optional implementation, the determining submodule is further configured to: obtain the region mapping rate of the candidate light map; if the region mapping rate reaches a preset condition, use the candidate light map as the global light map, and use the region size and region position coordinates of each candidate region in the candidate light map as the region description information of the texture position region of each local virtual object in the global light map; if the region mapping rate does not reach the preset condition, adjust the region position coordinates of each candidate region in the candidate light map until the region mapping rate of the adjusted candidate light map reaches the preset condition.
[0021] As an optional implementation, the merging unit includes: a first merging module, used to merge the object model mesh vertices corresponding to the at least two static virtual objects to obtain a vertex set, and store the vertex set in a vertex list; a second merging module, used to merge the object model mesh indices corresponding to the at least two static virtual objects to obtain an index merge array; a transformation module, used to transform the normal vectors of the object model mesh corresponding to the at least two static virtual objects through a normal transformation matrix to obtain normal transformation vectors; merge the normal transformation vectors to obtain a normal transformation vector set; and store the normal transformation vector set in a normal list; and a determination module, used to determine the global object model mesh information based on the vertex list, the index merge array, and the normal list.
[0022] As an optional implementation, the second merging module further includes one of the following: a first statistics submodule, used to separately count the number of grids of the object model grid corresponding to each of the local virtual objects in the index merging array, to obtain the statistical information of the object model grid corresponding to each of the local virtual objects; or a second statistics submodule, used to separately count the square root of the grid area of the object model grid corresponding to each of the local virtual objects in the index merging array, to obtain the statistical information of the object model grid corresponding to each of the local virtual objects.
[0023] As an optional implementation, the generation unit includes: a processing module for hiding the at least two static virtual objects and retaining the global static virtual object created using the global object model mesh information; and a generation module for adding the lighting information of each local virtual object in the global static virtual object to the texture location area corresponding to the region description information, so as to generate the global lighting texture of the global static virtual object.
[0024] As an optional implementation, the above apparatus further includes: a first processing unit, configured to delete the global static virtual object and display the at least two static virtual objects; and a third determining unit, configured to determine the current static virtual object from the at least two static virtual objects and perform the following operations respectively: configuring the global illumination map for the current static virtual object; and assigning the lighting information stored in the map position area of the global illumination map that matches the current static virtual object to the current static virtual object for rendering.
[0025] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, wherein a computer program is stored in the computer program, and the computer program is configured to execute the above-described method for generating lightmaps when running.
[0026] According to another aspect of the embodiments of this application, a computer program product or computer program is provided, the computer program product or computer program including computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, causing the computer device to perform the lightmap generation method as described above.
[0027] According to another aspect of the embodiments of this application, an electronic device is also provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the above-described method for generating a lightmap through the computer program.
[0028] In this embodiment, after determining at least two static virtual objects contained in the target game screen, the object model mesh information corresponding to each of the at least two static virtual objects is merged to obtain global object model mesh information. This global object model mesh information is used to construct a global static virtual object containing at least two static virtual objects. The object model mesh statistical information corresponding to each local virtual object in the global static virtual object is obtained from the global object model mesh information, wherein each local virtual object corresponds to each static virtual object. Based on the obtained object model mesh statistical information, the region description information of the texture location area to be stored for the lighting information of each local virtual object is determined, and a global lighting texture corresponding to the global object model mesh information is generated using the region description information. The texture location areas corresponding to the different local virtual objects have the same region graphics but different region sizes. By merging multiple static virtual objects to obtain a global static virtual object, and extracting the object model mesh statistics of each local virtual object in the global static virtual object from the global object model mesh information, the region description information of the texture location area where the lighting information of each local virtual object should be stored can be determined based on the obtained object model mesh statistics. This enables the determination of the texture location area of the lighting information of each local virtual object in the global lighting map based on the global static virtual object obtained by merging multiple static virtual objects. This avoids the problem of wasted space caused by a large amount of unused storage space in the generated lighting map, and achieves the goal of flexibly changing the storage location of the virtual object model in the lighting map during the lighting map generation process, thereby improving the space utilization of the generated lighting map. This solves the technical problem of low space utilization of lighting maps caused by the scattered original display positions of virtual object models. Attached Figure Description
[0029] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0030] Figure 1 This is a schematic diagram of an application environment for an optional method for generating a lightmap according to an embodiment of this application;
[0031] Figure 2 This is a flowchart of an optional method for generating a lightmap according to an embodiment of this application;
[0032] Figure 3 This is a schematic diagram of an optional method for generating a lightmap according to an embodiment of this application;
[0033] Figure 4 This is a schematic diagram of another optional method for generating a lightmap according to an embodiment of this application;
[0034] Figure 5 This is a schematic diagram of another optional method for generating a lightmap according to an embodiment of this application;
[0035] Figure 6 This is a schematic diagram of another optional method for generating a lightmap according to an embodiment of this application;
[0036] Figure 7 This is a schematic diagram of another optional method for generating a lightmap according to an embodiment of this application;
[0037] Figure 8 This is a schematic diagram of another optional method for generating a lightmap according to an embodiment of this application;
[0038] Figure 9 This is a flowchart of another optional method for generating a lightmap according to an embodiment of this application;
[0039] Figure 10 This is a flowchart of another optional method for generating a lightmap according to an embodiment of this application;
[0040] Figure 11 This is a flowchart of another optional method for generating a lightmap according to an embodiment of this application;
[0041] Figure 12 This is a schematic diagram of another optional method for generating a lightmap according to an embodiment of this application;
[0042] Figure 13 This is a schematic diagram of another optional method for generating a lightmap according to an embodiment of this application;
[0043] Figure 14 This is a schematic diagram of another optional method for generating a lightmap according to an embodiment of this application;
[0044] Figure 15 This is a schematic diagram of another optional method for generating a lightmap according to an embodiment of this application;
[0045] Figure 16 This is a schematic diagram of another optional method for generating a lightmap according to an embodiment of this application;
[0046] Figure 17 This is a schematic diagram of another optional method for generating a lightmap according to an embodiment of this application;
[0047] Figure 18 This is a schematic diagram of another optional method for generating a lightmap according to an embodiment of this application;
[0048] Figure 19 This is a schematic diagram of an optional lightmap generation apparatus according to an embodiment of this application;
[0049] Figure 20 This is a schematic diagram of the structure of an optional electronic device according to an embodiment of this application. Detailed Implementation
[0050] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.
[0051] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0052] In some embodiments, for example, the game in the virtual environment consists of maps of one or more game worlds. The virtual environment in the game can simulate scenes in the real world. Users can control virtual characters in the game to perform actions such as walking, running, jumping, shooting, fighting, and driving in the virtual environment. They can also control virtual vehicles to drive in the virtual environment. The game is highly interactive, and multiple users can team up online to play competitive games.
[0053] The aforementioned applications can be shooting games, racing games, motorsports games, role-playing games, adventure games, sandbox games, tactical competitive games, etc. The client can support at least one of the following operating systems: Windows, macOS, Android, iOS, and Linux, and clients on different operating systems can interconnect. In some embodiments, the client is a program suitable for mobile terminals with touchscreens. For example, the virtual vehicle shifting method provided in this application embodiment can be applied to applications supporting racing games, allowing players to control virtual vehicles in virtual racing competitions; similarly, the virtual vehicle shifting method provided in this application embodiment can be applied to applications supporting role-playing games, allowing players to control virtual vehicles to move in virtual scenes to meet their needs for roaming and sightseeing.
[0054] In some embodiments, the aforementioned client is an application developed based on a 3D engine, such as the Unreal Engine. The terminal in this application can be a desktop computer, laptop computer, mobile phone, tablet computer, e-book reader, MP3 (Moving Picture Experts Group Audio Layer III) player, MP4 (Moving Picture Experts Group Audio Layer IV) player, etc. This terminal has a client installed and running that supports a virtual environment, such as a client for an application that supports a 3D virtual environment. This application can be any of the following: a Battle Royale (BR) game, a virtual reality application, an augmented reality application, a 3D map application, a third-person shooter game, a first-person shooter game, a multiplayer online battle arena game, a racing game, or a speed racing game. Optionally, the application can be a standalone application, such as a standalone 3D game application, or a network-based application.
[0055] According to an embodiment of this application, a method for generating lightmaps is provided. Optionally, in this embodiment, the above-described method for generating lightmaps can be used, but is not limited to, for generating lightmaps for game screens in various online or offline games. For example, the above-described method can be used to generate lightmaps for virtual attack items, equipment, and other objects in first-person shooter (FPS) games, and can also be applied to generating lightmaps for buildings and environmental objects (such as gems, trees, etc.) in role-playing games (RPGs). The quality of the lightmap is closely related to the overall quality of the game screen. High-quality lightmaps can significantly improve the visual realism and detail of the game, thereby enhancing the user's immersion and gaming experience. Conversely, low-quality lightmaps may result in poor visual effects and affect the overall quality of the game.
[0056] The above method for generating lightmaps can be applied to, for example... Figure 1 The lightmap generation system in the hardware environment shown. This lightmap generation system may include, but is not limited to, the terminal device 102 and the information processing server 104. The terminal device is used to capture the target game screen of the currently running game and send the captured target game screen to the information processing server 104, as shown in step S102. Optionally, in this embodiment, the target game screen may be as follows: Figure 1 The image shown contains a game screen with multiple static objects.
[0057] After receiving the target game screen, the information processing server 104 executes steps S104 to S112. Specifically, the information processing server 104 is used to determine static virtual objects (such as...) in the target game screen. Figure 1The information processing server 104 processes objects in the target game screen (such as spheres and cubes) and merges the object model mesh information corresponding to at least two static virtual objects to obtain global object model mesh information. This global object model mesh information is used to construct a global static virtual object containing at least two static virtual objects, and the global static virtual object is a single static virtual object that includes all static virtual objects in the target game screen. Subsequently, the information processing server 104 obtains the object model network statistics information corresponding to each local virtual object in the global static virtual object from the global object model mesh information, wherein each local virtual object corresponds to each static virtual object. Further, after obtaining the object model mesh statistics information, the information processing server 104 determines the region description information of the texture location area where the lighting information of each local virtual object is to be stored based on the object model mesh statistics information, and uses the region description information to generate a global lighting map corresponding to the global object model mesh information. This global lighting map stores the lighting information of all static virtual objects in the target game screen. After generating the global illumination map, the information processing server 104 sends the generated global illumination map to the terminal device 102, as shown in step S114.
[0058] Optionally, in this embodiment, the terminal device can be a terminal device configured with a target client, which may include, but is not limited to, at least one of the following: mobile phone (such as Android phone, iOS phone, etc.), laptop computer, tablet computer, PDA, MID (Mobile Internet Devices), PAD, desktop computer, smart TV, etc. The target client can be a video client, instant messaging client, browser client, educational client, etc. The server can be a single server, a server cluster consisting of multiple servers, or a cloud server. The above is merely an example, and no limitation is made in this embodiment.
[0059] As an optional implementation method, such as Figure 2 As shown, the method for generating the above-mentioned lightmap includes:
[0060] S202, Identify at least two static virtual objects contained in the target game screen;
[0061] Optionally, in this embodiment, the target game screen can come from various online or offline games, such as online games like Multiplayer Online Battle Arena (MOBA) and First-Person Shooter (FPS), or offline games like Action-Adventure Game (AAVG) and Single-Player RPG (SPRPG). The static virtual object can be a static object within the target game screen. For example, the static virtual object can be environmental objects such as trees, rocks, and mountain walls in the game screen, or it can be objects such as buildings and vehicles (e.g., cars, trains, bicycles).
[0062] As an optional implementation, the target game screen described above can be as follows: Figure 3 As shown. The target game screen 302 includes multiple static objects, such as... Figure 3 Sphere 304, etc. Furthermore, the aforementioned multiple static objects are illuminated by light emitted from at least one light source. For each static object, the illumination information can be information such as the refraction and diffuse reflection of light emitted from the light source as it strikes the static object.
[0063] S204, merge the object model mesh information corresponding to at least two static virtual objects to obtain global object model mesh information, wherein the global object model mesh information is used to construct a global static virtual object containing at least two static virtual objects;
[0064] Optionally, in this embodiment, the object model mesh information may be, but is not limited to, information about the triangular mesh used to indicate the surface geometry of each static virtual object. For example, the object model mesh information may be the vertices included in each triangle in the triangular mesh of the surface geometry of each static virtual object, or the normal corresponding to each triangle in the triangular mesh of the surface geometry of each static virtual object. The global static virtual object may be, but is not limited to, a single static virtual object obtained by merging the multiple static virtual objects. Further, the global object model mesh information may be information about the triangular mesh used to indicate the surface geometry of the global static virtual object, and the global object model mesh information may be, but is not limited to, obtained by transforming or merging the object model mesh information of the multiple static virtual objects.
[0065] S206, Obtain the object model grid statistics information corresponding to each local virtual object in the global static virtual object from the global object model grid information, wherein each local virtual object corresponds to each static virtual object respectively;
[0066] Optionally, in this embodiment, the aforementioned local virtual object can be a virtual object existing in a local region of the aforementioned global static virtual object and corresponding to each of the static virtual objects. The aforementioned object model mesh statistics can be, but are not limited to, information calculated based on the aforementioned global object model mesh information, used to indicate the spatial size of the object space corresponding to each static virtual object. Here, the object space is used to indicate the virtual space storing the aforementioned static virtual objects. It should be noted that the spatial shape of the object space corresponding to different static virtual objects is the same, but the spatial size can be different.
[0067] S208, Based on the object model mesh statistics, determine the region description information of the texture location area to be stored for the lighting information of each local virtual object. Among them, the texture location areas corresponding to different local virtual objects have the same region graphics but different region sizes.
[0068] Optionally, in this embodiment, the aforementioned lighting information may include, but is not limited to, information on the reflection, refraction, and shadow effects of light illuminating the aforementioned local virtual objects. The aforementioned texture location region may include, but is not limited to, the region where the lighting information of each local virtual object is stored in the global lighting map. Here, the global lighting map refers to a lighting map that stores the lighting information corresponding to all local virtual objects in the global static virtual object. The aforementioned region description information may include, but is not limited to, information describing the size and position of the aforementioned texture location region, such as the size of the texture location region and its position information (e.g., coordinates) in the lighting map. It should be noted that the object space used to store the static virtual objects may include, but is not limited to, adjusting the size of the region description information of the original texture region of each local virtual object to obtain the region description information of the texture location region where the lighting information of each local virtual object is to be stored. The aforementioned original texture area is the area in the original light map where the lighting information of a single local virtual object is stored. Here, the original light map refers to a light map with a standard size that stores the lighting information of a single local virtual object. The standard size here refers to the same size as the global light map.
[0069] S210 generates a global illumination map corresponding to the global object model mesh information using region description information.
[0070] Optionally, in this embodiment, the global illumination map may be, but is not limited to, a illumination map corresponding to the global static virtual object, storing the illumination information of multiple local virtual objects included in the global static virtual object. Further, the global illumination map may be, but is not limited to, based on the aforementioned region description information, determining the corresponding static virtual object and its illumination information stored in each local region within the map, and mapping the illumination information of each local virtual object to the corresponding map location region.
[0071] According to the embodiments provided in this application, after determining at least two static virtual objects contained in the target game screen, the object model mesh information corresponding to each of the at least two static virtual objects is merged to obtain global object model mesh information. This global object model mesh information is used to construct a global static virtual object containing at least two static virtual objects. The object model mesh statistical information corresponding to each local virtual object in the global static virtual object is obtained from the global object model mesh information, wherein each local virtual object corresponds to each static virtual object. Based on the obtained object model mesh statistical information, the region description information of the texture location area to be stored for the lighting information of each local virtual object is determined, and a global lighting texture corresponding to the global object model mesh information is generated using the region description information. The texture location areas corresponding to the different local virtual objects have the same region graphics but different region sizes. By merging multiple static virtual objects to obtain a global static virtual object, and extracting the object model mesh statistics of each local virtual object in the global static virtual object from the global object model mesh information, the region description information of the texture location area where the lighting information of each local virtual object should be stored can be determined based on the obtained object model mesh statistics. This enables the determination of the texture location area of the lighting information of each local virtual object in the global lighting map based on the global static virtual object obtained by merging multiple static virtual objects. This avoids the problem of wasted space caused by a large amount of unused storage space in the generated lighting map, and achieves the goal of flexibly changing the storage location of the virtual object model in the lighting map during the lighting map generation process, thereby improving the space utilization of the generated lighting map. This solves the technical problem of low space utilization of lighting maps caused by the scattered original display positions of virtual object models.
[0072] As an optional implementation, based on the object model mesh statistics, the region description information for the texture location area to be stored for the lighting information of each local virtual object includes:
[0073] S1, each local virtual object is assigned an object space that matches the object model mesh statistics. Different object spaces have the same spatial shape but different spatial dimensions. The spatial dimensions are linearly related to the object model mesh statistics.
[0074] Optionally, in this embodiment, the object space can be a geometric shape with the same shape but different sizes, such as a square. The spatial size of the object space is linearly related to the object model mesh statistics. For example, the spatial size of the object space can be the same value as the object model mesh statistics, or a value that is an integer multiple of the object model mesh statistics. It should be noted that the object space has a one-to-one correspondence with each of the local virtual objects, and one local virtual object corresponds to one object space.
[0075] S2, map each object space according to its spatial size to obtain the region description information of the local virtual object's lighting information in the texture location area of the global light map. Each object space is mapped to a texture location area in the global light map, and the region description information includes the region size and region offset.
[0076] Optionally, in this embodiment, the mapping operation described above may, but is not limited to, mapping each object space to a local region in the global illumination map. Here, the local region refers to the area used to store the lighting information of the local virtual object matching the object space. The region size is the size information of the texture location region, and the region offset may, but is not limited to, two-dimensional coordinate information indicating the position of the texture location region in the global illumination map. Further, the region size of the texture location region may, but is not limited to, be obtained by linearly scaling the spatial size of the object space. For example, assuming the length and width of the object space are both 4, the length and width of the texture location region can be values obtained by scaling the length and width of the object space by the same scaling ratio (e.g., enlarging the length and width of the object space by a factor of four).
[0077] The embodiments provided in this application, after allocating an object space matching the object model mesh statistics for each local virtual object, map each object space according to its spatial size to obtain the region description information of the local virtual object's lighting information in the global illumination map's texture location area. This allows for dynamic adjustment of the local virtual object's lighting information in the global illumination map's texture location area by changing the object space and its size, through allocating object space to the local virtual object. Furthermore, the region description information of the texture location area can be obtained through a relatively simple mapping operation. This not only improves the generation efficiency of the global illumination map but also enhances the storage flexibility of the lighting information of each local virtual object during the global illumination map generation process, contributing to the generation of global illumination maps with higher space utilization.
[0078] As an optional implementation, assigning an object space to each local virtual object that matches the object model mesh statistics includes one of the following:
[0079] S1, use the object model mesh statistics as the spatial description parameter of the object space; assign object spaces to local virtual objects that match the spatial description parameters; or...
[0080] S2, linearly scale the object model mesh statistics to obtain the spatial description parameters of the object space; allocate object space matching the spatial description parameters to local virtual objects.
[0081] Optionally, in this embodiment, the spatial description parameter of the object space can be the spatial size of the object space, and the spatial description parameter of the object space can be the same value as the object model mesh statistics, or it can be a value obtained by linearly scaling the object model mesh statistics. For example, assuming the object model mesh statistics are 6, the spatial description parameter of the object space can be 6, or it can be a value obtained by linearly scaling 6, such as 18 obtained by multiplying 6 by three, or 1.2 obtained by shrinking it to one-fifth of 6.
[0082] Through the embodiments provided in this application, when allocating an object space that matches the object model mesh statistics for each local virtual object, the object model mesh statistics can be used as the spatial description parameter of the object space, thereby allocating an object space that matches the spatial description parameter to the local virtual object; alternatively, the object model mesh statistics can be linearly scaled to obtain the spatial description parameter of the object space, thereby allocating an object space that matches the spatial description parameter to the local virtual object, thus improving the flexibility of object space allocation and realizing the dynamic adjustment of the spatial information of the object space.
[0083] As an optional implementation, each object space is mapped separately according to its spatial dimensions to obtain the region description information of the local virtual object's lighting information in the texture location area of the global lightmap, including:
[0084] S1, sort the object spaces according to their size to obtain the object space sequence;
[0085] Optionally, the sorting operation described above can be either arranging the object spaces in descending order according to their spatial dimensions, or arranging them in ascending order according to their spatial dimensions. Further, the object space sequence described above can be obtained by arranging the object spaces in ascending or descending order according to their spatial dimensions, and includes a sequence of all object spaces.
[0086] S2, determine the current object space sequentially from the object space sequence, and perform the following operations:
[0087] S3, adjust the spatial size of the current object space according to the mapping scaling ratio to obtain the current region size of the texture location area where the lighting information of the current local virtual object corresponding to the current object space is to be stored. The mapping scaling ratio is determined based on the texture size of the global light map and the global object space size. The global object space size is the result of summing the spatial sizes of each object space.
[0088] Optionally, the aforementioned mapping scaling ratio may be, but is not limited to, the ratio of the global lightmap's texture size to the global object space size, where the global object space size is the sum of the spatial sizes of all object spaces. The aforementioned current region size may be, but is not limited to, a value obtained by adjusting the spatial size of the current object space according to the aforementioned mapping scaling ratio.
[0089] S4. In the candidate light map that is in an idle state, assign a current candidate region that matches the current region size to the current local virtual object, and obtain the region position coordinates of the current candidate region. Here, the candidate light map in the idle state has not yet been mapped with lighting information, and the region position coordinates are used to indicate the region offset of the current candidate region in the candidate light map.
[0090] Optionally, the aforementioned candidate lightmap may be, but is not limited to, a lightmap with the same size as the generated global lightmap. The aforementioned current candidate region is a region in the candidate lightmap that has the aforementioned current region size as its region size and corresponds to the current local virtual object. The aforementioned region position coordinates are used to indicate the position information of the aforementioned current candidate region in the candidate lightmap. It should be noted that the aforementioned current candidate region is only used to indicate the position information of the lighting information of the aforementioned current local virtual object in the aforementioned candidate lightmap, and is not occupied by the lighting information of the current local virtual object. The aforementioned region position coordinates may be, but are not limited to, two-dimensional coordinates with the horizontal and vertical coordinates ranging from [0,1].
[0091] S5, where each local virtual object in the object space sequence has been assigned a candidate region in the candidate light map, the region description information of the texture position region of each local virtual object in the global light map is determined based on the region size and region position coordinates of each candidate region in the candidate light map.
[0092] Optionally, the aforementioned region description information may, but is not limited to, be obtained by linearly scaling the region size and region position coordinates of each of the aforementioned candidate regions. The linear scaling ratio here can be based on the texture size of the candidate lightmap and the texture size of the global lightmap. For example, assuming the texture size of the candidate lightmap is 1×1 and the size of the global lightmap is 4×4, then the aforementioned linear scaling ratio can be 1:4.
[0093] As an optional implementation, the process of obtaining the above-mentioned area description information can be as follows: Figures 4 to 6 As shown. The object space sequence obtained by arranging the various object spaces in descending order of their spatial dimensions is as follows. Figure 4 As shown, the object space sequence includes object space 402, object space 404, object space 406, and object space 408. The sum of the spatial dimensions of each object space is 6, so the mapping scaling ratio is 6:1. After adjusting the spatial dimensions of the above object spaces according to the mapping scaling ratio, the current region size of the texture location area where the lighting information of the current local virtual object corresponding to the current object space is to be stored is obtained. Subsequently, a current candidate region matching the current region size is assigned to the local virtual object in the candidate lighting texture, such as... Figure 5 As shown. After allocation, the remaining area in the candidate lightmap can be divided into two regions. This division can be vertical or horizontal, with the vertical division shown below. Figure 5As shown. The remaining area in the vertically sliced candidate lightmap is divided into a left region 502 and a right region 504. The next object space after the current object space can be assigned to either the left region 502 or the right region 504. Further, the candidate lightmap after all object spaces have been assigned to the candidate lightmap can be as follows. Figure 6 As shown. Based on the region size and region position coordinates of each candidate region in the candidate lightmap, the region description information of the texture position region of each local virtual object in the global lightmap can be determined. For example, Figure 6 In object space 602 and object space 604 Figure 6 The region description information in the candidate lighting maps shown are 0.25, (0.125, 0.375) and 0.25, (0.375, 0.375), respectively.
[0094] Through the embodiments provided in this application, each object space is sorted according to its spatial size to obtain an object space sequence. Then, the current object space is determined sequentially from the object space sequence, and the spatial size of the current object space is adjusted according to the mapping scaling ratio to obtain the current region size of the texture location area where the lighting information of the current local virtual object corresponding to the current object space is to be stored. In the candidate lighting map that is in an idle state, a current candidate region matching the current region size is assigned to the current local virtual object, and the region position coordinates of the current candidate region are obtained. Thus, when the local virtual objects corresponding to each object space in the object space sequence have been assigned candidate regions in the candidate lighting map, the region description information of the texture location area of each local virtual object in the global lighting map is determined based on the region size and region position coordinates of each candidate region in the candidate lighting map. In this way, the region information of each local virtual object in the candidate lighting map can be changed by adjusting the size of the object space, thereby flexibly changing the region description information of the texture location area where the lighting information of each local virtual object is to be stored in the global lighting map, so as to improve the space utilization of the global lighting map.
[0095] As an optional implementation, based on the region size and region position coordinates of each candidate region in the candidate lightmap, the region description information of the texture position region of each local virtual object in the global lightmap is determined, including:
[0096] S1, obtain the region mapping rate of the candidate light map;
[0097] Optionally, in this embodiment, the aforementioned region mapping rate is used to indicate the proportion of the candidate region in the candidate lightmap, rather than a value indicating the occupancy of the global lightmap. For example, Figure 6The region mapping rate of the candidate lightmap shown is 62.5%.
[0098] S2, when the region mapping rate reaches the preset condition, the candidate light map is used as the global light map, and the region size and region position coordinates of each candidate region in the candidate light map are used as the region description information of the texture position region of each local virtual object in the global light map.
[0099] S3, if the region mapping rate does not meet the preset conditions, adjust the region position coordinates of each candidate region in the candidate light map until the region mapping rate of the adjusted candidate light map meets the preset conditions.
[0100] Optionally, the aforementioned preset conditions may be, but are not limited to, a preset threshold range for the region mapping rate, such as [75%, 95%], etc. Further, if the aforementioned region mapping rate does not meet the preset conditions, the positions of each candidate region in the candidate lightmap can be moved to reduce the number of unassigned regions in the candidate lightmap until the region mapping rate meets the preset conditions.
[0101] As an optional implementation, if the region mapping rate does not meet the mapping conditions, the candidate lightmaps at the corresponding positions of the candidate regions that have not been adjusted can be used as follows: Figure 7 As shown, the candidate lightmap obtained by adjusting the corresponding position of the candidate region can be as follows: Figure 8 As shown. By Figure 7 and Figure 8 As shown in the two types of light maps, the region mapping rate of the candidate light map obtained by adjusting the corresponding position of the candidate region is significantly higher than that of the candidate light map whose corresponding position of the candidate region is not adjusted.
[0102] Through the embodiments provided in this application, after obtaining the region mapping rate of the candidate light map, if the region mapping rate reaches a preset condition, the candidate light map is used as the global light map, and the region size and region position coordinates of each candidate region in the candidate light map are used as the region description information of the texture position region of each local virtual object in the global light map; if the region mapping rate does not reach the preset condition, the region position coordinates of each candidate region in the candidate light map are adjusted until the region mapping rate of the adjusted candidate light map reaches the preset condition. In this way, the region mapping rate of the candidate light map can be improved by adjusting the position of the candidate regions in the candidate light map, thereby improving the space utilization of the global light map and avoiding the problem that the space utilization of the global light map is low due to the insufficient concentration of the storage area of the lighting information of static virtual objects in the light map.
[0103] As an optional implementation method, such as Figure 9As shown, the object model mesh information corresponding to at least two static virtual objects is merged to obtain the global object model mesh information, which includes:
[0104] S902, merge the object model mesh vertices corresponding to at least two static virtual objects to obtain a vertex set, and store the vertex set in the vertex list;
[0105] Optionally, the vertices of the object model mesh mentioned above may be, but are not limited to, the vertices of the triangular mesh that constitute the surface geometry of each static virtual object. The merging process mentioned above may be, but is not limited to, merging the object model mesh vertices of each static virtual object into a vertex set. The vertex list mentioned above may be, but is not limited to, a list storing the correspondence between the static virtual objects and their corresponding object model mesh vertices.
[0106] S904, merge the object model grid indices corresponding to at least two static virtual objects to obtain an index merge array;
[0107] Optionally, the aforementioned object model mesh index may be, but is not limited to, an identifier used to indicate the multiple triangular meshes included in the surface geometry of each static virtual object. The aforementioned merged index array may be a collection including the object model mesh indices corresponding to all static virtual objects.
[0108] S906, transform the normal vectors of the object model mesh corresponding to at least two static virtual objects using the normal transformation matrix to obtain normal transformation vectors; S908, merge the normal transformation vectors to obtain a normal transformation vector set; S910, store the normal transformation vector set in the normal list.
[0109] Optionally, the aforementioned normal transformation matrix can be determined based on the geometry of each static virtual object and its position on the target game screen. Further, the aforementioned normal transformation matrix can be a matrix used to transform the normal vectors of the object model mesh corresponding to each static virtual object into vectors in the same coordinate system. The aforementioned normal transformation vector set can be a collection including the normal transformation vectors of the object model mesh corresponding to all static virtual objects. The aforementioned normal list can be, but is not limited to, a list used to store the correspondence between each static virtual object and the normal transformation vectors in the normal transformation vector set.
[0110] S912 determines the global object model mesh information based on the vertex list, the index merge array, and the normal list.
[0111] Optionally, the aforementioned global object model mesh information may include, but is not limited to, all object model mesh vertices in the vertex list, all object model mesh indices in the index merge array, and all normal transformation vectors in the normal transformation vector set in the normal list.
[0112] Through the embodiments provided in this application, in the process of obtaining global object model mesh information, the vertices of the object model mesh corresponding to at least two static virtual objects are merged to obtain a vertex set, and the vertex set is stored in a vertex list; the indices of the object model mesh corresponding to at least two static virtual objects are merged to obtain an index merge array; the normal vectors of the object model mesh corresponding to at least two static virtual objects are transformed by the normal transformation matrix to obtain normal transformation vectors, the normal transformation vectors are merged to obtain a normal transformation vector set, and the normal transformation vector set is stored in a normal list. Thus, the global object model mesh information can be determined based on the vertex list, the index merge array, and the normal list, thereby achieving the effect of merging multiple static virtual objects into a single global static virtual object, reducing the operational complexity and computational load in the lightmap generation process, and improving the computational efficiency of lightmaps.
[0113] As an optional implementation, when merging the object model grid indices corresponding to at least two static virtual objects to obtain an index merge array, one of the following is also included:
[0114] S1, count the number of meshes in the object model mesh corresponding to each local virtual object in the index merging array to obtain the object model mesh statistics for each local virtual object; or,
[0115] S2, calculate the square root of the grid area of the object model grid corresponding to each local virtual object in the index merge array, and obtain the statistical information of the object model grid corresponding to each local virtual object.
[0116] Optionally, in this embodiment, the object model mesh statistics can be either the number of meshes corresponding to each local virtual object, or the square root of the mesh area of each local virtual object. It should be noted that the above-mentioned mesh number statistics refer to the total number of all object model meshes corresponding to each local virtual object, and the above-mentioned square root of the mesh area refers to the square root of the total area of all object model meshes corresponding to each local virtual object.
[0117] Through the embodiments provided in this application, when merging the object model mesh indices corresponding to at least two static virtual objects to obtain an index merge array, the number of meshes corresponding to the object model mesh of each local virtual object in the index merge array can be counted separately to obtain the object model mesh statistics of each local virtual object; alternatively, the square root of the mesh area of the object model mesh corresponding to each local virtual object in the index merge array can be counted separately to obtain the object model mesh statistics of each local virtual object. Thus, the object model mesh statistics of each local virtual object can be determined based on different types of data related to the object model mesh of each local virtual object, improving the flexibility and accuracy of the calculation of object model mesh statistics.
[0118] As an optional implementation, generating a global illumination map corresponding to the global object model mesh information using region description information includes:
[0119] S1, hide at least two static virtual objects, and retain the global static virtual object created using the global object model mesh information;
[0120] Optionally, the aforementioned hiding operation may, but is not limited to, setting at least two of the aforementioned static virtual objects to an invisible state. Here, "invisible" means they cannot be directly observed, rather than deleting each static virtual object. Further, the aforementioned retaining operation may, but is not limited to, setting the aforementioned global static virtual object to a visible state.
[0121] S2 adds the lighting information of each local virtual object in the global static virtual object to the texture location area corresponding to the region description information to generate the global lighting map of the global static virtual object.
[0122] Optionally, the above-mentioned addition operation may, but is not limited to, storing the lighting information of each local virtual object in each pixel included in the texture location area.
[0123] The embodiments provided in this application hide at least two static virtual objects, retain the global static virtual object created using the global object model mesh information, and add the lighting information of each local virtual object in the global static virtual object to the texture location area corresponding to the region description information, thereby generating a global lighting map of the global static virtual object. This achieves the goal of storing the lighting information of all static virtual objects in the target game screen in a single global lighting map, reducing the computational load of the lighting map and improving the generation efficiency of the lighting map.
[0124] As an optional implementation, after generating a global illumination map corresponding to the global object model mesh information using region description information, the method further includes:
[0125] S1, Delete the global static virtual object and display at least two static virtual objects;
[0126] S2, determine the current static virtual object from at least two static virtual objects, and perform the following operations on each:
[0127] S3 configures a global lightmap for the current static virtual object;
[0128] S4 assigns the lighting information stored in the texture location area that matches the current static virtual object in the global illumination map to the current static virtual object for rendering.
[0129] Optionally, displaying at least two static virtual objects can be achieved, but is not limited to, by setting at least two static virtual objects to a visible state. The configuration operation described above can, but is not limited to, setting the lightmap corresponding to the current static virtual object to the aforementioned global lightmap. Further, the rendering operation described above can, but is not limited to, obtaining the lighting information stored in the texture location region of the global lightmap that matches the current static virtual object, and then assigning the lighting information to the shader corresponding to the current static virtual object.
[0130] As an optional implementation method, the application process of global illumination mapping can be as follows: Figure 10 Steps S1002 to S1016 are shown below. After obtaining a list of static virtual objects containing multiple static virtual objects, the i-th static virtual object in the list is taken as the current static virtual object. It should be noted that i indicates the position of the current static virtual object in the list, and i is a natural number greater than 1 and less than N, where N is the total number of static virtual objects in the list. After determining the current static virtual object, it is determined whether i is greater than the list length, where the list length is N. If i is greater than the list length, the updated list of static virtual objects is output, which includes all rendered static virtual objects. If i is less than or equal to the list length, the current static virtual object is set to visible, and a global illumination map is configured for it. Lighting information stored in the area of the global illumination map that matches the current static virtual object is collected, and the collected lighting information is assigned to the current static virtual object to complete the rendering of the current static virtual object. Subsequently, the value of i is incremented by one, and the current static virtual object is redefined.
[0131] According to the embodiments provided in this application, after generating a global illumination map, a global static virtual object is deleted, and at least two static virtual objects are displayed. The current static virtual object is determined from the at least two static virtual objects, and the following operations are performed respectively: a global illumination map is configured for the current static virtual object, and the lighting information stored in the map position area that matches the current static virtual object in the global illumination map is assigned to the current static virtual object to render the current static virtual object. This allows the global illumination map with higher space utilization to be applied to each static virtual object, thereby improving the lighting effect of each static virtual object.
[0132] Specific combination Figure 11 To illustrate the process of generating lightmaps for multiple static objects contained in a game screen in an online game, the embodiments of this application are described below:
[0133] S1102, set the lighting map parameters and acquire the target game image; these lighting map parameters include the fill rate, resolution, maximum size, etc., which are set by editing the corresponding parameter editing area. Figure 12 As shown; after acquiring the target game screen, the lightmap generation function can be enabled via the toolbar in the lightmap generation software interface, such as... Figure 13 As shown, after clicking the toolbar, you can access... Figure 13 (a) Jump to Figure 13 (b) Select Figure 13 (b) The baking option in the toolbar can enable the generation of lightmaps.
[0134] S1104, determine at least two static virtual objects contained in the target game screen; here, static virtual objects are all static three-dimensional objects in the target game screen.
[0135] S1106, merge at least two static virtual objects to obtain a global static virtual object; the global static virtual object is a single static 3D object that includes all static virtual objects. The merging operation includes: S11062, merging the vertices corresponding to at least two static virtual objects to obtain a vertex list; the vertices are the vertices of the triangular mesh that constitute the surface geometry of each static virtual object, and the vertex list includes the vertices corresponding to all static virtual objects; S11064, merging the object model mesh indices corresponding to at least two static virtual objects to obtain an index merge array; the object model mesh index is the triangular mesh identifier corresponding to the triangular mesh of the surface geometry of each static virtual object, and the index merge array includes the object model mesh indices corresponding to all static virtual objects; S11066, merging the normal vectors corresponding to at least two static virtual objects to obtain a normal list. The above merging process is as follows: Figure 14 As shown in the pseudocode, the above normal vectors are the normal vectors corresponding to the normals of the triangular meshes of the surface geometry of each static virtual object. The merging process of the normal vectors includes transforming the normal vectors using a normal transformation matrix to obtain normal transformation vectors. Here, the normal transformation matrix is determined according to the position of the static virtual object in the target game screen, and the normal list includes the normal transformation vectors of all static virtual objects. A new static virtual object is created, and the above vertex list, index merging array, and normal list are assigned to the newly created static virtual object to obtain the above global static virtual object. The process of determining the above global static virtual object is as follows: Figure 15 The pseudocode is shown in the figure.
[0136] S1108, Determine the global object model mesh information based on the vertex list, the index merge array, and the normal list; the global object model mesh information includes: all vertices in the vertex list and their correspondence with each static virtual object, all object model mesh indices in the index merge array and their correspondence with each static virtual object, and all normal transformation vectors in the normal list and their correspondence with each static virtual object.
[0137] S1110: Obtain the object model mesh statistics of each local virtual object in the global static virtual object from the global object model mesh information; the local virtual object has a one-to-one correspondence with each static virtual object, and the object model mesh statistics of each local virtual object are obtained by taking the square root of the sum of the areas of all triangular meshes corresponding to the local virtual object in the global object model mesh information.
[0138] S1112, Based on the object model mesh statistics, determine the region information of the texture location area where the lighting information of each local virtual object needs to be stored; the process of determining the region information of the texture location area where the lighting information of each local virtual object needs to be stored is as follows: Figure 16 As shown in the pseudocode, after allocating an object space that matches the object model mesh statistics for each local virtual object, each object space is mapped according to its spatial size. Based on the mapping result, the region information of the corresponding texture position area in the candidate light map for each local virtual object is updated, thus obtaining the region information of the texture position area where the lighting information of each local virtual object is to be stored. The texture position area is the position area in the global light map where the lighting information of each local virtual object is to be stored. The region information includes the region size of each texture position area and two-dimensional coordinates used to indicate the position of the texture position area in the global light map. The horizontal and vertical coordinates of the two-dimensional coordinates are both in the range of [0,1].
[0139] S1114, Based on the region description information, generate a global light map corresponding to the global object model information; hide at least two static virtual objects, retain the global static virtual object, and store the lighting information corresponding to each local virtual object in the global static virtual object in the global light map.
[0140] S1116, Apply the global illumination map to at least two static virtual objects; the application process of the global illumination map is as follows: Figure 17 As shown in the pseudocode, after deleting the global static virtual object, at least two static virtual objects are made visible; a global lightmap is configured for each static virtual object, and the lighting information stored in the texture location area corresponding to each local virtual object in the global lightmap is extracted sequentially. The extracted lighting information is then assigned to the corresponding static virtual object, completing the rendering of the static virtual objects; after completing the above rendering operations, the rendered at least two static virtual objects are saved, and the saving process is as follows: Figure 18 The pseudocode is shown in the figure.
[0141] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.
[0142] According to another aspect of the embodiments of this application, an apparatus for generating a lightmap for implementing a method for generating a lightmap is also provided. For example... Figure 19 As shown, the device includes:
[0143] The first determining unit 1902 is used to determine at least two static virtual objects contained in the target game screen;
[0144] Merging unit 1904 is used to merge the object model mesh information corresponding to at least two static virtual objects to obtain global object model mesh information, wherein the global object model mesh information is used to construct a global static virtual object containing at least two static virtual objects.
[0145] The acquisition unit 1906 is used to acquire the object model grid statistics of each local virtual object in the global static virtual object from the global object model grid information, wherein each local virtual object corresponds to each static virtual object.
[0146] The second determining unit 1908 is used to determine the region description information of the texture location area to be stored for the lighting information of each local virtual object based on the object model mesh statistical information. The texture location areas corresponding to different local virtual objects have the same region graphics but different region sizes.
[0147] Generation unit 1910 is used to generate a global illumination map corresponding to the global object model mesh information using region description information.
[0148] Optionally, the embodiments in this solution may be, but are not limited to, the embodiments of the reference method, which will not be described in detail here.
[0149] As an optional solution, the second determining unit 1908 includes:
[0150] The allocation module is used to allocate an object space that matches the object model mesh statistics for each local virtual object. Different object spaces have the same spatial shape but different spatial dimensions, and the spatial dimensions are linearly related to the object model mesh statistics.
[0151] The mapping module is used to map each object space according to its spatial size to obtain the region description information of the local virtual object's lighting information in the texture location area of the global light map. Each object space is mapped to a texture location area in the global light map, and the region description information includes the region size and region offset.
[0152] Optionally, the embodiments in this solution may be, but are not limited to, the embodiments of the reference method, which will not be described in detail here.
[0153] As an optional solution, the allocation module includes one of the following:
[0154] The processing submodule is used to use the object model mesh statistics as spatial description parameters of the object space.
[0155] The first allocation submodule is used to allocate object space to local virtual objects that matches the space description parameters;
[0156] The scaling submodule is used to linearly scale the object model mesh statistics to obtain the spatial description parameters of the object space.
[0157] The second allocation submodule is used to allocate object space to local virtual objects that matches the space description parameters.
[0158] Optionally, the embodiments in this solution may be, but are not limited to, the embodiments of the reference method, which will not be described in detail here.
[0159] As an optional solution, the mapping module includes:
[0160] The sorting submodule is used to sort the various object spaces according to their spatial dimensions to obtain a sequence of object spaces;
[0161] The determination submodule is used to sequentially determine the current object space from the object space sequence and perform the following operations: Adjust the spatial size of the current object space according to the mapping scaling ratio to obtain the current region size of the texture location area where the lighting information of the current local virtual object corresponding to the current object space is to be stored. The mapping scaling ratio is determined based on the texture size of the global lightmap and the global object space size, which is the sum of the spatial sizes of each object space. In the idle candidate lightmap, assign a current candidate region matching the current region size to the current local virtual object and obtain the region position coordinates of the current candidate region. The candidate lightmap in the idle state has not yet been mapped with lighting information, and the region position coordinates are used to indicate the region offset of the current candidate region in the candidate lightmap. When the local virtual objects corresponding to each object space in the object space sequence have all been assigned candidate regions in the candidate lightmap, determine the region description information of the texture location area of each local virtual object in the global lightmap based on the region size and region position coordinates of each candidate region in the candidate lightmap.
[0162] Optionally, the embodiments in this solution may be, but are not limited to, the embodiments of the reference method, which will not be described in detail here.
[0163] As an optional approach, the determination submodule is also used to: obtain the region mapping rate of the candidate light map; if the region mapping rate meets the preset conditions, use the candidate light map as the global light map, and use the region size and region position coordinates of each candidate region in the candidate light map as the region description information of the texture position region of each local virtual object in the global light map; if the region mapping rate does not meet the preset conditions, adjust the region position coordinates of each candidate region in the candidate light map until the region mapping rate of the adjusted candidate light map meets the preset conditions.
[0164] Optionally, the embodiments in this solution may be, but are not limited to, the embodiments of the reference method, which will not be described in detail here.
[0165] As an optional solution, merging unit 1904 includes:
[0166] The first merging module is used to merge the object model mesh vertices corresponding to at least two static virtual objects to obtain a vertex set, and store the vertex set in the vertex list;
[0167] The second merging module is used to merge the object model grid indices corresponding to at least two static virtual objects to obtain an index merge array;
[0168] The transformation module is used to transform the normal vectors of the object model mesh corresponding to at least two static virtual objects through the normal transformation matrix to obtain normal transformation vectors; merge the normal transformation vectors to obtain a normal transformation vector set; and store the normal transformation vector set into a normal list.
[0169] The determination module is used to determine the global object model mesh information based on the vertex list, the index merge array, and the normal list.
[0170] Optionally, the embodiments in this solution may be, but are not limited to, the embodiments of the reference method, which will not be described in detail here.
[0171] As an optional solution, the second merging module also includes one of the following:
[0172] The first statistics submodule is used to separately count the number of grids in the object model grid corresponding to each local virtual object in the index merge array, and obtain the object model grid statistics information corresponding to each local virtual object; or the second statistics submodule is used to separately count the square root of the grid area of the object model grid corresponding to each local virtual object in the index merge array, and obtain the object model grid statistics information corresponding to each local virtual object.
[0173] Optionally, the embodiments in this solution may be, but are not limited to, the embodiments of the reference method, which will not be described in detail here.
[0174] As an optional solution, the generation unit 1910 includes:
[0175] The processing module is used to hide at least two static virtual objects and retain the global static virtual object created using the global object model mesh information;
[0176] The generation module is used to add the lighting information of each local virtual object in the global static virtual object to the texture location area corresponding to the region description information, so as to generate the global lighting map of the global static virtual object.
[0177] Optionally, the embodiments in this solution may be, but are not limited to, the embodiments of the reference method, which will not be described in detail here.
[0178] As an optional solution, the above-mentioned device further includes:
[0179] The first processing unit is used to delete global static virtual objects and display at least two static virtual objects;
[0180] The third determining unit is used to determine the current static virtual object from at least two static virtual objects, and perform the following operations respectively: configure a global illumination map for the current static virtual object; assign the lighting information stored in the map position area that matches the current static virtual object in the global illumination map to the current static virtual object for rendering.
[0181] According to one aspect of this application, a computer-readable storage medium is provided, from which a processor of a computer device reads computer instructions, and the processor executes the computer instructions, causing the computer device to perform the method provided in various alternative implementations of the above-described method for generating a lightmap.
[0182] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0183] S1, Identify at least two static virtual objects contained in the target game screen;
[0184] S2, merge the object model mesh information corresponding to at least two static virtual objects to obtain global object model mesh information, wherein the global object model mesh information is used to construct a global static virtual object containing at least two static virtual objects;
[0185] S3, obtain the object model grid statistics of each local virtual object in the global static virtual object from the global object model grid information, wherein each local virtual object corresponds to each static virtual object respectively;
[0186] S4. Based on the object model mesh statistics, determine the region description information of the texture location area to be stored for the lighting information of each local virtual object. Among them, the texture location areas corresponding to different local virtual objects have the same region graphics but different region sizes.
[0187] S5 generates a global illumination map corresponding to the global object model mesh information using region description information.
[0188] According to one aspect of this application, a computer program product is provided, the computer program product comprising a computer program / instructions containing program code for performing the above-described method for generating lightmaps.
[0189] According to another aspect of the embodiments of this application, an electronic device for implementing the above-described method for generating lightmaps is also provided. For example... Figure 20 As shown, the electronic device includes a memory 2002 and a processor 2004. The memory 2002 stores a computer program, and the processor 2004 is configured to execute the steps in any of the above method embodiments via the computer program.
[0190] Optionally, in this embodiment, the aforementioned electronic device may be located in at least one of a plurality of network devices in a computer network.
[0191] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0192] S1, Identify at least two static virtual objects contained in the target game screen;
[0193] S2, merge the object model mesh information corresponding to at least two static virtual objects to obtain global object model mesh information, wherein the global object model mesh information is used to construct a global static virtual object containing at least two static virtual objects;
[0194] S3, obtain the object model grid statistics of each local virtual object in the global static virtual object from the global object model grid information, wherein each local virtual object corresponds to each static virtual object respectively;
[0195] S4. Based on the object model mesh statistics, determine the region description information of the texture location area to be stored for the lighting information of each local virtual object. Among them, the texture location areas corresponding to different local virtual objects have the same region graphics but different region sizes.
[0196] S5 generates a global illumination map corresponding to the global object model mesh information using region description information.
[0197] Alternatively, as those skilled in the art will understand, Figure 20 The structure shown is for illustrative purposes only. Electronic devices can also be smartphones (such as Android phones, iOS phones, etc.), tablets, PDAs, mobile internet devices (MIDs), PADs, and other terminal devices. Figure 20 This does not limit the structure of the aforementioned electronic devices. For example, the electronic device may also include components that are more... Figure 20 The more or fewer components shown (such as network interfaces, etc.), or having the same Figure 20 The different configurations shown.
[0198] The memory 2002 can be used to store software programs and modules, such as the program instructions / modules corresponding to the lightmap generation method and apparatus in this embodiment. The processor 2004 executes various functional applications and data processing by running the software programs and modules stored in the memory 2002, thereby realizing the aforementioned lightmap generation method. The memory 2002 may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 2002 may further include memory remotely located relative to the processor 2004, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof. Specifically, the memory 2002 may be used, but is not limited to, to store information such as at least two static virtual objects in the target game screen. As an example, such as... Figure 20 As shown, the memory 2002 may include, but is not limited to, the first determining unit 1902, merging unit 1904, acquiring unit 1906, second determining unit 1908, and generating unit 1910 in the above-mentioned lightmap generation apparatus. Furthermore, the memory 2002 may also include, but is not limited to, other module units in the above-mentioned lightmap generation apparatus, which will not be elaborated upon in this example.
[0199] Optionally, the aforementioned transmission device 2006 is used to receive or send data via a network. Specific examples of the network may include wired and wireless networks. In one example, the transmission device 2006 includes a Network Interface Controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In another example, the transmission device 2006 is a Radio Frequency (RF) module used for wireless communication with the Internet.
[0200] In addition, the aforementioned electronic device also includes: a display 2008 for displaying the generation result of the aforementioned light map and a connection bus 2010 for connecting the various module components in the aforementioned electronic device.
[0201] In other embodiments, the aforementioned terminal device or server can be a node in a distributed system, wherein the distributed system can be a blockchain system, which is a distributed system formed by connecting multiple nodes through network communication. The nodes can form a point-to-point network, and any form of computing device, such as a server, terminal, or other electronic device, can become a node in the blockchain system by joining this point-to-point network.
[0202] Optionally, in embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0203] Optionally, in this embodiment, those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0204] If the integrated units in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in the aforementioned computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0205] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0206] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. The device embodiments described above are merely illustrative; for example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection between units or modules, and may be electrical or other forms.
[0207] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0208] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0209] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.
Claims
1. A method for generating a lightmap, characterized in that, include: Identify at least two static virtual objects contained in the target game screen; The object model mesh information corresponding to each of the at least two static virtual objects is merged to obtain global object model mesh information, wherein the global object model mesh information is used to construct a global static virtual object containing the at least two static virtual objects; From the global object model mesh information, obtain the object model mesh statistics information corresponding to each local virtual object in the global static virtual object, wherein each local virtual object corresponds to each static virtual object. Based on the object model mesh statistics, the region description information of the texture location area to be stored for the lighting information of each local virtual object is determined, wherein the texture location areas corresponding to different local virtual objects have the same region graphics but different region sizes; A global illumination map corresponding to the global object model mesh information is generated using the region description information.
2. The method according to claim 1, characterized in that, The region description information for determining the texture location area to be stored for the lighting information of each local virtual object based on the object model mesh statistics includes: Each local virtual object is assigned an object space that matches the object model mesh statistics, wherein different object spaces have the same spatial shape but different spatial dimensions, and the spatial dimensions are linearly related to the object model mesh statistics. Each of the object spaces is mapped according to the space size to obtain the region description information of the local virtual object's lighting information in the texture location area of the global illumination map. Each of the object spaces is mapped to a texture location area in the global illumination map, and the region description information includes region size and region offset.
3. The method according to claim 2, characterized in that, The method of allocating an object space for each of the local virtual objects to match the object model mesh statistics includes one of the following: Use the object model mesh statistics as the spatial description parameter of the object space; allocate the object space matching the spatial description parameter to the local virtual object; or The object model mesh statistics are linearly scaled to obtain the spatial description parameters of the object space; the local virtual object is then assigned an object space that matches the spatial description parameters.
4. The method according to claim 2, characterized in that, The step of mapping each of the object spaces according to the space size to obtain the region description information of the local virtual object's lighting information in the texture location area of the global illumination map includes: The object spaces are sorted according to their dimensions to obtain an object space sequence; The current object space is determined sequentially from the object space sequence, and the following operations are performed: The spatial size of the current object space is adjusted according to the mapping scaling ratio to obtain the current region size of the texture location area where the lighting information of the current local virtual object corresponding to the current object space is to be stored. The mapping scaling ratio is determined based on the texture size of the global lighting map and the global object space size. The global object space size is the result of summing the spatial sizes of each object space. In an idle candidate light map, a current candidate region matching the current region size is assigned to the current local virtual object, and the region position coordinates of the current candidate region are obtained. The candidate light map in the idle state has not yet been mapped with lighting information, and the region position coordinates are used to indicate the region offset of the current candidate region in the candidate light map. When each local virtual object in the object space sequence has been assigned a candidate region in the candidate light map, the region description information of the texture position region of each local virtual object in the global light map is determined based on the region size and region position coordinates of each candidate region in the candidate light map.
5. The method according to claim 4, characterized in that, The method of determining the region description information of the texture location region of each local virtual object in the global lightmap based on the region size and region position coordinates of each candidate region in the candidate lightmap includes: Obtain the region mapping rate of the candidate lighting map; When the region mapping rate reaches the preset condition, the candidate light map is used as the global light map, and the region size and region position coordinates of each candidate region in the candidate light map are used as the region description information of the texture position region of each local virtual object in the global light map. If the region mapping rate does not meet the preset condition, adjust the region position coordinates of each candidate region in the candidate lighting map until the region mapping rate of the adjusted candidate lighting map meets the preset condition.
6. The method according to claim 1, characterized in that, The step of merging the object model mesh information corresponding to each of the at least two static virtual objects to obtain global object model mesh information includes: Merge the object model mesh vertices corresponding to each of the at least two static virtual objects to obtain a vertex set, and store the vertex set in a vertex list; Merge the object model grid indices corresponding to each of the at least two static virtual objects to obtain an index merge array; The normal vectors of the object model mesh corresponding to each of the at least two static virtual objects are transformed by the normal transformation matrix to obtain normal transformation vectors; the normal transformation vectors are merged to obtain a normal transformation vector set; the normal transformation vector set is stored in the normal list. The global object model mesh information is determined based on the vertex list, the index merge array, and the normal list.
7. The method according to claim 6, characterized in that, When merging the object model grid indices corresponding to the at least two static virtual objects to obtain an index merge array, one of the following is also included: The number of grids in the object model mesh corresponding to each local virtual object in the index merging array is counted separately to obtain the object model mesh statistics for each local virtual object; or The square root of the grid area of the object model grid corresponding to each local virtual object in the index merging array is calculated separately to obtain the statistical information of the object model grid corresponding to each local virtual object.
8. The method according to claim 1, characterized in that, The step of generating a global illumination map corresponding to the global object model mesh information using the region description information includes: Hide the at least two static virtual objects, and retain the global static virtual object created using the global object model mesh information; The lighting information of each local virtual object in the global static virtual object is added to the texture location area corresponding to the region description information to generate the global lighting texture of the global static virtual object.
9. The method according to claim 8, characterized in that, After generating the global illumination map corresponding to the global object model mesh information using the region description information, the method further includes: Delete the global static virtual object and display the at least two static virtual objects; Determine the current static virtual object from the at least two static virtual objects, and perform the following operations respectively: Configure the global illumination map for the current static virtual object; The lighting information stored in the texture location area that matches the current static virtual object in the global illumination map is assigned to the current static virtual object for rendering.
10. An apparatus for generating a lightmap, characterized in that, The device includes: The first determining unit is used to determine at least two static virtual objects contained in the target game screen; The merging unit is used to merge the object model mesh information corresponding to each of the at least two static virtual objects to obtain global object model mesh information, wherein the global object model mesh information is used to construct a global static virtual object containing the at least two static virtual objects; The acquisition unit is used to acquire object model grid statistics information corresponding to each local virtual object in the global static virtual object from the global object model grid information, wherein each local virtual object corresponds to each static virtual object. The second determining unit is used to determine the region description information of the texture location area to be stored for the lighting information of each of the local virtual objects based on the object model mesh statistical information, wherein the texture location areas corresponding to different local virtual objects have the same region graphics but different region sizes; The generation unit is used to generate a global illumination map corresponding to the global object model mesh information using the region description information.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein the program is executed by a processor to perform the method described in any one of claims 1 to 9.
12. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the steps of the method according to any one of claims 1 to 9.
13. An electronic device comprising a memory and a processor, characterized in that, The memory stores a computer program, and the processor is configured to execute the method described in any one of claims 1 to 9 through the computer program.
