Material rendering method and device, storage medium, and electronic device

By converting model normal information into vertex color information for rendering, the existing technology problems of difficulty in stylized light and shadow rendering of models and high consumption of normal maps are solved, achieving efficient rendering effects and low consumption of storage.

CN114241114BActive Publication Date: 2024-09-10SHANGHAI PERFECT WORLD SOFTWARE CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202111582697.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-22
Publication Date
2024-09-10
Estimated Expiration
2041-12-22

AI Technical Summary

Technical Problem

Existing technology cannot effectively perform stylized light and shadow rendering of model normals, and normal mapping results in excessive storage space and rendering consumption, which cannot meet the needs of game manufacturers and players for the ultimate stylized rendering effect.

Method used

By selecting the initial normal group to be edited, editing and converting it based on the specified coordinate system to obtain the target normal group, converting the normal information into vertex color information, and using the vertex color information to render the stylized material, reducing the storage space and Rendering cost.

Benefits of technology

It realizes stylized light and shadow rendering of the model, which meets the demand for the ultimate stylized rendering effect. At the same time, it reduces the storage space consumption and rendering consumption caused by normal maps, and improves the efficiency of normal editing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114241114B
    Figure CN114241114B
Patent Text Reader

Abstract

The present invention provides a material rendering method and device, storage medium, and electronic device, wherein the method comprises: selecting an initial normal group to be edited according to the structural trend of a target model, wherein the initial normal group includes normal information of multiple target model vertices; editing the initial normal group based on a specified axis of a specified coordinate system to obtain an intermediate normal group; converting the intermediate normal group to obtain a target normal group; converting the normal information of the target model into vertex color information based on the target normal group, wherein the vertex color information is used to store the normal information of the target normal group; and rendering the stylized material of the target model using the vertex color information. The present invention solves the technical problem that the related technology cannot render the model in stylized light and shadow, and can meet the requirements of game manufacturers and players for the ultimate stylized rendering effect, while reducing the storage space consumption and rendering consumption caused by the normal map, and improving the editing efficiency of the normal.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a material rendering method and device, a storage medium, and an electronic device. Background Art

[0002] In related technologies, the normal information of the model mesh determines the pointing direction of the triangle surface and is used to calculate lighting-related shading effects. In most CG film, television or game works with stylized lighting and shadow effects, 3D artists usually manually adjust the model normal information and match the shading scheme to achieve the expected lighting and shadow rendering results, and finally cover the original mesh normal information or bake it on the normal map as a storage medium.

[0003] In games with related technologies, 3D artists generally use normal editing tools to manually draw normal information, but it is impossible to achieve normal grouping through existing art editing tools, accurately adjust normal information in "groups" and store normal information separately as separate files for subsequent use. Secondly, stylized light and shadow often require "normal transfer" from a smoother model mesh to the currently used model mesh. Thirdly, storing normal information through normal maps requires a certain amount of storage space and rendering consumption.

[0004] Normal editing tools in related technologies cannot meet the requirements of efficient normal editing and the formation of normals at specific angles, and will also occupy additional storage and rendering pressure caused by texture mapping.

[0005] With respect to the above-mentioned problems existing in the related technologies, no effective solutions have been found so far. Summary of the invention

[0006] The embodiments of the present invention provide a material rendering method and device, a storage medium, and an electronic device.

[0007] According to one embodiment of the present invention, a material rendering method is provided, comprising: selecting an initial normal group to be edited according to a structural trend of a target model, wherein the initial normal group includes normal information of multiple target model vertices; editing the initial normal group based on a specified axis of a specified coordinate system to obtain an intermediate normal group; converting the intermediate normal group to obtain a target normal group; converting the normal information of the target model into vertex color information based on the target normal group, wherein the vertex color information is used to store the normal information of the target normal group; and rendering the stylized material of the target model using the vertex color information.

[0008] Optionally, the intermediate normal group is transformed to obtain a target normal group, including: constructing a custom sphere and locating the center of the custom sphere; for each target model vertex of multiple target model vertices, calculating the normalized vector of the target model vertex and the center of the sphere; converting the normalized vector into a normalized normal, and interpolating the normalized normal and the corresponding normal in the intermediate normal group according to a preset ratio to obtain a first target normal group.

[0009] Optionally, the intermediate normal group is transformed to obtain a target normal group, including: for each target model vertex of multiple target model vertices, diffusing with the target model vertex as the center, and selecting adjacent vertices within the diffusion area; accumulating the normal information of the adjacent vertices and the normal information of the corresponding target model vertex in the intermediate normal group to obtain a second target normal group.

[0010] Optionally, the intermediate normal group is transformed to obtain a target normal group, including: determining a first transformation model, nesting the target model and the first transformation model in the same coordinate origin; for each target model vertex of the target model, traversing each vertex of the first transformation model, and calculating the first vertex distance between the current vertex and the target model vertex; selecting the normal information of the specified vertex closest to the first vertex to overwrite the normal information of the corresponding target model vertex in the intermediate normal group, to obtain a third target normal group.

[0011] Optionally, converting the normal information of the target model into vertex color information based on the target normal group includes: converting the normal information in the target normal group into vertex color information of the target model; determining a second conversion model, using the vertex color information of the second conversion model to overwrite the vertex color information of the target model, and converting the channel information of the overwritten vertex color information into model UV information.

[0012] Optionally, using the vertex color information of the second transformation model to overwrite the vertex color information of the target model includes: nesting the target model and the second transformation model in the same coordinate origin; for each target model vertex of the target model, traversing each vertex of the second transformation model, and calculating the second vertex distance between the current vertex and the target model vertex; selecting the vertex color information of the specified vertex closest to the second vertex to overwrite the vertex color information of the corresponding target model vertex.

[0013] Optionally, using the vertex color information to render the stylized material of the target model includes: importing the target model in a physical engine; converting the vertex color information into tangent space normals; and rendering the target model in the physical engine based on the tangent space normals to generate the stylized material of the target model.

[0014] Optionally, the method also includes: for each target model vertex of the target model, calculating the average normal value of all triangular faces connected to the target model vertex; determining the average normal value as a smooth normal of the corresponding target model vertex; and storing the vertex color information and the smooth normal in the vertex attributes of the target model.

[0015] Optionally, after storing the vertex color information and the smooth normals in the vertex attributes of the target model, the method further includes: using the vertex color information to render the stroke and character lighting of the target model to generate stylized light and shadow of the target model, and using the smooth normals to render the lighting model to generate smooth light and shadow of the target model.

[0016] Optionally, after converting the intermediate normal group to obtain a target normal group, the method further includes: generating a normal text using a group normal identifier and the target normal group; and storing the normal text.

[0017] According to another embodiment of the present invention, a material rendering device is provided, comprising: a selection module, used to select an initial normal group to be edited according to the structural trend of a target model, wherein the initial normal group includes normal information of multiple target model vertices; an editing module, used to edit the initial normal group based on a specified axis of a specified coordinate system to obtain an intermediate normal group; a first conversion module, used to convert the intermediate normal group to obtain a target normal group; a second conversion module, used to convert the normal information of the target model into vertex color information based on the target normal group, wherein the vertex color information is used to store the normal information of the target normal group; and a rendering module, used to render the stylized material of the target model using the vertex color information.

[0018] Optionally, the first conversion module includes: a positioning unit, used to construct a custom sphere and locate the center of the custom sphere; a calculation unit, used to calculate the normalized vector of the target model vertex and the center of the sphere for each target model vertex of multiple target model vertices; an interpolation unit, used to convert the normalized vector into a normalized normal, and interpolate the normalized normal and the corresponding normal in the intermediate normal group according to a preset ratio to obtain a first target normal group.

[0019] Optionally, the first conversion module includes: a selection unit, used to diffuse each target model vertex of multiple target model vertices with the target model vertex as the center, and select adjacent vertices within the diffusion area; an accumulation unit, used to accumulate the normal information of the adjacent vertices and the normal information of the corresponding target model vertex in the intermediate normal group to obtain a second target normal group.

[0020] Optionally, the first conversion module includes: a nesting unit, used to determine a first conversion model, and nest the target model and the first conversion model at the same coordinate origin; a calculation unit, used to traverse each vertex of the first conversion model for each target model vertex of the target model, and calculate the first vertex distance between the current vertex and the target model vertex; a covering unit, used to select the normal information of a specified vertex closest to the first vertex to cover the normal information of the corresponding target model vertex in the intermediate normal group, so as to obtain a third target normal group.

[0021] Optionally, the second conversion module includes: a conversion unit, used to convert the normal information in the target normal group into vertex color information of the target model; a processing unit, used to determine a second conversion model, use the vertex color information of the second conversion model to overwrite the vertex color information of the target model, and convert the channel information of the overwritten vertex color information into model UV information.

[0022] Optionally, the processing unit includes: a nesting subunit, used to nest the target model and the second transformation model in the same coordinate origin; a calculation subunit, used to traverse each vertex of the second transformation model for each target model vertex of the target model, and calculate the second vertex distance between the current vertex and the target model vertex; and an overwriting subunit, used to select the vertex color information of a specified vertex that is closest to the second vertex to overwrite the vertex color information of the corresponding target model vertex.

[0023] Optionally, the rendering module includes: an import module, used to import the target model in the physical engine; a conversion module, used to convert the vertex color information into tangent space normals; and a rendering module, used to render the target model in the physical engine based on the tangent space normals to generate a stylized material for the target model.

[0024] Optionally, the device also includes: a calculation module, used to calculate, for each target model vertex of the target model, the average normal value of all triangular faces connected to the target model vertex; a determination module, used to determine the average normal value as the smooth normal of the corresponding target model vertex; and a storage module, used to store the vertex color information and the smooth normal in the vertex attributes of the target model.

[0025] Optionally, the device also includes: a first generation module, which is used to render the stroke and character lighting of the target model using the vertex color information to generate stylized light and shadow of the target model after the storage module stores the vertex color information and the smooth normal in the vertex attributes of the target model, and use the smooth normal to render the lighting model to generate smooth light and shadow of the target model.

[0026] Optionally, the device also includes: a second generation module, used to generate normal text using the group normal identifier and the target normal group after the first conversion module converts the intermediate normal group to obtain a target normal group; and a storage module, used to store the normal text.

[0027] According to yet another embodiment of the present invention, a storage medium is provided, in which a computer program is stored, wherein the computer program is configured to execute the steps of any one of the above method embodiments when running.

[0028] According to yet another embodiment of the present invention, there is provided an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.

[0029] Through the present invention, an initial normal group to be edited is selected according to the structural trend of the target model, wherein the initial normal group includes normal information of multiple target model vertices, the initial normal group is edited based on a specified axis of a specified coordinate system to obtain an intermediate normal group, the intermediate normal group is converted to obtain a target normal group, and the normal information of the target model is converted into vertex color information based on the target normal group, wherein the vertex color information is used to store the normal information of the target normal group, and the stylized material of the target model is rendered using the vertex color information. The normals are grouped and then converted to convert the normal information, and the technical problem that the related technology cannot perform stylized light and shadow rendering on the model is solved, and the requirements of game manufacturers and players for extremely stylized rendering effects can be met. At the same time, the storage space consumption and rendering consumption caused by the normal map are reduced, and the editing efficiency of the normal is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0031] Figure 1 It is a hardware structure block diagram of a material rendering computer according to an embodiment of the present invention;

[0032] Figure 2 is a schematic flow chart of a material rendering method according to an embodiment of the present invention;

[0033] Figure 3 is a schematic diagram of a spherical normal conversion method according to an embodiment of the present invention;

[0034] Figure 4 is a schematic diagram of a normal line smoothly converted according to an embodiment of the present invention;

[0035] Figure 5 is a schematic diagram of normal transcription according to an embodiment of the present invention;

[0036] Figure 6 is a complete flow chart of an embodiment of the present invention;

[0037] Figure 7 2 is a schematic diagram for comparing the effects of the embodiments of the present invention;

[0038] Figure 8 is a structural block diagram of a material rendering device according to an embodiment of the present invention;

[0039] Fig. 9 It is a structural diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0040] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only embodiments of a part of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work should fall within the scope of protection of the present application. It should be noted that the embodiments in the present application and the features in the embodiments can be combined with each other without conflict.

[0041] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, product or device comprising 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.

[0042] Example 1

[0043] The method embodiment provided in the first embodiment of the present application can be executed in a mobile phone, tablet, server, computer or similar electronic terminal. Taking running on a computer as an example, Figure 1 1 is a hardware structure block diagram of a material rendering computer according to an embodiment of the present invention. Figure 1 As shown, the computer may include one or more ( Figure 1Only one is shown in the figure) a processor 102 (the processor 102 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Optionally, the computer may also include a transmission device 106 and an input / output device 108 for communication functions. It can be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above-mentioned computer. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0044] The memory 104 can be used to store computer programs, for example, software programs and modules of application software, such as a computer program corresponding to a material rendering method in an embodiment of the present invention. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, to implement the above method. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor 102, and these remote memories may be connected to the computer via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof. In this embodiment, the processor 104 is used to respond to human-computer interaction instructions and game strategies, and control the target virtual character to perform specified operations to complete the game task. The memory 104 is used to store program scripts, configuration information, attribute information of virtual characters, etc. of electronic games.

[0045] The transmission device 106 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computer. In one example, the transmission device 106 includes a network adapter (Network Interface Controller, referred to as NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0046] Optionally, the input-output device 108 further includes a human-computer interaction screen for obtaining human-computer interaction instructions through a human-computer interaction interface and for presenting images in a virtual scene;

[0047] In this embodiment, a material rendering method is provided. Figure 2is a flow chart of a material rendering method according to an embodiment of the present invention, such as Figure 2 As shown, the process includes the following steps:

[0048] Step S202, selecting an initial normal line group to be edited according to the structural trend of the target model, wherein the initial normal line group includes normal line information of multiple vertices of the target model;

[0049] Optionally, the target model may be a three-dimensional model of game characters, scene objects and other elements in the virtual scene.

[0050] Optionally, the normal information of this embodiment is the triangle normal Normal, which represents the three-dimensional vector information of the direction of the current triangle, is stored in the vertex attributes, and can be float3 according to the accuracy requirements.

[0051] Step S204, editing the initial normal line group based on the specified axis of the specified coordinate system to obtain an intermediate normal line group;

[0052] In this embodiment, the specified coordinate system may be a world coordinate system, a coordinate system where the target model itself is located, and the specified coordinate system may be an X / Y / Z axis.

[0053] Step S206, converting the intermediate normal line group to obtain a target normal line group;

[0054] The normal group conversion in this embodiment can be editing and conversion methods such as normal precise offset, spherical normal, smooth normal, normal copy between models, etc., which are adapted and selected according to the actual light and shadow rendering effect requirements.

[0055] Step S208, converting the normal information of the target model into vertex color information based on the target normal group, wherein the vertex color information is used to store the normal information of the target normal group;

[0056] In this embodiment, vertex color information is used to store normal information of the target normal group, which can solve the storage space consumption and rendering consumption caused by storing normal information through normal maps, and improve the utilization rate of hardware and rendering resources.

[0057] Step S210: using vertex color information to render the stylized material of the target model.

[0058] Through the above steps, the initial normal group to be edited is selected according to the structural trend of the target model, wherein the initial normal group includes normal information of multiple target model vertices, the initial normal group is edited based on the specified axis of the specified coordinate system to obtain an intermediate normal group, the intermediate normal group is converted to obtain a target normal group, and the normal information of the target model is converted into vertex color information based on the target normal group, wherein the vertex color information is used to store the normal information of the target normal group, and the stylized material of the target model is rendered using the vertex color information. The normals are grouped and then converted to convert the normal information, and the technical problem that the related technology cannot perform stylized light and shadow rendering on the model is solved, which can meet the requirements of game manufacturers and players for extremely stylized rendering effects, while reducing the storage space consumption and rendering consumption caused by normal maps, and improving the editing efficiency of normals.

[0059] In this embodiment, the intermediate normal group is converted, including precise offset of the intermediate normal group, spherical normals, smooth normals, normal copying between models, etc., which are explained and illustrated here through different implementation methods.

[0060] In one implementation of the present embodiment, the intermediate normal group is transformed to obtain a target normal group, including: constructing a custom sphere and locating the center of the custom sphere; for each target model vertex of multiple target model vertices, calculating the normalized vector of the target model vertex and the center of the sphere; converting the normalized vector into a normalized normal, and interpolating the normalized normal and the corresponding normal in the intermediate normal group according to a preset ratio to obtain a first target normal group.

[0061] This implementation adopts the spherical normal conversion method, by constructing a custom spherical center position to calculate the normalized vector of the model vertex and the spherical center, as the normal information and the original normal are interpolated according to the "percentage" to obtain the "spherical" normal information. It can be used for the spherical object's surface-changing appendages, shells, etc. to perform spherical normal conversion. Figure 3 Schematic diagram of spherical normal conversion adopted in an embodiment of the present invention.

[0062] In one implementation of the present embodiment, the intermediate normal group is transformed to obtain a target normal group, including: for each target model vertex of multiple target model vertices, diffusing with the target model vertex as the center, and selecting adjacent vertices within the diffusion area; accumulating the normal information of the adjacent vertices and the normal information of the corresponding target model vertex in the intermediate normal group to obtain a second target normal group.

[0063] This implementation adopts a smooth normal conversion method to diffuse and select the normal information of the surrounding vertices of the selected vertex and accumulate it, and finally obtain normalized normal information, which covers the original selected vertex normal to achieve the effect of smooth normal. In an example of cumulative averaging, the normal of the target model vertex to be adjusted is normal_ori, and the surrounding normal of the adjacent vertex is: normalArea[5]. The following algorithm is used for cumulative averaging to obtain the second target normal group.

[0064]

[0065] Figure 4 It is a schematic diagram of a smooth conversion of normals according to an embodiment of the present invention, in which normals having a large angle with surrounding normals are averaged with surrounding normals to weaken the turning point of light and shadow changes.

[0066] In one implementation of the present embodiment, the intermediate normal group is transformed to obtain a target normal group, including: determining a first transformation model, nesting the target model and the first transformation model in the same coordinate origin; for each target model vertex of the target model, traversing each vertex of the first transformation model, and calculating the first vertex distance between the current vertex and the target model vertex; selecting the normal information of the specified vertex closest to the first vertex to overwrite the normal information of the corresponding target model vertex in the intermediate normal group, to obtain a third target normal group.

[0067] This implementation adopts a conversion method of normal transcription: the target model that needs to transcribe normals is used as the "source", and the first converted model to be transcribed is used as the "destination". The two models are placed under the same coordinate origin, and all vertex positions of the "source" model are traversed, and then the vertex position information of the "destination" model is traversed and the nearest vertex is calculated. Finally, the normal of this "destination" vertex covers the corresponding "source" vertex normal.

[0068] Figure 5 It is a schematic diagram of normal transcription in an embodiment of the present invention. The first conversion model is model A (cylindrical model of the periphery of the kettle), the target model is model B (kettle model), and the normal of model A is transcribed to model B.

[0069] In some other implementations, the intermediate normal group may be transformed by offsetting, such as offsetting by accumulation, offsetting by multiplication, offsetting by the model's own coordinate system or the world coordinate system, and so on.

[0070] In this embodiment, converting the normal information of the target model into vertex color information based on the target normal group includes:

[0071] S11, converting the normal information in the target normal group into vertex color information of the target model;

[0072] Convert normalized normal information into model vertex color information, and finally convert vertex color into tangent space normal for rendering.

[0073] S12, determining a second conversion model, using vertex color information of the second conversion model to cover vertex color information of the target model, and converting channel information of the covered vertex color information into model UV information.

[0074] Converting the channel information of the model vertex color into the model UV information, and converting any RGB channel of the vertex color into UV information, can achieve the separation of drawing vertex color information and storing vertex color information, break the limitation of the number of vertex color channels, and reduce the storage and rendering pressure caused by relying on normal maps to store normal information.

[0075] In some examples, using vertex color information of the second transformation model to overwrite vertex color information of the target model includes: nesting the target model and the second transformation model in the same coordinate origin; for each target model vertex of the target model, traversing each vertex of the second transformation model, and calculating the second vertex distance between the current vertex and the target model vertex; selecting the vertex color information of a specified vertex that is closest to the second vertex to overwrite the vertex color information of the corresponding target model vertex.

[0076] In this example, when the vertex color information between models is copied, the model whose vertex color needs to be copied (target model) is the "source", and the model whose vertex color is copied (second conversion model) is the "destination". The two models are placed under the same coordinate origin, and all vertex positions of the "source" model are traversed, and then the vertex position information of the "destination" model is traversed to calculate the nearest vertex, and finally the vertex color of this "destination" vertex is overwritten with the corresponding "source" vertex color. Finally, any RGB channel of the vertex color is converted to UV information.

[0077] In one implementation of this embodiment, using vertex color information to render a stylized material of a target model includes: importing the target model into a physical engine; converting the vertex color information into tangent space normals; rendering the target model in the physical engine based on the tangent space normals to generate a stylized material for the target model.

[0078] In one implementation of this embodiment, it includes: for each target model vertex of the target model, calculating the average normal value of all triangles connected to the target model vertex; determining the average normal value as the smooth normal of the corresponding target model vertex; and storing vertex color information and smooth normal in the vertex attributes of the target model.

[0079] Based on this implementation, after storing vertex color information and smooth normals in the vertex attributes of the target model, it also includes: using vertex color information to render the target model's stroke and character lighting to generate stylized light and shadow of the target model, and using smooth normals to render the lighting model to generate smooth light and shadow of the target model.

[0080] Optionally, after converting the intermediate normal group to obtain the target normal group, the method further includes: generating normal text using the group normal identifier and the target normal group; and storing the normal text.

[0081] The grouped vertex normal IDs are stored in text format. When they need to be used again, the text is loaded to obtain the corresponding group normal ID for re-editing and multiple calls.

[0082] Figure 6 It is a complete flow chart of an embodiment of the present invention, including: grouping normals, storing normal groups, editing and converting the grouped normals, converting the normals into vertex color information and storing them when the expected effect is met, and rendering them in the game engine for use.

[0083] The above process of this embodiment can be encapsulated as a model mesh normal editing tool, which includes: a normal editing module, a vertex color editing module, and a material module. Among them, the normal editing module is used to achieve precise offset, spherical normal, smooth normal, normal copy between models, and load model normal information by group storage to solve the normal information required for stylized light and shadow; the vertex color editing module is used to achieve vertex color copy between models, normal and vertex color conversion, and vertex color RGB arbitrary channel conversion to UV information to solve the storage and rendering pressure caused by relying on normal map to store normal information; the material module is used to display the final effect of normal editing stylized material in real time, cooperate with the real-time display of the light and shadow effect after model normal editing, automatically load the project Shader and set parameters, use the edited normal to calculate light and shadow, and observe the rendering results in real time.

[0084] This embodiment adjusts the normal editing process of the model making process according to the rules of stylized light and shadow rendering such as cartoons, provides efficient editing tools and storage methods, and achieves production results and efficiency that 3D artists cannot achieve with existing tools. The final model stores two sets of normal information for stylized light and shadow and smooth stroke effects. The final model mesh vertex attributes store two sets of normal information, one set is the normals (vertex color information) edited by the normal tool, and one set is the normals after unified smooth group (smooth normals) stored in the vertex color attributes. The smooth normal is the normal after unified smooth group (the model vertex normal is the average of the normals of all connected triangles), which is used for the normals of the back side of the model to extrude and draw the stroke, and finally obtains a stroke effect with uniform stroke thickness and no bifurcation.

[0085] Figure 7 It is a schematic diagram for comparing the effects of an embodiment of the present invention. The left side is the rendering effect of the target normal group, and the right side is the rendering effect of the initial normal group. For area 1, the left side uses vertex colors to convert normals and then performs edge light calculation, and the transition is uniform and continuous, while the right side stores an uneven and discontinuous scene of edge light; for area 2, the vertex colors are converted to normals and then stroked, and the thickness is uniform and the effect is good, while the normal stroke on the right has a forked and uneven scene.

[0086] The solution of this embodiment can meet the pursuit of game developers and game players for the ultimate cartoon-style rendering effect and reduce the rendering and production consumption caused by normal maps.

[0087] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0088] Example 2

[0089] In this embodiment, a material rendering device is also provided to implement the above-mentioned embodiments and preferred implementation modes, which have been described and will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.

[0090] Figure 8 is a structural block diagram of a material rendering device according to an embodiment of the present invention, such as Figure 8 As shown, the device includes: a selection module 80, an editing module 82, a first conversion module 84, a second conversion module 86, and a rendering module 88, wherein:

[0091] A selection module 80, for selecting an initial normal line group to be edited according to the structural trend of the target model, wherein the initial normal line group includes normal line information of multiple vertices of the target model;

[0092] An editing module 82, configured to edit the initial normal line group based on a specified axial direction of a specified coordinate system to obtain an intermediate normal line group;

[0093] A first conversion module 84, configured to convert the intermediate normal line group to obtain a target normal line group;

[0094] A second conversion module 86, configured to convert the normal information of the target model into vertex color information based on the target normal group, wherein the vertex color information is used to store the normal information of the target normal group;

[0095] The rendering module 88 is used to render the stylized material of the target model using the vertex color information.

[0096] Optionally, the first conversion module includes: a positioning unit, used to construct a custom sphere and locate the center of the custom sphere; a calculation unit, used to calculate the normalized vector of the target model vertex and the center of the sphere for each target model vertex of multiple target model vertices; an interpolation unit, used to convert the normalized vector into a normalized normal, and interpolate the normalized normal and the corresponding normal in the intermediate normal group according to a preset ratio to obtain a first target normal group.

[0097] Optionally, the first conversion module includes: a selection unit, used to diffuse each target model vertex of multiple target model vertices with the target model vertex as the center, and select adjacent vertices within the diffusion area; an accumulation unit, used to accumulate the normal information of the adjacent vertices and the normal information of the corresponding target model vertex in the intermediate normal group to obtain a second target normal group.

[0098] Optionally, the first conversion module includes: a nesting unit, used to determine a first conversion model, and nest the target model and the first conversion model at the same coordinate origin; a calculation unit, used to traverse each vertex of the first conversion model for each target model vertex of the target model, and calculate the first vertex distance between the current vertex and the target model vertex; a covering unit, used to select the normal information of a specified vertex closest to the first vertex to cover the normal information of the corresponding target model vertex in the intermediate normal group, so as to obtain a third target normal group.

[0099] Optionally, the second conversion module includes: a conversion unit, used to convert the normal information in the target normal group into vertex color information of the target model; a processing unit, used to determine a second conversion model, use the vertex color information of the second conversion model to overwrite the vertex color information of the target model, and convert the channel information of the overwritten vertex color information into model UV information.

[0100] Optionally, the processing unit includes: a nesting subunit, used to nest the target model and the second transformation model in the same coordinate origin; a calculation subunit, used to traverse each vertex of the second transformation model for each target model vertex of the target model, and calculate the second vertex distance between the current vertex and the target model vertex; and an overwriting subunit, used to select the vertex color information of a specified vertex that is closest to the second vertex to overwrite the vertex color information of the corresponding target model vertex.

[0101] Optionally, the rendering module includes: an import module, used to import the target model in the physical engine; a conversion module, used to convert the vertex color information into tangent space normals; and a rendering module, used to render the target model in the physical engine based on the tangent space normals to generate a stylized material for the target model.

[0102] Optionally, the device also includes: a calculation module, used to calculate, for each target model vertex of the target model, the average normal value of all triangular faces connected to the target model vertex; a determination module, used to determine the average normal value as the smooth normal of the corresponding target model vertex; and a storage module, used to store the vertex color information and the smooth normal in the vertex attributes of the target model.

[0103] Optionally, the device also includes: a first generation module, which is used to render the stroke and character lighting of the target model using the vertex color information to generate stylized light and shadow of the target model after the storage module stores the vertex color information and the smooth normal in the vertex attributes of the target model, and use the smooth normal to render the lighting model to generate smooth light and shadow of the target model.

[0104] Optionally, the device also includes: a second generation module, used to generate normal text using the group normal identifier and the target normal group after the first conversion module converts the intermediate normal group to obtain a target normal group; and a storage module, used to store the normal text.

[0105] It should be noted that the above modules can be implemented by software or hardware. For the latter, it can be implemented in the following ways, but not limited to: the above modules are all located in the same processor; or the above modules are located in different processors in any combination.

[0106] Example 3

[0107] The present application also provides an electronic device, Fig. 9 is a structural diagram of an electronic device according to an embodiment of the present invention, such as Fig. 9As shown, it includes a processor 91, a communication interface 92, a memory 93 and a communication bus 94, wherein the processor 91, the communication interface 92, and the memory 93 communicate with each other through the communication bus 94, and the memory 93 is used to store computer programs;

[0108] The processor 91 is used to execute the program stored in the memory 93 to implement the following steps: select an initial normal group to be edited according to the structural trend of the target model, wherein the initial normal group includes normal information of multiple target model vertices; edit the initial normal group based on a specified axis of a specified coordinate system to obtain an intermediate normal group; transform the intermediate normal group to obtain a target normal group; transform the normal information of the target model into vertex color information based on the target normal group, wherein the vertex color information is used to store the normal information of the target normal group; and render the stylized material of the target model using the vertex color information.

[0109] Optionally, the intermediate normal group is transformed to obtain a target normal group, including: constructing a custom sphere and locating the center of the custom sphere; for each target model vertex of multiple target model vertices, calculating the normalized vector of the target model vertex and the center of the sphere; converting the normalized vector into a normalized normal, and interpolating the normalized normal and the corresponding normal in the intermediate normal group according to a preset ratio to obtain a first target normal group.

[0110] Optionally, the intermediate normal group is transformed to obtain a target normal group, including: for each target model vertex of multiple target model vertices, diffusing with the target model vertex as the center, and selecting adjacent vertices within the diffusion area; accumulating the normal information of the adjacent vertices and the normal information of the corresponding target model vertex in the intermediate normal group to obtain a second target normal group.

[0111] Optionally, the intermediate normal group is transformed to obtain a target normal group, including: determining a first transformation model, nesting the target model and the first transformation model in the same coordinate origin; for each target model vertex of the target model, traversing each vertex of the first transformation model, and calculating the first vertex distance between the current vertex and the target model vertex; selecting the normal information of the specified vertex closest to the first vertex to overwrite the normal information of the corresponding target model vertex in the intermediate normal group, to obtain a third target normal group.

[0112] Optionally, converting the normal information of the target model into vertex color information based on the target normal group includes: converting the normal information in the target normal group into vertex color information of the target model; determining a second conversion model, using the vertex color information of the second conversion model to overwrite the vertex color information of the target model, and converting the channel information of the overwritten vertex color information into model UV information.

[0113] Optionally, using the vertex color information of the second transformation model to overwrite the vertex color information of the target model includes: nesting the target model and the second transformation model in the same coordinate origin; for each target model vertex of the target model, traversing each vertex of the second transformation model, and calculating the second vertex distance between the current vertex and the target model vertex; selecting the vertex color information of the specified vertex closest to the second vertex to overwrite the vertex color information of the corresponding target model vertex.

[0114] Optionally, using the vertex color information to render the stylized material of the target model includes: importing the target model in a physical engine; converting the vertex color information into tangent space normals; and rendering the target model in the physical engine based on the tangent space normals to generate the stylized material of the target model.

[0115] Optionally, the method also includes: for each target model vertex of the target model, calculating the average normal value of all triangular faces connected to the target model vertex; determining the average normal value as a smooth normal of the corresponding target model vertex; and storing the vertex color information and the smooth normal in the vertex attributes of the target model.

[0116] Optionally, after storing the vertex color information and the smooth normals in the vertex attributes of the target model, the method further includes: using the vertex color information to render the stroke and character lighting of the target model to generate stylized light and shadow of the target model, and using the smooth normals to render the lighting model to generate smooth light and shadow of the target model.

[0117] Optionally, after converting the intermediate normal group to obtain a target normal group, the method further includes: generating a normal text using a group normal identifier and the target normal group; and storing the normal text.

[0118] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0119] The communication interface is used for communication between the above terminal and other devices.

[0120] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0121] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0122] In another embodiment provided in the present application, a computer-readable storage medium is also provided, in which instructions are stored. When the computer-readable storage medium is run on a computer, the computer executes the material rendering method described in any of the above embodiments.

[0123] In another embodiment provided by the present application, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the material rendering method described in any one of the above embodiments.

[0124] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.

[0125] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0126] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.

[0127] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0128] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0129] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0130] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk and other media that can store program codes.

[0131] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A material rendering method, characterized in that: include: Selecting an initial normal line group to be edited according to the structural trend of the target model, wherein the initial normal line group includes normal line information of multiple vertices of the target model; Edit the initial normal line group based on a specified axial direction of a specified coordinate system to obtain an intermediate normal line group; Converting the intermediate normal line group to obtain a target normal line group; Converting the normal information of the target model into vertex color information based on the target normal group, wherein the vertex color information is used to store the normal information of the target normal group; Rendering the stylized material of the target model using the vertex color information; Among them, converting the normal information of the target model into vertex color information based on the target normal group includes: converting the normal information in the target normal group into vertex color information of the target model; determining a second conversion model, using the vertex color information of the second conversion model to cover the vertex color information of the target model, and converting the channel information of the covered vertex color information into model UV information; wherein, using the vertex color information of the second conversion model to cover the vertex color information of the target model includes: nesting the target model and the second conversion model in the same coordinate origin; for each target model vertex of the target model, traversing each vertex of the second conversion model, and calculating the second vertex distance between the current vertex and the target model vertex; selecting the vertex color information of the specified vertex with the closest second vertex distance to cover the vertex color information of the corresponding target model vertex.

2. The method according to claim 1, characterized in that The intermediate normal group is converted to obtain a target normal group, including: Constructing a custom sphere and locating the center of the custom sphere; For each target model vertex of the plurality of target model vertices, calculating a normalized vector between the target model vertex and the sphere center; The normalized vector is converted into a normalized normal line, and the normalized normal line and the corresponding normal line in the intermediate normal line group are interpolated according to a preset ratio to obtain a first target normal line group.

3. The method according to claim 1, characterized in that: The intermediate normal group is converted to obtain a target normal group, including: For each target model vertex of the plurality of target model vertices, diffusion is performed with the target model vertex as the center, and adjacent vertices within the diffusion area are selected; The normal information of the adjacent vertices and the normal information of the corresponding target model vertices in the intermediate normal group are accumulated to obtain a second target normal group.

4. The method according to claim 1, characterized in that: The intermediate normal group is converted to obtain a target normal group, including: Determine a first conversion model, and nest the target model and the first conversion model at the same coordinate origin; For each target model vertex of the target model, traverse each vertex of the first conversion model, and calculate a first vertex distance between a current vertex and the target model vertex; The normal information of the designated vertex closest to the first vertex is selected to overwrite the normal information of the corresponding target model vertex in the intermediate normal group, so as to obtain a third target normal group.

5. The method according to claim 1, characterized in that Rendering the stylized material of the target model using the vertex color information includes: Importing the target model into a physics engine; Converting the vertex color information into a tangent space normal; The target model is rendered in the physics engine based on the tangent space normal to generate a stylized material of the target model.

6. The method according to claim 1, characterized in that The method further comprises: For each target model vertex of the target model, calculating the average normal value of all triangular faces connected to the target model vertex; Determine the normal average value as the smooth normal corresponding to the vertex of the target model; The vertex color information and the smooth normal are stored in vertex attributes of the target model.

7. The method according to claim 6, characterized in that After storing the vertex color information and the smooth normal in the vertex attributes of the target model, the method further comprises: The vertex color information is used to render the stroke and character light variation of the target model to generate stylized light and shadow of the target model, and the smooth normal is used to render the lighting model to generate smooth light and shadow of the target model.

8. The method according to claim 1, characterized in that After converting the intermediate normal line group to obtain the target normal line group, the method further includes: Generate normal text using the group normal identifier and the target normal group; Stores the normal text.

9. A material rendering device, characterized in that: include: A selection module, used for selecting an initial normal line group to be edited according to the structural trend of the target model, wherein the initial normal line group includes normal line information of multiple vertices of the target model; An editing module, used for editing the initial normal line group based on a specified axial direction of a specified coordinate system to obtain an intermediate normal line group; A first conversion module, used for converting the intermediate normal line group to obtain a target normal line group; A second conversion module, configured to convert the normal information of the target model into vertex color information based on the target normal group, wherein the vertex color information is used to store the normal information of the target normal group; A rendering module, used for rendering the stylized material of the target model using the vertex color information; Wherein, the second conversion module includes: a conversion unit, which is used to convert the normal information in the target normal group into the vertex color information of the target model; a processing unit, which is used to determine the second conversion model, use the vertex color information of the second conversion model to cover the vertex color information of the target model, and convert the channel information of the covered vertex color information into model UV information; wherein, the processing unit includes: a nesting subunit, which is used to nest the target model and the second conversion model in the same coordinate origin; a calculation subunit, which is used to traverse each vertex of the second conversion model for each target model vertex of the target model, and calculate the second vertex distance between the current vertex and the target model vertex; a covering subunit, which is used to select the vertex color information of the specified vertex with the closest second vertex distance to cover the vertex color information of the corresponding target model vertex.

10. A storage medium, characterized in that: The storage medium stores a computer program, wherein the computer program is configured to execute the method according to any one of claims 1 to 8 when executed.

11. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to run the computer program to perform the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Three-dimensional model rendering method and device, processor and terminal

    CN109903385A

  • Cartoon rendering undercut smoothing method

    CN110390709A

  • Model stroking processing method and device, computer equipment and readable storage medium

    CN111729322A

  • Deformable snowfield grid drawing method and device

    CN113808243A

  • Method for renfering of simulating illumination and terminal

    US20200184714A1