Method for rendering three-dimensional model into cartoon style
Through technical means such as normal expansion algorithm, manual drawing UV modification and color degradation, the problem of poor stroke, inner outline and shadow effects in 3D model rendering is solved, and comic stylized rendering with rich details and high artistry is achieved. Effect.
Patent Information
- Application Number
- CN202410839486.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-26
- Publication Date
- 2024-10-11
AI Technical Summary
The existing method of rendering 3D models in a comic style has deficiencies in stroke processing, inner outline clarity, shadow effects and edge light control, resulting in poor image effects and a lack of detail level and flexibility.
The normal expansion algorithm is used for outer outline processing, and the thickness of the outer stroke is dynamically adjusted; the clarity of the inner outline is improved through manual drawing and UV modification; the color is reduced to two levels for coloring processing; the edge light is During processing, mask mapping and normal correction are used to optimize the shadow effect.
It achieves detailed outer strokes and anti-aliasing effects for inner outlines, improves the smoothness of shadows and edge lights, makes the 3D model present a more realistic cartoon style, and enhances artistic expression.
Smart Images

Figure CN118762147A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the field of image processing, and in particular relates to a method for rendering a three-dimensional model into a cartoon style. Background Art
[0002] The method of rendering a 3D model in a comic style belongs to the non-photorealistic rendering (NPR) technology. This technology aims to make computer-generated images appear hand-painted. It is often used in 3D Japanese two-dimensional style mobile games or PC games to enhance the texture and artistic expression of the picture. Many existing plug-ins can achieve this function. Such plug-ins usually provide preset settings that can quickly convert 3D models into a style with comic characteristics. However, there are many areas that need to be improved in the existing rendering methods. For example, in traditional stroke processing, the thickness of the outer outline of the image is fixed and lacks detail levels; the inner outline is severely jagged, which affects the overall effect. When coloring, the shadow effect is poor and the adjustment is cumbersome. In edge light processing, the light emission of each part lacks changes and the control is cumbersome. Summary of the invention
[0003] In view of the above problems, the present invention proposes a technical solution to improve the stroke processing, coloring processing, edge light processing and other aspects.
[0004] A method for rendering a three-dimensional model in a comic style, comprising the following parts: Stroke processing: Stroke processing includes outer outline processing and inner outline processing; The processing of the outer outline includes the following: using the normal expansion algorithm to generate an outer outline for the three-dimensional model, setting the outer stroke pixel overflow value parameter of the normal expansion algorithm to a dynamic value, the size of the value is determined by the distance between the viewpoint and the three-dimensional model, the closer the distance, the smaller the value, the farther the distance, the larger the value; further processing is performed on the outer outline that requires changes in thickness and virtuality, and the processing method is to adjust the alpha value of the model vertices on the outer outline. When the alpha value of the model vertex changes from large to small, the corresponding position of the outer outline will change from thick to thin and then to virtual.
[0005] The processing of inner edges includes the following: manually drawing inner edges on the map of the parts where inner edges are needed, modifying the UV at the corresponding position of the inner edges that need to improve the clarity, so that the inner edges that need to improve the clarity are parallel to any coordinate axis of the UV; further processing is performed on the inner edges that need to change in thickness and virtuality, and the processing method is to adjust the position of the model vertices on the inner edges. When the position of the model vertices is adjusted toward the inside of the three-dimensional model, the corresponding position of the inner edge will change from thick to thin and then to virtual.
[0006] Preferably, the following parts are also included: Coloring processing: reduce the color from multiple levels to two levels, the two levels are light level and dark level respectively; determine whether the dot product result of the model vertex normal and the light at each location of the three-dimensional model exceeds the control threshold. If it exceeds, use the light level for coloring at the corresponding position to achieve the bright part coloring of the three-dimensional model. If it does not exceed, use the dark level for coloring at the corresponding position to achieve the dark part coloring of the three-dimensional model. The value of the control threshold at each location of the three-dimensional model is obtained from the channel of the model vertex at the corresponding location or the channel of the map. The value of the control threshold at each location of the three-dimensional model is controlled by setting the specific value of the color channel of the model vertex at the corresponding location or the color channel of the map.
[0007] Preferably, the following parts are also included: Edge light processing: set the edge light color and edge light intensity in the material ball, set the mask map in the channel of any map, and calculate the edge coefficient of each position of the 3D model; among them, the mask map is used to set the relative intensity of the edge light at each position of the model, and the edge coefficient is obtained according to the angle between the model vertex normal and the viewpoint at the corresponding position. The larger the angle, the larger the edge coefficient; the edge light at each position is equal to the edge coefficient of the corresponding position multiplied by the value of the corresponding position in the mask map multiplied by the edge light color and edge light intensity.
[0008] Preferably, the edge coefficient is equal to 1 minus the cosine value of the angle between the normal line of the model vertex at the corresponding position and the viewpoint vector.
[0009] Preferably, the following parts are also included: Normal correction: Normal correction is used to correct the hair and other parts that need to improve the shadow effect; The process of correcting the normal of the hair is as follows: draw a smooth cavity to completely wrap the hair; transfer the normal of the model vertex of the smooth cavity to the corresponding model vertex of the hair; The normal correction process for other parts is: in the parts where the shadow effect needs to be adjusted, manually adjust the normals of the model vertices to achieve the purpose of improving the shadow effect.
[0010] Beneficial effects: The advantage of this invention is first of all to associate the thickness of the outer stroke with the vertices of the model, so that the outer stroke has virtual and real changes, and at the same time, the normal is smoothed so that the outer stroke has no broken edges. The advantage of the inner stroke is to modify the UV so that the inner outline that needs to improve the clarity is parallel to any coordinate axis of the UV, so that the inner stroke has an anti-aliasing effect. In the coloring process, the model is closer to the cartoon style in color, reducing the effect of the gang, smoothing the normal to adjust the shadow effect, and the edge light processing makes the edge light have intensity changes and is smoother. Overall, the cartoon stylization of the model is achieved, and this stylization effect is further optimized. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Figure 1 This is a comparison chart of the outer stroke with different outer stroke pixel overflow value parameters; Figure 2 It is an outer outline with varying thickness, virtuality and reality; Figure 3 This is the effect picture after manually drawing the inner edge; Figure 4 It is a coloring effect diagram in the embodiment; Figure 5 This is an edge light effect diagram in the embodiment; Figure 6 : The facial shadow images before and after normal correction in the embodiment; Figure 7 A process diagram of normal correction of hair in an embodiment; Figure 8 1 is a hair shadow map before and after normal correction in the embodiment. DETAILED DESCRIPTION
[0014] In order to make the purpose, features and advantages of the present invention more obvious and easy to understand, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described below are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0015] A method for rendering a three-dimensional model in a comic style, comprising the following parts: Stroke processing: Stroke processing includes outer outline processing and inner outline processing; The processing of the outer outline includes the following: using the normal expansion algorithm to generate an outer outline for the 3D model, setting the outer stroke pixel overflow value parameter of the normal expansion algorithm to a dynamic value, the value of which is determined by the distance between the viewpoint and the 3D model. The closer the distance, the smaller the value, and the farther the distance, the larger the value; further processing is performed on the outer outline that requires changes in thickness and virtuality. The processing method is to adjust the alpha value of the model vertex on the outer outline. When the alpha value of the model vertex changes from large to small, the corresponding position of the outer outline will change from thick to thin and then to virtual. Figure 2 As shown in the figure, the alpha value of the model vertex in the red box gradually decreases from 100 to 0 from top to bottom, so that the outer outline changes from thick to thin and then to virtual from top to bottom. This can better handle the details of the outer outline, so as to better meet the realization of comic stylized art.
[0016] The outer stroke pixel overflow value parameter of the normal expansion algorithm is the parameter used to adjust the thickness of the outer stroke in the normal expansion algorithm, such as Figure 1 As shown, Figure 1 In the upper and lower figures, the values of the outer stroke pixel overflow value parameters are 0.8 and 0.4 respectively. It can be clearly seen that Figure 1 The outer border of the upper middle image is thicker than that of the lower image. In the present invention, this parameter is set to a dynamic value and changes as the distance between the viewpoint and the three-dimensional model changes. This can solve the problem that the outer border of the user's screen becomes very thick when the viewpoint is zoomed in, and becomes very thin when the viewpoint is zoomed out.
[0017] The processing of inner edges includes the following: manually drawing inner edges on the map of the parts where inner edges are needed, modifying the UV at the corresponding position of the inner edges that need to improve the clarity, so that the inner edges that need to improve the clarity are parallel to any coordinate axis of the UV; further processing is performed on the inner edges that need to change in thickness and virtuality, and the processing method is to adjust the position of the model vertices on the inner edges. When the position of the model vertices is adjusted toward the inside of the three-dimensional model, the corresponding position of the inner edge will change from thick to thin and then to virtual.
[0018] Some of the inner outlines drawn manually may have low clarity, such as Figure 3 As shown in the figure, the inner outline marked by the red line has a very low definition and has an obvious pixelation. However, the present invention can significantly improve the definition of the corresponding inner outline by modifying UV so that the inner outline whose definition needs to be improved is parallel to any coordinate axis of UV.
[0019] Coloring: reduce the color from multiple levels to two levels, the two levels are light level and dark level; determine whether the dot product result of the model vertex normal and the light at each location of the three-dimensional model exceeds the control threshold, if it exceeds, use the light level to color the corresponding position to achieve the bright part coloring of the three-dimensional model, if it does not exceed, use the dark level to color the corresponding position to achieve the dark part coloring of the three-dimensional model; the value of the control threshold at each location of the three-dimensional model is obtained from the channel of the model vertex at the corresponding location or the channel of the map, and the value of the control threshold at each location of the three-dimensional model is controlled by setting the specific value of the color channel of the model vertex at the corresponding location or the color channel of the map. In this embodiment, the three-dimensional model has three layers of maps, namely base map, ilm map, and sss map, and the value of the control threshold at each location of the three-dimensional model is equal to the value of the r channel of the model vertex at the corresponding location plus the value of the g channel of the ilm map.
[0020] The shading process of the present invention includes some ideas of CelShading and Tone Based Shading algorithms, ensuring smooth transition in the shadow transition area under the tone of comic stylized light and dark contrast, the effect is as follows: Figure 4 shown.
[0021] Edge light processing: setting edge light color and edge light intensity in the material ball, setting a mask map in the channel of any map, and calculating edge coefficients at various positions of the three-dimensional model; wherein the mask map is used to set the relative intensity of edge light at various positions of the model, and the edge coefficient is obtained according to the angle between the model vertex normal at the corresponding position and the viewpoint vector, and the larger the angle, the larger the edge coefficient; in the present embodiment, the edge coefficient is equal to 1 minus the cosine value of the angle between the model vertex normal at the corresponding position and the viewpoint vector; the edge light at each position is equal to the edge coefficient at the corresponding position multiplied by the value at the corresponding position in the mask map and then multiplied by the edge light color and edge light intensity.
[0022] The edge light color and edge light intensity set in the material ball are used to set the overall intensity and color of the edge light, while the values of each position in the mask map are used to indicate the relative size of the edge light intensity at different positions, such as Figure 5 As shown, the intensity of the edge light in the red area and the green area is different. This is the effect controlled by the ask mask map. The larger the angle between the model vertex normal and the viewpoint at a position, the closer the position is to the edge. Therefore, using the size of this angle as the basis for the size of the edge coefficient can well identify the position of the edge.
[0023] Normal correction: Normal correction is used to correct the hair and other parts that need to improve the shadow effect; The process of correcting the normal of the hair is as follows: draw a smooth cavity to completely wrap the hair; transfer the normal of the model vertex of the smooth cavity to the corresponding model vertex of the hair; The normal correction process for other parts is: in the parts where the shadow effect needs to be adjusted, manually adjust the normals of the model vertices to achieve the purpose of improving the shadow effect.
[0024] According to the shading method of the present invention, the shadow effect will be affected by the normal of the model vertex at the corresponding position, so the shadow effect can be improved by directly manually adjusting the normal of the model vertex at the corresponding position; the normal correction of the hair can be directly corrected by normal transfer. Figure 6 , where the left and right sides are the effects of the facial normal before and after correction; Figure 7 As shown in FIG. 1 , in this embodiment, the smooth cavity used is an ellipse, which completely wraps the hair and then performs a normal transfer operation, thereby improving the shadow effect at the hair. Figure 8 As shown, the left and right sides are the effects of normal correction of the hair area before and after.
[0025] During the rendering process, existing technologies can be used to achieve other effects such as hair highlights as needed, which will not be discussed here.
[0026] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for rendering a three-dimensional model in a comic style, characterized in that Includes the following parts: Stroke processing: Stroke processing includes outer outline processing and inner outline processing; The processing of the outer outline includes the following: using the normal expansion algorithm to generate an outer outline for the 3D model, setting the outer stroke pixel overflow value parameter of the normal expansion algorithm to a dynamic value, the value of which is determined by the distance between the viewpoint and the 3D model. The closer the distance, the smaller the value, and the farther the distance, the larger the value; further processing is performed on the outer outline that requires changes in thickness and virtuality, and the processing method is to adjust the alpha value of the model vertex on the outer outline. When the alpha value of the model vertex changes from large to small, the corresponding position of the outer outline will change from thick to thin and then to virtual; The processing of inner edges includes the following: manually drawing inner edges on the map of the parts where inner edges are needed, modifying the UV at the corresponding position of the inner edges that need to improve the clarity, so that the inner edges that need to improve the clarity are parallel to any coordinate axis of the UV; further processing is performed on the inner edges that need to change in thickness and virtuality, and the processing method is to adjust the position of the model vertices on the inner edges. When the position of the model vertices is adjusted toward the inside of the three-dimensional model, the corresponding position of the inner edge will change from thick to thin and then to virtual.
2. A method for rendering a three-dimensional model in a comic style according to claim 1, characterized in that Also includes the following sections: Coloring: Reduce the color from multiple levels to two levels, the two levels are light level and dark level; It is determined whether the dot product result of the normal of the model vertex and the light at each location of the three-dimensional model exceeds the control threshold. If it exceeds, a light color level is used for coloring at the corresponding location to realize the bright part coloring of the three-dimensional model. If it does not exceed, a dark color level is used for coloring at the corresponding location to realize the dark part coloring of the three-dimensional model. The value of the control threshold at each location of the three-dimensional model is obtained from the channel of the model vertex at the corresponding location or the channel of the map. The value of the control threshold at each location of the three-dimensional model is controlled by setting the specific value of the color channel of the model vertex at the corresponding location or the color channel of the map.
3. The method for rendering a three-dimensional model in a comic style according to claim 1, characterized in that Also includes the following sections: Edge light processing: set the edge light color and edge light intensity in the material ball, set the mask map in the channel of any map, and calculate the edge coefficient of each position of the 3D model; among them, the mask map is used to set the relative intensity of the edge light at each position of the model, and the edge coefficient is obtained according to the angle between the model vertex normal and the viewpoint at the corresponding position. The larger the angle, the larger the edge coefficient; the edge light at each position is equal to the edge coefficient of the corresponding position multiplied by the value of the corresponding position in the mask map multiplied by the edge light color and edge light intensity.
4. The method for rendering a three-dimensional model in a comic style according to claim 3, characterized in that: The edge coefficient is equal to 1 minus the cosine of the angle between the normal of the model vertex at the corresponding position and the view vector.
5. The method for rendering a three-dimensional model in a comic style according to claim 2, characterized in that Also includes the following sections: Normal correction: Normal correction is used to correct the hair and other parts that need to improve the shadow effect; The process of correcting the normal of the hair is as follows: draw a smooth cavity to completely wrap the hair; transfer the normal of the model vertex of the smooth cavity to the corresponding model vertex of the hair; The normal correction process for other parts is: in the parts where the shadow effect needs to be adjusted, manually adjust the normals of the model vertices to achieve the purpose of improving the shadow effect.
