Interface rendering method, device, equipment and computer-readable storage medium
By creating preset-size texture maps in game interface rendering, combining and updating the position parameters of the target object, the problem of memory waste and dynamic maps cannot be rendered in batches is solved, and a more efficient rendering process is achieved.
Patent Information
- Application Number
- CN202111478365.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-06
- Publication Date
- 2025-08-15
- Estimated Expiration
- 2041-12-06
AI Technical Summary
In the prior art, when rendering the game interface, multiple minimaps are combined offline into large images, resulting in waste of memory resources and dynamic replaceable maps that cannot be rendered in batches, increasing the number of rendering commands.
By creating a texture map of preset size, determining the target object based on the node tree, and combining it into the texture map, updating the position parameters for rendering, filtering objects that meet the conditions for batch rendering, and dynamic maps are processed separately.
Reduces memory usage, improves rendering efficiency and batch rendering effect, and reduces the number of renderings.
Smart Images

Figure CN114241105B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to an interface rendering method, apparatus, device, and computer-readable storage medium. Background Art
[0002] With the popularity of computers and smart phones, computer games and mobile games have also entered people's lives. In order to display various interfaces or pictures in the games, it is often necessary to render pictures or texts.
[0003] In related technologies, a common solution used in games is to merge multiple small tiles into a large image offline, and then render the image or text that needs to be processed. If the small tiles to be displayed in the interface happen to be in the same large image, then these small tiles that need to be used can be batched and rendered in the same batch.
[0004] However, since this solution merges multiple small stickers offline, sometimes in the same interface, it may be necessary to display some small stickers in multiple large pictures. In order to display a small sticker, the entire large picture containing the small sticker must be loaded, which causes a waste of memory resources. Summary of the Invention
[0005] The purpose of this application is to provide an interface rendering method, device, equipment and computer-readable storage medium, which can reduce memory usage and improve rendering efficiency.
[0006] The embodiment of the present application is implemented as follows:
[0007] In one aspect of an embodiment of the present application, a method for rendering an interface is provided, comprising:
[0008] Creating a texture map, wherein the size of the texture map is a preset size;
[0009] Based on the node tree of the current interface, determine multiple target objects to be merged and rendered;
[0010] Merging each of the target objects into the texture map, and updating the position parameters of each of the target objects;
[0011] Rendering the texture map on the current interface according to the position parameters of each target object.
[0012] Optionally, determining multiple target objects to be merged and rendered based on the node tree of the current interface includes:
[0013] Traversing the node tree of the current interface and generating a rendering command on a target node of the node tree, wherein the node tree includes multiple nodes, the target node is a node in the node tree on which a rendering operation needs to be performed, and each target node points to one or more objects to be rendered;
[0014] Taking the object to be rendered pointed to by each target node as the object to be rendered;
[0015] The plurality of target objects that meet preset conditions are screened out from the objects to be rendered.
[0016] Optionally, updating the position parameters of each target object includes:
[0017] The position of each target object after being merged into the texture map is updated into the rendering command corresponding to each target object.
[0018] Optionally, rendering the texture map on the current interface according to the position parameters of each target object includes:
[0019] Execute a rendering command on a corresponding node in the node tree for each target object.
[0020] Optionally, the target object includes: a target map;
[0021] The step of merging each target object into the texture map and updating the position parameters of each target object includes:
[0022] Obtain the image path of each target map;
[0023] Loading each of the target maps into a memory, and determining the position parameters of each of the target maps merged into the texture map;
[0024] Copying each pixel in each target map to the texture map according to the position parameter;
[0025] The position parameters of each target texture are updated.
[0026] Optionally, after updating the position parameters of each second target map, the method further includes:
[0027] Update the texture of the target area on the GPU;
[0028] The target area is an area in the texture map after each of the target maps is merged into the texture map.
[0029] Optionally, the target object includes: target text;
[0030] The step of merging each target object into the texture map and updating the position parameters of each target object includes:
[0031] Copying each pixel in each target text into the texture map;
[0032] Determining the position parameters of each target text merged into the texture map;
[0033] Update the position parameters of each target text.
[0034] Optionally, the method further includes:
[0035] The objects to be rendered that do not meet the preset conditions are rendered separately.
[0036] Optionally, merging each target object into the texture map and updating a position parameter of each target object includes:
[0037] If the size of the current target object to be merged is larger than the size of the free area in the texture map, a new texture map is created;
[0038] The target object currently to be merged is merged into the new texture map, and the position parameters of the target object currently to be merged are updated.
[0039] Optionally, the texture map is rectangular.
[0040] Optionally, the position parameter is a UV coordinate.
[0041] According to a third aspect of the embodiments of the present application, an interface rendering device is provided, the interface rendering device comprising:
[0042] Create a module for creating texture maps;
[0043] A determination module is used to determine multiple target objects to be merged and rendered based on the node tree of the current interface;
[0044] A merging and updating module, configured to merge each of the target objects into the texture map and update position parameters of each of the target objects;
[0045] A rendering module is used to render the texture map on the current interface according to the position parameters of each target object.
[0046] Optionally, the determination module is used to traverse the node tree of the current interface and generate a rendering command on a target node of the node tree;
[0047] Taking the object to be rendered pointed to by each target node as the object to be rendered;
[0048] The plurality of target objects that meet preset conditions are screened out from the objects to be rendered.
[0049] Optionally, the merge update module is used to update the position of each target object after being merged into the texture map into the rendering command corresponding to each target object.
[0050] Optionally, the merging and updating module is further configured to create a new texture map if the size of the target object to be merged is larger than the size of the free area in the texture map;
[0051] The target object currently to be merged is merged into the new texture map, and the position parameters of the target object currently to be merged are updated.
[0052] Optionally, the rendering module is used to execute a rendering command on a node corresponding to each target object in the node tree.
[0053] In a third aspect of an embodiment of the present application, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the interface rendering method described in the first aspect is implemented.
[0054] According to a fourth aspect of an embodiment of the present application, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the interface rendering method described in the first aspect is implemented.
[0055] The beneficial effects of the embodiments of the present application include:
[0056] An embodiment of the present application provides an interface rendering method, which creates a texture map, determines multiple target objects to be merged and rendered based on the node tree of the current interface, then merges each target object into the texture map, and updates the position parameters of each target object. Finally, according to the position parameters of each target object, the texture map is rendered in the current interface. The size of the created texture map is set to a preset size, so that the memory occupied by the texture map can be controlled; based on the node tree of the current interface, multiple target objects to be merged and rendered are determined, so that it can be ensured that the multiple target objects are the objects to be rendered that need to be processed in the current interface frame; then each target object is merged into the texture map, and the position parameters of each target object are updated, so that the multiple target objects merged into the texture map can be rendered in the same batch; then, according to the position parameters of each target object after being merged into the texture map, the position of each target object in the texture map can be directly determined, so that each target object can be called for rendering conveniently and quickly. In this way, the effect of reducing memory usage and improving batch rendering efficiency can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.
[0058] Figure 1 A flowchart of the first interface rendering method provided in an embodiment of the present application;
[0059] Figure 2 A flowchart of the second interface rendering method provided in an embodiment of the present application;
[0060] Figure 3 A flowchart of the third interface rendering method provided in an embodiment of the present application;
[0061] Figure 4 A flowchart of the fourth interface rendering method provided in an embodiment of the present application;
[0062] Figure 5 A flowchart of the fifth interface rendering method provided in an embodiment of the present application;
[0063] Figure 6 A schematic diagram of a first game interface provided in an embodiment of the present application;
[0064] Figure 7 A flowchart of the sixth interface rendering method provided in an embodiment of the present application;
[0065] Figure 8 A schematic diagram of a second game interface provided in an embodiment of the present application;
[0066] Figure 9 A schematic diagram of the structure of an interface rendering device provided in an embodiment of the present application;
[0067] Figure 10 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0068] To make the objectives, technical solutions, and advantages of the embodiments of the present application more clear, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Generally, the components of the embodiments of the present application described and shown in the drawings herein can be arranged and designed in various different configurations.
[0069] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for protection, but merely represents selected embodiments of the present application. All other embodiments obtained by persons of ordinary skill in the art based on the embodiments in the present application without creative work are within the scope of protection of the present application.
[0070] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.
[0071] In the description of this application, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," "outer," etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings, or are the orientations or positional relationships in which the inventive product is typically placed when in use. These terms are intended only to facilitate the description of this application and simplify the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, be constructed, or operate in a specific orientation. Therefore, they should not be construed as limiting this application. Furthermore, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0072] In addition, the terms "horizontal" and "vertical" do not mean that the components must be absolutely horizontal or overhanging, but can be slightly tilted. For example, "horizontal" only means that its direction is more horizontal than "vertical", not that the structure must be completely horizontal, but can be slightly tilted.
[0073] It should also be noted that, in the description of this application, unless otherwise expressly specified or limited, the terms "disposed," "installed," "connected," and "connected" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integral connections; they can refer to mechanical connections or electrical connections; they can refer to direct connections or indirect connections through an intermediate medium; and they can refer to internal connections between two components. Those skilled in the art will understand the specific meanings of the above terms in this application based on the specific circumstances.
[0074] In order to display various interfaces or screens in games, images or text often need to be rendered. Currently, multiple small tiles are often merged offline into a large image, and then the images or text that need to be processed are rendered. However, since this solution merges multiple small tiles offline, sometimes in the same interface, it may be necessary to display some small tiles from multiple large images. In order to display a small tile, the entire large image containing the small tile must be loaded, which results in a waste of memory resources. In addition, in this solution, dynamically replaceable tiles cannot be merged into the large image. In other words, dynamically replaceable tiles cannot be batch rendered, which requires more rendering commands to complete the rendering. Dynamically replaceable tiles refer to those tiles that change or are replaced frequently in the game interface. For example, in an interface in the game, the package interface in the game is displayed, and the tiles corresponding to the items in the inventory of this package interface are dynamically replaceable.
[0075] To this end, an embodiment of the present application provides an interface rendering method. By creating a texture map, determining multiple target objects based on a node tree, and then merging each target object into the texture map for batch rendering, it is possible to reduce memory usage and improve batch rendering efficiency.
[0076] The interface rendering method in one embodiment of the present application can be run on a terminal device or a server. The terminal device can be a local terminal device. When the interface rendering method is run on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.
[0077] In an optional embodiment, various cloud applications, such as cloud games, can be run under the cloud interaction system. Taking cloud games as an example, cloud games refer to a gaming method based on cloud computing. In the cloud gaming operation mode, the operating body of the game program and the main body of the game screen presentation are separated. The storage and operation of the game display method are completed on the cloud gaming server. The role of the client device is to receive and send data and present the game screen. For example, the client device can be a display device with data transmission function close to the user side, such as a mobile terminal, TV, computer, PDA, etc.; but the terminal device for information processing is the cloud gaming server in the cloud. When playing the game, the player operates the client device to send operation instructions to the cloud gaming server. The cloud gaming server runs the game according to the operation instructions, encodes and compresses the game screen and other data, and returns it to the client device through the network. Finally, the client device decodes and outputs the game screen.
[0078] In an optional embodiment, the terminal device can be a local terminal device. Taking a game as an example, the local terminal device stores the game program and is used to present the game screen. The local terminal device is used to interact with the player through a graphical user interface, that is, conventionally downloading and installing the game program through an electronic device and running it. The local terminal device can provide the graphical user interface to the player in various ways, for example, it can be rendered and displayed on the terminal display, or provided to the player through holographic projection. For example, the local terminal device may include a display screen and a processor, the display screen is used to present the graphical user interface, the graphical user interface including the game screen, and the processor is used to run the game, generate the graphical user interface, and control the display of the graphical user interface on the display screen.
[0079] In a possible implementation, an embodiment of the present invention provides an interface rendering method for providing a graphical user interface through a first terminal device, wherein the first terminal device can be the local terminal device mentioned above, or the client device in the cloud interaction system mentioned above.
[0080] The embodiment of the present application is described by taking the interface rendering method applied in a terminal game as an example, but it does not mean that the embodiment of the present application can only be applied to interface rendering in a terminal game.
[0081] The interface rendering method provided in the embodiment of the present application is explained in detail below.
[0082] Figure 1 This is a flowchart of an interface rendering method provided by this application. This method can be applied to a computer device, which can be the aforementioned terminal device or server. Figure 1 , an embodiment of the present application provides an interface rendering method, comprising:
[0083] Step 101: Create texture maps.
[0084] Optionally, the texture map may be a blank virtual map for placing a map to be rendered.
[0085] Optionally, the shape of the texture map may be rectangular, circular, or other applicable shapes, which is not limited in the present embodiment.
[0086] Optionally, the size of the texture map is a preset size.
[0087] For example, the preset size is 2048×2048, or other sizes, which are not limited in the present embodiment.
[0088] It is worth noting that the size of the created texture map is set to the preset size, which can control the memory occupied by the texture map and avoid the problem of excessive memory usage.
[0089] Step 102: Based on the node tree of the current interface, determine multiple target objects to be merged and rendered.
[0090] Optionally, the current interface can be any frame of the game, for example, it can be a game login interface, or it can be an operation interface within the game. This embodiment of the application does not limit this.
[0091] Optionally, the node tree may include multiple nodes, the multiple nodes have a hierarchical relationship with each other, and each node may include at least one command.
[0092] Optionally, the target object may be an image or text that needs to be merged and rendered in the current interface.
[0093] Optionally, the images or texts to be combined and rendered may be images or texts stored in a local file of the terminal, or may be images or texts stored in a cloud server.
[0094] Optionally, the size of the image to be merged and rendered can be any value, and the image can also be any shape.
[0095] Optionally, the text to be merged and rendered may also be text in any text format.
[0096] In addition, the images or texts that need to be merged and rendered may be images or texts with a certain grayscale value.
[0097] It is worth noting that the multiple target objects are determined based on the node tree of the current interface, so that it can be ensured that the multiple target objects are the objects to be rendered that need to be processed in the current interface frame.
[0098] Step 103: Merge each target object into the texture map, and update the position parameters of each target object.
[0099] It's worth noting that by merging the target objects determined based on the current interface's node tree into the texture map, multiple target objects merged into the texture map can be rendered in the same batch. This reduces the number of render batches. Furthermore, updating the position parameters of each target object after merging into the texture map facilitates subsequent operations, thereby improving batch rendering efficiency.
[0100] Step 104: Render the texture map on the current interface according to the position parameters of each target object.
[0101] Rendering is the process of using software to generate an image from a model. For example, in a game, a model in a 3D scene is projected into a 2D digital image based on the set environment, lighting, materials, and rendering parameters.
[0102] It is worth noting that according to the position parameters of each target object after being merged into the texture map, the position of each target object in the texture map can be directly determined, so that each target object can be called for rendering conveniently and quickly, thereby achieving the effect of improving the efficiency of batch rendering.
[0103] In an embodiment of the present application, a texture map is created, and then based on the node tree of the current interface, multiple target objects to be merged and rendered are determined, and then each target object is merged into the texture map, and the position parameters of each target object are updated. Finally, according to the position parameters of each target object, the texture map is rendered in the current interface. Wherein, the size of the created texture map is set to a preset size, so that the memory occupied by the texture map can be controlled; based on the node tree of the current interface, multiple target objects to be merged and rendered are determined, so that it can be ensured that the multiple target objects are the objects to be rendered that need to be processed in the current interface frame; then each target object is merged into the texture map, and the position parameters of each target object are updated, so that the multiple target objects merged into the texture map can be rendered in the same batch; then, according to the position parameters of each target object after being merged into the texture map, the position of each target object in the texture map can be directly determined, so that each target object can be called for rendering conveniently and quickly. In this way, the effect of reducing memory usage and improving batch rendering efficiency can be achieved.
[0104] In one possible implementation, see Figure 2 The operation of step 102 may specifically be:
[0105] Step 1021: traverse the node tree of the current interface and generate a rendering command on the target node of the node tree.
[0106] The node tree includes multiple nodes, the target node is a node in the node tree that needs to perform a rendering operation, and each target node points to one or more objects to be rendered.
[0107] Optionally, the multiple nodes in the node tree may include at least one node that needs to perform a rendering operation, and the multiple nodes may also include multiple nodes that need to perform other operations.
[0108] Optionally, there may be a certain sequential relationship between the multiple nodes in the node tree, for example, the operation in node B may be executed only after the operation in node A is executed, and the operations in nodes C and D may be executed simultaneously after the operation in node B is executed.
[0109] It is worth noting that traversing the node tree of the current interface means searching from the first node of the node tree to the last node of the node tree in sequence to find the target node in the node tree that needs to perform the rendering operation, and generating rendering commands according to the objects to be rendered pointed to by each target node.
[0110] It is worth noting that by traversing the node tree of the current interface to determine the target node of the node tree and generating rendering commands, it can be ensured that the generated rendering commands are all rendering commands corresponding to the current interface.
[0111] Step 1022: The object to be rendered pointed to by each target node is used as the object to be rendered.
[0112] It's worth noting that since each target node is the node in the node tree that needs to be rendered, and each target node points to one or more objects to be rendered, using the objects pointed to by each target node as the objects to be rendered ensures that the objects to be rendered are all corresponding to the current interface. This eliminates the need to call or read objects to be rendered that are not related to the current interface, thereby reducing memory usage and improving rendering efficiency.
[0113] Step 1023: Filter out a plurality of target objects that meet preset conditions from the objects to be rendered.
[0114] Optionally, the preset condition can be set in advance. If any object to be rendered meets the preset condition, it indicates that the object to be rendered can be merged into the texture map. Otherwise, it indicates that the object to be rendered cannot be merged into the texture map.
[0115] For example, when the target object is an image, the preset condition may be that the size of the target object is smaller than a preset threshold. The preset threshold may be set in advance, for example, the preset threshold may be 512×512.
[0116] For example, when the target object is text, the preset condition can be: the rendering command corresponding to the target object does not overlap with the rendering command area corresponding to other target objects. The preset condition can also be: the rendering command corresponding to the target object is blocked by the same most recent rendering command.
[0117] It is worth noting that, since the size or other features of each object to be rendered are different, by screening out multiple target objects that meet preset conditions among the objects to be rendered, those objects to be rendered that cannot be merged into the texture map can be excluded.
[0118] It is worth noting that the multiple target objects screened out all meet the preset conditions, that is, the multiple target objects can be merged into the texture map, so the number of commands can be reduced in subsequent operations to improve rendering efficiency.
[0119] For a possible implementation, see Figure 2 , merging each target object into the texture map and updating the position parameters of each target object may include: Step 1031: merging each target object into the texture map.
[0120] Step 1032: Update the position of each target object after being merged into the texture map into the rendering command corresponding to each target object.
[0121] The rendering command corresponding to each target object refers to the rendering command generated by the target node corresponding to each target object in the node tree of the current interface.
[0122] It's worth noting that by updating the position of each target object after it's merged into the texture map in the corresponding rendering command, each rendering command will refer to the position of each target object in the texture map. This way, when each rendering command is executed, the corresponding target object placed in the texture map is called or read. This improves batch rendering efficiency.
[0123] In a possible implementation, based on the position parameters of each target object, the specific operation of rendering the texture map in the current interface may be: executing a rendering command on a node corresponding to each target object in the node tree.
[0124] It is worth noting that by executing the rendering commands corresponding to each target object, the rendering of each target object can be completed, and the rendering commands corresponding to all target objects can be executed in the same batch, so that the target objects can be rendered in batches to reduce the number of rendering times.
[0125] In a possible implementation, each target object is merged into the texture map, and the position parameters of each target object are updated, further comprising: if the size of the current target object to be merged is larger than the size of the free area in the texture map, a new texture map is created.
[0126] Optionally, the size of the new texture map may be the preset size, or the size of the new texture map may be set according to other rules, which is not limited in the present embodiment.
[0127] Merge the current target object to be merged into the new texture map and update the position parameters of the current target object to be merged.
[0128] In one possible implementation, see Figure 3 , the method further comprises:
[0129] Step 105: Render the objects that do not meet the preset conditions separately among the objects to be rendered.
[0130] It is worth noting that by rendering objects that do not meet the preset conditions separately, these objects that do not meet the preset conditions will not be merged into the texture map. In this way, more objects that meet the preset conditions can be merged into the texture map and the texture maps can be rendered in one batch, thereby reducing the number of rendering batches and improving rendering efficiency.
[0131] The interface rendering method provided in the embodiment of the present application can also be applied to the rendering process of multiple continuous interfaces.
[0132] The multiple continuous interfaces may be multiple interfaces arranged linearly according to a certain time sequence, or may be multiple interfaces arranged linearly according to other rules.
[0133] In one possible implementation, see Figure 4 , after rendering the texture map on the current interface according to the position parameters of each target object, it also includes:
[0134] Step 106: The next interface among the multiple consecutive interfaces is used as the current interface, and steps 101 to 104 are repeated.
[0135] Optionally, after the current interface rendering operation is completed, the content of the texture map used to render the current interface may be cleared, or the content of the texture map used to render the current interface may be retained.
[0136] Optionally, while retaining the content of the texture map used to render the current interface, the content of the texture map used to render the current interface can be cleared after the rendering operation of the next interface adjacent to the current interface in the multiple consecutive interfaces is completed. In this way, the memory usage can be reduced.
[0137] Optionally, after completing the rendering operation on the first interface among the multiple consecutive interfaces, while retaining the content in the texture map used to render the current interface, starting from the second interface among the multiple consecutive interfaces, the following operations may be performed:
[0138] Before merging each target object into the texture map and updating the position parameters of each target object, it also includes:
[0139] It is determined whether each of the plurality of target objects has been merged into the texture map.
[0140] If it has not been merged, the unmerged target object will be merged into the texture map.
[0141] If it has been merged, it is determined that the target object that has been merged does not need to be merged again, and the position parameters after the last merge are directly returned to the corresponding rendering command.
[0142] It's worth noting that by determining whether each of the multiple target objects has already been incorporated into the texture map, it's possible to exclude target objects that have already been incorporated into the texture map in at least one of the multiple consecutive interfaces preceding the current interface. This allows only target objects that haven't yet been incorporated into the texture map to be merged. This reduces rendering times and memory usage.
[0143] The interface rendering method provided in the embodiment of the present application can be applied to the rendering of images or texts. The image rendering method and the text rendering method are respectively described with examples below.
[0144] Figure 5 This is a flow chart of an interface rendering method suitable for image rendering provided in an embodiment of the present application. Figure 5 , the target object may include: a target map.
[0145] Step 201: Create texture map.
[0146] Optionally, the texture map is a blank virtual map used to place a map to be rendered.
[0147] Optionally, the shape of the texture map may be rectangular, circular, or other applicable shapes, which is not limited in the present embodiment.
[0148] Optionally, the size of the texture map is a preset size.
[0149] For example, the preset size is 2048×2048, or other sizes, which are not limited in the present embodiment.
[0150] It is worth noting that the size of the created texture map is set to the preset size, which can control the memory occupied by the texture map and avoid the problem of excessive memory usage.
[0151] Step 202: Based on the node tree of the current interface, determine multiple target maps to be merged and rendered.
[0152] Optionally, the current interface can be any frame of the game, for example, it can be a game login interface, or it can be an operation interface within the game. This embodiment of the application does not limit this.
[0153] Optionally, the node tree may include multiple nodes, the multiple nodes have a hierarchical relationship with each other, and each node may include at least one command.
[0154] Optionally, the target map may be an image that needs to be merged and rendered in the current interface.
[0155] It is worth noting that the multiple target maps are determined based on the node tree of the current interface, so that it can be ensured that the multiple target maps are the images to be rendered that need to be processed in the frame of the current interface.
[0156] Step 203: Merge each target map into the texture map, and update the position parameters of each target map.
[0157] It's worth noting that by merging the target maps determined based on the current interface's node tree into the texture map, multiple target maps merged into the texture map can be rendered in the same batch. This reduces rendering times. Furthermore, updating the position parameters of each target object after merging into the texture map facilitates subsequent operations, further improving batch rendering efficiency.
[0158] Step 204: Render the texture map on the current interface according to the position parameters of each target map.
[0159] Rendering is the process of using software to generate an image from a model. For example, in a game, a model in a 3D scene is projected into a 2D digital image based on the set environment, lighting, materials, and rendering parameters.
[0160] It is worth noting that according to the position parameters of each target map after being merged into the texture map, the position of each target map in the texture map can be directly determined, so that each target map can be called for rendering conveniently and quickly, thereby achieving the effect of improving the efficiency of batch rendering.
[0161] In an embodiment of the present application, a texture map is created, and then based on the node tree of the current interface, multiple target maps to be merged and rendered are determined, and then each target map is merged into the texture map, and the position parameters of each target map are updated. Finally, according to the position parameters of each target map, the texture map is rendered in the current interface. Wherein, the size of the created texture map is set to a preset size, so that the memory occupied by the texture map can be controlled; based on the node tree of the current interface, multiple target maps to be merged and rendered are determined, so that it can be ensured that the multiple target maps are the maps to be rendered that need to be processed in the current interface frame; then each target map is merged into the texture map, and the position parameters of each target map are updated, so that the multiple target maps merged into the texture map can be rendered in the same batch; then, according to the position parameters of each target map after being merged into the texture map, the position of each target map in the texture map can be directly determined, so that each target map can be called for rendering conveniently and quickly. In this way, the effect of reducing memory usage and improving batch rendering efficiency can be achieved.
[0162] Specifically, merging each target object into the texture map and updating the position parameters of each target object may include:
[0163] Step 2031: Get the image path of each target texture.
[0164] Optionally, the image path may be a file storage path of each target image in the terminal, or a reading or calling path of each target image in the cloud. This embodiment of the present application does not limit this.
[0165] Step 2032: Load each target map into the memory, and determine the position parameters of each target map to be merged into the texture map.
[0166] It is worth noting that since the memory reads and writes data very quickly, loading each target map into the memory for processing can improve rendering efficiency.
[0167] Step 2033: Copy each pixel in each target map to the texture map according to the position parameter.
[0168] Furthermore, in copying each pixel in each target map to the texture map, the specific operation may be:
[0169] Each pixel in each target map is copied to this texture map according to certain preset rules.
[0170] The preset rule may be to copy each pixel point into the texture map in sequence from left to right starting from the top row of each target map.
[0171] Step 2034: Update the position parameters of each target texture.
[0172] It is worth noting that by updating the position parameters of each target object after being merged into the texture map, subsequent operations can be facilitated, thereby achieving the effect of improving batch rendering efficiency.
[0173] Furthermore, after updating the position parameters of each second target map, the method may further include:
[0174] Update the texture of the target area on the Graphics Processing Unit (GPU).
[0175] The target area is the area in the texture map after each target map is merged into the texture map.
[0176] It is worth noting that by updating the texture of the target area on the GPU, it can be ensured that the successfully merged target maps all use the same texture, thereby ensuring that the successfully merged target maps can be correctly rendered in one batch.
[0177] In one possible implementation, see Figure 6 Figure a shows a virtual package interface A in the game. Virtual package interface A includes a virtual package prompt bar and multiple virtual item slots. In virtual package interface A, no icons are displayed in the multiple virtual item slots.
[0178] Optionally, virtual items can be locked in the game.
[0179] Locked operations refer to operations that are prohibited from being traded, given away, discarded, or damaged within the game.
[0180] For example, locked virtual items cannot be traded, given away, discarded or damaged.
[0181] Furthermore, after the virtual item is locked, a virtual icon may be displayed on the icon of the virtual item to indicate the locked state of the virtual item.
[0182] For example, in order to display an icon of a locked virtual item, you can create a texture map, merge multiple target maps into this texture map, perform batch rendering, and then display the multiple target maps at the specified position.
[0183] for example, Figure 6b in FIG. 1 shows a texture map H, which includes a virtual item icon J and a lock icon L.
[0184] Among them, the virtual item icon J and the lock icon L can be the two target maps required by the locked virtual item determined after creating the texture map H and traversing the node tree of the virtual package interface A, and then the virtual item icon J and the lock icon L are merged into the texture map H.
[0185] Figure 6 Graph c shows a texture map H and a virtual wrapping interface B in the game. In order to display a locked virtual item, the virtual item icon J and the lock icon L in the texture map H need to be rendered and displayed at the specified location.
[0186] Continue to see Figure 6 ,For example Figure 6 d in the figure shows a virtual package interface C in the game. Virtual package interface C is the interface after the virtual item J in virtual package interface A has been locked. Specifically, virtual icon L and the icon J of the virtual item are rendered together and displayed in a virtual item slot located in the upper left corner of the multiple virtual item slots. This allows the locked virtual item icon to be displayed in virtual package interface C.
[0187] For example, in the virtual package interface C, the virtual icon L displayed in the virtual item grid and the icon J associated with the virtual item are dynamically replaceable.
[0188] Figure 7 This is a flow chart of an interface rendering method suitable for text rendering provided in an embodiment of the present application. Figure 7 , the target object may include: target text.
[0189] Step 301: Create a texture map.
[0190] Optionally, the texture map may be a blank virtual map for placing a map to be rendered.
[0191] Optionally, the shape of the texture map may be rectangular, circular, or other applicable shapes, which is not limited in the present embodiment.
[0192] Optionally, the size of the texture map is a preset size.
[0193] For example, the preset size is 2048×2048, or other sizes, which are not limited in the present embodiment.
[0194] It is worth noting that the size of the created texture map is set to the preset size, which can control the memory occupied by the texture map and avoid the problem of excessive memory usage.
[0195] Step 302: Based on the node tree of the current interface, determine multiple target texts to be merged and rendered.
[0196] Optionally, the current interface can be any frame of the game, for example, it can be a game login interface, or it can be an operation interface within the game. This embodiment of the application does not limit this.
[0197] Optionally, the node tree may include multiple nodes, the multiple nodes have a hierarchical relationship with each other, and each node may include at least one command.
[0198] Optionally, the target map may be an image that needs to be merged and rendered in the current interface.
[0199] It is worth noting that the multiple target maps are determined based on the node tree of the current interface, so that it can be ensured that the multiple target maps are the images to be rendered that need to be processed in the frame of the current interface.
[0200] Step 303: Merge each target text into the texture map, and update the position parameters of each target text.
[0201] It's worth noting that by merging the target text determined based on the current interface's node tree into the texture map, multiple target text merged into the texture map can be rendered in the same batch. This reduces the number of rendering batches. Furthermore, updating the position parameters of each target text after merging into the texture map can improve rendering efficiency.
[0202] In an embodiment of the present application, a texture map is created, and then based on the node tree of the current interface, a plurality of target texts to be merged and rendered are determined, and then each target text is merged into the texture map, and the position parameters of each target text are updated. Among them, the size of the texture map created is set to a preset size, so that the memory occupied by the texture map can be controlled; based on the node tree of the current interface, a plurality of target texts to be merged and rendered are determined, so that it can be ensured that the plurality of target texts are the texts to be rendered that need to be processed in the current interface frame; then each target text is merged into the texture map, so that the plurality of target texts merged into the texture map can be rendered in the same batch; then the position parameters of each target text are updated, and the position of each target text in the texture map can be directly determined, so that each target text can be called for rendering conveniently and quickly. In this way, the effect of reducing memory usage and improving the efficiency of batch rendering can be achieved.
[0203] Specifically, merging each target object into the texture map and updating the position parameters of each target object may include:
[0204] Step 3031: Copy each pixel in each target text into the texture map.
[0205] Furthermore, when copying each pixel in each target text into the texture map, the specific operation may be:
[0206] Each pixel in each target text is copied to the texture map according to certain preset rules.
[0207] The preset rule may be to copy each row of pixels into the texture map in order from top to bottom starting from the leftmost point of each target character toward the right.
[0208] Step 3032: Determine the position parameters of each target text to be merged into the texture map.
[0209] Step 3033: Update the position parameter of each target text.
[0210] It is worth noting that by updating the position parameters of each target object after being merged into the texture map, subsequent operations can be facilitated, thereby achieving the effect of improving batch rendering efficiency.
[0211] In one possible implementation, see Figure 8 Figure a in the figure shows a virtual interface U in the game. This virtual interface includes a virtual prompt bar, three virtual navigation bars, and multiple virtual inventory bars. However, no text is displayed on the virtual interface U.
[0212] In order to display the information of the virtual prompt bar, virtual navigation bar and virtual inventory in the virtual interface U, you can create a texture map, merge multiple target texts into this texture map, perform batch rendering, and then display the multiple target texts at the specified location.
[0213] for example, Figure 8 b in FIG. 4 shows a texture map T, which includes text Q, text W, text E, and text R. FIG.
[0214] Among them, text Q, text W, text E and text R can be the four target texts required by the locked virtual item determined after creating the texture map T and traversing the node tree of the virtual interface V, and then text Q, text W, text E and text R are merged into the texture map H.
[0215] Figure 8Figure c shows the texture map T and virtual interface U in the game. In order to display the information of text Q, text W, text E and text R on the virtual interface U, it is necessary to render the text Q, text W, text E and text R in the texture map T and display them at the specified position in the virtual interface U.
[0216] Continue to see Figure 8 ,For example Figure 8 The d in the figure shows the virtual interface V in the game. Virtual interface V is the interface after the text Q, text W, text E, and text R are rendered and displayed on the virtual interface U. Specifically, after the text Q, text W, text E, and text R are batch-rendered, text Q, text W, and text R are displayed in the three virtual navigation bars located on the right side of virtual interface V, respectively, and text E is displayed in the virtual prompt bar located directly above virtual interface V. In this way, the information of the virtual prompt bar, virtual navigation bar, and virtual inventory can be displayed in virtual interface U.
[0217] The following describes the apparatus, device, and computer-readable storage medium used to execute the interface rendering method provided in this application. The specific implementation process and technical effects are described above and will not be repeated below.
[0218] Figure 9 This is a schematic diagram of the structure of an interface rendering device provided in an embodiment of the present application, see Figure 9 , the device includes: a creation module 401, used to create a texture map.
[0219] The determination module 402 is configured to determine a plurality of target objects to be merged and rendered based on the node tree of the current interface.
[0220] The merging and updating module 403 is used to merge each target object into the texture map and update the position parameters of each target object.
[0221] The rendering module 404 is used to render the texture map on the current interface according to the position parameters of each target object.
[0222] Optionally, the determination module 402 is configured to traverse the node tree of the current interface and generate a rendering command on a target node of the node tree.
[0223] The object to be rendered pointed to by each target node is used as the object to be rendered.
[0224] The multiple target objects that meet the preset conditions are screened out from the objects to be rendered.
[0225] Optionally, the merge update module 403 is configured to update the position of each target object after being merged into the texture map into a rendering command corresponding to each target object.
[0226] Optionally, the merging and updating module 403 is further configured to create a new texture map if the size of the target object to be merged is larger than the size of the free area in the texture map.
[0227] Merge the current target object to be merged into the new texture map and update the position parameters of the current target object to be merged.
[0228] Optionally, the rendering module 404 is configured to execute a rendering command for each target object on a corresponding node in the node tree.
[0229] The above-mentioned device is used to execute the method provided in the above-mentioned embodiment. Its implementation principle and technical effect are similar and will not be repeated here.
[0230] The above modules can be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more microprocessors, or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented by scheduling program code through a processing element, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0231] Figure 10 This is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. Figure 10 The computer device 500 includes: a memory 501 and a processor 502. The memory 501 stores a computer program that can be run on the processor 502. When the processor 502 executes the computer program, the steps in any of the above method embodiments are implemented.
[0232] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.
[0233] Optionally, the present application also provides a program product, such as a computer-readable storage medium, comprising a program, which is used to execute any of the above-mentioned interface rendering method embodiments when executed by a processor.
[0234] In the several embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interface, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0235] Units described as separate components may or may not be physically separate, and 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 these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0236] In addition, the functional units in various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or hardware plus software functional units.
[0237] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or a processor (English: processor) to perform some steps of the methods of various embodiments of the present invention. The aforementioned storage medium includes: a USB flash drive, a mobile hard disk, a read-only memory (English: Read-Only Memory, abbreviated: ROM), a random access memory (English: Random Access Memory, abbreviated: RAM), a magnetic disk or an optical disk, and other media that can store program code.
[0238] The above are only specific embodiments of the present application, but the scope of protection of this application is not limited to them. Any changes or substitutions that can be easily conceived by any person skilled in the art within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.
[0239] The above description is merely a preferred embodiment of the present application and is not intended to limit the present application. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present application shall be included within the scope of protection of the present application.
Claims
1. An interface rendering method, characterized in that: include: Creating a texture map, wherein the size of the texture map is a preset size; The texture map is a blank virtual map used to place the map to be rendered; Based on the node tree of the current interface, determine multiple target objects to be merged and rendered; Merging each of the target objects into the texture map, and updating the position parameters of each of the target objects; Rendering the texture map on the current interface according to the position parameters of each target object; Merging each of the target objects into the texture map and updating the position parameters of each of the target objects, including: updating the position of each target object after being merged into the texture map into the rendering command corresponding to each target object; wherein, the rendering command corresponding to each target object refers to the rendering command generated by the target node corresponding to each target object in the node tree of the current interface.
2. The interface rendering method according to claim 1, wherein: The step of determining multiple target objects to be merged and rendered based on the node tree of the current interface includes: Traversing the node tree of the current interface and generating a rendering command on a target node of the node tree, wherein the node tree includes multiple nodes, the target node is a node in the node tree on which a rendering operation needs to be performed, and each target node points to one or more objects to be rendered; Taking the object to be rendered pointed to by each target node as the object to be rendered; The plurality of target objects that meet preset conditions are screened out from the objects to be rendered.
3. The interface rendering method according to claim 1, wherein: Rendering the texture map on the current interface according to the position parameters of each target object includes: Execute a rendering command on a corresponding node in the node tree for each target object.
4. The interface rendering method according to claim 1, wherein: The target object includes: a target map; The step of merging each target object into the texture map and updating the position parameters of each target object includes: Obtain the image path of each target map; Loading each of the target maps into a memory, and determining the position parameters of each of the target maps merged into the texture map; Copying each pixel in each target map to the texture map according to the position parameter; The position parameters of each target texture are updated.
5. The interface rendering method according to claim 4, wherein: After updating the position parameters of each target map, the method further includes: Update the texture of the target area on the graphics processor GPU; The target area is an area in the texture map after each of the target maps is merged into the texture map.
6. The interface rendering method according to claim 1, wherein: The target object includes: target text; The step of merging each target object into the texture map and updating the position parameters of each target object includes: Copying each pixel in each target text into the texture map; Determining the position parameters of each target text merged into the texture map; Update the position parameters of each target text.
7. The interface rendering method according to claim 2, wherein: The method further comprises: The objects to be rendered that do not meet the preset conditions are rendered separately.
8. The interface rendering method according to any one of claims 1 to 7, wherein: The step of merging each target object into the texture map and updating the position parameters of each target object further includes: If the size of the current target object to be merged is larger than the size of the free area in the texture map, a new texture map is created; The target object currently to be merged is merged into the new texture map, and the position parameters of the target object currently to be merged are updated.
9. The interface rendering method according to any one of claims 1 to 7, wherein: The texture map is rectangular.
10. The interface rendering method according to any one of claims 1 to 7, characterized in that: The position parameters are UV coordinates.
11. An interface rendering device, characterized in that: The interface rendering device includes: A creation module, used to create a texture map; the texture map is a blank virtual map used to place the map to be rendered; A determination module is used to determine multiple target objects to be merged and rendered based on the node tree of the current interface; A merging and updating module, configured to merge each of the target objects into the texture map and update position parameters of each of the target objects; A rendering module, configured to render the texture map on the current interface according to the position parameters of each target object; The merge update module is specifically used to update the position of each target object after it is merged into the texture map to the rendering command corresponding to each target object; wherein, the rendering command corresponding to each target object refers to the rendering command generated by the target node corresponding to each target object in the node tree of the current interface.
12. A computer device, characterized in that: include: A memory and a processor, wherein the memory stores a computer program that can be run on the processor, and when the processor executes the computer program, the steps of the method described in any one of claims 1 to 10 are implemented.
13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 10.
Citation Information
Patent Citations
Game rendering method and apparatus, storage device and terminal
CN107463398A
Three-dimensional model and material merging method and device, terminal, storage medium and rendering method
CN111028361A