CN114201832A - Method and device for simulating window glass raindrops and wiper scraping effect in rainy days - Google Patents
Method and device for simulating window glass raindrops and wiper scraping effect in rainy days Download PDFInfo
- Publication number
- CN114201832A CN114201832A CN202111515157.4A CN202111515157A CN114201832A CN 114201832 A CN114201832 A CN 114201832A CN 202111515157 A CN202111515157 A CN 202111515157A CN 114201832 A CN114201832 A CN 114201832A
- Authority
- CN
- China
- Prior art keywords
- value
- calculating
- coordinate
- image
- coordinate system
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Granted
Links
- 230000000694 effects Effects 0.000 title claims abstract description 94
- 238000000034 method Methods 0.000 title claims abstract description 39
- 239000005357 flat glass Substances 0.000 title claims abstract description 24
- 238000007790 scraping Methods 0.000 title claims description 15
- XLYOFNOQVPJJNP-UHFFFAOYSA-N water Substances O XLYOFNOQVPJJNP-UHFFFAOYSA-N 0.000 claims abstract description 140
- 238000005070 sampling Methods 0.000 claims abstract description 15
- 238000004088 simulation Methods 0.000 claims abstract description 14
- 238000004422 calculation algorithm Methods 0.000 claims abstract description 11
- 238000012545 processing Methods 0.000 claims abstract description 7
- 230000006870 function Effects 0.000 claims description 69
- 239000011324 bead Substances 0.000 claims description 17
- 239000013598 vector Substances 0.000 claims description 16
- 230000008859 change Effects 0.000 claims description 5
- 238000013507 mapping Methods 0.000 claims description 4
- 230000009471 action Effects 0.000 claims description 3
- 238000004590 computer program Methods 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 8
- 238000004364 calculation method Methods 0.000 description 6
- 239000002245 particle Substances 0.000 description 6
- 238000009877 rendering Methods 0.000 description 6
- 239000000463 material Substances 0.000 description 5
- 230000008569 process Effects 0.000 description 5
- 238000005516 engineering process Methods 0.000 description 3
- 238000012549 training Methods 0.000 description 3
- 230000007547 defect Effects 0.000 description 2
- 230000004927 fusion Effects 0.000 description 2
- 206010039203 Road traffic accident Diseases 0.000 description 1
- 238000005162 X-ray Laue diffraction Methods 0.000 description 1
- 238000009825 accumulation Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 230000015572 biosynthetic process Effects 0.000 description 1
- 238000004891 communication Methods 0.000 description 1
- 230000010485 coping Effects 0.000 description 1
- 239000011521 glass Substances 0.000 description 1
- 230000001788 irregular Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 230000002035 prolonged effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F30/00—Computer-aided design [CAD]
- G06F30/10—Geometric CAD
- G06F30/17—Mechanical parametric or variational design
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F30/00—Computer-aided design [CAD]
- G06F30/20—Design optimisation, verification or simulation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T17/00—Three dimensional [3D] modelling, e.g. data description of 3D objects
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06T—IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06T3/00—Geometric image transformations in the plane of the image
- G06T3/40—Scaling of whole images or parts thereof, e.g. expanding or contracting
- G06T3/4007—Scaling of whole images or parts thereof, e.g. expanding or contracting based on interpolation, e.g. bilinear interpolation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2119/00—Details relating to the type or aim of the analysis or the optimisation
- G06F2119/10—Noise analysis or noise optimisation
Landscapes
- Physics & Mathematics (AREA)
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Geometry (AREA)
- General Physics & Mathematics (AREA)
- Computer Hardware Design (AREA)
- Evolutionary Computation (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Computer Graphics (AREA)
- Computational Mathematics (AREA)
- Mathematical Analysis (AREA)
- Mathematical Optimization (AREA)
- Pure & Applied Mathematics (AREA)
- Processing Or Creating Images (AREA)
Abstract
The invention discloses a method and a device for simulating the window glass raindrops and the wiper moving effect in rainy days, which comprises the following steps: establishing a three-dimensional space model of a vehicle windshield, putting the model into a uv coordinate system and cutting the model into a plurality of equally divided squares, wherein each square is used as a coordinate system for drawing water drops; fitting a noise function, a pull-up function and a motion curve function, calculating a pull-up value of an X axis and a motion value of a y axis for the water drop, calculating a water drop coordinate and a pixel deviation value, calculating a trailing water drop coordinate and a pixel deviation value, and superposing the trailing water drop coordinate and the pixel deviation value into a pixel deviation value; carrying out offset sampling on an original image to obtain an image with water drop sliding, and carrying out fuzzy algorithm processing to obtain an image simulating a water vapor effect; calculating two radian distance fields and superposing the radian distance fields into one radian distance field; and mixing the simulated water vapor effect image and the original image through the radian distance field to obtain a final simulated effect image. The invention greatly improves the simulation sense of reality, is easy to quickly deploy and simulate, and has better effect and better efficiency.
Description
Technical Field
The invention relates to a method and equipment for simulating raindrops of window glass and the scraping effect of a windscreen wiper in rainy days, and belongs to the technical field of automobile driving simulation.
Background
The automobile driving simulator is one kind of simulating system capable of simulating automobile driving. The existing automobile driving simulator is a simulation technology integrating multiple technologies such as three-dimensional real-time animation, artificial intelligence, data communication, network, multimedia and machinery, and is mainly used for training students to prepare driving training exams; the system can be used for emergency deduction, the investment cost of the emergency deduction is reduced, and the deduction training time is prolonged, so that the coping skills of people in the face of accident disasters are guaranteed, the limitation of space can be broken, and personnel in various places can be conveniently organized for deduction, and the case is applied and is a trend of the future emergency deduction; the method can also be used for simulating microscopic traffic, researching the control characteristics of automobiles and the like. The automobile driving simulator can simulate various road environment and weather conditions conveniently and analyze the technical performance indexes of the automobile, thereby saving a large amount of natural resources and having high economic value.
The rainfall weather has great influence on the driving safety, the continuous rainfall can seriously influence the sight of a driver and the braking distance of a vehicle, and traffic accidents caused by the rainfall weather occur occasionally; therefore, the driving environment of the rainfall weather simulated on the automobile driving simulator is very important.
Currently, the raindrop effect is mostly produced through the particle effect, and the technology has the following defects: (1) the more particles are used for the processor, the higher the calculation consumption ratio is; (2) when the windscreen wiper is used for wiping, raindrops disappear relatively hard and hard, and the real effect is lacked; (3) the water mark effect when raindrops slide down and the scratch effect of the windscreen wiper cannot be generated; (4) no water vapor blurring effect caused by rain water.
Disclosure of Invention
In order to overcome the defects in the prior art, the invention provides a method and equipment for simulating the raindrops of a window glass and the scraping effect of a wiper in rainy days, so as to solve the problems that the water mark effect when the raindrops slide off, the scraping effect of the wiper and the water vapor blurring effect generated by no rainwater cannot be generated in the rainfall weather simulation in the prior art.
The invention specifically adopts the following technical scheme to solve the technical problems:
a method for simulating raindrops on a window glass and the scraping effect of a windscreen wiper in rainy days comprises the following steps:
S2, assuming that the time variation is t, establishing a three-dimensional space model of the vehicle windshieldPutting the model into a uv coordinate system, namely a model coordinate system uv (x, y); calculating three-dimensional space model of vehicle windshieldThe pull-up value w of the uv coordinate y axis; adding an offset value accumulated along with time t to the y axis of the model coordinate system uv (x, y) to enable the vehicle windshield to be in a three-dimensional space modelThe uv coordinates of (a) move downwards;
s3, modeling the vehicle windshield in three-dimensional space in a model uv coordinate systemCutting the water drop into a plurality of equally divided squares, and taking each cut square as a coordinate system gv for drawing the water drop, namely a water drop coordinate system gv (x, y);
s4, fitting a noise function, and calculating a random noise value n of each square; fitting a pull-up function f (w) of the water drop coordinate along with the change of a pull-up value w in the x-axis direction, and superposing a random noise value n to make the water drop pull-up move in the x-axis direction; fitting a motion curve function f (t) accumulated by the coordinates of the water drop along with time t in the y-axis direction to enable the water drop to move in a variable speed in the y-axis direction; expanding and calculating a trailing water droplet coordinate system dv through a water droplet coordinate system gv (x, y) and a pull-up function f (w), namely the trailing water droplet coordinate system dv (x, y); calculating coordinates dropPos (x, y) of the water drop under a water drop coordinate system gv according to a pull-up function f (w) and a motion curve function f (t) and calculating a water drop pixel offset value; calculating coordinates of a trailing water drop, namely, a dropTrailPos (x, y) according to a trailing water drop coordinate system dv and calculating a trailing water drop pixel deviation value; combining the bead pixel offset value and the trailing bead pixel offset value into a pixel offset value col;
s5, supposing that an input image is an input original image T2, carrying out offset sampling on the original image T2 by using the pixel offset value col obtained in the step S4 to obtain an image with a water droplet sliding off, and then carrying out fuzzy algorithm processing on the image with the water droplet sliding off to obtain a fuzzy simulated water vapor effect image T1;
s6, calculating two radian distance fields when the wiper scraping form is simulated, and superposing the two radian distance fields to form a radian distance field T3;
and S7, mixing the simulated water vapor effect image T1 and the original image T2 through the radian distance field T3 to obtain a final simulated effect image.
Further, as a preferred technical solution of the present invention, the three-dimensional space model of the vehicle windshield built in the step S1Is a quadrilateral model.
Further, as a preferred technical solution of the present invention, the three-dimensional space model of the vehicle windshield in the step S2The uv coordinate system of (1) is the lower left corner (0,0), the upper left corner (0,1), the upper right corner (1,1), and the lower right corner (1, 0).
Further, as a preferred technical solution of the present invention, the three-dimensional space model of the vehicle windshield in the step S2The pull-up value w of the y-axis of the uv-coordinate is uv.y 10, and the formula of the downward movement of the uv-coordinate is uv.y + (t 0.25).
Further, as a preferred technical solution of the present invention, in the step S3, a three-dimensional space model of a vehicle windshield is obtainedCutting into a plurality of equally divided squares, which specifically comprises the following steps:
s3-1, modeling the three-dimensional space of the vehicle windshieldThe uv coordinate system uv (x, y) ranges from 0 to 1 and is mapped into 0 to 10, and the mapping formula is uv-uv 10;
s3-2, and then changing a uv coordinate system into squares with x and y axes of 10 x 10 by the frac function, wherein the range of each square is 0-1, and calculating a gv-frac (uv) -0.5 coordinate system of the water drop so that the range of each square of 10 x 10 is-0.5.
Further, as a preferred technical solution of the present invention, the step S4 specifically includes:
s4-1, fitting a noise function, defining a two-dimensional coordinate q (x, y), q.x ═ 123.34, q.y ═ 345.45, inputting a coordinate value p (x, y), calculating p + ═ dot (p, p +34.345) through p ═ frac (p × q), and outputting a random noise value n ═ p.x × (p.y), wherein dot () is a calculated point-by-point function;
s4-2, fitting a pull-up function formula as follows: (w) sin (3w) sin (w) 6;
s4-3, fitting a motion curve function formula as follows: (t) ═ sin (t + sin (t) × 0.5));
s4-4, calculating a pulling value formula of an x axis for the water drop, wherein x is (n-0.5) × 0.8; x + (0.4-abs (x)) f (w), wherein abs () is an absolute value function; calculating a motion value of a y-axis for the water droplet, wherein the motion value is expressed as y ═ f (t); y ═ g.x-x (g.x-x);
s4-5, calculating the coordinate position of the water drop, and assuming that the offset vector is m1(x, y), wherein m1.x is the pull-up value of the x axis calculated in the step S4-4, m1.y is the motion value of the y axis calculated in the step S4-4, and the coordinate formula of the water drop is that dropPos is gv-m 1; calculating a drop pixel offset value drop (0.05,0.03, length (dropPos)) from dropPos;
s4-6, calculating a trailing water droplet coordinate system d (x, y), assuming that an offset vector is m2(x, y), wherein m2.x is the x-axis lifting value calculated in the step S4-4, m2.y is t 0.25, and the trailing water droplet coordinate system formula is that d (x, y) is gv-m 2; calculating trailing water droplet coordinates droptailboom Pos, wherein the formula is as follows:
dropTrailPos.x=d.x;dropTrailPos.y=(frac(d.y*8)/8)-0.03;
the trailing water bead pixel offset value droptail is calculated from droptail pos as smoothstep (0.03,0.02,
length(dropTrailPos));
s4-7, the superimposed bead pixel offset value and the trailing bead pixel offset value are a pixel offset value col, and the formula is col
=drop+dropTrail。
Further, as a preferred technical solution of the present invention, the step S5 obtains a blurred simulated water vapor effect image T1, and the specific steps are as follows:
s5-1, using the pixel offset value col obtained in the step S4 as texture sampling of the original image T2 to obtain an image of the original image after texture coordinate offset, namely an image of water drops sliding off;
s5-2, processing the water drop image obtained in the S5-1 by using a mean fuzzy algorithm: using the noise function fitted in the step S4 to model the vehicle windshield in three-dimensional spaceThe uv coordinates uv (x, y) of (a) are used as input values, assuming that the output random noise value is a, and the two-dimensional vectors e (x, y), e.x ═ sin (a), e.y ═ cos (a); the offset value is calculated by the formula of 0.01, and the water drop slip map is sampled by the offset valueAnd obtaining an offset pixel value, circularly sampling for four times, outputting a random noise value a < + > equal to 1 in each circulation, adding the offset pixel values subjected to four-time sampling, dividing by 4 to obtain an average pixel value as a new pixel value, and forming a blurred simulated steam effect image T1 by the new pixel value.
Further, as a preferred technical solution of the present invention, the step S6 superimposes two radian distance fields as a radian distance field T3, specifically:
s6-1, giving definition of radian distance field function, inputting 4 parameters, namely uv coordinate points uv (x, y), central coordinate points c (x, y), angle values angle and distance values len;
s6-2, calculating a vector dir which is equal to uv-center of the uv coordinate point and the central coordinate point;
calculating the distance dist ═ length (dir) between the uv coordinate point and the central coordinate point;
calculating an included angle ang between the vector dir and the x axis of the uv coordinate system, namely atan2(dir.y, dir.x);
calculating a relation value dd between the distance dist and an input distance value len, wherein the relation value dd is 1-smooth step (len, len +0.02, dist), and when the distance dist is smaller than len, the output dd value is 1; when the distance dist is larger than len +0.02, outputting a dd value of 0; outputting a value with dd between 0 and 1 when the distance dist is larger than len and smaller than len + 0.02;
calculating a relation value aa of the included angle ang and the input angle value angle as 1-smooth (angle, angle +0.8, degrees (angle)), and when the included angle ang is smaller than the angle, outputting an aa value of 1; when the included angle ang is larger than angle, the output aa value is 0; outputting a value aa of between 0 and 1 when the included angle ang is larger than angle and smaller than angle + 0.8;
and, calculating an output value of the radian distance field function equal to dd aaa;
s6-3, using the function of the radian distance field obtained in step S6-2, assuming that the left radian distance field parameter is input to obtain an output value dt1, assuming that the right radian distance field parameter is input to obtain an output value dt2, merging dt1 and dt2 into a radian distance field T3-min (dt1+ dt2, 1); wherein the min function is the value of the limit dt1+ dt2 between 0 and 1.
Further, as a preferred technical solution of the present invention, the step S7 of mixing to obtain a final simulation effect image specifically includes:
mixing the simulated steam effect image T1 and the original image T2 through a radian distance field T3 to obtain a final simulated effect image T-lerp (T2, T1 and T3), and outputting a pixel value of the original image T2 when the radian distance field T3 is 0; outputting a pixel value of a simulated steam effect image T1 when the radian distance field T3 has a value of 1; intermediate over-interpolation of pixel values of the original image T2 to pixel values of the simulated steam effect image T1 is output when the radian distance field T3 is greater than 0 and less than 1.
The invention also provides an electronic device, which comprises a memory, a processor and a computer program stored on the memory and capable of running on the processor, wherein the processor executes the program to realize the steps of the method for simulating the effects of raindrops of the window glass and the scraping of the windscreen wiper in rainy days.
By adopting the technical scheme, the invention can produce the following technical effects:
the method and the equipment provided by the invention have the advantages that the calculation cost is high when excessive particles exist in the raindrop effect of the traditional particle manufacturing, the raindrop particle effect disappears and is harder when the windscreen wiper is used for wiping, the reality is lacked, no raindrop slides to generate water marks, and the windscreen wiper scratches and the water vapor fuzzy effect are taken out, and the method for calculating the simulated rendering picture by adopting the computer graphics algorithm is provided. And the raindrop picture is rendered at one time, so that the calculation overhead of a CPU is reduced. Through the pull-up function, the motion curve function, the noise function and the picture fusion, the raindrop effect sliding is more consistent with the motion rule, the raindrop scraped by the windscreen wiper disappears and is not hard, and the simulation reality sense is greatly improved.
Therefore, aiming at the situation that the traditional particle effect windscreen wiper has no scratch effect during wiping, the radian distance field image of a mask is calculated by calculating the radian distance field during the wiping of the simulated windscreen wiper and transmitting the radian and the length of the windscreen wiper during the wiping, and then the image of the simulated water vapor effect, the original image and the radian distance field are fused to obtain the final simulated effect image, so that the scratch effect of the windscreen wiper is realized. Aiming at the water vapor fuzzy effect, the rendered raindrop picture is fuzzy by the fuzzy algorithm, so that the glass fogging effect in the rainy days is improved in certain specific situations. The invention is easy to operate, can be conveniently and quickly transplanted to other different vehicle types, and realizes the rain simulation effect of the vehicle window glass of different vehicle types. The effect simulated by the method is easy and quick to deploy and simulate, and the effect is better and the efficiency is better.
Drawings
FIG. 1 is a schematic overall flow chart of the method of the present invention.
FIG. 2 is a three-dimensional space model of a vehicle windshield according to the present inventionIs a schematic diagram of a quadrilateral model.
FIG. 3 is a schematic diagram of a small square cut in the present invention.
Fig. 4 is a schematic view of uv coordinate expansion mapping in the present invention.
FIG. 5 is a schematic representation of the frac function image of the present invention.
FIG. 6 is a diagram of a noise function image according to the present invention.
FIG. 7 is a diagram of a lifting function f (w) sin (3w) sin (w) 6 image according to the present invention.
Fig. 8 is a schematic diagram of an image of a motion curve function f (t) ═ -sin (t + sin (t) × 0.5) in the present invention.
FIGS. 9,10,11,12 and 13 are schematic views of the process of forming water droplets according to the present invention.
Fig. 14 is a schematic view of an image after the raindrop effect is blurred in the present invention.
FIG. 15 is a schematic view of a radian distance field profile of a wiper blade according to the invention.
Fig. 16 is a schematic diagram of a final simulation effect image after mixing by a distance field image in the present invention.
Fig. 17 is a schematic view of a vehicle model image in the present invention.
FIG. 18 is a diagram of a computer rendered Shader file constructed in accordance with the inventive method of the present invention.
FIG. 19 is a schematic diagram of a custom material ball file constructed in the present invention.
FIG. 20 is a schematic view of a vehicle window model with a custom material ball according to the present invention.
FIG. 21 is a schematic view of a vehicle window model with a custom material ball according to the present invention.
FIG. 22 is a schematic view of an image rendered when a wiper blade of the present invention is moved.
Detailed Description
The following describes embodiments of the present invention with reference to the drawings.
As shown in fig. 1, the present invention relates to a method for simulating the effect of rain drops on a window glass and the wiping action of a wiper in a rainy day, which specifically comprises the following steps:
Further, as shown in fig. 2, the three-dimensional space model of the vehicle windshieldIs a quadrilateral model; the quadrilateral model is composed of 4 vertexes and 2 triangular surfaces, and the vertex of a diagonal line of the quadrilateral model is the vertex shared by the two triangular surfaces.
S2, assuming that the time variation is t, establishing a three-dimensional space model of the vehicle windshieldPut into the uv coordinate system, i.e. the model coordinate system uv (x, y). Calculating three-dimensional space model of vehicle windshieldUv coordinate y-axis of (d). Adding an offset value accumulated along with time t to the y axis of uv (x, y) to make the three-dimensional space model of the vehicle windshieldMoves down the uv coordinates of (a).
Further, 4 vertices of the quadrilateral model with coordinate information, i.e., uv coordinates, will beThe model is put into a uv coordinate system, and the left sides of the 4 vertexes are respectively the lower left corner (0,0), the upper left corner (0,1), the upper right corner (1,1) and the lower right corner (1,0), as shown in fig. 3.
The pull-up value w of the y axis of the uv coordinate is uv.y 10, the formula of the downward movement of the model uv coordinate is uv.y + ═ t 0.25, wherein 0.25 is a coefficient value, and t is a value with the time change accumulation quantity becoming larger.
S3, modeling the vehicle windshield in three-dimensional space in a model uv coordinate systemCutting the water drop into a plurality of equally divided squares, and taking each cut square as a coordinate system gv for drawing the water drop, namely a water drop coordinate system gv (x, y). The method comprises the following specific steps:
s3-1, modelThe uv coordinate system uv (x, y) of (1) is mapped from 0 to 1 to 0 to 10, and the mapping formula is uv-uv 10. As shown in fig. 4.
S3-2, in the frac (uv) function image, as shown in fig. 5, the frac function is used to change the uv coordinate system into squares with x and y axes of 10 × 10, respectively, each square is in the range of 0 to 1, and the coordinate system of the water drop gv ═ frac (uv) -0.5 is calculated so that each square of 10 × 10 is in the range of-0.5 to 0.5.
Thus, each cut square is taken as an independent water drop coordinate system gv (x, y), and a circle, namely a water drop, is drawn in the square.
S4, fitting a noise function, and calculating a random noise value n of each square; fitting a pull-up function f (w) of the water drop coordinate along with the change of a pull-up value w in the x-axis direction, and superposing a random noise value n to make the water drop pull-up move in the x-axis direction; fitting a motion curve function f (t) accumulated by the coordinates of the water drop along with time t in the y-axis direction to enable the water drop to move in a variable speed in the y-axis direction; expanding and calculating a trailing water droplet coordinate system dv through a water droplet coordinate system gv (x, y) and a pull-up function f (w), namely the trailing water droplet coordinate system dv (x, y); calculating coordinates dropPos (x, y) of the water drop under a water drop coordinate system gv according to a pull-up function f (w) and a motion curve function f (t) and calculating a water drop pixel offset value; calculating coordinates of a trailing water drop, namely, a dropTrailPos (x, y) according to a trailing water drop coordinate system dv and calculating a trailing water drop pixel deviation value; combining the bead pixel offset value and the trailing bead pixel offset value into a pixel offset value col; the process prepares for the subsequent calculation of coordinates of the water drop and a water drop pixel deviation value by fitting a noise function, a pull-up function and a motion curve function. Combining the pixel deviation value of the bead and the pixel deviation value of the trailing bead into a value by utilizing the calculated coordinate of the trailing bead in the trailing bead coordinate space and the pixel deviation value of the trailing bead, wherein the value is as follows:
s4-1, a fitting noise function formula, firstly, defining a two-dimensional coordinate q (x, y), q.x-123.34 and q.y-345.45, inputting a coordinate value p (x, y) into the function, converting the coordinate value p (x, y) through the formula p-frac (p-q) and p + (dot (p, p +34.345), and returning to output a changed random noise value n-p.x-p.y: assuming that each square has a row-column coordinate id (x, y), and the calculation formula of the row-column number is id ═ floor (uv), the floor function rounds the uv coordinate interval of 0-10 downwards to obtain the values of 0,1,2,3,4,5,6,7,8,9, and 10, that is, the row-column coordinate id.x is an integer of 0-10, and the id.y is an integer of 0-10. The id coordinate is passed into the noise function as an input value p (x, y). The input value is transformed by an substituting formula: p ═ frac (p × float2(123.34,345.45)), p + ═ dot (p, p +34.345), and output a random noise function n ═ p.x × p.y, where dot () is the calculated dot product function, and the noise image is shown in fig. 6.
S4-2, fitting the Laue function formula, f (w) ═ sin (3w) sin (w) ^6, as shown in fig. 7.
S4-3, the formula of the fitted motion curve, f (t) ═ -sin (t + sin (t) × 0.5), is shown in fig. 8.
S4-4, the following is primarily a process of calculating the formation of a water droplet, as shown in fig. 9,10,11,12,13, first calculating the X-axis pull-up value and the y-axis motion value for the water droplet: calculating a pull-up value formula for an x-axis for the water droplet as x ═ 0.5 × 0.8; x + (0.4-abs (x)) f (w), wherein abs () is an absolute value function; calculating a motion value of a y-axis for the water droplet, wherein the motion value is expressed as y ═ f (t); y ═ g.x-x (g.x-x).
S4-5, calculating the coordinates of the water drop in the water drop coordinate space and the pixel deviation value of the water drop: calculating the coordinate position of the water drop in the water drop coordinate space, and assuming an offset vector m1(x, y), wherein m1.x is the pull-up value of the x axis calculated in the step S4-4, m1.y is the motion value of the y axis calculated in the step S4-4, and the formula of the water drop coordinate is that dropPos is gv-m 1; the drop pixel offset value drop is calculated from dropPos (0.05,0.03, length (dropPos)).
S4-6, calculating the trailing water droplet coordinate and the trailing water droplet pixel deviation value under the trailing water droplet space: and calculating a trailing water droplet coordinate system d (x, y) in the trailing water droplet space, and assuming that the offset vector is m2(x, y), wherein m2.x is the x-axis pull-up value calculated in the step S4-4, and the value of m2.x is the same as that of m1. x. m2.y is t 0.25, and the formula of the trailing water bead coordinate system is d (x, y) gv-m 2; calculating trailing water droplet coordinates droptailboom Pos, wherein the formula is as follows:
dropTrailPos.x=d.x;
dropTrailPos.y=(frac(d.y*8)/8)-0.03;
the trailing water bead pixel offset values were calculated from droptailpos:
dropTrail=smoothstep(0.03,0.02,length(dropTrailPos))。
s4-7, the superimposed water droplet pixel offset value and the trailing water droplet pixel offset value are a pixel offset value col, which is expressed as col ═ drop + drop tail.
S5, assuming that an input image is an input original image T2, performing offset sampling on the original image T2 by using the pixel offset value obtained in the step S4 to obtain a water droplet sliding image, and performing fuzzy algorithm processing on the water droplet sliding image to obtain a fuzzy water vapor effect image T1, as shown in FIG. 14, the method specifically comprises the following steps:
s5-1, using the pixel offset value col obtained finally in the step S4 as texture sampling of the original image T2, and obtaining an image of the original image after texture coordinate offset, namely an image of water drops sliding off.
And S5-2, processing the water drop falling image obtained in the S5-1 by using a fuzzy algorithm, wherein the fuzzy algorithm is an average fuzzy algorithm. Calculate out4 random offset values, and the sum of the peripheral pixel values obtained by sampling the offset values for 4 times is averaged. Wherein the model is modeled using the noise function fitted in S4-1The uv coordinates uv (x, y) of (a) are used as input values, assuming that the output random noise value is a, and the two-dimensional vectors e (x, y), e.x ═ sin (a), e.y ═ cos (a); the offset value offset is calculated by the formula of 0.01 × e, the offset value is used to sample the image of water drop sliding to obtain the offset pixel value, the sampling is performed four times, the random noise value a + is output in each cycle, the offset pixel value obtained after the sampling is added for four times and divided by 4 to obtain the average pixel value as the new pixel value, and thus, the blurred water vapor effect image T1 is formed by the new pixel value.
And S6, calculating two radian distance fields when the wiper scraping form is simulated, superposing the two radian distance fields to form a radian distance field T3, and using the radian distance field T3 distance value as the parameter of the final mixed image. The morphology of the radian distance field is schematically illustrated in figure 15, and the calculation process is specifically as follows:
s6-1, the concept of distance field is simply a field function, which can be a three-dimensional space geometry function, or two-dimensional, one-dimensional or N-dimensional. The distance field function has an input, which is an argument or a point in space, and an output, which is the distance of the input point to a point or a geometric or irregular volume. What is required here is a modelA distance relationship between a point in the uv coordinate system space and the radian of the fan, and the radian distance field function needs to be defined by calculating the distance between the coordinate point in the uv coordinate system and the predefined central coordinate and the included angle formed by the vector of the predefined central coordinate and the x axis of the uv coordinate system.
The definition of radian distance field function is given in the invention, 4 input parameters are provided, uv coordinate points uv (x, y), center coordinate points c (x, y), angle values angle and distance values len.
S6-2, calculating the radian distance field:
step 4, calculating a relation value dd between the distance dist and the input distance value len to be 1-smooth step (len, len +0.02, dist), wherein when the distance dist is smaller than len, the output dd value is 1, and when the distance dist is larger than len +0.02, the output dd value is 0; when dist is larger than len and smaller than len +0.02, outputting a value of dd between 0 and 1;
S6-3, obtaining a function for solving the radian distance field through the step S6-2, supposing that parameters of the left radian distance field are input to obtain an output value dt1, supposing that parameters of the right radian distance field are input to obtain an output value dt2, combining dt1 and dt2 into a radian distance field T3 ═ min (dt1+ dt2,1) through a formula, wherein the geometrical structure of the radian distance field is two radian sectors, and the min function is used for limiting the value of dt1+ dt2 to be 0-1.
And S7, mixing the simulated water vapor effect image T1 and the original image T2 through the radian distance field T3 to obtain a final simulated effect image. As shown in fig. 16, the details are as follows:
mixing the simulated steam effect image T1 and the original image T2 through a radian distance field T3 to obtain a final simulated effect image T-lerp (T2, T1 and T3), and outputting a pixel value of the original image T2 when the radian distance field T3 is 0; outputting a pixel value of a simulated steam effect image T1 when the radian distance field T3 has a value of 1; intermediate over-interpolation of pixel values of the original image T2 to pixel values of the analog moisture effect image T1 is output when T3 is greater than 0 and less than 1.
The invention also relates to an electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the steps of the method for simulating the window glass raindrops and the wiper wiping effect in rainy days when executing the program, thereby realizing real simulation of the window glass raindrops and the wiper wiping effect in rainy days.
Therefore, the method and the device calculate the radian distance field of the mask by calculating the radian distance field when the simulated windscreen wiper is in scraping, transmitting the radian and the length of the simulated windscreen wiper in scraping, and fusing three images of the image simulating the water vapor effect, the original image and the radian distance field to obtain the final simulated effect image, thereby realizing the scraping effect of the windscreen wiper, leading the sliding of the raindrop effect to be more accordant with the motion rule and improving the simulation reality.
In order to verify that the method and the device of the invention can effectively simulate the raindrop effect, an example is given below, and the method and the device are applied to the field of virtual simulation, and the specific process is as follows:
And 2, constructing a computer graphic rendering file shader in the virtual simulation software by the principle method, as shown in FIG. 18.
And 3, constructing material balls required by the vehicle window glass model in the virtual simulation software, namely rendering a carrier of the file loader, as shown in FIG. 19.
And 4, endowing the constructed material ball to the vehicle window glass model, and rendering the model in a rendering mode through the custom shader file of the principle, as shown in FIG. 20.
And 5, operating according to the steps of the method disclosed by the invention, and obtaining a final rendering effect in virtual simulation software, namely the effect of scraping the window and the windshield by the windscreen wiper in rainy days, as shown in fig. 21 and 22.
In conclusion, the method and the device provided by the invention can be used for obtaining the final simulation effect image by fusing the three images of the water vapor simulation effect image, the original image and the radian distance field, the image fusion enables the raindrop effect to slide and conform to the movement rule better, the raindrop scraped by the windscreen wiper disappears and is not hard, and the simulation reality sense is greatly improved. Therefore, the method and the device effectively simulate the effect of the windscreen wiper in the rainy day to scrape the window glass of the car, the effect simulated by the method is easy to quickly deploy and simulate, the effect can be conveniently and quickly transplanted to other different car types, the effect of simulating the window glass of different car types in the rainy day is realized, the effect is better, and the efficiency is better.
The embodiments of the present invention have been described in detail with reference to the drawings, but the present invention is not limited to the above embodiments, and various changes can be made within the knowledge of those skilled in the art without departing from the gist of the present invention.
Claims (10)
1. A method for simulating raindrops on a window glass and the scraping effect of a windscreen wiper in a rainy day is characterized by comprising the following steps of:
S2, assuming that the time variation is t, establishing a three-dimensional space model of the vehicle windshieldPutting the model into a uv coordinate system, namely a model coordinate system uv (x, y); calculating three-dimensional space model of vehicle windshieldThe pull-up value w of the uv coordinate y axis; adding an offset value accumulated along with time t to the y axis of the model coordinate system uv (x, y) to enable the vehicle windshield to be in a three-dimensional space modelThe uv coordinates of (a) move downwards;
s3, modeling the vehicle windshield in three-dimensional space in a model uv coordinate systemCutting the water drop into a plurality of equally divided squares, and taking each cut square as a coordinate system gv for drawing the water drop, namely a water drop coordinate system gv (x, y);
s4, fitting a noise function, and calculating a random noise value n of each square; fitting a pull-up function f (w) of the water drop coordinate along with the change of a pull-up value w in the x-axis direction, and superposing a random noise value n to make the water drop pull-up move in the x-axis direction; fitting a motion curve function f (t) accumulated by the coordinates of the water drop along with time t in the y-axis direction to enable the water drop to move in a variable speed in the y-axis direction; expanding and calculating a trailing water droplet coordinate system dv through a water droplet coordinate system gv (x, y) and a pull-up function f (w), namely the trailing water droplet coordinate system dv (x, y); calculating coordinates dropPos (x, y) of the water drop under a water drop coordinate system gv according to a pull-up function f (w) and a motion curve function f (t) and calculating a water drop pixel offset value; calculating coordinates of a trailing water drop, namely, a dropTrailPos (x, y) according to a trailing water drop coordinate system dv and calculating a trailing water drop pixel deviation value; combining the bead pixel offset value and the trailing bead pixel offset value into a pixel offset value col;
s5, supposing that an input image is an input original image T2, carrying out offset sampling on the original image T2 by using the pixel offset value col obtained in the step S4 to obtain an image with a water droplet sliding off, and then carrying out fuzzy algorithm processing on the image with the water droplet sliding off to obtain a fuzzy simulated water vapor effect image T1;
s6, calculating two radian distance fields when the wiper scraping form is simulated, and superposing the two radian distance fields to form a radian distance field T3;
and S7, mixing the simulated water vapor effect image T1 and the original image T2 through the radian distance field T3 to obtain a final simulated effect image.
3. The method for simulating raindrops and a wiper blade effect of a window glass in a rainy day according to claim 1, wherein the three-dimensional space model of the vehicle windshield in the step S2The uv coordinate system of (1) is the lower left corner (0,0), the upper left corner (0,1), the upper right corner (1,1), and the lower right corner (1, 0).
4. The method for simulating raindrops and a wiper blade effect of a window glass in a rainy day according to claim 1, wherein the three-dimensional space model of the vehicle windshield in the step S2The pull-up value w of the y-axis of the uv-coordinate is uv.y 10, and the formula of the downward movement of the uv-coordinate is uv.y + (t 0.25).
5. The method for simulating raindrops and a wiper blade effect of a window glass in a rainy day according to claim 1, wherein the three-dimensional space model of the windshield of the vehicle in the step S3Cutting into a plurality of equally divided squares, which specifically comprises the following steps:
s3-1, modeling the three-dimensional space of the vehicle windshieldThe uv coordinate system uv (x, y) ranges from 0 to 1 and is mapped into 0 to 10, and the mapping formula is uv-uv 10;
s3-2, and then changing a uv coordinate system into squares with x and y axes of 10 x 10 by the frac function, wherein the range of each square is 0-1, and calculating a gv-frac (uv) -0.5 coordinate system of the water drop so that the range of each square of 10 x 10 is-0.5.
6. The method for simulating the effects of raindrops on a window glass and the wiping action of a wiper in a rainy day according to claim 1, wherein the step S4 is specifically as follows:
s4-1, fitting a noise function, defining a two-dimensional coordinate q (x, y), q.x ═ 123.34, q.y ═ 345.45, inputting a coordinate value p (x, y), calculating p + ═ dot (p, p +34.345) through p ═ frac (p × q), and outputting a random noise value n ═ p.x × (p.y), wherein dot () is a calculated point-by-point function;
s4-2, fitting a pull-up function formula as follows: (w) sin (3w) sin (w) 6;
s4-3, fitting a motion curve function formula as follows: (t) ═ sin (t + sin (t) × 0.5));
s4-4, calculating a pulling value formula of an x axis for the water drop, wherein x is (n-0.5) × 0.8; x + (0.4-abs (x)) f (w), wherein abs () is an absolute value function; calculating a motion value of a y-axis for the water droplet, wherein the motion value is expressed as y ═ f (t); y ═ g.x-x (g.x-x);
s4-5, calculating the coordinate position of the water drop in the water drop coordinate space, and assuming that an offset vector is m1(x, y), wherein m1.x is the pull-up value of the x axis calculated in the step S4-4, m1.y is the motion value of the y axis calculated in the step S4-4, and the formula of the water drop coordinate is that dropPos is gv-m 1; calculating a drop pixel offset value drop (0.05,0.03, length (dropPos)) from dropPos;
s4-6, calculating a trailing water droplet coordinate system d (x, y) in a trailing water droplet space, assuming that an offset vector is m2(x, y), wherein m2.x is the x-axis pulling value calculated in the step S4-4, m2.y is t 0.25, and the trailing water droplet coordinate system formula is that d (x, y) is gv-m 2; calculating trailing water droplet coordinates droptailboom Pos, wherein the formula is as follows:
dropTrailPos.x=d.x;dropTrailPos.y=(frac(d.y*8)/8)-0.03;
calculating a trailing water bead pixel offset value droptail ═ smoothstep (0.03,0.02, length: (droptail pos)) from droptail pos;
s4-7, the superimposed water droplet pixel offset value and the trailing water droplet pixel offset value are a pixel offset value col, which is expressed as col ═ drop + drop tail.
7. The method for simulating the effect of raindrops on a window glass and the wiping action of a wiper in a rainy day according to claim 1, wherein the step S5 is to obtain a blurred simulated water vapor effect image T1, and comprises the following specific steps:
s5-1, using the pixel offset value col obtained in the step S4 as texture sampling of the original image T2 to obtain an image of the original image after texture coordinate offset, namely an image of water drops sliding off;
s5-2, processing the water drop image obtained in the S5-1 by using a mean fuzzy algorithm: using the noise function fitted in the step S4 to model the vehicle windshield in three-dimensional spaceThe uv coordinates uv (x, y) of (a) are used as input values, assuming that the output random noise value is a, and the two-dimensional vectors e (x, y), e.x ═ sin (a), e.y ═ cos (a); the offset value offset is calculated by the formula of 0.01 × e, an offset pixel value is obtained by sampling an image in which water drops slide through the offset value offset, sampling is performed four times in a circulating manner, a random noise value a + ═ 1 is output in each circulating manner, the offset pixel value obtained by sampling four times is added and divided by 4 to obtain an average pixel value which is used as a new pixel value, and a blurred simulated water vapor effect image T1 is formed by the new pixel value.
8. The method for simulating raindrops on a window glass and a wiping effect of a wiper in a rainy day according to claim 1, wherein the step S6 is to superimpose two arc distance fields as one arc distance field T3, specifically:
s6-1, giving definition of radian distance field function, inputting 4 parameters, namely uv coordinate points uv (x, y), central coordinate points c (x, y), angle values angle and distance values len;
s6-2, calculating a vector dir which is equal to uv-center of the uv coordinate point and the central coordinate point;
calculating the distance dist ═ length (dir) between the uv coordinate point and the central coordinate point;
calculating an included angle ang between the vector dir and the x axis of the uv coordinate system, namely atan2(dir.y, dir.x);
calculating a relation value dd between the distance dist and an input distance value len, wherein the relation value dd is 1-smooth step (len, len +0.02, dist), and when the distance dist is smaller than len, the output dd value is 1; when the distance dist is larger than len +0.02, outputting a dd value of 0; outputting a value with dd between 0 and 1 when the distance dist is larger than len and smaller than len + 0.02;
calculating a relation value aa of the included angle ang and the input angle value angle as 1-smooth (angle, angle +0.8, degrees (angle)), and when the included angle ang is smaller than the angle, outputting an aa value of 1; when the included angle ang is larger than angle, the output aa value is 0; outputting a value aa of between 0 and 1 when the included angle ang is larger than angle and smaller than angle + 0.8;
and, calculating an output value of the radian distance field function equal to dd aaa;
s6-3, using the function of the radian distance field obtained in step S6-2, assuming that the left radian distance field parameter is input to obtain an output value dt1, assuming that the right radian distance field parameter is input to obtain an output value dt2, merging dt1 and dt2 into a radian distance field T3-min (dt1+ dt2, 1); wherein the min function is the value of the limit dt1+ dt2 between 0 and 1.
9. The method for simulating the effect of raindrops on a window glass and the wiping effect of a wiper in a rainy day according to claim 1, wherein the step S7 of mixing to obtain a final simulation effect image is as follows:
mixing the simulated steam effect image T1 and the original image T2 through a radian distance field T3 to obtain a final simulated effect image T-lerp (T2, T1 and T3), and outputting a pixel value of the original image T2 when the radian distance field T3 is 0; outputting a pixel value of a simulated steam effect image T1 when the radian distance field T3 has a value of 1; intermediate over-interpolation of pixel values of the original image T2 to pixel values of the simulated steam effect image T1 is output when the radian distance field T3 is greater than 0 and less than 1.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor when executing the program performs the steps of the method of simulating raindrops and wiper blade effects of a windscreen wiper according to any of the claims 1 to 9.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111515157.4A CN114201832B (en) | 2021-12-10 | 2021-12-10 | Method and equipment for simulating wiping effect of window glass raindrops and windscreen wiper in rainy days |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111515157.4A CN114201832B (en) | 2021-12-10 | 2021-12-10 | Method and equipment for simulating wiping effect of window glass raindrops and windscreen wiper in rainy days |
Publications (2)
Publication Number | Publication Date |
---|---|
CN114201832A true CN114201832A (en) | 2022-03-18 |
CN114201832B CN114201832B (en) | 2024-07-16 |
Family
ID=80652777
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111515157.4A Active CN114201832B (en) | 2021-12-10 | 2021-12-10 | Method and equipment for simulating wiping effect of window glass raindrops and windscreen wiper in rainy days |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114201832B (en) |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6146143A (en) * | 1997-04-10 | 2000-11-14 | Faac Incorporated | Dynamically controlled vehicle simulation system, and methods of constructing and utilizing same |
JP2009070215A (en) * | 2007-09-14 | 2009-04-02 | Making:Kk | Simulation device |
US20100053325A1 (en) * | 2008-09-03 | 2010-03-04 | Dai Nippon Printing Co., Ltd. | Image converter |
CN111008928A (en) * | 2019-11-26 | 2020-04-14 | 杭州趣维科技有限公司 | Method and system for realizing special effect of dripping and scratching ripples of raindrops of image |
-
2021
- 2021-12-10 CN CN202111515157.4A patent/CN114201832B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US6146143A (en) * | 1997-04-10 | 2000-11-14 | Faac Incorporated | Dynamically controlled vehicle simulation system, and methods of constructing and utilizing same |
JP2009070215A (en) * | 2007-09-14 | 2009-04-02 | Making:Kk | Simulation device |
US20100053325A1 (en) * | 2008-09-03 | 2010-03-04 | Dai Nippon Printing Co., Ltd. | Image converter |
CN111008928A (en) * | 2019-11-26 | 2020-04-14 | 杭州趣维科技有限公司 | Method and system for realizing special effect of dripping and scratching ripples of raindrops of image |
Also Published As
Publication number | Publication date |
---|---|
CN114201832B (en) | 2024-07-16 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN105336003B (en) | The method for drawing out three-dimensional terrain model with reference to the real-time smoothness of GPU technologies | |
CN106056660A (en) | Mobile terminal simulation particle system method | |
Wilkie et al. | Virtualized traffic at metropolitan scales | |
Kaneda et al. | Animation of water droplet flow on curved surfaces | |
CN104157000B (en) | The computational methods of model surface normal | |
Wang et al. | Automatic generation of large-scale 3D road networks based on GIS data | |
CN106570926A (en) | Efficient particle cloud drawing method in flight scene simulation | |
CN105184843A (en) | OpenSceneGraph-based three dimensional animation manufacturing method | |
CN115330969A (en) | Local static environment vectorization description method for ground unmanned vehicle | |
KR100816622B1 (en) | Image generating device and image generating method | |
CN114138265B (en) | Visualization method based on digital twinning | |
CN113808243B (en) | Drawing method and device for deformable snowfield grid | |
CN114201832A (en) | Method and device for simulating window glass raindrops and wiper scraping effect in rainy days | |
CN113536538A (en) | Pedestrian and vehicle interaction simulation method and system based on traffic conflict | |
JPH11509009A (en) | Weather phenomenon effect simulation method and apparatus | |
Sakaino | A semitransparency-based optical-flow method with a point trajectory model for particle-like video | |
Galazka et al. | CiThruS2: Open-source photorealistic 3D framework for driving and traffic simulation in real time | |
CN111859612B (en) | Laser radar simulation method and device | |
CN114254501A (en) | Large-scale grassland rendering and simulating method | |
CN107274482B (en) | Marine oil spill visualization and interaction method based on texture projection method | |
CN114078202A (en) | Performance evaluation method and device of natural scene target detection system | |
Luo et al. | On the representation of contact states between curved objects | |
CN117710557B (en) | Method, device, equipment and medium for constructing realistic volume cloud | |
CN114820971B (en) | Graphical expression method for describing complex driving environment information | |
US11727616B2 (en) | Contour lines for volumetric objects |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |