Multi-role rendering method and device, electronic equipment, storage medium and program product
By rendering multiple 3D characters on the same canvas and limiting the rendering area, the performance and resource pressure issues of displaying multiple characters in large-scale multiplayer online games are solved, achieving more efficient rendering and clearer display effects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2026-03-30
- Publication Date
- 2026-07-03
AI Technical Summary
In massively multiplayer online games, displaying multiple 3D characters involves significant performance and resource pressure due to each character having its own independent canvas, as well as visual clutter caused by the spatial overlap of character models and effects.
By rendering multiple 3D characters on the same canvas and defining a rendering area for each character, a unified rendering target texture is generated and passed to the UI framework for display. The clipping state is managed using the RAII automatic state management class.
This reduces the performance and resource pressure of rendering each character independently, avoids the spatial overlap of character models and special effects, and improves the controllability and display efficiency of the image.
Smart Images

Figure CN122336091A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, specifically to multi-role rendering methods, apparatuses, electronic devices, storage media, and program products. Background Technology
[0002] In massively multiplayer online games (MMOs), players need to view other players' 3D character images in the user interface. This requirement is extremely common in scenarios such as leaderboards, team management, character selection, and personal profiles. To achieve this functionality, self-developed game engines typically adopt a "off-screen rendering + texture binding" technical approach: first, the 3D character is rendered onto an off-screen canvas at the engine layer, generating a render target (RT) texture. Then, through the interface between the engine and the UI framework, the texture is bound to a specified location on the UI interface for display. However, when multiple 3D characters need to be displayed simultaneously, the relevant technologies create an independent canvas for each 3D character, and each canvas needs to perform a complete rendering process, including model-independent post-processing steps. This approach brings significant performance and resource pressure in multi-character scenarios. Summary of the Invention
[0003] This application provides a multi-character rendering method, apparatus, electronic device, storage medium, and program product to solve the problem of significant performance and resource pressure caused by the related technologies when multiple 3D characters need to be displayed simultaneously. These technologies create an independent canvas for each 3D character, and each canvas needs to perform a complete rendering process, including model-independent post-processing steps.
[0004] Firstly, this application provides a multi-role rendering method that provides a graphical user interface through a terminal device, including: In response to a character rendering request, determine the 3D character to be rendered; A first canvas is created based on the number of the three-dimensional characters to be rendered and the display size corresponding to each of the three-dimensional characters; wherein, the first canvas includes multiple rendering areas, and the size of each rendering area corresponds to the display size of the three-dimensional character to be rendered; Based on the correspondence between the rendering area and the 3D character, the 3D character to be rendered is rendered in multiple rendering areas respectively, a rendering target texture corresponding to the first canvas is generated, and the rendering target texture is passed to a preset UI framework to render and display the 3D character in the graphical user interface.
[0005] The multi-character rendering method provided in this embodiment solves the performance and resource pressure caused by the fact that in related technologies, when displaying multiple 3D character images in a graphical user interface, each 3D character requires a corresponding canvas, and each canvas needs to perform a complete rendering process, including model-independent post-processing steps. Furthermore, by generating corresponding rendering target textures on a single canvas containing multiple 3D characters, and having the graphical user interface sample and display the corresponding sampled content, the method solves the performance and resource pressure caused by the graphical user interface needing to process multiple rendering target textures generated from multiple canvases corresponding to multiple 3D characters in related technologies. In addition, by limiting the rendering area corresponding to each 3D character, the method solves the problem in related technologies where directly rendering multiple 3D characters on the same canvas causes spatial overlap of 3D character models and effects, leading to chaotic and uncontrollable visuals.
[0006] Secondly, this application provides a multi-role rendering apparatus, including: The character quantity module is used to determine the 3D characters to be rendered in response to character rendering requests.
[0007] The rendering area module is used to create a first canvas based on the number of 3D characters to be rendered and the display size of each 3D character. The first canvas includes multiple rendering areas, each with a size corresponding to the display size of the 3D character to be rendered.
[0008] The character rendering module is used to render the 3D character to be rendered in multiple rendering areas based on the correspondence between the rendering area and the 3D character, generate the rendering target texture corresponding to the first canvas, and pass the rendering target texture to the preset UI framework to render and display the 3D character in the graphical user interface.
[0009] Thirdly, this application provides an electronic device, including: a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to perform the multi-role rendering method described in the first aspect or any corresponding embodiment.
[0010] Fourthly, this application provides a computer-readable storage medium storing computer instructions for causing a computer to execute the multi-role rendering method described in the first aspect or any corresponding embodiment thereof.
[0011] Fifthly, this application provides a computer program product, including computer instructions for causing a computer to execute the multi-role rendering method described in the first aspect or any corresponding embodiment thereof. Attached Figure Description
[0012] To more clearly illustrate the technical solutions in the specific embodiments of this application or the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0013] Figure 1 This is a schematic diagram illustrating an application scenario according to an embodiment of this application; Figure 2 This is a schematic diagram of the first process of a multi-role rendering method according to an embodiment of this application; Figure 3 This is a schematic diagram of a second process for a multi-role rendering method according to an embodiment of this application; Figure 4 This is a schematic diagram of a system architecture according to an embodiment of this application; Figure 5 This is a rendering effect diagram according to an embodiment of this application; Figure 6 This is a structural block diagram of a multi-role rendering apparatus according to an embodiment of this application; Figure 7 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of this application. Detailed Implementation
[0014] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0015] It is understood that before using the technical solutions disclosed in the various embodiments of this application, users should be informed of the types, scope of use, and usage scenarios of the personal information involved in this application in an appropriate manner in accordance with relevant laws and regulations, and user authorization should be obtained.
[0016] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.
[0017] In some related technologies, multiple 3D characters can be rendered on a single canvas. However, due to the lack of semantic isolation mechanisms, multiple 3D characters rendered on the same canvas may experience spatial interweaving of models, effects, etc., resulting in a chaotic and uncontrollable visual effect.
[0018] This application provides a multi-character rendering method. By rendering various 3D characters onto the same canvas and defining the rendering area corresponding to each 3D character, it solves the problems in related technologies where, when displaying multiple 3D character images in a graphical user interface, each 3D character requires a corresponding canvas, and each canvas needs to perform a complete rendering process, including model-independent post-processing steps, resulting in performance and resource pressure. It also addresses the problem that directly rendering multiple 3D characters onto the same canvas causes the 3D character models and special effects to overlap in space, leading to chaotic and uncontrollable visuals.
[0019] As one optional application scenario in the embodiments of this application, such as Figure 1 As shown, application 101 is installed in terminal device 110, and user 130 can interact with application 101 through terminal device 110 and / or access device of terminal device 110.
[0020] For example, application 101 can be arbitrary and can provide a 3D model display for related applications. For instance, application 101 could be a game application, etc. Figure 1 In the application scenario shown, if application 101 is active, the terminal device 110 can display the interface 102 of application 101. The interface 102 may include various game model display pages that application 101 can provide, such as team-up pages, leaderboard pages, etc.
[0021] Terminal device 110 can be a mobile terminal, a fixed terminal, or a portable terminal, etc., including but not limited to mobile phones, desktop computers, laptop computers, multimedia tablets, e-book devices, gaming devices, or any combination thereof, including accessories and peripherals of these devices or any combination thereof.
[0022] It should be noted that, Figure 1 This is merely an example of an application scenario and does not limit the scope of protection of this application.
[0023] The embodiments of this application will be described below with reference to the accompanying drawings. It should be understood that the pages shown in the drawings are merely examples, and various page designs are possible in practice. The various graphic elements on the page may have different arrangements and different visual representations, one or more elements may be omitted or replaced, and one or more other elements may also be present; no limitations are made in the embodiments of this application. Furthermore, the embodiments are mainly described below with reference to terminal device 110. It should be understood that the actions described relative to terminal device 110 can be performed by application 101 on terminal device 110.
[0024] According to an embodiment of this application, a multi-role rendering method embodiment is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0025] This embodiment provides a multi-role rendering method, which can be used in the aforementioned terminal devices, such as mobile phones, desktop computers, and laptops, to provide a graphical user interface through the terminal device. Figure 2 This is a flowchart of a multi-role rendering method according to an embodiment of this application, such as... Figure 2 As shown, the process includes the following steps: Step S201: In response to the character rendering request, determine the 3D character to be rendered.
[0026] In the graphical user interface (GUI) of a game application, multiple 3D characters can be displayed, such as in leaderboards and team-up interfaces. In this case, the GUI that needs to display multiple 3D characters can initiate a rendering request to display those characters. These 3D characters can be preset characters; or they can be characters displayed according to the needs of the GUI. For example, in a leaderboard interface, it's necessary to display the 3D characters corresponding to the top three players on the leaderboard. Therefore, the rendering request is specifically for the 3D characters corresponding to the top three players.
[0027] It should be understood that the generation method for rendering requests for multiple 3D characters is not limited to what is shown above, and this article does not make any specific limitations.
[0028] After receiving a rendering request from the graphical user interface, the number of 3D characters to be rendered can be determined based on the content of the rendering request; that is, how many 3D characters need to be rendered in the graphical user interface. For example, if the graphical user interface is a team interface, the number of 3D characters can be 4, meaning that 4 3D characters need to be rendered and displayed in the team interface.
[0029] Step S202: Create a first canvas based on the number of 3D characters to be rendered and the display size of each 3D character. The first canvas includes multiple rendering areas, each with a size corresponding to the display size of the 3D character to be rendered.
[0030] After obtaining the number of characters, the first canvas can be initialized based on the number of characters and the corresponding display size of the 3D characters, i.e., the first canvas is created. The display size of the 3D characters can be a preset size, such as 320×640, or it can be determined based on the function of the graphical user interface. For example, the leaderboard interface can display 3 3D characters, so the display size of the 3D characters in the leaderboard interface can be set to 480×960, where 480×960 can be a parameter pre-input by the user to set the area occupied by the 3D characters in the leaderboard interface; the team interface can display 4 3D characters, so the display size of the 3D characters in the team interface can be set to 320×640, where 320×640 can be a parameter pre-input by the user to set the area occupied by the 3D characters in the team interface. It is understandable that since the leaderboard interface has fewer characters, the area occupied by the 3D characters can be set to a larger parameter, i.e., a larger area.
[0031] Preferably, since it is necessary to arrange the display sizes corresponding to the 3D characters, and since the model sizes of the various 3D characters are similar in any display interface of the game scene, the display sizes corresponding to the 3D characters can be universal. In this case, the display sizes corresponding to the 3D characters can be consistent within the same graphical user interface. For cases where the display sizes corresponding to the 3D characters are inconsistent, the display sizes can also be arranged. For example, the display sizes corresponding to other 3D characters can be updated according to the maximum value among the display sizes of the 3D characters to ensure that the display sizes corresponding to the 3D characters can be arranged.
[0032] After determining the number of characters and the corresponding display size of the 3D characters, the first canvas can be created. The canvas is the rendering target container used for off-screen rendering in the game engine; that is, the 3D model can be rendered on the canvas. The size of the first canvas can be the product of the number of characters and the corresponding display size of the 3D characters. For example, if the display size of the 3D characters is 320×640 and there are 4 characters: if the 4 3D characters are arranged along both the width and height of the first canvas, the size of the first canvas can be 640×1280; if the 4 3D characters are arranged only along the width of the first canvas, the size of the first canvas can be 1280×640; if the 4 3D characters are arranged only along the height of the first canvas, the size of the first canvas can be 320×2560. In other words, the arrangement of each 3D character can be along the width and / or height of the first canvas, and the size of the first canvas is determined accordingly based on the arrangement direction of each 3D character and the data for each arrangement direction.
[0033] Furthermore, within the first canvas, specific rendering areas can be defined, each corresponding to a different 3D character. It should be understood that during the rendering process of a 3D character, the area corresponding to that character is limited to its designated rendering area; that is, the rendering of each 3D character is independent of the others.
[0034] Step S203: Based on the correspondence between the rendering area and the 3D character, render the 3D character to be rendered in multiple rendering areas respectively, generate the rendering target texture corresponding to the first canvas, and pass the rendering target texture to the preset UI framework to render and display the 3D character in the graphical user interface.
[0035] After determining the rendering areas corresponding to each 3D character, the 3D characters can be rendered in their respective rendering areas within the first canvas. This involves rendering the 3D characters into their corresponding rendering areas. Once all 3D characters have been rendered, a rendering target texture corresponding to the first canvas is generated. The rendering target texture serves as the communication medium between the game engine and the graphical user interface. The game engine stores the processed second canvas in the rendering target texture and transmits it to the preset UI framework via interfaces. The preset UI framework then samples the 3D characters from the rendering target texture and displays the sampled content—the 3D characters to be displayed—in the graphical user interface that includes the UI framework.
[0036] By rendering all 3D characters onto the same canvas, this approach solves the performance and resource pressure caused by the fact that each 3D character requires its own canvas when displaying multiple 3D character images in a graphical user interface, and each canvas needs to perform a complete rendering process, including model-independent post-processing steps. Furthermore, by limiting the rendering area for each 3D character, this approach avoids the problem of spatial overlap between 3D character models and effects, leading to visual chaos and uncontrollable visuals, which occurs when multiple 3D characters are directly rendered onto the same canvas in related technologies.
[0037] The multi-character rendering method provided in this embodiment solves the performance and resource pressure caused by the fact that in related technologies, when displaying multiple 3D character images in a graphical user interface, each 3D character requires a corresponding canvas, and each canvas needs to perform a complete rendering process, including model-independent post-processing steps. Furthermore, by generating corresponding rendering target textures on a single canvas containing multiple 3D characters, and having the graphical user interface sample and display the corresponding sampled content, the method solves the performance and resource pressure caused by the graphical user interface needing to process multiple rendering target textures generated from multiple canvases corresponding to multiple 3D characters in related technologies. In addition, by limiting the rendering area corresponding to each 3D character, the method solves the problem in related technologies where directly rendering multiple 3D characters on the same canvas causes spatial overlap of 3D character models and effects, leading to chaotic and uncontrollable visuals.
[0038] This embodiment provides a multi-role rendering method, which can be used in the aforementioned terminal devices, such as mobile phones, desktop computers, and laptops, to provide a graphical user interface through the terminal device. Figure 3 This is a flowchart of a multi-role rendering method according to an embodiment of this application, such as... Figure 3 As shown, the process includes the following steps: Step S301: In response to the character rendering request, determine the 3D character to be rendered.
[0039] Please see details Figure 2 Step S201 of the illustrated embodiment will not be described again here.
[0040] Step S302: Create a first canvas based on the number of 3D characters to be rendered and the display size of each 3D character; wherein the first canvas includes multiple rendering areas, and the size of each rendering area corresponds to the display size of the 3D character to be rendered.
[0041] Specifically, step S302, "creating a first canvas based on the number of characters of the three-dimensional characters to be rendered and the display size corresponding to each three-dimensional character", includes steps S3021 to S3023.
[0042] Step S3021: Determine the width of the first canvas based on the number of characters and the width value of the display size corresponding to the three-dimensional characters.
[0043] Step S3022: Determine the height of the first canvas based on the height value of the display size corresponding to the 3D character.
[0044] Step S3023: Create the first canvas based on the width, height and number of characters of the first canvas.
[0045] During the creation of the first canvas, the width of the first canvas can be determined based on the number of characters and the width of the display size corresponding to each 3D character. This involves horizontally arranging the display sizes of each 3D character. For example, when N 3D characters need to be displayed in the graphical user interface (i.e., the number of characters is N), first determine the width (BaseWidth) of the display size corresponding to each 3D character, and then multiply this width by the number of characters N to determine the width of the first canvas: CanvasWidth = BaseWidth × N. For instance, if the current number of characters is 3, and the display size corresponding to each 3D character is 320 (width) × 640 (height), then the width of the first canvas (CanvasWidth) can be 320 (BaseWidth) × 3 (number of characters N) = 960.
[0046] Since the display area occupied by each 3D character is arranged horizontally, the height of the first canvas (CanvasHeight) can be directly determined based on the height (BaseHeight) of the corresponding display size of the 3D character, i.e., CanvasHeight = BaseHeight. For example, if the display size of the 3D character is 320 (width) × 640 (height), then the height (CanvasHeight) of the first canvas can be 640. After determining the width (CanvasWidth) and height (CanvasHeight) of the first canvas, its size can be determined. Then, combined with the number of characters (N), a first canvas comprising N display areas can be created.
[0047] In some alternative implementations, step S3023, “creating a first canvas based on the width, height, and number of characters of the first canvas,” includes steps a1 to a4.
[0048] Step a1: Create a third canvas based on the width, height, and number of characters of the first canvas.
[0049] Step a2: Determine the character index corresponding to each 3D character.
[0050] Step a3: Determine the rendering area parameters of the 3D character based on the character index and the size of the third canvas.
[0051] Step a4: Determine the rendering area of the 3D character in the third canvas based on the rendering area parameters of the 3D character, and obtain the first canvas.
[0052] After determining the width (CanvasWidth) and height (CanvasHeight) of the first canvas, and the number N of the 3D characters to be rendered, a temporary rendering target canvas, denoted as the third canvas, can be created in video memory. The third canvas has the same dimensions as the first canvas, i.e., a width of CanvasWidth and a height of CanvasHeight, and is used as the initial canvas for subsequent allocation of the rendering area.
[0053] In addition, the character index of each 3D character can be determined, that is, a unique index is assigned to each of the N (i.e., the number of characters) 3D characters that need to be rendered. The character index can be numbered sequentially from 1 to N to identify the order of each 3D character on the third canvas.
[0054] Next, for each 3D character, the rendering area parameters of that 3D character on the third canvas can be calculated based on its corresponding character index. Since the size of the third canvas is the same as the first canvas, the rendering area parameters of the 3D character on the third canvas can be divided sequentially according to its character index, based on the display size of the 3D character. In this embodiment, the rendering area parameters may include the left boundary (Left_i), right boundary (Right_i), top boundary (Top_i), and bottom boundary (Bottom_i) of the rendering area (where i is the character index). The left boundary, Left_i, can be calculated as: Left_i = (i-1) × (CanvasWidth / N), where i is the character index, N is the number of characters, and CanvasWidth is the width of the third canvas. In practice, since the width of the third canvas, CanvasWidth, is calculated as CanvasWidth = BaseWidth (the width of the display size corresponding to the 3D character) × N, this formula can be simplified to Left_i = (i-1) × BaseWidth. The right boundary, Right_i, can be calculated as: Right_i = i × (CanvasWidth / N), or Right_i = i × BaseWidth. Since the display area occupied by each 3D character is the first canvas obtained by horizontal arrangement, which in turn forms the third canvas, the upper boundary, Top_i, can be directly set to 0, i.e., Top_i = 0. The lower boundary, Bottom_i, can be consistent with the height of the third canvas, CanvasHeight, i.e., Bottom_i = CanvasHeight, or Bottom_i = BaseHeight. After determining the rendering area parameters of the 3D characters, the rendering area parameters of each 3D character are associated with the third canvas. That is, non-overlapping rectangular sub-regions are defined for each 3D character on the third canvas, thus forming a first canvas containing multiple rendering areas. In this embodiment, non-overlapping rectangular sub-regions can also be defined directly in the first canvas for each 3D character, i.e., the first canvas is updated; this is not limited here. The first canvas is the canvas actually used in the subsequent unified rendering process. Logically, it is divided into N equal-width sub-regions, each sub-region corresponding to the rendering area of a 3D character.
[0055] For example, if there are 3 characters to be rendered, with a CanvasWidth of 960 and a CanvasHeight of 640, then the rendering area parameters for the 3D character with character index 2 are as follows: Left_2 = (2-1)×(960 / 3), i.e., Left_2 = 320; Right_2 = 2×(960 / 3), i.e., Right_2 = 640; Top_2 = 0; and Bottom_2 = 640. That is, with the third canvas size being 960×640, it is logically divided into N equally wide areas horizontally. The rendering area for the 2nd (character index) 3D character is the area enclosed by the left boundary Left_2 = 320, the right boundary Right_2 = 640, the top boundary Top_2 = 0, and the bottom boundary Bottom_2 = 640.
[0056] By dividing the first canvas into multiple sub-regions, each sub-region corresponding to the rendering area of a 3D character, it can be ensured that after the 3D character rendering is completed, the 3D characters do not affect each other. This solves the problem in related technologies where the 3D character models and special effects are interspersed in space when multiple 3D characters are rendered directly on the same canvas, resulting in chaotic and uncontrollable images.
[0057] In some optional implementations, step a4, "determining the rendering area of the 3D character in the third canvas based on the rendering area parameters of the 3D character," includes step a41.
[0058] Step a41: Using a preset scope management class, a rendering area corresponding to the 3D character is generated in the third canvas according to the rendering area parameters of the 3D character. The scope management class is used to manage the rendering area.
[0059] In this embodiment, when generating the rendering area corresponding to the 3D character in the third canvas, it can be done through a preset scope management class. The scope management class can be a class built on Resource Acquisition IsInitialization, used to automatically set and restore the state of the rendering area in the rendering pipeline when generating the rendering area corresponding to the 3D character, thereby realizing the delineation of non-overlapping rendering areas for each 3D character on the third canvas.
[0060] In some optional implementations, step a41, "by using a preset scope management class, generating a rendering area corresponding to the 3D character in the third canvas according to the rendering area parameters of the 3D character," includes steps a411 to a413.
[0061] Step a411: Obtain the first rasterized state object of the third canvas through the scope management class.
[0062] Step a412: Modify the first configuration parameter corresponding to the first rasterized state object to the second configuration parameter to obtain the second rasterized state object. The second configuration parameter is used to enable the region clipping function.
[0063] Step a413: Determine the rendering area of the 3D character in the third canvas based on the second rasterized state object and the rendering area parameters corresponding to each 3D character.
[0064] Within the scope management class, including the constructor, it's possible to actively query and retrieve the rasterization state object currently bound to the rendering pipeline, i.e., the first rasterization state object. The first rasterization state object encapsulates all configuration information related to primitive rasterization in the current graphics pipeline, such as polygon fill mode, culling mode, depth offset, and the enabled / disabled status of the clipping rectangle function.
[0065] Next, the underlying configuration parameter structure, i.e., the first configuration parameter, can be read from the first rasterized state object. Then, a copy of the first configuration parameter is created, and the clipping enable flag (such as the ScissorEnable field) is changed from "disabled" to "enabled" (e.g., changing the value of the ScissorEnable field from "0" to "1"), while the other parameters remain unchanged, forming the second configuration parameter. A new rasterized state object, i.e., the second rasterized state object, can be found or created based on the second configuration parameter. It is understandable that the difference between the second and first rasterized state objects is that the second rasterized state object enables rectangular clipping (e.g., ScissorRect supported by GPU hardware).
[0066] After obtaining the second rasterized state object, it can be bound to the rendering pipeline so that the subsequent character rendering process is executed with the rectangle clipping function enabled. Then, the rectangle clipping function is called, and the rendering area parameter corresponding to the current 3D character is passed in, thereby limiting the rendering area of the 3D character on the third canvas.
[0067] In some alternative implementations, the multi-role rendering method further includes step a414.
[0068] Step a414: After post-processing the second canvas, restore the second rasterized state object to the first rasterized state object, and delete the second rasterized state object and the second configuration parameters.
[0069] Once all rendering and post-processing operations for the 3D characters are complete, the destructor in the scope management class can be called to perform state restoration and resource cleanup operations. In this embodiment, the second rasterized state object currently bound to the rendering pipeline can be unbound, and the first rasterized state object saved in step a411 can be rebound. This restores the rendering pipeline to its original rasterized state when the clipping function is not enabled, resets the clipping rectangle to its default state (i.e., the first configuration parameter), disables the rectangle clipping function, deletes the second rasterized state object temporarily created or obtained in step a412, and deletes the associated second configuration parameter. Since the second rasterized state object and the second configuration parameter are temporarily generated for this clipping operation, timely deletion can avoid memory resource leakage and state manager cache redundancy.
[0070] Managing the rendering region through a scope management class makes the rendering region safer, eliminating the need for developers to manually handle state switching and exception recovery, avoiding rendering errors, and ensuring isolation when rendering multiple roles.
[0071] Step S303: Based on the correspondence between the rendering area and the 3D character, render the 3D character to be rendered in multiple rendering areas respectively, generate the rendering target texture corresponding to the first canvas, and pass the rendering target texture to the preset UI framework to render and display the 3D character in the graphical user interface.
[0072] Please see details Figure 2 Step S203 of the illustrated embodiment will not be described again here.
[0073] In some optional implementations, step S303, "based on the correspondence between the rendering area and the 3D character, renders the 3D character to be rendered in multiple rendering areas respectively, and generates a rendering target texture corresponding to the first canvas", includes steps b1 and b2.
[0074] Step b1: Based on the correspondence between the rendering area and the 3D character, render the 3D character to be rendered in multiple rendering areas to obtain the second canvas. Step b2: Post-process the second canvas to generate a rendering target texture corresponding to the first canvas.
[0075] After determining the rendering areas corresponding to each 3D character, the 3D characters corresponding to the rendering areas in the first canvas can be rendered. That is, the 3D characters are rendered into the rendering areas corresponding to their respective 3D characters. After all the 3D characters have been rendered, the second canvas is obtained. In this embodiment, the corresponding 3D characters can be rendered directly in the rendering areas based on the first canvas to obtain the rendered first canvas, i.e., the second canvas; alternatively, a new second canvas can be created for rendering. This is not limited in this document.
[0076] After acquiring the second canvas, post-processing can be performed on it. Post-processing steps may include Shadow Mapping, Ambient Occlusion (AO), and Bloom effects to improve rendering quality. It should be understood that the post-processing methods used are determined based on actual needs, and no limitations are imposed here.
[0077] By generating corresponding rendering target textures from a single canvas containing multiple 3D characters, and having the UI framework sample a single rendering target texture and display the corresponding sampled content, this solves the performance and resource pressure caused by the UI framework needing to handle multiple rendering target textures generated from multiple canvases corresponding to multiple 3D characters in related technologies.
[0078] In some alternative implementations, after step S303, the multi-role rendering method further includes step c1.
[0079] Step c1: Send a display command to the UI framework; the display command is used to make the UI framework sample the rendering area corresponding to each 3D character from the rendering target texture, and display the rendering effect corresponding to the rendering area of each 3D character in the UI framework, so as to render and display the 3D characters in the graphical user interface.
[0080] After rendering and post-processing of the second canvas are completed, and the generated render target texture is passed to the UI framework, a display command can be sent to the UI framework. At this point, the UI framework can sample the render target texture based on the position and size of each 3D character in the interface layout. During sampling, UV offset can be used. For example, for the i-th character (where i is the character index of the 3D character), the u-component of the original UV coordinates in the render target texture can be divided by the number of characters N, and an offset (i-1) / N can be added, while the v-component remains unchanged, i.e.: UV_u = (UV_u_original / N)+((i-1) / N); UV_v = UV_v_original; Among them, UV_u_original and UV_v_original are the UV offsets used to render the target texture.
[0081] In this way, the UI framework can extract the image area corresponding to each character from the same rendering target texture, and render the sampled images of each 3D character to the specified position of the graphical user interface, thereby displaying the independent rendering effects of N 3D characters on the user interface at the same time.
[0082] Figure 4 This is a schematic diagram of a system architecture according to an embodiment of this application, such as... Figure 4 As shown, the UI (User Interface) framework layer first initiates a request to render N characters. At this point, the engine rendering layer creates a unified canvas (i.e., the first canvas) based on the number of characters N and sends it to the GPU resource layer. The GPU resource layer can then allocate rendering resources to this unified canvas, marking it as ready for rendering. Next, the engine rendering layer generates rendering regions corresponding to each 3D character and sends them to the GPU resource layer. The GPU resource layer then renders the 3D characters sequentially in the rendering regions corresponding to the unified canvas. After rendering is complete, a second canvas is generated and sent to the engine rendering layer. The engine rendering layer can then generate a rendering target texture based on the second canvas and send it to the UI framework layer. The UI framework layer then samples the rendering region corresponding to each 3D character from the rendering target texture and displays the rendering effect corresponding to the rendering region of each 3D character in the graphical user interface.
[0083] Figure 5 This is a rendering effect diagram according to an embodiment of this application, such as... Figure 5 As shown, by constraining the rendering of the 3D model through the rendering area, it is possible to effectively prevent the models and effects of the 3D character from overlapping and affecting the display effect.
[0084] The multi-character rendering method provided in this embodiment solves the performance and resource pressure caused by the fact that in related technologies, when displaying multiple 3D character images in a graphical user interface, each 3D character requires a corresponding canvas, and each canvas needs to perform a complete rendering process, including model-independent post-processing steps. Furthermore, by generating corresponding rendering target textures on a single canvas containing multiple 3D characters, and having the graphical user interface sample and display the corresponding sampled content, it solves the performance and resource pressure caused by the graphical user interface needing to handle multiple rendering target textures generated from multiple canvases corresponding to multiple 3D characters in related technologies. In addition, by limiting the rendering area corresponding to each 3D character, it solves the problem of spatial overlap of 3D character models and effects, leading to chaotic and uncontrollable visuals, caused by directly rendering multiple 3D characters on the same canvas in related technologies. The RAII automatic state management encapsulates the lifecycle management of the clipping state, simplifying the development process and reducing the risk of human configuration errors. Moreover, it supports flexible configuration of the number of characters; simple parameter adjustments can adapt to scenes with any number of characters without modifying the core rendering code, facilitating the creation and maintenance of the graphical user interface for developers.
[0085] This embodiment also provides a multi-role rendering apparatus for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0086] This embodiment provides a multi-role rendering device, such as Figure 6 As shown, it includes: The character quantity module 601 is used to determine the 3D characters to be rendered in response to character rendering requests. The rendering area module 602 is used to create a first canvas based on the number of 3D characters to be rendered and the display size of each 3D character; wherein, the first canvas includes multiple rendering areas, and the size of each rendering area corresponds to the display size of the 3D character to be rendered; The character rendering module 603 is used to render the three-dimensional character to be rendered in multiple rendering areas based on the correspondence between the rendering area and the three-dimensional character, generate the rendering target texture corresponding to the first canvas, and pass the rendering target texture to the preset UI framework to render and display the three-dimensional character in the graphical user interface.
[0087] In some alternative implementations, the character rendering module 603 includes: The second canvas submodule is used to render the 3D character to be rendered in multiple rendering areas based on the correspondence between the rendering area and the 3D character, thus obtaining the second canvas.
[0088] The post-processing submodule is used to post-process the second canvas and generate the rendering target texture corresponding to the first canvas.
[0089] In some alternative implementations, the rendering region module 602 includes: The canvas width submodule is used to determine the width of the first canvas based on the number of characters and the width value of the display size corresponding to the 3D characters.
[0090] The Canvas Height submodule is used to determine the height of the first canvas based on the height value of the display size corresponding to the 3D character.
[0091] The Canvas Creation submodule is used to create the first canvas based on its width, height, and number of characters.
[0092] In some optional implementations, the canvas creation submodule includes: The third canvas unit is used to create a third canvas based on the width, height, and number of characters of the first canvas.
[0093] The character index unit is used to determine the character index corresponding to each 3D character.
[0094] The rendering region parameter unit is used to determine the rendering region parameters of a 3D character based on the character index and the size of the third canvas.
[0095] The canvas creation unit is used to determine the rendering area of the 3D character in the third canvas based on the rendering area parameters of the 3D character, and thus obtain the first canvas.
[0096] In some alternative implementations, the canvas creation unit includes: The rendering region generation subunit is used to generate a rendering region corresponding to the 3D character in the third canvas based on the rendering region parameters of the 3D character using a preset scope management class. The scope management class is used to manage the rendering region.
[0097] In some alternative implementations, the rendering region generation subunit is used for: Obtain the first rasterized state object of the third canvas through the scope management class.
[0098] The first configuration parameter corresponding to the first rasterized state object is modified to the second configuration parameter to obtain the second rasterized state object. The second configuration parameter is used to enable the region clipping function.
[0099] Based on the second rasterized state object and the rendering area parameters corresponding to each 3D character, determine the rendering area corresponding to the 3D character in the third canvas.
[0100] In some alternative implementations, the multi-role rendering apparatus further includes: The rendering area restoration subunit is used to restore the second rasterized state object to the first rasterized state object after post-processing the second canvas, and to delete the second rasterized state object and the second configuration parameters.
[0101] In some alternative implementations, the multi-role rendering apparatus further includes: The display instruction sending module is used to send display instructions to the UI framework. The display instructions are used to cause the UI framework to sample the rendering area corresponding to each 3D character from the rendering target texture, and display the rendering effect corresponding to the rendering area of each 3D character in the UI framework, so as to render and display the 3D character in the graphical user interface.
[0102] The multi-role rendering apparatus provided in this application embodiment can execute the multi-role rendering method provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects for executing the method. Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0103] Figure 7 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.
[0104] The following is a detailed reference. Figure 7 The diagram illustrates a structural schematic suitable for implementing the electronic device described in the embodiments of this application. The electronic device may include a processor (e.g., a central processing unit, graphics processor, etc.) 701, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 702 or a program loaded from memory 708 into random access memory (RAM) 703. The RAM 703 also stores various programs and data required for the operation of the electronic device. The processor 701, ROM 702, and RAM 703 are interconnected via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0105] Typically, the following devices can be connected to I / O interface 705: input devices 706 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 707 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; memory devices 708 including, for example, magnetic tapes, hard disks, etc.; and communication devices 709. Communication device 709 allows electronic devices to exchange data via wireless or wired communication with other devices. Although Figure 7Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.
[0106] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication device 709, or installed from memory 708, or installed from ROM 702. When the computer program is executed by processor 701, it performs the functions defined in the multi-role rendering method of embodiments of this application.
[0107] Figure 7 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0108] This application also provides a computer-readable storage medium. The methods described in this application can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code downloaded over a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the multi-role rendering method shown in the above embodiments is implemented.
[0109] A portion of this application can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to this application through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.
[0110] Although embodiments of this application have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of this application, and all such modifications and variations fall within the scope defined by the appended claims.
Claims
1. A multi-role rendering method, characterized by, The method of providing a graphical user interface via a terminal device includes: In response to a character rendering request, determine the 3D character to be rendered; A first canvas is created based on the number of the three-dimensional characters to be rendered and the display size corresponding to each of the three-dimensional characters; wherein, the first canvas includes multiple rendering areas, and the size of each rendering area corresponds to the display size of the three-dimensional character to be rendered; Based on the correspondence between the rendering area and the 3D character, the 3D character to be rendered is rendered in multiple rendering areas respectively, a rendering target texture corresponding to the first canvas is generated, and the rendering target texture is passed to a preset UI framework to render and display the 3D character in the graphical user interface.
2. The method of claim 1, wherein, The step of rendering the 3D character in multiple rendering areas based on the correspondence between the rendering area and the 3D character, and generating a rendering target texture corresponding to the first canvas, includes: Based on the correspondence between the rendering area and the 3D character, the 3D character to be rendered is rendered in multiple rendering areas respectively to obtain a second canvas; The second canvas is post-processed to generate a rendering target texture corresponding to the first canvas.
3. The method of claim 1, wherein, The process of creating a first canvas based on the number of 3D characters to be rendered and the display size corresponding to each 3D character includes: The width of the first canvas is determined based on the number of characters and the width value of the display size corresponding to the three-dimensional characters; The height of the first canvas is determined based on the height value of the display size corresponding to the three-dimensional character; A first canvas is created based on the width, height, and number of characters of the first canvas.
4. The method of claim 3, wherein, Creating the first canvas based on its width, height, and the number of characters includes: Create a third canvas based on the width, height, and number of characters of the first canvas; Determine the character index corresponding to each of the three-dimensional characters; Based on the character index and the size of the third canvas, determine the rendering area parameters of the 3D character; The rendering area corresponding to the 3D character in the third canvas is determined based on the rendering area parameters of the 3D character, and the first canvas is obtained.
5. The method of claim 4, wherein, Determining the rendering area corresponding to the 3D character in the third canvas based on the rendering area parameters of the 3D character includes: Using a preset scope management class, a rendering area corresponding to the 3D character is generated in the third canvas according to the rendering area parameters of the 3D character. The scope management class is used to manage the rendering area.
6. The method of claim 5, wherein, The step of generating a rendering area corresponding to the 3D character in the third canvas according to the rendering area parameters of the 3D character through a preset scope management class includes: The first rasterized state object of the third canvas is obtained through the scope management class; The first configuration parameter corresponding to the first rasterized state object is modified to the second configuration parameter to obtain the second rasterized state object; the second configuration parameter is used to enable the region clipping function; Based on the second rasterized state object and the rendering area parameters corresponding to each of the three-dimensional characters, the rendering area corresponding to the three-dimensional character in the third canvas is determined.
7. The method of claim 6, wherein, The method further includes: After generating the rendering target texture corresponding to the first canvas, the second rasterized state object is restored to the first rasterized state object, and the second rasterized state object and the second configuration parameter are deleted.
8. The method according to claim 1, characterized in that, After passing the rendering target texture to the preset UI framework, the method further includes: A display instruction is sent to the UI framework; the display instruction is used to cause the UI framework to sample the rendering area corresponding to each of the three-dimensional characters from the rendering target texture, and to display the rendering effect corresponding to the rendering area of each of the three-dimensional characters in the UI framework, so as to render and display the three-dimensional characters in the graphical user interface.
9. A multi-character rendering device, characterized in that, The device includes: The character quantity module is used to determine the 3D characters to be rendered in response to character rendering requests; A rendering area module is used to create a first canvas based on the number of the three-dimensional characters to be rendered and the display size corresponding to each of the three-dimensional characters; wherein, the first canvas includes multiple rendering areas, and the size of each rendering area corresponds to the display size of the three-dimensional character to be rendered; The character rendering module is used to render the three-dimensional character to be rendered in multiple rendering areas based on the correspondence between the rendering area and the three-dimensional character, generate a rendering target texture corresponding to the first canvas, and pass the rendering target texture to a preset UI framework to render and display the three-dimensional character in the graphical user interface.
10. An electronic device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the multi-role rendering method of any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to execute the multi-role rendering method according to any one of claims 1 to 8.
12. A computer program product, characterized in that, Includes computer instructions for causing a computer to execute the multi-role rendering method according to any one of claims 1 to 8.