Distortion effect generation method, device, equipment and storage medium
By processing water ripples, annular ripples and spiral distortions on the image texture, and combining the distortion texture coordinates input by the user for superposition, the problem of difficulty in integrating multiple distortion effects in the existing technology is solved, and the image quality and effect are improved.
Patent Information
- Application Number
- CN202110077490.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-10-23
- Publication Date
- 2024-09-27
- Estimated Expiration
- 2040-10-23
AI Technical Summary
The existing technology cannot effectively integrate multiple distortion effects, resulting in poor distortion effects of rendered images and reducing image quality.
By obtaining the image texture, water ripple distortion, circular ripple distortion and spiral distortion are performed in sequence, combined with the distortion texture coordinates input by the user for superposition, and finally the image texture is sampled and radially distorted to generate a mixed distortion effect.
It realizes the free combination of multiple distortion algorithms, improves the image quality of the distorted image texture, and generates richer and more realistic picture rotation and fluctuation effects.
Smart Images

Figure CN112652047B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to a distortion effect generation method, device, equipment and storage medium. Background Art
[0002] In the related art, in the scene where the rendered image needs to be processed with a distortion effect, only one distortion effect processing method can be used to process the rendered image, and the purpose of integrating multiple distortion effects cannot be achieved. If only a single distortion effect processing method is used to process the rendered image, the distortion effect of the obtained distorted image will be poor, thereby reducing the image quality of the distorted image. Summary of the invention
[0003] The embodiments of the present invention provide a distortion effect generation method, device, equipment and storage medium, which are used to improve the distortion effect of a distorted image and improve the image quality of the distorted image.
[0004] In a first aspect, an embodiment of the present invention provides a method for generating a distortion effect, the method comprising: obtaining an image texture; performing a distortion process on texture coordinates corresponding to the image texture to obtain a first distorted texture coordinate, the distortion process comprising water ripple distortion, annular ripple distortion and spiral distortion in sequence; obtaining a second distorted texture coordinate input by a user, superimposing the first distorted texture coordinate with the second distorted texture coordinate input by the user to obtain a final sampling coordinate; sampling the image texture through the final sampling coordinate, and outputting the sampling result to a temporary texture cache; performing a radial distortion process on the sampling result in the temporary texture cache to obtain a mixed distorted image texture, and displaying the mixed distorted image texture on a screen.
[0005] Optionally, the warping of the texture coordinates corresponding to the image texture to obtain first warped texture coordinates further includes: warping the texture coordinates of the image texture in a sorting order of the warping, and each time the texture coordinates of the image texture are warped, determining the image texture obtained by the current warping as the image texture to be used for the next warping.
[0006] Optionally, the distortion processing includes a water ripple distortion effect, and the distortion processing of the texture coordinates corresponding to the image texture includes: performing a water ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a first distortion vector after water ripple distortion; and determining the texture coordinates after water ripple distortion based on the initial texture coordinates of each pixel point in the image texture and the first distortion vector.
[0007] Optionally, the obtaining of the second distorted texture coordinates input by the user, and superimposing the first distorted texture coordinates with the second distorted texture coordinates input by the user to obtain the final sampling coordinates, includes: obtaining the second distorted texture coordinates input by the user, the second distorted texture coordinates including component values of a red r channel and a green g channel; sampling the second distorted texture coordinates through the texture coordinates distorted by the water ripples to obtain a third distortion vector; and adding the initial texture coordinates of each pixel point in the image texture to the corresponding third distortion vector to obtain the final sampling coordinates distorted by the water ripples.
[0008] Optionally, performing water ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture includes:
[0009] The water ripple distortion calculation is performed on the initial texture coordinates of each pixel point in the image texture by using the formula; the formula is:
[0010] The formula is:
[0011] WaveDistortion.x'=sin(DistanceToCenter-Time*5)*0.2
[0012] WaveDistortion.x=WaveDistortion.x'+sin(CurrentTexcoord.y-Time*5)*0.2WaveDistortion.y'=cos(DistanceToCenter-Time*5)*0.2
[0013] WaveDistortion.y=WaveDistortion.y'+cos(CurrentTexcoord.x-Time*5)*0.2
[0014] Among them, WaveDistortion.x is the final offset component of the initial texture coordinates of any pixel point in the image texture in the horizontal direction, WaveDistortion.y is the final offset component of the initial texture coordinates of any pixel point in the image texture in the vertical direction, DistanceToCenter is the distance between the current pixel point and the center point in the image texture, CurrentTexcoord.x and CurrentTexcoord.y are the initial texture coordinates of the current pixel point in the image texture, and Time is the time difference between the program startup time and the image texture rendering time.
[0015] Optionally, the distortion effect processing includes a circular ripple distortion effect, and the distortion processing of the texture coordinates corresponding to the image texture includes: performing a circular ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a fourth distortion vector after the circular ripple distortion; and determining the texture coordinates after the circular ripple distortion based on the initial texture coordinates of each pixel point in the image texture and the fourth distortion vector.
[0016] Optionally, the step of obtaining a second distorted texture coordinate input by a user and superimposing the first distorted texture coordinate with the second distorted texture coordinate input by the user to obtain a final sampling coordinate includes: obtaining a fifth distorted texture coordinate input by the user, the fifth distorted texture coordinate including component values of a red r channel and a green g channel; sampling the fifth distorted texture coordinate through the texture coordinate distorted by the annular ripple to obtain a sixth distortion vector; and adding the initial texture coordinate of each pixel point in the image texture to the corresponding sixth distortion vector to obtain the final sampling coordinate distorted by the annular ripple.
[0017] Optionally, performing annular ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture includes:
[0018] The initial texture coordinates of each pixel in the image texture are subjected to annular ripple distortion calculation by a formula; the formula is:
[0019] WaveDistortion.x=sin(DistanceToCenter-Time*5)*0.2WaveDistortion.y=sin(DistanceToCenter-Time*5)*0.2
[0020] Wherein, WaveDistortion.x is the final offset component of the initial texture coordinates of any pixel point in the image texture in the horizontal direction, WaveDistortion.y is the final offset component of the initial texture coordinates of any pixel point in the image texture in the vertical direction, and Time is the time difference between the program startup time and the time when the image texture is rendered. Optionally, the distortion effect processing includes a spiral distortion effect, and the distortion processing of the texture coordinates corresponding to the image texture includes: performing a spiral distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a seventh distortion vector after spiral distortion; and determining the texture coordinates after spiral distortion based on the initial texture coordinates of each pixel point in the image texture and the seventh distortion vector.
[0021] Optionally, the performing spiral distortion calculation on the initial texture coordinates of each pixel point in the image texture includes:
[0022] The spiral distortion calculation is performed on the initial texture coordinates of each pixel in the image texture by using the formula; the formula is:
[0023] DeltaUV=CurrentTexcoord-DistortCenter
[0024] RotatedDistortion.x=cos(RotateAngle)*DeltaUV.x-sin(RotateAngle)*DeltaUV.y
[0025] RotatedDistortion.y=sin(RotateAngle)*DeltaUV.x-cos(RotateAngle)*DeltaUV.y
[0026] Among them, CurrentTexcoord is the initial texture coordinate of the current pixel in the image texture, DistortCenter is the disturbance center, DeltaUV includes DeltaUV.x and DeltaUV.y, RotatedDistortion.x is the distortion value in the horizontal direction after spiral distortion, RotatedDistortion.y is the distortion value in the vertical direction after spiral distortion, and RotateAngle is a value calculated based on the distance between CurrentTexcoord and DistortCenter.
[0027] Optionally, the radial distortion processing of the sampling results in the temporary texture cache includes: obtaining a radial sampling step; starting from the texture coordinates corresponding to the current pixel in the image texture, sampling the sampling results in the temporary texture cache a target number of times, adding the radial sampling step to the texture coordinates corresponding to the current pixel each time sampling, until the texture coordinates corresponding to the current pixel plus the radial sampling step reach the target coordinates; accumulating the color values obtained from each sampling, dividing the accumulated value by the target number of times, to obtain a radially distorted image texture.
[0028] Optionally, obtaining the radial sampling step length includes: obtaining the radial sampling step length by a formula; the formula is:
[0029] BlurVector=DistortCenter-CurrentTexcoord
[0030] DeltaSampling=BlurVector / BlurStepCount
[0031] Among them, DistortCenter is the disturbance center, CurrentTexcoord is the initial texture coordinate of the current pixel in the image texture, BlurVector is the direction vector between DistortCenter and CurrentTexcoord, BlurStepCount is the target number of times, and DeltaSampling is the radial sampling step.
[0032] In a second aspect, an embodiment of the present invention provides a distortion effect generating device, comprising: an acquisition module, used to acquire an image texture; a distortion module, used to distort the texture coordinates corresponding to the image texture to obtain a first distorted texture coordinate, wherein the distortion processing includes water ripple distortion, annular ripple distortion and spiral distortion in sequence; a superposition module, used to acquire a second distorted texture coordinate input by a user, and superimpose the first distorted texture coordinate with the second distorted texture coordinate input by the user to obtain a final sampling coordinate; a sampling module, used to sample the image texture through the final sampling coordinate, and output the sampling result to a temporary texture cache; a mixing module, used to perform radial distortion processing on the sampling result in the temporary texture cache to obtain a mixed distorted image texture, and display the mixed distorted image texture on a screen.
[0033] Optionally, the sampling module is also used to: perform a distortion process on the texture coordinates of the image texture according to the sorting order of the distortion process, and each time the texture coordinates of the image texture are distorted, determine the image texture obtained by the current distortion process as the image texture used for the next distortion process.
[0034] Optionally, the distortion processing includes a water ripple distortion effect, and the distortion module is used to: perform water ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a first distortion vector after water ripple distortion; and determine the texture coordinates after water ripple distortion based on the initial texture coordinates of each pixel point in the image texture and the first distortion vector.
[0035] Optionally, the overlay module is used to: obtain a second distorted texture coordinate input by a user, the second distorted texture coordinate including component values of a red r channel and a green g channel; sample the second distorted texture coordinate through the texture coordinate distorted by the water ripple to obtain a third distortion vector; add the initial texture coordinate of each pixel point in the image texture to the corresponding third distortion vector to obtain the final sampling coordinate distorted by the water ripple.
[0036] Optionally, the distortion module is used to: perform water ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture by using a formula; the formula is:
[0037] WaveDistortion.x'=sin(DistanceToCenter-Time*5)*0.2
[0038] WaveDistortion.x=WaveDistortion.x'+sin(CurrentTexcoord.y-Time*5)*0.2
[0039] WaveDistortion.y'=cos(DistanceToCenter-Time*5)*0.2
[0040] WaveDistortion.y=WaveDistortion.y'+cos(CurrentTexcoord.x-Time*5)*0.2
[0041] Among them, WaveDistortion.x is the final offset component of the initial texture coordinates of any pixel point in the image texture in the horizontal direction, WaveDistortion.y is the final offset component of the initial texture coordinates of any pixel point in the image texture in the vertical direction, DistanceToCenter is the distance between the current pixel point and the center point in the image texture, CurrentTexcoord.x and CurrentTexcoord.y are the initial texture coordinates of the current pixel point in the image texture, and Time is the time difference between the program startup time and the image texture rendering time.
[0042] Optionally, the distortion effect processing includes a circular ripple distortion effect, and the distortion module is used to: perform a circular ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a fourth distortion vector after the circular ripple distortion; and determine the texture coordinates after the circular ripple distortion based on the initial texture coordinates of each pixel point in the image texture and the fourth distortion vector.
[0043] Optionally, the overlay module is used to: obtain a fifth distorted texture coordinate input by a user, the fifth distorted texture coordinate including component values of a red r channel and a green g channel; sample the fifth distorted texture coordinate through the texture coordinate distorted by the annular ripple to obtain a sixth distortion vector; add the initial texture coordinate of each pixel point in the image texture to the corresponding sixth distortion vector to obtain a final sampling coordinate distorted by the annular ripple.
[0044] Optionally, the distortion module is used to: perform an annular ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture by using a formula; the formula is:
[0045] WaveDistortion.x=sin(DistanceToCenter-Time*5)*0.2
[0046] WaveDistortion.y=sin(DistanceToCenter-Time*5)*0.2
[0047] Among them, WaveDistortion.x is the final offset component of the initial texture coordinates of any pixel point in the image texture in the horizontal direction, WaveDistortion.y is the final offset component of the initial texture coordinates of any pixel point in the image texture in the vertical direction, DistanceToCenter is the distance between the current pixel point and the center point in the image texture, and Time is the time difference between the program startup time and the image texture rendering time.
[0048] Optionally, the distortion effect processing includes a spiral distortion effect, and the distortion module is used to: perform a spiral distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a seventh distortion vector after spiral distortion; and determine the texture coordinates after spiral distortion based on the initial texture coordinates of each pixel point in the image texture and the seventh distortion vector.
[0049] Optionally, the distortion module is used to: perform spiral distortion calculation on the initial texture coordinates of each pixel point in the image texture by using a formula; the formula is:
[0050] DeltaUV=CurrentTexcoord-DistortCenter
[0051] RotatedDistortion.x=cos(RotateAngle)*DeltaUV.x-sin(RotateAngle)*DeltaUV.y
[0052] RotatedDistortion.y=sin(RotateAngle)*DeltaUV.x-cos(RotateAngle)*DeltaUV.y
[0053] Among them, CurrentTexcoord is the initial texture coordinate of the current pixel in the image texture, DistortCenter is the disturbance center, DeltaUV includes DeltaUV.x and DeltaUV.y, RotatedDistortion.x is the distortion value in the horizontal direction after spiral distortion, RotatedDistortion.y is the distortion value in the vertical direction after spiral distortion, and RotateAngle is a value calculated based on the distance between CurrentTexcoord and DistortCenter.
[0054] Optionally, the mixing module is used to: obtain a radial sampling step;
[0055] Starting from the texture coordinates corresponding to the current pixel in the image texture, the sampling results in the temporary texture cache are sampled a target number of times, and the texture coordinates corresponding to the current pixel are added to the radial sampling step each time the sampling is performed, until the texture coordinates corresponding to the current pixel plus the radial sampling step reach the target coordinates; the color values obtained from each sampling are accumulated, and the accumulated value is divided by the target number of times to obtain a radially distorted image texture.
[0056] Optionally, the mixing module is used to obtain the radial sampling step length through a formula; the formula is:
[0057] BlurVector=DistortCenter-CurrentTexcoord
[0058] DeltaSampling=BlurVector / BlurStepCount
[0059] Among them, DistortCenter is the disturbance center, CurrentTexcoord is the initial texture coordinate of the current pixel in the image texture, BlurVector is the direction vector between DistortCenter and CurrentTexcoord, BlurStepCount is the target number of times, and DeltaSampling is the radial sampling step.
[0060] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a processor and a memory, wherein the memory stores executable code, and when the executable code is executed by the processor, the processor can at least implement the distortion effect generating method in the first aspect.
[0061] In a fourth aspect, an embodiment of the present invention provides a non-temporary machine-readable storage medium having executable code stored thereon. When the executable code is executed by a processor of an electronic device, the processor can at least implement the distortion effect generating method in the first aspect.
[0062] The present invention can freely combine multiple distortion algorithms, and iteratively superimpose distorted image textures output by different distortion algorithms to achieve richer and more realistic distortion effects such as image rotation and fluctuation. The present invention can improve the image quality of distorted image textures. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0064] Figure 1 A schematic diagram of a flow chart of a method for generating a distortion effect provided by an embodiment of the present invention;
[0065] Figure 2 A schematic diagram of the effect of enabling a switch option provided by an embodiment of the present invention;
[0066] Figure 3 A schematic structural diagram of a distortion effect generating device provided by an embodiment of the present invention;
[0067] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0068] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0069] The terms used in the embodiments of the present invention are only for the purpose of describing specific embodiments, and are not intended to limit the present invention. The singular forms "a", "said" and "the" used in the embodiments of the present invention and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings, and "multiple" generally includes at least two.
[0070] As used herein, the words “if” and “if” may be interpreted as “when” or “when” or “in response to determining” or “in response to detecting,” depending on the context. Similarly, the phrases “if it is determined” or “if (stated condition or event) is detected” may be interpreted as “when it is determined” or “in response to determining” or “when detecting (stated condition or event)” or “in response to detecting (stated condition or event),” depending on the context.
[0071] In addition, the step sequence in the following method embodiments is only an example and not a strict limitation.
[0072] Figure 1 A flowchart of a method for generating a distortion effect provided by an embodiment of the present invention is shown in FIG. Figure 1 As shown, the method comprises the following steps:
[0073] 101. Get image texture.
[0074] 102. Perform a distortion process on the texture coordinates corresponding to the image texture to obtain first distorted texture coordinates, where the distortion processes sequentially include water ripple distortion, annular ripple distortion, and spiral distortion.
[0075] 103. Obtain the second distorted texture coordinates input by the user, and superimpose the first distorted texture coordinates with the second distorted texture coordinates input by the user to obtain final sampling coordinates.
[0076] 104. Sample the image texture using the final sampling coordinates, and output the sampling result to a temporary texture cache.
[0077] 105. Perform radial distortion processing on the sampling result in the temporary texture cache to obtain a mixed distorted image texture, and display the mixed distorted image texture on the screen.
[0078] In the embodiment of the present invention, a variety of distortion algorithms are provided. The present invention can be used to freely combine the various distortion algorithms to achieve more rich and realistic distortion effects such as picture rotation and fluctuation. The present invention can be applied to the special effects processing process of science fiction movies, and can also be applied to various different distortion effect processing scenarios such as the underwater perspective effect processing process in games.
[0079] In practical applications, first, the image texture can be obtained. The initial image texture is an image that has not been processed with any distortion effect. Assuming that the image texture needs to be distorted, any two or any multiple distortion effects can be selected from a variety of distortion effects according to actual application requirements for iterative superposition, and different distortion effects can be combined together to finally output a mixed distorted image texture. The distortion effect can include a water ripple distortion effect, a ring ripple distortion effect, a spiral distortion effect, a radial distortion effect, and a distortion effect input by a user.
[0080] It should be noted that if Figure 2 As shown, a corresponding enable switch option can be set for each distortion effect, so that when the user selects the enable option corresponding to a certain distortion effect, the distortion effect can be added. Correspondingly, when the user turns off the enable switch option corresponding to a certain distortion effect, the distortion effect can be skipped without any processing. Optionally, the distortion processing of the texture coordinates corresponding to the image texture to obtain the first distorted texture coordinates also includes: according to the sorting order of the distortion processing, the texture coordinates of the image texture are distorted, and each time the texture coordinates of the image texture are distorted, the image texture obtained by the current distortion processing is determined as the image texture used in the next distortion processing.
[0081] In practical applications, the texture coordinates of the image texture can be processed with distortion effects in sequence in combination with the sorting order of the distortion processing. Each time the texture coordinates of the image texture are distorted, the image texture output to the temporary texture cache after the previous distortion can be determined as the image texture for the current distortion processing. For example, assuming that it is necessary to perform water ripple distortion effects and annular ripple distortion effects on the image texture, and the image texture is subjected to water ripple distortion after the water ripple distortion effect, then in the process of performing the annular ripple distortion effect, the image texture subjected to water ripple distortion can be used as a processing object for the annular ripple distortion effect, so that a processing effect of continuous iteration and superposition can be achieved. The specific process of using the image texture output to the temporary texture cache after the previous distortion for the current distortion effect processing will be described in detail later and will not be repeated here.
[0082] (1) Water ripple distortion effect
[0083] Optionally, the distortion effect processing includes a water ripple distortion effect, and the process of distorting the texture coordinates corresponding to the image texture can be implemented as follows: performing water ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a first distortion vector after water ripple distortion; based on the initial texture coordinates of each pixel point in the image texture and the first distortion vector, determining the texture coordinates after water ripple distortion.
[0084] In practical applications, image textures can be two-dimensional images, which are the result of rasterizing a triangle in a three-dimensional space after projecting it onto a two-dimensional plane. Image textures are composed of many pixels, each of which corresponds to its own initial texture coordinates. After a series of water ripple distortion calculations for each initial texture coordinate, a first distortion vector can be obtained. The first distortion vector can also be considered as an offset vector, that is, a new texture coordinate can be obtained by offsetting the corresponding initial texture coordinates through the first distortion vector. The new texture coordinates can be used to sample the color texture corresponding to the image texture, and the image texture distorted by water ripples can be output.
[0085] The above process of calculating the water ripple distortion of the initial texture coordinates of each pixel in the image texture can be implemented by formulas 1 to 4:
[0086] WaveDistortion.x'=sin(DistanceToCenter-Time*5)*0.2 (Formula 1)
[0087] WaveDistortion.x=WaveDistortion.x'+sin(CurrentTexcoord.y-Time*5)*0.2(Formula 2)
[0088] WaveDistortion.y'=cos(DistanceToCenter-Time*5)*0.2 (Formula 3)
[0089] WaveDistortion.y=WaveDistortion.y'+cos(CurrentTexcoord.x-Time*5)*0.2(Formula 4)
[0090] Among them, WaveDistortion.x is the final offset component of the initial texture coordinates of any pixel point in the image texture in the horizontal direction, WaveDistortion.y is the final offset component of the initial texture coordinates of any pixel point in the image texture in the vertical direction, DistanceToCenter is the distance between the current pixel point and the center point in the image texture, CurrentTexcoord.x and CurrentTexcoord.y are the initial texture coordinates of the current pixel point in the image texture, Time is the time difference between the program startup time and the image texture rendering time, WaveDistortion.x' is a value determined based on DistanceToCenter and Time, and WaveDistortion.y' is a value determined based on DistanceToCenter and Time.
[0091] Optionally, if the user does not provide a distortion vector texture during the water ripple distortion process, the initial texture coordinates of each pixel in the image texture can be added to the corresponding first distortion vector to obtain the texture coordinates after the water ripple distortion, that is, the texture coordinates after the water ripple distortion can be calculated by adding WaveDistortion to CurrentTexcoord. On the other hand, if the user provides a distortion vector texture during the water ripple distortion process, the distortion vector texture can also be taken into account in the calculation of the texture coordinates after the water ripple distortion.
[0092] Optionally, obtaining a second distorted texture coordinate input by a user, and superimposing the first distorted texture coordinate with the second distorted texture coordinate input by the user to obtain a final sampling coordinate may include: obtaining the second distorted texture coordinate input by the user, the second distorted texture coordinate including component values of a red r channel and a green g channel; sampling the second distorted texture coordinate through the texture coordinate distorted by water ripples to obtain a third distortion vector; adding the initial texture coordinates of each pixel point in the image texture to the corresponding third distortion vector to obtain the final sampling coordinate distorted by water ripples.
[0093] It is understandable that the distortion vector texture can also be called the second distortion texture coordinate. The distortion vector texture is an image texture. The difference between it and a general image is that the distortion vector texture stores the normalized two-dimensional direction vector, including the x and y component values stored in the r channel and the g channel respectively. The distortion vector texture indicates the direction in which the texture coordinate needs to be distorted. The third distortion vector can be obtained by adding the distortion vector in the distortion vector texture to WaveDistortion. After obtaining the third distortion vector, the final sampling coordinate after water ripple distortion can be calculated by adding the corresponding third distortion vector to CurrentTexcoord.
[0094] Finally, the final sampling coordinates after water ripple distortion can be used to sample the color texture corresponding to the image texture.
[0095] In this way, an image texture distorted by water ripples is output. The output image texture distorted by water ripples can be stored in a color buffer.
[0096] (II) Annular corrugated distortion effect
[0097] Optionally, the distortion effect processing includes a circular ripple distortion effect, and the process of distorting the texture coordinates corresponding to the image texture can be implemented as follows: performing a circular ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a fourth distortion vector after the circular ripple distortion; based on the initial texture coordinates of each pixel point in the image texture and the fourth distortion vector, determining the texture coordinates after the circular ripple distortion.
[0098] In practical applications, the image texture is composed of many pixels, each of which corresponds to its own initial texture coordinates. After a series of annular ripple distortion calculations are performed on each initial texture coordinate, the fourth distortion vector can be obtained. The fourth distortion vector can also be considered as an offset vector, that is, the corresponding initial texture coordinate can be offset by the fourth distortion vector to obtain a new texture coordinate. The new texture coordinate can be used to sample the water ripple distorted image texture output by the previous distortion process to obtain an annular ripple distorted image texture.
[0099] The above process of calculating the annular ripple distortion of the initial texture coordinates of each pixel in the image texture can be implemented by Formula 5 to Formula 6: WaveDistortion.x = sin(DistanceToCenter-Time*5)*0.2 (Formula 5) WaveDistortion.y = sin(DistanceToCenter-Time*5)*0.2 (Formula 6)
[0100] Among them, WaveDistortion.x is the final offset component of the initial texture coordinates of any pixel point in the image texture in the horizontal direction, WaveDistortion.y is the final offset component of the initial texture coordinates of any pixel point in the image texture in the vertical direction, DistanceToCenter is the distance between the current pixel point and the center point in the image texture, and Time is the time difference between the program startup time and the image texture rendering time.
[0101] Optionally, if the user does not provide a distortion vector texture during the annular wave distortion process, the initial texture coordinates of each pixel in the image texture can be added with the corresponding first distortion vector to obtain the texture coordinates after the annular wave distortion, that is, the texture coordinates after the annular wave distortion can be calculated by adding. On the other hand, if the user provides a distortion vector texture during the annular wave distortion process, the distortion vector texture can also be taken into account in the calculation of the texture coordinates after the annular wave distortion.
[0102] Optionally, obtaining a second distorted texture coordinate input by a user, and superimposing the first distorted texture coordinate with the second distorted texture coordinate input by the user to obtain a final sampling coordinate may include: obtaining a fifth distorted texture coordinate input by the user, the fifth distorted texture coordinate including component values of an r channel and a g channel; sampling the fifth distorted texture coordinate through the texture coordinate distorted by the annular ripple to obtain a sixth distortion vector; and adding the initial texture coordinate of each pixel point in the image texture to the corresponding sixth distortion vector to obtain the final sampling coordinate distorted by the annular ripple.
[0103] It should be noted that, since the processing process of the distortion effect input by the second user is similar to the processing process of the distortion effect input by the first user, the processing process of the distortion effect input by the second user can refer to the processing process of the distortion effect input by the first user, and the processing process of the distortion effect input by the second user will not be repeated here.
[0104] (III) Spiral Twist Effect
[0105] Optionally, the distortion effect processing includes a spiral distortion effect, and the process of distorting the texture coordinates corresponding to the image texture can be implemented as follows: performing a spiral distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a seventh distortion vector after spiral distortion; and determining the texture coordinates after spiral distortion based on the initial texture coordinates of each pixel point in the image texture and the seventh distortion vector.
[0106] In practical applications, image textures are composed of many pixels, each of which corresponds to its own initial texture coordinates. After a series of spiral distortion calculations for each initial texture coordinate, the seventh distortion vector can be obtained. The seventh distortion vector can also be considered as an offset vector, that is, the corresponding initial texture coordinates can be offset by the seventh distortion vector to obtain a new texture coordinate, which can be used to sample the annular corrugated image texture output by the previous distortion process to obtain a spirally distorted image texture.
[0107] Optionally, the process of calculating the spiral distortion of the initial texture coordinates of each pixel in the image texture can be
[0108] This is achieved by Equation 7 to Equation 9:
[0109] DeltaUV=CurrentTexcoord-DistortCenter (Formula 7)
[0110] RotatedDistortion.x=cos(RotateAngle)*DeltaUV.x-sin(RotateAngle)*DeltaUV.y(Formula 8)
[0111] RotatedDistortion.y=sin(RotateAngle)*DeltaUV.x-cos(RotateAngle)*DeltaUV.y(Formula 9)
[0112] Among them, CurrentTexcoord is the initial texture coordinate of the current pixel in the image texture, CurrentTexcoord is a two-dimensional vector, DistortCenter is the disturbance center, DistortCenter is a two-dimensional vector, DeltaUV includes DeltaUV.x and DeltaUV.y, RotatedDistortion.x is the distortion value in the horizontal direction after spiral distortion, RotatedDistortion.y is the distortion value in the vertical direction after spiral distortion, and RotateAngle is a value calculated based on the distance between CurrentTexcoord and DistortCenter.
[0113] After obtaining the RotatedDistortion, the spirally distorted texture coordinates can be calculated by adding the corresponding RotatedDistortion to the CurrentTexcoord. Finally, the spirally distorted texture coordinates can be used to sample the color texture corresponding to the image texture, and the spirally distorted image texture can be output. The output spirally distorted image texture can be stored in the color buffer.
[0114] (IV) Radial distortion effect
[0115] Optionally, the process of performing radial distortion processing on the sampling results in the temporary texture cache can be implemented as follows: obtaining a radial sampling step; starting from the texture coordinates corresponding to the current pixel in the image texture, sampling the sampling results in the temporary texture cache a target number of times, adding the radial sampling step to the texture coordinates corresponding to the current pixel each time sampling, until the texture coordinates corresponding to the current pixel plus the radial sampling step reach the target coordinates; accumulating the color values obtained from each sampling, dividing the accumulated value by the target number of times, and obtaining a radially distorted image texture.
[0116] The calculation method of the above radial sampling step size can be:
[0117] BlurVector=DistortCenter-CurrentTexcoord (Formula 10)
[0118] DeltaSampling=BlurVector / BlurStepCoun (Formula 11)
[0119] Among them, DistortCenter is the disturbance center, CurrentTexcoord is the initial texture coordinate of the current pixel in the image texture, CurrentTexcoord is a two-dimensional vector, BlurVector is the direction vector between DistortCenter and CurrentTexcoord, BlurStepCount is the target number, and the user can set the target number BlurStepCount, and DeltaSampling is the radial sampling step.
[0120] The radial sampling step can be calculated by formula 10 and formula 11. After the radial sampling step is obtained, the sampling result in the temporary texture cache can be sampled BlurStepCount times starting from the texture coordinates corresponding to the current pixel in the image texture. In each sampling process, the texture coordinates corresponding to the current pixel can be superimposed with the radial sampling step until DistortCenter is reached. Each sampling can obtain a color value, and the color value obtained by each sampling can be accumulated. Finally, the accumulated value is divided by BlurStepCount to calculate the color value of each pixel in the radially distorted image texture.
[0121] Finally, after the mixed and distorted image texture is obtained, the mixed and distorted image texture can be displayed on the screen.
[0122] The present invention can freely combine multiple distortion algorithms, and iteratively superimpose distorted image textures output by different distortion algorithms to achieve richer and more realistic distortion effects such as image rotation and fluctuation. The present invention can improve the image quality of distorted image textures.
[0123] The following will describe in detail the distortion effect generating device of one or more embodiments of the present invention. Those skilled in the art will appreciate that these distortion effect generating devices can be configured using commercially available hardware components through the steps taught in this solution.
[0124] Figure 3 A schematic diagram of the structure of a distortion effect generating device provided by an embodiment of the present invention is shown in FIG. Figure 3 As shown, the device comprises:
[0125] An acquisition module 31 is used to acquire image texture;
[0126] A distortion module 32, configured to perform distortion processing on the texture coordinates corresponding to the image texture to obtain first distorted texture coordinates, wherein the distortion processing sequentially includes water ripple distortion, annular ripple distortion and spiral distortion;
[0127] A superposition module 33 is used to obtain a second distorted texture coordinate input by a user, and to superpose the first distorted texture coordinate with the second distorted texture coordinate input by the user to obtain a final sampling coordinate;
[0128] A sampling module 34, configured to sample the image texture using the final sampling coordinates and output the sampling result to a temporary texture cache;
[0129] The blending module 35 is used to perform radial distortion processing on the sampling results in the temporary texture buffer to obtain a blended distorted image texture, and display the blended distorted image texture on the screen.
[0130] Optionally, the sampling module 34 is further used to: perform a distortion process on the texture coordinates of the image texture according to the sorting order of the distortion process, and each time a distortion process is performed on the texture coordinates of the image texture, determine the image texture obtained by the current distortion process as the image texture used for the next distortion process.
[0131] Optionally, the distortion processing includes a water ripple distortion effect, and the distortion module 32 is used to: perform water ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a first distortion vector after water ripple distortion; and determine the texture coordinates after water ripple distortion based on the initial texture coordinates of each pixel point in the image texture and the first distortion vector.
[0132] Optionally, the overlay module 33 is used to: obtain a second distorted texture coordinate input by a user, the second distorted texture coordinate including component values of a red r channel and a green g channel; sample the second distorted texture coordinate through the texture coordinate distorted by the water ripple to obtain a third distortion vector; add the initial texture coordinate of each pixel point in the image texture to the corresponding third distortion vector to obtain the final sampling coordinate distorted by the water ripple.
[0133] Optionally, the distortion module 32 is used to: perform water ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture by using a formula; the formula is:
[0134] WaveDistortion.x'=sin(DistanceToCenter-Time*5)*0.2
[0135] WaveDistortion.x=WaveDistortion.x'+sin(CurrentTexcoord.y-Time*5)*0.2WaveDistortion.y'=cos(DistanceToCenter-Time*5)*0.2
[0136] WaveDistortion.y=WaveDistortion.y'+cos(CurrentTexcoord.x-Time*5)*0.2
[0137] Among them, WaveDistortion.x is the final offset component of the initial texture coordinates of any pixel point in the image texture in the horizontal direction, WaveDistortion.y is the final offset component of the initial texture coordinates of any pixel point in the image texture in the vertical direction, DistanceToCenter is the distance between the current pixel point and the center point in the image texture, CurrentTexcoord.x and CurrentTexcoord.y are the initial texture coordinates of the current pixel point in the image texture, and Time is the time difference between the program startup time and the image texture rendering time.
[0138] Optionally, the distortion effect processing includes a circular ripple distortion effect, and the distortion module 32 is used to: perform a circular ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a fourth distortion vector after the circular ripple distortion; and determine the texture coordinates after the circular ripple distortion based on the initial texture coordinates of each pixel point in the image texture and the fourth distortion vector.
[0139] Optionally, the overlay module 33 is used to: obtain a fifth distorted texture coordinate input by a user, wherein the fifth distorted texture coordinate includes component values of a red r channel and a green g channel; sample the fifth distorted texture coordinate through the texture coordinate distorted by the annular ripple to obtain a sixth distortion vector; and add the initial texture coordinates of each pixel point in the image texture to the corresponding sixth distortion vector to obtain a final sampling coordinate distorted by the annular ripple.
[0140] Optionally, the distortion module 32 is used to: perform annular ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture by using a formula; the formula is:
[0141] WaveDistortion.x=sin(DistanceToCenter-Time*5)*0.2WaveDistortion.y=sin(DistanceToCenter-Time*5)*0.2
[0142] Among them, WaveDistortion.x is the final offset component of the initial texture coordinates of any pixel point in the image texture in the horizontal direction, WaveDistortion.y is the final offset component of the initial texture coordinates of any pixel point in the image texture in the vertical direction, DistanceToCenter is the distance between the current pixel point and the center point in the image texture, and Time is the time difference between the program startup time and the image texture rendering time.
[0143] Optionally, the distortion effect processing includes a spiral distortion effect, and the distortion module 32 is used to: perform a spiral distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a seventh distortion vector after spiral distortion; and determine the texture coordinates after spiral distortion based on the initial texture coordinates of each pixel point in the image texture and the seventh distortion vector.
[0144] Optionally, the distortion module 32 is used to: perform a spiral distortion calculation on the initial texture coordinates of each pixel point in the image texture by using a formula;
[0145] The formula is:
[0146] DeltaUV=CurrentTexcoord-DistortCenter
[0147] RotatedDistortion.x=cos(RotateAngle)*DeltaUV.x-sin(RotateAngle)*DeltaUV.y
[0148] RotatedDistortion.y=sin(RotateAngle)*DeltaUV.x-cos(RotateAngle)*DeltaUV.y
[0149] Among them, CurrentTexcoord is the initial texture coordinate of the current pixel in the image texture, DistortCenter is the disturbance center, DeltaUV includes DeltaUV.x and DeltaUV.y, RotatedDistortion.x is the distortion value in the horizontal direction after spiral distortion, RotatedDistortion.y is the distortion value in the vertical direction after spiral distortion, and RotateAngle is a value calculated based on the distance between CurrentTexcoord and DistortCenter.
[0150] Optionally, the mixing module 35 is used to: obtain a radial sampling step length;
[0151] Starting from the texture coordinates corresponding to the current pixel in the image texture, the target number of samplings is performed for the spirally distorted image, and the radial sampling step is added to the texture coordinates corresponding to the current pixel each time the sampling is performed, until the texture coordinates corresponding to the current pixel plus the radial sampling step reach the target coordinates; the color values obtained from each sampling are accumulated, and the accumulated value is divided by the target number of times to obtain the radially distorted image texture.
[0152] Optionally, the mixing module 35 is used to obtain the radial sampling step length through a formula; the formula is:
[0153] BlurVector=DistortCenter-CurrentTexcoord
[0154] DeltaSampling=BlurVector / BlurStepCount
[0155] Among them, DistortCenter is the disturbance center, CurrentTexcoord is the initial texture coordinate of the current pixel in the image texture, BlurVector is the direction vector between DistortCenter and CurrentTexcoord, BlurStepCount is the target number of times, and DeltaSampling is the radial sampling step.
[0156] Figure 3 The device shown can perform the aforementioned Figure 1 to Figure 2 The distortion effect generating method provided in the illustrated embodiment, the detailed execution process and technical effects thereof refer to the description in the aforementioned embodiment, which will not be repeated here.
[0157] In one possible design, the above Figure 3 The structure of the distortion effect generating device shown can be implemented as an electronic device, such as Figure 4 As shown, the electronic device may include: a processor 91 and a memory 92. The memory 92 stores executable code, and when the executable code is executed by the processor 91, the processor 91 can at least implement the above-mentioned Figure 1 to Figure 2 The distortion effect generation method provided in the illustrated embodiment.
[0158] Optionally, the electronic device may further include a communication interface 93 for communicating with other devices.
[0159] In addition, an embodiment of the present invention provides a non-transitory machine-readable storage medium, wherein an executable code is stored on the non-transitory machine-readable storage medium. When the executable code is executed by a processor of an electronic device, the processor can at least implement the above-mentioned Figure 1 to Figure 2 The distortion effect generation method provided in the illustrated embodiment.
[0160] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present embodiment. Those of ordinary skill in the art may understand and implement the present invention without creative effort.
[0161] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by adding a necessary general hardware platform, and of course can also be implemented by combining hardware and software. Based on such an understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a computer product, and the present invention can be in the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.
[0162] The distortion effect generation method provided in the embodiment of the present invention can be executed by a certain program / software, and the program / software can be provided by the network side. The electronic device mentioned in the above embodiment can download the program / software to a local non-volatile storage medium, and when it needs to execute the above distortion effect generation method, the program / software is read into the memory by the CPU, and then the CPU executes the program / software to implement the distortion effect generation method provided in the above embodiment. The execution process can refer to the above Figure 1 to Figure 2 Instructions in .
[0163] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for generating a distortion effect, characterized in that: include: Get image texture; Performing a distortion process on the texture coordinates corresponding to the image texture to obtain first distorted texture coordinates, wherein the distortion process sequentially includes water ripple distortion, annular ripple distortion, and spiral distortion; Acquire a second distorted texture coordinate input by a user, and superimpose the first distorted texture coordinate and the second distorted texture coordinate to obtain a final sampling coordinate; Sampling the image texture using the final sampling coordinates, and outputting the sampling result to a temporary texture cache; Performing radial distortion processing on the sampling results in the temporary texture cache to obtain a mixed distorted image texture, and displaying the mixed distorted image texture on a screen; The performing radial distortion processing on the sampling result in the temporary texture buffer comprises: Get the radial sampling step size; Starting from the texture coordinates corresponding to the current pixel point in the image texture, sampling the sampling results in the temporary texture cache for a target number of times, adding the radial sampling step length to the texture coordinates corresponding to the current pixel point each time the texture is sampled, until the texture coordinates corresponding to the current pixel point plus the radial sampling step length reach the target coordinates; The color value obtained by each sampling is accumulated, and the accumulated value is divided by the target number of times to obtain a radially distorted image texture.
2. The method according to claim 1, characterized in that The distorting process is performed on the texture coordinates corresponding to the image texture to obtain first distorted texture coordinates, and further includes: The texture coordinates of the image texture are distorted according to the sorting order of the distortion processing. Whenever the texture coordinates of the image texture are distorted, the image texture obtained by the current distortion processing is determined as the image texture used in the next distortion processing.
3. The method according to claim 2, characterized in that The distortion processing includes a water ripple distortion effect, and the distortion processing of the texture coordinates corresponding to the image texture includes: Performing water ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a first distortion vector after water ripple distortion; Based on the initial texture coordinates of each pixel point in the image texture and the first distortion vector, the texture coordinates after water ripple distortion are determined.
4. The method according to claim 3, characterized in that: The step of obtaining the second distorted texture coordinates input by the user and superimposing the first distorted texture coordinates with the second distorted texture coordinates to obtain the final sampling coordinates includes: Acquire a second distorted texture coordinate input by a user, wherein the second distorted texture coordinate includes component values of a red r channel and a green g channel; The second distorted texture coordinates are sampled by the texture coordinates distorted by the water ripples to obtain a third distortion vector; The initial texture coordinates of each pixel point in the image texture are added to the corresponding third distortion vector to obtain the final sampling coordinates after water ripple distortion.
5. The method according to claim 3, characterized in that: The performing water ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture comprises: The water ripple distortion calculation is performed on the initial texture coordinates of each pixel point in the image texture by using the formula; the formula is: WaveDistortion.x'=sin(DistanceToCenter-Time*5)*0.2 WaveDistortion.x=WaveDistortion.x'+sin(CurrentTexcoord.y-Time*5)*0.2 WaveDistortion.y′=cos(DistanceToCenter-Time*5)*0.2 WaveDistortion.y=WaveDistortion.y+cos(CurrentTexcoord.x-Time*5)*0.2 Among them, Wavedistortion.x is the final offset component of the initial texture coordinates of any pixel point in the image texture in the horizontal direction, Wavedistortion.y is the final offset component of the initial texture coordinates of any pixel point in the image texture in the vertical direction, DistanceToCenter is the distance between the current pixel point and the center point in the image texture, CurrentTexcoord.x and CurrentTexcoord.y are the initial texture coordinates of the current pixel point in the image texture, Time is the time difference between the program startup time and the time of rendering the image texture, WaveDistortion.x' is a value determined based on DistanceToCenter and Time, and WaveDistortion.y' is a value determined based on DistanceToCenter and Time.
6. The method according to claim 2, characterized in that The distortion effect processing includes a circular ripple distortion effect, and the distortion processing of the texture coordinates corresponding to the image texture includes: Performing a circular ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a fourth distortion vector that has undergone circular ripple distortion; Based on the initial texture coordinates of each pixel point in the image texture and the fourth distortion vector, the texture coordinates after the annular corrugation distortion are determined.
7. The method according to claim 6, characterized in that The step of obtaining the second distorted texture coordinates input by the user and superimposing the first distorted texture coordinates with the second distorted texture coordinates to obtain the final sampling coordinates includes: Acquire a second distorted texture coordinate input by a user, wherein the second distorted texture coordinate includes component values of a red r channel and a green g channel; The second distorted texture coordinates are sampled by the texture coordinates distorted by the annular corrugation to obtain a sixth distortion vector; The initial texture coordinates of each pixel point in the image texture are added to the corresponding sixth distortion vector to obtain the final sampling coordinates after the annular corrugation distortion.
8. The method according to claim 6, characterized in that The performing annular ripple distortion calculation on the initial texture coordinates of each pixel point in the image texture comprises: The initial texture coordinates of each pixel in the image texture are subjected to annular ripple distortion calculation by a formula; the formula is: WaveDistortion.x=sin(DistanceToCenter-Time*5)*0.2 WaveDistortion.y=sin(DistanceToCenter-Time*5)*0.2 Among them, Wavedistortion.x is the final offset component of the initial texture coordinates of any pixel point in the image texture in the horizontal direction, Wavedistortion.y is the final offset component of the initial texture coordinates of any pixel point in the image texture in the vertical direction, DistanceToCenter is the distance between the current pixel point and the center point in the image texture, and Time is the time difference between the program startup time and the image texture rendering time.
9. The method according to claim 2, characterized in that: The distortion effect processing includes a spiral distortion effect, and the distortion processing of the texture coordinates corresponding to the image texture includes: Performing a spiral distortion calculation on the initial texture coordinates of each pixel point in the image texture to obtain a seventh distortion vector after the spiral distortion; Based on the initial texture coordinates of each pixel in the image texture and the seventh distortion vector, the spirally distorted texture coordinates are determined.
10. The method according to claim 9, characterized in that The step of performing spiral distortion calculation on the initial texture coordinates of each pixel in the image texture comprises: The spiral distortion calculation is performed on the initial texture coordinates of each pixel in the image texture by using the formula; the formula is: DeltaUV=CurrentTexcoord-DistortCenter RotatedDistortion.x=cos(Rotate.Angle)*DeltaUV.x-sin(RotateAngle)*DeltaUV.y RotatedDistortion.y=sin(RotareAngle)*DeltaUV.x-cos(RotateAngle)*DeltaUV.y Among them, DeltaUV is the seventh distortion vector after spiral distortion, CurrentTexcoord is the initial texture coordinates of the current pixel in the image texture, DistortCenter is the disturbance center, DeltaUV includes DeltaUV.x and DeltaUV.y, DeltaUV.x is the offset of the initial texture coordinates of the current pixel in the image texture relative to the disturbance center in the horizontal direction, DeltaUV.y represents the offset of the initial texture coordinates of the current pixel in the image texture relative to the disturbance center in the vertical direction; DeltaUV is a value determined based on CurrentTexcoord and DistortCenter, RotatedDistortion.x is the distortion value in the horizontal direction after spiral distortion, RotatedDistortion.y is the distortion value in the vertical direction after spiral distortion, and RotateAngle is a value calculated based on the distance between CurrentTexcoord and DistortCenter.
11. The method according to claim 1, characterized in that: The obtaining of the radial sampling step length comprises: The radial sampling step length is obtained by the formula; the formula is: BlurVector=DistortCenter-CurrentTexcoord DeltaSampling=BlurVector / BlurStepCount Among them, DistortCenter is the disturbance center, CurrentTexcoord is the initial texture coordinate of the current pixel in the image texture, BlurVector is the direction vector between DistortCenter and CurrentTexcoord, BlurStepCount is the target number of times, and DeltaSampling is the radial sampling step.
12. A distortion effect generating device, characterized in that: include: An acquisition module, used to acquire image texture; A distortion module, used for performing distortion processing on the texture coordinates corresponding to the image texture to obtain first distorted texture coordinates, wherein the distortion processing sequentially includes water ripple distortion, annular ripple distortion and spiral distortion; A superposition module, used for acquiring a second distorted texture coordinate input by a user, and superimposing the first distorted texture coordinate and the second distorted texture coordinate to obtain a final sampling coordinate; A sampling module, used for sampling the image texture according to the final sampling coordinates, and outputting the sampling result to a temporary texture cache; A blending module, used for performing radial distortion processing on the sampling results in the temporary texture cache to obtain a blended distorted image texture, and displaying the blended distorted image texture on a screen; The mixing module is specifically used to obtain a radial sampling step; starting from the texture coordinates corresponding to the current pixel point in the image texture, sampling the sampling results in the temporary texture cache a target number of times, and adding the radial sampling step length to the texture coordinates corresponding to the current pixel point each time the sampling is performed, until the texture coordinates corresponding to the current pixel point plus the radial sampling step length reach the target coordinates; The color value obtained by each sampling is accumulated, and the accumulated value is divided by the target number of times to obtain a radially distorted image texture.
13. An electronic device, characterized in that: include: A memory and a processor; wherein the memory stores executable code, and when the executable code is executed by the processor, the processor executes the distortion effect generating method as described in any one of claims 1-11.
14. A non-transitory machine-readable storage medium, characterized in that: The non-transitory machine-readable storage medium stores executable code, and when the executable code is executed by a processor of an electronic device, the processor is caused to execute the distortion effect generating method according to any one of claims 1 to 11.
