Method and device for simulating oil painting drawing

By rendering and overlaying pixel color and transparency, and adjusting the pigment color in combination with lighting parameters, the problem of difficulty in simulating real painting effects in electronic drawings is solved, achieving a more realistic and natural painting experience.

CN119494886AActive Publication Date: 2025-02-21DARK MATTER ARTIFICIAL INTELLIGENT (BEIJING) TECHNOLOGY CO LTD
View PDF 7 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing electronic drawing techniques are difficult to accurately simulate pigment accumulation, natural diffusion of brushstrokes and texture effects in real paintings.

Method used

By rendering the pigment color and transparency of each pixel point, superimposing the initial image of the current frame with the transparency of the display image of the previous frame, adjusting the pigment color with preset lighting parameters to generate an image that simulates the real painting effect.

Benefits of technology

It enhances the realistic and visual depth of the paintings, simulates the mixing and superposition of real pigments on the canvas, and improves the natural sense and expressiveness of electronic paintings.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119494886A_ABST
    Figure CN119494886A_ABST
Patent Text Reader

Abstract

The invention relates to a method and device for simulating oil painting drawing, and the method comprises the steps: responding to a movement control contact, generating the pigment color and transparency of each pixel point through the movement of the control contact on a canvas, and carrying out the rendering, and generating an initial image of a current frame; determining an intermediate image by superposing the transparency of each corresponding pixel point in the initial image of the current frame and the display image of the previous frame; and adjusting the pigment color corresponding to each pixel point in the intermediate image according to a preset illumination parameter, and determining 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 painting, and in particular to a method and device for simulating oil painting. Background Art

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

[0003] However, existing electronic drawing technology still faces many challenges in simulating real painting effects. For example, the accumulation of paint on real canvas, the natural diffusion of brushstrokes, and the texture effect of brushes are difficult to accurately replicate in electronic drawing. Although some electronic drawing software attempts to simulate these effects by increasing the types of brushes and adjusting brush parameters, it is still difficult for users to get an experience that is completely consistent with real painting. Summary of the invention

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

[0005] In response to the movement of the control touch point, the initial image of the 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;

[0006] 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;

[0007] The pigment color corresponding to each pixel in the intermediate image is adjusted according to the preset lighting parameters to determine the display image of the current frame.

[0008] Optionally, in response to moving the control contact point, generating an initial image of the current frame by rendering the pigment color and transparency of each pixel point generated by the movement of the control contact point on the canvas, comprises:

[0009] In response to moving the control contact, determining a current position and a direction of movement of the control contact;

[0010] Generate a brush that moves with the control contact point according to preset brush parameters, the current position and moving direction of the control contact point;

[0011] The initial image of the current frame is determined by rendering the paint color and transparency of each pixel in the image generated by moving the brush on the canvas.

[0012] Optionally, generating a brush that follows the movement of the control contact point according to preset brush parameters, the current position and the moving direction of the control contact point includes:

[0013] Determining the positions of a plurality of bristle vertices within a preset range of the control contact according to the current position of the control contact;

[0014] Determine the bristles corresponding to each of the bristle vertices according to the preset brush parameters, the moving direction of the control contact point, and the position of each of the bristle vertices;

[0015] A brush that follows the movement of the control contact point is generated according to the plurality of determined bristles.

[0016] Optionally, the preset brush parameters include preset vertex spacing and preset bristle length, and determining the bristles corresponding to each bristle vertex according to the preset brush parameters, the moving direction of the control contact, and each bristle vertex includes:

[0017] For any of the bristle vertices, based on the position of the bristle vertex, the moving direction of the control contact and the preset vertex spacing, the next bristle vertex corresponding to the bristle vertex is determined in sequence within the preset bristle length, and a plurality of face patches of preset shapes and sizes are filled between any two adjacent bristle vertices to obtain the bristles corresponding to the bristle vertex.

[0018] Optionally, rendering the paint color and transparency of each pixel in the image generated by moving the brush on the canvas to determine the initial image of the current frame includes:

[0019] According to preset rendering parameters, the paint color and transparency of each pixel in the image generated by the brush moving on the canvas are rendered to determine the initial image of the current frame. The preset rendering parameters include that the transparency of the pixel gradually decreases as it moves away from the bristle axis, and the bristle axis is a line segment formed by any two adjacent bristle vertices.

[0020] Optionally, adjusting the pigment color corresponding to each pixel in the intermediate image according to the preset illumination parameters to determine the display image of the current frame includes:

[0021] Determine the basic pigment color and transparency of a target pixel, wherein the target pixel is any pixel in the intermediate image;

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

[0023] Adjusting the basic pigment color of the target pixel point according to the preset illumination parameter and the normal vector of the target pixel point to determine the target pigment color of the target pixel point;

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

[0025] Optionally, adjusting the basic pigment color of the target pixel point according to the preset illumination parameter and the normal vector of the target pixel point to determine the target pigment color of the target pixel point includes:

[0026] Determine a target highlight value and an initial pigment color based on diffuse reflection of the target pixel according to the preset illumination parameters, the basic pigment color of the target pixel, and the normal vector of the target pixel;

[0027] The target pigment color of the target pixel is determined according to the initial pigment color of the target pixel and the target highlight value.

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

[0029] Determine the diffuse reflection value based on the light source unit vector and the normal vector of the target pixel point

[0030] Determine an initial pigment color of the target pixel based on diffuse reflection according to the basic pigment color of the target pixel, 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 sight line unit vector, and the highlight parameter;

[0032] The target highlight value is determined according to the initial highlight value and a preset highlight weight.

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

[0034] Determine the initial position and initial moving speed of each pixel in the intermediate image, wherein the initial moving speed of each pixel is the same as the moving speed of the corresponding control contact;

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

[0036] The display image of the current frame is determined according to the target pigment color and the target position of each pixel.

[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 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;

[0039] A superposition module is 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] The adjustment module is configured to adjust the pigment color corresponding to each pixel 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. When the program instructions are executed by a processor, the method for simulating oil painting provided by the present disclosure is implemented.

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

[0043] By rendering the paint color and transparency of each pixel and superimposing the initial image of the current frame with the transparency of the display image of the previous frame, the mixing and superposition of real paints on the canvas can be simulated, enhancing the realism of the painting. In addition, by adjusting the paint color according to the preset lighting parameters, the painting effects under different lighting conditions can be simulated, enhancing the visual depth and three-dimensionality of the work.

[0044] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

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

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

[0047] Figure 2The figure is a flow chart of a method for simulating oil painting according to an exemplary embodiment.

[0048] Figure 3 is a schematic diagram showing a method of determining bristle vertices according to an exemplary embodiment.

[0049] Figure 4 is a schematic diagram showing a method of determining bristle vertices according to an exemplary embodiment.

[0050] Figure 5 The invention is a block diagram of a device for simulating oil painting according to an exemplary embodiment.

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

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

[0053] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0054] Traditional electronic paintings are usually images formed by superimposing a single shape on a canvas, such as Figure 1 As shown, as the control contact moves on the canvas, multiple sampling points are determined by a fixed sampling frequency, and then the lines between the sampling points are filled with Bezier curves to form a drawing pattern. The drawing pattern obtained in this way does not have the details of a real brush, such as texture, brush shape, paint thickness and brightness, etc.

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

[0056] Figure 2 is a flow chart of a method for simulating oil painting according to an exemplary embodiment. Figure 2 As shown, the following steps are included.

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

[0058] It is worth noting that the simulated oil painting method provided by the present disclosure can be applied to a variety of electronic device platforms, such as painting software in computers and mobile terminals. The painting effects can be freely configured in the painting software, such as basic paint color and brush type. Once the configuration is completed, the user can use a mouse, a touch pen or directly swipe on the touch screen with a finger to control the movement of the touch point on the canvas.

[0059] In one embodiment, when a user moves a stylus on a touch screen or touchpad, the device captures the position coordinates of the stylus in real time. Based on the pre-configured brush style and the movement trajectory of the control touch point, the image outline that the user wants to draw can be obtained. The paint color and transparency of each pixel in the image outline are rendered through a shader to obtain an initial image.

[0060] Among them, users can freely set the paint color and transparency rendering mode in the initial image.

[0061] In step S12, an intermediate image is determined by superimposing the transparency of each corresponding pixel 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 paint on the bristles will leave paint in the shape of the bristles on the canvas, and the paint is thickest in the center of the bristles and gradually becomes thinner on both sides of the center axis of the bristles. Based on this feature, in order to make the displayed image have a more accurate paint effect, the thickness of the paint can be simulated by the transparency of the pixel points. For example, the brush is moved back and forth in the same area, and the paint is in the same position in the initial image generated in each frame. 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 darker visual effect while keeping the color of the paint unchanged, thereby improving the visual layering of the displayed image.

[0063] 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 pixels can be fused through the blending mode SrcAlpha OneMinusSrcAlpha, and the pigment color and transparency of each pixel of the intermediate image can be obtained by using the superimposed transparency value and the pigment color of the initial image of the current frame.

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

[0066] Among them, the preset lighting parameters are used to characterize the position, intensity, color, direction and viewing angle of the light source, so that the pigment color corresponding to each pixel in the intermediate image is adjusted by the preset lighting parameters, and different lighting performances of pigment colors can be obtained, such as highlight effects, diffuse reflection effects, mirror effects and reflection effects.

[0067] For example, by adjusting the color of the light source through preset lighting parameters, a warm light source may add an orange tint to the displayed image, while a cold light source may make the displayed image bluish.

[0068] By rendering the paint color and transparency of each pixel and superimposing the initial image of the current frame with the transparency of the display image of the previous frame, the mixing and superposition of real paints on the canvas can be simulated, enhancing the realism of the painting. In addition, by adjusting the paint color according to the preset lighting parameters, the painting effects under different lighting conditions can be simulated, enhancing the visual depth and three-dimensionality of the work.

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

[0070] First, in response to moving the control contact, a current position and a moving direction of the control contact are determined.

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

[0072] Then, a brush that follows the movement of the control contact point is generated according to preset brush parameters, the current position and the moving direction of the control contact point.

[0073] The preset brush parameters include 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 one embodiment, a brush model may be generated according to preset brush parameters, where the brush model includes vectors 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 contact, so that each stroke has unique dynamic characteristics, enhancing the naturalness and expressiveness of the painting. The position of the bristle vertices and the corresponding bristles are determined by presetting the brush parameters, which can simulate the physical characteristics of a real brush.

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

[0077] The initial image (render image) is a frozen brush paint image obtained by rendering the image generated by the brush moving on the canvas.

[0078] In one embodiment, first, as the brush moves on the canvas, an outline image including multiple bristles in the brush is created on the canvas, and these outlines represent the shapes of the bristles. Then, based on the pre-configured basic paint color, the created bristle outline image is rendered by a shader to obtain an initial image, which includes the position, distribution and concentration information of the paint applied by the brush on the canvas. The shader code usually includes a vertex shader and a fragment shader. The vertex shader processes the vertex data of the graphics, while the fragment shader is responsible for calculating the color and transparency of each pixel. Finally, the rendered initial image is temporarily stored in a cache area, and the drawing is repeatedly called for each frame as the data basis for making an intermediate image.

[0079] The above method can be used to simulate the movement of the control touch point on the digital canvas, generate a brush effect, and render the paint color and transparency of each pixel, making the electronic painting process more natural and close to the traditional painting experience. 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. The user can accurately control the movement of the brush to achieve fine painting details.

[0080] Optionally, generating a brush that follows the movement of the control contact point according to preset brush parameters, the current position and the moving direction of the control contact point comprises:

[0081] The first step is to determine the positions of a plurality of bristle vertices within a preset range of the control contact according to the current position of the control contact.

[0082] In one embodiment, see Figure 3 As shown, polar coordinates can be used to generate a brush shape within a circle with a radius of R and a current position p0 of the control contact as the center. The generated circle is the preset range of the control contact. Within the generated circle, a random number method random(r, 0, R) is used to generate a floating-point number in the range of 0 to R and assigned to r. A random number method random(θ, 0, 2π) is used to generate a floating-point number in the range of 0 to 2π and assigned to θ. Finally, the position coordinates of a bristle vertex (r*cosθ, r*sinθ) are obtained. This process is repeated multiple times to generate multiple bristle vertices.

[0083] Each bristle vertex corresponds to a combing hair.

[0084] In the second step, the bristles corresponding to each of the bristle vertices are determined according to the preset brush parameters, the moving direction of the control contact point and the position of each of the bristle vertices.

[0085] In one embodiment, each bristle may include multiple bristle vertices. The more bristle vertices there are, the better the combing simulation effect is. A figure formed by sequentially connecting multiple combing vertices is determined as the combing.

[0086] The third step is to generate a brush that moves following the control contact point based on the multiple determined bristles.

[0087] In one embodiment, in order to simulate the physical properties of a 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, rectangular patches are arranged along the path of the brush, and their positions and shapes in three-dimensional space are defined by bristle vertex data, thereby simulating the bristles of the brush. The bristle entity is then rendered using a camera. For example, in a three-dimensional graphics engine, the solid rectangle of the brush can be rendered into a two-dimensional image through the camera perspective.

[0088] Optionally, the preset brush parameters include preset vertex spacing and preset bristle length, and determining the bristles corresponding to each bristle vertex according to the preset brush parameters, the moving direction of the control contact, and each bristle vertex includes:

[0089] For any of the bristle vertices, based on the position of the bristle vertex, the moving direction of the control contact and the preset vertex spacing, the next bristle vertex corresponding to the bristle vertex is determined in sequence within the preset bristle length, and a plurality of face patches of preset shapes and sizes are filled between any two adjacent bristle vertices to obtain the bristles corresponding to the bristle vertex.

[0090] In one embodiment, see Figure 4 As shown, for any bristle vertex p n (x n ,y n ) can be determined by the following calculation formula 1: n+1 (x n+1 ,y n+1 ), where n∈(0,N), 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, where v n.normalTo control the moving direction of the contact v n The direction vector of , size is the preset vertex spacing.

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

[0093] Optionally, rendering the paint color and transparency of each pixel in the image generated by moving the brush on the canvas to determine the initial image of the current frame includes:

[0094] According to preset rendering parameters, the paint color and transparency of each pixel in the image generated by the brush moving on the canvas are rendered to determine the initial image of the current frame. The preset rendering parameters include that the transparency of the pixel gradually decreases as it moves away from the bristle axis, and the bristle axis is a line segment formed by any two adjacent bristle vertices.

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

[0096] In one 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 patches (which can be rectangular or circular), and these solid patches can be arranged along the connecting paths between the bristle vertices to simulate the shape and distribution of the bristles.

[0097] The position, size, and orientation of each bristle vertex are then calculated and used to define the three-dimensional shape of the bristles, including their thickness and spread.

[0098] After that, the camera component in the graphics engine is used to define the perspective for observing these bristle nodes. The position, angle, and field of view of the camera determine how the bristles are presented in the final rendered image. The bristle nodes are rendered into an initial image through the camera. This process involves the calculation of materials, lighting, and shadows to ensure that the bristles look realistic.

[0099] Finally, the rendered initial image may not be displayed directly on the screen, but used as a data basis for further processing, for example, the rendered initial image is used as a data basis for calculating a freeze brush paint map.

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

[0101] Improves the realism of renderings by simulating the natural distribution of paint, which is thicker in the center of the brush and thinner at the edges.

[0102] Optionally, adjusting the pigment color corresponding to each pixel in the intermediate image according to the preset illumination parameters to determine the display image of the current frame includes:

[0103] Determine the basic pigment color and transparency of a target pixel, where the target pixel is any pixel in the intermediate image.

[0104] A normal vector of the target pixel is determined according to the transparency of a plurality of adjacent pixels within a unit distance range of the target pixel.

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

[0106] Calculation 2:

[0107] normal=(vx, vy, 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] Among them, 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, normalScale can be dynamically modified to adjust the height difference (transparency) of the paint, and h is the transparency of the pixel.

[0109] By taking into account normal vectors and paint thickness (transparency), it is possible to simulate the reflection and shadow effects of light on different surfaces, adding detail and depth to the image.

[0110] The basic pigment color of the target pixel is adjusted according to the preset illumination parameter and the normal vector of the target pixel to determine the target pigment color of the target pixel.

[0111] The display image of the current frame is determined according to the target pigment colors of the plurality of target pixel points.

[0112] In one embodiment, according to preset lighting parameters, the target pigment color of the target pixel under different lighting conditions and / or different viewing angles can be determined through a lighting model, such as a Phong lighting model or a PBR model, wherein different lighting effects may correspond to different preset lighting parameters, and the user may set this through the rendering software. For example, the preset lighting parameters corresponding to the highlight effect may include the direct light color, viewing direction, and highlight parameters, and the preset lighting parameters corresponding to the diffuse reflection effect may include the light source direction, diffuse reflection weight, and direct light color.

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

[0114] Optionally, adjusting the basic pigment color of the target pixel point according to the preset illumination parameter and the normal vector of the target pixel point to determine the target pigment color of the target pixel point includes:

[0115] According to the preset illumination parameters, the basic pigment color of the target pixel and the normal vector of the target pixel, a target highlight value of the target pixel and an initial pigment color based on diffuse reflection are determined.

[0116] The target pigment color of the target pixel is determined according to the initial pigment color of the target pixel and the target highlight value.

[0117] In one 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 sight line unit vector, a diffuse reflection weight, a direct light color, and a highlight parameter, and determining a target highlight value of the target pixel and an initial pigment color based on diffuse reflection according to the preset lighting parameters, a basic pigment color of the target pixel, and a normal vector of the target pixel includes:

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

[0120] An initial pigment color of the target pixel based on diffuse reflection is determined according to the basic pigment color of the target pixel, the diffuse reflection value, and the diffuse reflection weight.

[0121] It is worth mentioning that in computer graphics, diffuse reflection is the phenomenon that light scatters evenly in all directions after hitting a surface.

[0122] In one implementation, the diffuse reflection value diffuse may be determined by the following calculation formula 3.

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

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

[0125] The diffuse reflection value represents the angle between the incident light and the surface normal. If the angle is closer to 0 degrees (that is, the normal is closer to the light source direction), the diffuse reflection value is larger and the diffuse reflection is stronger. In order to avoid the strong contrast between light and dark in the final displayed image, which affects the viewing experience, a diffuse reflection weight diffuseWeight can be introduced to adjust the contribution of diffuse reflection. This weight factor usually ranges from 0 to 1, which determines the degree of influence of diffuse reflection on the final pixel color.

[0126] The base color value.rgb of the target pixel plus the initial pigment color surfaceColor after diffuse reflection can be expressed as the following calculation formula 4:

[0127] Calculation 4:

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

[0129] Among them, (1.0-diffuseWeight) in the formula is used to characterize the contribution of ambient light, which ensures that the surface still has a certain brightness even in areas with weak light, thus avoiding excessively strong contrast between light and dark.

[0130] In one approach, the Phong model can be used to adjust the initial pigment color by other lighting parameters such as specular reflection and ambient light.

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

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

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

[0134] In one embodiment, the initial highlight value Specular may be determined by the following calculation formula 5.

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

[0136] Among them, lightColor is the direct light color, lightDirectio is the light source unit vector, halfVector is the average of the light source unit vector and the view unit vector viewDirection, that is, the half vector, and gloss is the highlight parameter. The highlight parameter is used to control the sharpness of the highlight. The larger the gloss value, the sharper the highlight.

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

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

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

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

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

[0142] Through the above method, it is ensured that the highlight effect is obvious but not too strong, thereby maintaining a good visual effect. In the actual rendering process, the highlight calculation is usually combined with other lighting components such as diffuse reflection and ambient light to obtain the target pigment color.

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

[0144] The first step is to determine the initial position and initial moving speed of each pixel in the intermediate image, wherein the initial moving speed of each pixel is the same as the moving speed of the corresponding control contact.

[0145] It is worth noting that the initial position of the pixel points in the intermediate image is the same as the position of the pixel points in the initial image, that is, the pixel points in the image generated by moving the brush on the canvas, and the moving speed of the brush is the moving speed of the control contact. The initial moving speed of the pixel points generated on the canvas by the user controlling the contact is the same as the moving speed of the control contact.

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

[0147] It is worth mentioning that in actual oil painting, the pigment has fluid properties, which is characterized by the pigment moving with the brush. In electronic painting, the flow properties of the pigment can be simulated by calculating the moving speed of each pixel in the brush moving area.

[0148] In one embodiment, the intermediate image includes a plurality of pixels generated by the movement of the brush, and for each pixel in the brush movement area, the movement speed thereof is calculated, which can be achieved 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 may be (1, 0), and if the brush moves upward, the speed vector may be (0, 1).

[0149] Then, the calculated velocity vectors of all pixels are stored in the 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 moving speed. For example, if the velocity vector is (u, i), r can be set to u and g can be set to i.

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

[0151] Calculation formula 8: v1=v0*a, where 0<a<1, v0 is the initial moving speed of the pixel point, and v1 is the actual moving speed of the pixel point after flow attenuation, which means that the speed of each pixel point will decrease over time until the pixel point stops.

[0152] Finally, in each frame, the position of each pixel is updated according to the stored velocity vector. For example, the flow change of the pixel can be achieved by adding the velocity vector to the current position.

[0153] The third step is to determine the display image of the current frame according to the target pigment color and the target position of each pixel.

[0154] In one implementation, the image may be rendered onto a canvas using a shader according to the determined target pigment color and target position of each pixel to obtain a display image of the current frame.

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

[0156] Figure 5 is a block diagram of a device for simulating oil painting according to an exemplary embodiment. Figure 5 The device 200 includes a generating module 201, a superimposing module 202 and a superimposing 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 generated by the movement of the control contact point on the canvas in response to the movement of the control contact point.

[0158] The superposition module 202 is 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.

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

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

[0161] In response to moving the control contact, a current position and a direction of movement of the control contact are determined.

[0162] A brush that follows the movement of the control contact point is generated according to preset brush parameters, the current position and the moving direction of the control contact point.

[0163] The initial image of the current frame is determined by rendering the paint color and transparency of each pixel in the image generated by moving the brush on the canvas.

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

[0165] According to the current position of the control contact, the positions of a plurality of bristle vertices are determined within a preset range of the control contact.

[0166] The bristles corresponding to each of the bristle vertices are determined according to the preset brush parameters, the moving direction of the control contact point, and the position of each of the bristle vertices.

[0167] A brush that follows the movement of the control contact point is generated according to the plurality of determined bristles.

[0168] Optionally, the preset brush parameters include a preset vertex spacing and a preset bristle length, and the generating module 201 is configured as follows:

[0169] For any of the bristle vertices, based on the position of the bristle vertex, the moving direction of the control contact and the preset vertex spacing, the next bristle vertex corresponding to the bristle vertex is determined in sequence within the preset bristle length, and a plurality of face patches of preset shapes and sizes are filled between any two adjacent bristle vertices to obtain the bristles corresponding to the bristle vertex.

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

[0171] According to preset rendering parameters, the paint color and transparency of each pixel in the image generated by the brush moving on the canvas are rendered to determine the initial image of the current frame. The preset rendering parameters include that the transparency of the pixel gradually decreases as it moves away from the bristle axis, and the bristle axis is a line segment formed by any two adjacent bristle vertices.

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

[0173] Determine the basic pigment color and transparency of a target pixel, where the target pixel is any pixel in the intermediate image.

[0174] A normal vector of the target pixel is determined according to the transparency of a plurality of adjacent pixels within a unit distance range of the target pixel.

[0175] The basic pigment color of the target pixel is adjusted according to the preset illumination parameter and the normal vector of the target pixel to determine the target pigment color of the target pixel.

[0176] The display image of the current frame is determined according to the target pigment colors of the plurality of target pixel points.

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

[0178] According to the preset illumination parameters, the basic pigment color of the target pixel and the normal vector of the target pixel, a target highlight value of the target pixel and an initial pigment color based on diffuse reflection are determined.

[0179] The target pigment color of the target pixel is determined according to the initial pigment color of the target pixel and the target highlight value.

[0180] Optionally, the preset illumination parameters include a light source unit vector, a sight line unit vector, a diffuse reflection weight, a direct light color, and a highlight parameter, and the adjustment module 203 is configured as follows:

[0181] Determine the diffuse reflection value based on the light source unit vector and the normal vector of the target pixel point

[0182] An initial pigment color of the target pixel based on diffuse reflection is determined according to the basic pigment color of the target pixel, the diffuse reflection value, and the diffuse reflection weight.

[0183] An initial highlight value is determined according to the direct light color, the light source unit vector, the sight line unit vector, and the highlight parameter.

[0184] The target highlight value is determined according to the initial highlight value and a preset highlight weight.

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

[0186] The initial position and initial moving speed of each pixel point in the intermediate image are determined, 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.

[0187] According to the preset flow deceleration and the initial position and initial moving speed of each pixel point in the intermediate image, the target position of each pixel point after the flow change is determined.

[0188] The display image of the current frame is determined according to the target pigment color and the target position of each pixel.

[0189] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0190] The present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, and the method provided by the present disclosure is implemented when the program instructions are executed by a processor.

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

[0192] a memory having a computer program stored thereon;

[0193] A processor is used to execute the computer program in the memory to implement the steps of the method provided in the present disclosure.

[0194] Figure 6 FIG. 7 is a block diagram of an electronic device 700 according to an exemplary embodiment. Figure 6As shown, the electronic device 700 may include: a processor 701 and a memory 702. The electronic device 700 may also 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 used to control the overall operation of the electronic device 700 to complete all or part of the steps in the above-mentioned method of simulating oil painting. The memory 702 is used to store various types of data to support the operation of the electronic device 700, and these data may include, for example, instructions for any application or method used to operate on the electronic device 700, and application-related data, such as contact data, sent and received messages, pictures, audio, video, etc. 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 (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. The multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 702 or sent through the communication component 705. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 704 provides an interface between the processor 701 and other interface modules, and the other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 705 may include: Wi-Fi module, Bluetooth module, NFC module, etc.

[0196] In an exemplary embodiment, the electronic device 700 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned method of simulating oil painting.

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

[0198] Figure 7 1 is a block diagram of an electronic device 1900 according to an exemplary embodiment. For example, the electronic device 1900 may be provided as a server. Figure 7 The electronic device 1900 includes a processor 1922, which may 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 may include one or more modules each corresponding to a set of instructions. In addition, the processor 1922 may be configured to execute the computer program to perform the above-mentioned method of simulating oil painting.

[0199] In addition, the electronic device 1900 may further include a power supply component 1926 and a communication component 1950, wherein the power supply component 1926 may be configured to perform power management of the electronic device 1900, and the communication component 1950 may be configured to implement communication, for example, wired or wireless communication, of the electronic device 1900. In addition, the electronic device 1900 may further include an input / output (I / O) interface 1958. The electronic device 1900 may 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, and when the program instructions are executed by a processor, the steps of the above-mentioned method of simulating oil painting are implemented. For example, the non-transitory computer-readable storage medium can be the above-mentioned memory 1932 including program instructions, and the above-mentioned program instructions can be executed by the processor 1922 of the electronic device 1900 to complete the above-mentioned method of simulating oil painting.

[0201] In another exemplary embodiment, a computer program product is also provided. The computer program product includes a computer program executable by a programmable device, and the computer program has a code portion for executing the above-mentioned method of simulating oil painting when executed by the programmable device.

[0202] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.

[0203] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.

[0204] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as disclosed in the present disclosure.

Claims

1. A method for simulating oil painting, characterized in that: include: In response to the movement of the control touch point, the initial image of the 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; 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; The pigment color corresponding to each pixel in the intermediate image is adjusted according to the preset lighting parameters to determine the display image of the current frame.

2. The method according to claim 1, characterized in that In response to the moving control touch point, the initial image of the 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, including: In response to moving the control contact, determining a current position and a direction of movement of the control contact; Generate a brush that moves with the control contact point according to preset brush parameters, the current position and moving direction of the control contact point; The initial image of the current frame is determined by rendering the paint color and transparency of each pixel in the image generated by moving the brush on the canvas.

3. The method according to claim 2, characterized in that The step of generating a brush that follows the movement of the control contact point according to preset brush parameters, the current position and the moving direction of the control contact point comprises: Determining the positions of a plurality of bristle vertices within a preset range of the control contact according to the current position of the control contact; Determine the bristles corresponding to each of the bristle vertices according to the preset brush parameters, the moving direction of the control contact point, and the position of each of the bristle vertices; A brush that follows the movement of the control contact point is generated according to the plurality of determined bristles.

4. The method according to claim 3, characterized in that The preset brush parameters include preset vertex spacing and preset bristle length, and determining the bristles corresponding to each bristle vertex according to the preset brush parameters, the moving direction of the control contact point, and each bristle vertex includes: For any of the bristle vertices, based on the position of the bristle vertex, the moving direction of the control contact and the preset vertex spacing, the next bristle vertex corresponding to the bristle vertex is determined in sequence within the preset bristle length, and a plurality of face patches of preset shapes and sizes are filled between any two adjacent bristle vertices to obtain the bristles corresponding to the bristle vertex.

5. The method according to claim 4, characterized in that The step of rendering the paint color and transparency of each pixel in the image generated by moving the brush on the canvas to determine the initial image of the current frame includes: According to preset rendering parameters, the paint color and transparency of each pixel in the image generated by the brush moving on the canvas are rendered to determine the initial image of the current frame. The preset rendering parameters include that the transparency of the pixel gradually decreases as it moves away from the bristle axis, and the bristle axis is a line segment formed by any two adjacent bristle vertices.

6. The method according to claim 1, characterized in that The step of adjusting the pigment color corresponding to each pixel in the intermediate image according to the preset illumination parameters to determine the display image of the current frame includes: Determine the basic pigment color and transparency of a target pixel, wherein the target pixel is any pixel in the intermediate image; Determine a normal vector of the target pixel point according to the transparency of a plurality of adjacent pixels within a unit distance range of the target pixel point; Adjusting the basic pigment color of the target pixel point according to the preset illumination parameter and the normal vector of the target pixel point to determine the target pigment color of the target pixel point; The display image of the current frame is determined according to the target pigment colors of the plurality of target pixel points.

7. The method according to claim 6, characterized in that The step of adjusting the basic pigment color of the target pixel point according to the preset illumination parameter and the normal vector of the target pixel point to determine the target pigment color of the target pixel point includes: Determine a target highlight value and an initial pigment color based on diffuse reflection of the target pixel according to the preset illumination parameters, the basic pigment color of the target pixel, and the normal vector of the target pixel; The target pigment color of the target pixel is determined according to the initial pigment color of the target pixel and the target highlight value.

8. The method according to claim 7, characterized in that The preset lighting parameters include a light source unit vector, a sight line unit vector, a diffuse reflection weight, a direct light color, and a highlight parameter. The step of determining a target highlight value of a target pixel and an initial pigment color based on diffuse reflection according to the preset lighting parameters, a basic pigment color of the target pixel, and a normal vector of the target pixel includes: Determine the diffuse reflection value based on the light source unit vector and the normal vector of the target pixel point Determine an initial pigment color of the target pixel based on diffuse reflection according to the basic pigment color of the target pixel, the diffuse reflection value, and the diffuse reflection weight; Determining an initial highlight value according to the direct light color, the light source unit vector, the sight line unit vector, and the highlight parameter; The target highlight value is determined according to the initial highlight value and a preset highlight weight.

9. The method according to claim 6, characterized in that The step of determining the display image of the current frame according to the target pigment colors of the plurality of target pixel points comprises: Determine the initial position and initial moving speed of each pixel in the intermediate image, wherein the initial moving speed of each pixel is the same as the moving speed of the corresponding control contact; Determining a target position of each pixel point after flow change according to a preset flow deceleration and an initial position and an initial moving speed of each pixel point in the intermediate image; The display image of the current frame is determined according to the target pigment color and the target position of each pixel.

10. A device for simulating oil painting, characterized in that: include: A generating module, configured to generate an initial image of a current frame by rendering the pigment color and 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; A superposition module is 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; The adjustment module is configured to adjust the pigment color corresponding to each pixel in the intermediate image according to preset lighting parameters to determine the display image of the current frame.

Citation Information

Patent Citations

  • Layered oil painting brush drawing method based on incremental Voronoi sequence

    CN111127596A

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

    CN114066715A

  • Graph processing method and device, computer equipment and storage medium

    CN114119847A

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

    CN114723839A

  • Oil painting style image generation method and device, electronic equipment and storage medium

    CN114758025A