Virtual object coloring method and device, equipment, storage medium and program product

By detecting the direction of illumination and the angle between hair strands to calculate color adjustment values, the problem of personalized requirements in the virtual object hair coloring method is solved, achieving rich color expression and higher artistry, and enhancing the attractiveness of virtual objects.

CN122072989APending Publication Date: 2026-05-22TENCENT TECH SHANGHAI
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TENCENT TECH SHANGHAI
Filing Date
2024-11-20
Publication Date
2026-05-22

AI Technical Summary

Technical Problem

Existing virtual object hair coloring methods fail to meet users' personalized aesthetic needs and cannot exhibit rich color changes under different lighting conditions, thus reducing the artistry and appeal of virtual objects.

Method used

By detecting the lighting direction of virtual objects in a virtual scene, and combining the angle between each hair strand and the lighting direction, the color adjustment coefficient and preset color change range are determined. The color adjustment value of each hair strand is calculated and superimposed with the initial color parameters to achieve personalized color representation of the hair model.

Benefits of technology

Under different lighting conditions, the virtual object's hair model can exhibit a variety of color changes, enhancing its artistry and appeal, and improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122072989A_ABST
    Figure CN122072989A_ABST
Patent Text Reader

Abstract

The invention provides a virtual object coloring method and device, equipment, a storage medium and a program product. The method comprises the steps of detecting an illumination direction of a position where a virtual object is located in a virtual scene; determining a color adjustment coefficient of each hairline according to an included angle between the illumination direction and each hairline in a hair model of the virtual object; determining a color adjustment value of each hairline based on the color adjustment coefficient of each hairline and a preset color change range; superposing the color adjustment value of each hairline with the initial color parameter of each hairline to obtain a to-be-colored color parameter of each hairline; and based on the to-be-colored color parameter of each hairline, performing coloring operation on each hairline in the hair model. According to the method and the device, the color expression of the hair model can be enhanced in a personalized manner on the basis of the original hair color of the hair model of the virtual object.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a method, apparatus, device, storage medium, and program product for coloring virtual objects. Background Technology

[0002] In virtual scenes, the colors of various virtual objects are achieved through shading techniques. For the shading of virtual objects' hair, most existing shading methods focus on achieving a display effect similar to the real world. However, users often have personalized aesthetic needs regarding the display effects in virtual scenes, and existing hair shading solutions have limitations in this area, failing to meet users' individual aesthetic requirements. Summary of the Invention

[0003] This application provides a method, apparatus, device, storage medium, and program product for coloring virtual objects, which can personalize and enhance the color performance of the hair model based on its original hair color.

[0004] The technical solution of this application embodiment is implemented as follows:

[0005] This application provides a method for coloring virtual objects, the method comprising:

[0006] Detect the lighting direction at the location of the virtual object in the virtual scene;

[0007] The color adjustment coefficient for each hair strand is determined based on the angle between the lighting direction and each hair strand in the hair model of the virtual object;

[0008] Based on the color adjustment coefficient of each hair strand and the preset color change range, the color adjustment value of each hair strand is determined;

[0009] The color adjustment value of each hair strand is superimposed with the initial color parameter of each hair strand to obtain the color parameter to be colored for each hair strand;

[0010] Based on the color parameters to be colored for each hair strand, a coloring operation is performed on each hair strand in the hair model.

[0011] This application provides a coloring device for a virtual object, including:

[0012] The data acquisition module is used to detect the lighting direction of the virtual object's position in the virtual scene;

[0013] The coloring parameter calculation module is used to determine the color adjustment coefficient of each hair strand based on the angle between the lighting direction and each hair strand in the hair model of the virtual object;

[0014] The coloring parameter calculation module is also used to determine the color adjustment value of each hair strand based on the color adjustment coefficient of each hair strand and the preset color change range;

[0015] The coloring parameter calculation module is also used to superimpose the color adjustment value of each hair strand with the initial color parameter of each hair strand to obtain the color parameter to be colored for each hair strand.

[0016] The coloring module is used to perform coloring operations on each hair strand in the hair model based on the color parameters to be colored for each hair strand.

[0017] This application provides an electronic device, the electronic device comprising:

[0018] Memory is used to store executable instructions or computer programs.

[0019] When a processor executes computer-executable instructions or computer programs stored in the memory, it implements the virtual object coloring method provided in the embodiments of this application.

[0020] This application provides a computer-readable storage medium storing a computer program or computer-executable instructions for implementing the virtual object coloring method provided in this application when executed by a processor.

[0021] This application provides a computer program product, including a computer program or computer executable instructions. When the computer program or computer executable instructions are executed by a processor, they implement the virtual object coloring method provided in this application.

[0022] The embodiments of this application have the following beneficial effects:

[0023] By obtaining the angle between the lighting direction and the hair strands of the virtual object's hair model based on the initial color parameters, and obtaining a preset color variation range, the color adjustment value of each hair strand is obtained by combining the angle and the color variation range. The color adjustment value is then superimposed on the initial color parameters. Based on matching the lighting direction, complex color representation is achieved through the color variation range. This not only enriches the visual hierarchy of the hair model, but also enables the virtual object's hair model to exhibit diverse color changes under different lighting conditions. This enhances the artistry and attractiveness of the virtual object, making it more vivid in the virtual scene, effectively attracting the user's attention, and improving the user experience. Attached Figure Description

[0024] Figure 1This is a schematic diagram of the architecture of the virtual object shading system provided in the embodiments of this application;

[0025] Figure 2 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application;

[0026] Figure 3A This is a first flowchart illustrating the virtual object coloring method provided in this application embodiment;

[0027] Figure 3B This is a second flowchart illustrating the virtual object coloring method provided in the embodiments of this application;

[0028] Figure 3C This is a schematic diagram of the third process of the virtual object coloring method provided in the embodiments of this application;

[0029] Figure 3D This is a schematic diagram of the fourth process of the virtual object coloring method provided in the embodiments of this application;

[0030] Figure 3E This is a fifth flowchart illustrating the virtual object coloring method provided in this application embodiment;

[0031] Figure 3F This is a sixth flowchart illustrating the virtual object coloring method provided in this application embodiment;

[0032] Figure 3G This is a seventh flowchart illustrating the virtual object coloring method provided in this application embodiment;

[0033] Figure 4 This is a flowchart illustrating the coloring method for virtual objects in a game scene provided in an embodiment of this application;

[0034] Figure 5A This is a schematic diagram of hair strands and hair strand points provided in the embodiments of this application;

[0035] Figure 5B This is a schematic diagram of hair strands and hair strand segments provided in the embodiments of this application;

[0036] Figure 5C This is a schematic diagram of a sliding window-based sampling of hair strands provided in an embodiment of this application;

[0037] Figure 5D This is a schematic diagram of the color setting control displayed on the human-computer interaction interface provided in the embodiments of this application;

[0038] Figure 6A This is a first schematic diagram illustrating the coloring effect of the coloring method for virtual objects provided in this application embodiment;

[0039] Figure 6BThis is a second schematic diagram illustrating the coloring effect of the coloring method for virtual objects provided in this application embodiment;

[0040] Figure 6C This is a third schematic diagram illustrating the coloring effect of the coloring method for virtual objects provided in this application embodiment.

[0041] It should be noted that the terms "first" and "second" mentioned above are only used to distinguish between different options and do not represent the degree of superiority or inferiority of the options or their priority in the implementation process. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this application clearer, the application will be further described in detail below with reference to the accompanying drawings. The described embodiments should not be regarded as limitations on this application. All other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0043] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.

[0044] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.

[0045] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

[0046] Unless otherwise defined, all technical and scientific terms used in the embodiments of this application have the same meaning as commonly understood by one of ordinary skill in the art. The terminology used in the embodiments of this application is for the purpose of describing the embodiments of this application only and is not intended to limit this application.

[0047] In the implementation of this application, the collection and processing of relevant data should strictly comply with the requirements of relevant laws and regulations, obtain the informed consent or separate consent of the personal information subject, and carry out subsequent data use and processing within the scope of laws and regulations and the authorization of the personal information subject.

[0048] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.

[0049] 1) In response to, used to indicate the conditions or states on which the operation performed depends. When the conditions or states on which it depends are met, one or more operations performed may be performed in real time or with a set delay. Unless otherwise specified, there is no restriction on the order in which the multiple operations are performed.

[0050] 2) Human-computer interaction interface, which is used to provide human-computer interaction functions / interface to display the coloring information of virtual objects.

[0051] Examples include Graphical User Interface (GUI), Augmented Reality (AR) interfaces, Virtual Reality (VR) interfaces, Voice User Interface (VUI), Interactive Projection Interface (using projection technology to display information on a flat surface), Eye-tracking Interface (an interface controlled by detecting the user's gaze), Holographic Interface (a three-dimensional hologram formed by projecting images using holographic projection technology, allowing users to see stereoscopic images without wearing special glasses), Multimodal Interface (an interface that combines multiple interaction methods, such as tactile, visual, and auditory interaction), and Brain-Machine Interface (BMI) interfaces.

[0052] 3) A virtual scene is a scene displayed (or provided) by an application while it is running on a terminal device. This virtual scene can be a simulation of the real world, a semi-simulated / semi-fictional virtual environment, or a purely fictional virtual environment. A virtual scene can be any of a two-dimensional, 2.5-dimensional, or three-dimensional virtual scene; this application does not limit the dimension of the virtual scene. For example, a virtual scene may include the sky, land, ocean, etc., and the land may include environmental elements such as deserts and cities. Players can control their character to move within this virtual scene.

[0053] 4) Virtual objects refer to objects or resources that do not actually exist in a virtual, simulated, or specific environment (virtual environment). This environment can be any form of scene, such as a virtual reality scene or a network scene. Virtual objects can take any form, including but not limited to characters, items, scenes, and events. They can be used to simulate various situations in the real world or to provide games, simulations, training, or other types of interactive experiences, such as player characters or non-player characters in a game scene.

[0054] 5) Model space is a local coordinate system used to define the geometry and dimensions of an object (such as a virtual object). In this space, the object's vertices, faces, and other geometric data are described using the object's own coordinate system. In other words, model space is the object's own reference frame, relevant to the object's creation and representation. In model space, each object has an origin (usually the object's center) and a coordinate system that defines the object's local orientation.

[0055] 6) World Space is a global coordinate system used to describe the position and relationship of all objects (such as virtual objects) in the virtual 3D world (virtual scene). In world space, each object is placed in a shared, unified coordinate system, which allows objects to interact and be relatively positioned. When rendering a virtual scene, objects are usually first transformed from model space to world space, and then rendering calculations such as lighting, shadows, and texture mapping are performed. This can be achieved through a model matrix, which contains the translation, rotation, and scaling information of the objects.

[0056] Most of the coloring methods for virtual objects in related technologies focus on pursuing realistic hair effects. However, since the rendering of hair models is limited to the representation of the real world, it is difficult to flexibly adjust them according to the user's personalized aesthetics, thereby reducing the artistry and appeal of virtual objects.

[0057] 7) A hair model is a data structure used to simulate and represent the geometry and visual effects of the hair of a virtual object. This model is used to realistically present the appearance and movement of a character's hair in digital media such as games, animations, and movies. In games, the hair model of a game character (virtual object) needs to be rendered in real-time to respond to the character's movements and environmental changes, thereby enhancing realism.

[0058] 8) A hair strand is the smallest geometric unit in a hair model. Each hair strand is a fundamental component of the hair model, and together they form the overall appearance of the hair. Hair strands can be represented by curves (such as Bézier curves) to achieve a smooth effect. Each hair strand can be mapped with a specific texture to define its color, shine, and detail. Hair strands can participate in physical simulations, responding to external factors such as gravity, wind, and collisions to achieve dynamic effects.

[0059] 9) Color variation range refers to two color parameters (first color parameter and second color parameter) that are preset or input by the user in real time. They are used to represent the coloring effect that the user expects to superimpose on the original hair color of the hair model. Specifically, the color variation range is combined with the color adjustment coefficient to determine the color adjustment value of the hair strand. The color intensity (brightness) and saturation of the first color parameter and the second color parameter are the same.

[0060] 10) Color parameters refer to specific color values, which can be represented by the RGB color model.

[0061] To address the aforementioned issues, embodiments of this application provide a method, apparatus, device, computer program product, and computer-readable storage medium for coloring virtual objects, which can personalize and enhance the color representation of a virtual object's hair model based on its original hair color.

[0062] The following describes exemplary applications of the devices provided in the embodiments of this application. The electronic devices provided in the embodiments of this application can be implemented as various types of terminals such as laptops, tablets, desktop computers, set-top boxes, smartphones, smart speakers, smartwatches, smart TVs, and vehicle terminals, or they can be implemented as servers.

[0063] See Figure 1 , Figure 1 This is a schematic diagram of the architecture of the virtual object shading system provided in the embodiments of this application, exemplified by... Figure 1 The system involves server 100, terminal device 200, and network 300. Terminal device 200 is connected to server 100 through network 300, which can be a wide area network (WAN), a local area network (LAN), or a combination of both.

[0064] In some embodiments, the embodiments of this application can be implemented collaboratively by a server and a terminal device. For example, the terminal device 200 sends the color variation range to the server 100, the server 100 obtains the color parameters to be colored for each hair strand using the coloring method for virtual objects provided in the embodiments of this application, and sends the color parameters to be colored for each hair strand to the terminal device 200, and the terminal device 200 performs coloring operations on each hair strand in the hair model using the color parameters to be colored for each hair strand.

[0065] In other embodiments, the embodiments of this application can be implemented collaboratively by a server and a terminal device. For example, the terminal device 200 sends the color change range and intensity control parameters (used to weight the color adjustment values) to the server 100. The server 100 obtains the color parameters to be colored for each hair strand (obtained by superimposing the weighted color adjustment values ​​of the intensity control parameters with each initial color parameter) through the coloring method of the virtual object provided in the embodiments of this application, and sends the color parameters to be colored for each hair strand to the terminal device 200. The terminal device 200 performs coloring operations on each hair strand in the hair model based on the color parameters to be colored for each hair strand. By receiving the color change range and intensity control parameters set by the user, the user's personalized needs for the coloring effect can be realized.

[0066] In other embodiments, the embodiments of this application can be implemented independently by a terminal device. The terminal device 200 obtains the color parameters to be colored for each hair strand according to a preset color change range and the coloring method of the virtual object provided in the embodiments of this application, and performs coloring operations on each hair strand in the hair model using the color parameters to be colored for each hair strand.

[0067] In other embodiments, the embodiments of this application can be implemented independently by a terminal device. The terminal device 200 obtains the color parameters to be colored for each hair strand (obtained by superimposing the color adjustment value weighted by the intensity control parameter with each initial color parameter) according to a preset color change range, intensity control parameters (used to weight the color adjustment value) and the coloring method of the virtual object provided in the embodiments of this application, and performs coloring operations on each hair strand in the hair model using the color parameters to be colored for each hair strand.

[0068] In some embodiments, the terminal device or server can implement the virtual object coloring method provided in this application by running various computer-executable instructions or computer programs. For example, computer-executable instructions can be microprogram-level commands, machine instructions, or software instructions. Computer programs can be native programs or software modules in an operating system. In summary, the aforementioned computer-executable instructions can be any form of instruction, and the aforementioned computer programs can be any form of application program, module, or plug-in. Terminal devices include, but are not limited to, mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, and aircraft.

[0069] See Figure 2 , Figure 2 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Figure 2 The electronic device 400 shown can be either the server 100 or the terminal device 200 mentioned above. Figure 2The illustrated electronic device 400 includes at least one processor 410, a memory 430, and at least one network interface 420. The various components of the electronic device 400 are coupled together via a bus system 440. It is understood that the bus system 440 is used to implement communication between these components. In addition to a data bus, the bus system 440 also includes a power bus, a control bus, and a status signal bus. However, for clarity, ... Figure 2 The general labeled all buses as Bus System 440.

[0070] The processor 410 can be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor, etc.

[0071] The memory 430 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid-state memory, hard disk drives, optical disk drives, etc. The memory 430 may optionally include one or more storage devices physically located away from the processor 410.

[0072] The memory 430 may include volatile memory or non-volatile memory, or both. The non-volatile memory may be read-only memory (ROM), and the volatile memory may be random access memory (RAM). The memory 430 described in this application embodiment is intended to include any suitable type of memory.

[0073] In some embodiments, memory 430 is capable of storing data to support various operations, examples of which include programs, modules, and data structures or subsets or supersets thereof, as illustrated below.

[0074] Operating system 431 includes system programs for handling various basic system services and performing hardware-related tasks, such as the framework layer, core library layer, driver layer, etc., for implementing various basic business functions and handling hardware-based tasks;

[0075] The network communication module 432 is used to reach other electronic devices via one or more (wired or wireless) network interfaces 420, exemplary network interfaces 420 including: Bluetooth, WiFi, and Universal Serial Bus (USB), etc.

[0076] In some embodiments, the apparatus provided in this application can be implemented in software. Figure 2 A shading device 433 for virtual objects stored in memory 430 is shown. This device can be software in the form of programs and plugins, and includes the following software modules: a data acquisition module 4331, a shading parameter calculation module 4332, and a shading module 4333. These modules are logically connected and can therefore be arbitrarily combined or further separated according to their implemented functions. The functions of each module will be described below.

[0077] In other embodiments, the apparatus provided in this application can be implemented in hardware. For example, the apparatus provided in this application can be a processor in the form of a hardware decoding processor, which is programmed to execute the virtual object coloring method provided in this application. For example, the processor in the form of a hardware decoding processor can be one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), or other electronic components.

[0078] The following will describe the virtual object coloring method provided in this application embodiment, using exemplary applications and implementations of the server provided in the embodiments of this application. The executing entity can be the aforementioned server or terminal device. See also Figure 3A , Figure 3A This is a first flowchart illustrating the virtual object coloring method provided in this application embodiment, which will be combined with... Figure 3A The steps shown are explained.

[0079] In step 101, the lighting direction of the virtual object's location in the virtual scene is detected.

[0080] In some embodiments, a first lighting direction in the scene coordinate system of the virtual scene is obtained; the first lighting direction is converted into a second lighting direction in the world coordinate system, and the second lighting direction is used as the lighting direction of the virtual scene where the virtual object is located.

[0081] For example, the first lighting direction in the virtual scene coordinate system can be obtained based on the type of light source in the virtual scene.

[0082] For example, when the light source is a directional light, the first illumination direction (illumination direction vector) is known and points in a fixed direction. In a 3D game scene, the direction of the directional light can be specified by the game engine's lighting settings.

[0083] For example, when the light source is a point light or a spotlight, the first lighting direction is the vector from each point in the virtual scene to the light source position. In the game engine, the first lighting direction can be obtained by calculating the vector difference between two points. For instance, if the light source position is (L) (coordinates in 3D virtual space) and the point in the scene (such as a point on a hair strand in a virtual object's hair model) is (P), then the first lighting direction (D) can be obtained by (D = LP). Then, the vector (D) is normalized (i.e., divided by its length to make its length 1) to obtain a unit vector, which is used as the first lighting direction.

[0084] For example, the first lighting direction (lighting direction vector) can be represented in the form (x, y, z), where x, y, and z are the three coordinate components of the lighting direction vector in three-dimensional space (virtual scene). For instance, a unit vector pointing towards the positive z-axis can be represented as (0, 0, 1).

[0085] In some embodiments, the first lighting direction is converted into a second lighting direction in the world coordinate system through matrix transformation, and the second lighting direction is used as the lighting direction of the virtual scene where the virtual object is located.

[0086] For example, a model matrix is ​​pre-set, and the first lighting direction is converted into a second lighting direction in the world coordinate system through the model matrix.

[0087] Here, the model matrix is ​​a transformation matrix used to transform the vertex coordinates of a model or object (such as a virtual object) from model space to world space (corresponding to the world coordinate system). Model space is a coordinate system unique to the virtual object itself, usually with the center of the virtual object as the origin, while world space (which can be understood as the space in which the virtual scene is constructed) is a global coordinate system in which all virtual objects are positioned and rendered according to this coordinate system. Specifically, the model matrix is ​​responsible for determining the position of the virtual object in world space, including translation, rotation, and scaling. The model matrix typically consists of three parts: a translation part, used to control the position of the virtual object in world space; a rotation part, used to control the rotation of the virtual object relative to one or more axes; and a scaling part, used to control the size of the virtual object. When you want to render a virtual object into the virtual scene, you can multiply the vertex coordinates of the virtual object in model space by the model matrix to obtain its position in world space.

[0088] For example, the model matrix can be a 4×4 matrix, including a 3×3 rotation matrix and a 3×1 translation vector, with additional rows and columns for handling perspective projection. In a 3D rendering scene, the model matrix is ​​multiplied by the view matrix to transform virtual objects from world space to the observer's (camera's) view space. Then, the view matrix is ​​multiplied by the projection matrix to transform the coordinates in view space to screen space. Ultimately, these screen coordinates are used to determine pixel positions and fill the pixels on the screen with corresponding color and depth information, thus rendering the 3D scene onto a 2D screen.

[0089] In step 102, the color adjustment coefficient for each hair strand is determined based on the angle between the lighting direction and each hair strand in the virtual object's hair model.

[0090] In some embodiments, the hair model of the virtual object is a pre-rendered hair model, and each strand of hair in the hair model includes initial color parameters.

[0091] For example, the hair model of a virtual object can be rendered using the Kajiya-Kay model or the Marschner model.

[0092] Taking the Kajiya-Kay model for rendering the hair model of a virtual object as an example, the hair is first represented as a series of elongated strip-shaped geometries, such as cylinders or Bézier curves. These strips are arranged along the hair's growth direction and can have different thicknesses and curvatures to simulate the shape of realistic hair. The Kajiya-Kay model uses ray tracing to simulate the interaction of light with the hair. For each ray in the scene, its possible intersections with the hair strips are calculated. For each intersection, it is necessary to determine whether the light penetrates the hair, reflects off the hair, or scatters inside the hair. This involves calculating the relative angle between the light and the normal direction of the hair strip. If the light reflects off the hair surface, an appropriate reflection model (such as the Cook-Torrance model) is used to calculate the direction and intensity of the reflected light. If the light enters the hair, refraction can be calculated and the path of the light inside the hair can be traced. Inside the hair, the light interacts with the hair fibers and is scattered. The Kajiya-Kay model uses a simplified model to estimate this scattering effect, typically based on the cross-sectional shape of the hair fibers and the angle of incidence of the light. The occlusion between hair strands and the occlusion of hair on other objects in the scene are calculated to generate realistic shadow effects. The hair's color and texture are mapped onto the rendered hair, which can be achieved through texture mapping or other forms of shading. Finally, the results of all traced rays are composited to generate the final hair model.

[0093] Here, because the virtual object coloring method provided in this application embodiment does not limit the specific rendering model used, it enables the virtual object coloring method provided in the embodiment to run smoothly on different platforms (such as mobile terminal platforms and host platforms). Through reasonable algorithm design and resource management, the visual effect of the hair model can be guaranteed while reducing the consumption of system resources. This compatibility and efficiency make the virtual object coloring method provided in this application embodiment widely applicable in practical applications, able to meet the needs of different platforms, and promote the further development of enhancing the color performance of hair models.

[0094] In some embodiments, see Figure 3B , Figure 3A Step 102 shown can be achieved by performing steps 1021 to 1023 for each hair strand, as explained in detail below.

[0095] In step 1021, the tangential direction of multiple hair points in the hair is detected.

[0096] In some embodiments, the tangent direction of each hair point in the hair is detected; or, the hair is sampled according to a preset distance parameter to obtain multiple sampled hair points, and the direction of the line connecting any two adjacent sampled hair points is taken as the tangent direction of any two adjacent sampled hair points, and as the tangent direction of the hair point between any two adjacent sampled hair points.

[0097] For example, due to the different directions and curliness of hair strands in the hair model, the tangent direction of each hair strand point will also be different. Therefore, in real-time rendering, since the tangent direction of the hair strand directly affects the color parameters to be colored, dynamically calculating the tangent direction of each hair strand point can achieve a refined effect on the color parameters to be colored.

[0098] For example, see Figure 5A , Figure 5A This is a schematic diagram of hair strands and hair strand points provided in the embodiments of this application. Figure 5A The hair strand 001 in the image can be represented by a series of three-dimensional points (e.g., ...). Figure 5A The hair strands shown in the figure (001) are used to represent the hair strands, and these hair strands define the growth direction (path of the hair strand) in sequence.

[0099] For example, for any hair point (P) on a hair strand. i (representing the coordinates of the hair strand), can be calculated by P. i With adjacent hair point P i-1 and P i+1 The difference is used to approximate the tangent vector, for example, P i Tangent vector Ti Represented as: T i =P i+1 -P i-1 The obtained tangent vector T i Normalization yields the unit tangent vector, and the direction represented by the unit tangent vector is taken as P. i The direction of the tangent.

[0100] For example, hair strands are sampled according to a preset distance parameter to obtain multiple sampled hair strand points. For instance, if the distance parameter is 10 (the number of hair strand points), multiple sampled hair strand points P are obtained. 10 P 20 P 30 …P n To obtain the direction of the line connecting any two adjacent sampled hair points, for example, to obtain P 10 and P 20 The direction of the line connecting them can be represented as T. 10~20 =P 20 -P 10 The obtained T 10~20 Normalization yields the unit tangent vector, and the direction represented by the unit tangent vector is taken as the hairline point P. 10 To P 20 The direction of the tangent.

[0101] This sampling method calculates only the tangent direction of a portion of the hair strands, thus reducing the amount of computation. At the same time, since the color change of a hair strand over a certain distance is often small, the tangent direction of the same hair strand can be reused within a certain distance, thereby ensuring the overall coloring effect of the subsequent hair strands.

[0102] For example, the coordinates of each hair strand can be obtained based on the vertex coordinates of the hair model. Specifically, each hair strand in the hair model consists of a series of vertices (corresponding to hair strand points), which are arranged in a certain order, defining the shape and path of the hair strand. The hair model can be stored in a vertex array, where each vertex contains coordinates (x, y, z). If the hair model uses indices to define the connection order of the vertices, there will also be an index array. The coordinates of each hair strand point can be obtained by accessing the vertex array of the hair model.

[0103] For example, after obtaining the tangent direction of each hair point, the tangent direction of the hair point can be transformed into the world coordinate system through spatial transformation (e.g., matrix transformation), thereby calculating the angle between the tangent direction of each hair point and the illumination direction in the world coordinate system (world space). For example, a model matrix is ​​set in advance, and the tangent direction of the hair point is transformed into the world coordinate system through the model matrix. Here, the specific implementation of the matrix transformation can be found in the description of step 101 above, and will not be repeated here.

[0104] See also Figure 3B In step 1022, the angle between the tangent direction of each hair point and the illumination direction is determined.

[0105] In step 1023, a nonlinear transformation is performed on the included angle to obtain the sub-adjustment coefficient of each hair point, wherein the sub-adjustment coefficient of each hair point constitutes the color adjustment coefficient of the hair.

[0106] In some embodiments, when the tangential direction of each hair point is detected, the angle between the tangential direction of each hair point and the illumination direction is nonlinearly transformed (such as the square of the cosine value of the angle, the exponential transformation of the cosine value of the angle, etc.) to obtain the sub-adjustment coefficient of each hair point.

[0107] For example, obtain the cosine value of the angle between the tangent direction and the illumination direction of each hair point, and use the cosine value as the sub-adjustment coefficient of each hair point.

[0108] For example, the cosine value of the angle between the tangent direction and the illumination direction of each hair point is calculated to obtain the sub-adjustment coefficient of each hair point, which can be expressed by formula (1):

[0109] k = Abs(dot(worldTangent,lightdir) (1)

[0110] Where k represents the sub-adjustment coefficient, worldTangent represents the vector of the tangent direction of the hair point in world space, lightdir represents the vector of the lighting direction in world space, dot represents the cosine value obtained by the dot product of vectors, and Abs represents taking the absolute value.

[0111] For example, when the cosine value is 1, it means that the tangent direction is exactly the same as the lighting direction, and the hair strands on the hair model will receive the maximum amount of lighting; when the cosine value is -1, the tangent direction is completely opposite to the lighting direction, and the hair strands on the hair model will not receive any lighting; and when the cosine value is 0, it means that the angle between the two is 90 degrees, and the lighting effect of the hair strands on the hair model is in between.

[0112] For example, see Figure 6A , Figure 6A This is a first schematic diagram illustrating the coloring effect of the coloring method for virtual objects provided in this application embodiment. Figure 6A The numerical visualization of the sub-adjustment coefficients for each hair strand under different lighting directions is shown, where the black parts of the hair model (such as...) Figure 6A (1) The black part -1) represents k=0 (meaning the angle between the tangent direction of the hair strand and the direction of illumination is 90 degrees), and the white part of the hair model (such as Figure 6A (4) The white part -1) represents k=1 (meaning the tangent direction of the hair strand is exactly the same as or completely opposite to the direction of the light), and the gray part of the hair model (such as Figure 6A (1) The gray part -1) represents the numerical representation of k in the interval from 0 to 1. Figure 6A The red arrows in the image indicate the approximate direction of the light, from... Figure 6A As can be seen from Figures (1) to (4), different lighting directions combined with the position of the hair model will result in different k values, so as to dynamically adjust the performance of the hair model under different lighting conditions, thereby enhancing the realism and visual appeal of virtual objects (such as game characters in game scenes).

[0113] In some embodiments, when detecting the tangential direction of the sampled hair point obtained from the hair sample, the angle between the tangential direction of the sampled hair point and the illumination direction is nonlinearly transformed to obtain the sub-adjustment coefficient of the sampled hair point; the sub-adjustment coefficient is used as the sub-adjustment coefficient of the hair point located after the sampled hair point and before the next sampled hair point.

[0114] For example, obtain the sampling hair point (e.g. Figure 5A The cosine of the angle between the tangent direction of the sampled hair point 001 and the illumination direction is taken as the value of the angle cosine of all hair points located after sampled hair point 001 and before the next sampled hair point 002 (e.g., ...). Figure 5A The sub-adjustment coefficient of the hair point 002 shown in the figure.

[0115] In some embodiments, see Figure 3C , Figure 3A Step 102 shown can be achieved by performing steps 1024 to 1026 for each hair strand, as explained below.

[0116] In step 1024, the tangential direction of multiple hair segments in the hair is detected. The tangential direction of the hair segment is either the tangential direction of the hair point at the middle position of the hair segment or the direction of the line connecting the beginning and end of the hair segment.

[0117] In some embodiments, before detecting the tangential direction of multiple hair segments in a hair strand, the segmentation length of the hair model can be obtained; the hair strand is segmented according to the segmentation length to obtain multiple hair segments.

[0118] For example, see Figure 5B , Figure 5B This is a schematic diagram of hair strands and hair segments provided in the embodiments of this application. They can be cut at preset lengths at cutting points (e.g., ...). Figure 5B The hair strands are divided at the cutting points 001, 002, and 003 shown in the figure to obtain multiple hair segments (e.g., Figure 5B The hair segments shown are hair segment-1, hair segment-2, hair segment-3, and hair segment-4, all of which are the same length.

[0119] Here, the cutting length can be preset or dynamically set, such as dynamically set according to the length of the hair strands, for example, the total length of the hair strands is positively correlated with the cutting length.

[0120] In other embodiments, see Figure 3D Before detecting the tangential direction of multiple hair segments in a hair strand, the following steps 201 to 203 can be performed, which are explained in detail below.

[0121] In step 201, the curvature of multiple hair points in the hair strand is detected.

[0122] In some embodiments, the curvature of each hair point in the hair is detected; or, the hair is sampled according to a preset distance parameter to obtain multiple sampled hair points, and the curvature of the line connecting any two adjacent sampled hair points is taken as the curvature of any two adjacent sampled hair points, and also as the curvature of the hair point between any two adjacent sampled hair points.

[0123] For example, the curvature of each hair point can be approximated by the radius of the circle formed by three hair points on the hair. Specifically, any two adjacent sampled hair points and the hair point located at the center of the two adjacent sampled hair points are obtained. The radius of the circle is determined by the above three hair points, and the reciprocal of the radius is used as the curvature of the two adjacent sampled hair points and the hair point between the two adjacent sampled hair points. Alternatively, a more precise mathematical formula can be used, such as by using the derivative and second derivative of the hair (which is regarded as a curve). The embodiments of this application do not limit the specific calculation method for the curvature of each hair point.

[0124] In step 202, hair strands with curvature greater than or equal to the curvature threshold are used as cutting points.

[0125] In some embodiments, a curvature threshold is preset according to actual needs. This curvature threshold determines when to cut the hair into hair segments. If the curvature of a certain hair point is greater than this curvature threshold, then that hair is used as the cutting point.

[0126] For example, the curvature threshold can be the mean curvature obtained by statistically analyzing the curvature of sample hair models, such as the mean curvature obtained by statistically analyzing hair models with the same virtual character attributes (such as gender, hair color, character type, etc.).

[0127] In step 203, the hair strands are cut according to the cutting points to obtain multiple hair strand segments.

[0128] In some embodiments, the hair strands are cut at the cutting point to obtain multiple hair segments.

[0129] In other embodiments, each hair strand includes an initial color parameter for each hair strand point, see [link to relevant documentation]. Figure 3E Before detecting the tangential direction of multiple hair segments in a hair, the following steps 301 to 304 can be performed, which are explained in detail below.

[0130] In step 301, the hair strands are sampled based on a sliding window according to a preset step size.

[0131] In some embodiments, the step size of the sliding window, which is the sampling interval, is determined. This step size can be a fixed distance value or a relative value proportional to the length of the hair. A starting point on the hair is selected as the initial position of the sliding window. The sliding window is moved along the path (growth direction) of the hair according to the step size. After each movement, the hair point within the sliding window is used for sampling.

[0132] In step 302, starting from the second sampling, the average color value of the hair sample fragment obtained from the current sampling is determined.

[0133] In some embodiments, starting from the second sampling, the average color value of all hair points within the hair sampling segment obtained by the current sampling is determined, that is, the average value of the initial color parameters of the hair points within the current sliding window is used as the average color value of the hair sampling segment.

[0134] In step 303, if the difference between the average color value of the hair sampled segment obtained in the current sampling and the average color value of the hair sampled segment obtained in the previous sampling is less than the color threshold, then the next sampling continues. If the difference between the average color value of the hair sampled segment obtained in the current sampling and the average color value of the hair sampled segment obtained in the previous sampling is greater than or equal to the color threshold, then the last hair point of the hair sampled segment obtained in the current sampling is taken as the cutting point.

[0135] In some embodiments, the segmentation point is determined based on the difference between the mean colors obtained from adjacent sliding window samplings. Specifically, when the difference between the mean color of the hair sample segment obtained in the current sampling and the mean color of the hair sample segment obtained in the previous sampling is greater than or equal to the color threshold, the last hair point of the hair sample segment obtained in the current sampling is taken as the segmentation point.

[0136] For example, see Figure 5C , Figure 5C This is a schematic diagram of a sliding window-based sampling of hair strands provided in an embodiment of this application. Figure 5C The diagram shows sliding windows-1 and-2. The step size of the sliding window is the same as the size of the sliding window. The sliding window is moved along the path (growth direction) of hair 003 according to the step size. After each movement, the hair points in the sliding window (such as the n hair points included in sliding window-1) will be used for sampling.

[0137] For example, assuming the difference between the average color value of the hair sampled segment obtained by sliding window-2 and the average color value of the sampled hair segment obtained by sliding window-1 is less than the color threshold, then the sliding window continues to slide for the next sampling, resulting in sliding window-3; assuming the difference between the average color value of the hair sampled segment obtained by sliding window-2 and the average color value of the sampled hair segment obtained by sliding window-1 is greater than or equal to the color threshold, then the last hair point of the hair sampled segment obtained by sliding window-2 is used as the segmentation point, such as... Figure 5C The dividing point 004 is shown in the figure.

[0138] In step 304, the hair strands are cut at at least one cutting point to obtain multiple hair strand segments.

[0139] In some embodiments, the hair is cut according to the position of the cutting point on the hair strand to obtain multiple hair strand segments.

[0140] See also Figure 3C In step 1025, the angle between the tangent direction and the illumination direction of each hair segment is determined.

[0141] In some embodiments, the direction of the line connecting the first and last hair points within each hair segment is taken as the tangential direction of the hair segment, thereby determining the angle between the tangential direction of each hair segment and the illumination direction.

[0142] For example, will Figure 5B The direction of the line connecting the first and last hair points (cutting point 001) in the hair segment-1 shown is taken as the tangential direction of hair segment-1.

[0143] In other embodiments, the tangent direction of the hair point at the middle position of each hair segment is taken as the tangent direction of the hair segment, thereby determining the angle between the tangent direction of each hair segment and the illumination direction.

[0144] Example, assuming Figure 5A The hair point 001 to hair point 002 shown is a hair segment. The sampled hair point 001 is located in the middle of the hair segment. The tangent direction of the sampled hair point 001 is taken as the tangent direction of the hair segment (the hair segment composed of hair point 001 to hair point 002).

[0145] In step 1026, a nonlinear transformation is performed on the included angle to obtain the sub-adjustment coefficients of each hair segment, wherein the sub-adjustment coefficients of each hair segment constitute the color adjustment coefficients of the hair.

[0146] As an example, the cosine value of the included angle is obtained and used as the sub-adjustment coefficient for each hair segment.

[0147] See also Figure 3A In step 103, the color adjustment value of each hair strand is determined based on the color adjustment coefficient of each hair strand and the preset color change range.

[0148] In some embodiments, the endpoints of the color variation range include a first color parameter and a second color parameter, and the color variation range is determined by: displaying a first rendering result of a virtual object of the initial color parameters of each hair strand of the applied hair model and a color setting control on a human-computer interaction interface; and displaying the set first color parameter and second color parameter in response to a setting operation based on the color setting control.

[0149] For example, see Figure 5D , Figure 5D This is a schematic diagram of the color setting control displayed on the human-computer interaction interface provided in this application embodiment. It can be used by... Figure 5D The color setting control 001 shown in the figure allows users to select color parameters from the drop-down menu or enter specific RGB values ​​to set the first and second color parameters. It can display a real-time preview of the hair model coloring effect, and the color effect of the selected first color parameter can be previewed in real-time through the first color parameter visualization area 001, and the color effect of the selected second color parameter can be previewed in real-time through the second color parameter visualization area 002, making it convenient for users to adjust and set the first and second color parameters in real time.

[0150] For example, it can also display the color effects of multiple sets of first and second color parameters, as well as a preview of the corresponding hair model coloring, so that users can compare and choose the most satisfactory coloring scheme.

[0151] For example, the first and second color parameters have the same color intensity (brightness) and saturation, so that the two color parameters have the same vividness (saturation) and brightness visually, so that they can be used harmoniously without causing visual abruptness.

[0152] For example, the RGB color model can be converted to the HSV (hue, saturation, brightness) color model so that the first and second color parameters with the same brightness and saturation can be set. For example, the RGB color model of the first color parameter is represented as: R = 255 (maximum red intensity (i.e., brightness), G = 0 (minimum green intensity), and B = 0 (minimum blue intensity). In the HSV space, this first color parameter can be represented as: H = 0° (the position of red on the color wheel), S = 1 (fully saturated, because no other colors are mixed), and V = 1 (maximum color intensity (brightness), because it is a pure color). Now, we obtain the second color parameter, which has the same saturation and brightness as the first color parameter, but a different hue. For example, we can choose: R = 0 (minimum red intensity), G = 255 (maximum green intensity), and B = 0 (minimum blue intensity). In the HSV space, the second color parameter can be represented as: H = 120° (the position of green on the color wheel), S = 1 (same saturation as the first color parameter), and V = 1 (same brightness as the first color parameter).

[0153] Here, the RGB color space is based on an additive color model of red, green, and blue light, and is widely used in monitors, televisions, and photography. The RGB color space can be directly associated with display devices, making it suitable for image editing and display, but not for color printing. The HSV color space is based on human color perception, where H represents hue, S represents saturation, and V represents brightness, making color selection and manipulation more intuitive.

[0154] In some embodiments, the endpoints of the color variation range include a first color parameter and a second color parameter, and the color adjustment coefficient of the hair strand includes a sub-adjustment coefficient for each hair strand point, see [link to relevant documentation]. Figure 3F , Figure 3A Step 103 shown can be achieved by performing steps 1031 to 1032 for each hair point in each hair strand, as explained in detail below.

[0155] In step 1031, the first color parameter and the second color parameter are adjusted based on the sub-adjustment coefficients of the hair strands to obtain the first sub-coloring parameter and the second sub-coloring parameter respectively.

[0156] In some embodiments, see Figure 3G , Figure 3FStep 1031 shown can be implemented through steps 10311 to 10312, which will be explained in detail below.

[0157] In step 10311, the difference between the preset value and the sub-adjustment coefficient of the hair point is determined, and the product of the difference and the first color parameter is obtained, and the product is used as the first sub-coloring parameter.

[0158] For example, the first sub-coloring parameter can be represented as: c1*(1-k), where c1 represents the first color parameter, 1 represents the preset value, and k represents the sub-adjustment coefficient of the hair point. Here, the first color parameter is represented by the RGB color space, and the maximum value of the R, G, and B values ​​in the first sub-coloring parameter is 255.

[0159] In step 10312, the product of the sub-adjustment coefficient of the hair point and the second color parameter is used as the second sub-coloring parameter.

[0160] For example, the second sub-coloring parameter can be represented as: c2*k, where c2 represents the second color parameter. Here, the second color parameter is represented in the RGB color space, and the maximum value of the R, G, and B values ​​in the second sub-coloring parameter is 255.

[0161] See also Figure 3F In step 1032, the sum of the first sub-coloring parameter and the second sub-coloring parameter is used as the color adjustment value of the hair strand.

[0162] Following the example above, the color adjustment value ck of the hair strand can be expressed as: ck=c1*(1-k)+c2*k. Here, the color adjustment value is represented by the RGB color space, and the maximum value of the R, G, and B values ​​in the color adjustment value is 255.

[0163] See also Figure 3A In step 104, the color adjustment value of each hair strand is superimposed with the initial color parameter of each hair strand to obtain the color parameter to be colored for each hair strand.

[0164] In some embodiments, the color adjustment value of each hair strand is added to the initial color parameter to obtain the color parameter to be colored for each hair strand. Here, the color parameter to be colored is represented by the RGB color space, and the maximum value of the R, G, and B values ​​in the color parameter to be colored is 255.

[0165] In step 105, each hair strand in the hair model is colored based on the color parameters to be colored for each hair strand.

[0166] In some embodiments, each hair strand in the hair model is colored based on the color parameter to be colored for each hair point of each hair strand, and the colored hair model is displayed.

[0167] In some embodiments, the hair model represents the current pose of the virtual object's hair. Before determining the color adjustment value of each hair strand based on the angle between the lighting direction and each hair strand in the virtual object's hair model, the hair model representing the pose of the virtual object's hair in the current frame can be obtained at the same frequency as the frame rate of the virtual scene as the current hair model.

[0168] For example, based on the same frequency as the frame rate of the virtual scene, a hair model representing the pose of the virtual object's hair in the virtual scene displayed in the current frame is obtained (i.e., for each frame of the virtual scene, a hair model representing the pose of the hair in each frame is obtained) as the hair model at the current moment. In other words, for each frame of the displayed virtual scene, the corresponding hair model is determined.

[0169] For example, during the rendering of frame 1, a hair model representing the posture of the virtual object's hair in the virtual scene displayed in frame 1 is obtained as the hair model at the current moment. The hair model is then colored using the virtual object coloring method provided in this embodiment, and the hair model is rendered for display. During the rendering of frame 2, a hair model representing the posture of the virtual object's hair in the virtual scene displayed in frame 2 is obtained as the hair model at the current moment. The hair model is then colored using the virtual object coloring method provided in this embodiment, and the hair model is rendered for display. This process continues, and by obtaining the hair model synchronously with the frame rate, it is ensured that the update of the hair model is consistent with the rendering frame rate of the virtual scene, avoiding visual tearing or delay caused by asynchrony.

[0170] In some embodiments, the hair model represents the pose of the virtual object's hair at the current moment. Before determining the color adjustment value of each hair strand based on the angle between the lighting direction and each hair strand in the virtual object's hair model, the following processing can be performed for the motion picture group in which the current moment is located: obtain the hair model representing the pose of the virtual object's hair in the keyframes of the motion picture group as the hair model at the current moment.

[0171] For example, for the current Group of Pictures (GOP) (that is, the current moment is within the decoding time interval of the GOP (from the decoding time of the first frame to the decoding time of the last frame)), the following processing is performed: Obtain the hair model representing the pose of the virtual object's hair in the keyframes of the GOP, and use it as the hair model for the current moment. In other words, the same hair model is reused within the decoding time interval of a GOP.

[0172] For example, during the rendering of image group 1, a hair model representing the posture of the virtual object's hair in the virtual scene displayed in image group 1 is obtained as the hair model at the current moment. The hair model is then colored using the virtual object coloring method provided in this application embodiment, and the hair model is rendered for display. During the rendering of image group 2, a hair model representing the posture of the virtual object's hair in the virtual scene displayed in image group 2 is obtained as the hair model at the current moment. The hair model is then colored using the virtual object coloring method provided in this application embodiment, and the hair model is rendered for display. And so on. Reusing the same hair model within the decoding time period of a GOP can reduce the frequency of calculating the hair model, thereby reducing the amount of computation and resource consumption. At the same time, reusing the hair model within a GOP can simplify the coloring process because the shader can reuse the same hair model parameters. Since it is not necessary to recalculate the hair model in every frame, the rendering process can be faster.

[0173] In some embodiments, the hair model represents the current pose of the hair of a virtual object. Before determining the color adjustment value of each hair strand based on the angle between the lighting direction and each hair strand in the hair model of the virtual object, the hair model of the previous frame can be used as the hair model of the current moment if the pose difference between the current frame and the hair pose of the previous frame is less than the pose difference threshold. If the pose difference between the current frame and the hair pose of the previous frame is greater than or equal to the pose difference threshold, a hair model representing the pose of the hair in the current frame is obtained and used as the hair model of the current moment.

[0174] For example, in a virtual scene, the pose of a hair model can be characterized using a series of parameters, which may include, but are not limited to: position parameters, including the overall position of the hair model and the local position of each hair strand; rotation parameters, describing the rotation angle of the hair model and hair strands, which may involve orientation and curvature; scaling parameters, describing the scaling ratio of the size of the hair model and hair strands; and morphological parameters, describing the shape features of the hair model, such as waves, curls, etc.

[0175] For example, the difference in hair pose between two frames can be calculated using the following method:

[0176] Euclidean distance: If the pose of the hair is represented by position coordinates, Euclidean distance can be used to measure the positional difference between two frames.

[0177] Rotational difference: If the hair's pose is represented using Euler angles, the rotational difference can be measured by calculating the angular difference between two rotation vectors. For quaternions, the rotational difference can be calculated using dot product and the inverse cosine function.

[0178] Overall Difference: If we want to consider the overall difference between position and rotation, we can calculate a weighted sum as the attitude difference.

[0179] Attitude matching algorithm: Uses algorithms such as Procrustes analysis to calculate the optimal match between two sets of attitude parameters, thereby obtaining the attitude difference.

[0180] For example, steps 101 to 105 are executed continuously. That is, the hair model used each time steps 101 to 105 are executed for the current hair model of the virtual object. The posture of the hair model is different at different times, such as the posture of hair being blown by the wind, the posture of hair hanging on the shoulders, etc.

[0181] Through steps 101 to 105, based on the initial color parameters of the virtual object's hair model, the angle between the lighting direction and the hair strands of the model is obtained, along with a preset color variation range. By combining the angle and the color variation range, the user's personalized color needs are ensured. This not only considers the influence of different lighting conditions but also reflects the user's personalized aesthetics, achieving differentiated display effects of the same virtual object on different users' devices. Specifically, by superimposing the color adjustment value with the basic initial color parameters, complex color expressions are achieved through the color variation range while matching the lighting direction. This not only enriches the visual hierarchy of the hair model but also allows the virtual object's hair model to exhibit diverse color changes under different lighting conditions, enhancing the artistry and attractiveness of the virtual object. It reflects the user's personalized color needs, conforms to lighting conditions, and reflects the user's personalized aesthetics, achieving differentiated display effects of the same virtual object on different users' devices. This makes the virtual object more vivid in the virtual scene, effectively attracting the user's attention and improving the user experience.

[0182] The following will describe, with reference to exemplary applications and implementations of the server and terminal devices combined as provided in the embodiments of this application, and taking the server as the execution subject as an example, the method for coloring virtual objects provided in the embodiments of this application in a game scene. See also Figure 4 , Figure 4 This is a flowchart illustrating the coloring method for virtual objects in a game scene provided in this application embodiment, which will be combined with... Figure 4 The steps shown are explained.

[0183] In step 401, the lighting direction of the game character's position in the game scene is detected.

[0184] In some embodiments, a first lighting direction in the scene coordinate system of the game scene (corresponding to the virtual scene) is obtained; the first lighting direction is converted into a second lighting direction in the world coordinate system (world space), and the second lighting direction is used as the lighting direction of the game scene where the game character is located.

[0185] For specific implementation details, please refer to the description of step 101 above, which will not be repeated here.

[0186] In step 402, the color adjustment coefficient for each strand of hair is determined based on the angle between the lighting direction and each strand of hair in the game character's hair model.

[0187] In some embodiments, the hair model of a game character is a pre-rendered hair model, where each strand of hair includes initial color parameters. For example, the hair model of a virtual object can be rendered using a Kajiya-Kay model or a Marschner model; see examples. Figure 6B , Figure 6B Figure (1) shows a hair model colored by initial color parameters.

[0188] In some embodiments, the tangential direction of multiple hair strands is detected (see step 1021 above for details); the angle between the tangential direction of each hair strand and the illumination direction is determined (see step 1022 above for details); the angle is nonlinearly transformed to obtain the sub-adjustment coefficient of each hair strand, wherein the sub-adjustment coefficient of each hair strand constitutes the color adjustment coefficient of the hair strand (see step 1023 above for details).

[0189] For example, obtain the cosine value of the angle between the tangent direction and the illumination direction of each hair point, and use the cosine value as the sub-adjustment coefficient of each hair point.

[0190] For example, when the cosine value (i.e., the sub-adjustment coefficient of the hair strands) is 1, it means that the tangent direction is completely consistent with the lighting direction, and the hair strands on the hair model will receive the maximum amount of lighting; when the cosine value is -1, the tangent direction is completely opposite to the lighting direction, and the hair strands on the hair model will not receive any lighting; and when the cosine value is 0, it means that the angle between the two is 90 degrees, and the lighting effect of the hair strands on the hair model is in between.

[0191] In other embodiments, the tangential direction of multiple hair segments in the hair is detected, wherein the tangential direction of the hair segment is either the tangential direction of the hair point at the middle position of the hair segment or the direction of the line connecting the beginning and end of the hair segment (for specific implementation, please refer to the description of step 1024 above); the angle between the tangential direction of each hair segment and the illumination direction is determined (for specific implementation, please refer to the description of step 1025 above); the cosine value of the angle is calculated, and the cosine value obtained by the calculation is used as the sub-adjustment coefficient of each hair segment, wherein the sub-adjustment coefficient of each hair segment in the hair constitutes the color adjustment coefficient of the hair (for specific implementation, please refer to the description of step 1026 above).

[0192] For example, before detecting the tangent direction of multiple hair segments in a hair strand, the segmentation length of the hair model can be obtained; the hair strand is then segmented according to the segmentation length to obtain multiple hair segments.

[0193] For example, before detecting the tangential direction of multiple hair segments in a hair strand, the curvature of multiple hair points in the hair strand can be detected (for specific implementation, please refer to the description of step 201 above); hair points with curvature greater than or equal to the curvature threshold are used as cutting points (for specific implementation, please refer to the description of step 202 above); the hair strand is cut according to the cutting points to obtain multiple hair segments (for specific implementation, please refer to the description of step 203 above).

[0194] For example, before detecting the tangent direction of multiple hair segments in a hair strand, the hair strand can be sampled based on a sliding window according to a preset step size (see step 301 above for a specific implementation); starting from the second sampling, the average color value of the hair strand sampled segment obtained by the current sampling is determined (see step 302 above for a specific implementation); if the difference between the average color value of the hair strand sampled segment obtained by the current sampling and the average color value of the sampled hair strand segment obtained by the previous sampling is less than the color threshold, then the next sampling continues; if the difference between the average color value of the hair strand sampled segment obtained by the current sampling and the average color value of the sampled hair strand segment obtained by the previous sampling is greater than or equal to the color threshold, then the last hair strand point of the hair strand sampled segment obtained by the current sampling is taken as the cutting point (see step 303 above for a specific implementation).

[0195] In step 403, the color adjustment value for each hair strand is determined based on the color adjustment coefficient for each hair strand and the preset color change range.

[0196] In some embodiments, the endpoints of the color variation range include a first color parameter and a second color parameter, and the color variation range is determined by: displaying a first rendering result of a virtual object of the initial color parameters of each hair strand of the applied hair model and a color setting control on a human-computer interaction interface; and displaying the set first color parameter and second color parameter in response to a setting operation based on the color setting control.

[0197] In some embodiments, the following processing is performed for each hair point in each hair strand: the first color parameter and the second color parameter are adjusted based on the sub-adjustment coefficient of the hair point to obtain the first sub-coloring parameter and the second sub-coloring parameter (for specific implementation, please refer to the description of step 1031 above); the sum of the first sub-coloring parameter and the second sub-coloring parameter is used as the color adjustment value of the hair point (for specific implementation, please refer to the description of step 1032 above).

[0198] For example, see Figure 6B , Figure 6B Figure (2) shows the visualization of the color adjustment value of each hair point obtained by adjusting the first color parameter (magenta) and the second color parameter (dark purple) based on the sub-adjustment coefficients of the hair point.

[0199] In step 404, the color adjustment value of each hair strand is superimposed with the initial color parameter of each hair strand to obtain the color parameter to be colored for each hair strand.

[0200] In some embodiments, the color adjustment value of each hair strand is added to the initial color parameter to obtain the color parameter to be colored for each hair strand. Here, the color parameter to be colored is represented by the RGB color space, and the maximum value of the R, G, and B values ​​in the color parameter to be colored is 255.

[0201] In some embodiments, the color adjustment value of the hair strand with a preset weight (or intensity control parameter) is added to the initial color parameter to obtain the color parameter to be colored for each hair strand.

[0202] Following the example above, see [link / reference]. Figure 6B , Figure 6B Figure (3) shows that... Figure 6B The color adjustment value of the hair point obtained in Figure (2) is superimposed with the initial color parameter with a preset weight of 0.34. Figure 6B The color effect of the hair model after Figure (1) is achieved by superimposing the original color (initial color parameter) of each hair point on the hair strand with the corresponding color adjustment value of 0.34 times.

[0203] In step 405, each hair strand in the hair model is colored based on the color parameters to be colored for each hair strand.

[0204] In some embodiments, each hair strand in the hair model is colored based on the color parameter to be colored for each hair point of each hair strand, and the rendered hair model is displayed.

[0205] For example, see Figure 6C It allows for custom weighting, adding the preset weighted color adjustment value of each hair strand to the initial color parameter to obtain the color parameter to be colored for each hair strand. Based on this color parameter, the coloring operation is then performed on each hair strand in the hair model. Figure 6C Figures (1) to (3) show the coloring effects of the hair model with preset weights of 0.1, 0.3, and 0.6, respectively, gradually deviating from the original color (green) as the weight increases. This coloring effect is very suitable as a high-value hair product in game commercialization, which can significantly enhance players' willingness to buy and their consumption experience. Due to its high degree of adjustment freedom, developers can flexibly adjust the parameters of the iridescent effect according to different game styles and player needs to achieve diversified visual expressions. This flexibility not only enhances the personalized experience of players, but also provides developers with more creative space and further expands revenue potential. By combining this iridescent hair effect with virtual goods in the game, developers can effectively enhance the commercial value of the game, create more attractive content, and thus promote the overall profitability of the game.

[0206] For example, see Figure 6B Players can Figure 6B The human-computer interaction interface (game interface) shown allows players to customize and personalize their game characters. Players can use a color picker to select hair color from a preset color list, or manually adjust color parameters (such as RGB values) to create custom hair colors. Players can preview the selected hair color (the range of color variations selected by the player) on the character model in real time to ensure satisfaction (e.g., ...). Figure 6B As shown in Figure (2), the human-computer interaction interface can also include four functions: "Reset", "Undo", "Cache" and "Download".

[0207] For example, the reset function allows players to restore their game character's hair color to the default state or the last saved state. When a player clicks the "Reset" button, a confirmation dialog box pops up, asking if the player is sure they want to reset the hair color. If the player confirms, the game character's hair color will be restored to the initial default settings or the most recently saved state. This helps players easily revert to their initial choice or most satisfactory settings after trying different hair colors.

[0208] For example, the undo function allows players to undo their most recent hair color changes. For instance, the system records each time a player changes their hair color. Clicking the "Undo" button will undo the last change, restoring the previous hair color. This provides a flexible way to adjust a character's appearance without having to start from scratch every time.

[0209] For example, the caching feature allows players to save their current character's appearance settings for quick loading. Players can click the "Cache" button to save their current settings to a local cache. Saved settings can be quickly loaded, which is very convenient for players who frequently change their character's appearance. Cached settings can be recalled at any time during the game without requiring detailed reconfiguration.

[0210] For example, the download feature allows players to share and access other players' character appearance settings. Players can upload their character appearance settings to the game server, generating a unique download link. Other players can use this link to download and install these settings onto their own characters. This encourages sharing and community interaction among players, increasing the game's social element.

[0211] These features together provide a user-friendly interface that allows players to easily customize and share their game characters, increasing the game's personalization and interactivity.

[0212] Steps 401 to 405 demonstrate how to easily achieve a rich variety of effects using only two basic colors (preset color variation ranges) and intensity control parameters. This simplified parameter mechanism not only improves development efficiency but also effectively reduces game production costs. Furthermore, developers can make these parameters available to players, allowing them to freely adjust their characters' appearances in the game, further enhancing playability and interactivity. Players can create unique character appearances according to their preferences, increasing the personalized experience of the game. This flexibility not only enhances player engagement but also adds more fun and diversity to the game, enabling each player to find their own style and enjoy unique gaming fun.

[0213] Furthermore, since the virtual object shading method provided in this application does not limit the specific rendering model used to render the hair model of game characters, it can adapt to multiple platforms, including mobile and console platforms, ensuring smooth real-time effects on different devices and providing users with a natural and dreamlike visual experience. This compatibility and efficiency make the virtual object shading method provided in this application widely applicable in practical applications, meeting the needs of different types of games and promoting the further development of game visual effects. At the same time, the parameter settings are simple and easy to control. Developers do not need to invest a lot of time and resources in art production, nor do they need additional texture resources. This simplified process greatly reduces the production cost of art resources, improves work efficiency, and allows development teams to focus more on other aspects of game development.

[0214] In summary, the virtual object coloring method provided in this application not only significantly improves the visual effect of hair models, but also provides strong commercial value for game developers, helping game products to be more competitive in the market.

[0215] The following description continues to illustrate the exemplary structure of the virtual object coloring device 433 provided in the embodiments of this application as a software module. In some embodiments, such as Figure 2 As shown, the software module in the shading device 433 of the virtual object stored in the memory 430 may include:

[0216] The data acquisition module 4331 is used to detect the lighting direction of the virtual object's position in the virtual scene.

[0217] The coloring parameter calculation module 4332 is used to determine the color adjustment coefficient of each hair strand based on the angle between the lighting direction and each hair strand in the hair model of the virtual object.

[0218] In some embodiments, the coloring parameter calculation module 4332 is further configured to determine the color adjustment value of each hair strand based on the color adjustment coefficient of each hair strand and a preset color change range.

[0219] In some embodiments, the coloring parameter calculation module 4332 is further configured to superimpose the color adjustment value of each hair strand with the initial color parameter of each hair strand to obtain the color parameter to be colored for each hair strand.

[0220] The coloring module 4333 is used to perform a coloring operation on each hair strand in the hair model based on the color parameters to be colored for each hair strand.

[0221] In some embodiments, the coloring parameter calculation module 4332 is further configured to perform the following processing for each hair strand: detect the tangent direction of a plurality of hair strand points in the hair strand; determine the angle between the tangent direction of each hair strand point and the illumination direction; perform a nonlinear transformation on the angle to obtain a sub-adjustment coefficient for each hair strand point, wherein the sub-adjustment coefficient of each hair strand point in the hair strand constitutes the color adjustment coefficient of the hair strand.

[0222] In some embodiments, the coloring parameter calculation module 4332 is further configured to detect the tangent direction of each hair point in the hair strand; or, to sample the hair strand according to a preset distance parameter to obtain multiple sampled hair points, and to take the line direction connecting any two adjacent sampled hair points as the tangent direction of any two adjacent sampled hair points, and as the tangent direction of the hair point between any two adjacent sampled hair points.

[0223] In some embodiments, the color parameter calculation module 4332 is further configured to perform a nonlinear transformation on the angle between the tangent direction of the sampled hair point and the illumination direction to obtain the sub-adjustment coefficient of the sampled hair point; and use the sub-adjustment coefficient as the sub-adjustment coefficient of the hair point located after the sampled hair point and before the next sampled hair point.

[0224] In some embodiments, the coloring parameter calculation module 4332 is further configured to perform a nonlinear transformation on the angle between the tangent direction of each hair strand and the illumination direction to obtain a sub-adjustment coefficient for each hair strand.

[0225] In some embodiments, the color parameter calculation module 4332 is further configured to perform the following processing for each hair strand: detect the tangent direction of multiple hair strand segments in the hair strand, wherein the tangent direction of the hair strand segment is the tangent direction of the hair strand point at the middle position of the hair strand segment, or the direction of the line connecting the beginning and end of the hair strand segment; determine the angle between the tangent direction of each hair strand segment and the illumination direction; perform a nonlinear transformation on the angle to obtain the sub-adjustment coefficient of each hair strand segment, wherein the sub-adjustment coefficient of each hair strand segment in the hair strand constitutes the color adjustment coefficient of the hair strand.

[0226] In some embodiments, the coloring parameter calculation module 4332 is further configured to obtain the segmentation length of the hair model; and to segment the hair strands according to the segmentation length to obtain the plurality of hair strand segments.

[0227] In some embodiments, the coloring parameter calculation module 4332 is further configured to detect the curvature of multiple hair points in the hair strand; use hair points with curvature greater than or equal to a curvature threshold as cutting points; and cut the hair strand according to the cutting points to obtain the multiple hair strand segments.

[0228] In some embodiments, the coloring parameter calculation module 4332 is further configured to detect the curvature of each hair point in the hair strand; or, to sample the hair strand according to a preset distance parameter to obtain multiple sampled hair points, and to take the curvature of the line connecting any two adjacent sampled hair points as the curvature of any two adjacent sampled hair points, and as the curvature of the hair point between any two adjacent sampled hair points.

[0229] In some embodiments, the coloring parameter calculation module 4332 is further configured to perform sliding window-based sampling of the hair strands according to a preset step size; starting from the second sampling, determine the color mean of the hair strand sampled segment obtained by the current sampling; if the difference between the color mean of the hair strand sampled segment obtained by the current sampling and the color mean of the sampled hair strand segment obtained by the previous sampling is less than a color threshold, then continue to the next sampling; if the difference between the color mean of the hair strand sampled segment obtained by the current sampling and the color mean of the sampled hair strand segment obtained by the previous sampling is greater than or equal to the color threshold, then take the last hair strand point of the hair strand sampled segment obtained by the current sampling as a cutting point; and cut the hair strands according to at least one of the cutting points to obtain the plurality of hair strand segments.

[0230] In some embodiments, the endpoints of the color change range include a first color parameter and a second color parameter, and the color adjustment coefficient of the hair strand includes a sub-adjustment coefficient for each hair strand point in the hair strand. The color parameter calculation module 4332 is further configured to perform the following processing for each hair strand point in each hair strand: adjust the first color parameter and the second color parameter based on the sub-adjustment coefficient of the hair strand point respectively to obtain a first sub-color parameter and a second sub-color parameter; and use the sum of the first sub-color parameter and the second sub-color parameter as the color adjustment value of the hair strand point.

[0231] In some embodiments, the coloring parameter calculation module 4332 is further configured to determine the difference between the preset value and the sub-adjustment coefficient of the hair point, and obtain the product of the difference and the first color parameter, and use the product as the first sub-coloring parameter; and use the product of the sub-adjustment coefficient of the hair point and the second color parameter as the second sub-coloring parameter.

[0232] In some embodiments, the hair model represents the current pose of the hair of the virtual object. The data acquisition module 4331 is further configured to acquire the hair model representing the pose of the hair of the virtual object in the current frame based on the same frequency as the frame rate of the virtual scene, so as to use the hair model at the current moment.

[0233] In some embodiments, the hair model represents the current pose of the virtual object's hair. The data acquisition module 4331 is further configured to perform the following processing for the motion image group in which the current moment is located: acquire the hair model representing the pose of the virtual object's hair in the keyframes of the motion image group, as the hair model at the current moment.

[0234] In some embodiments, the hair model represents the current pose of the hair of the virtual object. The data acquisition module 4331 is further configured to: use the hair model of the previous frame as the hair model of the current moment when the difference between the pose of the current frame and the pose of the hair in the previous frame is less than a pose difference threshold; and acquire a hair model representing the pose of the hair in the current frame as the hair model of the current moment when the difference between the pose of the current frame and the pose of the hair in the previous frame is greater than or equal to a pose difference threshold.

[0235] This application provides a computer program product comprising a computer program or computer-executable instructions stored in a computer-readable storage medium. An electronic device's processor reads the computer-executable instructions from the computer-readable storage medium and executes the computer-executable instructions, causing the electronic device to perform the virtual object coloring method described above in this application.

[0236] This application provides a computer-readable storage medium storing computer-executable instructions or a computer program. When the computer-executable instructions or the computer program are executed by a processor, the processor will execute the virtual object coloring method provided in this application. For example, ... Figure 3A The coloring method for the virtual object is shown.

[0237] In some embodiments, the computer-readable storage medium may be a memory such as RAM, ROM, flash memory, magnetic surface memory, optical disk, or CD-ROM; or it may be a variety of devices including one or any combination of the above-mentioned memories.

[0238] In some embodiments, computer-executable instructions may take the form of programs, software, software modules, scripts, or code, written in any form of programming language (including compiled or interpreted languages, or declarative or procedural languages), and may be deployed in any form, including as stand-alone programs or as modules, components, subroutines, or other units suitable for use in a computing environment.

[0239] As an example, computer-executable instructions may, but do not necessarily, correspond to files in a file system. They may be stored as part of a file that holds other programs or data, for example, in one or more scripts in a Hyper Text Markup Language (HTML) document, in a single file dedicated to the program in question, or in multiple co-located files (e.g., files that store one or more modules, subroutines, or code sections).

[0240] As an example, computer-executable instructions can be deployed to execute on a single electronic device, or on multiple electronic devices located at one location, or on multiple electronic devices distributed across multiple locations and interconnected via a communication network.

[0241] In summary, through the embodiments of this application, based on the initial color parameters of the hair model of the virtual object, the angle between the lighting direction and the hair strands of the hair model is obtained, and a preset color change range is obtained. By combining the angle and the color change range, the color adjustment value of each hair strand is obtained. The color adjustment value is then superimposed on the initial color parameters. Based on matching the lighting direction, complex color representation is achieved through the color change range. This not only enriches the visual hierarchy of the hair model, but also enables the hair model of the virtual object to exhibit diverse color changes under different lighting conditions, enhancing the artistry and attractiveness of the virtual object. This makes the virtual object more vivid in the virtual scene, effectively attracting the user's attention and improving the user experience.

[0242] The above description is merely an embodiment of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent substitutions, and improvements made within the spirit and scope of this application are included within the scope of protection of this application.

Claims

1. A method for coloring virtual objects, characterized in that, The method includes: Detect the lighting direction at the location of the virtual object in the virtual scene; The color adjustment coefficient for each hair strand is determined based on the angle between the lighting direction and each hair strand in the hair model of the virtual object; Based on the color adjustment coefficient of each hair strand and the preset color change range, the color adjustment value of each hair strand is determined; The color adjustment value of each hair strand is superimposed with the initial color parameter of each hair strand to obtain the color parameter to be colored for each hair strand; Based on the color parameters to be colored for each hair strand, a coloring operation is performed on each hair strand in the hair model.

2. The method according to claim 1, characterized in that, The step of determining the color adjustment coefficient for each hair strand based on the angle between the lighting direction and each hair strand in the hair model of the virtual object includes: Perform the following processing on each of the hair strands: Detect the tangential direction of multiple hair points in the hair strand; Determine the angle between the tangent direction of each hair strand and the illumination direction; A nonlinear transformation is performed on the included angle to obtain the sub-adjustment coefficient for each hair strand point, wherein the sub-adjustment coefficient for each hair strand point constitutes the color adjustment coefficient for the hair strand.

3. The method according to claim 2, characterized in that, The detection of the tangential direction of multiple hair points in the hair includes: Detect the tangent direction of each hair point in the hair strand; or... The hair strands are sampled according to preset distance parameters to obtain multiple sampled hair strand points. The direction of the line connecting any two adjacent sampled hair strand points is taken as the tangent direction of any two adjacent sampled hair strand points, and is also taken as the tangent direction of the hair strand point between any two adjacent sampled hair strand points.

4. The method according to claim 3, characterized in that, In detecting the tangential direction of the sampled hair points obtained from the hair samples, the nonlinear transformation of the included angle to obtain the sub-adjustment coefficient for each hair point includes: The angle between the tangent direction of the sampled hair point and the illumination direction is nonlinearly transformed to obtain the sub-adjustment coefficient of the sampled hair point; The sub-adjustment coefficient is used as the sub-adjustment coefficient for the hair point located after the sampled hair point and before the next sampled hair point.

5. The method according to claim 2, characterized in that, In detecting the tangential direction of each hair strand, the nonlinear transformation of the included angle to obtain the sub-adjustment coefficient for each hair strand includes: The angle between the tangent direction of each hair strand and the illumination direction is nonlinearly transformed to obtain the sub-adjustment coefficient of each hair strand.

6. The method according to any one of claims 1 to 5, characterized in that, The step of determining the color adjustment coefficient for each hair strand based on the angle between the lighting direction and each hair strand in the hair model of the virtual object includes: Perform the following processing on each of the hair strands: The tangential direction of multiple hair segments in the hair is detected, wherein the tangential direction of the hair segment is the tangential direction of the hair point at the middle position of the hair segment, or the direction of the line connecting the beginning and end of the hair segment. Determine the angle between the tangential direction of each hair segment and the direction of illumination; A nonlinear transformation is performed on the included angle to obtain the sub-adjustment coefficient of each hair segment, wherein the sub-adjustment coefficient of each hair segment in the hair constitutes the color adjustment coefficient of the hair.

7. The method according to claim 6, characterized in that, Before detecting the tangential direction of multiple hair segments in the hair, the method further includes: Obtain the segmentation length of the hair model; The hair strands are cut according to the specified cutting length to obtain the plurality of hair strand segments.

8. The method according to claim 6, characterized in that, Before detecting the tangential direction of multiple hair segments in the hair, the method further includes: Detect the curvature of multiple hair points in the hair strand; The hair strands with curvature greater than or equal to the curvature threshold are used as the cutting points; The hair strands are cut according to the cutting points to obtain the plurality of hair strand segments.

9. The method according to claim 8, characterized in that, The detection of the curvature of multiple hair points in the hair strand includes: Detect the curvature of each hair point in the hair strand; or, The hair strands are sampled according to a preset distance parameter to obtain multiple sampled hair strand points. The curvature of the line connecting any two adjacent sampled hair strand points is taken as the curvature of any two adjacent sampled hair strand points, and is also taken as the curvature of the hair strand points between any two adjacent sampled hair strand points.

10. The method according to claim 6, characterized in that, Before detecting the tangential direction of multiple hair segments in the hair, the method further includes: The hair strands are sampled using a sliding window based on a preset step size; Starting from the second sampling, determine the average color value of the hair sample segment obtained from the current sampling; If the difference between the mean color value of the currently sampled hair segment and the mean color value of the previously sampled hair segment is less than the color threshold, then continue to the next sampling. If the difference between the mean color value of the currently sampled hair segment and the mean color value of the previously sampled hair segment is greater than or equal to the color threshold, then the last hair point of the currently sampled hair segment is taken as the cutting point. The hair strands are cut at at least one of the cutting points to obtain the plurality of hair strand segments.

11. The method according to any one of claims 1 to 5, characterized in that, The endpoints of the color change range include a first color parameter and a second color parameter, and the color adjustment coefficient of the hair strand includes a sub-adjustment coefficient for each hair strand point; determining the color adjustment value of each hair strand based on the color adjustment coefficient of each hair strand and the preset color change range includes: Perform the following processing for each hair point within each of the aforementioned hair strands: The first color parameter and the second color parameter are adjusted based on the sub-adjustment coefficients of the hair strands to obtain the first sub-coloring parameter and the second sub-coloring parameter respectively. The sum of the first sub-coloring parameter and the second sub-coloring parameter is used as the color adjustment value for the hair strand.

12. The method according to claim 11, characterized in that, The sub-adjustment coefficients based on the hair strands are used to adjust the first color parameter and the second color parameter respectively, resulting in the first sub-coloring parameter and the second sub-coloring parameter, including: Determine the difference between the preset value and the sub-adjustment coefficient of the hair strand, and obtain the product of the difference and the first color parameter, and use the product as the first sub-coloring parameter; The product of the sub-adjustment coefficient of the hair point and the second color parameter is used as the second sub-coloring parameter.

13. The method according to any one of claims 1 to 5, characterized in that, The endpoints of the color variation range include a first color parameter and a second color parameter, and the color variation range is determined in the following manner: The first rendering result of the virtual object, which applies the initial color parameters of each hair strand of the hair model, and the color setting control are displayed on the human-computer interaction interface. In response to a setting operation based on the color setting control, the first color parameter and the second color parameter that have been set are displayed.

14. The method according to any one of claims 1 to 5, characterized in that, The hair model represents the current pose of the virtual object's hair. Before determining the color adjustment value of each hair strand based on the angle between the lighting direction and each hair strand in the virtual object's hair model, the method further includes: Based on the same frequency as the frame rate of the virtual scene, a hair model representing the pose of the virtual object's hair in the current frame is obtained as the hair model at the current moment.

15. The method according to any one of claims 1 to 5, characterized in that, The hair model represents the current pose of the virtual object's hair. Before determining the color adjustment value of each hair strand based on the angle between the lighting direction and each hair strand in the virtual object's hair model, the method further includes: For the current group of moving images, perform the following processing: Obtain a hair model representing the pose of the virtual object's hair in the keyframes of the motion image group, as the hair model at the current moment.

16. The method according to any one of claims 1 to 5, characterized in that, The hair model represents the current pose of the virtual object's hair. Before determining the color adjustment value of each hair strand based on the angle between the lighting direction and each hair strand in the virtual object's hair model, the method further includes: If the difference between the pose of the current frame and the pose of the hair in the previous frame of the virtual scene is less than the pose difference threshold, the hair model of the previous frame is used as the hair model at the current moment. If the difference between the pose of the hair in the current frame and the pose of the hair in the previous frame is greater than or equal to a pose difference threshold, a hair model representing the pose of the hair in the current frame is obtained and used as the hair model at the current moment.

17. A coloring device for a virtual object, characterized in that, The device includes: The data acquisition module is used to detect the lighting direction of the virtual object's position in the virtual scene; The coloring parameter calculation module is used to determine the color adjustment coefficient of each hair strand based on the angle between the lighting direction and each hair strand in the hair model of the virtual object; The coloring parameter calculation module is also used to determine the color adjustment value of each hair strand based on the color adjustment coefficient of each hair strand and the preset color change range; The coloring parameter calculation module is also used to superimpose the color adjustment value of each hair strand with the initial color parameter of each hair strand to obtain the color parameter to be colored for each hair strand. The coloring module is used to perform coloring operations on each hair strand in the hair model based on the color parameters to be colored for each hair strand.

18. An electronic device, characterized in that, The electronic device includes: Memory is used to store executable instructions or computer programs. A processor, when executing computer-executable instructions or computer programs stored in the memory, implements the coloring method for virtual objects according to any one of claims 1 to 16.

19. A computer-readable storage medium storing computer-executable instructions or a computer program, characterized in that, When the computer-executable instructions or computer program are executed by a processor, they implement the virtual object coloring method according to any one of claims 1 to 16.

20. A computer program product comprising computer-executable instructions or a computer program, characterized in that, When the computer-executable instructions or computer program are executed by a processor, they implement the coloring method for the virtual object according to any one of claims 1 to 16.