Image processing method and device for realizing simulated snow effect
By simulating the snowing process in 3D virtual technology, the collision between snow particles and virtual objects and the accumulated height value are used to calculate the color change value, and rendering the virtual objects is solved, which solves the problem of unreal snowing effect in the existing technology, and achieves a more realistic snowing scene fusion effect.
Patent Information
- Application Number
- CN202210393277.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-15
- Publication Date
- 2025-03-18
- Estimated Expiration
- 2042-04-15
AI Technical Summary
The existing 3D virtual technology simulates snowing effects are not realistic enough and cannot effectively integrate snowing scenes and reality.
By adding snowflake particles to the emitter for emission, when the snowflake particles collide with the virtual object, the collision position coordinates are determined and the snowflake particles are destroyed, the cumulative height value and color change value of the hit position of the snowflake particles are calculated, and the virtual objects are rendered based on this information to simulate the real snowing process.
The entire process of real snow is realized, so that the snow scene and reality are fusion effect are better, and the authenticity and visualization of the scene are enhanced.
Smart Images

Figure CN114758101B_ABST
Abstract
Description
[0001] This application claims the priority of the Chinese patent application filed with the China Patent Office on January 7, 2022, with application number 202210017585.2 and invention name “An image processing method and device for realizing simulated snowing effect”, the entire contents of which are incorporated by reference in this application. Technical Field
[0002] The present application relates to the field of 3D virtual technology, and in particular to an image processing method and device for realizing simulated snowing effect. Background Art
[0003] In the field of 3D virtual technology, it is usually necessary to visualize and restore some events or effects, such as restoring an explosion event or presenting the effect of simulating a snowy scene.
[0004] At present, there are many ways to simulate snow in the field of 3D virtual technology, such as using Unity to simulate snow effects. Unity is a user interface based on the GNOME desktop environment and is mainly used in the Ubuntu operating system. However, the snow scene simulated by Unity is not realistic enough and cannot effectively integrate the snow scene with reality. Summary of the invention
[0005] In order to solve the above technical problems, the embodiment of the present application provides an image processing method and device for realizing simulated snow effect, simulating the whole process of real snowing, so that the snowing scene can be better integrated with reality. The technical solution is as follows:
[0006] On the one hand, an embodiment of the present application provides an image processing method for realizing a simulated snow effect, comprising:
[0007] Add snowflake particles to the emitter for emission;
[0008] When the snowflake particles collide with the virtual object, the collision position coordinates are determined and the snowflake particles are destroyed;
[0009] Determine the cumulative height value of the snowflake particles hitting the collision position coordinates;
[0010] The original color of the collision position is changed to white to obtain a vertex color, and the transparent value of the vertex color is accumulated, and the color change value of the collision position is calculated by the vertex color and the transparent value of the vertex color;
[0011] The virtual object is rendered according to the collision position coordinates, the accumulated height value and the color change value.
[0012] Preferably, before adding the snowflake particles into the emitter for emission, the method further comprises:
[0013] Add the snowflake particles to the upper node of the octree.
[0014] Preferably, before adding the snowflake particles into the emitter for emission, the method further comprises:
[0015] Change the emission direction of the snowflake particles through pre-configured influencers.
[0016] Preferably, rendering the virtual object according to the collision position coordinates, the accumulated height value and the color change value comprises:
[0017] Obtaining a normal vector of a normal line of the virtual object at the collision position coordinates;
[0018] In the programmable rendering pipeline of the virtual object, the vertex coordinates of the collision position coordinates after being offset along the normal direction are calculated according to the collision position coordinates, the accumulated height value and the normal vector;
[0019] Inputting the collision position coordinates, the vertex coordinates and the original color into the programmable rendering pipeline for rendering;
[0020] The parameter value of the second layer texture of the virtual object is obtained according to the color change value to change the second layer texture of the virtual object.
[0021] Preferably, rendering the virtual object according to the collision position coordinates, the accumulated height value and the color change value comprises:
[0022] The collision position coordinates are stored in a first rendering target through multiple rendering targets to obtain a first geometry buffer;
[0023] Storing the color change value in a second rendering target through the multiple rendering targets to obtain a second geometry buffer;
[0024] Storing the accumulated height value in a third rendering target through the multiple rendering targets to obtain a third geometry buffer;
[0025] Storing the normal information in a fourth rendering target through the multiple rendering targets to obtain a fourth geometry buffer, the normal information including a normal vector of the normal of the virtual object at the collision position coordinates;
[0026] In the programmable rendering pipeline of the virtual object, the first geometry buffer, the second geometry buffer, the third geometry buffer and the fourth geometry buffer are merged, and the vertex coordinates of the collision position coordinates after being offset along the normal direction are calculated using the collision position coordinates, the accumulated height value and the normal vector to generate a fifth geometry buffer;
[0027] The fifth geometry buffer is rendered in the programmable rendering pipeline.
[0028] Preferably, the step of calculating the vertex coordinates of the collision position coordinates after the collision position coordinates are offset along the normal direction according to the collision position coordinates, the accumulated height value and the normal vector comprises:
[0029] The vertex coordinates of the collision position after the coordinates are offset along the normal direction are calculated according to the following calculation formula:
[0030] out.vertex=in.vertex+in.Alpha*in.normal,
[0031] Among them, out.vertex represents the vertex coordinates of the collision position coordinates in the virtual object after being offset along the normal direction, in.vertex represents the collision position coordinates in the virtual object, in.Alpha represents the cumulative height value of the snowflake particles hitting the collision position coordinates, and in.normal represents the normal vector of the normal line of the virtual object at the collision position coordinates.
[0032] On the other hand, an embodiment of the present application provides an image processing device for realizing a simulated snow effect, comprising:
[0033] The emission unit is used to add snowflake particles to the emitter for emission;
[0034] A destruction unit, used for determining the collision position coordinates and destroying the snowflake particles when the snowflake particles collide with the virtual object;
[0035] A determination unit, used to determine the cumulative height value of the snowflake particles hitting the collision position coordinates;
[0036] A calculation unit, used for changing the original color of the collision position to white to obtain a vertex color, accumulating the transparent values of the vertex colors, and calculating the color change value of the collision position through the vertex colors and the transparent values of the vertex colors;
[0037] A rendering unit is used to render the virtual object according to the collision position coordinates, the accumulated height value and the color change value.
[0038] Preferably, the device further comprises:
[0039] The node unit is used to add the snowflake particles to the upper node of the octree.
[0040] Preferably, the rendering unit is specifically used for:
[0041] Obtaining a normal vector of a normal line of the virtual object at the collision position coordinates;
[0042] In the programmable rendering pipeline of the virtual object, the vertex coordinates of the collision position coordinates after being offset along the normal direction are calculated according to the collision position coordinates, the accumulated height value and the normal vector;
[0043] Inputting the collision position coordinates, the vertex coordinates and the original color into the programmable rendering pipeline for rendering;
[0044] The parameter value of the second layer texture of the object is obtained according to the color change value to change the second layer texture of the virtual object.
[0045] Preferably, the rendering unit is specifically used for:
[0046] The collision position coordinates are stored in a first rendering target through multiple rendering targets to obtain a first geometry buffer;
[0047] Storing the color change value in a second rendering target through the multiple rendering targets to obtain a second geometry buffer;
[0048] Storing the accumulated height value in a third rendering target through the multiple rendering targets to obtain a third geometry buffer;
[0049] Storing the normal information in a fourth rendering target through the multiple rendering targets to obtain a fourth geometry buffer, the normal information including a normal vector of the normal of the virtual object at the collision position coordinates;
[0050] In the programmable rendering pipeline of the virtual object, the first geometry buffer, the second geometry buffer, the third geometry buffer and the fourth geometry buffer are merged, and the vertex coordinates of the collision position coordinates after being offset along the normal direction are calculated according to the collision position coordinates, the accumulated height value and the normal vector to generate a fifth geometry buffer;
[0051] The fifth geometry buffer is rendered in the programmable rendering pipeline.
[0052] Compared with the prior art, the beneficial effects of this application are:
[0053] In an embodiment of the present application, snowflake particles are added to the emitter for emission. When the snowflake particles collide with a virtual object, the collision position coordinates are determined and the snowflake particles are destroyed. The cumulative height value of the snowflake particles hitting the collision position coordinates is determined, the original color of the collision position is changed to white to obtain the vertex color, and the transparent value of the vertex color is accumulated. The color change value of the collision position is calculated by the vertex color and the transparent value of the vertex color. The virtual object is rendered according to the collision position coordinates, the cumulative height value and the color change value. The embodiment of the present application proposes an image processing method for realizing a simulated snowing effect, combining physical collisions and real-time calculations, so that snow can cover any virtual object in the scene, so that the snowing scene can be better integrated with reality. BRIEF DESCRIPTION OF THE DRAWINGS
[0054] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0055] Figure 1 This is a flowchart of Embodiment 1 of an image processing method for realizing a simulated snow effect provided by the present application;
[0056] Figure 2 is a flow chart of Embodiment 2 of an image processing method for realizing a simulated snowing effect provided by the present application;
[0057] Figure 3 is a flowchart of Embodiment 3 of an image processing method for realizing simulated snow effect provided by the present application;
[0058] Figure 4 is a flowchart of Embodiment 4 of an image processing method for realizing a simulated snowing effect provided by the present application;
[0059] Figure 5 It is a structural schematic diagram of an image processing device for realizing simulated snow effect provided by the present application;
[0060] Figure 6 is a schematic diagram of the force synthesis principle provided by the present application;
[0061] Figure 7 It is a schematic diagram of the synthesis of wind and gravity provided by this application;
[0062] Figure 8 It is a schematic diagram of the object bounding box provided in this application. DETAILED DESCRIPTION
[0063] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0064] Some of the terms involved in this application are explained:
[0065] Programmable rendering pipeline (shader), including vertex fragment shader and color fragment shader.
[0066] Render Target (RT) refers to creating a texture-sized display storage space in the graphics card's video memory;
[0067] Multiple Render Target (MRT), which means creating multiple RTs at one time;
[0068] Geometry Buffer (GBuffer) refers to a buffer containing color, normal, and world space coordinates, that is, a texture containing color, normal, and world space coordinates.
[0069] The embodiment of the present application discloses an image processing method for realizing a simulated snowing effect, including: adding snowflake particles to an emitter for emission; when the snowflake particles collide with a virtual object, determining the collision position coordinates and destroying the snowflake particles; determining the cumulative height value of the snowflake particles hitting the collision position coordinates; making the original color of the collision position white to obtain the vertex color, and accumulating the transparency value of the vertex color, and determining the color change value of the collision position through the vertex color and the transparency value of the vertex color; rendering the virtual object according to the collision position coordinates, the cumulative height value and the color change value. In the embodiment of the present application, the whole process of real snowing is simulated, so that the snowing scene is better integrated with reality.
[0070] Next, an image processing method for realizing a simulated snow effect disclosed in an embodiment of the present application is introduced. Figure 1 As shown, it is a flowchart of Embodiment 1 of an image processing method for realizing simulated snow effect provided by the present application, and the method comprises the following steps:
[0071] Step S11, adding snowflake particles to the emitter for emission.
[0072] In this embodiment, the emitter consists of an active queue and an inactive queue. First, a certain amount of snowflake particles are created, the snowflake particles are added to the active queue, and the emission is performed according to the acceleration calculation offset formula. The acceleration calculation offset formula is as follows:
[0073]
[0074] Among them, v represents the initial velocity of the snowflake particle emission, and the value of v is between 0-1; a represents the acceleration of the snowflake particle emission; t represents the time from the emission to the destruction of the snowflake particle.
[0075] When the external environment is not considered, a is the gravitational acceleration g (g = 9.8m / s 2 ), the snowflake particles are emitted downwards due to the influence of gravity, and the acceleration calculation offset formula only acts on the y-axis, and the x and z values are both 0.
[0076] In the actual snowing process, there will be external environmental influences, such as wind influence, so there is also a pre-configured influencer in this embodiment.
[0077] There may be wind forces in multiple directions in the external environment, so the influencer randomly generates one or more wind components in different directions, and sets acceleration outside the components so that different components have different vector values. According to the principle of force synthesis, the synthetic wind force and synthetic wind direction of the vector values in multiple directions are determined. Figure 6 As shown, assuming there is a force F in the AB direction 1 and the force F in the AC direction 2 , for F 1 and F 2 By synthesis, we get the force F in the AD direction 3 .
[0078] In this embodiment, the component forces in multiple directions are first synthesized to obtain the synthesized wind force and the direction of the synthesized wind force, and then the synthesized wind force f is synthesized with the gravity G of the snowflake particles to obtain the synthesized force F, and the synthesized wind force direction is synthesized with the gravity direction of the snowflake particles to obtain the direction of the synthesized force, thereby obtaining the new direction and force of the falling snowflake particles (such as Figure 7 As shown, the angle between the resultant wind force f and the gravity G is α). Therefore, the snowflake particles can be deflected left and right by the pre-configured influencer.
[0079] Step S12: When the snowflake particles collide with the virtual object, the collision position coordinates are determined and the snowflake particles are destroyed.
[0080] When a snowflake particle falls into a certain spatial range, that is, when the coordinate position (x, y, z) of the snowflake particle is included in the range of a virtual object, it means that the snowflake particle collides with the virtual object. When a snowflake particle collides with a virtual object, the coordinates of the snowflake particle are the collision position coordinates.
[0081] In this embodiment, the object range of each virtual object is calculated using the bounding box information of each virtual object. The object range is expressed as Among them, ObjMin represents the minimum (x, y, z) value of the virtual object, ObjMax represents the maximum (x, y, z) value of the virtual object, ObjMin.x is the minimum value of the x value of the eight vertices of the virtual object bounding box, ObjMin.y is the minimum value of the y value of the vertices of the virtual object bounding box, ObjMin.z is the minimum value of the z value of the vertices of the virtual object bounding box, ObjMax.x is the maximum value of the x value of the vertices of the virtual object bounding box, ObjMax.y is the maximum value of the y value of the vertices of the virtual object bounding box, and ObjMax.z is the maximum value of the z value of the vertices of the virtual object bounding box. Figure 8 As shown, suppose there is an object composed of ABCDEFH, the coordinates of A are (0,0,0), the coordinates of B are (10,0,0), the coordinates of C are (10,6,0), the coordinates of D are (0,6,0), the coordinates of E are (0,0,4), the coordinates of F are (10,0,4), the coordinates of G are (10,6,4), and the coordinates of H are (0,6,4), then the ObjMin.x of the object ABCDEFH is 0, ObjMin.y is 0, ObjMin.z is 0, ObjMax.x is 10, ObjMax.y is 6, and ObjMax.z is 4.
[0082] In order to quickly locate which virtual object the snowflake particle is contained in, the object range of each virtual object in the scene is pre-calculated. When it is determined that the snowflake particle collides with the virtual object, the snowflake particle is automatically destroyed and placed in the inactive queue after being destroyed, waiting to be reactivated for re-emission.
[0083] Each virtual object is composed of multiple triangular faces. After determining that the snowflake particles enter the range of a single virtual object, the triangular face to which the collision position belongs is determined, thereby determining the coordinates of the collision position.
[0084] Step S13, determining the cumulative height value of the snowflake particles hitting the collision position coordinates.
[0085] Step S14, making the original color of the collision position white to obtain the vertex color, accumulating the transparent values of the vertex colors, and calculating the color change value of the collision position through the vertex colors and the transparent values of the vertex colors.
[0086] When snow starts to fall, snowflake particles collide with virtual objects, and the collision position turns white. As time goes by, the color of the collision position will continue to deepen. In this embodiment, not only the original color of the collision position is turned white, but also the transparency value is accumulated on the vertex color of the collision position, making the scene of the collision between snowflake particles and virtual objects more realistic. During the snow melting process, according to the change of external temperature, the collision position also slowly presents the color of the virtual object itself, that is, slowly presents the original color of the collision position.
[0087] Step S15: Rendering the virtual object according to the collision position coordinates, the accumulated height value and the color change value.
[0088] After the snowflake particles physically collide with the virtual object, the accumulated amount over time will cause the collision position to deform and change color. Therefore, the virtual object needs to be rendered based on the calculated collision position coordinates, the accumulated height value, and the determined color change value. There are two solutions for drawing the deformation and color changes after the accumulation of rain and snow: forward rendering and post-processing delayed rendering. These two solutions will be explained in subsequent embodiments.
[0089] In the embodiment of the present application, snowflake particles are added to the emitter for emission; when the snowflake particles collide with the virtual object, the collision position coordinates are determined and the snowflake particles are destroyed; the cumulative height value of the snowflake particles hitting the collision position coordinates is determined; the original color of the collision position is changed to white to obtain the vertex color, and the transparency value of the vertex color is accumulated, and the color change value of the collision position is calculated by the vertex color and the transparency value of the vertex color; the virtual object is rendered according to the collision position coordinates, the cumulative height value and the color change value. In the embodiment of the present application, the whole process of real snowing is simulated, so that the snowing scene is better integrated with reality.
[0090] As another optional embodiment of the present application, refer to Figure 2 , is a flow chart of a second embodiment of an image processing method for realizing a simulated snowing effect provided by the present application. This embodiment is mainly a refinement of the image processing method for realizing a simulated snowing effect described in the first embodiment above. Figure 2 As shown, the method may include but is not limited to the following steps:
[0091] Step S20: adding the snowflake particles to the upper node of the octree.
[0092] Adding snowflake particles to the upper nodes of the octree enables the position of the snowflake particles to be quickly located when detecting the collision between the snowflake particles and the virtual objects.
[0093] Step S21, adding the snowflake particles into the emitter for emission.
[0094] Step S22: When the snowflake particles collide with the virtual object, the collision position coordinates are determined and the snowflake particles are destroyed.
[0095] In this embodiment, before determining whether a snowflake particle falls on a certain virtual object, the scene is first spatially segmented through an octree. When it is necessary to determine the falling position of the snowflake particle, the spatial size of each layer of the octree node is traversed to first determine in which node the snowflake particle is. Each octree node stores a list of all models of its own segmented space, and then by traversing the model list and judging which virtual object the snowflake particle collides with based on the size of the virtual object bounding box. Among them, the octree usually divides the entire scene into eight equal parts, and divides the segmented space into eight equal parts again, with no more than seven levels of segmentation in sequence. Too many levels will reduce the efficiency of traversal.
[0096] Step S23, determining the cumulative height value of the snowflake particles hitting the collision position coordinates.
[0097] Step S24, making the original color of the collision position white to obtain the vertex color, accumulating the transparent values of the vertex colors, and calculating the color change value of the collision position through the vertex colors and the transparent values of the vertex colors.
[0098] Step S25: Rendering the virtual object according to the collision position coordinates, the accumulated height value and the color change value.
[0099] The detailed process of steps S23-S25 can refer to the relevant introduction of steps S13-S15 in Example 1, which will not be repeated here.
[0100] As another optional embodiment of the present application, refer to Figure 3 , is a flow chart of a third embodiment of an image processing method for realizing a simulated snowing effect provided by the present application. This embodiment is mainly a refinement of the image processing method for realizing a simulated snowing effect described in the first embodiment above. Figure 3 As shown, the method may include but is not limited to the following steps:
[0101] Step S31, adding snowflake particles to the emitter for emission.
[0102] Step S32: When the snowflake particles collide with the virtual object, the collision position coordinates are determined and the snowflake particles are destroyed.
[0103] Step S33, determining the cumulative height value of the snowflake particles hitting the collision position coordinates.
[0104] Step S34, making the original color of the collision position white to obtain the vertex color, and accumulating the transparent values of the vertex colors, and calculating the color change value of the collision position through the vertex colors and the transparent values of the vertex colors.
[0105] The detailed process of steps S31-S34 can refer to the relevant introduction of steps S11-S14 in Example 1, which will not be repeated here.
[0106] Step S351: Obtain a normal vector of the normal line of the virtual object at the collision position coordinates.
[0107] Step S352: In the shader of the virtual object, the vertex coordinates of the collision position coordinates after being offset along the normal direction are calculated according to the collision position coordinates, the accumulated height value and the normal vector.
[0108] Step S353: input the collision position coordinates, the vertex coordinates and the original color into the shader for rendering.
[0109] Step S354: acquiring a parameter value of the second layer texture of the virtual object according to the color change value, so as to change the second layer texture of the virtual object.
[0110] Steps S351-S354 are a specific implementation of step S15 in Example 1.
[0111] In this embodiment, a forward rendering engine mechanism is involved. First, the normal vector of the normal line of the virtual object at the collision position coordinate is obtained. In the shader of the virtual object, the vertex coordinates of the collision position coordinate after being offset along the normal line direction are calculated according to the collision position coordinate, the accumulated height value and the normal vector. The collision position coordinate, the vertex coordinate and the original color are input into the shader for rendering. Then, the parameter value of the second-layer texture of the virtual object is obtained according to the color change value to change the second-layer texture of the virtual object. Forward rendering does not need to process global rendering information before rendering, nor does it need to ensure the accuracy of color or other attributes before rendering.
[0112] As another optional embodiment of the present application, refer to Figure 4 , is a flow chart of a fourth embodiment of an image processing method for realizing a simulated snowing effect provided by the present application. This embodiment is mainly a refinement of the image processing method for realizing a simulated snowing effect described in the first embodiment above. Figure 4 As shown, the method may include but is not limited to the following steps:
[0113] Step S41, adding snowflake particles to the emitter for emission.
[0114] Step S42: When the snowflake particles collide with the virtual object, the collision position coordinates are determined and the snowflake particles are destroyed.
[0115] Step S43, calculating the vertex coordinates of the collision position coordinates after being offset along the normal direction.
[0116] Step S44: the original color of the collision position is changed to white to obtain a vertex color, and the transparent values of the vertex colors are accumulated, and the color change value of the collision position is determined by the vertex colors and the transparent values of the vertex colors.
[0117] The detailed process of steps S41-S44 can refer to the relevant introduction of steps S11-S14 in Example 1, which will not be repeated here.
[0118] Step S451: storing the collision position coordinates into a first rendering target through multiple rendering targets to obtain a first geometry buffer.
[0119] Step S452: Store the color change value into a second rendering target through the multiple rendering targets to obtain a second geometry buffer.
[0120] Step S453: Store the accumulated height value into a third rendering target through the multiple rendering targets to obtain a third geometry buffer.
[0121] Step S454: storing the normal information in a fourth rendering target through the multiple rendering targets to obtain a fourth geometry buffer, wherein the normal information includes a normal vector of the normal of the virtual object at the collision position coordinates.
[0122] Step S455: In the programmable rendering pipeline of the virtual object, the first geometry buffer, the second geometry buffer, the third geometry buffer and the fourth geometry buffer are merged, and the vertex coordinates of the collision position coordinates after being offset along the normal direction are calculated according to the collision position coordinates, the accumulated height value and the normal vector to generate a fifth geometry buffer.
[0123] Step S456: Render the fifth geometry buffer in the programmable rendering pipeline.
[0124] Steps S451-S456 are a specific implementation of step S15 in Example 1.
[0125] In the present embodiment, a post-processing delayed rendering mechanism is involved. The information in the current rendering frame is processed into multiple RTs through MRT, that is, the collision position coordinates are stored in the first RT through MRT to obtain the first GBuffer; the color change value is stored in the second RT through MRT to obtain the second GBuffer; the cumulative height value is stored in the third RT through MRT to obtain the third GBuffer; the normal information is stored in the fourth RT through MRT to obtain the fourth GBuffer. In the shader of the virtual object, the first GBuffer, the second GBuffer, the third GBuffer and the fourth GBuffer are merged, and the vertex coordinates of the collision position coordinates after the offset along the normal direction are calculated according to the collision position coordinates, the cumulative height value and the normal vector to generate the fifth GBuffer. In the present embodiment, the normal information includes the normal vector of the normal of the virtual object at the collision position coordinates.
[0126] Deferred rendering obtains global rendering information before rendering. The global rendering information includes the collision position coordinates, color change values, cumulative height values, and normal information of all snowflake particles in the scene. After obtaining the global rendering information, it performs one rendering to avoid the complex process caused by multiple renderings.
[0127] Among them, MRT is a function only available on some high-end graphics cards. In order to enable some graphics cards that do not support the MRT function to support the MRT function, multiple RTs can be created through a program for loop, so that some graphics cards that do not support the MRT function can also realize the MRT function.
[0128] As another optional embodiment of the present application, the vertex coordinates of the collision position after the coordinates are offset along the normal direction are calculated according to the following formula:
[0129] out.vertex=in.vertex+in.Alpha*in.normal;
[0130] Among them, out.vertex represents the vertex coordinates of the collision position coordinates in the virtual object after being offset along the normal direction, in.vertex represents the collision position coordinates in the virtual object, in.Alpha represents the cumulative height value of the snowflake particles hitting the collision position coordinates, and in.normal represents the normal vector of the normal line of the virtual object at the collision position coordinates. After it starts snowing, in.Alpha becomes higher and higher as time goes by; after it stops snowing, in.Alpha becomes lower and lower as time goes by.
[0131] Next, the image processing device for realizing the simulated snowing effect provided by the present application is introduced. The image processing device for realizing the simulated snowing effect introduced below and the image processing method for realizing the simulated snowing effect introduced above can be referred to each other.
[0132] like Figure 5 As shown, an image processing device for realizing a simulated snowing effect comprises:
[0133] The emission unit 501 is used to add snowflake particles into the emitter for emission;
[0134] A destroying unit 502, used for determining the collision position coordinates and destroying the snowflake particles when the snowflake particles collide with the virtual object;
[0135] A determination unit 503, used to determine the cumulative height value of the snowflake particles hitting the collision position coordinates;
[0136] The calculation unit 504 is used to whiten the original color of the collision position to obtain a vertex color, accumulate the transparency value of the vertex color, and calculate the color change value of the collision position through the vertex color and the transparency value of the vertex color;
[0137] The rendering unit 505 is used to render the virtual object according to the collision position coordinates, the accumulated height value and the color change value.
[0138] In this embodiment, the device further includes:
[0139] The node unit is used to add the snowflake particles to the upper node of the octree.
[0140] In this embodiment, the device further includes:
[0141] Pre-configured influencers for changing the emission direction of the snowflake particles.
[0142] In this embodiment, the rendering unit is specifically used for:
[0143] Obtaining a normal vector of a normal line of the virtual object at the collision position coordinates;
[0144] In the programmable rendering pipeline of the virtual object, the vertex coordinates of the collision position coordinates after being offset along the normal direction are calculated according to the collision position coordinates, the accumulated height value and the normal vector;
[0145] Inputting the collision position coordinates, the vertex coordinates and the original color into the programmable rendering pipeline for rendering;
[0146] The parameter value of the second layer texture of the virtual object is obtained according to the color change value to change the second layer texture of the virtual object.
[0147] In this embodiment, the rendering unit is specifically used for:
[0148] The collision position coordinates are stored in a first rendering target through multiple rendering targets to obtain a first geometry buffer;
[0149] Storing the color change value in a second rendering target through the multiple rendering targets to obtain a second geometry buffer;
[0150] Storing the accumulated height value in a third rendering target through the multiple rendering targets to obtain a third geometry buffer;
[0151] Storing the normal information in a fourth rendering target through the multiple rendering targets to obtain a fourth geometry buffer, the normal information including a normal vector of the normal of the virtual object at the collision position coordinates;
[0152] In the programmable rendering pipeline of the virtual object, the first geometry buffer, the second geometry buffer, the third geometry buffer and the fourth geometry buffer are merged, and the vertex coordinates of the collision position coordinates after being offset along the normal direction are calculated according to the collision position coordinates, the accumulated height value and the normal vector to generate a fifth geometry buffer.
[0153] In this embodiment, the calculating, according to the collision position coordinates, the accumulated height value and the normal vector, the vertex coordinates of the collision position coordinates after being offset along the normal direction specifically includes:
[0154] The vertex coordinates of the collision position after the coordinates are offset along the normal direction are calculated according to the following calculation formula:
[0155] out.vertex=in.vertex+in.Alpha*in.normal,
[0156] Among them, out.vertex represents the vertex coordinates of the collision position coordinates in the virtual object after being offset along the normal direction, in.vertex represents the collision position coordinates in the virtual object, in.Alpha represents the cumulative height value of the snowflake particles hitting the collision position coordinates, and in.normal represents the normal vector of the normal line of the virtual object at the collision position coordinates.
[0157] In the embodiment of the present application, snowflake particles are added to the emitter for emission; when the snowflake particles collide with the virtual object, the collision position coordinates are determined and the snowflake particles are destroyed; the cumulative height value of the snowflake particles hitting the collision position coordinates is determined; the original color of the collision position is changed to white to obtain the vertex color, and the transparency value of the vertex color is accumulated, and the color change value of the collision position is calculated by the vertex color and the transparency value of the vertex color; the virtual object is rendered according to the collision position coordinates, the cumulative height value and the color change value. In the embodiment of the present application, the whole process of real snowing is simulated, so that the snowing scene is better integrated with reality.
[0158] It should be noted that the same or similar parts between the various embodiments can be referred to each other. As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0159] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0160] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.
[0161] It can be known from the description of the above implementation methods that those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform. Based on such an understanding, the technical solution of the present application can be essentially or partly contributed to the prior art in the form of a software product, which can be stored in a storage medium such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in the various embodiments of the present application or certain parts of the embodiments.
[0162] The above is a detailed introduction to the image processing method and device for realizing simulated snow effect provided by the present application. Specific examples are used in this article to illustrate the principle and implementation mode of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for the general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation mode and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. An image processing method for realizing a simulated snow effect, characterized in that: include: Add snowflake particles to the emitter for emission; When the snowflake particles collide with the virtual object, the collision position coordinates are determined and the snowflake particles are destroyed; Determine the cumulative height value of the snowflake particles hitting the collision position coordinates; The original color of the collision position is changed to white to obtain a vertex color, and the transparent value of the vertex color is accumulated, and the color change value of the collision position is calculated by the vertex color and the transparent value of the vertex color; Rendering the virtual object according to the collision position coordinates, the accumulated height value and the color change value; Before adding the snowflake particles into the emitter for emission, the method further includes: Changing the emission direction of the snowflake particles by a pre-configured influencer, wherein the influencer is used to generate one or more directional wind components; When the snowflake particles collide with the virtual object, determining the collision position coordinates includes: Traverse the spatial size of each layer of the octree node to determine the node where the snowflake particle is located; Traversing the model list of the node where the snowflake particle is located, and determining the virtual object with which the snowflake particle collides according to the size of the virtual object bounding box; The collision position coordinates are determined according to the triangular face to which the collision position belongs in the virtual object.
2. The method according to claim 1, characterized in that Before adding the snowflake particles into the emitter for emission, the method further includes: Add the snowflake particles to the upper node of the octree.
3. The method according to claim 1, characterized in that The rendering of the virtual object according to the collision position coordinates, the accumulated height value and the color change value includes: Obtaining a normal vector of a normal line of the virtual object at the collision position coordinates; In the programmable rendering pipeline of the virtual object, the vertex coordinates of the collision position coordinates after being offset along the normal direction are calculated according to the collision position coordinates, the accumulated height value and the normal vector; Inputting the collision position coordinates, the vertex coordinates and the original color into the programmable rendering pipeline for rendering; The parameter value of the second layer texture of the virtual object is obtained according to the color change value to change the second layer texture of the virtual object.
4. The method according to claim 1, characterized in that: The rendering of the virtual object according to the collision position coordinates, the accumulated height value and the color change value includes: The collision position coordinates are stored in a first rendering target through multiple rendering targets to obtain a first geometry buffer; Storing the color change value in a second rendering target through the multiple rendering targets to obtain a second geometry buffer; Storing the accumulated height value in a third rendering target through the multiple rendering targets to obtain a third geometry buffer; Storing the normal information in a fourth rendering target through the multiple rendering targets to obtain a fourth geometry buffer, the normal information including a normal vector of the normal of the virtual object at the collision position coordinates; In the programmable rendering pipeline of the virtual object, the first geometry buffer, the second geometry buffer, the third geometry buffer and the fourth geometry buffer are merged, and the vertex coordinates of the collision position coordinates after being offset along the normal direction are calculated according to the collision position coordinates, the accumulated height value and the normal vector to generate a fifth geometry buffer; The fifth geometry buffer is rendered in the programmable rendering pipeline.
5. The method according to any one of claims 3 to 4, characterized in that: The step of calculating the vertex coordinates of the collision position coordinates after the collision position coordinates are offset along the normal direction according to the collision position coordinates, the accumulated height value and the normal vector comprises: The vertex coordinates of the collision position after the coordinates are offset along the normal direction are calculated according to the following calculation formula: out.vertex=in.vertex+in.Alpha*in.normal, Among them, out.vertex represents the vertex coordinates of the collision position coordinates in the virtual object after being offset along the normal direction, in.vertex represents the collision position coordinates in the virtual object, in.Alpha represents the cumulative height value of the snowflake particles hitting the collision position coordinates, and in.normal represents the normal vector of the normal line of the virtual object at the collision position coordinates.
6. An image processing device for realizing a simulated snow effect, characterized in that: include: The emission unit is used to add snowflake particles to the emitter for emission; A destruction unit, used for determining the collision position coordinates and destroying the snowflake particles when the snowflake particles collide with the virtual object; A determination unit, used to determine the cumulative height value of the snowflake particles hitting the collision position coordinates; A calculation unit, used for changing the original color of the collision position to white to obtain a vertex color, accumulating the transparent values of the vertex colors, and calculating the color change value of the collision position through the vertex colors and the transparent values of the vertex colors; A rendering unit, configured to render the virtual object according to the collision position coordinates, the accumulated height value and the color change value; The device also includes: A pre-configured influencer for generating one or more directional wind components to change the emission direction of the snowflake particles; The destruction unit determines the collision position when the snowflake particles collide with the virtual object, specifically for: Traverse the spatial size of each layer of the octree node to determine the node where the snowflake particle is located; Traversing the model list of the node where the snowflake particle is located, and determining the virtual object with which the snowflake particle collides according to the size of the virtual object bounding box; The collision position coordinates are determined according to the triangular face to which the collision position belongs in the virtual object.
7. The device according to claim 6, characterized in that The device also includes: The node unit is used to add the snowflake particles to the upper node of the octree.
8. The device according to claim 6, characterized in that The rendering unit is specifically used for: Obtaining a normal vector of a normal line of the virtual object at the collision position coordinates; In the programmable rendering pipeline of the virtual object, the vertex coordinates of the collision position coordinates after being offset along the normal direction are calculated according to the collision position coordinates, the accumulated height value and the normal vector; Inputting the collision position coordinates, the vertex coordinates and the original color into the programmable rendering pipeline for rendering; The parameter value of the second layer texture of the virtual object is obtained according to the color change value to change the second layer texture of the virtual object.
9. The device according to claim 6, characterized in that The rendering unit is specifically used for: The collision position coordinates are stored in a first rendering target through multiple rendering targets to obtain a first geometry buffer; Storing the color change value in a second rendering target through the multiple rendering targets to obtain a second geometry buffer; Storing the accumulated height value in a third rendering target through the multiple rendering targets to obtain a third geometry buffer; Storing the normal information in a fourth rendering target through the multiple rendering targets to obtain a fourth geometry buffer, the normal information including a normal vector of the normal of the virtual object at the collision position coordinates; In the programmable rendering pipeline of the virtual object, the first geometry buffer, the second geometry buffer, the third geometry buffer and the fourth geometry buffer are merged, and the vertex coordinates of the collision position coordinates after being offset along the normal direction are calculated according to the collision position coordinates, the accumulated height value and the normal vector to generate a fifth geometry buffer; The fifth geometry buffer is rendered in the programmable rendering pipeline.
Citation Information
Patent Citations
Force-based plant and snow interaction simulation method
CN111523271A