Method and apparatus for simulating oil painting

By rendering the pigment color and transparency of each pixel, overlaying the transparency of the current frame, and adjusting the pigment color in combination with preset lighting parameters, the problem of electronic drawing in existing technologies being unable to simulate the effect of real painting is solved, achieving a more realistic and three-dimensional painting effect.

CN119494886BActive Publication Date: 2026-01-02DARK MATTER ARTIFICIAL INTELLIGENT (BEIJING) TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411501246.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-10-25
Publication Date
2026-01-02
Estimated Expiration
2044-10-25

AI Technical Summary

Technical Problem

Existing digital drawing technologies struggle to accurately replicate the pigment build-up, natural diffusion of brushstrokes, and brush texture effects found in real paintings, resulting in a user experience that differs from that of real paintings.

Method used

By rendering the pigment color and transparency of each pixel, and overlaying the transparency of the current frame with that of the previous frame, and adjusting the pigment color in combination with preset lighting parameters, the painting simulates the mixing and overlay of real pigments on the canvas, generating a more realistic and three-dimensional painting.

Benefits of technology

It enhances the realism of the painting, simulates the light and shadow effects of pigment colors, and enhances the visual depth and three-dimensionality of the work.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119494886B_ABST
    Figure CN119494886B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method and device for simulating oil painting, comprising: in response to a movement of a control touch point, generating an initial image of a current frame by rendering a pigment color and transparency of each pixel point generated by the movement of the control touch point on a canvas; determining an intermediate image by superimposing the transparency of each corresponding pixel point in the initial image of the current frame and a display image of a previous frame; and adjusting the pigment color corresponding to each pixel point in the intermediate image according to a preset lighting parameter to determine a display image of the current frame, so as to improve the authenticity of the simulated painting.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the field of electronic simulation of painting, and in particular to a method and device for simulating oil painting. BACKGROUND

[0002] With the development of digital technology, electronic drawing devices such as mobile terminals, digitizing tablets and digitizing screens have gradually become part of the creation tools. These devices can convert hand-drawn strokes into digital signals and reproduce them on a computer through software.

[0003] However, existing electronic drawing technology still has many challenges in simulating real painting effects, such as pigment accumulation on a real canvas, natural diffusion of strokes, and texture effects of brushes, which are difficult to accurately reproduce in electronic drawing. Although some electronic drawing software attempts to simulate these effects by increasing the types of brushes and adjusting the parameters of the brushes, users still have difficulty obtaining a completely consistent experience with real painting. SUMMARY

[0004] To overcome the problems in the related art, the present disclosure provides a method for simulating oil painting, comprising:

[0005] In response to moving a control touch point, an initial image of a current frame is generated by rendering the color and transparency of each pixel point generated by the movement of the control touch point on the canvas;

[0006] An intermediate image is determined by superimposing the transparency of each corresponding pixel point in the initial image of the current frame and the display image of the previous frame;

[0007] The color of each pixel point in the intermediate image is adjusted according to a preset lighting parameter to determine a display image of the current frame.

[0008] Optionally, in response to moving a control touch point, an initial image of a current frame is generated by rendering the color and transparency of each pixel point generated by the movement of the control touch point on the canvas, comprising:

[0009] In response to moving the control touch point, the current position and moving direction of the control touch point are determined;

[0010] A brush following the movement of the control touch point is generated according to a preset brush parameter, the current position and moving direction of the control touch point;

[0011] The color and transparency of each pixel point in the image generated by the movement of the brush on the canvas are rendered to determine the initial image of the current frame.

[0012] Optionally, the generating the brush following the movement of the control touch point according to the preset brush parameter, the current position and the moving direction of the control touch point comprises:

[0013] determining the positions of the plurality of bristle vertices within a preset range of the control touch point according to the current position of the control touch point;

[0014] determining the bristle corresponding to each of the bristle vertices according to the preset brush parameter, the moving direction of the control touch point and the position of each of the bristle vertices;

[0015] generating the brush following the movement of the control touch point according to the plurality of determined bristles.

[0016] Optionally, the preset brush parameter comprises a preset vertex interval and a preset bristle length, and the determining the bristle corresponding to each of the bristle vertices according to the preset brush parameter, the moving direction of the control touch point and the position of each of the bristle vertices comprises:

[0017] for any one of the bristle vertices, determining the next bristle vertex corresponding to the bristle vertex in sequence within the preset bristle length according to the position of the bristle vertex, the moving direction of the control touch point and the preset vertex interval, and filling a plurality of patches of a preset shape size between any two adjacent bristle vertices to obtain the bristle corresponding to the bristle vertex.

[0018] Optionally, the determining the initial image of the current frame by rendering the color and transparency of each pixel point in the image generated by the movement of the brush on the canvas comprises:

[0019] determining the initial image of the current frame by rendering the color and transparency of each pixel point in the image generated by the movement of the brush on the canvas according to a preset rendering parameter, the preset rendering parameter comprising that the transparency of the pixel point gradually decreases away from the bristle axis, the bristle axis being a line segment composed of any two adjacent bristle vertices.

[0020] Optionally, the determining the display image of the current frame by adjusting the color of each pixel point in the intermediate image according to a preset lighting parameter comprises:

[0021] determining the base color and transparency of a target pixel point, the target pixel point being any pixel point in the intermediate image;

[0022] determining the normal vector of the target pixel point according to the transparency of a plurality of adjacent pixel points within a unit distance range of the target pixel point;

[0023] adjust the base pigment color of the target pixel point according to the preset lighting parameter and the normal vector of the target pixel point, to determine a target pigment color of the target pixel point;

[0024] determine the display image of the current frame according to the target pigment colors of the plurality of target pixel points.

[0025] Optionally, the adjusting the base pigment color of the target pixel point according to the preset lighting parameter and the normal vector of the target pixel point, to determine a target pigment color of the target pixel point, comprises:

[0026] determining a target highlight value and an initial pigment color based on diffuse reflection of the target pixel point according to the preset lighting parameter, the base pigment color of the target pixel point and the normal vector of the target pixel point;

[0027] determining the target pigment color of the target pixel point according to the initial pigment color of the target pixel point and the target highlight value.

[0028] Optionally, the preset lighting parameter comprises a light source unit vector, a line-of-sight unit vector, a diffuse reflection weight, a direct light color and a highlight parameter, and the determining a target highlight value and an initial pigment color based on diffuse reflection of the target pixel point according to the preset lighting parameter, the base pigment color of the target pixel point and the normal vector of the target pixel point, comprises:

[0029] determining a diffuse reflection value according to the light source unit vector and the normal vector of the target pixel point

[0030] determining the initial pigment color based on diffuse reflection of the target pixel point according to the base pigment color of the target pixel point, the diffuse reflection value and the diffuse reflection weight;

[0031] determining an initial highlight value according to the direct light color, the light source unit vector, the line-of-sight unit vector and the highlight parameter;

[0032] determining the target highlight value according to the initial highlight value and a preset highlight weight.

[0033] Optionally, the determining the display image of the current frame according to the target pigment colors of the plurality of target pixel points, comprises:

[0034] determining an initial position and an initial moving speed of each pixel point in the intermediate image, the initial moving speed of each pixel point being the same as the moving speed of the control touch point corresponding to the pixel point;

[0035] determine a target position of each pixel point after flowing according to the preset flowing deceleration and the initial position and the initial moving speed of each pixel point in the intermediate image;

[0036] determine the display image of the current frame according to the target pigment color and the target position of each pixel point.

[0037] The present disclosure also provides a device for simulating oil painting, comprising:

[0038] a generating module configured to generate an initial image of a current frame by rendering the pigment color and the transparency of each pixel point in response to the movement of the control touch point on the canvas;

[0039] a superimposing module configured to determine an intermediate image by superimposing the transparency of each corresponding pixel point in the initial image of the current frame and the display image of the previous frame;

[0040] an adjusting module configured to adjust the pigment color corresponding to each pixel point in the intermediate image according to preset lighting parameters to determine the display image of the current frame.

[0041] The present disclosure also provides a computer readable storage medium having computer program instructions stored thereon, which, when executed by a processor, implement the method for simulating oil painting provided by the present disclosure.

[0042] The technical solutions provided by the embodiments of the present disclosure can have the following beneficial effects:

[0043] By rendering the pigment color and the transparency of each pixel point and superimposing the transparency of the initial image of the current frame and the display image of the previous frame, the mixing and superimposition of real pigments on the canvas can be simulated, and the realism of the painting work is enhanced. In addition, the pigment color can be adjusted according to the preset lighting parameters to simulate the painting effect under different lighting conditions, and the visual depth and stereoscopic effect of the work are enhanced.

[0044] It should be understood that the foregoing general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF DRAWINGS

[0045] The accompanying drawings, which are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present disclosure and, together with the specification, serve to explain the principles of the present disclosure.

[0046] Figure 1 is a schematic diagram of an existing electronic painting method according to an exemplary embodiment.

[0047] Figure 2is a flowchart of a method of simulating oil painting according to an example embodiment.

[0048] Figure 3 is a schematic diagram of determining a brush tip according to an example embodiment.

[0049] Figure 4 is a schematic diagram of determining a brush tip according to an example embodiment.

[0050] Figure 5 is a block diagram of an apparatus of simulating oil painting according to an example embodiment.

[0051] Figure 6 is a block diagram of an electronic device according to an example embodiment.

[0052] Figure 7 is a block diagram of an electronic device according to an example embodiment. DETAILED DESCRIPTION

[0053] The example embodiments will be described in detail herein with reference to the attached drawings. In the following description, same numbers refer to same elements in all figures. The following detailed description includes specific details for the purpose of providing a thorough understanding of the example embodiments. However, it will be apparent to those skilled in the art that the example embodiments can be practiced without these specific details. In some instances, well-known structures and components are not described in detail in order to avoid obscuring the example embodiments.

[0054] Conventional electronic painting is usually an image formed by superimposing single shapes on a canvas, such as Figure 1 As shown, as the control touch point moves on the canvas, a plurality of sampling points are determined by a fixed sampling frequency, and a drawing pattern is formed by filling lines between the sampling points with a Bezier curve. This way of forming a drawing pattern does not have the details of a real brush, such as texture, brush shape, pigment thickness, and shading, etc.

[0055] In view of this, the present disclosure provides a method of simulating oil painting to improve the realism of electronic painting.

[0056] Figure 2 is a flowchart of a method of simulating oil painting according to an example embodiment, as shown in Figure 2 includes the following steps.

[0057] In step S11, in response to moving the control touch point, an initial image of a current frame is generated by rendering the pigment color and transparency of each pixel point generated by the movement of the control touch point on the canvas.

[0058] It is worth mentioning that the simulation oil painting method provided by the present disclosure can be applied to various electronic device platforms, such as painting software in computers and mobile terminals, in which the painting effect can be freely configured, such as basic pigment color and brush type. When the configuration is completed, the user can move the control touch point on the canvas by moving the mouse, the touch screen pen, or directly by the finger on the touch screen.

[0059] In an embodiment, when the user moves the touch pen on the touch screen or the touch pad, the device captures the position coordinates of the touch pen in real time. According to the preconfigured brush style and the moving track of the control touch point, the image contour that the user wants to draw can be obtained. The pigment color and the transparency of each pixel point in the image contour are rendered by a shader to obtain an initial image.

[0060] In the initial image, the pigment color and the transparency rendering mode can be freely set by the user.

[0061] In step S12, an intermediate image is determined by superimposing the transparency of each corresponding pixel point in the initial image of the current frame and the display image of the previous frame.

[0062] In actual oil painting, when the brush is pressed on the canvas, the pigment on the brush will leave the pigment in the shape of the brush on the canvas, and the pigment in the center of the brush is the thickest, and the pigment gradually thins out on both sides of the center axis of the brush. Based on this feature, in order to make the display image have a more accurate pigment effect, the thickness of the pigment can be simulated by the transparency of the pixel point, for example, the brush is moved back and forth in the same area, and the pigment in the initial image generated by each frame is in the same position. The transparency of each corresponding pixel point in the initial image of the current frame and the display image of the previous frame is superimposed and summed to determine the transparency of each pixel point in the display image of the current frame, so as to obtain a visual effect of deeper color while keeping the pigment color unchanged, thereby improving the visual level of the display image.

[0063] In the display image of the previous frame, the display image of the previous frame is determined according to the initial image of the previous frame.

[0064] For example, the transparency of the pixel point can be fused by the blending mode SrcAlpha OneMinusSrcAlpha, and the pigment color and the transparency of each pixel point in the intermediate image are obtained by using the superimposed transparency value and combining the pigment color of the initial image of the current frame.

[0065] In step S13, the pigment color corresponding to each pixel point in the intermediate image is adjusted according to the preset lighting parameter to determine the display image of the current frame.

[0066] The preset light parameter is used to represent the position, intensity, color, direction and line of sight angle of the light source, so that the color of the paint corresponding to each pixel point in the intermediate image is adjusted through the preset light parameter, and the light performance of different paint colors, such as highlight effect, diffuse reflection effect, mirror effect and reflection effect, can be obtained.

[0067] For example, by adjusting the color of the light source through the preset light parameter, a warm light source can add an orange tone to the display image, and a cold light source can make the display image blue.

[0068] By rendering the color and transparency of the paint of each pixel point, and superimposing the initial image of the current frame and the transparency of the display image of the last frame, the mixing and superposition of real paint on the canvas can be simulated, and the realism of the painting work is enhanced. In addition, the paint color is adjusted according to the preset light parameter, the painting effect under different light conditions can be simulated, and the visual depth and stereoscopic sense of the work are enhanced.

[0069] Optionally, the above step S11 can be performed by the following steps.

[0070] First, in response to moving the control touch point, the current position and movement direction of the control touch point are determined.

[0071] In an embodiment, when the control touch point moves on the canvas, each frame corresponds to a coordinate, that is, the current position of the control touch point in each frame, and each frame corresponds to a movement direction.

[0072] Then, according to the preset brush parameter, the current position and movement direction of the control touch point, a brush following the movement of the control touch point is generated.

[0073] The preset brush parameter includes at least one of preset vertex spacing, preset bristle length, preset brush size, preset brush shape, preset brush hardness, preset brush angle, and preset brush texture.

[0074] In an embodiment, a brush model can be generated according to the preset brush parameter, and the brush model includes a vector defining the shape and distribution of the brush and a particle system simulating real bristles.

[0075] The brush is dynamically generated according to the position and movement direction of the control touch point, so that each stroke has unique dynamic characteristics, enhancing the naturalness and expressiveness of the painting. The position of the bristle vertex and the corresponding bristle are determined by the preset brush parameter, which can simulate the physical characteristics of a real brush.

[0076] Finally, the initial image of the current frame is determined by rendering the color and transparency of the paint of each pixel point in the image generated by the movement of the brush on the canvas.

[0077] The initial image is a still image of the image rendered by the brush moving on the canvas.

[0078] In an embodiment, first, as the brush moves on the canvas, an outline image of the brush including a plurality of bristles in the brush is created on the canvas, the outlines representing the shape of the bristles, then, based on a pre-configured base paint color, the created outline image of the bristles is rendered by a shader to obtain an initial image including the position, distribution and concentration information of the paint applied by the brush on the canvas, wherein the shader code usually includes a vertex shader and a fragment shader, the vertex shader processes the vertex data of the graphics, and the fragment shader is responsible for calculating the color and transparency of each pixel point, and finally, the rendered initial image is temporarily stored in a buffer area, and the drawing is repeatedly called every frame as the data basis for making intermediate images.

[0079] By the above method, the movement of the control touch point on the digital canvas is simulated, the brush effect is generated, and the paint color and transparency of each pixel point are rendered, so that the electronic drawing process is more natural and close to the traditional drawing experience, and the brush effect is dynamically generated according to the movement speed and direction of the control touch point, so that each stroke has unique dynamic characteristics, and the user can accurately control the movement of the brush to achieve fine drawing details.

[0080] Optionally, the generating the brush following the movement of the control touch point according to the preset brush parameters, the current position and the moving direction of the control touch point comprises:

[0081] First, according to the current position of the control touch point, the positions of a plurality of bristle vertices within the preset range of the control touch point are determined.

[0082] In an embodiment, referring to Figure 3 As shown, the polar coordinates can be used to generate the brush shape within a circle with a radius R and the current position p0 of the control touch point as the center, the generated circle is the preset range of the control touch point, within the generated circle, a floating point number in the range of 0 to R is generated by using the random number method random(r, 0, R) and assigned to r, a floating point number in the range of 0 to 2π is generated by using the random number method random(θ, 0, 2π) and assigned to θ, and finally the position coordinates (r*cosθ, r*sinθ) of a bristle vertex are obtained, and the above process is repeated multiple times to generate a plurality of bristle vertices.

[0083] Each bristle vertex corresponds to a bristle.

[0084] Secondly, according to the preset brush parameter, the moving direction of the control touch point and the position of each brush hair vertex, the brush hair corresponding to each brush hair vertex is determined.

[0085] In an embodiment, each brush hair can include a plurality of brush hair vertices, and the more the brush hair vertices, the better the combing simulation effect. A pattern formed by sequentially connecting the plurality of brush hair vertices is determined as the combing.

[0086] Thirdly, according to the plurality of determined brush hairs, a brush is generated following the movement of the control touch point.

[0087] In an embodiment, in order to simulate the physical characteristics of the brush, such as thickness and shape, a solid rectangle (usually a quadrilateral or a triangle) can be used to represent each node or a group of nodes of the brush, for example, the rectangular patches are arranged along the path of the brush, and the position and shape of the brush hair in the three-dimensional space are defined by the brush hair vertex data, so that the brush hair of the brush is simulated, and then the camera is used to render the brush hair entity, for example, in a three-dimensional graphics engine, through the camera view angle, the solid rectangle of the brush can be rendered into a two-dimensional image.

[0088] Optionally, the preset brush parameter includes a preset vertex interval and a preset brush hair length, and the determination of the brush hair corresponding to each brush hair vertex according to the preset brush parameter, the moving direction of the control touch point and each brush hair vertex includes:

[0089] For any brush hair vertex, the next brush hair vertex corresponding to the brush hair vertex is sequentially determined within the preset brush hair length according to the position of the brush hair vertex, the moving direction of the control touch point and the preset vertex interval, and a plurality of patches of a preset shape size are filled between any two adjacent brush hair vertices to obtain the brush hair corresponding to the brush hair vertex.

[0090] In an embodiment, referring to FIG. 1, Figure 4 for any brush hair vertex p n (x n , y n ), the next brush hair vertex p n+1 (x n+1 , y n+1 ) of the brush hair vertex can be determined by the following calculation formula 1, wherein n∈(0, N), and N is a natural number.

[0091] Calculation formula 1: p n+1 (x n+1 , y n+1 ) = p n (x n , y n ) + v n.normal *size, wherein v n.normalTo control the moving direction v of the contact n of the direction vector, size is a preset vertex distance.

[0092] Determine the k bristle vertices in sequence, so that (k-1) * size < L, L is a preset bristle length, and fill the facets of a preset shape size between any two adjacent bristle vertices to obtain the initial determined comb corresponding to the bristle vertex.

[0093] Optionally, the initial image of the current frame is determined by rendering the pigment color and transparency of each pixel point in the image generated by the movement of the brush on the canvas.

[0094] According to the preset rendering parameter, the pigment color and transparency of each pixel point in the image generated by the movement of the brush on the canvas are rendered to determine the initial image of the current frame, and the preset rendering parameter includes that the transparency of the pixel point gradually decreases away from the bristle axis, and the bristle axis is a line segment composed of any two adjacent bristle vertices.

[0095] It is worth noting that the initial image is used to determine where to apply the pigment on the canvas, and the initial image includes information such as the distribution of the pigment, the basic pigment color, the transparency and the position of each pixel point.

[0096] In an embodiment, first, in three-dimensional space, in order to simulate the physical properties of the brush such as thickness and shape, the bristles can be filled with solid facets (which can be rectangular or circular), which can be arranged along the connecting path between the bristle vertices to simulate the shape and distribution of the bristles.

[0097] Then, the position, size and direction of each bristle vertex are determined by calculation, which will be used to define the three-dimensional shape of the bristles, including their thickness and spread.

[0098] Thereafter, a camera component in the graphics engine is used to define the perspective of observing these bristle nodes, where the position, angle and field of view of the camera determine how the bristles are presented in the final rendered image, and the bristle nodes are rendered into an initial image through the camera. The process involves material, lighting and shadow calculation to ensure that the bristles look real.

[0099] Finally, the rendered initial image may not be directly displayed on the screen, but used as a data basis for further processing, such as using the rendered initial image as a data basis for calculating the still brush pigment map.

[0100] For example, the initial image can be converted into a texture map to simulate the accumulation and mixing of pigments.

[0101] By simulating the natural distribution of pigments that are thicker in the center of the brush and thinner at the edges, the realism of the rendering effect is improved.

[0102] Optionally, the method further comprises:

[0103] determining the base pigment color and the transparency of a target pixel point, the target pixel point being any pixel point in the intermediate image.

[0104] determining the normal vector of the target pixel point according to the transparency of a plurality of adjacent pixel points within a unit distance range of the target pixel point.

[0105] In an example, a plurality of adjacent pixel points tl, ml, bl, ct, bt, tr, mr, br within a unit distance range of the target pixel point p are determined, and then the normal vector of the target pixel point p is determined through the following calculation formula 2.

[0106] Calculation formula 2:

[0107] normal = (v.x, v.y, normalScale) = (h(tl)-h(tr)+2*h(ml)-2*h(mr)+h(bl)-h(br), h(bl)-h(tl)+2*h(bt)-2*h(ct)+h(br)-h(tr), normalScale)

[0108] wherein v is the direction of the normal vector of the target pixel point P on the canvas plane, normalScale is the size of the normal vector of the target pixel point P in the vertical direction, and normalScale can be dynamically modified to adjust the height difference (transparency) of the pigments, and h is the transparency of the pixel point.

[0109] By considering the normal vector and the pigment thickness (transparency), the reflection and shadow effect of light on different surfaces can be simulated, and the details and depth of the image are increased.

[0110] adjusting the base pigment color of the target pixel point according to the preset lighting parameter and the normal vector of the target pixel point, to determine the target pigment color of the target pixel point.

[0111] determining the display image of the current frame according to the target pigment colors of a plurality of target pixel points.

[0112] In an embodiment, according to preset lighting parameters, a target pigment color of a target pixel point under different lighting conditions and / or different line-of-sight angles can be determined by a lighting model, such as a Phong lighting model or a PBR model, where different lighting effects can correspond to different preset lighting parameters, which can be set by a user through rendering software, for example, preset lighting parameters corresponding to a highlight effect can include a direct light color, a line-of-sight direction, and a highlight parameter, and preset lighting parameters corresponding to a diffuse reflection effect can include a light source direction, a diffuse reflection weight, and a direct light color.

[0113] By simulating the effect of light on pigment color, the realism of the image can be enhanced, making the rendered image closer to the visual effect in the real world, and the lighting effect can be adjusted by adjusting the preset lighting parameters, so that the image can reflect the lighting changes under different times and environments.

[0114] Optionally, the adjusting, according to the preset lighting parameters and the normal vector of the target pixel point, the base pigment color of the target pixel point to determine the target pigment color of the target pixel point comprises:

[0115] According to the preset lighting parameters, the base pigment color of the target pixel point, and the normal vector of the target pixel point, determining a target highlight value and an initial pigment color based on diffuse reflection of the target pixel point.

[0116] According to the initial pigment color of the target pixel point and the target highlight value, determining the target pigment color of the target pixel point.

[0117] In an embodiment, the target pigment color surfaceColor' is the sum of the initial pigment color surfaceColor and the target highlight value Specular'.

[0118] Optionally, the preset lighting parameters include a light source unit vector, a line-of-sight unit vector, a diffuse reflection weight, a direct light color, and a highlight parameter, and the determining, according to the preset lighting parameters, the base pigment color of the target pixel point, and the normal vector of the target pixel point, a target highlight value and an initial pigment color based on diffuse reflection of the target pixel point comprises:

[0119] In a first aspect, according to the light source unit vector and the normal vector of the target pixel point, a diffuse reflection value is determined.

[0120] According to the base pigment color of the target pixel point, the diffuse reflection value, and the diffuse reflection weight, an initial pigment color based on diffuse reflection of the target pixel point is determined.

[0121] It is worth mentioning that in computer graphics, diffuse reflection is the phenomenon that light is uniformly scattered in all directions after being incident on a surface.

[0122] In an embodiment, the diffuse reflection value diffuse can be determined by the following calculation formula 3.

[0123] Calculation formula 3: diffuse = max(0, dot(lightDirection, normal))

[0124] Wherein, lightDirection is a light source unit vector, normal is a normal vector of a target pixel point of the target, and dot is a dot product operation.

[0125] Wherein, the diffuse reflection value represents the angle between the incident light and the surface normal, and the greater the diffuse reflection value, the stronger the diffuse reflection if the angle is closer to 0 degrees (i.e., the closer the normal and the light source direction). In order to avoid the light and dark contrast of the final display image being too strong and affecting the visual experience, a diffuse reflection weight diffuseWeight can be introduced to adjust the contribution of diffuse reflection, and the range of this weight factor is usually between 0 and 1, which determines the degree of influence of diffuse reflection on the final pixel color.

[0126] The initial pigment color surfaceColor after adding the base color value.rgb of the target pixel point and the diffuse reflection can be represented by the following calculation formula 4.

[0127] Calculation formula 4:

[0128] surfaceColor = value.rgb x (diffuse x diffuseWeight + (1.0-diffuseWeight))

[0129] Wherein, (1.0-diffuseWeight) in the formula is used to represent the contribution of ambient light, which ensures that the surface still has a certain brightness even in areas with weak light, thereby avoiding too strong light and dark contrast.

[0130] In one way, the initial pigment color can be adjusted by other lighting parameters such as specular reflection and ambient light by using the Phong model.

[0131] In a second aspect, an initial highlight value is determined according to the direct light color, the light source unit vector, the line of sight unit vector, and the highlight parameter.

[0132] According to the initial highlight value and a preset highlight weight, the target highlight value is determined.

[0133] It is worth mentioning that the high light calculation simulates the reflection of light on a smooth surface.

[0134] In an embodiment, the initial high light value Specular can be determined by the following calculation formula 5.

[0135] Calculation formula 5: Specular=pow(max(dot(lightDirection, halfVector), 0), gloss)

[0136] Wherein, lightColor is the color of direct light, lightDirectio is the unit vector of light source, halfVector is the average of the unit vector of light source and the unit vector of viewDirection, i.e. the half vector, gloss is the high light parameter, which is used to control the sharpness of high light, the greater the gloss value, the sharper the high light.

[0137] The halfVector can be determined by the following calculation formula 6.

[0138] Calculation formula 6: halfVector=(lightDirection+viewDirection) / 2

[0139] In order to avoid excessive distortion of high light, the initial high light value is usually adjusted by high light weight SpecularWeight to determine the target high light value Specular', and the range of SpecularWeight is usually between 0 and 1, which determines the degree of influence of high light on the final pixel color.

[0140] Therefore, the target high light value can be expressed as:

[0141] Calculation formula 7: Specular'=Specular×specularWeight

[0142] In this way, it is ensured that the high light effect is obvious but not too strong, so as to maintain good visual effect. In the actual rendering process, high light calculation is usually combined with other light components such as diffuse reflection and ambient light to obtain the target pigment color.

[0143] Optionally, the method further comprises:

[0144] First, determine the initial position and initial moving speed of each pixel point in the intermediate image, and the initial moving speed of each pixel point is the same as the moving speed of the control touch point corresponding to itself.

[0145] It is worth mentioning that the initial position of the pixel point in the intermediate image is the same as the position of the pixel point in the initial image, that is, the pixel point in the image generated by the movement of the brush on the canvas, and the movement speed of the brush is the movement speed of the control touch point. The initial movement speed of the pixel point generated by the user on the canvas is the same as the movement speed of the control touch point.

[0146] Secondly, according to the preset flow deceleration and the initial position and initial movement speed of each pixel point in the intermediate image, the target position of each pixel point after flow change is determined.

[0147] It is worth mentioning that in actual oil painting, the pigment has fluid characteristics, which is characterized by following the movement of the brush. In electronic painting, the movement speed of each pixel point in the brush movement area can be calculated to simulate the flow characteristics of the pigment.

[0148] In an embodiment, the intermediate image includes a plurality of pixel points generated by the movement of the brush. For each pixel point in the brush movement area, the movement speed thereof is calculated, which can be realized by encoding the direction and speed of the brush movement into a vector. For example, if the brush moves to the right, the encoded speed vector can be (1, 0), and if the brush moves upward, the speed vector can be (0, 1).

[0149] Then, the calculated speed vectors of all pixel points are stored in a cache image. The pixel position is marked by the UV coordinates of the cache image, and the two variables r and g in the pixel value (r, g, b, a) corresponding to the UV coordinates can be used to store the movement speed. For example, if the speed vector is (u, i), r can be set as u and g can be set as i.

[0150] Secondly, the effect of the pigment decelerating over time is simulated by the deceleration formula as shown below.

[0151] The calculation formula 8 is v1=v0*a, wherein 0

[0152] Finally, in each frame, the position of each pixel point is updated according to the stored speed vector, for example, the flow change of the pixel point can be realized by adding the speed vector to the current position.

[0153] Thirdly, the display image of the current frame is determined according to the target pigment color and the target position of each pixel point.

[0154] In an embodiment, the image can be rendered onto the canvas by a shader according to a determined target pigment color and target position of each pixel point to obtain a display image of the current frame.

[0155] The method described above simulates the flow characteristics of oil painting pigments, enhances the realism of the painting, and makes it closer to the visual effect of traditional oil painting. Complex physical effects such as pigment mixing, diffusion and sedimentation can be reproduced in electronic painting.

[0156] Figure 5 is a device block diagram for simulating oil painting according to an exemplary embodiment. Referring to Figure 5 The device 200 includes a generation module 201, an overlay module 202, and an overlay module 203.

[0157] The generation module 201 is configured to generate an initial image of the current frame by rendering the pigment color and transparency of each pixel point generated by moving the control touch point on the canvas in response to the movement of the control touch point.

[0158] The overlay module 202 is configured to determine an intermediate image by overlaying the transparency of each corresponding pixel point in the initial image of the current frame and the display image of the previous frame.

[0159] The adjustment module 203 is configured to adjust the pigment color corresponding to each pixel point in the intermediate image according to a preset lighting parameter to determine the display image of the current frame.

[0160] Optionally, the generation module 201 is configured to:

[0161] In response to moving the control touch point, determine the current position and movement direction of the control touch point.

[0162] According to the preset brush parameter, the current position and movement direction of the control touch point, generate a brush following the movement of the control touch point.

[0163] Determine the initial image of the current frame by rendering the pigment color and transparency of each pixel point in the image generated by moving the brush on the canvas.

[0164] Optionally, the generation module 201 is configured to:

[0165] According to the current position of the control touch point, determine the position of a plurality of bristle vertices within a preset range of the control touch point.

[0166] According to the preset brush parameter, the movement direction of the control touch point, and the position of each bristle vertex, determine the bristle corresponding to each bristle vertex.

[0167] generate a brush following the movement of the control touch point according to the plurality of determined bristles.

[0168] Optionally, the preset brush parameter comprises a preset vertex interval and a preset bristle length, and the generation module 201 is configured to:

[0169] for any vertex of the bristle, determine a next vertex of the bristle corresponding to the vertex according to the position of the vertex, the moving direction of the control touch point and the preset vertex interval, and fill a plurality of patches of a preset shape size between any two adjacent vertices of the bristle to obtain the bristle corresponding to the vertex.

[0170] Optionally, the generation module 201 is configured to:

[0171] render the pigment color and transparency of each pixel point in the image generated by the movement of the brush on the canvas according to preset rendering parameters, and determine the initial image of the current frame, wherein the preset rendering parameters comprise that the transparency of the pixel point gradually decreases away from the bristle axis, and the bristle axis is a line segment composed of any two adjacent vertices of the bristle.

[0172] Optionally, the adjustment module 203 is configured to:

[0173] determine the base pigment color and transparency of a target pixel point, and the target pixel point is any pixel point in the intermediate image.

[0174] determine the normal vector of the target pixel point according to the transparency of a plurality of adjacent pixel points within the unit distance range of the target pixel point.

[0175] adjust the base pigment color of the target pixel point according to the preset lighting parameters and the normal vector of the target pixel point to determine the target pigment color of the target pixel point.

[0176] determine the display image of the current frame according to the target pigment color of a plurality of target pixel points.

[0177] Optionally, the adjustment module 203 is configured to:

[0178] determine the target highlight value and the initial pigment color based on diffuse reflection of the target pixel point according to the preset lighting parameters, the base pigment color of the target pixel point and the normal vector of the target pixel point.

[0179] determine the target pigment color of the target pixel point according to the initial pigment color of the target pixel point and the target highlight value.

[0180] Optionally, the preset lighting parameters comprise a light source unit vector, a line-of-sight unit vector, a diffuse reflection weight, a direct light color, and a highlight parameter, and the adjusting module 203 is configured to:

[0181] determine a diffuse reflection value according to the light source unit vector and a normal vector of the target pixel point

[0182] determine an initial diffuse reflection color of the target pixel point based on diffuse reflection according to a base pigment color of the target pixel point, the diffuse reflection value, and the diffuse reflection weight.

[0183] determine an initial highlight value according to the direct light color, the light source unit vector, the line-of-sight unit vector, and the highlight parameter.

[0184] determine the target highlight value according to the initial highlight value and a preset highlight weight.

[0185] Optionally, the adjusting module 203 is configured to:

[0186] determine an initial position and an initial moving speed of each pixel point in the intermediate image, and the initial moving speed of each pixel point is the same as the moving speed of the control touch point corresponding to the pixel point.

[0187] determine a target position of each pixel point after flow change according to a preset flow deceleration and the initial position and the initial moving speed of each pixel point in the intermediate image.

[0188] determine a display image of the current frame according to the target pigment color and the target position of each pixel point.

[0189] As to the apparatus in the above embodiments, the specific manners in which various modules perform operations have been described in detail in the embodiments of the method, and thus will not be described here in detail.

[0190] The present disclosure also provides a computer readable storage medium having stored thereon computer program instructions, which, when executed by a processor, implement the method provided by the present disclosure.

[0191] The present disclosure also provides an electronic device, comprising:

[0192] a memory having stored thereon computer programs;

[0193] a processor configured to execute the computer programs in the memory to implement the steps of the method provided by the present disclosure.

[0194] Figure 6 is a block diagram of an electronic device 700 according to an exemplary embodiment. As shown in FIG. 7, the electronic device 700 includes a processor 710, a memory 720, and a communication interface 730. Figure 6As shown, the electronic device 700 can include a processor 701, a memory 702. The electronic device 700 can further include one or more of a multimedia component 703, an input / output (I / O) interface 704, and a communication component 705.

[0195] The processor 701 is configured to control overall operations of the electronic device 700 to complete all or part of the steps of the method of simulating oil painting drawing described above. The memory 702 is configured to store various types of data to support operations of the electronic device 700, which can include, for example, instructions for operating any application or method on the electronic device 700, and application-related data, such as contact data, transmitted and received messages, pictures, audio, video, and the like. The memory 702 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 storage, flash memory, magnetic disk or optical disk. The multimedia component 703 can include a screen and an audio component. The screen can be, for example, a touch screen, and the audio component is configured to output and / or input audio signals. For example, the audio component can include a microphone configured to receive external audio signals. The received audio signals can be further stored in the memory 702 or transmitted through the communication component 705. The audio component further includes at least one speaker configured to output audio signals. The I / O interface 704 provides an interface between the processor 701 and other interface modules, which can be a keyboard, a mouse, a button, and the like. The buttons can be virtual buttons or physical buttons. The communication component 705 is configured to perform wired or wireless communication between the electronic device 700 and other devices. The wireless communication, such as Wi-Fi, Bluetooth, near field communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, and the like, or a combination of one or more of them, is not limited herein. Therefore, the corresponding communication component 705 can include a Wi-Fi module, a Bluetooth module, an NFC module, and the like.

[0196] In an exemplary embodiment, the electronic device 700 can be implemented by one or more Application Specific Integrated Circuits (ASICs), Digital Signal Processors (DSPs), Digital Signal Processing Devices (DSPDs), Programmable Logic Devices (PLDs), Field Programmable Gate Arrays (FPGAs), controllers, micro-controllers, microprocessors, or other electronic elements for performing the method of simulating oil painting as described above.

[0197] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the method of simulating oil painting as described above. For example, the computer-readable storage medium can be the memory 702 as described above including program instructions executable by the processor 701 of the electronic device 700 to complete the method of simulating oil painting as described above.

[0198] Figure 7 is a block diagram of an electronic device 1900 according to an exemplary embodiment. For example, the electronic device 1900 can be provided as a server. Referring to Figure 7 , the electronic device 1900 includes a processor 1922, the number of which can be one or more, and a memory 1932 for storing a computer program executable by the processor 1922. The computer program stored in the memory 1932 can include one or more modules each corresponding to a set of instructions. In addition, the processor 1922 can be configured to execute the computer program to perform the method of simulating oil painting as described above.

[0199] In addition, the electronic device 1900 can further include a power supply component 1926, which can be configured to perform power management of the electronic device 1900, and a communication component 1950, which can be configured to implement communication of the electronic device 1900, for example, wired or wireless communication. In addition, the electronic device 1900 can further include an input / output (I / O) interface 1958. The electronic device 1900 can operate based on an operating system stored in the memory 1932.

[0200] In another exemplary embodiment, a computer readable storage medium including program instructions is also provided, which when executed by a processor implement the steps of the method of simulating oil painting described above. For example, the non-transitory computer readable storage medium can be the memory 1932 described above including program instructions executable by the processor 1922 of the electronic device 1900 to complete the method of simulating oil painting described above.

[0201] In another exemplary embodiment, a computer program product is also provided, which contains a computer program executable by a programmable device, the computer program having code portions for performing the method of simulating oil painting described above when executed by the programmable device.

[0202] The preferred embodiments of the present disclosure are described in detail above with reference to the accompanying drawings, but the present disclosure is not limited to the specific details of the above-described embodiments. Various simple modifications can be made to the technical solutions of the present disclosure within the scope of the technical concept of the present disclosure, and all these simple modifications shall fall within the protection scope of the present disclosure.

[0203] In addition, it should be noted that each specific technical feature described in the above specific embodiments can be combined in any appropriate manner without contradiction, and in order to avoid unnecessary repetition, the present disclosure will not make further descriptions on various possible combinations.

[0204] Furthermore, any combination of the various different embodiments of the present disclosure can also be made, as long as it does not deviate from the idea of the present disclosure, it shall be considered as disclosed within the present disclosure.

Claims

1. A method of simulating oil painting, characterized by, The method comprises: in response to the movement of the control touch point, rendering the pigment color and transparency of each pixel point generated by the movement of the control touch point on the canvas to generate an initial image of the current frame; determining an intermediate image by superimposing the transparency of each corresponding pixel point in the initial image of the current frame and the display image of the previous frame; adjusting the light performance of the pigment color corresponding to each pixel point in the intermediate image under a light source according to a preset light parameter to determine a display image of the current frame, the preset light parameter being used to represent at least one of the position, intensity, color, direction and line of sight angle of the light source; the response to the movement of the control touch point, rendering the pigment color and transparency of each pixel point generated by the movement of the control touch point on the canvas to generate an initial image of the current frame, comprising: in response to the movement of the control touch point, determining the current position and movement direction of the control touch point; determining the positions of a plurality of bristle vertices within a preset range of the control touch point according to the current position of the control touch point; determining the bristle corresponding to each bristle vertex according to the preset brush parameter, the movement direction of the control touch point and the position of each bristle vertex; generating a brush following the movement of the control touch point according to a plurality of determined bristles; rendering the pigment color and transparency of each pixel point in the image generated by the movement of the brush on the canvas to determine the initial image of the current frame.

2. The method of claim 1, wherein, The preset brush parameter includes a preset vertex spacing and a preset bristle length, and the determination of the bristle corresponding to each bristle vertex according to the preset brush parameter, the movement direction of the control touch point and the position of each bristle vertex comprises: for any bristle vertex, sequentially determining the next bristle vertex corresponding to the bristle vertex within the preset bristle length according to the position of the bristle vertex, the movement direction of the control touch point and the preset vertex spacing, and filling a plurality of face sheets of a preset shape size between any two adjacent bristle vertices to obtain the bristle corresponding to the bristle vertex.

3. The method of claim 2, wherein, The rendering of the pigment color and transparency of each pixel point in the image generated by the movement of the brush on the canvas to determine the initial image of the current frame comprises: rendering the pigment color and transparency of each pixel point in the image generated by the movement of the brush on the canvas according to a preset rendering parameter to determine the initial image of the current frame, the preset rendering parameter including that the transparency of the pixel point gradually decreases away from the bristle axis, and the bristle axis is a line segment composed of any two adjacent bristle vertices.

4. The method of claim 1, wherein, The adjustment of the light performance of the pigment color corresponding to each pixel point in the intermediate image under a light source according to a preset light parameter to determine a display image of the current frame comprises: determining the base pigment color and transparency of a target pixel point, the target pixel point being any pixel point in the intermediate image; determining the normal vector of the target pixel point according to the transparency of a plurality of adjacent pixel points within the unit distance range of the target pixel point; adjust the base pigment color of the target pixel point according to the preset lighting parameter and the normal vector of the target pixel point, to determine a target pigment color of the target pixel point; determine the display image of the current frame according to the target pigment colors of the plurality of target pixel points.

5. The method of claim 4, wherein, The method further includes: adjust the base pigment color of the target pixel point according to the preset lighting parameter and the normal vector of the target pixel point, to determine a target highlight value and an initial pigment color based on diffuse reflection of the target pixel point; determine the target pigment color of the target pixel point according to the initial pigment color and the target highlight value of the target pixel point.

6. The method of claim 5, wherein, The preset lighting parameter includes a light source unit vector, a line-of-sight unit vector, a diffuse reflection weight, a direct light color, and a highlight parameter, and the method further includes: determine a diffuse reflection value according to the light source unit vector and the normal vector of the target pixel point determine the initial pigment color based on diffuse reflection of the target pixel point according to the base pigment color of the target pixel point, the diffuse reflection value, and the diffuse reflection weight; determine an initial highlight value according to the direct light color, the light source unit vector, the line-of-sight unit vector, and the highlight parameter; determine the target highlight value according to the initial highlight value and a preset highlight weight.

7. The method of claim 4, wherein, The method further includes: determine an initial position and an initial moving speed of each pixel point in the intermediate image, and the initial moving speed of each pixel point is the same as the moving speed of the control contact point corresponding to the pixel point; determine a target position of each pixel point after flow change according to a preset flow deceleration and the initial position and the initial moving speed of each pixel point in the intermediate image; determine the display image of the current frame according to the target pigment color and the target position of each pixel point.

8. An apparatus for simulating oil painting, characterized by The method further includes: generate an initial image of a current frame by rendering the pigment color and the transparency of each pixel point generated by the movement of the control contact point on the canvas in response to the movement of the control contact point; determine an intermediate image by superimposing the transparency of each corresponding pixel point in the initial image of the current frame and the display image of a previous frame; adjust the lighting performance of the pigment color of each pixel point in the intermediate image under a light source according to a preset lighting parameter, to determine the display image of the current frame, the preset lighting parameter being used to represent at least one of the position, the intensity, the color, the direction, and the line-of-sight angle of the light source; the generation module is further configured to: determine the current position and the moving direction of the control contact point in response to the movement of the control contact point; According to the current position of the control contact, positions of a plurality of bristle vertices within a preset range of the control contact are determined; According to preset brush parameters, a moving direction of the control contact, and the position of each bristle vertex, a corresponding bristle of each bristle vertex is determined; According to a plurality of determined bristles, a brush following the movement of the control contact is generated; The color and transparency of each pixel in the image generated by the movement of the brush on the canvas are rendered to determine the initial image of the current frame.

Citation Information

Patent Citations

  • Image style migration method and device, electronic equipment and storage medium

    CN114066715A

  • Illumination color display method and device, electronic equipment and storage medium

    CN114723839A