Highlight rendering method and device, electronic equipment and computer readable storage medium

By constructing polar coordinates and converting them to UV coordinates, specular information is sampled from the specular mask, solving the problem that the specular mask cannot adapt to changes in viewing angle. This enables dynamic rendering of the specular area following visual changes, improving the realism and artistic expressiveness of the rendering.

CN121330147APending Publication Date: 2026-01-13GUANGZHOU BOGUAN TELECOMM TECH LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511836279.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-12-05
Publication Date
2026-01-13

AI Technical Summary

Technical Problem

In existing specular rendering solutions, specular masks cannot adapt to changes in viewing angle, resulting in inaccurate spatial relationships between specular areas and object surfaces. This makes them unable to respond to changes in viewing angle rotation, and dynamic adjustment solutions based on real-time calculations cannot achieve dynamic adjustments that follow visual changes.

Method used

By obtaining the specular vectors and specular weights of each vertex of the virtual model, polar coordinates are constructed and converted into UV coordinates. Specular information is sampled from the specular mask for rendering, enabling the specular area to follow visual changes.

Benefits of technology

It improves the realism and stylistic expressiveness of specular rendering, and the specular areas can dynamically adapt to visual changes, enhancing the realism and artistic expressiveness of the rendering effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121330147A_ABST
    Figure CN121330147A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a highlight rendering method and device, electronic equipment and a computer readable storage medium, and belongs to the technical field of computers.The method comprises the steps that highlight vectors and highlight weights of all vertexes of a virtual model are obtained, tangent values of the highlight vectors of all the vertexes are determined, and the tangent values of all the vertexes are obtained; constructing a corresponding polar coordinate according to the highlight weight of each vertex and the tangent value of the highlight vector of each vertex; each polar coordinate is converted into a corresponding UV coordinate; sampling corresponding highlight information from a highlight shade according to each UV coordinate; and performing highlight rendering on the virtual model according to the highlight information. Therefore, the polar coordinates are constructed according to the highlight weights of the vertexes of the virtual model and the tangent values of the highlight vectors of the vertexes, so that the polar coordinates rotate along with vision, and after the polar coordinates are converted into the UV coordinates and the corresponding highlight information is sampled from the highlight mask based on the UV coordinates for highlight rendering, the highlight area can move along with the vision change, so that the highlight rendering effect is improved. And the trueness of highlight rendering is improved.
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 specular rendering method, apparatus, electronic device, and computer-readable storage medium. Background Technology

[0002] In the field of computer graphics and visual rendering, specular highlights are a key component in simulating the specular reflection lighting effect on the surface of an object, and their shape directly affects the realism of the material and its artistic expression. Existing technologies mainly employ two methods to control the shape of specular highlights: 1) a static control scheme based on pre-drawn masks, which uses art resources to draw specular mask textures to achieve specific shapes of specular highlights; 2) a dynamic adjustment scheme based on real-time calculations, which uses mathematical modeling methods to perform geometric transformations on the specular region.

[0003] Although the two types of solutions mentioned above have been widely used in fields such as game engines, film and television special effects, and virtual reality, they still have significant technical limitations: the static control solution based on pre-drawn masks can achieve customized design of specular shapes, but the static mask cannot respond to the parameters of viewpoint changes, resulting in inaccurate spatial relationship between the specular area and the object surface, and it cannot adapt to specular changes caused by viewpoint rotation; the dynamic adjustment solution based on real-time calculation has dynamic adjustment capabilities, but it is limited by the inherent characteristics of the algorithm model and cannot dynamically adjust the specular area to follow visual changes. Summary of the Invention

[0004] In view of this, the purpose of the present invention is to provide a specular rendering method, apparatus, electronic device and computer-readable storage medium, which constructs polar coordinates based on the specular weights of each vertex of the virtual model and the tangent of the specular vectors of each vertex, so that the polar coordinates follow the visual rotation. When the polar coordinates are converted into UV coordinates, and the corresponding specular information is sampled from the specular mask based on the UV coordinates for specular rendering, the specular area can move with the visual changes, thereby improving the realism of specular rendering.

[0005] In a first aspect, the present invention provides a specular rendering method, the method comprising: Obtain the specular vector and specular weight of each vertex of the virtual model, determine the tangent value of the specular vector of each vertex, and construct the corresponding polar coordinates based on the specular weight and the tangent value of the specular vector of each vertex. Convert each of the polar coordinates to the corresponding UV coordinates; Based on the UV coordinates, sample the corresponding specular information from the specular mask; The virtual model is rendered using specular highlights based on the specular information provided.

[0006] In a second aspect, the present invention provides a specular rendering apparatus, the apparatus comprising: The acquisition module is used to acquire the specular vectors and specular weights of each vertex of the virtual model, determine the tangent value of the specular vector of each vertex, and construct the corresponding polar coordinates based on the specular weights and tangent values ​​of the specular vectors of each vertex. A conversion module is used to convert each of the polar coordinates into corresponding UV coordinates; The sampling module is used to sample the corresponding specular information from the specular mask according to each of the UV coordinates; The rendering module is used to perform specular rendering on the virtual model based on the specular information.

[0007] Thirdly, the present invention provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the computer program executes the specular rendering method provided in the first aspect when the processor is running.

[0008] Fourthly, the present invention provides a computer-readable storage medium storing a computer program that, when run on a processor, executes the specular rendering method provided in the first aspect.

[0009] The specular rendering method, apparatus, electronic device, and computer-readable storage medium provided in this application obtain the specular vectors and specular weights of each vertex of a virtual model, determine the tangent value of the specular vector of each vertex, construct corresponding polar coordinates based on the specular weights and tangent values ​​of the specular vectors of each vertex, convert each polar coordinate to corresponding UV coordinates, sample corresponding specular information from a specular mask based on each UV coordinate, and perform specular rendering on the virtual model based on the specular information. By constructing polar coordinates based on the specular weights and tangent values ​​of the specular vectors of each vertex of the virtual model, the polar coordinates follow visual rotation. When the polar coordinates are converted to UV coordinates, and specular rendering is performed by sampling corresponding specular information from a specular mask based on the UV coordinates, the specular area can move with visual changes, improving the realism of specular rendering and enhancing the expressive dimension of stylized rendering.

[0010] Other features and advantages of this disclosure will be set forth in the following description, or some features and advantages may be inferred from the description or determined without doubt, or may be learned by practicing the techniques described above.

[0011] To make the above-mentioned objects, features and advantages of this disclosure more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0012] To more clearly illustrate the technical solutions of this application, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of this application and should not be considered as a limitation on the scope of protection of this application. In the various drawings, similar components are numbered similarly.

[0013] Figure 1 A flowchart of the specular rendering method provided in this application is shown; Figure 2 A schematic diagram of the highlight weights provided in this application is shown; Figure 3 A schematic diagram of the tangent value of the specular vector provided in this application is shown; Figure 4 Another schematic diagram of the specular rendering method provided in this application is shown; Figure 5 A schematic diagram of the spherical-polar coordinate system provided in this application is shown; Figure 6 A schematic diagram of the spherical-plane coordinate system provided in this application is shown; Figure 7 A schematic diagram of the UV coordinate system provided in this application is shown; Figure 8 A schematic diagram of a highlight shape provided in this application is shown; Figure 9 This paper illustrates another flowchart of the specular rendering method provided in this application; Figure 10 This application provides another schematic diagram of a highlight shape. Figure 11 This paper illustrates another flowchart of the specular rendering method provided in this application; Figure 12 This paper illustrates another flowchart of the specular rendering method provided in this application; Figure 13 A schematic diagram of the specular rendering apparatus provided in this application is shown; Figure 14 A schematic diagram of the structure of the electronic device provided in this application is shown. Detailed Implementation

[0014] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0015] Example 1 This application provides a specular rendering method that can be integrated into an electronic device, such as a terminal or server. The terminal can be a mobile phone, tablet, smart Bluetooth device, laptop, or personal computer (PC); the server can be a single server or a server cluster. This specular rendering method overcomes the limitation of existing specular rendering schemes where specular masking cannot adapt to changes in viewing angle, and can provide specular rendering effects that follow viewing angle changes for various virtual models (eyes, bubbles, etc.).

[0016] In some embodiments, the specular rendering method can also be integrated into multiple electronic devices. For example, the specular rendering method can be integrated into multiple servers, with multiple servers implementing the specular rendering method of this application. In some embodiments, the server can also be implemented in the form of a terminal.

[0017] In some embodiments, the electronic device is a mobile terminal. The mobile terminal can acquire the specular vectors and specular weights of each vertex of the virtual model, determine the tangent value of the specular vector of each vertex, construct corresponding polar coordinates based on the specular weights and tangent values ​​of the specular vectors of each vertex, convert each polar coordinate into corresponding UV coordinates, sample corresponding specular information from the specular mask based on each UV coordinate, and perform specular rendering on the virtual model based on the specular information.

[0018] A specular rendering method in one embodiment of this disclosure can run on a terminal device or a server. The terminal device can be a local terminal device. When the specular rendering method runs on a server, it can be implemented and executed based on a cloud interaction system, which includes a server and client devices.

[0019] In an optional implementation, various cloud applications, such as cloud gaming, can run under the cloud interaction system. Taking cloud gaming as an example, cloud gaming refers to a gaming method based on cloud computing. In the cloud gaming operating mode, the game program and the game screen presentation are separated. The storage and execution of the specular rendering method are completed on the cloud gaming server. The client device is used for data reception, transmission, and game screen presentation. For example, the client device can be a display device with data transmission capabilities located close to the user, such as a terminal, television, computer, or PDA; however, the terminal device performing specular rendering is the cloud gaming server in the cloud. When playing the game, the user operates the client device to send operation commands to the cloud gaming server, such as touch operation commands. The cloud gaming server runs the game according to the operation commands, encodes and compresses the game screen data, returns it to the client device via the network, and finally, the client device decodes and outputs the game screen.

[0020] In an optional implementation, the terminal device can be a local terminal device. Taking a game as an example, the local terminal device stores the game program and is used to display the game screen. The local terminal device is used to interact with the user through a graphical user interface, that is, conventionally downloading, installing, and running the game program via an electronic device. The local terminal device can provide the graphical user interface to the user in various ways, such as rendering it on the terminal's display screen, or providing it to the user through holographic projection. For example, the local terminal device can include a display screen for displaying the graphical user interface, which includes game screens, and a processor for running the game, generating the graphical user interface, and controlling the display of the graphical user interface on the display screen.

[0021] A game scene (or virtual scene) is a virtual environment displayed (or provided) by an application while it is running on a terminal or server. Optionally, 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 either a two-dimensional or three-dimensional virtual scene. The virtual environment can be sky, land, ocean, etc., where land includes environmental elements such as deserts and cities. The virtual scene is the scene where the user controls virtual objects to form the complete game logic. For example, in a sandbox-style 3D shooting game, the virtual scene is a 3D game world used for users to control virtual objects in combat. Instances of virtual scenes can include at least one element from: mountains, plains, rivers, lakes, oceans, deserts, sky, plants, buildings, and vehicles.

[0022] A game interface refers to the interface of an application provided or displayed through a graphical user interface. This interface includes a graphical user interface for user interaction and game screens, which are the scenes in the game.

[0023] In an optional implementation, the UI may include game controls (e.g., skill controls, behavior controls, function controls, etc.), indicator icons (e.g., direction indicator icons, character indicator icons, etc.), information display area (e.g., number of kills, match time, etc.), or game settings controls (e.g., system settings, shop, gold coins, etc.).

[0024] In an optional implementation, the game screen is the display screen corresponding to the virtual scene shown on the terminal device. The game screen may include game objects that execute game logic in the virtual scene, and non-virtual characters. Virtual objects such as Player Characters (NPCs) and Artificial Intelligence (AI) characters.

[0025] For example, in some embodiments, the content displayed in the graphical user interface at least partially includes a game scene, wherein the game scene contains at least one game object. In some embodiments, the game object in the game scene includes a virtual object manipulated by the player, i.e., a user object.

[0026] Game objects refer to virtual objects within a virtual scene, including game characters. Game characters are controllable, dynamic objects, i.e., dynamic virtual objects. Optionally, these dynamic objects can be virtual characters, virtual animals, anime characters, etc. These virtual objects are characters controlled by the user through input devices, or AI trained and set up for battles in a virtual environment, or NPCs set up for battles in a virtual scene.

[0027] Optionally, the virtual object is a virtual character competing in a virtual scene. Optionally, the number of virtual objects in the virtual scene battle is preset or dynamically determined according to the number of clients joining the battle; this embodiment of the application does not limit this.

[0028] In one possible implementation, the user can control virtual objects to perform game behaviors in the virtual scene. Game behaviors can include moving, casting skills, using items, and talking. For example, the user can control the virtual object to run, jump, crawl, etc., and can also control the virtual object to use skills and virtual items provided by the application to fight against other virtual objects.

[0029] Virtual cameras are an essential component of game scene visuals, used for presenting game scene images. Each game scene corresponds to at least one virtual camera, and depending on actual needs, there can be two or more. These serve as rendering windows, capturing and presenting the game world's visual content to the user. By setting the parameters of the virtual camera, the user's viewing perspective can be adjusted, such as first-person or third-person perspective. The specular rendering method provided in this application can dynamically adapt to the viewing perspective to render appropriate specular effects. In the rendering field, especially in non-photorealistic rendering (NPR), the artistic control of specular shapes is a key technology for enhancing stylistic expressiveness, and it is widely used in digital content creation scenarios such as game animation and film special effects.

[0030] In one optional implementation, this invention provides a specular rendering method that provides a graphical user interface through a terminal device, wherein the terminal device can be either the aforementioned local terminal device or a client device in the aforementioned cloud interactive system.

[0031] The following sections provide detailed descriptions of each example. It should be noted that the sequence numbers of the following embodiments are not intended to limit the preferred order of the embodiments.

[0032] In this embodiment, a specular rendering method is provided, such as... Figure 1 As shown, the specific process of this method may include the following steps S110 to S140: Step S110: Obtain the specular vector and specular weight of each vertex of the virtual model, determine the tangent value of the specular vector of each vertex, and construct the corresponding polar coordinates based on the specular weight and the tangent value of the specular vector of each vertex.

[0033] In this embodiment, the virtual model is a virtual character or virtual object. For example, the virtual model could be the eyes of an anime-style character, an energy shield, or a glowing magic bubble, etc., without limitation. The virtual model can be assembled from many small triangles, with each corner of each small triangle being a vertex. In computer graphics, specular highlighting is a key processing step in rendering the gloss and material properties of an object.

[0034] In this embodiment, obtaining the specular vectors of each vertex of the virtual model includes: For each vertex of the virtual model, an intermediate vector is determined based on the viewing direction and the light source direction. The intermediate vector is then normalized to obtain the specular vector.

[0035] In one implementation, the Blinn-Phong model can be used to calculate the intermediate vector between the viewing direction and the light source direction, and the intermediate vector can be normalized to obtain the half-vec vector. The half-vec vector is then used as the specular vector.

[0036] As an example, the following calculation process can be used to obtain the specular vector: float half_vec = normalize(view_dir + light_dir); The above function is used to calculate the half-range vector. view_dir represents the viewing direction, light_dir represents the light source direction, view_dir + light_dir means adding the viewing direction and light source direction vectors together, and normalize means normalization processing. After normalization, only the direction is retained, and the length is 1, which is convenient for comparison and use.

[0037] In this embodiment, obtaining the specular weights of each vertex of the virtual model includes: The specular weights are determined based on the specular vectors and normal vectors of each vertex.

[0038] In one implementation, the cosine of the angle between the half-vec vector and the normal vector, spec, is calculated as the specular weight. The specular weight characterizes the degree of matching between the vertex's normal vector and specular vector. A larger specular weight indicates a higher degree of matching, resulting in a brighter specular highlight. Conversely, a smaller specular weight indicates a lower degree of matching, resulting in a darker specular highlight.

[0039] As an example, the highlight weights can be obtained using the following calculation process: float spec_weight = dot(normal_ws, half_vec); The above function is used to calculate the specular weight, spec_weight represents the specular weight, half_vec represents the half-vec vector, normal_ws represents the normal vector, and dot represents the dot product.

[0040] See Figure 2 , Figure 2 The diagram shown is a schematic of the highlight weights provided in this embodiment, with the corresponding highlight weights marked on the virtual model.

[0041] As an example, the tangent value of the specular vector at each vertex can be determined using the following procedure: float tan_val = atan2(half_vec.y, half_vec.x); Where tan_val represents the tangent of the specular vector of the vertex, half_vec.x represents the horizontal component of the half-vec vector, half_vec.y represents the vertical component of the half-vec vector, and atan2(half_vec.y, half_vec.x) represents the arctangent of the half-vec vector (i.e., the specular vector).

[0042] See Figure 3 , Figure 3 The diagram shows the tangent value of the specular vector provided in this embodiment, with the corresponding tangent value of the specular vector marked on the virtual model. See also... Figure 4 The polar coordinates are constructed based on the specular weights of each vertex and the tangent of the specular vectors of each vertex, including the following steps: Step S111: Determine the tangent value of the specular vector of each vertex as the angle parameter in polar coordinates; Step S112: Determine the specular weight of each vertex as the radial parameter in polar coordinates.

[0043] In this embodiment, a polar coordinate system is constructed using the tangent value tan_val and the specular weight spec_weight, ensuring that points in the coordinate system always follow the viewpoint rotation. First, the arctangent function (atan2) is used to obtain the polar coordinate angle parameter based on the specular vector; this angle parameter determines the direction vector of the specular highlight. Simultaneously, the specular weight is used to define the radial parameter in the polar coordinate system, which reflects the coordinate range of the specular highlight. See also... Figure 5 , Figure 5 The diagram shown is a schematic of the spherical-polar coordinate system provided in this embodiment. The corresponding UV coordinates can be obtained by using this polar coordinate system.

[0044] Step S120: Convert each polar coordinate into the corresponding UV coordinate.

[0045] In this embodiment, after defining the polar coordinate system, a conversion formula from polar coordinates to Cartesian coordinates (i.e., UV coordinates) is used. By multiplying the radial parameter by the cosine and sine values ​​of the angle parameter, the x-axis and y-axis components in the Cartesian coordinate system are calculated. These x-axis and y-axis components are the U and V components in the texture UV coordinates, respectively, thus realizing the conversion of polar coordinate information to texture UV coordinates. This conversion is particularly crucial in two-dimensional and three-dimensional rendering spaces, allowing 2D specular masks drawn in a planar coordinate system to be directly applied to 3D dynamic specular materials, thereby improving the efficiency of effect debugging.

[0046] In this embodiment, a UV coordinate system is first defined on the surface of the virtual model. UV coordinates are a parametric texture mapping method that can accurately apply 2D texture images to the 3D model surface. Each vertex has a corresponding UV coordinate in the local coordinate system of the virtual model. These coordinates typically vary within the range of 0 to 1, representing the relative position of the texture image. It can be understood that the local coordinate system refers to the information of the 3D space of the virtual model stored in a 2D plane (virtual model vertex xyz position -> UV coordinate position), thereby enabling the sampling of 2D textures and their final mapping back to the virtual model surface.

[0047] When constructing specular masks, a Cartesian coordinate system (i.e., the UV coordinate system) is used to calculate the specific position of each point on the model's surface. These UV coordinates allow for precise location of areas on the virtual model that require enhanced lighting effects. A specular mask is essentially a texture map specifically designed to represent specular reflections of light on the model's surface. The calculated UV coordinates allow for accurate mapping of this specular mask texture onto the virtual model's surface without loss of accuracy, ensuring the specular mask's performance (e.g., the checkerboard pattern is free of distortion or jagged edges).

[0048] In this embodiment, polar coordinates are converted into corresponding UV coordinates, enabling intelligent sampling coordinates dynamically generated based on the lighting direction. The specular direction in 3D space is transformed into a lookup location for 2D textures, allowing the specular shapes in the artwork to realistically and naturally follow changes in viewing angle, achieving a perfect combination of stylization and dynamism.

[0049] See Figure 6 and Figure 7 , Figure 6 The figure shown is a spherical-plane coordinate system provided in this embodiment, which is a Cartesian coordinate system. Figure 7 The UV coordinate system provided in this embodiment is... Figure 7 The illustrated checkerboard pattern shows the location of UV coordinates. Taking the highlight at the center of the sphere as an example, the UV coordinates of the highlight are (0.5, 0.5), and the area corresponding to the letter is the area near E4. For example, A1 corresponds to the UV (0, 0) position, and F4 might be the UV (0.3, 0.4) position.

[0050] See Figure 8 , Figure 8 The diagram shown is a schematic of the highlight shape provided in this embodiment, wherein the highlight shape is circular.

[0051] See Figure 9 Step S120 includes: Step S121: Determine the first axial component of each UV coordinate based on the cosine value of the angle parameter of each polar coordinate and the radial parameter of each polar coordinate. Step S122: Determine the second axial component of each UV coordinate based on the sine value of the angle parameter and the radial parameter of each polar coordinate.

[0052] Step S121 includes: Calculate the cosine value of the angle parameter in each polar coordinate and the first product value of the radial parameter in each polar coordinate; The first product value is mapped to a preset numerical range based on the mapping compensation parameters to obtain the first axial component.

[0053] As an example, the first axial component can be calculated in the following way: float U= cos(tan_val) × spec_weight × 0.5 + 0.5; Where U represents the horizontal coordinate of the specular mask texture, which is U in the UV coordinate system. The value of U ranges from 0 to 1. The range of the cos function is from -1 to 1. cos(tan_val) represents the cosine value of the tangent tan_val (i.e., the angle parameter). spec_weight represents the specular weight (i.e., the value of the radial parameter). 0.5 is the mapping compensation parameter. By adding two mapping compensation parameters of 0.5, the calculated value is mapped back to the numerical range of 0-1.

[0054] Step S122 includes: Calculate the sine value of the angular parameter for each polar coordinate and the second product value of the radial parameter for each polar coordinate; The second product value is mapped to a preset numerical range based on the mapping compensation parameters to obtain the second axial component.

[0055] As an example, the second axial component can be calculated in the following way: float V= sin(tan_val) ×spec_weight ×0.5 + 0.5; Where V represents the vertical coordinate of the specular mask texture, which is V in the UV coordinate system. The value of V ranges from 0 to 1. The range of the sin function is from -1 to 1. sin(tan_val) represents the sine value of the tangent tan_val (i.e., the angle parameter). spec_weight represents the specular weight (i.e., the value of the radial parameter). 0.5 is the mapping compensation parameter. By adding two mapping compensation parameters of 0.5, the value is mapped back to the numerical range of 0-1.

[0056] Step S130: Sample the corresponding specular information from the specular mask according to each UV coordinate. In this embodiment, UV sampling technology is applied to process the specular mask.

[0057] During rendering, the graphics engine can extract the corresponding specular information from the specular mask based on the UV coordinates of each pixel. This specular information includes color values ​​or reflection intensity. Image information (i.e., specular information) is extracted from the specular mask, which may be a color image with RGB colors or a single-channel black and white image (i.e., reflection intensity).

[0058] This sampling technique ensures that the specular effect is distributed evenly and correctly on the surface of the virtual model, reflecting realistic lighting interactions.

[0059] In this embodiment, users can customize the highlight shape to improve the flexibility and richness of the light.

[0060] In this embodiment, the method further includes: Receive shape adjustment parameters input by the user, and adjust the highlight shape of the highlight mask according to the shape adjustment parameters.

[0061] For example, shape adjustment parameters may include highlight shape size, graphic scheme, number of graphics, etc.

[0062] See Figure 10 , Figure 10 The diagram shown is another schematic of the highlight shape provided in this embodiment, wherein the highlight shape consists of two rectangles, one of which is larger and the other of which is smaller.

[0063] In this embodiment, users can input shape adjustment parameters to customize the highlight shape, ensuring high-precision highlight effects in stylized projects while also having broad applicability to various effect production needs (such as eye rendering and bubble rendering).

[0064] See Figure 11 Step S130 includes: Step S131: Determine the target UV coordinates based on each UV coordinate and the preset offset value; Step S132: Determine the specular information from the specular mask according to the target UV coordinates.

[0065] As an example, the following processing procedure can be adopted: float3 color = sample_texture(main_tex, UV + offset); Wherein, float3 color represents the three color components: red (R), green (G), and blue (B); sample_texture indicates the color to be found in the texture; main_tex indicates the main specular map; uv indicates the UV coordinates; offset indicates the preset offset value; and UV+offset indicates the target UV coordinates, so that the mapped UV sampling specular mask can be used.

[0066] In this embodiment, the open offset adjustment of specular UV coordinates allows artists to control the position of specular highlights. By constructing a spherical-plane coordinate mapping relationship to sample specular shape maps, the sampling points can be adaptively moved according to camera changes (and viewpoint changes). Furthermore, the addition of UV coordinate control enables flexible rotation, translation, and scaling operations on specular highlights.

[0067] Step S140: Perform specular rendering on the virtual model based on the specular information.

[0068] See Figure 12 Step S140 includes: Step S141: Smooth each highlight information to obtain corrected highlight information; Step S142: Determine the specular map based on the corrected specular information, and overlay the specular map onto the virtual model.

[0069] In this embodiment, the smoothstep function can be used to adjust the softness or hardness of the highlight shape, and finally the highlight mask can be superimposed back onto the model.

[0070] As an example, the following processing procedure can be adopted: color = smoothstep(min, max, color); Where color represents the output value, min represents the maximum value, max represents the maximum value, and smoothstep(min, max, color) represents a smooth gradient of the intermediate color between the minimum and maximum values ​​to obtain corrected highlight information, thereby adjusting the highlight mask and controlling the softness or hardness of the highlights.

[0071] In this embodiment, the defect of specular masking being unable to adapt to changes in viewing angle is solved. Compared with static specular masking, this method allows for sampling of specular masking by dynamically constructing a spherical-planar coordinate system, so that the specular area always moves with the light source and camera, which conforms to the physical motion law of specular light. In addition, the specular shape provided by this solution can be customized and adjusted to realize a customized specular rendering scheme, which can realize the stylization of the project, ensure high-precision specular effect, and has wide applicability to meet the needs of various types of effect production (such as eye rendering, bubble rendering).

[0072] Example 2 Corresponding to Embodiment 2 of the above method, this application provides a specular rendering apparatus, such as... Figure 13 As shown, the device 130 includes: The acquisition module 131 is used to acquire the specular vector and specular weight of each vertex of the virtual model, determine the tangent value of the specular vector of each vertex, and construct the corresponding polar coordinates based on the specular weight and the tangent value of the specular vector of each vertex. The conversion module 132 is used to convert each of the polar coordinates into corresponding UV coordinates; Sampling module 133 is used to sample corresponding specular information from the specular mask according to each of the UV coordinates; The rendering module 134 is used to perform specular rendering on the virtual model based on the specular information.

[0073] In one embodiment, the acquisition module 131 is further configured to determine an intermediate vector for each vertex of the virtual model based on the viewing direction and the light source direction, and normalize the intermediate vector to obtain the specular vector.

[0074] In one embodiment, the acquisition module 131 is further configured to determine the specular weight based on the specular vector and normal vector of each vertex.

[0075] In one embodiment, the acquisition module 131 is further configured to calculate the angle parameters of the polar coordinates by using the tangent values ​​of the arctangent function; The specular weight of each vertex is determined as the radial parameter of the polar coordinates.

[0076] In one embodiment, the conversion module 132 is further configured to determine the first axial component of each UV coordinate based on the cosine value of the angle parameter of each polar coordinate and the radial parameter of each polar coordinate. The second axial component of each UV coordinate is determined based on the sine value of the angle parameter of each polar coordinate and the radial parameter of each polar coordinate.

[0077] In one embodiment, the conversion module 132 is further configured to calculate the cosine value of the angle parameter of each polar coordinate and the first product value of the radial parameter of each polar coordinate; The first product value is mapped to a preset numerical range according to the mapping compensation parameters to obtain the first axial component; Calculate the sine value of the angle parameter of each polar coordinate and the second product value of the radial parameter of each polar coordinate; The second product value is mapped to the preset numerical range according to the mapping compensation parameter to obtain the second axial component.

[0078] In one embodiment, the device 130 further includes: An adjustment module is used to receive shape adjustment parameters input by the user and adjust the highlight shape of the highlight mask according to the shape adjustment parameters.

[0079] In one embodiment, the sampling module 133 is further configured to determine the target UV coordinates based on each of the UV coordinates and a preset offset value; The specular information is determined from the specular mask according to the target UV coordinates.

[0080] In one embodiment, the rendering module 134 is further configured to smooth each of the specular information to obtain corrected specular information; A specular map is determined based on the corrected specular information, and the specular map is superimposed on the virtual model.

[0081] The specular rendering apparatus and specular rendering method provided in this embodiment have the same technical features, so they can solve the same technical problems and achieve the same technical effects, which will not be elaborated here.

[0082] This invention also provides an electronic device for running the above-described specular rendering method; see [link to previous document]. Figure 14 The diagram shows the structure of an electronic device 140. The electronic device 140 includes a processor 141, a memory 142, and a bus 143. The memory 142 stores machine-readable instructions executable by the processor 141. When the electronic device 140 is running, the processor 141 communicates with the memory 142 via the bus 143. The processor 141 executes the machine-readable instructions to perform actions such as... Figure 1 The steps of the specular rendering method are shown.

[0083] The memory 142 may include high-speed random access memory (RAM) or non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface (wired or wireless), which can use the Internet, wide area network, local area network, metropolitan area network, etc. The bus 143 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc.

[0084] Processor 141 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 141 or by instructions in software form. Processor 141 can be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it can also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 142, and processor 141 reads the information in memory 142 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.

[0085] This invention also provides a computer-readable storage medium storing a computer program, which is executed by a processor as follows: Figure 1 The steps of the specular rendering method are shown.

[0086] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and / or device described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0087] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.

[0088] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, electronic device, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0089] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0090] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A specular rendering method, characterized in that, The method includes: Obtain the specular vector and specular weight of each vertex of the virtual model, determine the tangent value of the specular vector of each vertex, and construct the corresponding polar coordinates based on the specular weight and the tangent value of the specular vector of each vertex. Convert each of the polar coordinates to the corresponding UV coordinates; Based on the UV coordinates, sample the corresponding specular information from the specular mask; The virtual model is rendered using specular highlights based on the specular information provided.

2. The method according to claim 1, characterized in that, Obtaining the specular vectors of each vertex of the virtual model includes: For each vertex of the virtual model, an intermediate vector is determined based on the viewing direction and the light source direction. The intermediate vector is then normalized to obtain the specular vector.

3. The method according to claim 1, characterized in that, Obtaining the specular weights of each vertex of the virtual model includes: The specular weights are determined based on the specular vectors and normal vectors of each vertex.

4. The method according to claim 1, characterized in that, The step of constructing corresponding polar coordinates based on the specular weights of each vertex and the tangent of the specular vectors of each vertex includes: The tangent value of the specular vector of each vertex is determined as the angle parameter of the polar coordinates; The specular weight of each vertex is determined as the radial parameter of the polar coordinates.

5. The method according to claim 4, characterized in that, The process of converting each of the polar coordinates into corresponding UV coordinates includes: The first axial component of each UV coordinate is determined based on the cosine value of the angle parameter of each polar coordinate and the radial parameter of each polar coordinate. The second axial component of each UV coordinate is determined based on the sine value of the angle parameter of each polar coordinate and the radial parameter of each polar coordinate.

6. The method according to claim 5, characterized in that, The step of determining the first axial component of each UV coordinate based on the cosine value of the angle parameter and the radial parameter of each polar coordinate includes: Calculate the cosine value of the angle parameter of each polar coordinate and the first product value of the radial parameter of each polar coordinate; The first product value is mapped to a preset numerical range according to the mapping compensation parameters to obtain the first axial component; The step of determining the second axial component of each UV coordinate based on the sine value of the angle parameter and the radial parameter of each polar coordinate includes: Calculate the sine value of the angle parameter of each polar coordinate and the second product value of the radial parameter of each polar coordinate; The second product value is mapped to the preset numerical range according to the mapping compensation parameter to obtain the second axial component.

7. The method according to claim 1, characterized in that, The method further includes: Receive shape adjustment parameters input by the user, and adjust the highlight shape of the highlight mask according to the shape adjustment parameters.

8. The method according to claim 1, characterized in that, The step of sampling corresponding specular information from the specular mask based on each of the UV coordinates includes: The target UV coordinates are determined based on the described UV coordinates and preset offset values; The specular information is determined from the specular mask according to the target UV coordinates.

9. The method according to claim 1, characterized in that, The step of performing specular rendering on the virtual model based on the specular information includes: The aforementioned specular information is smoothed to obtain corrected specular information; A specular map is determined based on the corrected specular information, and the specular map is superimposed on the virtual model.

10. A specular rendering apparatus, characterized in that, The device includes: The acquisition module is used to acquire the specular vectors and specular weights of each vertex of the virtual model, determine the tangent value of the specular vector of each vertex, and construct the corresponding polar coordinates based on the specular weights and tangent values ​​of the specular vectors of each vertex. A conversion module is used to convert each of the polar coordinates into corresponding UV coordinates; The sampling module is used to sample the corresponding specular information from the specular mask according to each of the UV coordinates; The rendering module is used to perform specular rendering on the virtual model based on the specular information.

11. An electronic device, characterized in that, It includes a memory and a processor, the memory storing a computer program that executes the specular rendering method according to any one of claims 1 to 9 when the processor is running.

12. A computer-readable storage medium, characterized in that, It stores a computer program that, when run on a processor, executes the specular rendering method according to any one of claims 1 to 9.