Rendering Method and Device for Hairstyles in Game Scenes, Electronic Device, and Storage Medium
Rendering through hairstyle partition parameters and map channel parameters, the large amount of data storage and transmission delay caused by programmatic modeling is solved, and the personalized needs of hairstyles and low-latency data transmission in the game are realized.
Patent Information
- Application Number
- CN202111665675.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-31
- Publication Date
- 2025-07-04
- Estimated Expiration
- 2041-12-31
AI Technical Summary
In the prior art, the construction of hairstyles through programmatic modeling leads to excessive data storage and delay in data transmission.
Through hairstyle partition parameters and map channel parameters, determine the target hairstyle area of the virtual character and the target channel in the corresponding target hairstyle map, directly render, avoid programmatic modeling, realize personalized hairstyle needs, and reduce data transmission delay in multiplayer online games.
It realizes data transmission with low latency in multiplayer online games, meets the needs of personalized hairstyles, and reduces data storage and transmission delay.
Smart Images

Figure CN114288648B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of game technologies, and particularly to a method and apparatus for rendering hairstyles in a game scene, an electronic device, and a storage medium. Background Art
[0002] In order to enrich more personalized gameplay for players and enhance the differentiation of products, in the case where functions such as face pinching and beauty makeup are already very common, the concept of hairstyle design has been proposed in games. The currently commonly used method is to perform hairstyle design through a digital haircut simulator. This solution performs fine procedural modeling on the hair, abstracts each part of the hair into detail units, and can perform plasticity and trimming in multiple modes for each detail unit. However, if the current game is a multiplayer online game, using a digital haircut simulator for hairstyle design will result in a too high Draw Call (a type of command in the command buffer), a too large data storage volume, and thus a too low frame rate and a large network transmission pressure. Summary of the Invention
[0003] The purpose of the embodiments of this application is to provide a method and apparatus for rendering hairstyles in a game scene, an electronic device, and a storage medium, so as to solve the problem in the prior art that the data storage volume is relatively large when building a hairstyle through procedural modeling, resulting in data transmission delay. The specific technical solutions are as follows:
[0004] In the first aspect implemented in this application, first, a method for rendering a hairstyle in a game scene is provided, including: in response to a hairstyle selection operation for a virtual character, determining the hairstyle partition parameters and texture mapping channel parameters in the hairstyle selection operation; according to the hairstyle partition parameters and the texture mapping channel parameters, determining the target hairstyle area of the virtual character and the target channel in the target hairstyle texture map corresponding to the target hairstyle area, where the hairstyle texture maps stored in different channels of the target hairstyle texture map correspond to different hairstyle lengths of the target hairstyle area; and rendering the target hairstyle area of the virtual character according to the hairstyle texture map stored in the target channel.
[0005] Optionally, rendering the target hairstyle area of the virtual character according to the hairstyle texture map stored in the target channel includes: when the target channel is a preset channel, performing texture sampling on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area respectively according to the first set of texture coordinates corresponding to the target hairstyle area, so as to obtain a first sampling result and a second sampling result; rendering the target hairstyle area of the virtual character based on the first sampling result and the second sampling result; when the target channel is a non-preset channel, performing texture sampling on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area respectively according to the second set of texture coordinates corresponding to the target hairstyle area, so as to obtain a third sampling result and a fourth sampling result; rendering the target hairstyle area of the virtual character based on the third sampling result and the fourth sampling result.
[0006] Optionally, after rendering the target hairstyle area of the virtual character, the method further includes: obtaining an input adjustment parameter; adjusting the length of the hairstyle in the hairstyle texture map in the target channel based on the adjustment parameter; rendering the target hairstyle area of the virtual character based on the adjusted hairstyle texture map.
[0007] Optionally, before determining the hairstyle partition parameter and the texture map channel parameter in the hairstyle selection operation in response to a hairstyle selection operation on the virtual character, the method further includes: mapping the initial second set of texture coordinates of each hairstyle area of the hairstyle model to the corresponding hairstyle area in the target texture space, so as to obtain the second set of texture coordinates of each hairstyle area in the texture space, wherein the texture coordinate values of the second set of texture coordinates of each hairstyle area in the texture space are partially or entirely not between 0 and 1; scaling the second set of texture coordinates of each hairstyle area in the texture space to obtain the scaled second set of texture coordinates corresponding to each hairstyle area.
[0008] Optionally, the method further includes: performing mapping according to the scaled second set of texture coordinates corresponding to the target hairstyle area to obtain the second set of texture coordinates for performing texture sampling on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area, wherein the second set of texture coordinates for performing texture sampling is between 0 and 1.
[0009] Optionally, determining the target hairstyle area of the virtual character and the target channel in the target hairstyle texture map corresponding to the target hairstyle area according to the hairstyle partition parameter and the texture map channel parameter includes: determining the target hairstyle area characterized by the hairstyle partition parameter; when the target hairstyle area is a preset hairstyle area, determining the target hairstyle texture map corresponding to the target hairstyle area; and determining the target channel corresponding to the texture map channel parameter in the target hairstyle texture map according to the texture map channel parameter.
[0010] Optionally, each hairstyle area includes a preset hairstyle area and a non-preset hairstyle area, where the preset hairstyle area is an area that supports adjusting the hairstyle length, and the non-preset hairstyle area is an area that does not support adjusting the hairstyle length.
[0011] In a second aspect of the implementation of this application, there is also provided a rendering device for hairstyles in a game scene, including: a first determination module, configured to determine the hairstyle partition parameter and the texture map channel parameter in the hairstyle selection operation in response to a hairstyle selection operation on a virtual character; a second determination module, configured to determine the target hairstyle area of the virtual character and the target channel in the target hairstyle texture map corresponding to the target hairstyle area according to the hairstyle partition parameter and the texture map channel parameter, where the hairstyle texture maps stored in different channels of the target hairstyle texture map correspond to different hairstyle lengths of the target hairstyle area; and a first rendering module, configured to render the target hairstyle area of the virtual character according to the hairstyle texture map stored in the target channel.
[0012] Optionally, the first rendering module includes: a first sampling unit, configured to perform texture sampling on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area respectively according to the first set of texture coordinates corresponding to the target hairstyle area when the target channel is a preset channel, so as to obtain a first sampling result and a second sampling result; a first rendering unit, configured to render the target hairstyle area of the virtual character based on the first sampling result and the second sampling result; a second sampling unit, configured to perform texture sampling on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area respectively according to the second set of texture coordinates corresponding to the target hairstyle area when the target channel is a non-preset channel, so as to obtain a third sampling result and a fourth sampling result; and a second rendering unit, configured to render the target hairstyle area of the virtual character based on the third sampling result and the fourth sampling result.
[0013] Optionally, the device further includes: an acquisition module, configured to acquire an input adjustment parameter after rendering the target hairstyle area of the virtual character; an adjustment module, configured to adjust the length of the hairstyle in the hairstyle texture map in the target channel based on the adjustment parameter; a second rendering module, configured to render the target hairstyle area of the virtual character based on the adjusted hairstyle texture map.
[0014] Optionally, the device further includes: a first mapping module, configured to map the initial second set of texture coordinates of each hairstyle area of the hairstyle model to the corresponding hairstyle area in the target texture space to obtain the second set of texture coordinates of each hairstyle area in the texture space, where part or all of the texture coordinate values of the second set of texture coordinates of each hairstyle area in the texture space are not between 0 and 1; a scaling module, configured to scale the second set of texture coordinates of each hairstyle area in the texture space to obtain the corresponding scaled second set of texture coordinates of each hairstyle area.
[0015] Optionally, the device further includes: a second mapping module, configured to perform mapping according to the scaled second set of texture coordinates corresponding to the target hairstyle area to obtain a second set of texture coordinates for texture sampling the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area, where the second set of texture coordinates for texture sampling is between 0 and 1.
[0016] Optionally, the second determination module includes: a first determination unit, configured to determine the target hairstyle area characterized by the hairstyle partition parameter; a second determination unit, configured to determine the target hairstyle texture map corresponding to the target hairstyle area when the target hairstyle area is a preset hairstyle area; a third determination unit, configured to determine the target channel corresponding to the map channel parameter in the target hairstyle texture map according to the map channel parameter.
[0017] Optionally, each hairstyle area includes a preset hairstyle area and a non-preset hairstyle area, where the preset hairstyle area is an area that supports adjusting the length of the hairstyle, and the non-preset hairstyle area is an area that does not support adjusting the length of the hairstyle.
[0018] In another aspect of the implementation of this application, there is also provided a computer-readable storage medium, in which instructions are stored, and when it runs on a computer, it enables the computer to execute the random test method for the host operation described in any one of the above.
[0019] In another aspect of the implementation of this application, there is also provided a computer program product including instructions, and when it runs on a computer, it enables the computer to execute the random test method for the host operation described in any one of the above.
[0020] In the embodiments of the present application, the target hairstyle area of the virtual character and the target channel in the target hairstyle texture map corresponding to the target hairstyle area can be determined according to the hairstyle partition parameters and texture map channel parameters. Then, the target hairstyle area of the virtual character is rendered according to the hairstyle texture map stored in the target channel, that is, the target hairstyle area of the virtual character is directly rendered through the hairstyle partition parameters and texture map channel parameters. Without procedural modeling, the personalized requirements for hairstyles in the game can also be achieved, and in a multiplayer online game, data transmission can be completed with a relatively low latency, thereby solving the problem in the prior art that the data storage amount for hairstyle construction through procedural modeling is large, resulting in data transmission latency. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art.
[0022] Figure 1 It is a schematic flowchart of the method for rendering a hairstyle in a game scene in the embodiments of the present application;
[0023] Figure 2 It is a schematic diagram of the hairstyle partition in the partitioned texture map in the embodiments of the present application;
[0024] Figure 3 It is a schematic comparison diagram of the virtual character's hairstyle before and after cutting in the embodiments of the present application;
[0025] Figure 4 It is a schematic structural diagram of the device for rendering a hairstyle in a game scene in the embodiments of the present application
[0026] Figure 5 It is a schematic structural diagram of the electronic device in the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0027] The following will describe the technical solutions in the embodiments of the present application with reference to the drawings in the embodiments of the present application.
[0028] The embodiments of the present application provide a method for rendering a hairstyle in a game scene, as Figure 1 shown, the steps of the method include:
[0029] Step 102, in response to a hairstyle selection operation for the virtual character, determine the hairstyle partition parameters and texture map channel parameters in the hairstyle selection operation;
[0030] Step 104: Determine the target hairstyle area of the virtual character and the target channel in the target hairstyle texture map corresponding to the target hairstyle area according to the hairstyle partition parameters and texture map channel parameters. Among them, the hairstyle texture maps stored in different channels of the target hairstyle texture map correspond to different hairstyle lengths in the target hairstyle area;
[0031] Step 106: Render the target hairstyle area of the virtual character according to the hairstyle texture map stored in the target channel.
[0032] Through the above steps 102 to 106, the target hairstyle area of the virtual character and the target channel in the target hairstyle texture map corresponding to the target hairstyle area can be determined according to the hairstyle partition parameters and texture map channel parameters. Furthermore, the target hairstyle area of the virtual character can be rendered according to the hairstyle texture map stored in the target channel, that is, the target hairstyle area of the virtual character can be directly rendered according to the hairstyle partition parameters and texture map channel parameters. The personalized requirements for hairstyles in the game can be achieved without procedural modeling, and the data transmission can be completed with a lower latency in a multi-player online game, thus solving the problem in the prior art that the data storage volume is large when building hairstyles through procedural modeling, resulting in data transmission latency.
[0033] In an optional implementation manner of the present application, for the method of rendering the target hairstyle area of the virtual character according to the hairstyle texture map stored in the target channel involved in the above step 106, it may further include:
[0034] Step 11: When the target channel is a preset channel, perform texture sampling on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area respectively according to the first set of texture coordinates corresponding to the target hairstyle area to obtain a first sampling result and a second sampling result;
[0035] Step 12: Render the target hairstyle area of the virtual character based on the first sampling result and the second sampling result;
[0036] Step 13: When the target channel is a non-preset channel, perform texture sampling on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area respectively according to the second set of texture coordinates corresponding to the target hairstyle area to obtain a third sampling result and a fourth sampling result;
[0037] Step 14: Render the target hairstyle area of the virtual character based on the third sampling result and the fourth sampling result.
[0038] It should be noted that in a specific example, the preset channel in the embodiments of the present application may be the A channel of the alpha map (target hairstyle map), rather than other channels of the alpha map except the A channel. There can be four channels for the alpha map; the map in the A channel is the initial hairstyle, and the corresponding hairstyle length is the longest (compared with the hairstyle lengths corresponding to other channels), and the solid color map may refer to the Base color map. In addition, different hairstyle regions correspond to different texture coordinate values in the same texture coordinate. Moreover, since the hairstyle lengths of the hairstyle maps stored in different channels are different, after determining the channel in the hairstyle map corresponding to the hairstyle region, a second set of texture coordinates is required to perform texture sampling on the hairstyle map stored in the target channel and the solid color map corresponding to the hairstyle region, and then rendering is performed. That is, when the player cuts the hair (that is, when choosing to use a non-preset channel), sampling based on the second set of texture coordinates adapted to the currently selected channel can make the finally rendered hair effect more natural; that is to say, the hairstyle length of the same hairstyle region can be controlled through different channels in the hairstyle map, without the need to programatically model multiple prefabricated hairstyles to achieve the change of the hairstyle length, reducing the data transmission delay.
[0039] In another alternative implementation manner of the embodiments of the present application, after the method of rendering the target hairstyle region of the virtual character involved in step 106, the method of the embodiments of the present application may further include:
[0040] Step 21, obtain the input adjustment parameter;
[0041] Step 22, adjust the length of the hairstyle in the hairstyle map in the target channel based on the adjustment parameter;
[0042] Step 23, render the target hairstyle region of the virtual character based on the adjusted hairstyle map.
[0043] As can be seen from the above steps 21 to 23, after rendering the target hairstyle area of the virtual character according to the hairstyle texture map stored in the target channel, so that the target hairstyle area is rendered into the hairstyle length corresponding to the hairstyle texture map, the hairstyle texture map can be further stretched based on the adjustment parameter to achieve a fine adjustment of the hairstyle length. In a specific example, based on the control code in the Shader, the preset Alpha map (hairstyle texture map) can be stretched in the V direction (i.e., the vertical direction) to achieve arbitrary adjustment of the hairstyle length. Specifically, based on this control code, the values stored in the Alpha map representing transparency are set. For example, the value 0 represents completely transparent, and the value 1 represents opaque. Then, if you want to lengthen the hairstyle, you can control the code to stretch the non-transparent area in the vertical direction according to the adjustment parameter. For example, set the pixel points that were originally 0 in the vertical direction to 1, that is, change the original transparent area in the vertical direction to opaque to increase the hairstyle length; conversely, the effect of shortening the hairstyle can be achieved, that is, control the code to shorten the non-transparent area in the vertical direction according to the adjustment parameter. For example, set the pixel points that were originally 1 in the vertical direction to 0, that is, change the original opaque area in the vertical direction to transparent to shorten the hairstyle length and achieve the effect of hair cutting; specifically, whether to lengthen or shorten the hairstyle length is controlled by the adjustment parameter input by the user, that is, the player.
[0044] In addition, the method of rendering the target hairstyle area of the virtual character based on the adjusted hairstyle texture map is similar to the above steps 11 to 14, that is, texture sampling is performed on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area according to the second set of texture coordinates corresponding to the target hairstyle area to obtain the corresponding sampling results, and then the target hairstyle area of the virtual character is rendered again based on the sampling results, so that the finally rendered hair effect can be more natural.
[0045] In another optional implementation manner of the embodiment of the present application, before determining the target hairstyle area of the virtual character and the target channel in the target hairstyle map corresponding to the target hairstyle area according to the hairstyle partition parameter and the texture map channel parameter involved in step 104, the method in the embodiment of the present application further includes:
[0046] Step 31, mapping the initial second set of texture coordinates of each hairstyle area of the hairstyle model to the corresponding hairstyle area in the target texture space to obtain the second set of texture coordinates of each hairstyle area in the texture space, where part or all of the texture coordinate values of the second set of texture coordinates of each hairstyle area in the texture space are not between 0 and 1;
[0047] Step 32: Scale the second set of texture coordinates of each hairstyle area in the texture space to obtain the scaled second set of texture coordinates corresponding to each hairstyle area.
[0048] Based on the above Step 31 and Step 32, the partitioning of the hairstyle model of the virtual character in the target texture space can be achieved, and the scaled second set of texture coordinates corresponding to each hairstyle partition can be obtained, thus providing a basis for subsequently adjusting the hairstyle lengths of each hairstyle partition respectively. Taking the initial second set of texture coordinates as (x, y) as an example, the second set of texture coordinates OffsetUV in the texture space is OffsetUV = (OffsetX + X, OffsetY + Y); that is to say, the above mapping is actually an offset, that is, the initial second set of texture coordinates is offset to this target texture space, and OffsetX and OffsetY are the offset values in the U and V directions when the initial texture coordinates are offset to the corresponding hairstyle area in the target texture space. In a specific example, the scaled texture UV = OffsetUV / 3.0. Further, in the specific example, the hairstyle area may include a preset hairstyle area and a non-preset hairstyle area. Among them, the preset hairstyle area is the area that supports adjusting the hairstyle length, and the non-preset hairstyle area is the area that does not support adjusting the hairstyle length. The hairstyles in the preset hairstyle area may include at least one of the following: bangs, right-back hair, middle-back hair, left-back hair, left sideburn, and right sideburn.
[0049] Based on the above Steps 31 to 32, in an alternative implementation manner of the embodiments of the present application, the method steps of the embodiments of the present application may further include:
[0050] Step 41: Map according to the scaled second set of texture coordinates corresponding to the target hairstyle area to obtain the second set of texture coordinates for texture sampling of the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area, where the second set of texture coordinates for texture sampling is between 0 and 1.
[0051] For the above Step 41, taking the hairstyles of the set hairstyle area as bangs, right-back hair, middle-back hair, left-back hair, left sideburn, and right sideburn as an example, as Figure 2 shown, the numerical values of the second set of texture coordinates of different areas of the hairstyle model are respectively distributed in different areas of the target texture space, that is, each hairstyle area is respectively mapped to 9 texture spaces in the target texture space, and the texture coordinates of the hairstyle model are expanded to different hair partitions. The second set of texture coordinates UV for texture sampling: RenderUV = (3.0 * scaled UV.x - [scaled UV.x], 3.0 * scaled UV.y - [scaled UV.y]), where [] represents taking the integer; scaled UV.x represents the x coordinate in the scaled UV coordinates, and scaled UV.y represents the y coordinate in the scaled UV coordinates.
[0052] In an alternative implementation manner of the embodiment of the present application, for the manner of determining the target hairstyle area of the virtual character and the target channel in the target hairstyle texture map corresponding to the target hairstyle area according to the hairstyle partition parameter and the texture map channel parameter involved in step 104 above, it may further include:
[0053] Step 51, determine the target hairstyle area characterized by the hairstyle partition parameter;
[0054] Step 52, when the target hairstyle area is a preset hairstyle area, determine the target hairstyle texture map corresponding to the target hairstyle area;
[0055] Step 53, determine the target channel in the target hairstyle texture map corresponding to the texture map channel parameter according to the texture map channel parameter.
[0056] Among them, the texture map channel parameter can be selected according to the different hairstyle lengths of the user, that is, the player, for the target hairstyle area, and this texture map channel parameter is used to represent a specific channel in the target hairstyle texture map.
[0057] For the manner of determining the target hairstyle area characterized by the hairstyle partition parameter in steps 51 to 53 above, in a specific example, the area of the hairstyle to be adjusted can be determined through pseudocode. Specifically, it can be: determine the corresponding partition index according to the hairstyle partition parameter, and determine the corresponding hairstyle area according to this partition index. Among them, the hairstyle partition parameter can be the second set of texture coordinates after scaling of this area. For example, if the lengths of the ponytail and sideburns are to be adjusted, the pseudocode is as follows:
[0058] int index = GetUVIndex()
[0059] switch (index)
[0060] {
[0061] case 1 return ponytail
[0062] case 2 return sideburns
[0063] }
[0064] The above pseudocode is only an example and can be set accordingly according to requirements. In addition, if the currently determined area is not the area to be trimmed, the hairstyle texture map and the solid color texture map stored in the preset channel in the Alpha texture map corresponding to this area can be directly texture sampled through the first set of texture coordinates, and then rendered to obtain the final hairstyle.
[0065] Through the hair rendering method in the game scene of the embodiments of the present application, the hair can be divided into six regions: bangs, left ponytail, right ponytail, middle of the ponytail, left temple, and right temple, and the length data of these six regions are stored respectively, reducing the latency of real-time transmission. Moreover, without modifying the prefabricated hairstyle model, the transparency of the hair is modified through a Shader to achieve hair clipping, as Figure 3 shown. The left side is before clipping, and the right side is after clipping. It can be seen that in the embodiments of the present application, the rendering can be accelerated through the Instance drawing technique, and there is no need to use procedural modeling to produce a variety of prefabricated hairstyles to achieve changes in hairstyle length, improving the efficiency of hair rendering.
[0066] Corresponding to the above Figure 1 , the embodiments of the present application also provide a hair rendering device in a game scene, as Figure 4 shown. The device includes:
[0067] A first determination module 42, configured to determine the hairstyle partition parameter and texture mapping channel parameter in the hairstyle selection operation in response to a hairstyle selection operation on a virtual character;
[0068] A second determination module 44, configured to determine the target hairstyle region of the virtual character and the target channel in the target hairstyle texture map corresponding to the target hairstyle region according to the hairstyle partition parameter and the texture mapping channel parameter, where the hairstyle texture maps stored in different channels of the target hairstyle texture map correspond to different hairstyle lengths of the target hairstyle region;
[0069] A first rendering module 46, configured to render the target hairstyle region of the virtual character according to the hairstyle texture map stored in the target channel.
[0070] Through the device of the embodiments of the present application, the target hairstyle region of the virtual character and the target channel in the target hairstyle texture map corresponding to the target hairstyle region can be determined according to the hairstyle partition parameter and the texture mapping channel parameter, and then the target hairstyle region of the virtual character can be rendered according to the hairstyle texture map stored in the target channel, that is, the target hairstyle region of the virtual character can be directly rendered through the hairstyle partition parameter and the texture mapping channel parameter. Without procedural modeling, the personalized requirements for hairstyles in the game can also be achieved, and in a multiplayer online game, data transmission can be completed with a lower latency, thus solving the problem in the prior art that the data storage amount for hairstyle trimming through procedural modeling is large, resulting in data transmission latency.
[0071] Optionally, the first rendering module 46 in the embodiments of the present application may further include: a first sampling unit, configured to, when the target channel is a preset channel, perform texture sampling on the hairstyle map stored in the target channel and the solid color map corresponding to the target hairstyle area according to the first set of texture coordinates corresponding to the target hairstyle area, so as to obtain a first sampling result and a second sampling result; a first rendering unit, configured to render the target hairstyle area of the virtual character based on the first sampling result and the second sampling result; a second sampling unit, configured to, when the target channel is a non-preset channel, perform texture sampling on the hairstyle map stored in the target channel and the solid color map corresponding to the target hairstyle area according to the second set of texture coordinates corresponding to the target hairstyle area, so as to obtain a third sampling result and a fourth sampling result; a second rendering unit, configured to render the target hairstyle area of the virtual character based on the third sampling result and the fourth sampling result.
[0072] Optionally, the device in the embodiments of the present application further includes: an acquisition module, configured to acquire an input adjustment parameter after rendering the target hairstyle area of the virtual character; an adjustment module, configured to adjust the length of the hairstyle in the hairstyle map in the target channel based on the adjustment parameter; a second rendering module, configured to render the target hairstyle area of the virtual character based on the adjusted hairstyle map.
[0073] Optionally, the device in the embodiments of the present application further includes: a first mapping module, configured to map the initial second set of texture coordinates of each hairstyle area of the hairstyle model to the corresponding hairstyle area in the target texture space, so as to obtain the second set of texture coordinates of each hairstyle area in the texture space, where part or all of the texture coordinate values of the second set of texture coordinates of each hairstyle area in the texture space are not between 0 and 1; a scaling module, configured to scale the second set of texture coordinates of each hairstyle area in the texture space to obtain the scaled second set of texture coordinates corresponding to each hairstyle area.
[0074] Optionally, the device in the embodiments of the present application further includes: a second mapping module, configured to perform mapping according to the scaled second set of texture coordinates corresponding to the target hairstyle area, so as to obtain the second set of texture coordinates for performing texture sampling on the hairstyle map stored in the target channel and the solid color map corresponding to the target hairstyle area, where the second set of texture coordinates for performing texture sampling is between 0 and 1
[0075] Optionally, the second determination module in the embodiments of the present application includes: a first determination unit, configured to determine the target hairstyle area characterized by the hairstyle partition parameter; a second determination unit, configured to determine the target hairstyle map corresponding to the target hairstyle area when the target hairstyle area is a preset hairstyle area; a third determination unit, configured to determine the target channel corresponding to the map channel parameter in the target hairstyle map according to the map channel parameter.
[0076] Optionally, each hairstyle area in the embodiments of the present application includes a preset hairstyle area and a non-preset hairstyle area, where the preset hairstyle area is an area that supports adjusting the hairstyle length, and the non-preset hairstyle area is an area that does not support adjusting the hairstyle length.
[0077] The embodiments of the present application also provide an electronic device, as Figure 5 shown, including a processor 501, a communication interface 502, a memory 503, and a communication bus 504. Among them, the processor 501, the communication interface 502, and the memory 503 communicate with each other through the communication bus 504.
[0078] The memory 503 is used to store a computer program.
[0079] When the processor 501 is used to execute the program stored on the memory 503, it implements the Figure 1 method steps, and its function is the same as that of the Figure 1 method steps, which will not be elaborated here.
[0080] The communication bus mentioned above for the terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of convenience of representation, Figure 5 only a thick line is shown in
[0081] but it does not mean that there is only one bus or one type of bus.
[0082] The communication interface is used for communication between the above terminal and other devices.
[0083] The above-mentioned processor can be a general-purpose processor, including a Central Processing Unit (CPU for short), a Network Processor (NP for short), etc.; it can also be a Digital Signal Processor (DSP for short), an Application Specific Integrated Circuit (ASIC for short), a Field-Programmable Gate Array (FPGA for short), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0084] In another embodiment provided by the present application, there is also provided a computer-readable storage medium. Instructions are stored in the computer-readable storage medium. When it runs on a computer, it causes the computer to execute the rendering method of the hairstyle in any of the game scenarios described in the above embodiments.
[0085] In another embodiment provided by the present application, there is also provided a computer program product containing instructions. When it runs on a computer, it causes the computer to execute the rendering method of the hairstyle in any of the game scenarios described in the above embodiments.
[0086] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, Digital Subscriber Line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer, or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a Solid State Disk (SSD)).
[0087] It should be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the said element.
[0088] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for system embodiments, since they are basically similar to method embodiments, the description is relatively simple, and reference can be made to the relevant parts of the method embodiments for the related content.
[0089] The above description is only a preferred embodiment of the present application and is not intended to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application are included in the protection scope of the present application.
Claims
1. A rendering method for hairstyles in a game scene, characterized in that, Including: In response to a hairstyle selection operation on a virtual character, determining the hairstyle partition parameters and texture map channel parameters in the hairstyle selection operation; According to the hairstyle partition parameters and the texture map channel parameters, determining the target hairstyle area of the virtual character and the target channel in the target hairstyle texture map corresponding to the target hairstyle area, wherein the hairstyle texture maps stored in different channels of the target hairstyle texture map correspond to different hairstyle lengths of the target hairstyle area; Rendering the target hairstyle area of the virtual character according to the hairstyle texture map stored in the target channel; Wherein, the rendering the target hairstyle area of the virtual character according to the hairstyle texture map stored in the target channel includes: when the target channel is a preset channel, respectively performing texture sampling on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area according to the first set of texture coordinates corresponding to the target hairstyle area, so as to obtain a first sampling result and a second sampling result; rendering the target hairstyle area of the virtual character based on the first sampling result and the second sampling result; when the target channel is a non-preset channel, respectively performing texture sampling on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area according to the second set of texture coordinates corresponding to the target hairstyle area, so as to obtain a third sampling result and a fourth sampling result; rendering the target hairstyle area of the virtual character based on the third sampling result and the fourth sampling result.
2. The method according to claim 1, wherein After rendering the target hairstyle area of the virtual character, the method further includes: Obtaining an input adjustment parameter; Adjusting the length of the hairstyle in the hairstyle texture map in the target channel based on the adjustment parameter; Rendering the target hairstyle area of the virtual character based on the adjusted hairstyle texture map.
3. The method according to claim 1, wherein Before, in response to a hairstyle selection operation on a virtual character, determining the hairstyle partition parameters and texture map channel parameters in the hairstyle selection operation, the method further includes: Mapping the initial second set of texture coordinates of each hairstyle area of the hairstyle model to the corresponding hairstyle area in the target texture space, so as to obtain the second set of texture coordinates of each hairstyle area in the texture space, wherein the texture coordinate values of the second set of texture coordinates of each hairstyle area in the texture space are partially or entirely not between 0 and 1; Scaling the second set of texture coordinates of each hairstyle area in the texture space to obtain the scaled second set of texture coordinates corresponding to each hairstyle area.
4. The method according to claim 3, characterized in that The method further includes: Performing mapping according to the scaled second set of texture coordinates corresponding to the target hairstyle area, so as to obtain the second set of texture coordinates for performing texture sampling on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area, wherein the second set of texture coordinates for performing texture sampling is between 0 and 1.
5. The method according to claim 1, wherein Determining the target hairstyle area of the virtual character and the target channel in the target hairstyle texture map corresponding to the target hairstyle area according to the hairstyle partition parameter and the texture map channel parameter includes: Determining the target hairstyle area characterized by the hairstyle partition parameter; When the target hairstyle area is a preset hairstyle area, determining the target hairstyle texture map corresponding to the target hairstyle area; According to the texture map channel parameter, determining the target channel in the target hairstyle texture map corresponding to the texture map channel parameter.
6. The method according to claim 3, wherein Each of the hairstyle areas includes a preset hairstyle area and a non-preset hairstyle area, where the preset hairstyle area is an area that supports adjusting the hairstyle length, and the non-preset hairstyle area is an area that does not support adjusting the hairstyle length.
7. A rendering device for hairstyles in a game scene, characterized in that, It includes: A first determination module, configured to determine the hairstyle partition parameter and the texture map channel parameter in the hairstyle selection operation in response to a hairstyle selection operation on the virtual character; A second determination module, configured to determine the target hairstyle area of the virtual character and the target channel in the target hairstyle texture map corresponding to the target hairstyle area according to the hairstyle partition parameter and the texture map channel parameter, where the hairstyle texture maps stored in different channels of the target hairstyle texture map correspond to different hairstyle lengths of the target hairstyle area; A first rendering module, configured to render the target hairstyle area of the virtual character according to the hairstyle texture map stored in the target channel; Among them, the first rendering module includes: a first sampling unit, configured to, when the target channel is a preset channel, perform texture sampling on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area respectively according to the first set of texture coordinates corresponding to the target hairstyle area, so as to obtain a first sampling result and a second sampling result; a first rendering unit, configured to render the target hairstyle area of the virtual character based on the first sampling result and the second sampling result; a second sampling unit, configured to, when the target channel is a non-preset channel, perform texture sampling on the hairstyle texture map stored in the target channel and the solid color texture map corresponding to the target hairstyle area respectively according to the second set of texture coordinates corresponding to the target hairstyle area, so as to obtain a third sampling result and a fourth sampling result; a second rendering unit, configured to render the target hairstyle area of the virtual character based on the third sampling result and the fourth sampling result.
8. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus; The memory is used for storing a computer program; The processor, when executing the program stored on the memory, implements the method according to any one of claims 1-6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method according to any one of claims 1-6.
Citation Information
Patent Citations
Hair simulation method and device
CN111047675A
Virtual object rendering method and device and electronic equipment
CN113140028A