Model rendering method and device, electronic equipment and storage medium
By obtaining the basic color, normal and metallicity information of the three-dimensional model, converting it into a map and rendering the imposter model, the problem of hardware performance pressure caused by rendering a large number of three-dimensional models in the animation is solved, and more efficient rendering performance is achieved.
Patent Information
- Application Number
- CN202411604708.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-03-04
AI Technical Summary
In animation scenes, in order to ensure the display effect, a large number of three-dimensional models need to be rendered at the same time, which leads to the hardware device requiring strong computing power, causing pressure on animation display performance.
By obtaining the basic color information, normal information and metallicity information of the three-dimensional model, it is converted into basic color maps, target normal maps and target metallicity maps, and rendering the imposter model based on these maps. Impposter baking technology is used to reduce the number of patches in the rendered model.
Through the imposter baking technology, the number of patches in the rendered model is reduced, the performance requirements of hardware equipment is reduced, and the performance performance during animation playback is improved.
Smart Images

Figure CN119559314A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of model rendering methods, and in particular to a model rendering method, device, electronic device and storage medium. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the application that are recited in the claims. No description herein is admitted to be prior art by inclusion in this section.
[0003] At present, rendering models are widely used in various animation scenes, and in related technologies, in order to ensure the animation display effect, three-dimensional models are generally used as models to be rendered. However, in some animation scenes, a large number of rendering models need to appear at the same time in the same display screen. For example, in some game recharge animations, a large number of virtual currency models will appear at the same time. In addition, in order to ensure the display effect, the three-dimensional models in related technologies generally include hundreds or thousands of facets. Therefore, in related technologies, if you want to display multiple rendering models in the animation at the same time, the hardware equipment needs to provide powerful computing power, which puts a lot of pressure on the animation display performance. Summary of the invention
[0004] In view of this, the purpose of the present application is to propose a model rendering method, device, electronic device and storage medium to solve or partially solve the problems in the above-mentioned background technology.
[0005] Based on the above purpose, the present application provides a model rendering method, including:
[0006] Obtaining basic color information of a three-dimensional model corresponding to the model to be rendered, and obtaining a basic color map and an imposter model of the model to be rendered based on the basic color information; the imposter model is a two-dimensional model corresponding to the model to be rendered; the basic color map includes color information of the imposter model at multiple angles in space;
[0007] Acquire normal information of a three-dimensional model corresponding to the model to be rendered, and convert the normal information into a target normal map; the target normal map includes normal information of the imposter model at multiple angles in space;
[0008] Acquire the metalness information of the three-dimensional model corresponding to the model to be rendered, and convert the metalness information into a target metalness map; the target metalness map includes the metalness information of the imposter model at multiple angles in space;
[0009] The imposter model is rendered based on the base color map, the target normal map, and the target metalness map.
[0010] Based on the same inventive concept, the exemplary embodiment of the present application further provides a model rendering device, including:
[0011] A basic color baking module, which obtains basic color information of a three-dimensional model corresponding to the model to be rendered, and obtains a basic color map and an imposter model of the model to be rendered based on the basic color information; the imposter model is a two-dimensional model corresponding to the model to be rendered; the basic color map includes color information of the imposter model at multiple angles in space;
[0012] A normal baking module, which obtains normal information of a three-dimensional model corresponding to the model to be rendered, and converts the normal information into a target normal map; the target normal map includes normal information of the imposter model at multiple angles in space;
[0013] A metalness baking module, which obtains metalness information of a three-dimensional model corresponding to the model to be rendered, and converts the metalness information into a target metalness map; the target metalness map includes metalness information of the imposter model at multiple angles in space;
[0014] A rendering module is used to render the imposter model based on the base color map, the target normal map and the target metalness map.
[0015] Based on the same inventive concept, an exemplary embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable by the processor, wherein the processor implements the model rendering method as described above when executing the program.
[0016] Based on the same inventive concept, an exemplary embodiment of the present application further provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the model rendering method as described above.
[0017] Based on the same inventive concept, an exemplary embodiment of the present application further provides a computer program product, which includes a computer program. The computer program is executed by one or more processors so that the processor executes the model rendering method as described above.
[0018] As can be seen from the above, the model rendering method, device, electronic device and storage medium provided by the present application first obtain the basic color information of the three-dimensional model corresponding to the model to be rendered, and obtain the basic color map and imposter model of the model to be rendered based on the basic color information; the imposter model is a two-dimensional model corresponding to the model to be rendered; the basic color map includes the color information of the imposter model at multiple angles in space; then the normal information of the three-dimensional model corresponding to the model to be rendered is obtained, and the normal information is converted into a target normal map; the target normal map includes the color information of the imposter model in space; Then, the metalness information of the three-dimensional model corresponding to the model to be rendered is obtained, and the metalness information is converted into a target metalness map; the target metalness map includes the metalness information of the imposter model at multiple angles in space; finally, the imposter model is rendered based on the base color map, the target normal map and the target metalness map, so that the rendering effect of the model to be rendered is achieved by using the imposter baking technology and the two-dimensional imposter model, which greatly reduces the number of faces of the rendering model and reduces the requirements of the rendering model on the performance of the hardware device during animation playback. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the present application or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 A schematic diagram of an application scenario in an embodiment of the present application;
[0021] Figure 2 A schematic diagram of a flow chart of a model rendering method in an embodiment of the present application;
[0022] Figure 3 This is a schematic diagram of a game recharge animation effect in an embodiment of the present application;
[0023] Figure 4 A schematic diagram of a three-dimensional model corresponding to a model to be rendered in an embodiment of the present application;
[0024] Figure 5 A schematic diagram of an imposter model in an embodiment of the present application;
[0025] Figure 6 is a basic color map in the embodiment of the present application;
[0026] Figure 7 is another basic color map in the embodiment of the present application;
[0027] Figure 8 A target normal map in an embodiment of the present application;
[0028] Fig. 9 A metalness information map in an embodiment of the present application;
[0029] Fig.10 A target metalness map in an embodiment of the present application;
[0030] Fig.11 A preset light and shadow color sampling map in the embodiment of the present application;
[0031] Fig.12 A preset metal material sampling map in the embodiment of the present application;
[0032] Fig.13 This is a comparison diagram of the effects of a model rendering method in an embodiment of the present application;
[0033] Fig.14 A schematic diagram of the structure of a model rendering device according to an embodiment of the present application;
[0034] Fig.15 A schematic diagram of the structure of a specific electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0035] The principles and spirit of the present application will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided only to enable those skilled in the art to better understand and implement the present application, and are not intended to limit the scope of the present application in any way. On the contrary, these embodiments are provided to make the present application more thorough and complete, and to fully convey the scope of the present application to those skilled in the art.
[0036] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present disclosure should be understood by people with ordinary skills in the field to which the present disclosure belongs. The "first", "second" and similar words used in the embodiments of the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. "Including" or "comprising" and similar words mean that the elements or objects appearing in front of the word include the elements or objects listed after the word and their equivalents, without excluding other elements or objects. 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 clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly. In addition, in the description of this application, unless otherwise specified, the term "several" refers to two or more. The term "and / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0037] According to the implementation manner of the present application, a model rendering method, device, electronic device and storage medium are proposed.
[0038] It should be understood herein that any number of elements in the drawings is for illustration rather than limitation, and any naming is only for distinction rather than having any limiting meaning.
[0039] The principles and spirit of the present application are explained in detail below with reference to several representative implementations of the present application. SUMMARY OF THE INVENTION
[0041] In the current related technologies, in order to ensure the animation display effect, a three-dimensional model is generally used as the model to be rendered. However, in some animation scenes, a large number of rendering models need to appear simultaneously in the same display screen. For example, in some game recharge animations, a large number of virtual currency models will appear at the same time. In addition, in order to ensure the display effect, the three-dimensional models in the related technologies generally include hundreds or thousands of facets. Therefore, in the related technologies, if you want to display multiple rendering models in the animation at the same time, the hardware equipment needs to provide powerful computing power, which brings great pressure to the animation display performance. For example, refer to Figure 3, which is a schematic diagram of a game recharge animation effect. If each fairy jade currency model in the animation includes 800 triangles, it will be 1600 triangles after the stroke effect. If 100 fairy jade currency models appear and smash onto the table to form a small hill, then that will be 160,000 triangles. Such a number of faces will bring great pressure on performance.
[0042] In order to solve the above problems, the present application provides a model rendering method, which specifically includes:
[0043] First, basic color information of a three-dimensional model corresponding to a model to be rendered is obtained, and a basic color map and an imposter model of the model to be rendered are obtained based on the basic color information; the imposter model is a two-dimensional model corresponding to the model to be rendered; the basic color map includes color information of the imposter model at multiple angles in space; then normal information of the three-dimensional model corresponding to the model to be rendered is obtained, and the normal information is converted into a target normal map; the target normal map includes normal information of the imposter model at multiple angles in space; then, metalness information of the three-dimensional model corresponding to the model to be rendered is obtained, and the metalness information is converted into a target metalness map; the target metalness map includes metalness information of the imposter model at multiple angles in space; finally, the imposter model is rendered based on the basic color map, the target normal map and the target metalness map, so that the rendering effect of the model to be rendered is achieved by using the imposter baking technology and the two-dimensional imposter model, and each imposter model includes only two facets, which greatly reduces the number of facets of the rendering model and reduces the requirements of the rendering model on the performance of the hardware device during animation playback.
[0044] After introducing the basic principles of the present application, various non-limiting implementation methods of the present application are described in detail below.
[0045] Application Scenario Overview
[0046] In some specific application scenarios, the model rendering method of the present application can be applied to various systems involving model rendering methods. Optionally, the system can be a game system. As an example, refer to Figure 1, the application scenario includes at least one server 102 and at least one terminal 101. Terminal devices include but are not limited to desktop computers, mobile phones, mobile computers, tablet computers, media players, smart wearable devices, personal digital assistants (PDA) or other electronic devices that can realize the above functions. The server can be an independent physical server, or a server cluster or distributed system composed of several physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (content distribution network), and big data and artificial intelligence platforms. The server and the terminal can communicate through the network to realize data transmission. Among them, the network can be a wired network or a wireless network, which is not specifically limited in this application.
[0047] The server may be a server that provides various services. Specifically, the server may be used to provide background services for applications running on the terminal. Optionally, in some implementations, the model rendering method provided in the embodiment of the present application may be executed by a terminal device or a server. When executed by the server, the basic color information of the three-dimensional model corresponding to the model to be rendered is obtained, and the basic color map and the imposter model of the model to be rendered are obtained based on the basic color information; the imposter model is a two-dimensional model corresponding to the model to be rendered; the basic color map includes the color information of the imposter model at multiple angles in space; the normal information of the three-dimensional model corresponding to the model to be rendered is obtained, and the normal information is converted into a target normal map; the target normal map includes the normal information of the imposter model at multiple angles in space; the metalness information of the three-dimensional model corresponding to the model to be rendered is obtained, and the metalness information is converted into a target metalness map; the target metalness map includes the metalness information of the imposter model at multiple angles in space; the imposter model is rendered based on the basic color map, the target normal map and the target metalness map. Optionally, the server may be hardware or software. When the server is hardware, it can be implemented as a distributed server cluster consisting of several servers, or it can be implemented as a single server. When the server is software, it can be implemented as several software or software modules (such as software or software modules for providing distributed services), or it can be implemented as a single software or software module. This embodiment of the application does not specifically limit this.
[0048] Optionally, the wireless network or wired network uses standard communication technology and / or protocol. The network is usually the Internet, but it can also be any network, including but not limited to a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), a mobile, wired or wireless network, a dedicated network or any combination of a virtual private network). In some embodiments, the data exchanged through the network is represented by technologies and / or formats including hypertext mark-up language (HTML), extensible markup language (XML), etc. In addition, conventional encryption technologies such as secure socket layer (SSL), transport layer security (TLS), virtual private network (VPN), and Internet protocol security (IPsec) can be used to encrypt all or some links. In other embodiments, customized and / or dedicated data communication technologies can also be used to replace or supplement the above data communication technologies.
[0049] The following describes the model rendering method according to the exemplary embodiment of the present application in conjunction with a specific application scenario. It should be noted that the above application scenario is only shown to facilitate understanding of the spirit and principle of the present application, and the implementation of the present application is not limited in this regard. On the contrary, the implementation of the present application can be applied to any applicable scenario.
[0050] It should be understood that although Figure 2 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 2 At least part of the steps may include several sub-steps or several stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0051] Exemplary Methods
[0052] refer to Figure 2, an embodiment of the present application provides a model rendering method, the method comprising the following steps:
[0053] S101, obtaining basic color information of a three-dimensional model corresponding to a model to be rendered, and obtaining a basic color map and an imposter model of the model to be rendered based on the basic color information; the imposter model is a two-dimensional model corresponding to the model to be rendered; the basic color map includes color information of the imposter model at multiple angles in space.
[0054] In specific implementation, when obtaining the basic color information of the 3D model corresponding to the model to be rendered, the 3D model corresponding to the model to be rendered can be obtained first, that is, a 3D model that has been rendered, and then the basic color information is obtained through the rendered 3D model. Optionally, the 3D model corresponding to the model to be rendered generally includes multiple facets (more than 2 facets), and the basic color information of the 3D model is the color information of each facet. Figure 4 , is a schematic diagram of a three-dimensional model corresponding to a model to be rendered, and the schematic diagram of the three-dimensional model can be put into a rendering engine to obtain the above basic color information. Optionally, in some embodiments, after obtaining the basic color information of the three-dimensional model corresponding to the model to be rendered, the basic color map of the model to be rendered and the imposter model can be obtained by Imposter baking.
[0055] It should be noted that Imposter is a patch rendering technology that generates textures by photographing the model with cameras at multiple angles, and then maps the textures to the patch to achieve the effect of rendering a 3D stereo model on a two-dimensional patch. Through imposter baking, the base color map of the model to be rendered and the imposter model can be generated according to the basic color information of the three-dimensional model corresponding to the model to be rendered. Among them, the imposter model is a two-dimensional model obtained by imposter baking, and the two-dimensional model is composed of two triangular patches. Reference Figure 5 , which is a generated imposter model. You can see that the imposter model has only 2 triangle faces.
[0056] It should be noted that the basic color map includes the color information of the imposter model at multiple angles in space, wherein each angle corresponds to a sub-basic color map at the angle, that is, the basic color map is composed of multiple sub-basic color maps. Figure 6 ,for Figure 4 A corresponding basic color map can be seen, in which the color information of the imposter model at multiple angles in space is included, and the color information at each angle corresponds to a sub-basic color map at that angle.
[0057] Optionally, in some embodiments, the multiple angles of the imposter model in the space can be determined from various angles in the space as needed. For example, in some embodiments, an angle can be selected every 15 degrees in the 360 degrees of the space, and then 24*24 angles can be obtained. It should be noted that the more the number of the multiple angles, the more detailed the map information that can be obtained, and the user can determine the number of multiple angles according to the current rendering requirements and device performance.
[0058] S102, obtaining normal information of a three-dimensional model corresponding to the model to be rendered, and converting the normal information into a target normal map; the target normal map includes normal information of the imposter model at multiple angles in space.
[0059] In specific implementation, the normal information of the 3D model corresponding to the model to be rendered can also be directly obtained by using the 3D model corresponding to the model to be rendered. That is, the normal information of each vertex of the 3D model is obtained. Then, the normal information is converted into a target normal map by using the imposter baking technology. Since the imposter has only two facets and the normal information it can contain is too little, in order to ensure the rendering effect of the 3D model is restored, reference Figure 8 The baked target normal map includes the normal information of the imposter model at multiple angles in space.
[0060] S103, obtaining metalness information of a three-dimensional model corresponding to the model to be rendered, and converting the metalness information into a target metalness map; the target metalness map includes metalness information of the imposter model at multiple angles in space.
[0061] In specific implementation, as above, when obtaining the metalness information of the three-dimensional model corresponding to the model to be rendered, it can also be directly obtained through the three-dimensional model corresponding to the rendered model to be rendered, that is, obtaining the metalness information corresponding to the three-dimensional model. Optionally, the obtained metalness information generally may include metal strength information, self-shadow information, highlight shape information and metal mask information corresponding to each vertex of the three-dimensional model. Optionally, considering that, in some simply rendered three-dimensional models, their metalness information is not directly obtained through physical rendering, therefore, in some embodiments, the metalness information of the three-dimensional model corresponding to the model to be rendered can also be obtained through a preset metalness information map. Optionally, the metalness information map can be drawn in advance as needed, and there is no limitation on this. Refer to Fig. 9 , for Figure 4 A corresponding metalness information map, through which you can get Figure 4The metalness information of the 3D model corresponding to the model. Fig.10 It is a target metalness map obtained by the imposter baking technology. It can be seen that the target metalness map includes the metalness information of the imposter model at multiple angles in space. In some embodiments, the metalness information corresponding to the target metalness map may include one or more of metal strength information, self-shadow information, highlight shape information, and metal mask information, which is not limited to this.
[0062] S104: Rendering the imposter model based on the base color map, the target normal map, and the target metalness map.
[0063] In specific implementation, after respectively obtaining the base color map, the target normal map and the target metalness map, the imposter model can be rendered according to the three maps, thereby reducing the number of faces of the rendered model while restoring the rendering effect of the three-dimensional model. Fig.13 , where the left side is a rendering effect diagram obtained through the three-dimensional model, and the right side is a rendering effect diagram obtained through this embodiment. It can be seen that there is basically no difference between the two.
[0064] In order to accurately render the imposter model, in some embodiments, rendering the imposter model based on the base color map, the target normal map and the target metalness map specifically includes:
[0065] Determining light and shadow color information of the imposter model based on the target normal map;
[0066] Determining metallic color information of the imposter model based on the base color map, the target normal map, and the target metallicity map;
[0067] Determining highlight color information of the imposter model based on the target normal map and the target metalness map;
[0068] The imposter model is rendered based on the light and shadow color information, the metal color information and the highlight color information.
[0069] In a specific implementation, when rendering the imposter model, the light and shadow color information, metal color information and highlight color information of the imposter model can be determined according to the base color map, the target normal map and the target metalness map, and then the above three color information are superimposed together to complete the rendering of the imposter model.
[0070] In some embodiments, determining the light and shadow color information of the imposter model based on the target normal map specifically includes:
[0071] Get the target lighting direction;
[0072] Determining light and shadow information of the imposter model based on the target illumination direction and the target normal map;
[0073] A preset light and shadow color sampling map is sampled based on the light and shadow information to obtain light and shadow color information of the imposter model.
[0074] In specific implementation, when determining the light and shadow color information of the imposter model, the target lighting direction can be obtained first. The target lighting direction can directly obtain the lighting direction of the model from the rendering engine, or a target lighting direction can be preset directly based on the empirical line of sight. There is no limitation on this. After obtaining the target lighting direction, the dot product operation of the target lighting direction and the normal in the target normal map can be calculated to determine the light and shadow information of the imposter model, and then sample from the preset light and shadow color sampling map based on the light and shadow information to obtain the color information corresponding to each light and shadow information. Optionally, when sampling, the light and shadow information can be first mapped to a preset range, for example, between 0 and 1, and then the mapped light and shadow information can be used to determine the light and shadow color information from the corresponding position in the preset light and shadow color sampling map. Reference Fig.11 , is a preset light and shadow color sampling map in an embodiment of the present application. The sampling map corresponds to the change of light and shadow color from dark to light from left to right. The specific leftmost light and shadow color can be set as needed. For example, in some embodiments, the model to be rendered is the fairy jade currency in the game, and the leftmost color can be set to blue-green.
[0075] Ginseng Fig.11 , is a preset light and shadow color sampling map in an embodiment of the present application, wherein, when determining the light and shadow information of the imposter model, the light information can be classified as a UV coordinate for sampling, and another coordinate component can be set to a fixed value, so that sampling can be completed from the preset light and shadow color sampling map through the UV coordinate. For example, in a certain embodiment, a coordinate component of the UV coordinate is set to a fixed value of 0.2. The coordinate component set to a fixed value generally refers to a direction perpendicular to the direction of the color gradient in the preset light and shadow color sampling map, such as Fig.11 In the vertical direction, at the position of 0.2, there is a color gradient bar with a gradual change in color from left to right. When the light and shadow information of the first vertex corresponding to a certain imposter model is 0.5, the sampling coordinates at this time are (0.5, 0.2), that is, the sampling Fig.11The color value at the middle position of the color gradient bar.
[0076] In order to ensure that the part of the model to be rendered also has self-shadow information when it is illuminated, in some embodiments, the light and shadow color information of the imposter model is determined based on the target normal map, specifically including:
[0077] Get the target lighting direction;
[0078] Obtaining self-shadow information of the imposter model based on the target metalness map;
[0079] Determining light and shadow information of the imposter model based on the self-shadow information, the target lighting direction and the target normal map;
[0080] A preset light and shadow color sampling map is sampled based on the light and shadow information to obtain light and shadow color information of the imposter model.
[0081] In the specific implementation, in order to better restore the shadow effect of the model, in the embodiment of the present application, the self-shadow information of the model is taken into account while calculating the light and shadow information affected by the system illumination. After the illumination and shadow information of the imposter model is determined according to the target illumination direction and the target normal map, the illumination and shadow information and the self-shadow information are further compared, and the minimum value of the two is taken as the shadow value of the final light and shadow information to ensure that there will be self-shadow information in the illuminated part of the model. Then, the preset light and shadow color sampling map is sampled according to the confirmed light and shadow information to obtain the light and shadow color information of the imposter model. Optionally, the specific sampling process can refer to the process of the preset light and shadow color sampling map in the above embodiment, and no further description is given for this. Optionally, in some embodiments, after the self-shadow information and the illumination and shadow information, the smoothstep function can be further used for smooth interpolation to obtain the final shadow area value, that is, the above-mentioned light and shadow information.
[0082] In some embodiments, determining the metallic color information of the imposter model based on the base color map, the target normal map, and the target metallic map specifically includes:
[0083] The coordinates of the target normal map are transformed from the world space to the camera space; and based on the target normal map after the coordinate transformation, a preset metal material sampling map is sampled to obtain metal distribution information of the imposter model;
[0084] Determining first metal color distribution information of the imposter model based on the metal distribution information and preset metal color parameters;
[0085] Obtaining self-shadow information of the imposter model based on the target metalness map; the target metalness map includes the self-shadow information and metal strength information;
[0086] Determine second metal color distribution information of the imposter model based on the self-shadow information, the metal distribution information and the metal color distribution information;
[0087] Determining initial color information of the imposter model based on the basic color map;
[0088] The metal color information of the imposter model is determined based on the metal strength information, the initial color information and the second metal color distribution information.
[0089] In specific implementation, the coordinates of the target normal map can be transformed from the world space to the camera space through the ViewMatrix matrix, and then the preset metal material sampling map is sampled according to the target normal map after the coordinate transformation to obtain the metal distribution information of the imposter model. Optionally, the preset metal material sampling map can be generated or drawn as needed, refer to Fig.12 It is a preset metal material sampling map in the embodiment of the present application, through which the distribution of the metallic luster of the imposter model can be determined. After obtaining the metal distribution information, the metal distribution information can be multiplied by the preset metal color parameter to obtain the first metal color distribution information of the imposter model. Optionally, the preset metal color information can be set symmetrically as needed without limitation.
[0090] In order to determine the brightness of the metal effect, it is necessary to further determine the second metal color distribution information of the imposter model based on the self-shadow information, the metal distribution information and the metal color distribution information. In some embodiments, the second metal color distribution information of the imposter model is determined based on the self-shadow information, the metal distribution information and the metal color distribution information, specifically including:
[0091] Performing smooth interpolation processing on the self-shadow information, and mapping the self-shadow information after the interpolation processing to a preset value range;
[0092] The mapped self-shadow information, the metal distribution information and the metal color distribution information are multiplied to obtain second metal color distribution information of the imposter model.
[0093] In specific implementation, the self-shadow information can be firstly smoothed and interpolated using the smoothstep function to obtain a mask, and the mask is assigned a value between 0.5 and 1 using the lerp function, and then the value is multiplied by the metal distribution information and the metal color distribution information to obtain the second metal color distribution information. Finally, the metal color information of the imposter model is determined according to the metal strength information, the initial color information and the second metal color distribution information. It should be noted that the preset value range can be set as needed, for example, the above-mentioned 0.5 to 1 is not limited to this.
[0094] In some embodiments, before sampling the preset metal material sampling map based on the target normal map after coordinate transformation, the normal coordinates of the target normal map after coordinate transformation may be processed by the following formula:
[0095] matcapuv=viewnormaluv*hlaf2(0.5,-0.5)+half2(0.5,0.5);
[0096] Among them, matcapuv represents the normal coordinates of the target normal map after processing, and viewnormaluv represents the normal coordinates of the target normal map after coordinate transformation.
[0097] In some embodiments, the metal color information of the imposter model is determined by the following formula:
[0098] light_specularMatcap=lerp(A,A*B,Mix_metalIntensity);
[0099] Among them, light_specularMatcap represents the metal color information of the imposter model, A represents the initial color information, B represents the second metal color distribution information, and Mix_metalIntensity represents the metal intensity information.
[0100] In some embodiments, determining the initial color information of the imposter model based on the basic color map specifically includes:
[0101] Get preset color adjustment parameters;
[0102] Initial color information of the imposter model is determined based on the basic color map and the preset color adjustment parameters.
[0103] In specific implementation, the color on the basic color map can be directly multiplied by the preset color adjustment parameter to obtain the initial color information of the imposter model, which is the color information without other information such as metalness. The preset color adjustment parameter can be set as needed, and the color difference of the color can be controlled by the preset color adjustment parameter.
[0104] In some embodiments, determining the highlight color information of the imposter model based on the target normal map and the target metalness map specifically includes:
[0105] Get the target lighting direction and camera direction;
[0106] Determining a highlight calculation direction of the imposter model based on the target illumination direction, the camera direction, and the target normal map;
[0107] Determining highlight shape information of the imposter model based on the target metalness map; the target metalness map includes the highlight shape information;
[0108] Based on the highlight calculation direction, the preset highlight color parameters, the highlight shape information and the light and shadow information, highlight color information of the imposter model is determined.
[0109] In a specific implementation, after determining the highlight calculation direction of the imposter model through the target illumination direction, the camera direction and the target normal map, the highlight shape information of the imposter model is further determined through the target metalness map, and the light and shadow information of the imposter model is determined through the target normal map. Finally, the highlight calculation direction, the preset highlight color parameter, the highlight shape information and the light and shadow information are multiplied to determine the highlight color information of the imposter model.
[0110] It should be noted that the preset highlight color parameters can be set as needed and there is no limitation on this.
[0111] In some embodiments, determining the highlight calculation direction of the imposter model based on the target illumination direction, the camera direction and the target normal map specifically includes:
[0112] Based on the target illumination direction and the camera direction, obtaining a first illumination direction;
[0113] Obtaining a second lighting direction based on the first lighting direction and the target normal map;
[0114] Based on the second illumination direction and the target illumination direction, a highlight calculation direction of the imposter model is determined.
[0115] In a specific implementation, the target illumination direction and the camera direction may be added and then normalized to obtain a first illumination direction, and then the first illumination direction and the normal in the target normal map may be dot-producted and normalized to obtain a second illumination direction, and finally the second illumination direction may be multiplied by the target illumination direction to obtain the highlight calculation direction of the imposter model.
[0116] In some embodiments, before rendering the imposter model based on the base color map, the target normal map, and the target metalness map, the method further includes:
[0117] Determining a stroke color of a three-dimensional model corresponding to the rendering model;
[0118] The transparency color corresponding to the base color map is set as the stroke color.
[0119] When implementing it, refer to Figure 6 and Figure 7 , when the transparency color corresponding to the base color map is set as the stroke color, Figure 6 The background in the Figure 7 For example, when the stroke color of the three-dimensional model corresponding to the rendering model is dark green, when the transparency color corresponding to the basic color map is set to dark green, Figure 7 The background of the 3D model will turn dark green so that the stroke effect of the previous 3D model can be restored in subsequent renderings.
[0120] In some embodiments, after rendering the imposter model based on the base color map, the target normal map, and the target metalness map, the method further includes:
[0121] Acquire color distribution information of the imposter model based on the basic color map;
[0122] Generate stroke information of the imposter model based on the color distribution information and a preset threshold, and add the stroke information to the imposter model;
[0123] Obtaining initial transparency information of the map where the imposter model is located, and amplifying the initial transparency information;
[0124] The transparency information of the rendered imposter model is determined based on the amplified initial transparency information.
[0125] In specific implementation, after obtaining the color distribution information of the imposter model, the color distribution information can be compared with a preset threshold, and the color distribution information less than the preset threshold is made to be 0, so that the color information greater than the preset threshold can be retained, which is equivalent to obtaining the stroke information of the model. It should be noted that the color distribution information can be a grayscale value of a color or a depth value of a certain color, generally between 0 and 1. Since the stroke of the model before is assumed to belong to the darkest area of the model color distribution, the stroke information of the model is directly generated by the color distribution information and the preset threshold. After adding the stroke information to the imposter model, the initial transparency information of the imposter model is further amplified to determine the transparency information of the rendered imposter model.
[0126] In order to accurately calculate the edge light of the model, in some embodiments, the imposter model is rendered based on the light and shadow color information, the metal color information and the highlight color information, specifically including:
[0127] Get the camera direction;
[0128] Determining edge light information of the imposter model based on the target normal map and the camera direction;
[0129] The imposter model is rendered based on the edge light information, the light and shadow color information, the metal color information and the highlight color information.
[0130] In a specific implementation, when obtaining the camera direction, it can be directly obtained through a rendering engine, or the camera direction can be obtained by subtracting the camera position from the pixel position, and then the edge light information of the imposter model is obtained by performing a dot product of the camera direction and the normal in the target normal map. Finally, the edge light information, the light and shadow color information, the metal color information and the highlight color information are superimposed together to achieve rendering of the imposter model.
[0131] In some embodiments, after rendering the imposter model based on the base color map, the target normal map, and the target metalness map, the method further includes:
[0132] The rendered imposter model is bound to the target animation skeleton to generate the target animation effect.
[0133] In specific implementation, the rendered imposter model is bound to the target animation skeleton. When the target animation effect is generated, since the imposter model has only two faces, the performance consumption of the system when playing the target animation effect is greatly reduced.
[0134] In some embodiments, the method further comprises:
[0135] Obtaining a plurality of rendered imposter models;
[0136] By batch processing, the rendered imposter model is bound to the target animation skeleton to generate the target animation effect.
[0137] In specific implementation, when the target animation to be played requires multiple imposter models, since each imposter model uses the same rendering method, batch processing can be used to further improve rendering efficiency. It should be noted that, considering that in some rendering engines, batch processing requires the use of a world matrix for calculation, but the original default world matrix is not the same as the world matrix required for batch processing. Therefore, in order to achieve the correct batching effect, the world matrix called during the shader calculation process must use the batched world matrix. In order to call this batched world matrix, a declaration must be made in the rendering engine, and this declaration enables the shader to call the batched world matrix during the calculation process.
[0138] The model rendering method provided by the present application first obtains basic color information of a three-dimensional model corresponding to the model to be rendered, and obtains a basic color map and an imposter model of the model to be rendered based on the basic color information; the imposter model is a two-dimensional model corresponding to the model to be rendered; the basic color map includes color information of the imposter model at multiple angles in space; then obtains normal information of the three-dimensional model corresponding to the model to be rendered, and converts the normal information into a target normal map; the target normal map includes normal information of the imposter model at multiple angles in space; then obtains the model to be rendered The method comprises the following steps: obtaining the metalness information of the three-dimensional model corresponding to the imposter model, and converting the metalness information into a target metalness map; the target metalness map includes the metalness information of the imposter model at multiple angles in space; finally, rendering the imposter model based on the base color map, the target normal map and the target metalness map, thereby using the imposter baking technology and adopting the two-dimensional imposter model to achieve the rendering effect of the model to be rendered, each imposter model includes only two facets, which greatly reduces the number of facets of the rendering model and reduces the requirements of the rendering model on the performance of the hardware device during animation playback.
[0139] It should be noted that the method of the embodiment of the present application can be performed by a single device, such as a computer or server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In the case of such a distributed scenario, one of the multiple devices can only perform one or several steps in the method of the embodiment of the present application, and the multiple devices will interact with each other to complete the described method.
[0140] It should be noted that the above describes some embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0141] Exemplary Devices
[0142] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a model rendering device.
[0143] refer to Fig.14 , the model rendering device comprises:
[0144] The basic color baking module 201 obtains basic color information of a three-dimensional model corresponding to the model to be rendered, and obtains a basic color map and an imposter model of the model to be rendered based on the basic color information; the imposter model is a two-dimensional model corresponding to the model to be rendered; the basic color map includes color information of the imposter model at multiple angles in space;
[0145] A normal baking module 202 is used to obtain normal information of a three-dimensional model corresponding to the model to be rendered, and convert the normal information into a target normal map; the target normal map includes normal information of the imposter model at multiple angles in space;
[0146] The metalness baking module 203 obtains the metalness information of the three-dimensional model corresponding to the model to be rendered, and converts the metalness information into a target metalness map; the target metalness map includes the metalness information of the imposter model at multiple angles in space;
[0147] The rendering module 204 renders the imposter model based on the base color map, the target normal map and the target metalness map.
[0148] In some embodiments, the rendering module specifically includes:
[0149] a light and shadow color determination unit, which determines light and shadow color information of the imposter model based on the target normal map;
[0150] a metal color determination unit, which determines metal color information of the imposter model based on the base color map, the target normal map and the target metalness map;
[0151] a highlight color determination unit, which determines highlight color information of the imposter model based on the target normal map and the target metalness map;
[0152] A rendering unit renders the imposter model based on the light and shadow color information, the metal color information and the highlight color information.
[0153] In some embodiments, the light and shadow color determination unit is specifically used to:
[0154] Get the target lighting direction;
[0155] Determining light and shadow information of the imposter model based on the target illumination direction and the target normal map;
[0156] A preset light and shadow color sampling map is sampled based on the light and shadow information to obtain light and shadow color information of the imposter model.
[0157] In some embodiments, the light and shadow color determination unit is specifically used to:
[0158] Get the target lighting direction;
[0159] Obtaining self-shadow information of the imposter model based on the target metalness map;
[0160] Determining light and shadow information of the imposter model based on the self-shadow information, the target lighting direction and the target normal map;
[0161] A preset light and shadow color sampling map is sampled based on the light and shadow information to obtain light and shadow color information of the imposter model.
[0162] In some embodiments, the metal color determination unit specifically includes:
[0163] The coordinates of the target normal map are transformed from the world space to the camera space; and based on the target normal map after the coordinate transformation, a preset metal material sampling map is sampled to obtain metal distribution information of the imposter model;
[0164] Determining first metal color distribution information of the imposter model based on the metal distribution information and preset metal color parameters;
[0165] Obtaining self-shadow information of the imposter model based on the target metalness map; the target metalness map includes the self-shadow information and metal strength information;
[0166] Determine second metal color distribution information of the imposter model based on the self-shadow information, the metal distribution information and the metal color distribution information;
[0167] Determining initial color information of the imposter model based on the basic color map;
[0168] The metal color information of the imposter model is determined based on the metal strength information, the initial color information and the second metal color distribution information.
[0169] In some embodiments, the metal color information of the imposter model is determined by the following formula:
[0170] light_specularMatcap=lerp(A,A*B,Mix_metalIntensity);
[0171] Among them, light_specularMatcap represents the metal color information of the imposter model, A represents the initial color information, B represents the second metal color distribution information, and Mix_metalIntensity represents the metal intensity information.
[0172] In some embodiments, the metal color determination unit is specifically used to:
[0173] Get preset color adjustment parameters;
[0174] Initial color information of the imposter model is determined based on the basic color map and the preset color adjustment parameters.
[0175] In some embodiments, the metal color determination unit is specifically used to:
[0176] Performing smooth interpolation processing on the self-shadow information, and mapping the self-shadow information after the interpolation processing to a preset value range;
[0177] The mapped self-shadow information, the metal distribution information and the metal color distribution information are multiplied to obtain second metal color distribution information of the imposter model.
[0178] In some embodiments, the highlight color determination unit is specifically configured to:
[0179] Get the target lighting direction and camera direction;
[0180] Determining a highlight calculation direction of the imposter model based on the target illumination direction, the camera direction, and the target normal map;
[0181] Determining highlight shape information of the imposter model based on the target metalness map; the target metalness map includes the highlight shape information;
[0182] Based on the highlight calculation direction, the preset highlight color parameters, the highlight shape information and the light and shadow information, highlight color information of the imposter model is determined.
[0183] In some embodiments, the highlight color determination unit is specifically configured to:
[0184] Based on the target illumination direction and the camera direction, obtaining a first illumination direction;
[0185] Obtaining a second lighting direction based on the first lighting direction and the target normal map;
[0186] Based on the second illumination direction and the target illumination direction, a highlight calculation direction of the imposter model is determined.
[0187] In some embodiments, the device further comprises a transparency adjustment module, configured to:
[0188] Determining a stroke color of a three-dimensional model corresponding to the rendering model;
[0189] The transparency color corresponding to the base color map is set as the stroke color.
[0190] In some embodiments, the device further comprises a stroke module, configured to:
[0191] Acquire color distribution information of the imposter model based on the basic color map;
[0192] Generate stroke information of the imposter model based on the color distribution information and a preset threshold, and add the stroke information to the imposter model;
[0193] Obtaining initial transparency information of the map where the imposter model is located, and amplifying the initial transparency information;
[0194] The transparency information of the rendered imposter model is determined based on the amplified initial transparency information.
[0195] In some embodiments, the rendering module is specifically used to:
[0196] Get the camera direction;
[0197] Determining edge light information of the imposter model based on the target normal map and the camera direction;
[0198] The imposter model is rendered based on the edge light information, the light and shadow color information, the metal color information and the highlight color information.
[0199] In some embodiments, the apparatus further comprises an animation module for:
[0200] The rendered imposter model is bound to the target animation skeleton to generate the target animation effect.
[0201] In some embodiments, the apparatus further comprises a batch processing module, configured to:
[0202] Obtaining a plurality of rendered imposter models;
[0203] By batch processing, the rendered imposter model is bound to the target animation skeleton to generate the target animation effect.
[0204] For the convenience of description, the above device is described in terms of functions divided into various modules. Of course, when implementing the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0205] The model rendering device of the above embodiment is used to implement the corresponding model rendering method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0206] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the model rendering method described in any of the above embodiments is implemented.
[0207] Fig.15A more specific schematic diagram of the hardware structure of an electronic device provided in this embodiment is shown, and the device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are connected to each other through the bus 1050 in the device.
[0208] The processor 1010 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0209] The memory 1020 may be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.
[0210] The input / output interface 1030 is used to connect the input / output module to realize information input and output. The input / output module can be configured in the device as a component (not shown in the figure), or it can be externally connected to the device to provide corresponding functions. The input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.
[0211] The communication interface 1040 is used to connect a communication module (not shown) to realize communication interaction between the device and other devices. The communication module can realize communication through a wired mode (such as USB, network cable, etc.) or a wireless mode (such as mobile network, WIFI, Bluetooth, etc.).
[0212] The bus 1050 includes a path that transmits information between the various components of the device (eg, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).
[0213] It should be noted that, although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040 and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, it can be understood by those skilled in the art that the above device may also only include the components necessary for implementing the embodiments of the present specification, and does not necessarily include all the components shown in the figure.
[0214] The electronic device of the above embodiment is used to implement the corresponding model rendering method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0215] The memory 1020 stores machine-readable instructions executable by the processor 1010. When the electronic device is running, the processor 1010 communicates with the memory 1020 through the bus 1050, so that the processor 1010 executes the following instructions when running: obtaining basic color information of a three-dimensional model corresponding to the model to be rendered, and obtaining a basic color map and an imposter model of the model to be rendered based on the basic color information; the imposter model is a two-dimensional model corresponding to the model to be rendered; the basic color map includes color information of the imposter model at multiple angles in space; obtaining normal information of the three-dimensional model corresponding to the model to be rendered, and converting the normal information into a target normal map; the target normal map includes normal information of the imposter model at multiple angles in space; obtaining metalness information of the three-dimensional model corresponding to the model to be rendered, and converting the metalness information into a target metalness map; the target metalness map includes metalness information of the imposter model at multiple angles in space; rendering the imposter model based on the basic color map, the target normal map and the target metalness map.
[0216] In a possible implementation, the instructions executed by the processor 1010 render the imposter model based on the base color map, the target normal map, and the target metalness map, specifically including: determining light and shadow color information of the imposter model based on the target normal map; determining metal color information of the imposter model based on the base color map, the target normal map, and the target metalness map; determining highlight color information of the imposter model based on the target normal map and the target metalness map; rendering the imposter model based on the light and shadow color information, the metal color information, and the highlight color information.
[0217] In a possible implementation, the instructions executed by the processor 1010 determine the light and shadow color information of the imposter model based on the target normal map, specifically including: obtaining a target lighting direction; determining the light and shadow information of the imposter model based on the target lighting direction and the target normal map; sampling a preset light and shadow color sampling map based on the light and shadow information to obtain the light and shadow color information of the imposter model.
[0218] In a possible implementation, the instructions executed by the processor 1010 determine the light and shadow color information of the imposter model based on the target normal map, specifically including: obtaining the target lighting direction; obtaining the self-shadow information of the imposter model based on the target metalness map; determining the light and shadow information of the imposter model based on the self-shadow information, the target lighting direction and the target normal map; sampling a preset light and shadow color sampling map based on the light and shadow information to obtain the light and shadow color information of the imposter model.
[0219] In a possible implementation, the instructions executed by the processor 1010 determine the metal color information of the imposter model based on the base color map, the target normal map and the target metal map; specifically include: transforming the coordinates of the target normal map from the world space to the camera space; and sampling a preset metal material sampling map based on the target normal map after the coordinate transformation to obtain the metal distribution information of the imposter model; determining the first metal color distribution information of the imposter model based on the metal distribution information and the preset metal color parameter; obtaining the self-shadow information of the imposter model based on the target metal map; the target metal map includes the self-shadow information and the metal strength information; determining the second metal color distribution information of the imposter model based on the self-shadow information, the metal distribution information and the metal color distribution information; determining the initial color information of the imposter model based on the base color map; determining the metal color information of the imposter model based on the metal strength information, the initial color information and the second metal color distribution information.
[0220] In a possible implementation, in the instructions executed by the processor 1010, the metal color information of the imposter model is determined by the following formula:
[0221] light_specularMatcap=lerp(A, A*B, Mix_metalIntensity); wherein light_specularMatcap represents the metal color information of the imposter model, A represents the initial color information, B represents the second metal color distribution information, and Mix_metalIntensity represents the metal intensity information.
[0222] In a possible implementation, the instructions executed by the processor 1010 include determining the initial color information of the imposter model based on the basic color map, specifically including: obtaining preset color adjustment parameters; and determining the initial color information of the imposter model based on the basic color map and the preset color adjustment parameters.
[0223] In a possible implementation, the instructions executed by the processor 1010 determine the second metal color distribution information of the imposter model based on the self-shadow information, the metal distribution information and the metal color distribution information, specifically including: performing smooth interpolation processing on the self-shadow information, and mapping the self-shadow information after interpolation processing to a preset numerical range; multiplying the mapped self-shadow information, the metal distribution information and the metal color distribution information to obtain the second metal color distribution information of the imposter model.
[0224] In a possible implementation, the instructions executed by the processor 1010 determine the highlight color information of the imposter model based on the target normal map and the target metalness map, specifically including: obtaining a target lighting direction and a camera direction; determining a highlight calculation direction of the imposter model based on the target lighting direction, the camera direction and the target normal map; determining highlight shape information of the imposter model based on the target metalness map; the target metalness map includes the highlight shape information; determining the highlight color information of the imposter model based on the highlight calculation direction, preset highlight color parameters, the highlight shape information and the light and shadow information.
[0225] In a possible implementation, the instructions executed by the processor 1010 determine the highlight calculation direction of the imposter model based on the target illumination direction, the camera direction, and the target normal map, specifically including: obtaining a first illumination direction based on the target illumination direction and the camera direction; obtaining a second illumination direction based on the first illumination direction and the target normal map; and determining the highlight calculation direction of the imposter model based on the second illumination direction and the target illumination direction.
[0226] In a possible implementation, in the instructions executed by the processor 1010, before rendering the imposter model based on the base color map, the target normal map, and the target metalness map, the method further includes: determining a stroke color of a three-dimensional model corresponding to the rendered model; and setting a transparency color corresponding to the base color map as a stroke color.
[0227] In a possible implementation, in the instructions executed by the processor 1010, after rendering the imposter model based on the base color map, the target normal map and the target metalness map, the method further includes: obtaining color distribution information of the imposter model based on the base color map; generating stroke information of the imposter model based on the color distribution information and a preset threshold, and adding the stroke information to the imposter model; obtaining initial transparency information of the map where the imposter model is located, and amplifying the initial transparency information; determining the transparency information of the rendered imposter model based on the amplified initial transparency information.
[0228] In a possible implementation, the instructions executed by the processor 1010 render the imposter model based on the light and shadow color information, the metal color information, and the highlight color information, specifically including: obtaining a camera direction; determining edge light information of the imposter model based on the target normal map and the camera direction; and rendering the imposter model based on the edge light information, the light and shadow color information, the metal color information, and the highlight color information.
[0229] In a possible implementation, in the instructions executed by the processor 1010, after rendering the imposter model based on the base color map, the target normal map, and the target metalness map, the method further includes: binding the rendered imposter model to a target animation skeleton to generate the target animation effect.
[0230] In a possible implementation, in the instructions executed by the processor 1010, the method further includes: acquiring a plurality of rendered imposter models; and binding the rendered imposter models to a target animation skeleton through batch processing to generate the target animation effect.
[0231] By the above method, when the electronic device is running, the basic color information of the three-dimensional model corresponding to the model to be rendered is first obtained, and the basic color map and the imposter model of the model to be rendered are obtained based on the basic color information; the imposter model is a two-dimensional model corresponding to the model to be rendered; the basic color map includes the color information of the imposter model at multiple angles in space; then the normal information of the three-dimensional model corresponding to the model to be rendered is obtained, and the normal information is converted into a target normal map; the target normal map includes the normal information of the imposter model at multiple angles in space; then the model to be rendered is obtained. The imposter model is rendered based on the base color map, the target normal map and the target metalness map, thereby using the imposter baking technology and the two-dimensional imposter model to achieve the rendering effect of the model to be rendered. Each imposter model includes only two facets, which greatly reduces the number of facets of the rendered model and reduces the requirements of the rendering model on the performance of the hardware device during animation playback.
[0232] Exemplary Program Products
[0233] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the model rendering method described in any of the above embodiments.
[0234] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented 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 technology, read-only compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0235] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the model rendering method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0236] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present application also provides a computer program product, which includes a computer program. In some embodiments, the computer program instructions can be executed by one or more processors of a computer so that the computer and / or the processor execute the model rendering method described in the above-mentioned embodiment. Corresponding to the execution subject corresponding to each step in each embodiment of the scene editing method, the processor that executes the corresponding step can belong to the corresponding execution subject.
[0237] The computer program product of the above embodiment is used to enable the computer and / or the processor to execute the model rendering method described in any of the above embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0238] It is understandable that before using the technical solutions of each embodiment of the present application, the type, scope of use, usage scenarios, etc. of the personal information involved will be informed to the user in an appropriate manner, and the user's authorization will be obtained.
[0239] For example, in response to receiving an active request from a user, a prompt message is sent to the user to clearly remind the user that the operation requested to be performed will require obtaining and using the user's personal information. Thus, the user can independently choose whether to provide personal information to the electronic device, application, server, storage medium or other software or hardware that performs the operation of the technical solution of the present application according to the prompt message.
[0240] As an optional but non-limiting implementation, in response to receiving the user's active request, the prompt information may be sent to the user in the form of a pop-up window, in which the prompt information may be presented in text form. In addition, the pop-up window may also carry a selection control for the user to choose "agree" or "disagree" to provide personal information to the electronic device.
[0241] It is understandable that the above notification and the process of obtaining user authorization are merely illustrative and do not constitute a limitation on the implementation method of this application. Other methods that meet relevant laws and regulations may also be applied to the implementation method of this application.
[0242] It should be understood by those skilled in the art that the embodiments of the present application can be implemented as a system, method or computer program product. Therefore, the present application can be specifically implemented in the following forms, namely: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as "circuit", "module" or "system". In addition, in some embodiments, the present application can also be implemented in the form of a computer program product in one or more computer-readable media, which contains computer-readable program code.
[0243] Any combination of one or more computer-readable media can be used. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive examples) of computer-readable storage media can include, for example: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0244] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0245] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0246] Computer program code for performing the operation of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).
[0247] It should be understood that each box in the flowchart and / or block diagram and the combination of boxes in the flowchart and / or block diagram can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer or other programmable data processing device to produce a machine, and these computer program instructions are executed by a computer or other programmable data processing device to produce a device that implements the functions / operations specified in the boxes in the flowchart and / or block diagram.
[0248] These computer program instructions may also be stored in a computer-readable medium that enables a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable medium produce a product that includes an instruction device that implements the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0249] Computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby enabling the instructions executed on the computer or other programmable device to provide a process for implementing the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0250] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Among them, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0251] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into several modules or units to be embodied.
[0252] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples; based on the concept of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other adjustments to the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.
[0253] In addition, to simplify the description and discussion, and in order not to make the embodiments of the present application difficult to understand, the known power supply / ground connection with the integrated circuit (IC) chip and other components may or may not be shown in the provided drawings. In addition, the device can be shown in the form of a block diagram to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform to be implemented in the embodiments of the present application (that is, these details should be fully within the scope of understanding of those skilled in the art). In the case of elaborating specific details (e.g., circuits) to describe exemplary embodiments of the present application, it is obvious to those skilled in the art that the embodiments of the present application can be implemented without these specific details or when these specific details are adjusted. Therefore, these descriptions should be considered to be illustrative rather than restrictive.
[0254] Although the present application has been described in conjunction with specific embodiments of the present application, many replacements, modifications and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may use the embodiments discussed.
[0255] The embodiments of the present application are intended to cover all such substitutions, modifications and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of the present application.
Claims
1. A model rendering method, characterized in that: include: Obtaining basic color information of a three-dimensional model corresponding to the model to be rendered, and obtaining a basic color map and an imposter model of the model to be rendered based on the basic color information; the imposter model is a two-dimensional model corresponding to the model to be rendered; the basic color map includes color information of the imposter model at multiple angles in space; Acquire normal information of a three-dimensional model corresponding to the model to be rendered, and convert the normal information into a target normal map; the target normal map includes normal information of the imposter model at multiple angles in space; Acquire the metalness information of the three-dimensional model corresponding to the model to be rendered, and convert the metalness information into a target metalness map; the target metalness map includes the metalness information of the imposter model at multiple angles in space; The imposter model is rendered based on the base color map, the target normal map, and the target metalness map.
2. The method according to claim 1, characterized in that Rendering the imposter model based on the base color map, the target normal map, and the target metalness map specifically includes: Determining light and shadow color information of the imposter model based on the target normal map; Determining metallic color information of the imposter model based on the base color map, the target normal map, and the target metallic map; Determining highlight color information of the imposter model based on the target normal map and the target metalness map; The imposter model is rendered based on the light and shadow color information, the metal color information and the highlight color information.
3. The method according to claim 2, characterized in that Determining light and shadow color information of the imposter model based on the target normal map specifically includes: Get the target lighting direction; Determining light and shadow information of the imposter model based on the target illumination direction and the target normal map; A preset light and shadow color sampling map is sampled based on the light and shadow information to obtain light and shadow color information of the imposter model.
4. The method according to claim 2, characterized in that: Determining light and shadow color information of the imposter model based on the target normal map specifically includes: Get the target lighting direction; Obtaining self-shadow information of the imposter model based on the target metalness map; Determining light and shadow information of the imposter model based on the self-shadow information, the target lighting direction and the target normal map; A preset light and shadow color sampling map is sampled based on the light and shadow information to obtain light and shadow color information of the imposter model.
5. The method according to claim 2, characterized in that: Determining the metallic color information of the imposter model based on the base color map, the target normal map and the target metallic map; specifically comprising: The coordinates of the target normal map are transformed from the world space to the camera space; and based on the target normal map after the coordinate transformation, a preset metal material sampling map is sampled to obtain metal distribution information of the imposter model; Determining first metal color distribution information of the imposter model based on the metal distribution information and preset metal color parameters; Obtaining self-shadow information of the imposter model based on the target metalness map; the target metalness map includes the self-shadow information and metal strength information; Determine second metal color distribution information of the imposter model based on the self-shadow information, the metal distribution information and the metal color distribution information; Determining initial color information of the imposter model based on the basic color map; The metal color information of the imposter model is determined based on the metal strength information, the initial color information and the second metal color distribution information.
6. The method according to claim 5, characterized in that The metal color information of the imposter model is determined by the following formula: light_specularMatcap=lerp(A,A*B,Mix_metalIntensity); Among them, light_specularMatcap represents the metal color information of the imposter model, A represents the initial color information, B represents the second metal color distribution information, and Mix_metalIntensity represents the metal intensity information.
7. The method according to claim 5, characterized in that Determining initial color information of the imposter model based on the basic color map specifically includes: Get preset color adjustment parameters; Initial color information of the imposter model is determined based on the basic color map and the preset color adjustment parameters.
8. The method according to claim 5, characterized in that Determining second metal color distribution information of the imposter model based on the self-shadow information, the metal distribution information and the metal color distribution information specifically includes: Performing smooth interpolation processing on the self-shadow information, and mapping the self-shadow information after the interpolation processing to a preset value range; The mapped self-shadow information, the metal distribution information and the metal color distribution information are multiplied to obtain second metal color distribution information of the imposter model.
9. The method according to claim 3 or 4, characterized in that: Determining highlight color information of the imposter model based on the target normal map and the target metalness map specifically includes: Get the target lighting direction and camera direction; Determining a highlight calculation direction of the imposter model based on the target illumination direction, the camera direction, and the target normal map; Determining highlight shape information of the imposter model based on the target metalness map; the target metalness map includes the highlight shape information; Based on the highlight calculation direction, the preset highlight color parameters, the highlight shape information and the light and shadow information, highlight color information of the imposter model is determined.
10. The method according to claim 9, characterized in that Determining a highlight calculation direction of the imposter model based on the target illumination direction, the camera direction, and the target normal map specifically includes: Based on the target illumination direction and the camera direction, obtaining a first illumination direction; Based on the first illumination direction and the target normal map, obtaining a second illumination direction; Based on the second illumination direction and the target illumination direction, a highlight calculation direction of the imposter model is determined.
11. The method according to claim 1, characterized in that: Before rendering the imposter model based on the base color map, the target normal map and the target metalness map, the method further includes: Determining a stroke color of a three-dimensional model corresponding to the rendering model; The transparency color corresponding to the base color map is set as the stroke color.
12. The method according to claim 11, characterized in that After rendering the imposter model based on the base color map, the target normal map, and the target metalness map, the method further includes: Acquire color distribution information of the imposter model based on the basic color map; Generate stroke information of the imposter model based on the color distribution information and a preset threshold, and add the stroke information to the imposter model; Obtaining initial transparency information of the map where the imposter model is located, and amplifying the initial transparency information; The transparency information of the rendered imposter model is determined based on the amplified initial transparency information.
13. The method according to claim 2, characterized in that Rendering the imposter model based on the light and shadow color information, the metal color information and the highlight color information specifically includes: Get the camera direction; Determining edge light information of the imposter model based on the target normal map and the camera direction; The imposter model is rendered based on the edge light information, the light and shadow color information, the metal color information and the highlight color information.
14. The method according to claim 1, characterized in that After rendering the imposter model based on the base color map, the target normal map, and the target metalness map, the method further includes: The rendered imposter model is bound to the target animation skeleton to generate the target animation effect.
15. The method according to claim 14, characterized in that The method further comprises: Obtaining a plurality of rendered imposter models; The rendered imposter model is bound to the target animation skeleton through batch processing to generate the target animation effect.
16. A model rendering device, characterized in that: include: A basic color baking module, which obtains basic color information of a three-dimensional model corresponding to the model to be rendered, and obtains a basic color map and an imposter model of the model to be rendered based on the basic color information; the imposter model is a two-dimensional model corresponding to the model to be rendered; the basic color map includes color information of the imposter model at multiple angles in space; A normal baking module, which obtains normal information of a three-dimensional model corresponding to the model to be rendered, and converts the normal information into a target normal map; the target normal map includes normal information of the imposter model at multiple angles in space; A metalness baking module, which obtains metalness information of a three-dimensional model corresponding to the model to be rendered, and converts the metalness information into a target metalness map; the target metalness map includes metalness information of the imposter model at multiple angles in space; A rendering module is used to render the imposter model based on the base color map, the target normal map and the target metalness map.
17. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable by the processor, wherein the processor implements the method according to any one of claims 1 to 15 when executing the program.
18. A non-transitory computer-readable storage medium, characterized in that: The non-transitory computer-readable storage medium stores computer instructions for causing a computer to execute the method according to any one of claims 1 to 15.