CN113936080A - Rendering method and device of virtual model, storage medium and electronic equipment - Google Patents

Rendering method and device of virtual model, storage medium and electronic equipment Download PDF

Info

Publication number
CN113936080A
CN113936080A CN202111124242.8A CN202111124242A CN113936080A CN 113936080 A CN113936080 A CN 113936080A CN 202111124242 A CN202111124242 A CN 202111124242A CN 113936080 A CN113936080 A CN 113936080A
Authority
CN
China
Prior art keywords
virtual model
normal
color
rendering
colors
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111124242.8A
Other languages
Chinese (zh)
Inventor
肖海龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Netease Hangzhou Network Co Ltd
Original Assignee
Netease Hangzhou Network Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Netease Hangzhou Network Co Ltd filed Critical Netease Hangzhou Network Co Ltd
Priority to CN202111124242.8A priority Critical patent/CN113936080A/en
Publication of CN113936080A publication Critical patent/CN113936080A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/60Generating or modifying game content before or while executing the game program, e.g. authoring tools specially adapted for game development or game-integrated level editor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/506Illumination models
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/55Radiosity
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F2300/00Features of games using an electronically generated display having two or more dimensions, e.g. on a television screen, showing representations related to the game
    • A63F2300/60Methods for processing data by generating or executing the game program
    • A63F2300/66Methods for processing data by generating or executing the game program for rendering three dimensional images

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Graphics (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Multimedia (AREA)
  • Image Generation (AREA)

Abstract

The invention discloses a rendering method and device of a virtual model, a storage medium and electronic equipment. Wherein, the method comprises the following steps: acquiring a normal map corresponding to the virtual model, wherein colors in the normal map are used for representing normal vectors of vertexes of the virtual model; determining a normal vector of the vertex based on the normal map; the virtual model is rendered based on the normal vectors of the vertices. The invention solves the technical problem of uneven shadow transition caused by adopting a cartoon rendering mode to render a virtual model in the prior art.

Description

Rendering method and device of virtual model, storage medium and electronic equipment
Technical Field
The invention relates to the technical field of computers, in particular to a rendering method and device of a virtual model, a storage medium and electronic equipment.
Background
At present, a cartoon rendering mode is adopted in part of games to render virtual models, original natural light and shadow transition can be compressed into a binarization effect, and the problem of uneven shadow transition of the rendered virtual models exists because the light and shadow transition effect depends on an illumination vector and a model vertex normal vector.
In view of the above problems, no effective solution has been proposed.
Disclosure of Invention
The embodiment of the invention provides a rendering method and device of a virtual model, a storage medium and electronic equipment, which are used for at least solving the technical problem of uneven shadow transition existing in the process of rendering the virtual model by adopting a cartoon rendering mode in the related technology.
According to an aspect of an embodiment of the present invention, there is provided a rendering method of a virtual model, including: acquiring a normal map corresponding to the virtual model, wherein colors in the normal map are used for representing normal vectors of vertexes of the virtual model; determining a normal vector of the vertex based on the normal map; the virtual model is rendered based on the normal vectors of the vertices.
Optionally, determining the normal vector of the vertex based on the normal map comprises: acquiring color values in the normal map; mapping the color value from a first preset interval to a second preset interval to obtain a mapped color value; a normal vector for the vertex is determined based on the mapped color values.
Optionally, the obtaining of the normal map corresponding to the virtual model includes: dividing the virtual model into a plurality of regions, and determining the colors of the plurality of regions; determining the color of a preset area on the virtual model, wherein the preset area comprises: highlight and shadow regions of the virtual model; and generating a normal map based on the colors of the plurality of areas and the color of the preset area.
Optionally, the colors of the plurality of regions are determined by colors in an angular color ring, wherein different colors in the angular color ring are used to characterize different normal directions.
Optionally, the color of the preset area is determined by a color in an angular color ring, wherein different colors in the angular color ring are used for representing different normal directions.
Optionally, the method further comprises: creating a semicircular ring, wherein different positions of the semicircular ring correspond to different normal vectors; and adding colors to the semicircular ring based on a preset corresponding relation to obtain an angle color ring, wherein the preset corresponding relation is used for representing the corresponding relation between different normal vectors and different colors.
Optionally, rendering the virtual model based on the normal vector of the vertex comprises: determining a gradient diffuse reflection coefficient of the virtual model based on the normal vector of the vertex; and rendering the virtual model based on the gradient diffuse reflection coefficient.
Optionally, determining the gradient diffuse reflection coefficient of the virtual model based on the normal vector of the vertex comprises: acquiring an illumination vector corresponding to the virtual model; performing dot product on the normal vector and the illumination vector of the vertex to obtain a diffuse reflection coefficient; and carrying out binarization processing on the diffuse reflection coefficient to obtain a gradient diffuse reflection coefficient.
Optionally, rendering the virtual model based on the gradient diffuse reflection coefficient includes: obtaining a color map of the virtual model; mixing the color map and the gradient diffuse reflection coefficient to obtain a mixed color; rendering the virtual model based on the mixed colors.
According to another aspect of the embodiments of the present invention, there is also provided a rendering apparatus of a virtual model, including: the mapping obtaining module is used for obtaining a normal mapping corresponding to the virtual model, wherein colors in the normal mapping are used for representing normal vectors of vertexes on the virtual model; a normal determination module for determining a normal vector of the vertex based on the normal map; and the role rendering module is used for rendering the virtual model based on the normal vector of the vertex.
Optionally, the normal determination module includes: the color acquisition unit is used for acquiring color values in the normal map; the color mapping unit is used for mapping the color value from a first preset interval to a second preset interval to obtain a mapped color value; and a normal determination unit for determining a normal vector of the vertex based on the mapped color values.
Optionally, the map obtaining module includes: a first color determination unit for dividing the virtual model into a plurality of regions and determining colors of the plurality of regions; a second color determination unit, configured to determine a color of a preset region on the virtual model, where the preset region includes: highlight and shadow regions of the virtual model; and the map generating unit is used for generating the normal map based on the colors of the plurality of areas and the color of the preset area.
Optionally, the first color determination unit is further configured to determine the colors of the plurality of regions by colors in an angular color ring, wherein different colors in the angular color ring are used to characterize different normal directions.
Optionally, the second color determination unit is further configured to determine the color of the preset region by using a color in an angle color ring, where different colors in the angle color ring are used to represent different normal directions.
Optionally, the apparatus further comprises: the circular ring creating module is used for creating a semicircular ring, wherein different positions of the semicircular ring correspond to different normal vectors; and the color circle creating module is used for adding colors to the semicircular ring based on a preset corresponding relation to obtain an angle color circle, wherein the preset corresponding relation is used for representing the corresponding relation between different normal vectors and different colors.
Optionally, the character rendering module includes: a coefficient determining unit for determining a gradient diffuse reflection coefficient of the virtual model based on the normal vector of the vertex; and the role rendering unit is used for rendering the virtual model based on the gradient diffuse reflection coefficient.
Optionally, the coefficient determination unit is further configured to: acquiring an illumination vector corresponding to the virtual model; performing dot product on the normal vector and the illumination vector of the vertex to obtain a diffuse reflection coefficient; and carrying out binarization processing on the diffuse reflection coefficient to obtain a gradient diffuse reflection coefficient.
Optionally, the character rendering unit is further configured to: obtaining a color map of the virtual model; mixing the color map and the gradient diffuse reflection coefficient to obtain a mixed color; rendering the virtual model based on the mixed colors.
According to another aspect of the embodiments of the present invention, there is also provided a computer-readable storage medium, where the computer-readable storage medium includes a stored program, and when the program runs, the apparatus where the computer-readable storage medium is located is controlled to execute the rendering method of the virtual model in the above embodiments.
According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including: the virtual model rendering method includes a processor and a memory, where the processor is configured to execute a program stored in the memory, and the program executes the virtual model rendering method in the above embodiments.
In the embodiment of the invention, the normal map corresponding to the virtual model is obtained, the normal vector of the vertex is determined based on the normal map, and then the virtual model is rendered based on the normal vector of the vertex, so that the purpose of cartoon rendering is realized. Compared with the prior art, the purpose of normal adjustment can be realized by changing the color value in the normal map, the normal vector of the vertex does not need to be manually adjusted, the wiring of the virtual model is not limited, the adjustment time of the normal vector is shortened, the time of the model stage is shortened, the manufacturing difficulty is reduced, the shadow effect of the virtual model is improved, and the technical problem that the shadow transition is uneven when the cartoon rendering mode is adopted to render the virtual model in the prior art is solved.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this application, illustrate embodiment(s) of the invention and together with the description serve to explain the invention without limiting the invention. In the drawings:
FIG. 1 is a schematic diagram of a cartoon rendering effect according to the prior art;
FIG. 2 is a flow chart of a method of rendering a virtual model according to an embodiment of the invention;
FIG. 3a is a diagram illustrating an alternative default normal vector for color according to an embodiment of the present invention;
FIG. 3b is a schematic illustration of an alternative color change after modification of the normal vector according to an embodiment of the invention;
FIG. 4 is a schematic diagram of an alternative color mapping relationship according to an embodiment of the invention;
FIG. 5 is a schematic diagram of alternative colors corresponding to different normal vectors according to an embodiment of the invention;
FIG. 6a is a schematic view of an alternative face according to an embodiment of the invention;
FIG. 6b is a schematic illustration of alternative different region colors of the face according to an embodiment of the invention;
FIG. 6c is a schematic illustration of an alternative facial normal map in accordance with an embodiment of the present invention;
FIG. 7 is a schematic diagram of an alternative setting of different colors for different regions of a face, according to an embodiment of the invention;
FIG. 8a is a schematic illustration of an alternative horizontally oriented angular color wheel in accordance with an embodiment of the present invention;
FIG. 8b is a schematic view of an alternative vertically oriented angular color wheel in accordance with embodiments of the present invention;
FIG. 9 is a diagram illustrating an alternative default normal vector for face rendering according to an embodiment of the present invention;
FIG. 10 is a schematic diagram of an alternative adjusted normal vector corresponding face rendering effect according to an embodiment of the invention;
fig. 11 is a schematic diagram of a rendering apparatus of a virtual model according to an embodiment of the present invention.
Detailed Description
In order to make the technical solutions of the present invention better understood, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
It should be noted that the terms "first," "second," and the like in the description and claims of the present invention and in the drawings described above are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used is interchangeable under appropriate circumstances such that the embodiments of the invention described herein are capable of operation in sequences other than those illustrated or described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
First, technical names appearing in the embodiments of the present invention are explained as follows:
3D model: mathematical representation of the surface of an object in three dimensions.
Vertex: a point in 3D space contains information about the normal vector, texture coordinates and other mesh attributes.
Dot product/dot: in mathematics, a dot product or scalar product is an algebraic operation, meaning a binary operation that accepts two vectors on a real number R and returns a real-valued scalar.
Normal line: the normal is a vector describing the surface and curvature of the three-dimensional model. In real-time rendering, illumination and shading calculations on the three-dimensional model require normal vectors. A normal vector is stored at each vertex (point) of the three-dimensional model, the vertex defining a position and the normal vector defining the direction of the surface.
Shader/Shader: one technique for rendering graphics is to customize the algorithm that the graphics card renders the picture with code, using the code to tell the GPU how to draw the vertices or pixel colors of the model to achieve the desired effect on the picture.
Stylized rendering/cartoon rendering: relying on real-time lighting, but simplifying and planarizing the illumination feedback to create a more legible effect. The inspiration of the coloring model comes mainly from animations, cartoons and cartoons. While cartoon colorations come in different styles, they have in common that surface detail in texture and coloration is reduced. The illumination-to-shadow is not a smooth intensity ramp, but a single or multiple hard cuts between the light and the shadow.
NPR (Non-Photocosmetic degradation): non-photorealistic rendering, namely simulating the styles of cartoons, illustrations, sketches, watercolors, oil paintings and the like in a three-dimensional scene by shaders
Lambert diffuse reflection model: the light source irradiates the surface of an object and then reflects the object in all directions to generate a diffuse reflection effect, so that the light source is an ideal diffuse reflection illumination model. The Lambert illumination model is implemented mainly by the value obtained by dot product of the illumination vector and the normal vector.
In order to solve the above problems, the following solutions are provided in the related art:
the core principle of the first scheme is that the orientation of each vertex is manually modified to ensure that the light shows good shadow effect at different angles, the shadow effect under the condition of not performing any normal line editing is shown in the left side of fig. 1, a plurality of unnatural shadow effects exist, the illumination effect after manually adjusting the normal line of the vertex of the face is shown in the right side of fig. 1, and the normal line shadow is very clean.
However, the above solution has the following disadvantages: the model wiring needs special treatment, the shape of a boundary line needs to be opened by wiring at a light and shadow boundary, and if the light and shadow shape is not good, the wiring needs to be readjusted, so that the requirement on art makers is high, and the making period is relatively long; smooth or sharp transition of light and shadow depends on the width and density of the wiring of the boundary line and the angle of a normal line, and if the adjustment is needed, the workload is very large; if wiring needs to be modified due to the model problem, the vertex ID is changed, and the whole normal modification is messy; viewing the engine effects requires re-exporting the modified normal model.
The core principle of the second scheme is that illumination information at different angles is drawn out and then is mixed into a shadow threshold map with a linear gradual change value of 0-1 by using a distance field mode, and then a shadow effect is generated according to different angles, so that the phenomenon that the light and shadow change is influenced by model wiring can be avoided, and no special requirement is required on the model wiring.
However, the above solution has the following disadvantages: the light shadow map is relatively complex to manufacture, and shadow information of a plurality of light angles needs to be calculated (or drawn) in advance; because the light and shadow image records the light and shadow information in one direction, when the light source direction rotates to the other side, the same image is used for left-right turning, so that only a left-right completely symmetrical structure can be realized; the light and shadow information is only influenced by the Y-axis rotation of the lamp light and is not influenced by the height of the lamp light.
In accordance with an embodiment of the present invention, there is provided a method of rendering a virtual model, it being noted that the steps illustrated in the flowchart of the figure may be performed in a computer system, such as a set of computer-executable instructions, and that while a logical order is illustrated in the flowchart, in some cases the steps illustrated or described may be performed in an order different than here.
Fig. 2 is a flowchart of a rendering method of a virtual model according to an embodiment of the present invention, as shown in fig. 2, the method includes the following steps:
step S202, a normal map corresponding to the virtual model is obtained, wherein colors in the normal map are used for representing normal vectors of vertexes of the virtual model.
The virtual model in the above steps may be a three-dimensional model that needs cartoon rendering currently, for example, in a game scene, the virtual model may be a character model operated by a player, or may be other models in a background, such as a stone, a tree, and the like, but is not limited thereto.
It should be noted that, a sphere is created, and an edit normals modifier is added, as shown in fig. 3a, normals in the default case of the model are uniformly distributed, where each line on the model represents a normal of a point, and colors on the model represent normal vectors, where red corresponds to the X direction, green corresponds to the Y direction, and blue corresponds to the Z direction. The findings are manually edited by EditNormals, a partial normal is selected and adjusted to the Z direction, as shown in FIG. 3b, the circled normal vector is adjusted to the Z direction, and the color on the model changes to blue, at which time the values of RGB are (0,0, 1). And if the adjustment is in the negative direction of Z, the values of RGB are negative numbers, wherein the values of RGB corresponding to the negative direction of Z are (0,0, -1), and the color on the model is changed into black.
As can be seen from the above analysis, the RGB values can be used to represent the normal vector, and therefore, in the embodiment of the present invention, the normal vector can be represented by a chartlet drawing method, so that the light and shadow transition of the virtual model can be controlled by color filtering, and the wider the transition range between two colors, the softer the light and shadow transition.
In step S204, the normal vector of the vertex is determined based on the normal map.
In the embodiment of the present invention, because different colors of the normal map may represent different normal vectors, after the obtained normal map, color values in the normal map may be directly read as normal vectors of vertices.
Step S206, rendering the virtual model based on the normal vector of the vertex.
In the embodiment of the invention, the cartoon rendering can be performed on the virtual model based on the determined normal vector, and the rendered virtual model is displayed in the interactive interface for the user to view.
Through the steps, the normal map corresponding to the virtual model is obtained, the normal vector of the vertex is determined based on the normal map, and then the virtual model is rendered based on the normal vector of the vertex, so that the purpose of cartoon rendering is achieved. Compared with the prior art, the purpose of normal adjustment can be realized by changing the color value in the normal map, the normal vector of the vertex does not need to be manually adjusted, the wiring of the virtual model is not limited, the adjustment time of the normal vector is shortened, the time of the model stage is shortened, the manufacturing difficulty is reduced, the shadow effect of the virtual model is improved, and the technical problem that the shadow transition is uneven when the cartoon rendering mode is adopted to render the virtual model in the prior art is solved.
Optionally, determining the normal vector of the vertex based on the normal map comprises: acquiring color values in the normal map; mapping the color value from a first preset interval to a second preset interval to obtain a mapped color value; a normal vector for the vertex is determined based on the mapped color values.
The first preset interval in the above step may be a value range of color values of three channels RGB in the normal map, for example, the first preset interval may be (0, 1); the second preset interval may be a value range of color values of the three RGB channels corresponding to the normal vector, for example, the second preset interval may be (0, 1).
It should be noted that the three RGB channels of the 8-bit map can only store 0-1 values, but cannot store negative values. Therefore, after the normal map is drawn, colors in the (0,1) range in the normal map can be mapped into the (-1,1) range. As shown in fig. 4, a value of 0.5 in the normal map may be mapped to 0, and the Shader code is as follows: nDirP 2-1, where e _ p is the value in the normal map and nDirP is the normal vector. The color values in different directions shown in fig. 5 can be obtained through the above correspondence, and the color values in different directions in the vertical direction and the color values in different directions in the horizontal direction can be specifically obtained.
Optionally, the obtaining of the normal map corresponding to the virtual model includes: dividing the virtual model into a plurality of regions, and determining the colors of the plurality of regions; determining the color of a preset area on the virtual model, wherein the preset area comprises: highlight and shadow regions of the virtual model; and generating a normal map based on the colors of the plurality of areas and the color of the preset area.
In the embodiment of the invention, different areas of the virtual model face different directions, so that the virtual model can be divided into different areas according to different directions, and different colors can be drawn for different areas. In order to improve the light and shadow effect of the virtual model to be rendered, it is necessary to draw highlight regions and shadow regions on the virtual model, and finally obtain a final normal map by summarizing the colors of the regions, the highlight region, and the shadow region.
For example, taking the facial normal map rendering as an example, for a face as shown in fig. 6a, the face may be roughly divided into 6 directions and rendered for each region, as shown in fig. 6b, and then the cheek triangle highlight region, the shadow under the nose, chin, lips, and the shadow region of the inner corner of the eye socket are rendered, and the resulting normal map is shown in fig. 6 c.
Optionally, the colors of the plurality of regions are determined by colors in an angular color ring, wherein different colors in the angular color ring are used to characterize different normal directions.
In the embodiment of the invention, the Skustance pointer software can be matched to directly draw the normal color based on the model.
In an embodiment of the invention, first, Emissive channel can be added under the Texture set-Channels panel of SubstancePainter (because hand-drawn Normal as defined in Shader is drawn on Emissive channel). As shown in fig. 7, the Face is roughly divided into 6 directions, the colors are selected to be drawn corresponding to the lower angle color ring, and then an empty map layer is added to be named as Face drawing Face normal map.
Optionally, the color of the preset area is determined by a color in an angular color ring, wherein different colors in the angular color ring are used for representing different normal directions.
In the inventive embodiment, another empty layer named as Detail is added first, then colors are selected for the angle color circle, and the cheek triangle highlight area, the shadow under the nose, chin and lips, and the shadow area of the inner corner of the eye socket are drawn.
Optionally, the method further comprises: creating a semicircular ring, wherein different positions of the semicircular ring correspond to different normal vectors; and adding colors to the semicircular ring based on a preset corresponding relation to obtain an angle color ring, wherein the preset corresponding relation is used for representing the corresponding relation between different normal vectors and different colors.
In the embodiment of the invention, a semicircular ring in the horizontal direction is created, the origin of the three-dimensional coordinate is taken as the center of a circle, the semicircular ring is created on the plane with Y being 0, and different positions on the semicircular ring correspond to different X, Z coordinates; and then, creating a semicircular ring in the vertical direction, and taking the origin of the three-dimensional coordinates as a center of a circle, and creating the semicircular ring on a plane with the X being 0, wherein different positions on the semicircular ring correspond to different Y, Z coordinates. Then, based on the corresponding relationship between different colors and the normal vector, Gradient Ramp is added to the material of the created semicircular ring and the corresponding color is set, as shown in fig. 8a and 8 b.
Optionally, rendering the virtual model based on the normal vector of the vertex comprises: determining a gradient diffuse reflection coefficient of the virtual model based on the normal vector of the vertex; and rendering the virtual model based on the gradient diffuse reflection coefficient.
In the embodiment of the present invention, for the purpose of implementing cartoon rendering, a normal vector of a vertex may be determined based on a normal map drawn by a user, and then a gradient diffuse reflection coefficient is determined based on the normal vector determined by the user, that is, lambert illumination is calculated, then binarization processing is performed on the lambert illumination to obtain a value that is not 0, that is, 1, that is, the gradient diffuse reflection coefficient stepNdotL is obtained, and finally rendering is performed based on the gradient diffuse reflection coefficient stepNdotL.
Optionally, determining the gradient diffuse reflection coefficient of the virtual model based on the normal vector of the vertex comprises: acquiring an illumination vector corresponding to the virtual model; performing dot product on the normal vector and the illumination vector of the vertex to obtain a diffuse reflection coefficient; and carrying out binarization processing on the diffuse reflection coefficient to obtain a gradient diffuse reflection coefficient.
In an alternative embodiment, the current illumination vector in the game scene may be obtained, and then the normal vector and the illumination vector are dot-product to obtain lambert illumination NdotL, and the Shader code is as follows: NdotL ═ dot (nDirP, lDir), where nDirP denotes a normal vector determined based on a user-drawn normal map, and lDir denotes an illumination vector. In addition, nDir may represent the normal vector of the model itself. The binarization process can be performed using step (x, y) function, and the Shader code is as follows: stepNdotL ═ step (0.5, NdotL).
For example, still taking a face normal map as an example, for a face as shown in FIG. 6a, when the Shader code is as follows: when ndot (nDir, lDir) is satisfied, the final rendered face is a normal vector that is still default to the model, as shown in fig. 9, and thus the shadow effect is problematic. When the Shader code is as follows: when ndot (nDirP, lDir) is used, the face finally rendered is as shown in fig. 10, and the shadow effect is not problematic because a normal vector determined based on a normal map drawn by the user is used.
Optionally, rendering the virtual model based on the gradient diffuse reflection coefficient includes: obtaining a color map of the virtual model; mixing the color map and the gradient diffuse reflection coefficient to obtain a mixed color; rendering the virtual model based on the mixed colors.
The color map in the above step may be the basic color of the virtual model, and the light and shadow effect is not superimposed.
In the embodiment of the present invention, in order to implement cartoon rendering, gradient diffuse reflection coefficient stepNdotL, color map c _ p, light color col, and shadow color shadow _ col need to be mixed and superimposed to obtain mixed color final, and then a virtual model may be rendered based on the mixed color, where the final Shader code is as follows: final (shadow _ col _ c _ p, stepNdotL).
Through the embodiment of the invention, the light and shadow effect adjusting part of the cartoon face can be completed in the SubstancePainter, so that the vertex normal vector is prevented from being adjusted in a vertex-by-vertex mode in a DCC tool, no limitation is imposed on model wiring, the time and the manufacturing difficulty of a model stage can be greatly reduced, and the adjusting time of the normal vector can be accelerated. Through the Shader written in the Substance Painter, a vertex normal vector chartlet can be drawn in the Substance Painter in real time, and the light and shadow effect of the adjusted normal can be directly checked, so that real-time adjustment is facilitated, and the engine is introduced until the effect is OK. This greatly reduces the frequency of switching back and forth between the DCC software and the engine.
According to the embodiment of the present invention, there is also provided a rendering apparatus for a virtual model, where the apparatus may perform the rendering method for a virtual model in the above embodiment, and a specific implementation scheme and an application scenario are the same as those in the above embodiment, and are not described herein again. And the apparatus may be built into an electronic device.
Fig. 11 is a schematic diagram of an apparatus for rendering a virtual model according to an embodiment of the present invention, as shown in fig. 11, the apparatus including:
and the map obtaining module 112 is configured to obtain a normal map corresponding to the virtual model, where colors in the normal map are used to represent normal vectors of vertices on the virtual model.
A normal determination module 114 for determining a normal vector of the vertex based on the normal map.
And a character rendering module 116, configured to render the virtual model based on the normal vector of the vertex.
Optionally, the normal determination module includes: the color acquisition unit is used for acquiring color values in the normal map; the color mapping unit is used for mapping the color value from a first preset interval to a second preset interval to obtain a mapped color value; and a normal determination unit for determining a normal vector of the vertex based on the mapped color values.
Optionally, the map obtaining module includes: a first color determination unit for dividing the virtual model into a plurality of regions and determining colors of the plurality of regions; a second color determination unit, configured to determine a color of a preset region on the virtual model, where the preset region includes: highlight and shadow regions of the virtual model; and the map generating unit is used for generating the normal map based on the colors of the plurality of areas and the color of the preset area.
Optionally, the first color determination unit is further configured to determine the colors of the plurality of regions by colors in an angular color ring, wherein different colors in the angular color ring are used to characterize different normal directions.
Optionally, the second color determination unit is further configured to determine the color of the preset region by using a color in an angle color ring, where different colors in the angle color ring are used to represent different normal directions.
Optionally, the apparatus further comprises: the circular ring creating module is used for creating a semicircular ring, wherein different positions of the semicircular ring correspond to different normal vectors; and the color circle creating module is used for adding colors to the semicircular ring based on a preset corresponding relation to obtain an angle color circle, wherein the preset corresponding relation is used for representing the corresponding relation between different normal vectors and different colors.
Optionally, the character rendering module includes: a coefficient determining unit for determining a gradient diffuse reflection coefficient of the virtual model based on the normal vector of the vertex; and the role rendering unit is used for rendering the virtual model based on the gradient diffuse reflection coefficient.
Optionally, the coefficient determination unit is further configured to: acquiring an illumination vector corresponding to the virtual model; performing dot product on the normal vector and the illumination vector of the vertex to obtain a diffuse reflection coefficient; and carrying out binarization processing on the diffuse reflection coefficient to obtain a gradient diffuse reflection coefficient.
Optionally, the character rendering unit is further configured to: obtaining a color map of the virtual model; mixing the color map and the gradient diffuse reflection coefficient to obtain a mixed color; rendering the virtual model based on the mixed colors.
According to an embodiment of the present invention, there is also provided a computer-readable storage medium, where the computer-readable storage medium includes a stored program, and when the program runs, the apparatus where the computer-readable storage medium is located is controlled to execute the rendering method of the virtual model in the foregoing embodiments.
According to an embodiment of the present invention, there is also provided an electronic device including: the virtual model rendering method includes a processor and a memory, where the processor is configured to execute a program stored in the memory, and the program executes the virtual model rendering method in the above embodiments.
In the above embodiments of the present invention, the descriptions of the respective embodiments have respective emphasis, and for parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
In the embodiments provided in the present application, it should be understood that the disclosed technology can be implemented in other ways. The above-described embodiments of the apparatus are merely illustrative, and for example, the division of the units may be a logical division, and in actual implementation, there may be another division, for example, multiple units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, units or modules, and may be in an electrical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a removable hard disk, a magnetic or optical disk, and other various media capable of storing program codes.
The foregoing is only a preferred embodiment of the present invention, and it should be noted that, for those skilled in the art, various modifications and decorations can be made without departing from the principle of the present invention, and these modifications and decorations should also be regarded as the protection scope of the present invention.

Claims (12)

1. A method of rendering a virtual model, the method comprising:
acquiring a normal map corresponding to the virtual model, wherein colors in the normal map are used for representing normal vectors of vertexes of the virtual model;
determining a normal vector for the vertex based on the normal map;
rendering the virtual model based on the normal vector of the vertex.
2. The method of claim 1, wherein determining the normal vector for the vertex based on the normal map comprises:
acquiring color values in the normal map;
mapping the color value from a first preset interval to a second preset interval to obtain a mapped color value;
determining a normal vector for the vertex based on the mapped color values.
3. The method of claim 1, wherein obtaining the normal map corresponding to the virtual model comprises:
dividing the virtual model into a plurality of regions and determining colors of the plurality of regions;
determining the color of a preset area on the virtual model, wherein the preset area comprises: highlight and shadow regions of the virtual model;
and generating the normal map based on the colors of the plurality of areas and the color of the preset area.
4. The method of claim 3, wherein the colors of the plurality of regions are determined by colors in an angular color ring, wherein different colors in the angular color ring are used to characterize different normal directions.
5. The method according to claim 3, wherein the color of the preset area is determined by colors in an angular color ring, wherein different colors in the angular color ring are used to characterize different normal directions.
6. The method according to claim 4 or 5, characterized in that the method further comprises:
creating a semicircular ring, wherein different positions of the semicircular ring correspond to different normal vectors;
and adding colors to the semicircular ring based on a preset corresponding relation to obtain the angle color ring, wherein the preset corresponding relation is used for representing the corresponding relation between different normal vectors and different colors.
7. The method of any of claims 1-5, wherein rendering the virtual model based on the normal vector of the vertex comprises:
determining a gradient diffuse reflection coefficient of the virtual model based on the normal vector of the vertex;
rendering the virtual model based on the gradient diffuse reflection coefficient.
8. The method of claim 7, wherein determining the gradient diffuse reflectance of the virtual model based on the normal vector of the vertex comprises:
acquiring an illumination vector corresponding to the virtual model;
performing dot product on the normal vector of the vertex and the illumination vector to obtain a diffuse reflection coefficient;
and carrying out binarization processing on the diffuse reflection coefficient to obtain the gradient diffuse reflection coefficient.
9. The method of claim 7, wherein rendering the virtual model based on the gradient diffuse reflectance comprises:
acquiring a color map of the virtual model;
mixing the color map and the gradient diffuse reflection coefficient to obtain a mixed color;
rendering the virtual model based on the blended color.
10. An apparatus for rendering a virtual model, the apparatus comprising:
the mapping obtaining module is used for obtaining a normal mapping corresponding to a virtual model, wherein colors in the normal mapping are used for representing normal vectors of vertexes on the virtual model;
a normal determination module for determining a normal vector of the vertex based on the normal map;
and the role rendering module is used for rendering the virtual model based on the normal vector of the vertex.
11. A computer-readable storage medium, comprising a stored program, wherein the program, when executed, controls an apparatus on which the computer-readable storage medium is located to perform the method for rendering a virtual model according to any one of claims 1 to 9.
12. An electronic device, comprising: a processor and a memory, the processor being configured to execute a program stored in the memory, wherein the program when executed performs the method of rendering a virtual model according to any one of claims 1 to 9.
CN202111124242.8A 2021-09-24 2021-09-24 Rendering method and device of virtual model, storage medium and electronic equipment Pending CN113936080A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111124242.8A CN113936080A (en) 2021-09-24 2021-09-24 Rendering method and device of virtual model, storage medium and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111124242.8A CN113936080A (en) 2021-09-24 2021-09-24 Rendering method and device of virtual model, storage medium and electronic equipment

Publications (1)

Publication Number Publication Date
CN113936080A true CN113936080A (en) 2022-01-14

Family

ID=79276846

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111124242.8A Pending CN113936080A (en) 2021-09-24 2021-09-24 Rendering method and device of virtual model, storage medium and electronic equipment

Country Status (1)

Country Link
CN (1) CN113936080A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115082607A (en) * 2022-05-26 2022-09-20 网易(杭州)网络有限公司 Virtual character hair rendering method and device, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115082607A (en) * 2022-05-26 2022-09-20 网易(杭州)网络有限公司 Virtual character hair rendering method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN112215934B (en) Game model rendering method and device, storage medium and electronic device
Decaudin Cartoon-looking rendering of 3D-scenes
US6417850B1 (en) Depth painting for 3-D rendering applications
Johnston Lumo: Illumination for cel animation
Lu et al. Illustrative interactive stipple rendering
JP4276178B2 (en) Method for digital rendering of skin or similar
US7239314B2 (en) Method for 2-D animation
CN111508052A (en) Rendering method and device of three-dimensional grid body
JP3626144B2 (en) Method and program for generating 2D image of cartoon expression from 3D object data
CN112316420A (en) Model rendering method, device, equipment and storage medium
US20030107572A1 (en) Method and apparatus for reducing the polygon count of a textured, three dimensional model of an object
CN111508053A (en) Model rendering method and device, electronic equipment and computer readable medium
CN113240783B (en) Stylized rendering method and device, readable storage medium and electronic equipment
Winnemöller NPR in the Wild
US20090033674A1 (en) Method and apparatus for graphically defining surface normal maps
CN113936080A (en) Rendering method and device of virtual model, storage medium and electronic equipment
CN114119847A (en) Graph processing method and device, computer equipment and storage medium
Gooch Interactive non-photorealistic technical illustration
US7180523B1 (en) Trimming surfaces
Lopez-Moreno et al. Non-photorealistic, depth-based image editing
CN113838155A (en) Method and device for generating material map and electronic equipment
US20030081849A1 (en) Method and system for creating seamless textured three dimensional models of objects
Martin et al. Rendering silhouettes with virtual lights
KR100900076B1 (en) Texturing System and Method for Border Lins is Natural
Pietrok Real-Time Stylized Rendering for Large-Scale 3D Scenes

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination