A method and apparatus for rendering color levels of a model

By obtaining the shading effect parameters and model information of the target model for gradation calculation, and utilizing the visual gradation setting component and GPU parallel computing, the gradation processing flow of game models is simplified, solving the problems of complexity and high resource consumption in existing technologies, and achieving efficient gradation rendering effects.

CN114998501BActive Publication Date: 2025-10-28NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210428341.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-22
Publication Date
2025-10-28
Estimated Expiration
2042-04-22

AI Technical Summary

Technical Problem

The existing technology for color gradation of game models is complex and resource-intensive, especially the texture sampling method, which has problems such as high management difficulty, large storage requirements and poor performance.

Method used

By obtaining the shading effect parameters and model information of the target model, color level calculation is performed. The process of color level processing is simplified by utilizing the visual color level setting component and GPU parallel computing, which reduces resource storage and improves rendering efficiency.

Benefits of technology

It makes the process of color gradation of game models simpler and more efficient, with less resource consumption, and is applicable to a variety of rendering scenarios, including non-realistic rendering and realistic rendering.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114998501B_ABST
    Figure CN114998501B_ABST
Patent Text Reader

Abstract

This disclosure presents a method and apparatus for rendering a model using color gradation. The method includes: obtaining shading effect parameters for a target model to be shading, the shading effect parameters including color gradation parameters and position parameters; obtaining model information of the target model; then calculating color gradation based on the shading effect parameters and model information to obtain color gradation values ​​corresponding to the shading parts of the target model; and finally rendering the target model based on the color gradation values. Using this method, the color gradation process for game models can be made simpler and more efficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of computer network technology, specifically to a method for rendering models using color gradation. This disclosure also relates to apparatuses, electronic devices, and computer-readable storage media for rendering models using color gradation. Background Technology

[0002] Non-realistic rendering has become an important part of game development. The core of non-realistic rendering is the model coloring process, which involves processing the colors of the model to be colored by gradation. For example, complex colors of various types are classified into a series of fewer color categories. The purpose is to reduce the number of colors and increase the non-realistic feel of the game model. That is, after reducing the number of colors, the model will be more like a cartoon character.

[0003] Existing color gradation processes for game models are quite complex and resource-intensive. Summary of the Invention

[0004] This disclosure provides a method, apparatus, electronic device, and computer-readable storage medium for rendering color levels of a model, in order to solve the problems of complex processing and high resource consumption in the prior art for rendering color levels of game models.

[0005] This disclosure provides a method for rendering a model using color gradation, including:

[0006] Obtain the shading effect parameters for the target model to be shaded, the shading effect parameters including color level parameters and position parameters;

[0007] Obtain the model information of the target model;

[0008] Based on the shading effect parameters and the model information, the color level is calculated to obtain the color level value corresponding to the shading part of the target model;

[0009] The target model is rendered based on the color level values.

[0010] Optionally, obtaining the shading effect parameters for the target model to be shaded includes:

[0011] In response to a color selection operation based on a visual color level setting component, the color level parameters and position parameters corresponding to the selected color are obtained, and the selected color is used for coloring the target model.

[0012] Optionally, obtaining the model information of the target model includes: obtaining the color attribute information of the target shading points of the target model, wherein the color attribute information of the target shading points corresponds to the same data format as the position parameters;

[0013] The step of calculating color levels based on the shading effect parameters and the model information includes: calculating color levels based on the color attribute information of the target shading point and the shading effect parameters.

[0014] Optionally, the color attribute information of the target color point includes one of the following:

[0015] The dot product of the normal unit vector N and the ray unit vector L at the target shading point;

[0016] The hue corresponding to the target color point;

[0017] The saturation corresponding to the target coloring point;

[0018] The contrast of the target colored point.

[0019] Optionally, the coloring effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters;

[0020] The step of calculating color levels based on the color attribute information of the target color point and the coloring effect parameters includes:

[0021] The color attribute information of the target color point is compared with the multiple position parameters one by one. Based on the comparison results and the value of the color level mixing mode, the color level value corresponding to the target color point is determined.

[0022] Optionally, determining the color level value corresponding to the target color point based on the comparison result and the value of the color level blending mode includes:

[0023] In response to the fact that the color attribute information of the target shading point is greater than the first position parameter and less than the second position parameter, and the value of the color level blending mode is Fixed, the color level value corresponding to the target shading point is determined to be the color level parameter corresponding to the second position parameter;

[0024] Alternatively, in response to the color attribute information of the target shading point being greater than the first position parameter and less than the second position parameter, and the value of the color level blending mode being Blend, an interpolation operation is performed based on the first position parameter, the second position parameter, and the color attribute information of the target shading point, and the resulting interpolation result is determined as the color level value corresponding to the target shading point.

[0025] Wherein, the first position parameter and the second position parameter are adjacent position parameters.

[0026] Optionally, the coloring effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters;

[0027] The step of calculating color levels based on the color attribute information of the target color point and the coloring effect parameters includes:

[0028] Multiple positional parameters are represented by multiple matrices, and the step and lerp instructions are used to perform parallel calculations on the multiple matrices to obtain the target matrix corresponding to the target shading point, and the color level value corresponding to the target matrix is ​​calculated.

[0029] This disclosure also provides a color gradation rendering apparatus for a model, which is installed on a game platform, and the apparatus includes:

[0030] A shading effect parameter acquisition unit is used to obtain shading effect parameters for the target model to be shading, the shading effect parameters including color level parameters and position parameters;

[0031] A model information acquisition unit is used to acquire model information of the target model;

[0032] A color level value acquisition unit is used to perform color level calculation based on the coloring effect parameters and the model information to obtain the color level value corresponding to the coloring part of the target model;

[0033] The model rendering unit is used to render the target model based on the color level values.

[0034] Optionally, obtaining the shading effect parameters for the target model to be shaded includes:

[0035] In response to a color selection operation based on a visual color level setting component, the color level parameters and position parameters corresponding to the selected color are obtained, and the selected color is used for coloring the target model.

[0036] Optionally, obtaining the model information of the target model includes: obtaining the color attribute information of the target shading points of the target model, wherein the color attribute information of the target shading points corresponds to the same data format as the position parameters;

[0037] The step of calculating color levels based on the shading effect parameters and the model information includes: calculating color levels based on the color attribute information of the target shading point and the shading effect parameters.

[0038] Optionally, the color attribute information of the target color point includes one of the following:

[0039] The dot product of the normal unit vector N and the ray unit vector L at the target shading point;

[0040] The hue corresponding to the target color point;

[0041] The saturation corresponding to the target coloring point;

[0042] The contrast of the target colored point.

[0043] Optionally, the coloring effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters;

[0044] The step of calculating color levels based on the color attribute information of the target color point and the coloring effect parameters includes:

[0045] The color attribute information of the target color point is compared with the multiple position parameters one by one. Based on the comparison results and the value of the color level mixing mode, the color level value corresponding to the target color point is determined.

[0046] Optionally, determining the color level value corresponding to the target color point based on the comparison result and the value of the color level blending mode includes:

[0047] In response to the fact that the color attribute information of the target shading point is greater than the first position parameter and less than the second position parameter, and the value of the color level blending mode is Fixed, the color level value corresponding to the target shading point is determined to be the color level parameter corresponding to the second position parameter;

[0048] Alternatively, in response to the color attribute information of the target shading point being greater than the first position parameter and less than the second position parameter, and the value of the color level blending mode being Blend, an interpolation operation is performed based on the first position parameter, the second position parameter, and the color attribute information of the target shading point, and the resulting interpolation result is determined as the color level value corresponding to the target shading point.

[0049] Wherein, the first position parameter and the second position parameter are adjacent position parameters.

[0050] Optionally, the coloring effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters;

[0051] The step of calculating color levels based on the color attribute information of the target color point and the coloring effect parameters includes:

[0052] Multiple positional parameters are represented by multiple matrices, and the step and lerp instructions are used to perform parallel calculations on the multiple matrices to obtain the target matrix corresponding to the target shading point, and the color level value corresponding to the target matrix is ​​calculated.

[0053] This disclosure also provides an electronic device, including a processor and a memory; wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the above-described method.

[0054] This disclosure also provides a computer-readable storage medium having stored thereon one or more computer instructions that are executed by a processor to implement the above-described method.

[0055] Compared with the prior art, the embodiments disclosed herein have the following advantages:

[0056] The color gradation rendering method for models provided in this disclosure obtains gradation effect parameters for a target model to be colored. These parameters include color gradation parameters and position parameters. The method also obtains model information for the target model. Then, based on the gradation effect parameters and model information, color gradation calculations are performed to obtain the color gradation values ​​corresponding to the colored parts of the target model. Finally, the target model is rendered based on these color gradation values. Using this method, the color gradation process for game models becomes simpler, more efficient, and consumes less resources. Attached Figure Description

[0057] Figure 1 This is a flowchart of the color gradation rendering method for the model provided in the first embodiment of this disclosure;

[0058] Figure 1-A This is a schematic diagram of component interaction provided in the embodiments of this disclosure;

[0059] Figure 1-B This is a schematic diagram of component interaction provided in the embodiments of this disclosure;

[0060] Figure 1-C This is a schematic diagram of color level calculation provided in an embodiment of this disclosure;

[0061] Figure 1-D This is a schematic diagram of color level calculation provided in an embodiment of this disclosure;

[0062] Figure 2 This is a unit block diagram of the color gradation rendering apparatus for the model provided in the second embodiment of this disclosure;

[0063] Figure 3 This is a schematic diagram of the logical structure of an electronic device provided in the third embodiment of this disclosure. Detailed Implementation

[0064] Numerous specific details are set forth in the following description to provide a full understanding of this disclosure. However, this disclosure can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this disclosure. Therefore, this disclosure is not limited to the specific implementations disclosed below.

[0065] It should be noted that the terms "first," "second," and "third," etc., used in various parts of the embodiments and drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. These terms can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in a sequence other than that illustrated or described herein. The terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or devices.

[0066] Non-realistic rendering has become an important part of game development. The core of non-realistic rendering is the model coloring, which involves processing the colors of the model to be colored by gradation. For example, complex colors of various types are classified into a series of fewer color categories. The purpose is to reduce the number of colors and increase the non-realistic feel of the game model. That is, after reducing the number of colors, the model will be more like a cartoon character.

[0067] Existing methods for color gradation of game models are complex and resource-intensive. For example, using texture sampling for color gradation involves one texture per color level, leading to management difficulties and high storage requirements. While ramp textures can express more color details, they suffer from several drawbacks: managing large amounts of ramp texture resources is difficult (textures exist as resources in the project, requiring separate storage and not material storage, necessitating manual management and subject to compression and loading limitations); colors are limited to 0-1, requiring a sampling instruction during shading, resulting in poor performance (the GPU also needs a sampling instruction to obtain the colors within the texture, which is also inefficient); and the user experience is poor, requiring switching between the engine and third-party tools, failing to achieve a WYSIWYG (What You See Is What You Get) interactive effect.

[0068] In the process of coloring game models, to simplify the existing color gradation process and reduce resource consumption, this disclosure provides a color gradation rendering method for models, a corresponding color gradation rendering apparatus for models, an electronic device that can implement the color gradation rendering method for models, and a computer-readable storage medium. The following embodiments provide a detailed description of the above-described method, apparatus, electronic device, and computer-readable storage medium.

[0069] The first embodiment of this disclosure provides a method for rendering a model using color gradation. The main application of this method can be a rendering shader, which can run on a game platform. Figure 1 This is a flowchart of the color gradation rendering method for the model provided in the first embodiment of this disclosure, which is described below in conjunction with... Figure 1 The color gradation rendering method for the model provided in this embodiment will be described in detail. The embodiments described below are used to explain the principle of the method and are not intended to limit actual use.

[0070] S101, obtain the shading effect parameters for the target model to be shaded.

[0071] This step is used to obtain the shading effect parameters for the target model to be shading. These shading effect parameters include color level parameters and position parameters. Color level, or color index, represents the tonal relationship of an image. For example, in an 8-bit RGB digital image, red, green, and blue are represented by 2^8 (256) levels, and the value range of each color is [0, 255]. That is, the color level describes the tonal range of the image from 0 to 255. The color level can determine the color richness and detail of the image. In image processing, adjusting the color level is essentially adjusting the size of different pixel values ​​by adjusting the histogram to improve the visual effect of the image.

[0072] Shading parameters refer to the shading data set before shading the target model. These include level parameters, position parameters, color blending modes, and color categories. Level parameters are the color values ​​of the selected level. For example, in computers, a color is generally represented using RGBA, where R represents the red component, G represents the green component, B represents the blue component, and A represents transparency. These components are typically integers from 0 to 255. These combinations can describe most colors. For example, (255,0,0,255) represents red, and (0,0,255,128) represents blue with half transparency. Position parameters refer to the percentage of the position of the aforementioned level parameters in the target model, and are decimals from 0 to 1. Color blending modes include Fixed mode and Blend mode. Color categories refer to the number of level values ​​in the target model.

[0073] The shading effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters. In this embodiment, obtaining the shading effect parameters for the target model to be shading specifically refers to: in response to a color selection operation based on a visual color level setting component, obtaining the color level parameters and position parameters corresponding to the selected color, wherein the selected color is the color level used for shading the target model. The visual color level setting component allows users to select color levels in a WYSIWYG manner. For example, Gradient's UI components allow users to freely select the color blending mode as Blend or Fixed. When using this component, users can freely drag the position of the color to display different effects, and the data structure of this component is relatively simple, such as... Figure 1-A and Figure 1-B As shown, assuming Figure 1-A or Figure 1-B There are four subscripts, each requiring only four floating-point numbers to store. The first three floating-point numbers represent the three RGB channels of the selected color, and 'a' stores the position parameter from 0 to 1. The four subscripts only require storing 16 floating-point numbers. Using floating-point numbers allows color values ​​to exceed 1, conforming to HDR settings. When the user performs operations on this component (e.g., adding or deleting subscripts, changing the color and position of subscripts, setting the color blending mode to Fixed or Blend), the script passes the corresponding shading effect parameters to the material. During real-time runtime, the material passes these shading effect parameters to the Shader, allowing the Shader code to perform the corresponding color level calculations.

[0074] S102, obtain the model information of the target model.

[0075] This step is used for the Shader to obtain model information of the input target model during real-time runtime. Specifically, it involves obtaining the color attribute information of the target shading point of the target model. The target shading point is any shading point on the target model. The color attribute information of the target shading point has the same data format as the position parameter, that is, the position parameter is a decimal between 0 and 1, and the color attribute information of the target shading point is also a decimal between 0 and 1. The color attribute information of the target shading point can be one of the following: the dot product of the normal unit vector N and the ray unit vector L on the target shading point, NdotL (abbreviated as NL), the hue value corresponding to the target shading point, the saturation value corresponding to the target shading point, the contrast of the target shading point, etc. In this embodiment, NL is used as an example for explanation.

[0076] S103, calculate the color level based on the shading effect parameters and model information to obtain the color level values ​​corresponding to each shading part of the target model.

[0077] After obtaining the shading effect parameters and model information of the target model in the above steps, this step is used to perform color level calculation based on the above shading effect parameters and model information to obtain the color level value corresponding to each shading part of the target model. Specifically, the color level calculation can be performed based on the color attribute information of the target shading point and the shading effect parameters. For example, assuming there are multiple shading points on the target model, the dot product of the normal unit vector N and the light unit vector L of the target shading point is NL, that is, the color attribute information of the target shading point is NL. This step then determines the color level value that the target shading point should be output based on the above shading effect parameters.

[0078] In this embodiment, the above-mentioned calculation of color levels based on the color attribute information of the target color point and the coloring effect parameters can be achieved in the following two ways:

[0079] Method 1: Compare the color attribute information of the target shading point with each of the multiple position parameters, and determine the color level value corresponding to the target shading point based on the comparison results and the value of the color level blending mode. Specifically, this process can be as follows: If the color attribute information of the target shading point is greater than the first position parameter and less than the second position parameter, and the color level blending mode is set to Fixed, then the color level value corresponding to the target shading point is determined to be the color level parameter corresponding to the second position parameter; or, if the color attribute information of the target shading point is greater than the first position parameter and less than the second position parameter, and the color level blending mode is set to Blend, then an interpolation operation is performed based on the first position parameter, the second position parameter, and the color attribute information of the target shading point, and the resulting interpolation result is determined as the color level value corresponding to the target shading point; wherein the first position parameter and the second position parameter are adjacent position parameters.

[0080] like Figure 1-CAs shown, the above process can be described as follows: Since NL is the dot product of two unit vectors of the target shading point, the range of NL is [0,1]. This range of values ​​is compared with the color level indices one by one. i cycles from 1 to count, where count is the number of color level indices (color level types), and CK[i] represents the color level parameter and position parameter in the i-th color level index. t1 represents the previous color level index, and t2 represents the current color level index. If the value of NL is between the position parameters of t1 and t2, that is, NL is greater than or equal to t1.a (the position parameter of t1) and NL is less than or equal to t2.a (the position parameter of t2), then the color (color level value) output by the target shading point should be composed of the colors between i and i-1. If the value of the color level blending mode BM is Fixed, then the color level value (t2.rgb) corresponding to the i-th color level index is directly returned as the color level value of the target shading point. If BM is set to Blend, then the color level value corresponding to the i-th color level index is interpolated with the color level value corresponding to the (i-1)-th color level index. The interpolation formula is: P = (NL - t1.a) / (t2.a - t1.a). The final color level value of the target shading point is: t1.rgb + (t2.rgb - t1.rgb) * P. The GPU's shaderlerp instruction can describe the interpolation formula, so the lerp instruction can be used directly to replace the interpolation calculation process.

[0081] Method 2: Multiple matrices are used to represent the multiple positional parameters, and the `step` and `lerp` instructions are used to perform parallel calculations on these matrices to obtain the target matrix corresponding to the target shading point, and the color level value corresponding to the target matrix is ​​calculated. Due to the special nature of the GPU architecture, loops and conditional statements can significantly impact runtime efficiency during low-level operation. To optimize Method 1, Method 2 optimizes the Shader instruction set. Its main idea is to avoid using conditional and loop statements throughout the Shader implementation, utilizing the computational instructions provided by the GPU hardware. It employs a matrix approach and avoids using GPU loops and conditional statements, using only simple addition, subtraction, multiplication, and division instructions to achieve parallel GPU computation, thereby accelerating computation. Figure 1-DAs shown, this process is mainly optimized by 2x4 matrix multiplication instructions. Because GPU computing is parallel, matrix multiplication can greatly accelerate the entire calculation process. At the beginning of the program, T 2x4 matrices are defined. The meaning of each matrix is ​​the color level parameter and position parameter of the first color level index and the color level parameter and position parameter of the second color level index. This series of matrices is defined as the M[i] matrix. A total of T matrices are defined. M[0] represents the color position of the 0th index, and M[T-1] represents the color position of the last index. Next, the step instruction is used to replace the if condition judgment instruction. Because the step instruction has the characteristic of returning 1 if a <= b, otherwise returning 0, the step instruction can be used to determine whether the NL of the target shading point is less than the position parameter of the nth index. Then, the step instruction is combined with the lerp instruction for calculation. If step returns 0, it means taking the value before lerp. If step returns 1, it means taking the value after lerp. Through continuous lerp and step calculations, the final value of step 1 is taken as the result and stored in FC. The final FC obtains the corresponding M matrix. After obtaining the corresponding M matrix, the color level values ​​are interpolated again on the first and second rows of the M matrix to obtain the color level values ​​corresponding to the NL output.

[0082] S104 renders the target model based on color level values.

[0083] After calculating the color level values ​​corresponding to each shading part of the target model in the above steps, in this step, the shader can render the target model based on the above color level values. For example, after obtaining the color level values ​​of the target shading points of the target model, the target shading points can be rendered based on the color level values.

[0084] The color gradation rendering method for the model provided in this disclosure only requires storing a few color gradation indices during color gradation processing, making storage simple. The desired output gradation effect parameters are set through a visual color gradation setting component. This component allows users to set color gradation effects in a WYSIWYG manner. For example, the Gradient UI component allows users to freely select the color blending mode as Blend or Fixed. When using this component, users can freely drag the color positions to display different color gradation effects. Furthermore, the data structure of the gradation effect parameters obtained through this component is relatively simple. These gradation effect parameters, along with the model information of the target model (color attribute information of the target gradation points), can be input into the shader. The color gradation values ​​are calculated using the calculation methods described in Method 1 or Method 2 above. Based on these color gradation values, the model is rendered to obtain the gradation target model.

[0085] It should be noted that although gradation is widely used in non-realistic rendering, non-realistic rendering is only used as an example to explain this method. That is, this method is not limited to non-realistic rendering scenarios. In practice, this method can be applied to any scenario that uses gradation, such as subsurface scattering of skin in realistic rendering.

[0086] This method is relatively simple to implement and is not limited to any particular engine, nor is it limited to forward rendering or deferred rendering. It can maximize the performance of the graphics and make the process of color gradation of game models simpler and more efficient.

[0087] Furthermore, after the instruction set optimization of Method 2 above, a better performance calculation result can be obtained. Since the above calculation process is relatively simple, and the acquisition methods and approaches of the data it depends on (shading effect parameters, color attribute data of target shading points) are relatively simple and efficient, the above method has high scalability (this method can be ported to other platforms and can be implemented in any game engine).

[0088] The first embodiment described above provides a method for rendering color levels of a model. Correspondingly, the second embodiment of this disclosure also provides a device for rendering color levels of a model. This device can be applied in software or hardware to a game platform server to perform color level processing. Since the device embodiment is basically similar to the method embodiment, it is described simply. For details of the relevant technical features, please refer to the corresponding description of the method embodiment provided above. The following description of the device embodiment is merely illustrative.

[0089] Please refer to Figure 2 To understand this embodiment, the figure is a unit block diagram of the color gradation rendering device for the model provided in this embodiment, as shown below. Figure 2 As shown, the color gradation rendering device for the model provided in this embodiment includes:

[0090] The shading effect parameter acquisition unit 201 is used to obtain shading effect parameters for the target model to be shaded, the shading effect parameters including color level parameters and position parameters;

[0091] The model information acquisition unit 202 is used to acquire the model information of the target model;

[0092] The color level value acquisition unit 203 is used to perform color level calculation based on the color effect parameters and the model information to obtain the color level value corresponding to the color part of the target model;

[0093] The model rendering unit 204 is used to render the target model based on the color level values.

[0094] Optionally, obtaining the shading effect parameters for the target model to be shaded includes:

[0095] In response to a color selection operation based on a visual color level setting component, the color level parameters and position parameters corresponding to the selected color are obtained, and the selected color is used for coloring the target model.

[0096] Optionally, obtaining the model information of the target model includes: obtaining the color attribute information of the target shading points of the target model, wherein the color attribute information of the target shading points corresponds to the same data format as the position parameters;

[0097] The step of calculating color levels based on the shading effect parameters and the model information includes: calculating color levels based on the color attribute information of the target shading point and the shading effect parameters.

[0098] Optionally, the color attribute information of the target color point includes one of the following:

[0099] The dot product of the normal unit vector N and the ray unit vector L at the target shading point;

[0100] The hue corresponding to the target color point;

[0101] The saturation corresponding to the target color point;

[0102] The contrast of the target colored point.

[0103] Optionally, the coloring effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters;

[0104] The step of calculating color levels based on the color attribute information of the target color point and the coloring effect parameters includes:

[0105] The color attribute information of the target color point is compared with the multiple position parameters one by one. Based on the comparison results and the value of the color level mixing mode, the color level value corresponding to the target color point is determined.

[0106] Optionally, determining the color level value corresponding to the target color point based on the comparison result and the value of the color level blending mode includes:

[0107] In response to the fact that the color attribute information of the target shading point is greater than the first position parameter and less than the second position parameter, and the value of the color level blending mode is Fixed, the color level value corresponding to the target shading point is determined to be the color level parameter corresponding to the second position parameter;

[0108] Alternatively, in response to the color attribute information of the target shading point being greater than the first position parameter and less than the second position parameter, and the value of the color level blending mode being Blend, an interpolation operation is performed based on the first position parameter, the second position parameter, and the color attribute information of the target shading point, and the resulting interpolation result is determined as the color level value corresponding to the target shading point.

[0109] Wherein, the first position parameter and the second position parameter are adjacent position parameters.

[0110] Optionally, the coloring effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters;

[0111] The step of calculating color levels based on the color attribute information of the target color point and the coloring effect parameters includes:

[0112] Multiple positional parameters are represented by multiple matrices, and the step and lerp instructions are used to perform parallel calculations on the multiple matrices to obtain the target matrix corresponding to the target shading point, and the color level value corresponding to the target matrix is ​​calculated.

[0113] By using the color gradation rendering device for the model provided in this embodiment, the color gradation process of the game model can be made simpler, more efficient, and with less resource consumption.

[0114] In the above embodiments, a method and apparatus for rendering color levels of a model are provided. Furthermore, the third embodiment of this disclosure also provides an electronic device. Since the electronic device embodiment is basically similar to the method embodiment, it is described simply. For details regarding the relevant technical features, please refer to the corresponding descriptions of the above-provided method embodiments. The following description of the electronic device embodiment is merely illustrative. The electronic device embodiment is as follows:

[0115] Please refer to Figure 3 To understand this embodiment, Figure 3 This is a schematic diagram of the logical structure of the electronic device provided in this embodiment. Figure 3 As shown, the electronic device provided in this embodiment includes: a processor 301 and a memory 302;

[0116] The memory 302 is used to store computer instructions for executing the game scene display method. When these computer instructions are read and executed by the processor 301, they perform the following operations:

[0117] Obtain the shading effect parameters for the target model to be shaded, the shading effect parameters including color level parameters and position parameters;

[0118] Obtain the model information of the target model;

[0119] Based on the shading effect parameters and the model information, the color level is calculated to obtain the color level value corresponding to the shading part of the target model;

[0120] The target model is rendered based on the color level values.

[0121] Optionally, obtaining the shading effect parameters for the target model to be shaded includes:

[0122] In response to a color selection operation based on a visual color level setting component, the color level parameters and position parameters corresponding to the selected color are obtained, and the selected color is used for coloring the target model.

[0123] Optionally, obtaining the model information of the target model includes: obtaining the color attribute information of the target shading points of the target model, wherein the color attribute information of the target shading points corresponds to the same data format as the position parameters;

[0124] The step of calculating color levels based on the shading effect parameters and the model information includes: calculating color levels based on the color attribute information of the target shading point and the shading effect parameters.

[0125] Optionally, the color attribute information of the target color point includes one of the following:

[0126] The dot product of the normal unit vector N and the ray unit vector L at the target shading point;

[0127] The hue corresponding to the target color point;

[0128] The saturation corresponding to the target coloring point;

[0129] The contrast of the target colored point.

[0130] Optionally, the coloring effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters;

[0131] The step of calculating color levels based on the color attribute information of the target color point and the coloring effect parameters includes:

[0132] The color attribute information of the target color point is compared with the multiple position parameters one by one. Based on the comparison results and the value of the color level mixing mode, the color level value corresponding to the target color point is determined.

[0133] Optionally, determining the color level value corresponding to the target color point based on the comparison result and the value of the color level blending mode includes:

[0134] In response to the fact that the color attribute information of the target shading point is greater than the first position parameter and less than the second position parameter, and the value of the color level blending mode is Fixed, the color level value corresponding to the target shading point is determined to be the color level parameter corresponding to the second position parameter;

[0135] Alternatively, in response to the color attribute information of the target shading point being greater than the first position parameter and less than the second position parameter, and the value of the color level blending mode being Blend, an interpolation operation is performed based on the first position parameter, the second position parameter, and the color attribute information of the target shading point, and the resulting interpolation result is determined as the color level value corresponding to the target shading point.

[0136] Wherein, the first position parameter and the second position parameter are adjacent position parameters.

[0137] Optionally, the coloring effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters;

[0138] The step of calculating color levels based on the color attribute information of the target color point and the coloring effect parameters includes:

[0139] Multiple positional parameters are represented by multiple matrices, and the step and lerp instructions are used to perform parallel calculations on the multiple matrices to obtain the target matrix corresponding to the target shading point, and the color level value corresponding to the target matrix is ​​calculated.

[0140] Compared to existing color gradation methods, the electronic device provided in this embodiment makes the color gradation process of game models simpler, more efficient, and less resource-intensive.

[0141] In the above embodiments, a method for rendering a model using color gradation, a device for rendering a model using color gradation, and an electronic device are provided. Furthermore, the fourth embodiment of this disclosure also provides a computer-readable storage medium for implementing the above method. The computer-readable storage medium embodiments provided in this disclosure are described in a relatively simple manner; relevant parts can be found in the corresponding descriptions of the above method embodiments. The embodiments described below are merely illustrative.

[0142] The computer-readable storage medium provided in this embodiment stores computer instructions, which, when executed by a processor, perform the following steps: obtaining shading effect parameters for the target model to be shaded, the shading effect parameters including color level parameters and position parameters;

[0143] Obtain the model information of the target model;

[0144] Based on the shading effect parameters and the model information, the color level is calculated to obtain the color level value corresponding to the shading part of the target model;

[0145] The target model is rendered based on the color level values.

[0146] Optionally, obtaining the shading effect parameters for the target model to be shaded includes:

[0147] In response to a color selection operation based on a visual color level setting component, the color level parameters and position parameters corresponding to the selected color are obtained, and the selected color is used for coloring the target model.

[0148] Optionally, obtaining the model information of the target model includes: obtaining the color attribute information of the target shading points of the target model, wherein the color attribute information of the target shading points corresponds to the same data format as the position parameters;

[0149] The step of calculating color levels based on the shading effect parameters and the model information includes: calculating color levels based on the color attribute information of the target shading point and the shading effect parameters.

[0150] Optionally, the color attribute information of the target color point includes one of the following:

[0151] The dot product of the normal unit vector N and the ray unit vector L at the target shading point;

[0152] The hue corresponding to the target color point;

[0153] The saturation corresponding to the target coloring point;

[0154] The contrast of the target colored point.

[0155] Optionally, the coloring effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters;

[0156] The step of calculating color levels based on the color attribute information of the target color point and the coloring effect parameters includes:

[0157] The color attribute information of the target color point is compared with the multiple position parameters one by one. Based on the comparison results and the value of the color level mixing mode, the color level value corresponding to the target color point is determined.

[0158] Optionally, determining the color level value corresponding to the target color point based on the comparison result and the value of the color level blending mode includes:

[0159] In response to the fact that the color attribute information of the target shading point is greater than the first position parameter and less than the second position parameter, and the value of the color level blending mode is Fixed, the color level value corresponding to the target shading point is determined to be the color level parameter corresponding to the second position parameter;

[0160] Alternatively, in response to the color attribute information of the target shading point being greater than the first position parameter and less than the second position parameter, and the value of the color level blending mode being Blend, an interpolation operation is performed based on the first position parameter, the second position parameter, and the color attribute information of the target shading point, and the resulting interpolation result is determined as the color level value corresponding to the target shading point.

[0161] Wherein, the first position parameter and the second position parameter are adjacent position parameters.

[0162] Optionally, the coloring effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters;

[0163] The step of calculating color levels based on the color attribute information of the target color point and the coloring effect parameters includes:

[0164] Multiple positional parameters are represented by multiple matrices, and the step and lerp instructions are used to perform parallel calculations on the multiple matrices to obtain the target matrix corresponding to the target shading point, and the color level value corresponding to the target matrix is ​​calculated.

[0165] By executing the computer instructions stored on the computer-readable storage medium provided in this embodiment, the process of color gradation of game models can be made simpler, more efficient, and with less resource consumption.

[0166] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0167] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0168] 1. Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information by any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include non-transitory computer-readable media, such as modulated data signals and carrier waves.

[0169] 2. Those skilled in the art will understand that the embodiments of this disclosure can be provided as methods, systems, or computer program products. Therefore, this disclosure can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this disclosure can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0170] While this disclosure is presented above with reference to preferred embodiments, it is not intended to limit this disclosure. Any person skilled in the art can make possible changes and modifications without departing from the spirit and scope of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope defined in the claims of this disclosure.

Claims

1. A method for rendering a model using color gradation, characterized in that, include: Obtain the shading effect parameters for the target model to be shaded, the shading effect parameters including color level parameters and position parameters; Obtain the model information of the target model, wherein the model information of the target model includes the color attribute information of the target shading points of the target model; Based on the shading effect parameters and the model information, the color level is calculated to obtain the color level value corresponding to the shading part of the target model; The target model is rendered based on the color level values; The step of calculating color levels based on the shading effect parameters and the model information includes: calculating color levels based on the color attribute information of the target shading point and the shading effect parameters; The coloring effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters. The color level calculation based on the color attribute information of the target color point and the coloring effect parameters includes: When the color effect parameters include the color level blending mode corresponding to the target model, the color attribute information of the target color point is compared with the multiple position parameters one by one. Based on the comparison results and the value of the color level blending mode, the color level value corresponding to the target color point is determined. or, Multiple positional parameters are represented by multiple matrices, and the step and lerp instructions are used to perform parallel calculations on the multiple matrices to obtain the target matrix corresponding to the target shading point, and the color level value corresponding to the target matrix is ​​calculated.

2. The color gradation rendering method for the model according to claim 1, characterized in that, The steps to obtain the shading effect parameters for the target model to be shaded include: In response to a color selection operation based on a visual color level setting component, the color level parameters and position parameters corresponding to the selected color are obtained, and the selected color is used for coloring the target model.

3. The color gradation rendering method for the model according to claim 1, characterized in that, The step of obtaining the model information of the target model includes: obtaining the color attribute information of the target shading points of the target model, wherein the color attribute information of the target shading points corresponds to the same data format as the position parameters.

4. The color gradation rendering method for the model according to claim 3, characterized in that, The color attribute information of the target color point includes one of the following: The dot product of the normal unit vector N and the ray unit vector L at the target shading point; The hue corresponding to the target color point; The saturation corresponding to the target coloring point; The contrast of the target colored point.

5. The color gradation rendering method for the model according to claim 1, characterized in that, The step of determining the color level value corresponding to the target color point based on the comparison result and the value of the color level blending mode includes: In response to the fact that the color attribute information of the target shading point is greater than the first position parameter and less than the second position parameter, and the value of the color level blending mode is Fixed, the color level value corresponding to the target shading point is determined to be the color level parameter corresponding to the second position parameter; Alternatively, in response to the color attribute information of the target shading point being greater than the first position parameter and less than the second position parameter, and the value of the color level blending mode being Blend, an interpolation operation is performed based on the first position parameter, the second position parameter, and the color attribute information of the target shading point, and the resulting interpolation result is determined as the color level value corresponding to the target shading point. Wherein, the first position parameter and the second position parameter are adjacent position parameters.

6. A color gradation rendering device for a model, the device being installed on a game platform, characterized in that, The device includes: A shading effect parameter acquisition unit is used to obtain shading effect parameters for the target model to be shading, the shading effect parameters including color level parameters and position parameters; The model information acquisition unit is used to acquire the model information of the target model, wherein the model information of the target model includes the color attribute information of the target shading points of the target model; A color level value acquisition unit is used to perform color level calculation based on the coloring effect parameters and the model information to obtain the color level value corresponding to the coloring part of the target model; A model rendering unit is used to render the target model based on the color level values; The step of calculating color levels based on the shading effect parameters and the model information includes: calculating color levels based on the color attribute information of the target shading point and the shading effect parameters; The coloring effect parameters include multiple color level parameters and multiple position parameters corresponding to the multiple color level parameters. The color level calculation based on the color attribute information of the target color point and the coloring effect parameters includes: When the color effect parameters include the color level blending mode corresponding to the target model, the color attribute information of the target color point is compared with the multiple position parameters one by one. Based on the comparison results and the value of the color level blending mode, the color level value corresponding to the target color point is determined. or, Multiple positional parameters are represented by multiple matrices, and the step and lerp instructions are used to perform parallel calculations on the multiple matrices to obtain the target matrix corresponding to the target shading point, and the color level value corresponding to the target matrix is ​​calculated.

7. An electronic device, characterized in that, Includes processor and memory; among which, The memory is used to store one or more computer instructions, wherein the one or more computer instructions are executed by the processor to implement the method as described in claims 1-5.

8. A computer-readable storage medium storing one or more computer instructions thereon, characterized in that, The instruction is executed by the processor to implement the method as described in claims 1-5.

Citation Information

Patent Citations

  • Game model rendering method and device, storage medium and electronic device

    CN112215934A

  • Method and system for rendering quadrilateral wireframe of model and model rendering equipment

    CN114170368A