Character skin drawing method, system, and electronic device
By using Command Buffer to perform subsurface scattering calculations of character skins in the game, the hysteresis problem during game rendering is solved, achieving more efficient performance and smoother gaming experience.
Patent Information
- Application Number
- CN202111261002.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-27
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2041-10-27
AI Technical Summary
The prior art requires a lot of calculations when rendering the skin of the game character, which leads to a decrease in the drawing speed of the display card and the problem of screen hysteresis.
By drawing the character skin area again using the Command Buffer, the character subsurface scattering calculations are simplified from screen space to Command Buffer, using multiple Command Buffers to compute in parallel and optimized based on character priorities and GPU available memory.
Optimize the performance and game effects of the mobile terminal, reduce the phenomenon of hysteresis in the game screen, and improve the user experience.
Smart Images

Figure CN114042312B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of game rendering, and in particular to a method, system, and electronic device for drawing character skin. Background Art
[0002] At present, the core content of skin rendering of game characters is skin subsurface scattering. In order to achieve this, the more popular methods can be roughly divided into two categories: 1. Subsurface scattering based on screen space; 2. PreIntegrate rendering technology based on calculus.
[0003] The screen space method is similar to the image space method, except that the output position when calculating irradiance is not the UV coordinate but the projection coordinate of the model. In addition, the pixels belonging to the skin material in the screen space need to be marked with a stencilbuffer, and then the marked skin material is subjected to several convolution operations. The weight of the convolution kernel is determined by the diffusion profile, and the size of the convolution kernel needs to be determined based on the depth of the current pixel (d(x,y)) and its derivatives (dFdx(d(x,y)) and dFdy(d(x,y)).
[0004] In the process of implementing the present application, the inventors discovered that there are at least the following problems in the prior art: the existing method of performing subsurface scattering calculations on each game character in screen space requires a large amount of computation, which may exceed the upper limit of the computing power of the current ordinary graphics card GPU, reducing the drawing speed of the graphics card and causing the game image to lag on the screen. Summary of the invention
[0005] To this end, the embodiments of the present application provide a method, system, and electronic device for drawing a character skin, which can solve the technical problem that the game scene display is prone to lag when rendering the character skin. The specific technical solution is as follows:
[0006] In a first aspect, an embodiment of the present application provides a method for drawing character skin, the method comprising:
[0007] After the character is drawn, the Command Buffer is used to draw the character's skin area again. The redrawing includes: superimposing the subsurface scattering effect on the drawn character's skin area.
[0008] By adopting the above technical solution, the subsurface scattering calculation of the character's skin is drawn using the Command Buffer, and the character's subsurface skin information is simplified from the screen space to the Command Buffer. In general scenes, the pixel proportion of the skin area is very small, and the drawing calculation amount is smaller than the calculation amount of the entire screen space. The performance and game effects of the mobile terminal are optimized, and the lag phenomenon of the game displayed on the screen is reduced.
[0009] Preferably, the using the Command Buffer to redraw the character skin area comprises:
[0010] Set role priority;
[0011] Use Command Buffer to draw the character skin area again according to the character priority.
[0012] By adopting the above technical solution, rendering is performed according to the role priority, and important roles are rendered first to improve the user experience.
[0013] Preferably, redrawing the character skin area using the Command Buffer according to the character priority includes: performing subsurface scattering calculations on the character skin in the Command Buffer in sequence according to the character skin priority.
[0014] By adopting the above technical solution, the character skin area is drawn according to the character priority, the amount of calculation for drawing at the same time is reduced, and the amount of device resources occupied by character skin effect drawing is further reduced, thereby optimizing the performance of the mobile terminal and the performance of the game effects, and reducing the lag in the game screen display.
[0015] Preferably, the using the Command Buffer to redraw the character skin area comprises:
[0016] Set up multiple Command Buffers, and use multiple Command Buffers to parallelly calculate the subsurface scattering calculations of multiple characters' skins. By adopting the above technical solution, multiple Command Buffers are used to render game characters in parallel, reducing the delay of character rendering in the same frame in the game scene, and achieving a better game scene rendering effect.
[0017] Preferably, the using the Command Buffer to redraw the character skin area comprises:
[0018] Get the current GPU available memory;
[0019] If the current GPU available memory is lower than the memory required for the subsurface scattering of all current character skin areas, the Command Buffer is used in turn to calculate the character skin subsurface scattering;
[0020] If the current GPU has sufficient available memory, set up multiple Command Buffers and use multiple Command Buffers to parallelize the subsurface scattering calculations of multiple character skins.
[0021] By adopting the above technical solution, the Command Buffer processing solution is selected according to the GPU memory. When the current GPU has less available memory, the character skin rendering order is serially processed by calculating the character skin subsurface scattering in the Command Buffer in sequence according to the character priority, thereby reducing the GPU overflow. When the current GPU has more available memory, multiple Command Buffers are used to calculate the character skin subsurface scattering in parallel to achieve a better rendering scene, thereby achieving a balanced effect between device performance and rendering effect.
[0022] Preferably, the method for setting the role priority is:
[0023] Obtaining character attributes, the character attributes including the main character, the main character's opponent, the main character's teammates, and NPCs;
[0024] Determine the role priority of the roles based on their attributes.
[0025] By adopting the above technical solution, the role priorities are divided according to different role attributes to achieve the effect of refined control.
[0026] Preferably, when the distance between the character and the screen exceeds the set maximum display distance of the character skin effect, the skin area of the character is not drawn again.
[0027] By adopting the above technical solution, the amount of calculation of subsurface scattering of the character's skin can be effectively reduced, the performance of the mobile terminal and the performance of the game effects can be further optimized, and the lag phenomenon of the game displayed on the screen can be reduced.
[0028] In a second aspect, an embodiment of the present application provides a character sub-surface separation system, the system comprising:
[0029] The calculation module is used to use the Command Buffer to redraw the character skin area after the character drawing is completed. The redrawing includes: superimposing the subsurface scattering effect on the drawn character skin area.
[0030] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of any of the aforementioned character skin drawing methods when executing the computer program.
[0031] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the character skin drawing method described in any one of the above items are implemented.
[0032] In summary, compared with the prior art, the technical solution provided in the embodiment of the present application has at least the following beneficial effects:
[0033] 1. Use Command Buffer to draw the subsurface scattering calculation of the character's skin, and simplify the character's subsurface skin information from the screen space to the Command Buffer. In general, the skin area accounts for a small proportion of pixels in the scene, so the drawing calculation amount is smaller than the calculation amount of the entire screen space, which optimizes the performance of the mobile terminal and the performance of the game effect, and reduces the lag of the game screen display;
[0034] 2. Draw the character skin area in sequence according to the character priority, reduce the amount of calculation for drawing at the same time, and further reduce the amount of device resources occupied by character skin effect drawing, thereby optimizing the performance of the mobile terminal and the performance of the game effect, and reducing the lag of the game screen display;
[0035] 3. Select the Command Buffer processing solution based on the GPU memory. When the current GPU has less available memory, the command buffer is used to calculate the subsurface scattering of characters according to their priority, which reduces the GPU overflow. When the current GPU has more available memory, multiple command buffers are used to calculate the subsurface scattering of the character's skin in parallel to achieve a better rendering scene and a balanced effect between device performance and rendering effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 It is a flowchart of the character skin drawing method provided in Example 1 of the present application.
[0037] Figure 2 This is one of the flow charts of a method for drawing character skin provided in another implementation manner in Example 1 of the present application.
[0038] Figure 3This is the second flow chart of the character skin drawing method provided by another implementation method in Example 1 of the present application.
[0039] Figure 4 This is the third flow chart of the character skin drawing method provided by another implementation method in Example 1 of the present application.
[0040] Figure 5 It is a structural diagram of the character skin drawing system provided in Example 1 of the present application.
[0041] Figure 6 It is a schematic diagram of the structure of the electronic device provided in Example 1 of the present application.
[0042] Figure 7 It is a flowchart of the character skin drawing method provided in Example 2 of the present application.
[0043] Figure 8 It is a flowchart of the character skin drawing method provided in Example 3 of the present application. DETAILED DESCRIPTION
[0044] This specific embodiment is merely an explanation of the present application and is not a limitation of the present application. After reading this specification, those skilled in the art may make modifications to the present embodiment without any creative contribution as needed, but such modifications are protected by the patent law as long as they are within the scope of the claims of the present application.
[0045] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0046] In this application, the terms "first", "second", etc. are used to distinguish identical or similar items with substantially the same effects and functions. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor are there any limitations on quantity and execution order.
[0047] The embodiments of the present application are further described in detail below in conjunction with the drawings in the specification.
[0048] Embodiment 1
[0049] Reference Figure 1 In one embodiment of the present application, a method for drawing character skin is provided, and the main steps of the method are described as follows:
[0050] S0: After the character is drawn, the Command Buffer is used to draw the character's skin area again. The redrawing includes: superimposing the subsurface scattering effect on the drawn character's skin area.
[0051] Subsurface scattering (3S for short) is the phenomenon that light enters a non-metallic material and then undergoes internal subsurface scattering, and finally exits the object and enters the field of view. It refers to the light transmission process in which light enters an object from the surface, is scattered internally, and then exits through other vertices on the surface of the object. Specifically, Command Buffer is a command buffer that carries a series of rendering commands and is camera-dependent, used to extend the rendering effect of the rendering pipeline. Command Buffer can be used to perform additional rendering at a certain stage of camera rendering, and can specify a certain point in camera rendering to perform its own extended rendering.
[0052] Separable skin subsurface scattering calculations can be performed independently in the Command Buffer.
[0053] When rendering the character's skin, the character's sub-surface skin information is simplified from the screen space to the CommandBuffer. In general, the skin area accounts for a very small proportion of pixels in the scene, and the drawing calculation amount is smaller than the calculation amount of the entire screen space. This optimizes the performance of the mobile terminal and the performance of the game, and reduces the lag in the game display on the screen.
[0054] Secondly, skin subsurface scattering calculations are performed in the Command Buffer to reduce the impact of other parts, such as simulated light results close to the skin, hair, and clothing, when rendering the skin. This makes the character's rendering effect more uniform and less likely to cause sudden changes in the character's skin effect due to the influence of other light calculations.
[0055] Reference Figure 2 Optionally, in another embodiment, using the Command Buffer to redraw the character skin area includes:
[0056] S1: Set role priority;
[0057] S2: Use Command Buffer to draw the character skin area again according to the character priority.
[0058] Specifically, in this embodiment, the role skin sets the role priority in a way that the role priority is divided according to the distance of the role from the main light source in the current screen, and the closer the role is to the main light source, the higher the priority. For example, there are three roles A, B, and C in the current scene. The distance between A and the main light source is a, the distance between B and the main light source is b, and the distance between C and the main light source is c. If a>b>c, then the role priority is A>B>C. When rendering the role skin, the skin subsurface calculation of role A is performed first, and then the skin subsurface scattering calculation of roles B and C is performed.
[0059] Optionally, in another embodiment, corresponding skin effect parameters, such as skin blur range parameters, are stored in the skin data of each character. When rendering is performed using the Command Buffer, the skin effect parameters stored in the character skin data are read to accurately control the strength of the skin effect of each character.
[0060] By dividing the role priority, subsurface scattering calculation is performed on the role skin according to the importance of the role skin. The role priority is divided according to the importance of the role. When users watch the game scene, their attention is often focused on important characters, such as characters close to the main light source. Characters close to the main light source receive more light according to common sense, so the skin subsurface scattering rendering effect will be better than the rendering effect of characters farther away from the main light source, and it is also easier to be seen by the user. When rendering characters, important characters are rendered first. From the user's perspective, the picture rendering is smoother and less likely to be stuck.
[0061] Reference Figure 3 , Optionally, in another embodiment, the specific implementation of step S2 is S21:
[0062] S21: Perform subsurface scattering calculations on the character skin in the Command Buffer in turn according to the character priority.
[0063] Specifically, in the present embodiment, the Command Buffer is used to calculate the character skin subsurface scattering calculation data in a manner that the Command Buffer is used in a descending order according to the priority of the characters. Thus, when rendering, the character skin that is easily noticed by the user is rendered first, and the character skin that is noticed second is rendered later. By rendering in sequence, the user can have a better experience of the game scene while occupying less GPU resources, reduce the processing pressure of the game device processor, and reduce the occurrence of GPU overflow.
[0064] Optionally, in another implementation, the method for setting the role priority is:
[0065] 1. Obtaining character attributes, including the main character, the main character's opponent, the main character's teammates, and NPCs;
[0066] 2. Determine the role priority of the role based on the role attributes.
[0067] Specifically, determining the role priority of a role according to the role attributes further includes the following situations:
[0068] For roles with the same role attributes, the role priorities are divided according to the corresponding status information of the roles;
[0069] For characters with different attributes, the role priorities are divided according to the interaction status between the current character and the main character.
[0070] Here are some examples:
[0071] If the character attributes of several characters are all the main character, then these characters have the same character attributes, and the status information corresponding to these characters includes attack status and non-attack status, and the priority of the main character in the attack status is higher than that of the main character in the non-attack status. In addition, the status information corresponding to the main character is not limited to this, and will not be repeated here.
[0072] If the character attributes of several characters are all opponents of the main character, then these characters have the same character attributes, and the status information corresponding to these characters includes attack status and non-attack status, and the opponent of the main character in the attack status has a higher priority than the opponent of the main character in the non-attack status. In addition, the status information corresponding to the opponent of the main character is not limited to this, and will not be repeated here.
[0073] If the character attributes of several characters are teammates of the main character, then these characters have the same character attributes. At this time, the status information corresponding to these characters includes the spatial distance value between the teammates of the main character and the main character and the current state of the main character. The current state of the main character includes the attack state and the non-attack state. When the main character is in the attack state, the smaller the spatial distance value between the teammates of the main character and the main character, the lower the role priority of the teammates of the main character. When the main character is in the non-attack state, the smaller the spatial distance value between the teammates of the main character and the main character, the higher the role priority of the teammates of the main character. In addition, the status information corresponding to the teammates of the main character is not limited to this, and will not be repeated here.
[0074] If the character attributes of several characters are all NPCs, then these characters have the same character attributes. At this time, the status information corresponding to these characters includes the spatial distance between the NPC and the screen. The closer the NPC is to the screen, the higher the priority of the character. In addition, the status information corresponding to the NPC is not limited to this, and will not be repeated here.
[0075] Specifically, in this embodiment, the role priority of the main character is higher than that of other characters, and the role priorities of other game characters are set according to the method as described above; in other embodiments, role attributes may also include teammates in non-main roles and opponent players in the main role, etc. The scope of role attributes in this application is not limited to the types exemplified in this embodiment.
[0076] When the characters have different attributes, the main character has the highest priority, and other characters are prioritized according to the interaction status between the current character and the main character. The interaction status between the current character and the main character includes an interactive state and a non-interactive state.
[0077] The interactive state includes the instant interactive state and the continuous interactive state. The instant interactive state is the state of information interaction at the current moment, such as the attack state and the dialogue state; the continuous interactive state is the state of long-term association, such as the follow state and the team state in the game scene. In the game scene, in the interactive state, the role priority of the character in the instant interactive state is higher than the role priority of the character in the continuous interactive state; and the role priority of the character in the instant interactive state is determined according to the screen area occupied by the current character. The larger the screen area occupied by the current character, the higher the role priority. The role priority of the character in the continuous interactive state is also determined according to the screen area occupied by the current character. The larger the screen area occupied by the current character, the higher the role priority. The role priority of the character in the interactive state is higher than the role priority of the character in the non-interactive state. The role priorities of multiple characters in the non-interactive state are determined according to the screen area occupied by the current character. The larger the screen area occupied by the current character, the higher the role priority; when the continuous interactive state and the instant interactive state coexist, the role priority is set according to the instant interactive state.
[0078] For example: when there are 8 characters in the data frame to be rendered, including 2 main characters, 2 opponents of the main character, 2 teammates of the main character and 2 NPCs; the main characters include A and B, the opponents of the main character include C and D, the teammates of the main character include E and F, and the NPCs include G and H. In the current data frame to be rendered, A is in an attacking state and B is in a non-attack state, so the role priority of A is higher than the role priority of B; C is in an attacking state and D is in a non-attack state, so the role priority of C is higher than the role priority of D, C and A are in a real-time interactive state, and D is in a non-interactive state; at this time, A is in an attacking state, and the spatial distance value between E and A is greater than the spatial distance value between F and A, so the role priority of E is greater than the role priority of F, F and B are in a real-time interactive state, and E and F are both in a continuous interactive state with A and B; the distance between G and the screen is less than the distance between H and the screen, so the role priority of G is higher than the role priority of H, G and B are in a real-time interactive state, and H is in a non-interactive state. C occupies a larger screen area than G, H occupies a larger screen area than D, and G occupies a larger screen area than F, so the role priority is: A>B>C>G>E>F>H>D. The specific logic is that A is the main character and is in an attacking state, so A's role priority is the highest, B is the main character, so B's role priority is lower than A and higher than other characters; C and A are in an instant interaction state, F and B are in an instant interaction state, and G and B are in an instant interaction state. Based on the size of the screen area occupied, the priority of C, F, and G is C>G>F; while E is in a continuous interaction state, and C is in an instant interaction state, so C's role priority is higher than E; G is in an instant interaction state, so G's role priority is higher than E; F is in an instant interaction state, so F's role priority is higher than H; E is in a continuous interaction state, so E's role priority is higher than H; because H occupies a larger screen area than D, H's role priority is higher than D.
[0079] It should be noted that the method for determining role priority in the present application is not limited to this. For example, the role priority order between characters with different role attributes can also be pre-set, main character>opponent of the main character>teammate of the main character>NPC, and role priority judgment is only performed between characters with the same role attributes. The role priority order between characters with different role attributes is not limited to the examples in this implementation manner.
[0080] Reference Figure 4 Optionally, in another embodiment, the character skin drawing method further includes S3:
[0081] S3: When the distance between the character and the screen exceeds the set maximum display distance of the character skin effect, the skin area of the character will not be redrawn.
[0082] Specifically, in this embodiment, by adopting the above technical solution, the amount of calculation during device rendering is reduced, thereby reducing the freeze of the user's mobile terminal display screen and improving the user experience. In this embodiment, since the character skin subsurface scattering calculation is performed in the Command Buffer, it is independent of other scene renderings, so it is relatively easy to turn on and off, and has little impact on other scene renderings.
[0083] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0084] Reference Figure 5 In one embodiment of the present application, a character subsurface separation system is provided, and the character subsurface separation system corresponds one-to-one to the character skin drawing method in the above embodiment. The character subsurface separation system includes:
[0085] The calculation module is used to use the Command Buffer to redraw the character skin area after the character drawing is completed. The redrawing includes: superimposing the subsurface scattering effect on the drawn character skin area.
[0086] Furthermore, in another embodiment, the calculation module also includes a priority setting submodule and a rendering submodule.
[0087] The priority setting submodule is used to set the role priority;
[0088] The rendering submodule is used to use Command Buffer to redraw the character skin area. The use of Command Buffer to redraw the character skin area is performed according to the role priority.
[0089] Furthermore, in another embodiment, redrawing the character skin area using the Command Buffer according to the character priority includes: performing subsurface scattering calculations on the character skin in the Command Buffer in sequence according to the character skin priority.
[0090] Furthermore, in another embodiment, the method for setting the role priority is:
[0091] 1. Obtaining character attributes, including the main character, the main character's opponent, the main character's teammates, and NPCs;
[0092] 2. Determine the role priority of the role based on the role attributes.
[0093] Specifically, the role priority of a role is determined based on the role attributes, including the following situations:
[0094] For roles with the same role attributes, the role priorities are divided according to the corresponding status information of the roles;
[0095] For characters with different attributes, the role priorities are divided according to the interaction status between the current character and the main character.
[0096] Furthermore, in another embodiment, the system also includes a control module.
[0097] The control module is used for not redrawing the skin area of the character when the distance between the character and the screen exceeds the set maximum display distance of the character skin effect.
[0098] Each module of the skin subsurface separation system can be implemented in whole or in part by software, hardware, or a combination thereof. Each module can be embedded in or independent of a processor in an electronic device in the form of hardware, or can be stored in a memory in an electronic device in the form of software, so that the processor can call and execute operations corresponding to each module.
[0099] Reference Figure 6 In one embodiment of the present application, an electronic device is provided, which may be a server. The electronic device includes a processor, a memory and a network interface connected via a system bus. The processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device may be implemented by any type of volatile or non-volatile storage device or a combination thereof, and the volatile or non-volatile storage device includes but is not limited to: a disk, an optical disk, an EEPROM (Electrically-Erasable Programmable Read Only Memory), an EPROM (Erasable Programmable Read Only Memory), an SRAM (Static Random Access Memory), a ROM (Read-Only Memory), a magnetic memory, a flash memory, and a PROM (Programmable Read-Only Memory). The memory of the electronic device provides an environment for the operation of the operating system and computer programs stored therein. The network interface of the electronic device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, the steps of the data processing method described in the above embodiment are implemented.
[0100] In one embodiment of the present application, a computer-readable storage medium is provided. It should be noted that in the present application, the computer-readable storage medium may also be referred to as a readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the steps of the character skin drawing method described in the above embodiment are implemented. The computer-readable storage medium includes a ROM (Read-Only Memory), a RAM (Random-Access Memory), a CD-ROM (Compact Disc Read-Only Memory), a magnetic disk, a floppy disk, etc.
[0101] Embodiment 2
[0102] The difference between this embodiment and the first embodiment is that the specific implementation method of using the Command Buffer to redraw the character's skin area is different.
[0103] Reference Figure 7 In this embodiment, the Command Buffer is used to draw the character skin area again as follows:
[0104] S1: Set up multiple Command Buffers and use multiple Command Buffers to parallelly calculate the subsurface scattering of multiple character skins.
[0105] In the actual game scene rendering process, when the character drawing is completed, the parallel Command Buffer is used to realize the simultaneous rendering of multiple game character skins. For the overall scene rendering effect, the rendering effect is better. The skin effects of each character in the scene are rendered at the same time, reducing the situation where the scene rendering is not synchronized and causes partial delays in the rendering of the picture.
[0106] Specifically, in another embodiment, when multiple character skin subsurface scattering calculations use multiple CommandBuffers, the corresponding relationship between different character skin subsurface scattering calculations and different CommandBuffers can be set according to the character priority:
[0107] The multiple Command Buffers are sorted in order of the GPU memory occupation according to the difference in the GPU memory occupation. The skin subsurface scattering calculation of the character with high priority is calculated using the Command Buffer with high GPU memory occupation according to the role priority. The logic of matching the role priority and the Command Buffer is to assign the character skin subsurface scattering calculation to the corresponding Command Buffer for calculation according to the role priority and the order of the Command Buffer.
[0108] GPU (graphics processing unit), also known as display core, visual processor, display chip, is a microprocessor that is specially used for image and graphics related computing on personal computers, workstations, game consoles and some mobile devices (such as tablet computers, smart phones, etc.). Specifically, in this embodiment, multiple command buffers are preset in a device such as a server, and the memory sizes occupied by the command buffers may be the same or different. In this embodiment, the memory sizes occupied by multiple command buffers are set to be the same.
[0109] In this embodiment, the number of Command Buffers is set in the following ways: 1. The number of Command Buffers is set according to the number of characters that need to perform skin subsurface scattering calculation in the currently rendered data frame. 2. The number of Command Buffers is set according to the level of the character priority in the currently rendered data frame. Specifically, the number of character priorities corresponding to the characters can be pre-set, the character priorities between different characters are pre-set, and then the character priorities are associated with the corresponding Command Buffers, and the corresponding characters are imported into their corresponding Command Buffers for calculation. 3. Several Command Buffers are fixedly set, and the character skin subsurface scattering calculations are imported into the Command Buffer in sequence according to the character priorities; when a certain Command Buffer is processed, the unrendered character skin subsurface scattering calculations are imported into the Command Buffer according to the character priorities; when multiple Command Buffers are processed at the same time, the character skin subsurface scattering calculations are assigned to the corresponding Command Buffers for calculation according to the order of the character priorities and the Command Buffers. In other embodiments of the present application, there may be other logics for setting the number of Command Buffers, and the examples listed in this embodiment are not regarded as limitations on other embodiments of the present application.
[0110] If multiple Command Buffers are preset and the GPU memory occupied by them is different when they are called, the processing capacity of CommandBuffer is different. The skin subsurface scattering calculation of characters with high role priority is calculated in the Command Buffer that occupies more GPU memory. The character skin subsurface scattering calculation is coordinated with the Command Buffer called by the character skin subsurface scattering calculation according to the role priority and the order of CommandBuffer, so as to achieve the effect of reasonable resource allocation. Under limited GPU content, characters with high role priority can use more resources for rendering, with fast rendering speed and good rendering effect. At the same time, multiple Command Buffers are set to process the character skin subsurface scattering calculation in parallel, so that the rendering effect of the game scene is better and the game screen is not prone to lag.
[0111] In one embodiment of the present application, a rendering submodule in a character sub-surface separation system includes a calling unit and a matching unit.
[0112] The calling unit is used to set multiple Command Buffers, and use multiple Command Buffers to calculate the subsurface scattering of multiple characters' skins in parallel;
[0113] The matching unit is used to match the skin subsurface scattering calculation of a high-priority character to the Command Buffer with high GPU memory usage according to the character priority. The logic of matching the character priority and the Command Buffer is to allocate the skin subsurface scattering calculation of the character to the corresponding Command Buffer for calculation according to the order of the character priority and the Command Buffer.
[0114] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0115] Embodiment 3
[0116] The difference between this embodiment and the first embodiment is that the specific implementation method of using the Command Buffer to redraw the character's skin area is different.
[0117] Reference Figure 8 In this embodiment, the specific implementation method of using Command Buffer to redraw the character skin area is as follows:
[0118] S11: Get the current GPU available memory;
[0119] S12: If the current GPU available memory is lower than the memory required for the subsurface scattering of all current character skin areas, the Command Buffer is used in turn to calculate the character skin subsurface scattering;
[0120] S13: If the current GPU has sufficient available memory, set up multiple Command Buffers and use multiple Command Buffers to parallelly calculate the subsurface scattering of multiple character skins.
[0121] When the current GPU available memory is lower than the memory required for the subsurface scattering of the skin areas of all current characters, the characters that need to be rendered currently are calculated in turn using the Command Buffer, thereby reducing the possibility of GPU overflow; further, in other embodiments, the Command Buffer can be used in turn to calculate the subsurface scattering of the character skin according to the role priority; further, in other embodiments, a set of characters can be set according to the current GPU available memory, and the set of characters is formed by a combination of characters whose required memory for calculation is less than the current GPU available memory. When rendering, the characters in the set of characters are preferentially rendered. The skins of the characters in the set of characters are set according to the role priority setting method in Example 1. By adopting this technical solution, when the GPU has less available memory, the rendering of the skins of important characters can be achieved as much as possible, and the GPU overflow can also be reduced.
[0122] For example: when there are 5 characters in the data frame to be rendered, the priorities of the 5 characters are level 1, level 2, level 3, level 4, and level 5, respectively. Level 1 has a higher priority than level 2, and so on. The current GPU available memory is 3%. It can be seen that the GPU memory required for skin subsurface scattering calculations for characters corresponding to levels 1, 3, and 5 is less than 3%, and the GPU memory required for skin subsurface scattering calculations for characters corresponding to levels 2 and 4 is greater than 3%. The character set consists of characters corresponding to levels 1, 3, and 5, and the priority of the characters in the character set is level 1>level 3>level 5. During the period when the GPU available memory is less than 3%, the characters in the character set are rendered first according to the role priority, that is, the characters corresponding to level 1 are rendered first, then the characters corresponding to level 3, and finally the characters corresponding to level 5, and the rendering of characters outside the character set is suspended.
[0123] If the current GPU memory is available, multiple command buffers are used for parallel rendering to achieve better rendering results and make the game scene less prone to lag.
[0124] In the actual game scene rendering process, parallel Command Buffer is used to achieve simultaneous rendering of multiple game character skins. For the overall scene rendering effect, the rendering effect is better. The skin effects of each character in the scene are rendered at the same time, reducing the situation where the scene rendering is not synchronized and causes partial delays in the rendering of the picture.
[0125] In one embodiment of the present application, a rendering submodule in a character sub-surface separation system includes a calling and sorting unit, an information acquisition unit, a first calculation unit, and a second calculation unit.
[0126] The information acquisition unit is used to obtain the current GPU available memory;
[0127] The first calculation unit is used for setting the role priority according to the current GPU available memory if the current GPU available memory is lower than the memory required for the subsurface scattering of all the current role skin areas, and performing subsurface scattering calculations on the role skins in turn in the CommandBuffer according to the priority of the role skins;
[0128] The calling and sorting unit is used to set a plurality of command buffers, and the plurality of command buffers are sorted in order of the least occupied GPU memory according to the difference in the occupied GPU memory;
[0129] The second calculation unit is used to use multiple Command Buffers to parallelly calculate the subsurface scattering calculations of multiple character skins if the current GPU has sufficient available memory.
[0130] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0131] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the system described in the present application is divided into different functional units or modules to complete all or part of the functions described above.
Claims
1. A method for drawing character skin, characterized in that: The method comprises: Get the distance between the character and the main light source and the distance between the character and the screen; The role priority is divided according to the distance between the character and the main light source on the current screen. The closer the character is to the main light source, the higher the priority; Draw the character. After the drawing is completed, perform subsurface scattering calculations on the character's skin area in the Command Buffer in the order of the character's priority, from the highest priority to the lowest priority. After the subsurface scattering calculation is completed, the subsurface scattering effect is superimposed on the character; When the distance between the character and the screen exceeds the set maximum display distance of the character's skin effect, subsurface scattering calculation and superposition of subsurface scattering effects are not performed on the character's skin area.
2. The character skin drawing method according to claim 1, characterized in that: The step of performing subsurface scattering calculation on the skin area of the character in the Command Buffer in order from the character with the highest priority to the character with the lowest priority in the order of the character priority also includes: Set up multiple Command Buffers to use multiple Command Buffers in parallel to calculate the subsurface scattering of multiple character skins.
3. The character skin drawing method according to claim 1, characterized in that: The step of performing subsurface scattering calculation on the skin area of the character in the Command Buffer in order from the character with the highest priority to the character with the lowest priority in the order of the character priority also includes: Get the current GPU available memory; If the current GPU available memory is lower than the memory required for the subsurface scattering of all current character skin areas, the Command Buffer is used in turn to calculate the character skin subsurface scattering; If the current GPU has sufficient available memory, set up multiple Command Buffers and use multiple Command Buffers to parallelize the subsurface scattering calculations of multiple character skins.
4. The character skin drawing method according to claim 1, characterized in that: The method for setting the role priority includes: Obtaining character attributes, the character attributes including the main character, the main character's opponent, the main character's teammates, and NPCs; Obtain the interactive state of the character, and when the character whose character attributes do not belong to the main character is in the interactive state, obtain the area of the screen occupied by the current character; The closer the character is to the main light source, the higher the priority is set; Set the priority of character attributes from high to low to be the main character, the protagonist's opponent, the protagonist's teammate, and the NPC; When a character that is not the main character is in an interactive state, the larger the screen area occupied by the current character, the higher the character priority is set; The role priority is determined comprehensively based on the distance of the role from the main light source, the role attributes and the area of the occupied screen.
5. A character subsurface separation system, characterized in that: The system comprises: The calculation module is used to obtain the distance between the character and the main light source and the distance between the character and the screen; the character priority is divided according to the distance between the character and the main light source in the current screen, and the closer the character is to the main light source, the higher the priority; the character is drawn, and after the drawing is completed, the subsurface scattering calculation is performed on the skin area of the character in the order of the character priority from the high priority to the low priority in the Command Buffer; after the subsurface scattering calculation is completed, the subsurface scattering effect is superimposed on the character; when the distance between the character and the screen exceeds the set maximum display distance of the character skin effect, the subsurface scattering calculation and the superimposition of the subsurface scattering effect on the skin area of the character are not performed.
6. An electronic device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and running on the processor, wherein the processor implements the steps of the character skin drawing method according to any one of claims 1 to 4 when executing the computer program.
7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the character skin drawing method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Big scene three-dimensional rendering method and system
CN107507262A
Object rendering method and device, storage medium and electronic device
CN109499059A
Special effect distortion processing method and device, electronic equipment and medium
CN112489170A
Skin rendering method and device for game roles, and electronic equipment
CN113069764A
Mechanism for selecting instructions for execution in a multithreaded processor
US20060004989A1