Disclosure of Invention
One or more embodiments of the present specification describe a method and apparatus for improving transformation and rendering effects of a 3D particle model by performing optimization processing on remaining particles in the 3D particle model transformation.
According to a first aspect, there is provided a method of transforming a 3D particle model, comprising:
determining a first particle number and a second particle number related to a target model state to be transformed by a 3D particle model, wherein the first particle number is the number of particles required by the target model state, and the second particle number is the difference value between the total number of all particles included in the 3D particle model and the first particle number;
determining a second number of particles from the total number of particles;
determining whether a predetermined condition is satisfied based on the second number of particles;
and under the condition that the preset condition is met, setting the target position of the second particle for model transformation, so that the second particle with the ratio exceeding the preset ratio is in a position which is invisible after rendering in the target model state.
According to one possible design, the method further includes determining a first number of particles from the total number of particles; and setting the target position of the first particle for model transformation to form the target model state.
According to one embodiment, the starting time for the model transformation of the second particle is also optimally set to a predetermined time after the first particle starts the model transformation, in case the above predetermined condition is met.
In one embodiment, the first number of particles needed for a target model state is obtained from a 3D rendering engine.
In a possible design, the determination of the predetermined condition may include: judging whether the number of the second particles is larger than a preset number threshold value or not; or judging whether the ratio of the second particle number to the total number of all the particles is larger than a preset ratio threshold value.
In one embodiment, the second number of particles may be determined by randomly selecting a second number of particles as the second particles from the total number of particles.
According to one embodiment, the target model state corresponds to a closed shape. In such a case, the target position of the second particles may be set to be located within the closed shape.
According to one design, the target position of the second particle exceeding the predetermined proportion is set to be behind the first particle in a line of sight direction of the rendered view of the target model state.
Further, in one embodiment, the rendered view includes a first view having a first line of sight direction and a second view having a second line of sight direction, the first particles including third particles and fourth particles. In this case, the target position of at least one particle of the second particles may be set to be located at an intersection of a first extension line and a second extension line, the first extension line being an extension line of a position passing through the third particles in the first line-of-sight direction, the second extension line being an extension line of a position passing through the fourth particles in the second line-of-sight direction.
In one embodiment, the target position of at least one second particle may be set to be behind other second particles in the line of sight direction of the rendered view.
According to a second aspect, there is provided an apparatus for transforming a 3D particle model, comprising:
a number determination unit configured to determine a first number of particles and a second number of particles related to a target model state to be transformed by a 3D particle model, where the first number of particles is a number of particles required by the target model state, and the second number of particles is a difference between a total number of all particles included in the 3D particle model and the first number of particles;
a particle determination unit configured to determine a second particle of the second number of particles from the total number of particles;
a determination unit configured to determine whether a predetermined condition is satisfied based on the second number of particles;
and the position setting unit is configured to set the target position of the second particle for model transformation under the condition that the preset condition is met, so that the second particle with the ratio exceeding a preset ratio is in a position which is invisible after rendering in the target model state.
According to a third aspect, there is provided a computer readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method of the first aspect.
According to a fourth aspect, there is provided a computing device comprising a memory and a processor, wherein the memory has stored therein executable code, and wherein the processor, when executing the executable code, implements the method of the first aspect.
According to the embodiment of the specification, the number of the residual particles in the 3D particle model transformation is determined, and when the number of the residual particles is large, the target position of the residual particles is optimized to be in an invisible position after rendering. Furthermore, the optimization processing of the conversion starting time can be carried out, so that the conversion is delayed relative to the required particles. Therefore, the transformation and rendering of the 3D particle model have better visual reduction degree and visual effect.
Detailed Description
The scheme provided by the specification is described below with reference to the accompanying drawings.
Fig. 2 is a schematic view of an implementation scenario of an embodiment disclosed in this specification. As shown in fig. 2, when the 3D particle model is to undergo a transformation from the current model state to the target model state, a transformation optimization process is first performed. In the transformation optimization process, the number of particles required to form the target model state and the number of remaining particles are determined, and then the remaining particles are processed. Specifically, the position processing may be performed on the remaining particles, and the target positions thereof may be set to be covered by the target model state, so that the remaining particles are in positions that are not visible after rendering. The method can also be processed by changing the starting time, and the starting time for changing the model is set to start the change only after the particles needed by the target model start the model change. In this way, the model transformation is optimized. Then, based on the result of the optimization process, transformation and rendering of the object model is performed by means of a 3D engine. The specific procedure of the above-described transformation optimization process is described below.
Fig. 3 shows a flow diagram of a method of transformation of a 3D particle model according to an embodiment. The execution subject of the method can be any device, apparatus, platform, etc. with computing and processing capabilities. As shown in fig. 3, the transformation method at least includes, step 31, determining a first number of particles and a second number of particles associated with a target model state to be transformed by the 3D particle model, where the first number of particles is a number of particles required by the target model state, and the second number of particles is a difference between a total number of all particles included in the 3D particle model and the first number of particles; step 32, determining second particles with a second number of particles from all the particles; step 33, judging whether a predetermined condition is satisfied based on the second particle number; and step 34, under the condition that the preset condition is met, setting the target position of the second particle for model transformation, so that the second particle with the ratio exceeding the preset ratio is in a position which is invisible after rendering in the target model state. Specific execution modes of the above steps are described below.
First, in step 31, a first number of particles and a second number of particles associated with the target model state are determined, wherein the first number of particles is the number of particles required by the target model state, and the second number of particles is the difference between the total number of all particles included in the 3D particle model and the first number of particles, that is, the number of remaining particles, or the number of redundant particles, of the total number of particles excluding the particles required by the target model.
It will be appreciated that there are already some 3D rendering engines for transforming and rendering 3D particle models. The 3D rendering engine determines the number of particles required based on the various model states. Generally, in a 3D particle model, particles are used primarily to define the boundaries of the model shape, enveloping the general shape of the model. Therefore, generally, a relatively large number of particles are required for a model state having a complicated shape and a large change in surface curvature; for model states with simple shapes and small changes in surface curvature, a relatively small number of particles is required. To meet the requirements of various model states, a larger total number of particles is set for the 3D particle model. The 3D rendering engine may then use algorithms to determine in advance how many particles are needed for each model state to form and render, e.g., based on model size, model shape, particle density for each curvature shape, etc. for each model state.
Thus, in step 31, once the target model state to be transformed by the 3D particle model is determined, the number of particles required by the target model state, i.e. the first number of particles, can be obtained from the 3D rendering engine. Then, the difference between the total number of particles and the first number of particles is used as a second number, namely the number of remaining particles.
In a specific example, assuming that the total number of particles of the 3D particle model is 5000 and the number of particles required for the target model state, i.e. the first number of particles, is 4500, then correspondingly, the second number of particles is 500.
Next, in step 32, a second number of second particles is determined from the total number of particles, that is, the remaining particles are determined from the total number of particles.
In one embodiment, simultaneously with, or before or after step 32, a first number of first particles is also determined from all the particles, i.e. the particles required for the target model state are determined from all the particles. In other words, in this step, all the particles are divided into desired particles and remaining particles.
In one embodiment, the desired particle and the remaining particles are divided in a randomly selected manner. For example, a second number of particles are randomly selected from the total number of particles as remaining particles, and the rest are desired particles. Alternatively, a first number of particles are randomly selected from all the particles as desired particles, and the rest are left as remaining particles.
In another embodiment, the desired particle and the remaining particles are divided in consideration of the current position state of the particle. For example, the current position of each particle is determined, the target position of each particle in the target model state is determined, and the desired particle is selected according to the principle of proximity, for example, the particle closer to the target position is selected as the desired particle, so that the particle migration distance in the model transformation process is short.
In other embodiments, the desired particles and the remaining particles may also be divided in a greater variety of ways.
In one specific example, it is assumed that 500 particles are randomly selected as the remaining particles from among all 5000 particles, and the other 4500 particles are the desired particles.
Next, in step 33, it is determined whether a predetermined condition is satisfied based on the remaining particle number. The predetermined condition is a transformation optimization condition, and the subsequent transformation optimization processing is performed only when the predetermined condition is satisfied.
In one embodiment, the predetermined condition may be whether the number of remaining particles is greater than a preset number threshold. For example, in the above example, the remaining number of examples is 500. Assuming that the preset number threshold is 400, it can be determined that the number of remaining particles is greater than the preset number threshold, and the optimization process is required.
In another embodiment, the predetermined condition may be whether a ratio of the number of remaining particles to the total number of all particles is greater than a preset ratio threshold. For example, in the above example, the number of remaining particles was 500, the total number of all particles was 5000, and the proportion of remaining particles was 10%. Assuming that the preset proportion threshold is 8%, it can be determined that the proportion of the remaining particles is greater than the preset proportion threshold, and the optimization processing is required.
It will be appreciated that more flexible setting of the above predetermined conditions is also possible.
If the number of the residual particles does not meet the preset condition, the number of the residual particles is not large, the transformation and rendering effect of the model cannot be obviously influenced, and optimization processing can be omitted.
On the other hand, if it is determined based on the number of remaining particles that the predetermined condition is satisfied, step 34 is performed to optimally set the target positions of the remaining particles.
Generally, before optimally setting the target positions of the remaining particles, the target positions of the desired particles are determined, that is, the target positions of the desired particles (the first particles described above) subjected to model transformation are set to form the target model state. It is understood that the 3D rendering engine may pre-calculate the arrangement positions of the particles when forming each model state. Thus, the target position of the desired particle can be directly determined by means of the results of the 3D rendering engine.
In addition, it is understood that the step of determining the target position of the desired particle (first particle) may be performed after the desired particle is marked off in step 32 and before step 33, or may be performed after step 33 and before step 34.
In one embodiment, on the basis of determining the position arrangement of the particles required in the target model state, the target positions of the remaining particles are optimally set, so that the remaining particles exceeding a predetermined proportion are in positions invisible after rendering in the target model state.
Specifically, in one embodiment, the target model state corresponds to a closed shape. In such a case, the target positions of the remaining particles may be set to lie within the closed shape corresponding to the target model state.
As previously mentioned, in a 3D particle model, particles are used primarily to define the boundaries of the model shape, enveloping the general shape of the model. For the target model state of the closed shape, the required particles will be arranged at the boundary of the model shape and envelope a closed space. Positioning the remaining particles within the closed shape will cause the desired particles (first particles) forming the closed shape to "wrap" the remaining particles (second particles). Meanwhile, because the surface of the closed shape is densely covered with the required particles, the enclosed residual particles are shielded by the required particles in the rendered view with great proportion and probability and are not visible visually.
Fig. 4 shows the placement of the remaining particles in one embodiment. It can be seen that the model state in fig. 4 corresponds to the model B in fig. 1, which corresponds to a closed shape resembling the shape of a diamond. In the illustration of fig. 1, there are many remaining particles in the model space outside the diamond shape due to the random drift, affecting the rendering effect. In fig. 4, the remaining particles are shown with white asterisks. It can be seen that since the positions of the remaining particles are set within the diamond-like closed shape, there are no more floating remaining particles outside the diamond shape and most of the remaining particles are blocked from view by the desired particles forming the diamond shape. Even if a small amount of the remaining particles are not occluded, the rendered visual appearance is visually blended with the desired particles of the diamond-shaped surface due to the presence of the particles within the model shape, and does not significantly affect the visual reduction.
In one embodiment, in order to make the remaining particles in a position in the target model state that is not visible after rendering, the target positions of more than a certain proportion of the remaining particles may be set to be occluded by the desired particles forming the shape of the target model. That is, in the line-of-sight direction of the rendered view, the remaining particles (second particles) are located behind the desired particles (first particles). In this way, in the rendered view, the remaining particles are obscured by the desired particles forming the model state, seen along the line of sight direction, and are thus in an invisible state.
Fig. 5 shows a position arrangement of the remaining particles according to an embodiment, wherein the left side view shows a perspective view and the right side view shows a top view. In fig. 5, an object model in the shape of a cubic column with an open upper end is shown. For the sake of clarity and simplicity, only the shape of the target pattern, and two particles M and N among the desired particles (first particles) forming the pattern shape, are shown in fig. 5. Specifically, particle M is located on the surface ABCD of the cube, and particle N is located on the BD line. It is assumed that after rendering, a view from the front of the surface ABCD needs to be obtained, i.e. the direction of the line of sight is perpendicular to the surface ABCD. The remaining particles P can then be arranged behind the desired particle M in the direction of the line of sight, i.e. on the extension of the line of sight through the particle M. Similarly, the remaining particle Q may be arranged to be behind the desired particle N in the line of sight direction, i.e. on the extension of the line of sight through the particle N. In this way, after the model rendering, when viewed along the above-mentioned line-of-sight direction, the remaining particle P is blocked by the desired particle M, and the remaining particle Q is blocked by the desired particle N, so that both P and Q are in an invisible state.
It should be noted that, in some cases, the target model state needs to be rendered and displayed from multiple angles. Accordingly, there are multiple rendered views, each view having a respective gaze direction. In such a case, the positions of the remaining particles are set to be behind the desired particles in the direction of the line of sight of as many views as possible.
In particular, it is assumed that the rendered view comprises a first view having a first gaze direction and a second view having a second gaze direction. The desired particle includes a plurality of particles, where a certain particle (referred to as a third particle) is in a visible position in the first view and another example (referred to as a fourth particle) is in a visible position in the second view. At this time, the remaining particles may be disposed to be located at an intersection of two extension lines respectively parallel to the line-of-sight direction, i.e., an intersection of a first extension line and a second extension line, wherein the first extension line is an extension line of a position passing through the third particles in the first line-of-sight direction, and the second extension line is an extension line of a position passing through the fourth particles in the second line-of-sight direction. In this way, the remaining particles are hidden by the desired particles and are thus invisible, regardless of whether they are viewed from the first line of sight or from the second line of sight.
Fig. 6 illustrates a position arrangement of remaining particles according to an embodiment. More specifically, FIG. 6 shows a top view of the cube-pillar shaped object model shown in FIG. 5. It is assumed that for the object model, at least a first view from the first viewing direction V1 and a second view from the second viewing direction V2 need to be displayed after rendering. For simplicity and clarity, fig. 6 only shows particles M and O of the desired particles. Similar to fig. 5, the particle M is located on the surface ABCD, in a visible position in a view viewed from the first viewing direction V1 perpendicular to the surface ABCD. The particle O is located on the other surface of the cube, in a visible position in a view from the second line of sight direction. At this time, a certain remaining particle P may be disposed to be located at an intersection of an extension line L1 and an extension line L2, where the extension line L1 is an extension line of a position passing through the particle M in the first visual line direction V1, and the extension line L2 is an extension line of a position passing through the particle O in the second visual line direction V2. In this manner, the remaining particles P are blocked by the desired particles and are in an invisible state in both the view from the first visual line direction V1 and the view from the second visual line direction V2.
In one embodiment, in order to make the remaining particles in a position in the target model state that is not visible after rendering, the target positions of the remaining particles may also be set such that one remaining particle is occluded by another remaining particle in the rendered view, i.e. a plurality of remaining particles are occluded from each other. That is, at least one remaining particle (second particle) is located behind the other remaining particles in the line-of-sight direction of the rendered view. In this way, in the rendered view, at least part of the remaining particles are occluded from view along the line of sight and are thus in an invisible state. Thus, the number of visible remaining particles is reduced, and the visual reduction degree is improved to some extent. The positional relationship in which the shielding is formed in the line-of-sight direction between the particles can be referred to as shown in fig. 5, and the positional relationship in which the shielding is formed in the plurality of line-of-sight directions can be referred to as shown in fig. 6, except that the desired particles are replaced with the remaining particles.
It will be appreciated that the above embodiments may be used in combination with each other to form a wide variety of embodiments. For example, in one embodiment, the target positions of the remaining particles are set such that one portion is blocked by the desired particle in the line of sight direction and another portion is blocked by other remaining particles. In another embodiment, the target positions of the remaining particles are set to be located inside the closed shape corresponding to the target model state, while a certain proportion of the remaining particles are blocked by the desired particles. In yet another embodiment, the target positions of the remaining particles are set to be located inside the closed shape corresponding to the target model state, while a part of the remaining particles is occluded by another part of the remaining particles, and so on.
In addition to performing optimization at the target location, in one embodiment, the time for the remaining particles to initiate the model transformation is further optimally set. Specifically, in one embodiment, the starting time of the remaining particle model transformation is set to be a predetermined time after the required particle starts the model transformation, that is, the transformation of the required particle from the current position to the target position in the target model state is started first, and then the transformation of the remaining particle to the target position thereof is started at a predetermined time after that, wherein the target position of the remaining particle is set according to the foregoing embodiment. The setting of the predetermined time may depend on the time interval of the model transformation, the time required for the transformation, and the like. In a typical case, the predetermined time may be set to several hundred milliseconds, i.e., the position transition of the remaining particles is initiated with a delay of several hundred milliseconds compared to the position transition of the desired particles. The asynchronous transformation can enable the target model state to be formed quickly, the transformation and rendering of the model are accelerated, and the transformation and rendering effects are further improved.
Through the embodiment, under the condition that the number of the residual particles is large, the optimization processing is carried out on the residual particles, including the optimization of the target position and the optimization of the starting time, so that the transformation and rendering of the 3D particle model have better visual reduction degree and visual effect.
In an embodiment of another aspect, a transformation apparatus for a 3D particle model is also provided. Fig. 7 shows a schematic block diagram of a 3D particle model transformation apparatus according to an embodiment. As shown in fig. 7, the transforming apparatus 700 includes: a number determining unit 710 configured to determine a first number of particles and a second number of particles related to a target model state to be transformed by a 3D particle model, where the first number of particles is a number of particles required by the target model state, and the second number of particles is a difference between a total number of all particles included in the 3D particle model and the first number of particles; a particle determining unit 720 configured to determine a second particle of the second number of particles from the total number of particles; a determination unit 730 configured to determine whether a predetermined condition is satisfied based on the second number of particles; and a position setting unit 740 configured to set a target position for model transformation of the second particle so that the second particle exceeding a predetermined ratio is in a position invisible after rendering in the target model state, if the predetermined condition is satisfied.
In one embodiment, the apparatus 700 further comprises a time setting unit 750 configured to set a start time of the model transformation of the second particle to be a predetermined time after the model transformation is started by the first particle, in case the predetermined condition is satisfied.
According to an embodiment, the particle determining unit 720 is further configured to determine a first particle of the first number of particles from the total number of particles; accordingly, the position setting unit 740 is further configured to set the target position of the first particle for model transformation to form the target model state.
In one embodiment, the determining the number of the first particles by the number determining unit 710 comprises: obtaining the first number of particles needed for the target model state from a 3D rendering engine.
According to an embodiment, the particle determination unit 720 is configured to randomly select a second number of particles as the second particles from all the particles.
According to an embodiment, the determining unit 730 is configured to: judging whether the number of the second particles is larger than a preset number threshold value or not; or judging whether the ratio of the second particle number to the total number of all the particles is larger than a preset ratio threshold value.
In one embodiment, the target model state corresponds to a closed shape. In such a case, the position setting unit 740 is configured to set the target position of the second particle to be located within the closed shape.
In an embodiment, the position setting unit 740 is configured to set the target position of the second particle exceeding the predetermined proportion to be located behind the first particle in the line-of-sight direction of the rendered view of the target model state.
Further, in one embodiment, the rendered view includes a first view having a first gaze direction and a second view having a second gaze direction; the first particles include third particles and fourth particles; accordingly, the position setting unit 740 is configured to set the target position of at least one of the second particles to be located at an intersection of a first extension line that is an extension line of a position passing through the third particles in the first line-of-sight direction and a second extension line that is an extension line of a position passing through the fourth particles in the second line-of-sight direction.
In a further embodiment, the position setting unit 740 is configured to set the target position of at least one second particle to be located behind other second particles in the line-of-sight direction of the rendered view.
By the device, under the condition that the number of the residual particles is large, optimization processing including target position optimization and starting time optimization is carried out on the residual particles, so that the transformation and rendering of the 3D particle model have better visual reduction degree and visual effect.
According to an embodiment of another aspect, there is also provided a computer-readable storage medium having stored thereon a computer program which, when executed in a computer, causes the computer to perform the method described in connection with fig. 3.
According to an embodiment of yet another aspect, there is also provided a computing device comprising a memory and a processor, the memory having stored therein executable code, the processor, when executing the executable code, implementing the method described in connection with fig. 3.
Those skilled in the art will recognize that, in one or more of the examples described above, the functions described in this invention may be implemented in hardware, software, firmware, or any combination thereof. When implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium.
The above-mentioned embodiments, objects, technical solutions and advantages of the present invention are further described in detail, it should be understood that the above-mentioned embodiments are only exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made on the basis of the technical solutions of the present invention should be included in the scope of the present invention.