Ink rendering method and apparatus, terminal device, and storage medium

CN122902904APending Publication Date: 2026-10-13SHENZHEN HONGHE INNOVATION INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611210331.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-10
Publication Date
2026-10-13

AI Technical Summary

Technical Problem

然而,单纯贴图叠加难以表现水墨颜料沿笔迹方向的自然扩散、晕染和沉积动态;每次绘制后对全画布进行扩散和抗锯齿处理,移动设备图形处理器开销较大;高分辨率画布下易出现卡顿,且渲染输入参数处理不当易导致扩散方向抖动或边缘不连续

Benefits of technology

[0011]本申请实施例中,通过获取包含坐标和笔触面积的触摸点序列,并根据至少两个触摸点的坐标确定笔迹方向信息,为颜料扩散模拟提供方向依据;然后,基于笔迹方向信息和笔触面积在图形处理器中进行颜料扩散模拟,使颜料分布数据的更新能够反映水墨沿笔迹方向的自然流动特性,有效提升绘制效果的真实感;同时,在颜料扩散模拟过程中同步确定该扩散模拟所作用的笔迹影响区域,使得后续的局部合成操作能够精确限定在实际受影响的范围内;最后,根据该笔迹影响区域,将更新后的颜料分布数据与画布的历史状态进行局部合成并输出显示,由于合成操作仅针对笔迹实际影响的局部区域执行,避免了全画布遍历处理,可有效降低图形处理器的计算开销,从而在降低渲染计算开销的同时,实现了具有自然流动感的水墨绘制效果。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122902904A_ABST
    Figure CN122902904A_ABST
Patent Text Reader

Abstract

The application is suitable for the technical field of intelligent terminals, and provides a watercolor rendering method and device, a terminal device and a storage medium. The method comprises the following steps: acquiring a touch point sequence, each touch point in the touch point sequence comprising a coordinate and a brush stroke area; determining brushstroke direction information according to the coordinates of at least two touch points in the touch point sequence; performing pigment diffusion simulation in a graphics processor based on the brushstroke direction information and the brush stroke area, obtaining updated pigment distribution data, and determining a brushstroke influence area affected by the pigment diffusion simulation in the process of the pigment diffusion simulation; and performing local synthesis of the updated pigment distribution data and a historical state of a canvas according to the brushstroke influence area, generating a to-be-displayed image and outputting the to-be-displayed image to a screen. The application can reduce rendering calculation overhead on a mobile terminal while achieving a watercolor drawing effect with a natural flowing feeling.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of smart terminal technology, and in particular to an ink-wash rendering method, apparatus, terminal device, and storage medium. Background Technology

[0002] Real-time painting applications based on touch interaction have become widely popular on mobile devices, in-vehicle terminals, interactive whiteboards, and digital painting devices. These applications typically capture continuous touch operations from the user on the touchscreen and convert the sequence of touch points into brushstrokes on the canvas. With the continuous improvement of the performance of graphics processing units (GPUs) in mobile devices, utilizing GPUs for accelerated rendering has become the mainstream technology for mobile painting applications.

[0003] In existing mobile painting applications, the brushstrokes generated by user touches are typically converted into dot sprites, textures, or paths, and then overlaid onto the canvas via fragment shaders or the Canvas interface. Some solutions simulate the effects of natural media such as ink painting and oil painting, performing blurring, diffusion, anti-aliasing, or layer blending across the entire canvas. However, simply overlaying textures is insufficient to represent the natural diffusion, smudging, and deposition dynamics of ink pigments along the brushstroke direction; applying diffusion and anti-aliasing to the entire canvas after each drawing places a significant burden on the mobile device's graphics processor; stuttering is prone to occur on high-resolution canvases, and improper handling of rendering input parameters can lead to jitter in the diffusion direction or discontinuous edges.

[0004] Therefore, how to achieve a natural and fluid ink painting effect on mobile devices while reducing rendering computational overhead is a problem that needs to be solved. Summary of the Invention

[0005] This application provides a method, apparatus, terminal device, and storage medium for ink painting, which can reduce rendering computational overhead on mobile devices while achieving an ink painting effect with a natural sense of flow.

[0006] In a first aspect, embodiments of this application provide a method for ink wash rendering, including: Obtain a sequence of touch points, wherein each touch point in the sequence includes coordinates and pen stroke area; The handwriting direction information is determined based on the coordinates of at least two touch points in the touch point sequence; Based on the handwriting direction information and the stroke area, a pigment diffusion simulation is performed in the graphics processor to obtain updated pigment distribution data, and the handwriting influence area affected by the pigment diffusion simulation is determined during the pigment diffusion simulation process. Based on the area affected by the handwriting, the updated pigment distribution data is locally synthesized with the historical state of the canvas to generate an image to be displayed and output to the screen.

[0007] Secondly, embodiments of this application provide an ink-wash rendering apparatus, comprising: A touch point acquisition unit is used to acquire a sequence of touch points, wherein each touch point in the sequence includes coordinates and pen stroke area; The handwriting direction determination unit is used to determine handwriting direction information based on the coordinates of at least two touch points in the touch point sequence; The diffusion simulation unit is used to perform pigment diffusion simulation in the graphics processor based on the handwriting direction information and the pen stroke area to obtain updated pigment distribution data, and to determine the handwriting influence area affected by the pigment diffusion simulation during the pigment diffusion simulation process. The local synthesis unit is used to locally synthesize the updated pigment distribution data and the historical state of the canvas according to the area affected by the handwriting, and generate an image to be displayed and output it to the screen.

[0008] Thirdly, embodiments of this application provide a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the ink wash rendering method as described in the first aspect above.

[0009] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the ink-wash rendering method as described in the first aspect above.

[0010] Fifthly, embodiments of this application provide a computer program product that, when run on a terminal device, causes the terminal device to execute the ink-wash rendering method described in the first aspect above.

[0011] In this embodiment, a sequence of touch points containing coordinates and brushstroke area is obtained, and the brushstroke direction information is determined based on the coordinates of at least two touch points, providing a directional basis for the pigment diffusion simulation. Then, based on the brushstroke direction information and brushstroke area, the pigment diffusion simulation is performed in the graphics processor, so that the update of the pigment distribution data can reflect the natural flow characteristics of ink along the brushstroke direction, effectively improving the realism of the drawing effect. At the same time, the brushstroke influence area affected by the diffusion simulation is determined synchronously during the pigment diffusion simulation, so that the subsequent local compositing operation can be precisely limited to the actual affected area. Finally, based on the brushstroke influence area, the updated pigment distribution data and the historical state of the canvas are locally composited and output for display. Since the compositing operation is only performed on the local area actually affected by the brushstroke, the full canvas traversal processing is avoided, which can effectively reduce the computational overhead of the graphics processor, thereby achieving a natural flowing ink painting effect while reducing the rendering computational overhead. Attached Figure Description

[0012] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 This is a flowchart illustrating the implementation of the ink wash rendering method provided in this application embodiment; Figure 2 This is a flowchart illustrating a specific implementation of the ink wash rendering method provided in this application to obtain updated pigment distribution data; Figure 3 This is a flowchart illustrating a specific implementation of step S104 in the ink wash rendering method provided in this application embodiment; Figure 4 This is a flowchart illustrating a specific implementation of the ink painting rendering method provided in this application for handling pen lifting events; Figure 5 This is a flowchart illustrating a specific implementation of the drying command in the ink wash rendering method provided in this application embodiment; Figure 6 This is a structural block diagram of the ink-wash rendering apparatus provided in the embodiments of this application; Figure 7 This is a schematic diagram of the terminal device provided in the embodiments of this application. Detailed Implementation

[0014] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0015] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.

[0016] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0017] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."

[0018] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0019] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.

[0020] By way of example and not limitation, the ink-wash rendering method provided in this application is applicable to various types of terminal devices that need to perform ink-wash rendering. Specific terminal devices may include mobile phones, tablets, wearable devices, laptops, ultra-mobile personal computers (UMPCs), desktop computers, interactive large screens, and servers, etc. This application does not impose any restrictions on the specific type of terminal device.

[0021] Figure 1 The implementation flow of the ink wash rendering method provided in this application embodiment is illustrated. The method flow includes steps S101 to S104. The specific implementation principle of each step is as follows: Step S101: Obtain the touch point sequence, wherein each touch point in the touch point sequence includes coordinates and pen stroke area.

[0022] A touch point sequence is a set of touch point data arranged in chronological order, continuously collected and reported by the touchscreen at a certain sampling frequency during touch interaction (such as continuous writing or drawing). Each touch point in this sequence includes at least two dimensions of information: coordinates and touch area.

[0023] Coordinates are used to indicate the position of the touch point on the canvas. In one possible implementation, the coordinate values ​​in the canvas coordinate system are directly used as the coordinates of the touch point. In another possible implementation, to adapt to screens with different resolutions and canvas sizes, the screen coordinates are mapped to the canvas coordinate system through an inverse matrix transformation to obtain the coordinates of the touch point, so that the position information of the touch point is aligned with the pixel grid of the canvas.

[0024] The touch area is used to characterize the size of the contact area between a touch object (such as a finger or stylus) and the touchscreen. In one possible implementation, the touch event carries two parameters, touchMajor and touchMinor, representing the major and minor axis lengths of the contact area, respectively. The touch area can be calculated based on these two parameters. The touch area reflects the touch pressure or contact range applied by the user. A larger touch area indicates a thicker stroke, a wider initial range of pigment diffusion, and a corresponding increase in pigment deposition.

[0025] In practical applications, the sampling frequency of raw touch events may not be sufficient to meet the requirements of smooth rendering. One possible implementation is to encapsulate touch events into touch point data containing coordinates (horizontal and vertical coordinates), pressure values, major axis length, and minor axis length; perform Bezier interpolation on adjacent touch point data to generate a continuous sequence of touch points, so that subsequent simulation calculations can obtain a smoother input trajectory.

[0026] By converting discrete touch events reported by the touchscreen into a structured sequence of touch points, the location and range of the handwriting are provided for subsequent steps, which is the data basis for calculating the direction of the handwriting and simulating the diffusion of pigment.

[0027] Step S102: Determine the handwriting direction information based on the coordinates of at least two touch points in the touch point sequence.

[0028] Stroke direction information describes the direction in which a user draws on the canvas, that is, the direction in which the current stroke extends on the canvas. Determining stroke direction information requires at least two touch points from the touch point sequence.

[0029] In one possible implementation, a displacement vector is calculated based on the coordinates of the current touch point and the previous touch point, and a direction angle is determined based on the displacement vector. This direction angle is the handwriting direction information.

[0030] In one possible implementation, to further reduce abrupt changes in orientation caused by user hand tremors or touch sampling noise, the orientation angles calculated from consecutive frames can be smoothed by filtering. For example, Gaussian filtering can be used to smooth the orientation angle sequence, and the smoothed orientation angles can be used as handwriting orientation information. Alternatively, a weighted average of the orientation angles from multiple consecutive frames can be used to reduce the impact of input jitter on subsequent rendering effects.

[0031] By determining the direction information of the handwriting, directional constraints are provided for the simulation of pigment diffusion, so that the pigment distribution data generated subsequently can reflect the effect of ink naturally wetting and dragging along the direction of the handwriting, rather than simply spreading evenly in all directions.

[0032] Step S103: Based on the handwriting direction information and the pen stroke area, perform a pigment diffusion simulation in the graphics processor to obtain updated pigment distribution data, and determine the handwriting influence area affected by the pigment diffusion simulation during the pigment diffusion simulation process.

[0033] A Graphics Processing Unit (GPU) is a hardware unit specifically designed for parallel processing of graphics and computational tasks. GPUs have a large number of computational cores, making them suitable for performing computationally intensive tasks with high data parallelism. In a pigment diffusion simulation, the computation of each pixel or each mesh cell on the canvas is independent, making it suitable for parallel execution on a GPU.

[0034] Pigment diffusion simulation refers to simulating the dynamic physical processes of ink and color pigments flowing along the direction of the brushstrokes on paper, spreading outwards, and depositing at the edges of the brushstrokes. Pigment diffusion simulation is achieved by updating pigment distribution data. This data records the color and transparency information of the pigment at various locations on the canvas.

[0035] The brushstroke influence area refers to the local pixel region on the canvas that actually has an impact during the paint diffusion simulation. During the graphics processor's calculations for the paint diffusion simulation, it records which pixel positions undergo substantial changes; the spatial range formed by these changed pixels constitutes the brushstroke influence area. The brushstroke influence area differs from the geometric area directly covered by the touch point sequence. During the paint diffusion simulation, the paint flows along the direction of the brushstroke and spreads outwards; the actual affected pixel range is usually larger than the brushstroke trajectory itself.

[0036] The precise extent of the area affected by the handwriting cannot be accurately known before the diffusion simulation is completed. Determining the area affected by the handwriting and simulating pigment diffusion are two parallel tasks within the same computational process. In this embodiment, the pigment diffusion simulation is executed in the graphics processor, utilizing the parallel computing capabilities of the graphics processor to calculate the pigment flow in the affected local area on the canvas.

[0037] Simulating pigment diffusion in a graphics processor means mapping pixel areas on the canvas to texture data in the graphics processor, and using the parallel computing power of the graphics processor to perform diffusion operations simultaneously on each pixel or each computing unit in the texture.

[0038] In one possible implementation, before the initial execution of the pigment diffusion simulation, a rendering initialization step is performed, including: creating a background texture shader, a pigment diffusion simulation shader, a drying process shader, a local compositing shader, an edge smoothing shader, and an image output shader; and allocating and creating a background layer texture, a dried layer texture, two sets of velocity field textures, and two sets of color field textures. Specifically, the background texture shader is used to generate or load the canvas's background layer texture data; the pigment diffusion simulation shader is used to perform update calculations for the velocity field texture and color field texture; the drying process shader is used to merge pigment data from the current color field texture into the dried layer texture; the local compositing shader is used to perform blending operations on multiple textures within the area affected by the brushstrokes; the edge smoothing shader is used to perform edge smoothing processing within the area affected by the brushstrokes; and the image output shader is used to write the image to be displayed to the screen frame buffer. The background layer texture stores pixel data of the canvas background, the dried layer texture stores the dried pigment distribution data, the two sets of velocity field textures store flow velocity vector data at various locations on the canvas, and the two sets of color field textures store pigment color values ​​and transparency values ​​at various locations on the canvas. Through the rendering initialization step, a complete shader pipeline resource and texture storage system is established, providing a runtime environment and data carrier for pigment diffusion simulation, local compositing, and image output.

[0039] As one possible implementation of this application Figure 2A specific implementation flow of obtaining updated pigment distribution data in the ink wash rendering method provided in this application is illustrated below: A1: In the graphics processor, the flow rate information is updated based on the pen stroke direction information and the pen stroke area.

[0040] Flow velocity information is used to characterize the direction and rate of pigment flow at various locations on the canvas. Flow velocity information determines the trajectory and rate at which pigment migrates from the current pixel to adjacent pixels. Specifically, flow velocity information is a vector field data point. For each pixel location on the canvas, the flow velocity information contains two components: a horizontal component, representing the horizontal flow velocity of the pigment at that location; and a vertical component, representing the vertical flow velocity of the pigment at that location.

[0041] The update of flow velocity information is based on the stroke direction information and the stroke area: the stroke direction information provides the dominant direction of pigment flow, which determines the direction of the flow velocity vector, while the stroke area affects the intensity and range of the flow velocity information, which determines the range of the flow velocity vector in space.

[0042] In one possible implementation, updating the flow rate information includes: using a compute shader to input the pen stroke direction information and the pen stroke area into the graphics processor. The compute shader writes a new flow rate vector into an initial region in the velocity field texture corresponding to the touch point coordinates and the pen stroke area, based on the pen stroke direction information, the pen stroke area, a preset base flow rate value, and noise perturbation parameters. The direction of the flow rate vector is determined based on the pen stroke direction information, and the magnitude of the flow rate vector is positively correlated with the pen stroke area. This initial region is a rough calculation range determined based on the touch point coordinates and the pen stroke area; the precise pen stroke influence area is determined synchronously during the pigment diffusion simulation.

[0043] When updating the velocity field texture, the computational shader modulates the spatial distribution of the velocity field based on a preset brush stroke grayscale image, resulting in a higher amplitude of the flow velocity vector in the center region of the brush stroke and a lower amplitude in the edge region. The noise perturbation parameter simulates the random influence of paper texture on pigment flow, achieved by superimposing a random perturbation component following a specific distribution (e.g., uniform or normal distribution) onto the flow velocity vector. A preset base flow velocity value serves as the reference value for the flow velocity amplitude, and the final flow velocity amplitude is a combination of the reference value, brush stroke area related terms, brush stroke grayscale modulation terms, and noise perturbation terms.

[0044] In one possible implementation, the flow rate information is stored in two sets of velocity field textures, and the pigment color information is stored in two sets of color field textures. The two sets of velocity field textures and the two sets of color field textures are alternately read and written, and are exchanged after synchronization through a memory barrier after a single update.

[0045] The velocity field texture is a two-dimensional texture data set used by the graphics processor (GPU) to store the velocity vector for each pixel. Each pixel unit stores the velocity vector at a specific location. The color field texture is also a two-dimensional texture data set used by the GPU to store the pigment color and transparency values ​​for each pixel. Each pixel unit stores the pigment color and transparency values ​​at a specific location. Each set of velocity field textures contains velocity data for the entire canvas area. Each set of color field textures contains pigment distribution data for the entire canvas area.

[0046] In one possible implementation, two sets of velocity field textures are used for alternating read and write operations in a ping-pong manner. These two sets of velocity field textures include a first velocity field texture and a second velocity field texture. Both sets have the same size and pixel format and are used to store flow velocity vector data at various locations on the canvas. In one update operation, the graphics processor reads the current flow velocity data from the first velocity field texture, calculates the updated flow velocity data based on the stroke direction information and stroke area, and writes the updated flow velocity data to the second velocity field texture. In the next update operation, the roles are reversed; the graphics processor reads data from the second velocity field texture and writes the update result to the first velocity field texture. By using two sets of velocity field textures for alternating read and write operations, data contention caused by simultaneous read and write operations on the same texture is avoided.

[0047] One possible implementation uses two sets of color field textures for alternating read and write operations in a ping-pong manner. The two sets of color field textures include a first color field texture and a second color field texture. Both sets have the same size and pixel format and are used to store the pigment color and transparency values ​​at various locations on the canvas. In one update operation, the graphics processor reads the current pigment color information from the first color field texture, calculates the updated pigment color information based on the updated flow rate information, and writes the update result to the second color field texture. In the next update operation, the roles are reversed; the graphics processor reads data from the second color field texture and writes the update result to the first color field texture. By using two sets of color field textures for alternating read and write operations, data contention caused by simultaneous read and write operations on the same texture is avoided.

[0048] In this embodiment, after a single update is completed, the graphics processor synchronizes using a memory barrier to ensure that the result of the write operation is visible to all subsequent read operations. A memory barrier is a synchronization mechanism in the graphics processor used to ensure that all memory write operations before the barrier are completed and visible before executing operations after the barrier. Specifically, in an update operation, multiple computing units of the graphics processor write data to different locations of the output texture in parallel, and the completion time of the write operations of different computing units may differ. When a memory barrier instruction is executed, the graphics processor pauses subsequent operations and waits until all computing units have completed their output texture write operations before allowing subsequent read operations to continue. Synchronization via a memory barrier ensures that after two sets of textures exchange roles, the data read from the output texture is complete and fully written, avoiding the reading of incomplete data where some parts are written and others are not.

[0049] Velocity field textures and color field textures can use different data precision formats.

[0050] In one possible implementation, the flow velocity data in the velocity field texture is a continuously changing vector value, which can be stored in a floating-point format texture, such as RGBA16F format, where each channel is used to store the components of the flow velocity in the horizontal and vertical directions, as well as the validity marker of the data.

[0051] In one possible implementation, the color field texture can be stored in a fixed-point format, such as RGBA8, where each channel is used to store the red, green, and blue color components and the alpha component, respectively. The color and alpha data in the color field texture can be stored in a relatively low-precision format to balance storage overhead and rendering quality.

[0052] In this embodiment, by utilizing the parallel computing power of the graphics processor, the flow rate data at each position on the canvas is updated according to the pen stroke direction information and the pen stroke area, providing directional and intensity constraints for the subsequent sampling and diffusion of pigment color information, so that the pigment can flow naturally along the pen stroke direction.

[0053] A2: Based on the updated flow rate information, the pigment color information is sampled, and the pigment diffusion along the direction of the brushstroke is simulated to obtain updated pigment distribution data.

[0054] Pigment color information represents the color and transparency of the pigment at various locations on the canvas and is stored in the color field texture. Sampling the pigment color information based on updated flow rate information simulates pigment diffusion along the brushstroke direction. This involves using the direction and intensity indicated by the flow rate information as an offset basis, back-sampling from the color field texture, and migrating and diffusing the pigment color data along the flow rate direction to obtain updated pigment distribution data. The updated pigment distribution data reflects the latest pigment distribution state resulting from this brushstroke creation.

[0055] Specifically, backsampling involves: for each pixel position on the canvas, determining the pigment source direction at that pixel position based on the flow velocity vector corresponding to that pixel position in the velocity field texture. This source direction is the opposite direction of the flow velocity vector, meaning the pigment flows from an upstream position to the current position. Based on the direction and magnitude of the flow velocity vector corresponding to the pixel position, a sampling offset is determined. Pigment color information (color value and transparency value) is read from the color field texture at the corresponding offset position and written to the current pixel position of the output color field texture. The sampling offset is positively correlated with the magnitude of the flow velocity vector; the higher the flow velocity, the farther the pigment migrates, and the more pronounced the diffusion effect.

[0056] The backsampling process simulates the physical effects of pigment particles migrating and depositing on the canvas along the velocity direction. Through backsampling, pigment color information migrates from upstream to downstream along the flow direction. After one update operation, the distribution of pigment on the canvas changes; pigment along the brushstroke direction flows forward and spreads to a more distant area; pigment perpendicular to the brushstroke direction spreads to both sides, creating a smudged effect. After multiple consecutive update operations, the pigment gradually spreads from the center of the brushstroke outwards and deposits along the flow path, creating a natural gradient effect from dark to light.

[0057] The pigment color information is sampled based on the updated flow rate information to obtain updated pigment distribution data. The purpose is to enable the pigment color to migrate and diffuse along the direction of the brushstroke, thereby presenting a water-and-ink brushstroke effect with a sense of direction and flow.

[0058] In one possible implementation, during the pigment diffusion simulation, the set of affected local coordinate points is recorded simultaneously to generate a local point list. The area indicated by the local point list is determined as the area affected by the brushstrokes. This area is the local region on the canvas where the pigment diffusion simulation actually takes effect.

[0059] In this embodiment, the handwriting-affected area is not a fixed-shape region estimated in advance based on the touch point sequence, but rather dynamically marked and collected during the diffusion simulation process. Its range precisely matches the pixel range actually affected by the handwriting. The handwriting-affected area can then be used to guide local compositing and edge smoothing, allowing subsequent operations to be performed only within this area, without traversing the entire canvas.

[0060] The set of local coordinate points refers to the set of coordinates of pixels whose pigment color information has undergone substantial changes during the current update process.

[0061] In one possible implementation, when the graphics processor performs backsampling in parallel, for each pixel location, the updated color value or transparency value is compared with the corresponding value before the update. If the difference between the two exceeds a preset threshold, the coordinates of that pixel location are recorded in a local coordinate point set. This preset threshold can be pre-set by the system; for example, the color value difference threshold can be set to 5% of the color gradation range. When the difference between the color values ​​before and after the update exceeds this threshold, the pixel location is considered to be affected by the current pigment diffusion simulation.

[0062] In one possible implementation, during the process of updating the velocity field texture and the color field texture, a computational shader is used to synchronously mark the pixel positions where the pigment color information in the velocity field and the color field changes, and the area affected by the handwriting is determined based on the marked pixel positions.

[0063] In one possible implementation, the list of local points can be stored in the form of a coordinate array, or it can be stored in a compressed format to reduce storage overhead.

[0064] In one possible implementation, the list of local points is stored in a shader storage buffer object.

[0065] In this embodiment, by simulating pigment diffusion, the color can flow and diffuse naturally along the direction of the brushstrokes, rather than simply overlaying textures. During the process of simulating the diffusion of pigment along the direction of the brushstrokes, the area affected by the brushstrokes is determined simultaneously. This can accurately define the pixel range actually affected by the diffusion simulation, providing a precise basis for the operation area in subsequent local compositing and avoiding the computational overhead caused by full canvas processing.

[0066] Step S104: Based on the area affected by the handwriting, the updated pigment distribution data and the historical state of the canvas are locally synthesized to generate an image to be displayed and output to the screen.

[0067] The canvas's historical state refers to the state of the content already present on the canvas before the current stroke is drawn. In one possible implementation, the canvas's historical state includes data content at different levels, such as background layer texture data and dried layer texture data. The background layer is the bottommost texture of the canvas, and its texture data can include paper background color information, paper texture information, or user-preset canvas background pattern information. The dried layer is the pigment distribution data that has been cured after the completed strokes have been dried. Drying refers to the process of merging the current pigment distribution data into the dried layer texture data. After drying, the pigment distribution data no longer participates in subsequent pigment diffusion simulations but exists as a fixed base for the canvas, simulating the physical properties of ink pigments drying and curing on paper.

[0068] In this embodiment, based on the area affected by the handwriting, the updated pigment distribution data is locally composited with the historical state of the canvas to generate an image to be displayed, which is then output to the screen, presenting the final result of the ink wash rendering to the user and completing a full handwriting drawing and display process. The local composite operation refers to performing a mixing operation only within the area affected by the handwriting, combining the updated pigment distribution data with the historical state of the canvas to generate composite pixel data, rather than composited across the entire canvas area.

[0069] As one possible implementation of this application Figure 3 A specific implementation flow of step S104 in the ink wash rendering method provided in this application embodiment is shown below: B1: Within the area affected by the handwriting, read the texture data corresponding to the historical state of the canvas and the updated pigment distribution data. The historical state of the canvas includes the background layer texture data and the drying layer texture data.

[0070] Texture data refers to a collection of pixel data stored in a graphics processor as a two-dimensional array. Each texture unit corresponds to a pixel position on the canvas, storing the color value and transparency value at that position.

[0071] In one possible implementation, the background layer texture data, the air-dried layer texture data, and the texture data (color field texture) corresponding to the updated pigment distribution data are stored in different textures. These textures have the same size, so that the data of the same pixel position in different textures can be mapped pixel by pixel.

[0072] In this embodiment, the reading operation of the texture data corresponding to the historical state of the canvas and the updated pigment distribution data is not performed on the entire canvas area, but is limited to the area affected by the brushstrokes. Specifically, the graphics processor only initiates reading operations on the pixel positions indicated by the coordinate points in the set of local coordinate points recorded during the pigment diffusion simulation. For pixel positions outside the area affected by the brushstrokes, no reading operation is performed. This method of limiting the reading range avoids reading data from the entire canvas area, reducing the memory access bandwidth consumption of the graphics processor.

[0073] B2: Perform a mixing operation on the obtained background layer texture data, air-dried layer texture data, and texture data corresponding to the updated pigment distribution data to obtain a locally synthesized image.

[0074] Blending operations refer to the process of combining the color and transparency values ​​of the same pixel location in the texture data corresponding to the read background layer texture data, dried layer texture data, and updated pigment distribution data, according to preset blending rules, to generate a composite color value and composite transparency value for that pixel location. Blending operations can employ various blending modes, such as transparency blending mode, overlay blending mode, or multiply blending mode, to present different ink painting visual effects.

[0075] In one possible implementation, the blending operation employs a transparency blending mode: for each pixel location, the weight of that layer in the final composite result is determined based on the transparency values ​​of the texture data from each layer. Specifically, for each pixel location, the transparency value of that pixel location in the texture data corresponding to the updated pigment distribution data is obtained, and this transparency value is used as the weight of the pigment distribution data; the transparency value or a preset weight value of that pixel location in the background layer texture data is obtained, and used as the weight of the background layer; the transparency value or a preset weight value of that pixel location in the dried layer texture data is obtained, and used as the weight of the dried layer. Then, the color values ​​of each layer are weighted and summed according to the weights of each layer to obtain the composite color value and composite transparency value for that pixel location. In the transparency blending mode, the range of transparency values ​​can be normalized to between 0 and 1, where a transparency value of 1 indicates that the layer is completely opaque, and a transparency value of 0 indicates that the layer is completely transparent.

[0076] The transparency values ​​of the updated pigment distribution data may vary at different pixel locations. Pigment transparency values ​​are lower near the center of the brushstroke, indicating high pigment concentration and strong coverage at that location; conversely, pigment transparency values ​​are higher further away from the center, indicating thinner pigment and weaker coverage at that location. In transparency blending mode, the composite result near the center of the brushstroke is dominated by the updated pigment distribution data, while the composite result further away from the center is dominated by the background layer texture data and the dried layer texture data. After blending, a locally composited image is formed. A locally composited image is a local image that contains only the updated pixel data within the area affected by the brushstroke, and contains no valid data outside the area affected by the brushstroke.

[0077] In one possible implementation, the blending operation uses the Multiply blending mode: for each pixel location, the color value of that pixel location in the upper layer texture data is multiplied by the color value of that pixel location in the lower layer texture data, and then divided by the upper limit of the color value range to obtain the composite color value of that pixel location. The Multiply blending mode can simulate the effect of pigment penetrating the paper surface and blending with the paper's base color.

[0078] For example, suppose a pixel in the background texture data represents the background color of rice paper, the pixel in the dried texture data represents the color of previously drawn and dried ink, and the pixel in the updated pigment distribution data represents the wet ink color of the current brushstroke. During the blending operation, following the layer order from background to foreground, the background layer and the dried layer are blended first, and then the blending result is blended with the updated pigment distribution data to finally obtain the comprehensive color value of that pixel.

[0079] B3: Generate an image to be displayed based on the locally synthesized image, and output the image to be displayed to the screen.

[0080] The local composite image is the output of the blending operation, representing the new composite image generated within the area affected by the handwriting.

[0081] In one possible implementation, the locally synthesized image can be directly output as the image to be displayed. In another possible implementation, the locally synthesized image can be edge-smoothed within the area affected by the handwriting before generating the image to be displayed, so that the pixel color values ​​at the edge form a smooth transition with the color values ​​of the surrounding pixels, thereby eliminating edge jaggedness or color abruptness caused by local synthesis.

[0082] One possible implementation is to use Fast Approximate Anti-Aliasing (FXAA) to perform edge smoothing. This method identifies edges by detecting changes in pixel brightness and then smooths the edge pixels. After edge smoothing, the jagged edges of the handwriting can be effectively suppressed, improving the visual quality of the drawn image.

[0083] In this embodiment, the image to be displayed is written into the screen frame buffer and then output to the screen by the display driver. The screen frame buffer is a storage area in the graphics processor that corresponds one-to-one with screen pixels. The pixel data written into the screen frame buffer is periodically read by the display controller according to the screen refresh rate and converted into screen display signals. After the screen output is completed, the user can see the complete image containing the ink brushstroke effect on the touch screen.

[0084] In this embodiment, within the area affected by the handwriting, pixel data is read from the historical state texture of the canvas and the updated pigment distribution data texture. The updated pigment distribution data is then mixed with the historical state of the canvas (background layer and dried layer) to allow the newly drawn pigments to blend naturally with the existing content of the canvas at the boundary, forming a complete composite image. Furthermore, by limiting the reading range and mixing operation to the area affected by the handwriting, the full canvas traversal and mixing operation are avoided, which can effectively reduce the computational load of the graphics processor. This reduces the rendering computational overhead while achieving a natural and flowing ink painting effect. Finally, the image to be displayed is written to the screen frame buffer and output to the screen to complete the real-time display of the ink painting result.

[0085] As one possible implementation of this application Figure 4 This application illustrates a specific implementation flow of handling pen-lifting events in the ink wash rendering method provided in this embodiment, detailed below: C1: When a pen lifting event is detected, an end touch point is generated to complete the ink diffusion simulation at the end of the current pen stroke.

[0086] A pen lift event refers to the event in which a user lifts the object (such as a finger or stylus) off the screen after completing a continuous stroke of writing on the touchscreen.

[0087] When a pen lift event is detected, the acquisition of the touch point sequence terminates. However, the ink diffusion process at the end of the current stroke may not have been fully completed. That is, during the user's writing process, the ink diffusion simulation continues as touch points are continuously input. When the last touch point is processed, the ink diffusion corresponding to that touch point may not have been fully executed. Therefore, when a pen lift event is detected, one or more end touch points are generated in the stroke extension direction based on the position information of the last original touch point and the stroke direction information. These end touch points are virtual touch points. These virtual touch points also have coordinates and a stroke area. The coordinates extend along the stroke direction, and the stroke area can be set to be the same as the stroke area of ​​the last original touch point, or it can be set according to a preset attenuation rule. For example, it can gradually decrease to zero according to the extension distance of the stroke direction to simulate the effect of the stroke gradually becoming thinner and the ink gradually fading when the pen is lifted. As a supplement to the touch point sequence, the end touch point provides additional diffusion simulation input, allowing the pigment to continue to flow and diffuse along the direction of the stroke at the end of the stroke, forming a natural finishing effect. This avoids abnormal phenomena such as abrupt changes in pigment distribution or abrupt interruptions at the end of the stroke, thereby improving the completeness of a single stroke.

[0088] C2: Clear the temporary flow rate data generated by the pigment diffusion simulation.

[0089] Temporary flow velocity data refers to the flow velocity information stored in the velocity field texture during the current pigment diffusion simulation, used to drive the pigment diffusion along the stroke direction. This flow velocity information is a temporary intermediate calculation result corresponding to the current stroke and is only valid during the continuous drawing of the current stroke. When the pen is lifted, the pigment diffusion of the current stroke is complete, and this temporary flow velocity information is no longer useful. If it is not cleared, it may interfere with the initial state of the flow velocity for the next stroke, leading to unexpected pigment flow. By clearing the temporary flow velocity data, the flow velocity data corresponding to the current stroke in the velocity field texture is reset to its initial state (for example, both the horizontal and vertical components of the flow velocity vector are set to zero). It should be noted that the object cleared here is the temporary flow velocity data written for the current stroke, and does not involve data from other historical strokes.

[0090] C3: Set the updated pigment distribution data as the historical state of the canvas for the next round of ink wash rendering.

[0091] After the brushstroke event, the current stroke is complete, and its pigment distribution data should become part of the canvas's historical state. The updated pigment distribution data is set as the historical state of the canvas for the next round of ink wash rendering. This includes preserving the final pigment color and transparency values ​​written to the current stroke in the color field texture as background data for subsequent stroke compositing operations, maintaining the continuity of state between multiple brushstrokes. In this way, when the next stroke is drawn and local compositing is performed, it can read the pigment data of the previous stroke as part of the canvas's historical state, allowing multiple strokes to be layered and blended, forming a layered, overlapping ink wash effect.

[0092] In this embodiment, after a pen-lifting event is detected, a set of end-touch points are generated to ensure sufficient pigment diffusion simulation at the end of the stroke, forming a natural finishing shape. By clearing the temporary flow rate data generated by the pigment diffusion simulation, the temporary state in the velocity field texture is released, avoiding interference from residual flow rate data on the pigment diffusion simulation of subsequent strokes, ensuring the independence of each stroke. Then, the updated pigment distribution data is set as the canvas history state for the next round of rendering, ensuring that subsequent strokes can continue to be superimposed on the current drawing result.

[0093] As one possible implementation of this application Figure 5 This application illustrates a specific implementation flow of processing the drying command in the ink wash rendering method provided in this embodiment, detailed below: D1: When a drying command is detected, the updated pigment distribution data is merged into the drying layer texture data.

[0094] The drying command is a control command triggered by the user to perform a drying operation on the current canvas.

[0095] The updated pigment distribution data is merged into the air-dried layer texture data. This includes reading all current pigment distribution data from the color field texture, performing a mixing operation between the color and transparency values ​​in the pigment distribution data and the corresponding pixel values ​​in the air-dried layer texture data, and writing the mixing result into the air-dried layer texture data.

[0096] In one possible implementation, the color and transparency values ​​in the pigment distribution data can be mixed with the corresponding pixel values ​​in the dried layer texture data using either a direct overlay method or a layer-by-layer overlay method. The direct overlay method means that the pigment data in the color field texture directly overwrites the original data at the corresponding position in the dried layer texture; the layer-by-layer overlay method means that the pigment data in the color field texture and the original data at the corresponding position in the dried layer texture are weighted and mixed according to transparency weights.

[0097] D2: Clear the flow rate data and pigment distribution data generated by the pigment diffusion simulation.

[0098] Unlike the pen-lifting process, which only clears temporary flow rate data, the drying process requires clearing both flow rate data and pigment distribution data. This is because the pigment distribution data has been merged into the drying layer, and the color field texture needs to be cleared for use in the next round of drawing. Clearing flow rate data means resetting the flow rate data written in the current stroke in the velocity field texture to its initial state; clearing pigment distribution data means resetting the pigment data corresponding to the current stroke in the color field texture to its initial state (e.g., setting the color value to zero and the transparency value to a value representing complete transparency). After the drying process, the solidified pigment data has been merged into the drying layer texture data, and the dynamic pigment data in the color field texture no longer has any value for retention and is therefore cleared.

[0099] D3: Clear the local compositing cache data generated during the local compositing process so that the dried layer texture data can be used as the historical state of the canvas for the next round of ink wash rendering.

[0100] Local compositing cache data refers to intermediate data generated by the graphics processor during local compositing operations, such as compositing textures generated by the overlay compositing shader and smoothing textures generated by the edge smoothing shader. Clearing local compositing cache data means resetting the cache storing this intermediate data to its initial state. By clearing the local compositing cache data, the local compositing module is restored to its initial state, ensuring that subsequent local compositing operations on brushstrokes are not affected by historical cached data. Afterward, the canvas's historical state will only include the background layer texture data and the updated dried layer texture data, and subsequent brushstrokes will be drawn directly on this dried base.

[0101] In this embodiment, by merging pigment distribution data into the air-dried layer texture data, the current liquid pigment state is transformed into a permanent air-dried state, thereby achieving solidified storage of the currently drawn content; by clearing temporary flow rate data, pigment distribution data, and local compositing cache data, the storage resources in the graphics processor used for dynamic rendering are released, the rendering pipeline is restored to its initial state, and the superposition of old and new data is avoided to produce unexpected effects, thus preparing for a new round of drawing.

[0102] In one possible implementation, in response to a save command, the complete texture data of the image to be displayed is read; the complete texture data is vertically flipped; and the processed complete texture data is exported and stored as an image file.

[0103] A save command is a user-triggered control instruction used to save the current canvas content as an image file. In response to the save command, the complete texture data of the image to be displayed is read. This texture data corresponds to the final rendered result currently displayed on the screen, containing all overlay information of the background layer, the drying layer, and the current paint distribution data. Because the texture coordinate system inside the graphics processor differs from the general image file storage coordinate system, direct saving would result in the image being upside down. Therefore, the texture data needs to be vertically flipped to reverse the row order, ensuring the saved image orientation matches the screen display. After the flipping process, the pixel data is encoded according to a specified image format and written to the device's storage space (e.g., the device's internal storage or an external memory card), generating an image file that can be read and displayed by image viewing software.

[0104] By responding to the save command, the current ink painting content is persistently stored in a common image format, making it easy for users to view, share, or import into other applications later.

[0105] As can be seen from the above, in this embodiment, by obtaining a sequence of touch points containing coordinates and brushstroke area, and determining the brushstroke direction information based on the coordinates of at least two touch points, a directional basis is provided for the pigment diffusion simulation. Then, based on the brushstroke direction information and brushstroke area, the pigment diffusion simulation is performed in the graphics processor, so that the update of the pigment distribution data can reflect the natural flow characteristics of ink along the brushstroke direction, effectively improving the realism of the drawing effect. At the same time, the brushstroke influence area affected by the diffusion simulation is determined synchronously during the pigment diffusion simulation process, so that the subsequent local compositing operation can be precisely limited to the actual affected area. Finally, based on the brushstroke influence area, the updated pigment distribution data and the historical state of the canvas are locally composited and output for display. Since the compositing operation is only performed on the local area actually affected by the brushstroke, the full canvas traversal processing is avoided, which can effectively reduce the computational overhead of the graphics processor. Thus, while reducing the rendering computational overhead, an ink painting effect with a natural flow is achieved.

[0106] It should be understood that the sequence number of each step in the above embodiments does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.

[0107] Corresponding to the ink wash rendering method described in the above embodiments, Figure 6 A structural block diagram of the ink-wash rendering apparatus provided in the embodiments of this application is shown. For ease of explanation, only the parts related to the embodiments of this application are shown.

[0108] Reference Figure 6The ink painting rendering device includes a touch point acquisition unit 61, a stroke direction determination unit 62, a diffusion simulation unit 63, and a local compositing unit 64, wherein: The touch point acquisition unit 61 is used to acquire a touch point sequence, wherein each touch point in the touch point sequence includes coordinates and pen stroke area; The handwriting direction determination unit 62 is used to determine handwriting direction information based on the coordinates of at least two touch points in the touch point sequence; The diffusion simulation unit 63 is used to perform pigment diffusion simulation in the graphics processor based on the handwriting direction information and the pen stroke area to obtain updated pigment distribution data, and to determine the handwriting influence area affected by the pigment diffusion simulation during the pigment diffusion simulation process. The local synthesis unit 64 is used to locally synthesize the updated pigment distribution data and the historical state of the canvas according to the area affected by the handwriting, and generate an image to be displayed and output it to the screen.

[0109] As one possible implementation of this application, the diffusion simulation unit 63 includes a first processing module for: In the graphics processor, the flow rate information is updated based on the pen stroke direction information and the pen stroke area; The pigment color information is sampled based on the updated flow rate information, and the pigment diffusion along the direction of the brushstroke is simulated to obtain updated pigment distribution data.

[0110] As one possible implementation of this application, the flow rate information is stored in two sets of velocity field textures, the pigment color information is stored in two sets of color field textures, the two sets of velocity field textures and the two sets of color field textures are alternately read and written, and are exchanged after synchronization through memory barriers after a single update.

[0111] As one possible implementation of this application, the diffusion simulation unit 63 includes a second processing module for: During the pigment diffusion simulation, the set of affected local coordinate points is recorded, a list of local points is generated, and the area indicated by the list of local points is determined as the area affected by the handwriting.

[0112] As one possible implementation of this application, the local synthesis unit 64 is specifically used for: Within the area affected by the handwriting, read the texture data corresponding to the historical state of the canvas and the updated pigment distribution data. The historical state of the canvas includes background layer texture data and dried layer texture data. The texture data corresponding to the background layer texture data, the dried layer texture data, and the updated pigment distribution data are mixed and processed to obtain a locally synthesized image. An image to be displayed is generated based on the locally synthesized image, and the image to be displayed is output to the screen.

[0113] As one possible implementation of this application, the ink wash rendering device further includes a pen-lifting processing unit, used for: When a pen lift event is detected, an end touch point is generated to simulate the ink diffusion at the end of the current pen stroke. Clear the temporary flow rate data generated by the pigment diffusion simulation; Set the updated pigment distribution data as the historical state of the canvas for the next round of ink wash rendering.

[0114] As one possible implementation of this application, the ink-wash rendering apparatus further includes a drying instruction processing unit, used for: When a drying command is detected, the updated pigment distribution data is merged into the dried layer texture data; Clear the flow rate data and pigment distribution data generated by the pigment diffusion simulation; Clear the local compositing cache data generated during the local compositing process so that the dried layer texture data can be used as the historical state of the canvas for the next round of ink wash rendering.

[0115] As can be seen from the above, in this embodiment, by obtaining a sequence of touch points containing coordinates and brushstroke area, and determining the brushstroke direction information based on the coordinates of at least two touch points, a directional basis is provided for the pigment diffusion simulation. Then, based on the brushstroke direction information and brushstroke area, the pigment diffusion simulation is performed in the graphics processor, so that the update of the pigment distribution data can reflect the natural flow characteristics of ink along the brushstroke direction, effectively improving the realism of the drawing effect. At the same time, the brushstroke influence area affected by the diffusion simulation is determined synchronously during the pigment diffusion simulation process, so that the subsequent local compositing operation can be precisely limited to the actual affected area. Finally, based on the brushstroke influence area, the updated pigment distribution data and the historical state of the canvas are locally composited and output for display. Since the compositing operation is only performed on the local area actually affected by the brushstroke, the full canvas traversal processing is avoided, which can effectively reduce the computational overhead of the graphics processor. Thus, while reducing the rendering computational overhead, an ink painting effect with a natural flow is achieved.

[0116] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0117] This application embodiment also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements... Figures 1 to 5 This represents the steps of any ink wash rendering method.

[0118] This application embodiment also provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements... Figures 1 to 5 This represents the steps of any ink wash rendering method.

[0119] This application also provides a computer program product that, when run on a terminal device, causes the terminal device to execute the implementation of... Figures 1 to 5 This represents the steps of any ink wash rendering method.

[0120] Figure 7 This is a schematic diagram of a terminal device provided in an embodiment of this application. For example... Figure 7 As shown, the terminal device 7 in this embodiment includes: a processor 70, a memory 71, and a computer program 72 stored in the memory 71 and executable on the processor 70. When the processor 70 executes the computer program 72, it implements the steps in the various ink wash rendering method embodiments described above, for example... Figure 1 Steps S101 to S104 are shown. Alternatively, when the processor 70 executes the computer program 72, it implements the functions of each module / unit in the above-described device embodiments, for example... Figure 6 The functions of units 61 to 64 are shown.

[0121] For example, the computer program 72 may be divided into one or more modules / units, which are stored in the memory 71 and executed by the processor 70 to complete this application. The one or more modules / units may be a series of computer-readable instruction segments capable of performing a specific function, which describe the execution process of the computer program 72 in the terminal device 7.

[0122] The terminal device 7 may include, but is not limited to, a processor 70 and a memory 71. Those skilled in the art will understand that... Figure 7 This is merely an example of terminal device 7 and does not constitute a limitation on terminal device 7. It may include more or fewer components than shown, or combine certain components, or different components. For example, terminal device 7 may also include input / output devices, network access devices, buses, etc.

[0123] The processor 70 can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0124] The memory 71 can be an internal storage unit of the terminal device 7, such as a hard disk or memory of the terminal device 7. The memory 71 can also be an external storage device of the terminal device 7, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the terminal device 7. Furthermore, the memory 71 can include both internal and external storage units of the terminal device 7. The memory 71 is used to store the computer program and other programs and data required by the terminal device. The memory 71 can also be used to temporarily store data that has been output or will be output.

[0125] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.

[0126] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0127] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying computer program code to a device / terminal equipment, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.

[0128] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0129] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A method for ink wash painting, characterized in that, include: Obtain a sequence of touch points, wherein each touch point in the sequence includes coordinates and pen stroke area; The handwriting direction information is determined based on the coordinates of at least two touch points in the touch point sequence; Based on the handwriting direction information and the stroke area, a pigment diffusion simulation is performed in the graphics processor to obtain updated pigment distribution data, and the handwriting influence area affected by the pigment diffusion simulation is determined during the pigment diffusion simulation process. Based on the area affected by the handwriting, the updated pigment distribution data is locally synthesized with the historical state of the canvas to generate an image to be displayed and output to the screen.

2. The method according to claim 1, characterized in that, The step of simulating pigment diffusion in a graphics processor based on the handwriting direction information and the stroke area to obtain updated pigment distribution data includes: In the graphics processor, the flow rate information is updated based on the pen stroke direction information and the pen stroke area; The pigment color information is sampled based on the updated flow rate information, and the pigment diffusion along the direction of the brushstroke is simulated to obtain updated pigment distribution data.

3. The method according to claim 2, characterized in that, The flow rate information is stored in two sets of velocity field textures, and the pigment color information is stored in two sets of color field textures. The two sets of velocity field textures and the two sets of color field textures are read and written alternately, and are exchanged after synchronization through memory barriers after a single update.

4. The method according to claim 1, characterized in that, The process of determining the area of ​​influence of the handwriting affected by the pigment diffusion simulation during the pigment diffusion simulation includes: During the pigment diffusion simulation, the set of affected local coordinate points is recorded, a list of local points is generated, and the area indicated by the list of local points is determined as the area affected by the handwriting.

5. The method according to claim 1, characterized in that, The step of locally synthesizing the updated pigment distribution data with the historical state of the canvas based on the area affected by the handwriting to generate an image to be displayed and output to the screen includes: Within the area affected by the handwriting, read the texture data corresponding to the historical state of the canvas and the updated pigment distribution data. The historical state of the canvas includes background layer texture data and dried layer texture data. The texture data corresponding to the background layer texture data, the dried layer texture data, and the updated pigment distribution data are mixed and processed to obtain a locally synthesized image. An image to be displayed is generated based on the locally synthesized image, and the image to be displayed is output to the screen.

6. The method according to any one of claims 1 to 5, characterized in that, The method further includes: When a pen lift event is detected, an end touch point is generated to simulate the ink diffusion at the end of the current pen stroke. Clear the temporary flow rate data generated by the pigment diffusion simulation; Set the updated pigment distribution data as the historical state of the canvas for the next round of ink wash rendering.

7. The method according to any one of claims 1 to 5, characterized in that, The method further includes: When a drying command is detected, the updated pigment distribution data is merged into the dried layer texture data; Clear the flow rate data and pigment distribution data generated by the pigment diffusion simulation; Clear the local compositing cache data generated during the local compositing process so that the dried layer texture data can be used as the historical state of the canvas for the next round of ink wash rendering.

8. A watercolor rendering device, characterized in that, include: A touch point acquisition unit is used to acquire a sequence of touch points, wherein each touch point in the sequence includes coordinates and pen stroke area; The handwriting direction determination unit is used to determine handwriting direction information based on the coordinates of at least two touch points in the touch point sequence; The diffusion simulation unit is used to perform pigment diffusion simulation in the graphics processor based on the handwriting direction information and the pen stroke area to obtain updated pigment distribution data, and to determine the handwriting influence area affected by the pigment diffusion simulation during the pigment diffusion simulation process. The local synthesis unit is used to locally synthesize the updated pigment distribution data and the historical state of the canvas according to the area affected by the handwriting, and generate an image to be displayed and output it to the screen.

9. A terminal device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the ink wash rendering method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the ink wash rendering method as described in any one of claims 1 to 7.