Oil painting style scene rendering method, device and storage medium
By determining the position of the stroke line in a three-dimensional scene and shading the scene color, the problem of low oil painting style conversion efficiency in the existing technology is solved, and efficient oil painting style rendering and extensibility is achieved.
Patent Information
- Application Number
- CN202111056761.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-09
- Publication Date
- 2025-06-03
- Estimated Expiration
- 2041-09-09
AI Technical Summary
The prior art requires redrawing and modeling when converting game scenes from realistic style to oil painting style. Each scene requires a lot of work, resulting in low development efficiency and poor scalability.
By determining the stroke position in the three-dimensional scene element model, the scene is stroked and colored, and the scene color is blurred according to the texture coordinates of the pixels, the scene rendering is achieved in the oil painting style.
The three-dimensional scenes can be converted into oil painting style without redesigning and modeling, significantly improving the efficiency and scalability of scene rendering.
Smart Images

Figure CN113935892B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and particularly to a method, device, and storage medium for rendering a scene in an oil painting style. Background Art
[0002] Oil painting is a commonly used painting method. Generally, in an oil painting work, the details of the depicted object are usually represented by the texture, covering power, and transparency of various pigments. Oil paintings are characterized by rich colors and strong three-dimensional textures.
[0003] Taking game development as an example, there are usually multiple scenes set in a game. In the related art, if the game scene needs to be changed from a realistic style to an oil painting style, each scene in the game needs to be redrawn and modeled, which greatly reduces the game development efficiency and results in poor scalability of the existing game scenes. Therefore, there is an urgent need to propose a new solution to overcome the existing technical problems. Summary of the Invention
[0004] Multiple aspects of this application provide a method, device, and storage medium for rendering a scene in an oil painting style, so as to implement a scene with an oil painting style, improve the scene rendering efficiency, and enhance the scene scalability.
[0005] An embodiment of this application also provides a method for rendering a scene in an oil painting style, and the method includes:
[0006] For a three-dimensional scene to be processed, determine the positions of the outlining lines in each scene element model;
[0007] According to the positions of the outlining lines, perform outlining coloring on each scene element model to obtain a three-dimensional scene including the outlining lines;
[0008] In the three-dimensional scene including the outlining lines, perform blurring processing on the scene colors of the three-dimensional scene according to the texture coordinates of each pixel in the three-dimensional scene to obtain an oil painting style scene.
[0009] Further optionally, performing blurring processing on the scene colors of the three-dimensional scene according to the texture coordinates of each pixel in the three-dimensional scene includes:
[0010] According to the texture coordinates of each pixel in the three-dimensional scene, with each pixel in the three-dimensional scene as the center, divide the corresponding coordinate range in the screen space coordinate system;
[0011] According to the coordinate range corresponding to each pixel, perform blurring processing on the scene color of each pixel to obtain the target scene color of each pixel in the oil painting style scene.
[0012] Among them, further optionally, according to the texture coordinates of each pixel in the three-dimensional scene, with each pixel in the three-dimensional scene as the center, a corresponding coordinate range is divided in the screen space coordinate system, including:
[0013] For each pixel in the three-dimensional scene, the texture coordinates of the current pixel in the screen space coordinate system are offset to obtain the coordinate range corresponding to the current pixel.
[0014] Among them, further optionally, the current pixel corresponds to the first coordinate range;
[0015] According to the coordinate ranges corresponding to each pixel, the scene colors of each pixel are blurred to obtain the target scene colors of each pixel in the oil painting stylized scene, including:
[0016] According to the texture coordinates of the current pixel and the surrounding pixels in the first coordinate range, the scene colors of the current pixel and the surrounding pixels are obtained from the scene texture map;
[0017] According to the preset weight parameters, a weighted average calculation is performed on the scene colors of the current pixel and the surrounding pixels in the first coordinate range to obtain the weighted average value of the scene colors, and the weighted average value is used as the target scene color of the current pixel.
[0018] Among them, further optionally, the current pixel corresponds to the first coordinate range;
[0019] According to the coordinate ranges corresponding to each pixel, the scene colors of each pixel are blurred to obtain the target scene colors of each pixel in the oil painting stylized scene, including:
[0020] According to the texture coordinates of the current pixel and the surrounding pixels in the first coordinate range, the scene colors of the current pixel and the surrounding pixels are obtained from the scene texture map;
[0021] Obtain the similarity between the scene color of the current pixel and the scene colors of the surrounding pixels;
[0022] Fuse the scene colors of the surrounding pixels whose similarity is in the preset order with the scene color of the current pixel, and use the fused scene color as the target scene color of the current pixel.
[0023] Further optionally, based on the coordinate ranges corresponding to each pixel, each color block where each pixel is located is determined from the scene texture map;
[0024] Determine the arrangement order of each color block in the scene texture map;
[0025] Overlay the blurred color blocks in the arrangement order to obtain the oil painting stylized scene.
[0026] Among them, further optionally, determining the arrangement order of each color block in the scene texture map includes:
[0027] Obtaining the visual features of each color block from the scene texture map according to the pixel texture coordinates of each color block; wherein, the visual features include background texture features and / or lighting features, the background texture features are used to represent the relative position relationship of each color block in the scene texture map, and the lighting features are used to represent the light and dark relationship of each color block in the scene texture map;
[0028] Determining the color block range and arrangement order corresponding to each color block based on the visual features.
[0029] Among them, further optionally, superimposing each blurred color block in the arrangement order to obtain an oil painting stylized scene, including:
[0030] For each blurred color block, based on the color block range and arrangement order of each color block, superimposing each color block in the three-dimensional scene including the outline line to obtain an oil painting stylized scene.
[0031] Further optionally, the outline line includes a contour line and / or a polyline. The contour line is an outline line used to represent the external contour of the model, and the polyline is an outline line used to represent the internal contour of the model;
[0032] Determining the position of the outline line in each scene element model includes:
[0033] Obtaining the edge pixels on the contour line and / or polyline of each scene element model in the screen space coordinate system.
[0034] Among them, further optionally, if the outline line includes a contour line, obtaining the edge pixels on the contour line and / or polyline of each scene element model in the screen space coordinate system includes:
[0035] For the pixel to be detected in each scene element model, offset the texture coordinate of the current pixel in the screen space coordinate system to obtain the texture coordinates of the surrounding pixels; wherein, the offset direction is the normal direction of the current pixel, and the offset distance is the product of the scene depth of the current pixel and the offset coefficient;
[0036] Obtaining the scene depth of the current pixel and the surrounding pixels from the scene texture map according to the texture coordinates of the current pixel and the surrounding pixels;
[0037] If the scene depth difference between the current pixel and the surrounding pixels is greater than the set depth difference threshold, then use the current pixel as the edge pixel on the contour line of the scene element model.
[0038] Among them, further optionally, if the outline line includes a polyline, obtaining edge pixels on the contour line and / or polyline of each scene element model in the screen space coordinate system includes:
[0039] For each pixel to be detected in the scene element model, offset the texture coordinates of the current pixel in the screen space coordinate system to obtain the texture coordinates of the surrounding pixels; wherein, the offset direction is the normal direction of the current pixel, and the offset distance is the product of the scene depth of the current pixel and the offset coefficient;
[0040] According to the texture coordinates of the current pixel and the surrounding pixels, obtain the normal values of the current pixel and the surrounding pixels from the scene texture map;
[0041] If the difference in normal values between the current pixel and the surrounding pixels is greater than the set normal difference threshold, use the current pixel as the edge pixel on the polyline in the scene element model.
[0042] Further optionally, according to the position where the outline line is located, perform outline coloring on each scene element model to obtain a three-dimensional scene including the outline line, including:
[0043] Generate a first mask map including the edge pixels in each scene element model according to the edge pixels on the outline line in each scene element model;
[0044] Perform linear interpolation between the edge pixels in the first mask map according to the scene colors of the edge pixels to obtain a three-dimensional scene including the outline line.
[0045] Among them, further optionally, sample the three-dimensional noise map according to the texture coordinates of each edge pixel to obtain the noise value corresponding to each edge pixel;
[0046] Perform an offset process on the scene colors of each edge pixel according to the noise value corresponding to each edge pixel to obtain a three-dimensional scene including a discontinuous outline line.
[0047] Further optionally, use a custom depth template item to filter the target scene elements that do not require blurring;
[0048] Generate a second mask map for marking the target scene elements according to the filtering result, and the second mask map is used to represent the position where the target scene elements are located.
[0049] In this way, by using the second mask map to perform the step of blurring the scene colors of the three-dimensional scene, the initial scene colors of the target scene elements can be retained in the oil painting stylized scene.
[0050] Further optionally, use a custom depth template item to filter the occluded scene elements;
[0051] Generate a third mask image for marking the occluded scene elements according to the filtering result, where the third mask image is used to represent the positions where the occluded scene elements are located.
[0052] In this way, when performing the step of processing the scene color of the three-dimensional scene in an oil painting style using the third mask image, it is possible to avoid abnormalities of the occluded scene elements in the oil painting style scene.
[0053] An embodiment of the present application further provides an electronic device, including: a memory and a processor; the memory is used to store one or more computer instructions; the processor is used to execute the one or more computer instructions for: performing the steps in the method provided by the embodiment of the present application.
[0054] An embodiment of the present application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed, it can implement the steps in the method provided by the embodiment of the present application.
[0055] In the technical solution provided by the embodiment of the present application, for a three-dimensional scene to be processed, determine the positions where the outline lines are located in each scene element model; according to the positions where the outline lines are located, perform outline coloring on each scene element model to obtain a three-dimensional scene including the outline lines, thereby depicting the outlines of each scene element model. Furthermore, in the three-dimensional scene including the outline lines, perform blurring processing on the scene color of the three-dimensional scene according to the texture coordinates of each pixel in the three-dimensional scene to obtain an oil painting style scene. Thus, the oil painting texture on the surfaces of each scene element model in the three-dimensional scene is realized, and an oil painting style scene is obtained.
[0056] In the embodiment of the present application, by performing edge detection and outline coloring on each scene element model, the outlines of each scene element model are depicted, and an oil painting texture scene color is realized through blurring processing, thereby realizing an oil painting style scene. In the embodiment of the present application, it is possible to convert the three-dimensional scene to be processed into an oil painting style without re-designing and modeling, greatly improving the scene rendering efficiency and enhancing the scene scalability. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] The drawings described herein are used to provide a further understanding of the present application, and constitute a part of the present application. The schematic embodiments of the present application and their descriptions are used to explain the present application, and do not constitute an improper limitation to the present application. In the drawings:
[0058] Figure 1 is a flowchart of a method for rendering an oil painting style scene provided by an exemplary embodiment of the present application;
[0059] Figure 2 is an effect diagram of an oil painting style scene provided by an exemplary embodiment of the present application;
[0060] Figure 3 Schematic diagram of the effect of an oil painting stylized scene provided for another exemplary embodiment of the present application;
[0061] Figure 4 Schematic diagram of the effect of an oil painting stylized scene provided for still another exemplary embodiment of the present application;
[0062] Figure 5 Schematic diagram of the effect of scene elements provided for an exemplary embodiment of the present application;
[0063] Figure 6 Schematic diagram of the structure of an electronic device provided for an exemplary embodiment of the present application. Detailed implementation manners
[0064] To make the objectives, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in conjunction with specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0065] Oil painting is a commonly used painting method. Generally speaking, in oil painting works, the details of the depicted objects are usually expressed through the texture, covering power and transparency of various pigments. Oil paintings have the characteristics of rich colors and strong three-dimensional texture. In the present application, a three-dimensional scene will be presented in the form of an oil painting, and such a three-dimensional scene is called an oil painting stylized scene.
[0066] Currently, three-dimensional scenes are widely used, such as games, movies and television, virtual transactions, online tourism, etc. Taking game development as an example, multiple scenes are usually set in games. In the related art, if it is necessary to change the game scene from a realistic style to an oil painting style, each scene in the game needs to be redrawn and modeled, which greatly reduces the game development efficiency and results in poor scalability of the existing game scenes.
[0067] In view of the above technical problems, in some embodiments of the present application, a solution is provided. The technical solutions provided in each embodiment of the present application will be described in detail below in conjunction with the drawings.
[0068] In the embodiments of the present application, a three-dimensional scene will be presented in the form of an oil painting, and such a three-dimensional scene is called an oil painting stylized scene.
[0069] The embodiments of the present application provide a method for rendering an oil painting style scene, Figure 1 Schematic diagram of the process of the method for rendering an oil painting style scene provided for an exemplary embodiment of the present application. AsFigure 1 As shown, the method includes:
[0070] 101. For the three-dimensional scene to be processed, determine the positions of the outlining lines in each scene element model;
[0071] 102. According to the positions of the outlining lines, perform outlining coloring on each scene element model to obtain a three-dimensional scene containing the outlining lines;
[0072] 103. In the three-dimensional scene containing the outlining lines, perform blurring processing on the scene colors of the three-dimensional scene according to the texture coordinates of each pixel in the three-dimensional scene to obtain an oil painting stylized scene.
[0073] Among them, the three-dimensional scene to be processed, that is, the three-dimensional scene that needs to be scene-rendered. For example, assume that the three-dimensional scene to be processed is a realistic game scene in a certain game. After post-processing, what is obtained is another game scene in the oil painting style in this game. In the two game scenes before and after post-processing, the scene elements, the scene element layout, and the attributes of each scene element are all the same, but the scene styles of the two game scenes are different. Specifically, the scene style can be reflected in the art style characteristics in the three-dimensional scene, such as hue, lines, light and dark relationships, etc.
[0074] For a game scene, different scene styles can be understood as different art styles in this game scene. For example, in a realistic game scene, the scene hue and the light and dark relationships of the scene elements are closer to the real world, and the scene elements are not outlined by obvious lines. While in an oil painting style game scene, the outlines and light and dark relationships of the scene elements are depicted through oil painting material color blocks and brushstrokes, so as to reflect the detailed characteristics of the scene elements.
[0075] In the embodiments of the present application, each step in the oil painting style scene rendering method can be implemented through material codes. For example, by writing various rendering logics in the material codes to implement the rendering principle of the corresponding oil painting stylized scene.
[0076] Next, in combination with specific embodiments, Figure 1 explain each step in the provided oil painting style scene rendering method.
[0077] First, in 101, for the three-dimensional scene to be processed, determine the positions of the outlining lines in each scene element model.
[0078] Among them, the outlining line includes a contour line and / or a polyline. The contour line is the outlining line used to represent the external contour of the model, and the polyline is the outlining line used to represent the internal contour of the model. Optionally, the edges of the scene element model are determined through edge detection to provide a basis for coloring the outline. In practical applications, starting from the currently detected pixel, the coordinates of the surrounding pixels are obtained to detect the pixels on the edge of the scene element model. The methods for obtaining the contour line and the polyline are introduced separately below.
[0079] Specifically, an optional embodiment for determining the position of the outlining line in each scene element model in 101 can be implemented as: obtaining the edge pixels on the contour line and / or the polyline in each scene element model.
[0080] In an optional embodiment, if the outlining line includes a contour line, then obtaining the edge pixels on the contour line and / or the polyline in each scene element model in the above steps can be implemented as:
[0081] For each pixel to be detected in each scene element model, the texture coordinates of the current pixel are offset to obtain the texture coordinates of the surrounding pixels; according to the texture coordinates of the current pixel and the surrounding pixels, the scene depths of the current pixel and the surrounding pixels are obtained from the scene texture map; if the difference in scene depth between the current pixel and the surrounding pixels is greater than the set depth difference threshold, then the current pixel is used as the edge pixel on the contour line of the scene element model.
[0082] Among them, the offset direction is the normal direction of the current pixel, and the offset distance is the product of the scene depth of the current pixel and the offset coefficient. Specifically, the normal direction of the current pixel is extracted from the scene texture map as the offset direction; the scene depth of the current pixel is extracted from the scene texture map, and the product of the scene depth of the current pixel and the offset coefficient is used as the offset distance.
[0083] For each pixel to be detected in each scene element model, based on the offset direction and offset distance introduced above, the texture coordinates of the current pixel in the screen space coordinate system are offset to obtain the texture coordinates of the surrounding pixels. Specifically, the texture coordinates of the surrounding pixels are obtained through vector operations according to the coordinates of the current pixel point in the screen space coordinate system.
[0084] Furthermore, according to the texture coordinates of the current pixel and the surrounding pixels, the respective scene depths of the current pixel and the surrounding pixels are obtained from the scene texture map, and the difference in scene depth between the current pixel and the surrounding pixels is calculated. If the difference in scene depth between the current pixel and any of the surrounding pixels is greater than the set depth difference threshold, it means that the current pixel is on the contour line of the scene element model. In this case, the current pixel is used as the edge pixel on the contour line of the scene element model.
[0085] In another alternative embodiment, if the outline line includes a polyline, obtaining the edge pixels on the contour line and / or the polyline in each scene element model in the above steps can be implemented as follows:
[0086] For each pixel to be detected in the scene element model, offset the texture coordinates of the current pixel to obtain the texture coordinates of the surrounding pixels; according to the texture coordinates of the current pixel and the surrounding pixels, obtain the normal information of the current pixel and the surrounding pixels from the scene texture map; if the normal difference between the current pixel and the surrounding pixels is greater than the set normal difference threshold, it is considered that the current pixel is on the contour of the scene element model. In this case, use the current pixel as the edge pixel on the polyline in the scene element model.
[0087] Among them, the offset direction is the normal direction of the current pixel, and the offset distance is the product of the scene depth of the current pixel and the offset coefficient. The specific method for obtaining the offset direction and offset distance of the current pixel is similar to the above, and will not be elaborated here.
[0088] For each pixel to be detected in the scene element model, based on the offset direction and offset distance introduced above, offset the texture coordinates of the current pixel in the screen space coordinate system to obtain the texture coordinates of the surrounding pixels. Then, collect the normal information of the above pixels from the scene texture map through the texture coordinates of the current pixel and the surrounding pixels. Furthermore, determine the respective normal values of the current pixel and the surrounding pixels in the world coordinate system according to the collected normal information, and calculate the normal difference between the current pixel and the surrounding pixels. If the normal difference between the current pixel and any surrounding pixel is greater than the set normal difference threshold, it is considered that the current pixel is on the inner contour of the scene element model. In this case, use the current pixel as the edge pixel on the polyline in the scene element model.
[0089] In practical applications, the above threshold can be set and optimized according to the specific scene, and it is not limited in the embodiments of the present application. In addition to the above edge detection method, other edge detection methods can also be used in the embodiments of the present application to determine the position of the outline line, and the present application is not limited.
[0090] Furthermore, after detecting the position of the outline line, in 102, according to the position of the outline line, perform outline coloring on each scene element model to obtain a three-dimensional scene including the outline line.
[0091] Specifically, in an alternative embodiment, in 102, performing outline coloring on each scene element model according to the position of the outline line to obtain a three-dimensional scene including the outline line can be implemented as follows:
[0092] Generate a first mask image containing the edge pixels in each scene element model based on the edge pixels on the stroked line in each scene element model; perform linear interpolation (Linear Lerp) between the edge pixels in the first mask image according to the scene colors of the respective edge pixels to obtain a three-dimensional scene containing the stroked line.
[0093] In the above steps, a first mask image is generated based on the edge pixels on the stroked line in each scene element model, and the first mask image contains the edge pixels in each scene element model. Furthermore, for each edge pixel in the first mask image, linear interpolation is performed on the scene color of each edge pixel and the pre-set stroked line color to obtain a three-dimensional scene containing the stroked line.
[0094] In this way, through the above steps, the rendering of the stroked line can be achieved in the three-dimensional scene, thereby automatically generating a stroked line with an oil painting style and assisting in improving the three-dimensional scene rendering efficiency.
[0095] In fact, since the oil painting brushstrokes in the real world are not all continuous, and a continuous stroked line will be obtained after stroked coloring through the above steps, making the oil painting effect unnatural. To address this issue and make the oil painting brushstrokes have a more realistic effect, further optionally, sample the three-dimensional noise map according to the texture coordinates of each edge pixel to obtain the noise value corresponding to each edge pixel; perform an offset process on the scene color of each edge pixel according to the noise value corresponding to each edge pixel to obtain a three-dimensional scene containing a discontinuous stroked line.
[0096] For the three-dimensional scene containing the stroked line, in the above steps, first perform an inverse operation through the scene depth of the current pixel to obtain the world coordinates of the current pixel in the world coordinate system. Then, remap using the world coordinates of the current pixel to obtain the texture coordinates (denoted as UVW) of the current pixel for the three-dimensional noise map. Furthermore, sample the three-dimensional Perlin Noise map using the texture coordinates of the current pixel to obtain continuous noise values. In this way, use these continuous noise values to offset the stroked line, thereby simulating the effect of short lines to obtain a three-dimensional scene containing a discontinuous stroked line. Among them, Perlin Noise is a type of continuous noise often used to simulate clouds.
[0097] Briefly speaking, it is to obtain continuous noise values by sampling the three-dimensional Perlin Noise map using the texture coordinates of the current pixel. In practical applications, the value range of the continuous noise values usually ranges from 0 to 1. Then, multiply the continuous noise values by the color value of the stroked line to obtain a stroked line containing invalid values (such as continuous noise values with a value of 0). For example Figure 2 The intermittent and discontinuous wall seams shown in the three-dimensional scene.
[0098] Furthermore, after outlining the contour of the scene element model through the above-mentioned stroke coloring, in order to simulate the material texture in an oil painting work, it is necessary to blur the three-dimensional scene so that it has color blocks and brushstrokes in the style of an oil painting. Specifically, in 103, in the three-dimensional scene containing the stroke lines, the scene colors of the three-dimensional scene are blurred according to the texture coordinates of each pixel in the three-dimensional scene to obtain a stylized oil painting scene.
[0099] In an optional embodiment, blurring the scene colors of the three-dimensional scene according to the texture coordinates of each pixel in the three-dimensional scene can be implemented as follows:
[0100] According to the texture coordinates of each pixel in the three-dimensional scene, with each pixel in the three-dimensional scene as the center, a corresponding coordinate range is divided in the screen space coordinate system; according to the coordinate range corresponding to each pixel, the scene color of each pixel is blurred to obtain the target scene color of each pixel in the stylized oil painting scene.
[0101] In the above steps, multiple coordinate ranges are respectively divided with each pixel in the three-dimensional scene as the center, and the scene colors are blurred based on the coordinate range corresponding to each pixel, thereby forming the scene color blocks corresponding to each pixel to simulate the color blocks and brushstrokes in an oil painting work. It should be noted that the scene color blocks corresponding to each pixel may overlap with each other, which can further simulate the overlapping brushstroke effect in an oil painting work.
[0102] Specifically, in 103, blurring the scene colors of the three-dimensional scene according to the texture coordinates of each pixel in the three-dimensional scene, with each pixel in the three-dimensional scene as the center, and dividing a corresponding coordinate range in the screen space coordinate system can be implemented as follows:
[0103] For each pixel in the three-dimensional scene, the texture coordinates of the current pixel in the screen space coordinate system are offset to obtain the coordinate range corresponding to the current pixel.
[0104] Similar to the above, the coordinate range corresponding to the current pixel can also be obtained through offset processing here. In practical applications, the size of the coordinate range can be preset. Optionally, in the screen space coordinate system, with the current pixel as the center, the coordinates within a set range around the center are divided into the coordinate range corresponding to the current pixel. The set range is, for example, 9*9 unit pixels.
[0105] Furthermore, after obtaining the coordinate ranges corresponding to each pixel in the three-dimensional scene, it is necessary to blur the scene colors of each pixel in order to simulate the brushstroke effect in the style of an oil painting.
[0106] The following introduces the specific implementation method of blurring the scene colors of each pixel to obtain the target scene color in combination with specific embodiments:
[0107] In an alternative embodiment, in 103, according to the coordinate ranges corresponding to the respective pixels, the scene colors of the respective pixels are blurred to obtain the target scene colors of the respective pixels in the oil painting stylized scene, which can be implemented as:
[0108] Obtain the scene colors of the current pixel and the surrounding pixels from the scene texture map according to the texture coordinates of the current pixel and the surrounding pixels in the first coordinate range; perform a weighted average calculation on the scene colors of the current pixel and the surrounding pixels in the first coordinate range according to the preset weight parameters to obtain the weighted average value of the scene colors, and use the weighted average value as the target scene color of the current pixel.
[0109] Specifically, assume that the current pixel is pixel i, and assume that the coordinate range corresponding to pixel i is the first coordinate range. Assume that the surrounding pixels surrounding pixel i are denoted as {i 1 , i 2 , ……, i n}. Assume that the weight parameters corresponding to pixel i and the surrounding pixels {i 1 , i 2 , ……, i n} are respectively {x 1 , x 2 , ……, x n}. Assume that n is an integer less than or equal to 9.
[0110] Based on the above assumptions, obtain the texture coordinates of pixel i in the first coordinate range and the texture coordinates of the surrounding pixels surrounding this pixel i from the first coordinate range. Furthermore, sample the scene texture map according to the texture coordinates of pixel i and the surrounding pixels {i 1 , i 2 , ……, i n} to obtain the scene colors {y i , y 1 , y 2 , ……, y n} corresponding to pixel i and the surrounding pixels.
[0111] Next, according to the preset weight parameters, namely {x i , x 1 , x 2 , ……, x n}, for the scene colors {y 1 , y 2 , ……, y n} of pixel i and the surrounding pixels {i i , y 1 , y 2 , ……, y n} Perform weighted average calculation to obtain the weighted average value Y of the scene color, and use the weighted average value Y as the target scene color of pixel i.
[0112] In practical applications, optionally, in a game editing tool (such as UE4), blur processing is performed using the X Radius parameter and the Y Radius parameter. Among them, X Radius represents the length of the horizontal axis in the coordinate range corresponding to each pixel, and Y Radius represents the length of the vertical axis in the coordinate range corresponding to each pixel.
[0113] It can be understood that the larger the values of the length of the horizontal axis and the length of the vertical axis in the coordinate range corresponding to the pixels for which blur processing is performed, the more pixels are covered by the blur processing, and the better the blur processing effect, but the higher the computational performance required. For example, Figure 3 In the three-dimensional scene shown, the values of the length of the horizontal axis radius and the length of the vertical axis radius are 10*5, Figure 4 In the three-dimensional scene shown, the values of the length of the horizontal axis radius and the length of the vertical axis radius are 3*3. Figure 3 The overall light and dark relationship and the texture of the picture are obviously more natural. Figure 3 The blur processing effect of Figure 4 is better than that of
[0114] In another alternative embodiment, in 103, according to the coordinate range corresponding to each pixel, blur processing is performed on the scene color of each pixel to obtain the target scene color of each pixel in the oil painting stylized scene, which can be implemented as:
[0115] According to the texture coordinates of the current pixel and the surrounding pixels in the first coordinate range, obtain the scene colors of the current pixel and the surrounding pixels from the scene map; obtain the similarity between the scene color of the current pixel and the scene colors of the surrounding pixels; fuse the scene colors of the surrounding pixels whose similarity is in the preset order with the scene color of the current pixel, and use the fused scene color as the target scene color of the current pixel.
[0116] Specifically, assume that the current pixel is pixel i, and assume that the coordinate range corresponding to pixel i is the first coordinate range. Assume that the surrounding pixels surrounding pixel i are denoted as {i 1 , i 2 , ……, i n}. Assume that n is an integer less than or equal to 9. Assume that the preset order is the first 4 (where the first one is the surrounding pixel with the highest similarity).
[0117] Based on the above assumptions, obtain the texture coordinates of pixel i in the first coordinate range and the texture coordinates of the surrounding pixels around pixel i. Then, sample the scene texture map according to the texture coordinates of pixel i and the surrounding pixels {i 1 ,i 2 ,……,i n} to obtain the scene colors {y i ,y 1 ,y 2 ,……,y n} corresponding to pixel i and the surrounding pixels.
[0118] Next, calculate the similarity of the scene colors between pixel i and each surrounding pixel {i 1 ,i 2 ,……,i n}. Further assume that the surrounding pixels {i 1 ,i 2 ,……,i n} are sorted from high to low in similarity as pixel i 1 ,i 2 ,……,i n . Based on this, calculate the average value of the scene colors of the surrounding pixels {i 1 ,i 2 ,i 3 ,i 4} with the highest 4 similarities and the scene color of pixel i, and use the average scene color value obtained after the average calculation as the target scene color of pixel i and the surrounding pixels {i 1 ,i 2 ,i 3 ,i 4 .
[0119] In addition, in another embodiment, the scene color of the surrounding pixels in the preset order can also be directly used as the target scene color of pixel i, thereby forming color blocks in the style of an oil painting.
[0120] Through the above several embodiments, it is possible to fuse the scene colors of the current pixel and the surrounding pixels in the coordinate range corresponding to each pixel, so that the finally displayed 3D scene presents richer and continuous colors in the style of an oil painting, and simulates the brushstrokes in the style of an oil painting in the 3D scene.
[0121] Of course, the blurring processing method in the above embodiments can be applied to all pixels in the 3D scene or only to some pixels in the 3D scene. Optionally, select the pixels to be processed that need to perform blurring processing from all pixels according to a preset period, thereby reducing the overhead required for blurring processing and further improving the scene rendering efficiency.
[0122] In this embodiment, by performing edge detection and stroke coloring on each scene element model, the outlines of each scene element model are depicted. Furthermore, through blurring processing, continuous colors and brushstrokes with an oil painting texture are simulated in the 3D scene, such that the interior of each scene element model is filled with scene colors in an oil painting style, thereby realizing the oil painting stylization of the 3D scene. In the embodiment of the present application, the 3D scene to be processed can be converted into an oil painting style without re-designing and modeling, greatly improving the scene rendering efficiency and enhancing the scene scalability.
[0123] In the above or following embodiments, since some scene elements in the 3D scene do not need to be covered with an oil painting texture, these scene elements need to be filtered, and a second mask image is used to prevent these scene elements from being covered with an oil painting style texture. Thus, these scene elements retain their initial scene colors.
[0124] Specifically, the depth item (Custom Depth) stored in the object vertices of a custom stencil can also be used to filter the target scene elements that do not require an oil painting brush texture map; a second mask image for marking the target scene elements is generated according to the filtering result, and the second mask image is used to perform the step of blurring the scene colors of the 3D scene, so as to retain the initial scene colors of the target scene elements in the oil painting stylized scene.
[0125] The above-mentioned partial scene elements are, for example: virtual characters, sky spheres, scene elements with text or special identifiers (such as scene icons), and other scene elements that do not require blurring processing. Among them, the scene icon is as shown in Figure 5 shown.
[0126] For example, according to the scene depth of the virtual character in the 3D scene, the corresponding scene depth is set in the custom depth template item, thereby filtering out the virtual character and generating a corresponding second mask image to retain the external image of the virtual character in the 3D scene.
[0127] For example, according to the markers corresponding to various scene icons, set the corresponding markers to be filtered in the custom depth template item. Optionally, mark the scene icons in the 3DUI to obtain the markers to be filtered for the scene icons. Specifically, during the depth filtering process, compare the scene depth of the current pixel (i.e., Scene Depth) with the depth item corresponding to the current pixel (i.e., Custom Depth). If the Custom Depth is less than or equal to the Scene Depth, it indicates that the vertex of the marked scene icon is within the current viewing angle. In this case, it is necessary to retain the initial scene color of the scene icon to avoid the situation where the scene icon cannot provide accurate visual information after blurring. Thus, various scene icons are filtered out, and a corresponding second mask image is generated. This second mask image is used to represent the position where the target scene element is located, so that various scene icons can be flexibly retained with their initial scene colors, improving the rendering efficiency.
[0128] In this embodiment, through the above steps, in a scene with an oil painting stylization, the initial scene colors of some scene elements are retained, improving the scene rendering efficiency of the oil painting stylized scene. At the same time, marking the retention of the initial scene color can also reduce the post-processing overhead and shorten the scene rendering duration.
[0129] In practical applications, since some scene elements in the three-dimensional scene may obscure each other, it may cause abnormalities in the processing procedures such as stroke coloring or blurring for the obscured scene elements. In response to this situation, in this application, further optionally, before 101, a custom depth template can also be used to filter the obscured scene elements, thereby generating a third mask image. This third mask image is used to represent the position where the obscured scene element is located. Thus, the above steps shown can be executed in combination with the third mask image. Figure 1 The above steps shown.
[0130] Specifically, assume that the depth items (i.e., CustomDepth) of the vertices of each object are stored in the custom depth template. Based on this, during the depth filtering process, compare the scene depth of the current pixel (i.e., Scene Depth) with the depth item corresponding to the current pixel (i.e., Custom Depth). If the Custom Depth is greater than the Scene Depth, it indicates that the vertex of the marked object corresponding to the current pixel is invisible to the user under the current viewing angle. In this case, there is no need to perform oil painting style processing on the current pixel to avoid abnormalities in processing procedures such as stroke coloring or blurring. At the same time, by marking the pixels that do not require oil painting processing, it also helps to further reduce the post-processing overhead and improve the scene rendering efficiency.
[0131] It should be noted that the third mask image can be merged with the first and second mask images described above into a single mask image for input into the same post-processing node to trigger the node to complete the above-mentioned relevant post-processing process. Of course, according to actual application requirements, the first, second, and third mask images can also be separately input into different post-processing nodes to trigger different post-processing nodes to separately implement the above processes, and the embodiments of the present application do not limit this.
[0132] In the above or following embodiments, since various pigments are superimposed in an oil painting work to create a visual effect with a three-dimensional texture. Therefore, to increase the texture of the oil painting stylized scene, in this embodiment, optionally, based on the coordinate range corresponding to each pixel, each color block where each pixel is located is determined from the scene texture map; the arrangement order of each color block in the scene texture map is determined; and the blurred color blocks are superimposed in the arrangement order to obtain an oil painting stylized scene.
[0133] In the above steps, optionally, the process of determining the arrangement order of each color block in the scene texture map can be implemented as: based on the pixel texture coordinates of each color block, the visual features of each color block are obtained from the scene texture map; and based on the visual features, the color block range and the arrangement order corresponding to each color block are determined.
[0134] Among them, the visual features include background texture features and / or lighting features. The background texture features are used to represent the relative position relationship of each color block in the scene texture map, and the lighting features are used to represent the light and dark relationship of each color block in the scene texture map.
[0135] Furthermore, the process of superimposing the blurred color blocks in the arrangement order to obtain an oil painting stylized scene can be implemented as: for each blurred color block, based on the color block range and the arrangement order of each color block, the color blocks are superimposed in a three-dimensional scene including a contour line to obtain an oil painting stylized scene.
[0136] Thus, through this embodiment, the blurred color blocks can be superimposed in the arrangement order to obtain the finally displayed oil painting stylized scene, creating a relatively three-dimensional visual effect and greatly enhancing the texture of the oil painting stylized scene.
[0137] It should be noted that the execution subject of each step of the method provided in the above embodiments can be the same device, or the method can also be executed by different devices as the execution subject. For example, the execution subject of steps 101 to 104 can be device A; for another example, the execution subject of steps 101 and 102 can be device A, and the execution subject of step 103 can be device B; and so on.
[0138] In addition, in some of the processes described in the above embodiments and the accompanying drawings, a plurality of operations appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order in which they appear herein or may be executed in parallel. The serial numbers of the operations, such as 101, 102, etc., are only used to distinguish different operations, and the serial numbers themselves do not represent any order of execution. In addition, these processes may include more or fewer operations, and these operations may be executed in sequence or in parallel. It should be noted that the descriptions such as "first" and "second" in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequence, nor do they limit that "first" and "second" are of different types.
[0139] Figure 6 is a schematic structural diagram of an electronic device provided by an exemplary embodiment of the present application. As Figure 6 shown, the electronic device includes: a memory 601, a processor 602, a communication component 603, and a display component 604.
[0140] The memory 601 is used to store computer programs and can be configured to store various other data to support operations on the electronic device. Examples of these data include instructions for any application program or method for operating on the electronic device, contact data, phone book data, messages, pictures, videos, etc.
[0141] Among them, the memory 601 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, a magnetic disk, or an optical disc.
[0142] The processor 602 is coupled to the memory 601 and is used to execute the computer program in the memory 601 for: for a three-dimensional scene to be processed, determining the positions where the outlining lines are located in each scene element model; according to the positions where the outlining lines are located, performing outlining coloring on each scene element model to obtain a three-dimensional scene including the outlining lines; in the three-dimensional scene including the outlining lines, performing blurring processing on the scene color of the three-dimensional scene according to the texture coordinates of each pixel in the three-dimensional scene to obtain an oil painting stylized scene.
[0143] Further optionally, the oil painting stylized scene is displayed through the display component 604.
[0144] Further optionally, when the processor 602 performs blurring processing on the scene color of the three-dimensional scene according to the texture coordinates of each pixel in the three-dimensional scene, it is specifically used for:
[0145] According to the texture coordinates of each pixel in the three-dimensional scene, with each pixel in the three-dimensional scene as the center, divide the corresponding coordinate range in the screen space coordinate system;
[0146] According to the coordinate range corresponding to each pixel, perform blurring processing on the scene color of each pixel to obtain the target scene color of each pixel in the oil painting stylized scene.
[0147] Among them, further optionally, when the processor 602 divides the corresponding coordinate range in the screen space coordinate system with each pixel in the three-dimensional scene as the center according to the texture coordinates of each pixel in the three-dimensional scene, it is specifically used for:
[0148] For each pixel in the three-dimensional scene, offset the texture coordinates of the current pixel in the screen space coordinate system to obtain the coordinate range corresponding to the current pixel.
[0149] Among them, further optionally, the current pixel corresponds to the first coordinate range. Based on this, when the processor 602 performs blurring processing on the scene color of each pixel according to the coordinate range corresponding to each pixel to obtain the target scene color of each pixel in the oil painting stylized scene, it is specifically used for:
[0150] According to the texture coordinates of the current pixel and its surrounding pixels in the first coordinate range, obtain the scene colors of the current pixel and its surrounding pixels from the scene texture map; perform weighted average calculation on the scene colors of the current pixel and its surrounding pixels in the first coordinate range according to the preset weight parameters to obtain the weighted average value of the scene colors, and use the weighted average value as the target scene color of the current pixel.
[0151] Among them, further optionally, the current pixel corresponds to the first coordinate range. Based on this, when the processor 602 performs blurring processing on the scene color of each pixel according to the coordinate range corresponding to each pixel to obtain the target scene color of each pixel in the oil painting stylized scene, it is specifically used for:
[0152] According to the texture coordinates of the current pixel and its surrounding pixels in the first coordinate range, obtain the scene colors of the current pixel and its surrounding pixels from the scene texture map; obtain the similarity between the scene color of the current pixel and the scene colors of its surrounding pixels; fuse the scene colors of the surrounding pixels whose similarity is in the preset order with the scene color of the current pixel, and use the fused scene color as the target scene color of the current pixel.
[0153] Further optionally, the outline line includes a contour line and / or a polyline. The contour line is an outline line used to represent the external contour of the model, and the polyline is an outline line used to represent the internal contour of the model.
[0154] When determining the position of the outlining line in each scene element model, the processor 602 is specifically configured to: obtain the edge pixels on the contour line and / or the folding line of each scene element model in the screen space coordinate system.
[0155] Further optionally, if the outlining line includes a contour line, when obtaining the edge pixels on the contour line and / or the folding line of each scene element model in the screen space coordinate system, the processor 602 is specifically configured to:
[0156] For each pixel to be detected in the scene element model, offset the texture coordinates of the current pixel in the screen space coordinate system to obtain the texture coordinates of the surrounding pixels; wherein, the offset direction is the normal direction of the current pixel, and the offset distance is the product of the scene depth of the current pixel and the offset coefficient;
[0157] According to the texture coordinates of the current pixel and the surrounding pixels, obtain the scene depths of the current pixel and the surrounding pixels from the scene texture map; if the difference in the scene depths between the current pixel and the surrounding pixels is greater than the set depth difference threshold, then use the current pixel as the edge pixel on the contour line of the scene element model.
[0158] Further optionally, if the outlining line includes a folding line, when obtaining the edge pixels on the contour line and / or the folding line of each scene element model in the screen space coordinate system, the processor 602 is specifically configured to:
[0159] For each pixel to be detected in the scene element model, offset the texture coordinates of the current pixel in the screen space coordinate system to obtain the texture coordinates of the surrounding pixels; wherein, the offset direction is the normal direction of the current pixel, and the offset distance is the product of the scene depth of the current pixel and the offset coefficient; according to the texture coordinates of the current pixel and the surrounding pixels, obtain the normal values of the current pixel and the surrounding pixels from the scene texture map; if the difference in the normal values between the current pixel and the surrounding pixels is greater than the set normal value difference threshold, then use the current pixel as the edge pixel on the folding line of the scene element model.
[0160] Further optionally, when performing outlining coloring on each scene element model according to the position of the outlining line to obtain a three-dimensional scene including the outlining line, the processor 602 is specifically configured to:
[0161] Generate a first mask map including the edge pixels in each scene element model according to the edge pixels on the outlining line in each scene element model; perform linear interpolation between the edge pixels in the first mask map according to the scene colors of the edge pixels to obtain a three-dimensional scene including the outlining line.
[0162] Among them, further optionally, the processor 602 is further configured to: sample the three-dimensional noise map according to the texture coordinates of each edge pixel to obtain the noise value corresponding to each edge pixel; perform an offset process on the scene color of each edge pixel according to the noise value corresponding to each edge pixel to obtain a three-dimensional scene including discontinuous outline lines.
[0163] Further optionally, the processor 602 is further configured to: filter the target scene elements that do not require blurring processing by using a custom depth template item; generate a second mask map for marking the target scene elements according to the filtering result, and the second mask map is used to represent the position where the target scene elements are located.
[0164] Further optionally, the processor 602 is further configured to: filter the occluded scene elements by using a custom depth template item; generate a third mask map for marking the occluded scene elements according to the filtering result, and the third mask map is used to represent the position where the occluded scene elements are located.
[0165] Further optionally, the processor 602 is further configured to: determine each color patch where each pixel is located in the scene texture map based on the coordinate range corresponding to each pixel; determine the arrangement order of each color patch in the scene texture map; superimpose the blurred color patches in the arrangement order to obtain an oil painting stylized scene.
[0166] Among them, further optionally, the processor 602 determines the arrangement order of each color patch in the scene texture map for:
[0167] Obtain the visual features of each color patch from the scene texture map according to the pixel texture coordinates of each color patch; wherein, the visual features include background texture features and / or lighting features, the background texture features are used to represent the relative position relationship of each color patch in the scene texture map, and the lighting features are used to represent the light and shade relationship of each color patch in the scene texture map; determine the color patch range and arrangement order corresponding to each color patch based on the visual features.
[0168] Among them, further optionally, the processor 602 superimposes the blurred color patches in the arrangement order to obtain an oil painting stylized scene for: for each blurred color patch, superimpose each color patch in the three-dimensional scene including outline lines based on the color patch range and arrangement order of each color patch to obtain an oil painting stylized scene.
[0169] Further, as Figure 6 shown, the electronic device further includes: a power supply component 605, an audio component 606 and other components. Figure 6 Only some components are schematically shown, and it does not mean that the electronic device only includes Figure 6 the components shown.
[0170] Among them, the communication component 603 is configured to facilitate communication, in a wired or wireless manner, between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on communication standards, such as WiFi, 2G, 3G, 4G, or 5G, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component can be implemented based on near field communication (NFC) technology, radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0171] Among them, the display component 604 can be implemented as a display, which includes a screen, and the screen can include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen can be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can not only sense the boundaries of touch or swipe actions, but also detect the duration and pressure associated with the touch or swipe operations.
[0172] Among them, the power supply component 605 supplies power to various components of the device where the power supply component is located. The power supply component can include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the device where the power supply component is located.
[0173] Accordingly, an embodiment of the present application further provides a computer-readable storage medium storing a computer program, and when the computer program is executed, it can implement each step executable by an electronic device in the above method embodiment.
[0174] Those skilled in the art should understand that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0175] This application is described with reference to the flowcharts and / or block diagrams of methods, apparatuses (systems), and computer program products according to embodiments of the present application. It should be understood that each flow and / or block in the flowchart and / or block diagram, as well as the combination of flows and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing devices to generate a machine, such that the instructions executed by the processor of the computer or other programmable data processing devices generate a device for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or a device for implementing the functions specified in multiple blocks.
[0176] These computer program instructions can also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, such that the instructions stored in the computer-readable memory generate a manufactured article including an instruction device that implements the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or a device for implementing the functions specified in multiple blocks.
[0177] These computer program instructions can also be loaded onto a computer or other programmable data processing device, such that a series of operation steps are executed on the computer or other programmable device to generate a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one process Figure 1 one process or multiple processes and / or blocks Figure 1 or a device for implementing the functions specified in multiple blocks.
[0178] In a typical configuration, a computing device includes one or more processors (CPUs), an input / output interface, a network interface, and a memory. The memory may include non-permanent memory in the form of computer-readable media, random access memory (RAM), and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. The memory is an example of computer-readable media.
[0179] The above are only embodiments of the present application and are not used to limit the present application. For those skilled in the art, various changes and modifications can be made to the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.
Claims
1. A method for rendering a scene in an oil painting style, characterized in that, the method includes: For a three-dimensional scene to be processed, determine the positions of the outlining lines in each scene element model, where the outlining lines include the outlining lines for representing the external contour of the scene element model and the outlining lines for representing the internal contour of the scene element model; Determine the edge pixels located on the outlining lines according to the positions of the outlining lines; Perform outlining coloring on each scene element model according to the scene colors of the edge pixels and the pre-set outlining line colors to obtain a three-dimensional scene including the outlining lines; In the three-dimensional scene including the outlining lines, fuse the scene colors of each pixel and the surrounding pixels corresponding to each pixel according to the texture coordinates of each pixel in the three-dimensional scene to simulate the brushstrokes in an oil painting style in the three-dimensional scene and obtain an oil painting style scene.
2. The method according to claim 1, characterized in that, the blurring the scene colors of the three-dimensional scene according to the texture coordinates of each pixel in the three-dimensional scene includes: According to the texture coordinates of each pixel in the three-dimensional scene, with each pixel in the three-dimensional scene as the center, divide the respective corresponding coordinate ranges in the screen space coordinate system; Blur the scene colors of each pixel according to the coordinate ranges corresponding to each pixel to obtain the target scene colors of each pixel in the oil painting style scene.
3. The method according to claim 2, characterized in that, the dividing the respective corresponding coordinate ranges in the screen space coordinate system with each pixel in the three-dimensional scene as the center according to the texture coordinates of each pixel in the three-dimensional scene includes: For each pixel in the three-dimensional scene, offset the texture coordinates of the current pixel in the screen space coordinate system to obtain the coordinate range corresponding to the current pixel.
4. The method according to claim 2, characterized in that, the current pixel corresponds to a first coordinate range; the blurring the scene colors of each pixel according to the coordinate ranges corresponding to each pixel to obtain the target scene colors of each pixel in the oil painting style scene includes: Obtain the scene colors of the current pixel and the surrounding pixels from the scene texture map according to the texture coordinates of the current pixel and the surrounding pixels in the first coordinate range; Perform a weighted average calculation on the scene colors of the current pixel and the surrounding pixels in the first coordinate range according to the pre-set weight parameters to obtain the weighted average value of the scene colors, and use the weighted average value as the target scene color of the current pixel.
5. The method according to claim 2, characterized in that, the current pixel corresponds to a first coordinate range; the blurring the scene colors of each pixel according to the coordinate ranges corresponding to each pixel to obtain the target scene colors of each pixel in the oil painting style scene includes: Obtain the scene colors of the current pixel and the surrounding pixels from the scene texture map according to the texture coordinates of the current pixel and the surrounding pixels in the first coordinate range; Obtain the similarity between the scene color of the current pixel and the scene colors of the surrounding pixels; Fuse the scene colors of the surrounding pixels whose similarity is in the preset order with the scene color of the current pixel, and use the fused scene color as the target scene color of the current pixel.
6. The method according to claim 2, wherein, further comprising: Determine each color patch where each pixel is located in the scene map based on the coordinate range corresponding to each pixel; Determine the arrangement order of each color patch in the scene map; Superimpose the blurred color patches in the said arrangement order to obtain an oil painting stylized scene.
7. The method according to claim 6, wherein, The determination of the arrangement order of each color patch in the scene map includes: Obtain the visual features of each color patch from the scene map according to the pixel texture coordinates of each color patch; wherein, the visual features include background texture features and / or lighting features, the background texture features are used to represent the relative position relationship of each color patch in the scene map, and the lighting features are used to represent the light and shade relationship of each color patch in the scene map; Determine the color patch range and arrangement order corresponding to each color patch based on the visual features; The superimposing the blurred color patches in the said arrangement order to obtain an oil painting stylized scene includes: For each blurred color patch, based on the color patch range and arrangement order of each color patch, superimpose each color patch in the three-dimensional scene containing the outline line to obtain an oil painting stylized scene.
8. The method according to claim 1, wherein, The outline line includes a contour line and / or a polyline. The contour line is an outline line used to represent the external contour of the model, and the polyline is an outline line used to represent the internal contour of the model; The determination of the position where the outline line is located in each scene element model includes: Obtain the edge pixels on the contour line and / or polyline of each scene element model in the screen space coordinate system.
9. The method according to claim 8, wherein, If the outline line includes a contour line, the obtaining the edge pixels on the contour line and / or polyline of each scene element model in the screen space coordinate system includes: For each pixel to be detected in each scene element model, offset the texture coordinates of the current pixel in the screen space coordinate system to obtain the texture coordinates of the surrounding pixels; wherein, the offset direction is the normal direction of the current pixel, and the offset distance is the product of the scene depth of the current pixel and the offset coefficient; Obtain the scene depths of the current pixel and the surrounding pixels from the scene map according to the texture coordinates of the current pixel and the surrounding pixels; If the scene depth difference between the current pixel and the surrounding pixels is greater than the set depth difference threshold, use the current pixel as the edge pixel on the contour line of the scene element model.
10. The method according to claim 8, wherein, If the outline line includes a polyline, the obtaining the edge pixels on the contour line and / or polyline of each scene element model in the screen space coordinate system includes: For each pixel to be detected in the scene element model, offset the texture coordinates of the current pixel in the screen space coordinate system to obtain the texture coordinates of the surrounding pixels; wherein, the offset direction is the normal direction of the current pixel, and the offset distance is the product of the scene depth of the current pixel and the offset coefficient. Obtain the normal values of the current pixel and the surrounding pixels from the scene texture map according to the texture coordinates of the current pixel and the surrounding pixels. If the difference between the normals of the current pixel and the surrounding pixels is greater than the set normal difference threshold, then use the current pixel as the edge pixel on the fold line in the scene element model.
11. According to the method described in claim 1, wherein, the step of performing stroke coloring on each scene element model according to the position of the stroke line to obtain a three-dimensional scene including the stroke line includes: Generating a first mask map including the edge pixels in each scene element model according to the edge pixels on the stroke line in each scene element model; Performing linear interpolation between the edge pixels in the first mask map according to the scene colors of the edge pixels to obtain a three-dimensional scene including the stroke line.
12. According to the method described in claim 1, wherein, further comprising: Filtering the target scene elements that do not require blur processing using a custom depth template item; Generating a second mask map for marking the target scene elements according to the filtering result, and the second mask map is used to represent the position where the target scene elements are located.
13. According to the method described in claim 1, wherein, further comprising: Filtering the occluded scene elements using a custom depth template item; Generating a third mask map for marking the occluded scene elements according to the filtering result, and the third mask map is used to represent the position where the occluded scene elements are located.
14. An electronic device, wherein, comprising: A memory and a processor; The memory is used to store one or more computer instructions; The processor is used to execute the one or more computer instructions for: performing the steps in the method described in any one of claims 1-13.
15. A computer-readable storage medium, wherein, The computer-readable storage medium stores a computer program; When the computer program is executed, it is used to implement the steps in the method described in any one of claims 1-13.
Citation Information
Patent Citations
Model rendering method and device
CN112070873A