Rendering method and apparatus for flowing-light effect, and electronic device
By determining the location and calculating relevant parameters on the surface of the model surface such as the cube light box, combined with the time value, the multi-axial dynamic streaming effect is achieved, solving the problems of single effect and poor dynamic sense in the existing technology, and avoiding special UV treatment of the model and Break marks.
Patent Information
- Application Number
- PCT/CN2024/074489
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-05-18
- Filing Date
- 2024-01-29
- Publication Date
- 2024-11-21
AI Technical Summary
In the prior art, the dynamic streaming effects in virtual scenes such as cube light boxes are mostly single-axial or pseudo-multi-axial, with single effects and poor dynamic sense, and special treatment of the model UVs is required, resulting in obvious fracture marks at the joints. .
By determining the first and second sites on the surface of the model to be rendered, its position information and related parameters in the model coordinate system are calculated, and the color information of each site is calculated based on the time value of the rendering time, and the color information of each site is established Multi-axial dynamic streaming effect avoids special treatment of model UV.
The multi-axial dynamic streaming effect is realized, which enhances the dynamic sense, avoids the fracture of the streaming effect, and does not require additional streaming map processing.
Smart Images

Figure CN2024074489_21112024_PF_FP_ABST
Abstract
Description
Streamer effect rendering method, device, and electronic device
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to Chinese patent application number 202310571230.2, filed on May 18, 2023, entitled “A method, device, and electronic device for rendering a streamer effect”, the entire contents of which are incorporated herein by reference. Technical Field
[0003] The present disclosure relates to the field of computer technology, and in particular to a method, device, electronic device, and computer-readable storage medium for rendering a streamer effect. Background Art
[0004] Streaming effects are an essential rendering feature in virtual projects like games, providing users with a more vibrant visual experience. Currently, some virtual projects utilize dynamic, multi-axial streamers on 3D models to enhance the quality of the project. Cube light boxes, a common model for constructing virtual scenes, are often imbued with dynamic streamers.
[0005] In related technologies, the dynamic flowing light effects of cube light boxes are mostly uniaxial flow or pseudo-multiaxial flow. Among them, uniaxial flow is easier to achieve, but the effect is single and the dynamic sense is poor. Pseudo-multiaxial flow requires special processing of the texture image of the model, and obvious fracture marks will appear at the seams on the surface of the model.
[0006] Therefore, how to provide a method for rendering streamer effects with low production cost, good streamer effects, and strong dynamic sense has become a technical problem that needs to be solved urgently in this field.
[0007] Summary of the Invention
[0008] According to one aspect of the present disclosure, a method for rendering a streamer effect is provided, the method comprising:
[0009] Determining a first point and a second point on a to-be-rendered area of the to-be-rendered model, wherein the to-be-rendered area is at least a portion of an area on a surface of the to-be-rendered model, and the first point and the second point are different points within the to-be-rendered area;
[0010] Determine the position information of the to-be-rendered point in the model coordinate system, wherein the to-be-rendered point is any point on the to-be-rendered area, and the model coordinate system is a coordinate system with the first point as the origin;
[0011] Calculate the relevant parameters of the site to be rendered and the first feature line according to the position information of the site to be rendered in the model coordinate system, where the first feature line is the connecting line between the first point and the second point;
[0012] The color information of the location to be rendered at the nth rendering moment is calculated according to the relevant parameters and the time value corresponding to the nth rendering moment, where n is a positive integer greater than or equal to 1.
[0013] According to one aspect of the present disclosure, a device for rendering a streamer effect is provided, the device comprising: a position determination unit, a position information determination unit, a related parameter calculation unit, and a color information calculation unit;
[0014] a site determination unit, configured to determine a first site and a second site on a to-be-rendered area of the to-be-rendered model, wherein the to-be-rendered area is at least a portion of a surface of the to-be-rendered model, and the first site and the second site are different sites within the to-be-rendered area;
[0015] a position information determining unit, configured to determine position information of a to-be-rendered point in a model coordinate system, wherein the to-be-rendered point is any point on the to-be-rendered area, and the model coordinate system is a coordinate system with the first point as its origin;
[0016] A related parameter calculation unit, configured to calculate related parameters of the site to be rendered and a first feature line according to position information of the site to be rendered in the model coordinate system, where the first feature line is a line connecting the first point and the second point;
[0017] The color information calculation unit is used to calculate the color information of the to-be-rendered position at the nth rendering moment according to relevant parameters and the time value corresponding to the nth rendering moment, where n is a positive integer greater than or equal to 1.
[0018] According to one aspect of the present disclosure, there is provided an electronic device, including: a memory, a processor;
[0019] a memory for storing one or more computer instructions;
[0020] The processor is configured to execute one or more computer instructions to implement the above method.
[0021] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which one or more computer instructions are stored. When the instructions are executed by a processor, the above method is performed.
[0022] Compared with the related art, the rendering method of the streamer effect provided by the present disclosure includes: determining a first point and a second point on the to-be-rendered area of the to-be-rendered model, wherein the to-be-rendered area is at least a partial area on the model surface of the to-be-rendered model, and the first point and the second point are different points within the to-be-rendered area; determining the position information of the to-be-rendered point in the model coordinate system, wherein the to-be-rendered point is any point on the to-be-rendered area, and the model coordinate system is a coordinate system with the first point as the origin; calculating the relevant parameters of the to-be-rendered point and the first characteristic line according to the position information of the to-be-rendered point in the model coordinate system, the first characteristic line being the connecting line between the first point and the second point; calculating the color information of the to-be-rendered point at the nth rendering moment according to the relevant parameters and the time value corresponding to the nth rendering moment, wherein n is a positive integer greater than or equal to 1. This method is based on the geometric spatial relationship between the points in the to-be-rendered area on the surface of the to-be-rendered model, and establishes a relationship between the position information and color information of each point in the to-be-rendered area that changes with time, thereby realizing a multi-axial dynamic streamer effect on the model surface. The rendering method of the streamer effect provided by the present disclosure uses the geometric spatial relationship of each site on the surface of the model as the basis for rendering the streamer effect. Therefore, there is no need to perform special processing on the model and the model UV, and there will be no breakage of the streamer effect. In addition, the rendering method of the streamer effect provided by the present disclosure uses each site on the surface of the model as an independent site to be rendered for color rendering, and calculates the color information of each continuous site on the surface of the model at each continuous rendering moment. Therefore, the obtained streamer effect is multi-axial and has a strong sense of dynamics. In summary, the rendering method of the streamer effect provided by the present disclosure solves the technical problems of the existing streamer effect rendering method, such as the single streamer effect, poor sense of dynamics, the need for special processing of the model texture image, and the appearance of obvious breakage marks at the seams of the model surface. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] FIG1 is an application system diagram of a method for rendering a streamer effect provided by an embodiment of the present disclosure;
[0024] FIG2 is a flowchart of a method for rendering a streamer effect provided by the first embodiment of the present disclosure;
[0025] FIG3 is a schematic diagram of calculating relevant parameters of a site to be rendered provided by the first embodiment of the present disclosure;
[0026] FIG4 is a schematic diagram of rendering a streamer effect on a cube light box according to a second embodiment of the present disclosure;
[0027] FIG5 is a schematic diagram of another embodiment of the present disclosure for rendering a streamer effect on a cube light box;
[0028] FIG6 is another schematic diagram of rendering a streamer effect on a cubic light box according to the second embodiment of the present disclosure;
[0029] FIG7 is a schematic structural diagram of a device for rendering streamer effects provided by a third embodiment of the present disclosure;
[0030] FIG8 is a schematic structural diagram of an electronic device provided by a fourth embodiment of the present disclosure. DETAILED DESCRIPTION
[0031] The following description sets forth many specific details to facilitate a full understanding of the present disclosure. However, the present disclosure can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the scope of the present disclosure. Therefore, the present disclosure is not limited to the specific implementations disclosed below.
[0032] To facilitate understanding, a brief introduction is first given to the technical terms that may be involved in the embodiments of the present disclosure.
[0033] 1. Streamer effect
[0034] The light streamer effect is a graphic special effect commonly used in design, animation, video, and game production. By creating a series of parallel, interlaced colored stripes within an image or video, it creates a flowing, flickering effect, giving the user a sense of three-dimensionality and movement. Light streamers can be applied to a variety of projects, such as web design, game design, product presentations, and advertising, to enhance the user's visual experience.
[0035] Light streaming effects can be categorized into two types: uniaxial and multiaxial. Uniaxial light streaming typically manifests as a linear comb pattern in one direction, while multiaxial light streaming is more like a complex grid or lattice pattern, composed of multiple interlaced, colored lines moving in different directions. In between, there's a "pseudo-multiaxial light streaming effect," which appears to be composed of light rays interlaced in multiple directions, but actually uses a single light source.
[0036] 2. Uniaxial streamer effect
[0037] The uniaxial streamer effect creates a sense of fluidity and three-dimensionality by adding gradient color changes in a certain direction of the model, making it look like it is moving or deforming in that direction.
[0038] 3. Multi-axial streamer effect
[0039] The multi-axial streamer effect is similar to the uniaxial streamer effect, but it adds gradient color changes in multiple directions to create a more three-dimensional and dynamic effect. Compared with the uniaxial streamer effect, the multi-axial streamer effect can better express the three-dimensionality and movement of the model.
[0040] 4. Pseudo multi-axial streamer effect
[0041] The pseudo multi-axial streamer effect creates a flowing and flickering effect by creating a series of parallel and interlaced colored stripes on the surface of the model, giving a sense of three-dimensionality and movement. It looks like it is composed of multiple axial (i.e. different directions) light rays interlaced, but in fact only a single light source is used.
[0042] 5. Dot Product
[0043] The dot product, also known as the inner product or scalar product, is an operation between two vectors. It is the sum of the products of their corresponding components and can be represented by the symbol "·." For example, the dot product of vectors a and b is: a·b = a1b1 + a2b2 + ... + anbn. The dot product and the angle between vectors have the following relationship: a·b = |a| × |b| × cos(θ), where a and b represent vectors a and b, respectively, |a| and |b| represent the magnitudes of vectors a and b, respectively, and θ represents the angle between vectors a and b. The larger the dot product between two vectors, the smaller the angle.
[0044] 6. Mapping
[0045] A mapping is an operation that establishes a one-to-one correspondence between elements in one set and elements in another set. It is often used to describe the relationship between key-value pairs. A mapping is also a function in which each element in the domain uniquely corresponds to an element in the range.
[0046] 7. Frac function
[0047] The Frac function is a commonly used mathematical function that returns the fractional part of a real number. That is, for a real number x, Frac(x) equals the fractional part of x (the part remaining after removing the integer part). For example, Frac(6.82) equals 0.82.
[0048] 8. Lerp function
[0049] The Lerp (Linear Interpolation) function is a commonly used function in computer graphics. It is used to perform interpolation calculations between two known points to obtain a new point at a certain position between these two points. The calculation formula is: Lerp(A, B, C) = A×(1 - C) + B×C, where A and B represent two known points, and C is a number between 0 and 1, representing the position relationship of the new point relative to points A and B. When C = 0, the Lerp function returns A; when C = 1, the Lerp function returns B; when 0 < C < 1, the Lerp function returns the interpolation result between A and B. For example, when C is 0.5, the Lerp function returns the average value of A and B.
[0050] 9. Model UV
[0051] Model UV refers to the texture coordinates on a 3D model, also known as UV coordinates. These coordinates are used to map a 2D texture image onto the surface of a 3D model to achieve the texture mapping effect. In the UV coordinate system, each vertex has a corresponding UV coordinate, usually in the form of (u, v). Using UV coordinates allows developers to precisely control the display position and direction of the texture image on the model surface.
[0052] With the development of computer technology, virtual business projects such as games not only consider the usability of the project but also focus on the quality of the project. Among them, the flowing light effect is an indispensable rendering special effect for enhancing the project quality. Projects with the flowing light effect can often bring users a more gorgeous visual experience.
[0053] The flowing light effect is usually rendered on the model surface, that is, a high - light reflection is rendered on the model surface, making the model look as if it is surrounded or covered by colored and flowing light. The cube light box is a model commonly used to construct virtual scenes. The dynamic flowing light effects on traditional cube light boxes are mostly single - axial or pseudo - multi - axial. Among them, the production method of the single - axial flowing light effect is simple. A common method is to create a light - sweeping texture map and combine it with the UV coordinates on the model surface. By continuously updating the position of the light - sweeping texture map, the flowing light of texture movement is achieved. However, the flowing light effect rendered on the three - dimensional light box by this method has problems such as a single effect and poor dynamic sense. The production method of the pseudo - multi - axial flowing light effect is relatively complex. It is necessary to generate multiple flowing light maps in different directions and perform special processing on the model UV. By controlling multiple flowing light effects in different directions with multiple flowing light maps, the flowing light shows different intensities and speeds in different directions. However, due to the discontinuous UV coordinates at the seams of each face of the model, the flowing light map will produce a discontinuous effect at the seams, thus showing obvious fracture marks.
[0054] In view of this, the present disclosure provides a rendering method for streamer effects, which does not require special processing of the model UV or the production of additional streamer maps. The geometric spatial relationship of the model is used as the basis for rendering the streamer effect, and the relationship between the position information and color information of each point sequentially associated on the model surface that changes with time is established, thereby realizing a multi-axial dynamic streamer effect on the model surface, solving the technical problems of the existing streamer effect rendering method, such as the single streamer effect, poor dynamic sense, the need for special processing of the model UV, and the appearance of obvious fracture marks at the seams of the model surface.
[0055] The following further describes in detail the method, device, electronic device, and computer-readable storage medium for rendering the streamer effect of the present disclosure in conjunction with specific embodiments and drawings.
[0056] 1 is an application system diagram of a method for rendering a streamer effect provided by an embodiment of the present disclosure. As shown in FIG1 , the system includes a user node 101 and a service node 102. The user node 101 can be any device such as a smart phone, a tablet computer, a laptop computer, a desktop computer, a personal digital assistant (PDA), etc. The service node 102 can be a processing model inside the user node 101, or a processing device electrically connected to the user node 101, or a server communicatively connected to multiple user nodes 101. The rendering method for the streamer effect provided by the present disclosure is deployed on the service node 102, and when a user issues a rendering request for a model through the user node 101, the rendering method for the streamer effect provided by the embodiment of the present disclosure can be executed to render the model and present it to the user through the user node 101.
[0057] A first embodiment of the present disclosure provides a method for rendering a streamer effect.
[0058] Figure 2 is a flow chart of the method for rendering the streamer effect provided by this embodiment. The following describes the method for rendering the streamer effect provided by this embodiment in detail in conjunction with Figure 2. The embodiments described below are used to explain the technical solutions of this disclosure and are not intended to be limiting for actual use.
[0059] As shown in FIG. 2 , the method for rendering the streamer effect provided by this embodiment includes the following steps S210 to S240 .
[0060] In step S210 , a first point and a second point are determined on a to-be-rendered area of the to-be-rendered model, wherein the to-be-rendered area is at least a portion of the surface of the to-be-rendered model, and the first point and the second point are different points within the to-be-rendered area.
[0061] A site is a discrete point on the surface of a 3D model. In an optional implementation of this embodiment, pixels on the surface of the model being rendered are used as the basic unit for streamer rendering. That is, a pixel on the model surface is considered a site. The higher the pixel density and the denser the pixel density of the model being rendered, the better the model definition, resulting in a more detailed and vivid streamer effect.
[0062] The area to be rendered refers to the partial area or the entire area on the model surface of the model to be rendered where the light effect is desired to be rendered. That is, if the designer desires to display the light effect on the entire area of the model to be rendered, then the area to be rendered is the model surface of the model to be rendered.
[0063] The first location and the second location refer to different locations within the area to be rendered. In this step, the method for determining the first location and the second location may include the following optional implementations:
[0064] First, two randomly selected sites in the area to be rendered are used as the first site and the second site.
[0065] Secondly, the preset streamer flow direction is used as the basis for determining the first point and the second point. Specifically, any pair of points in the area to be rendered that are consistent with the streamer flow direction is used as the first point and the second point, and the connecting line between the first point and the second point is parallel to the streamer flow direction.
[0066] Third, the size of the area to be rendered is used as a basis for determining the first and second locations. Specifically, any pair of locations with a relatively large distance in the area to be rendered is used as the first and second locations.
[0067] Fourthly, the preset light flow direction and the size of the area to be rendered are used together as the basis for determining the first and second locations. Specifically, the site pair with the largest relative distance between the two sites in each site pair with the same light flow direction is used as the first and second locations.
[0068] Of course, in addition to the above four implementation methods, there are other implementation methods, such as: determining the first and second points based on the shape and material of the area to be rendered. The specific implementation method is not limited here.
[0069] In this step, determining the first point and the second point is actually to determine the reference point of the geometric relationship for the subsequent rendering of the light effect based on the geometric spatial relationship. The geometric spatial relationship between other points on the model to be rendered and the reference point can be further determined based on the reference point, so that each point can be rendered in color based on the corresponding geometric spatial relationship of each point. The specific method will be explained in detail in the subsequent steps.
[0070] Step S220 , determining the position information of the to-be-rendered point in the model coordinate system, wherein the to-be-rendered point is any point on the to-be-rendered area, and the model coordinate system is a coordinate system with the first point as the origin.
[0071] The site to be rendered refers to any site on the area to be rendered, that is, every site on the area to be rendered is a site to be rendered, including the first site and the second site.
[0072] The model coordinate system can be understood as a coordinate system established with the first point as its origin. The model coordinate system can be either a two-dimensional or three-dimensional coordinate system. If the first point and the second point are located on the same plane of the model surface to be rendered, a two-dimensional coordinate system with the first point as its origin can be established. If the first point and the second point are located on different planes of the model surface to be rendered, a three-dimensional coordinate system with the first point as its origin is required. The dynamic effect of the light flow rendered based on the geometric spatial relationship between each point to be rendered and the first and second points on the area to be rendered, obtained in the three-dimensional coordinate system, is more vivid.
[0073] The position information of the site to be rendered in the model coordinate system can be understood as the coordinates of the site to be rendered in the model coordinate system. If the model coordinate system is a two-dimensional coordinate system, the position information of the site to be rendered can be expressed as (X, Y). If the model coordinate system is a three-dimensional coordinate system, the position information of the site to be rendered can be expressed as (X, Y, Z).
[0074] Step S230 : Calculating parameters related to the site to be rendered and a first feature line based on the position information of the site to be rendered in the model coordinate system. The first feature line is a line connecting the first point and the second point.
[0075] The relevant parameters may be understood as data on the relationship between the site to be rendered and the first feature line, which is calculated based on the geometric spatial relationship between the site to be rendered, the first point, and the second point in the model coordinate system.
[0076] In an optional implementation provided by this embodiment, calculating the parameters related to the location to be rendered and the first feature line may include the following steps S231 and S232:
[0077] Step S231 : calculating original correlation parameters between the point to be rendered and the first feature line according to the position information of the point to be rendered in the model coordinate system and the first position information of the second point in the model coordinate system.
[0078] The original correlation parameters can be understood as the data of the initial relationship between the location to be rendered and the first feature line, obtained based on the geometric spatial relationship between the location to be rendered, the first point, and the second point in the model coordinate system. The relationship data, i.e., the correlation parameters, can only be obtained after processing the initial relationship data.
[0079] Since the first point is the origin of the model coordinate system, the position information of the site to be rendered and the position information of the second point can be used to obtain information such as the distance between the site to be rendered and the second point and the first point, and the inclination value of the site to be rendered and the second point. In this embodiment, the position information of the second point in the model coordinate system is defined as the first position information.
[0080] In an optional implementation of this embodiment, characteristic information of a first feature line between the second site and the first site and characteristic information of a second feature line between the site to be rendered and the first site are calculated based on the position information of the second site and the position information of the site to be rendered, thereby calculating original related parameters corresponding to the site to be rendered based on the characteristic information of the first feature line and the characteristic information of the second feature line. Specifically, the following steps S231-1 to S231-3 may be included:
[0081] Step S231 - 1 : determining first feature information of a first feature line according to first position information of a second point in a model coordinate system.
[0082] In this embodiment, feature information of the first feature line between the second point and the first point is defined as first feature information. The first feature information at least includes length information of the first feature line and inclination information of the first feature line in the model coordinate system.
[0083] Step S231 - 2 : determining second feature information of a second feature line between the first point and the point to be rendered according to the position information of the point to be rendered in the model coordinate system.
[0084] In this embodiment, feature information of the second feature line between the to-be-rendered position and the first position is defined as second feature information. The second feature information includes at least length information of the second feature line and inclination information of the second feature line in the model coordinate system.
[0085] Step S231 - 3 : Calculate the dot product of the first feature line and the second feature line based on the first feature information and the second feature information, and use the dot product as an original correlation parameter between the position to be rendered and the first feature line.
[0086] The dot product is an operation between two vectors. The dot product has the following relationship with the vector angle and vector modulus: a·b=|a|×|b|×cosθ
[0087] Where a and b represent vector a and vector b respectively, |a| and |b| represent the modulus of vector a and vector b respectively, and θ represents the angle between vector a and vector b.
[0088] In this embodiment, the dot product of the first feature line and the second feature line is used as the original correlation parameter corresponding to the position to be rendered. That is, the original correlation parameter is the length of the first feature line multiplied by the length of the second feature line multiplied by the angle between the first feature line and the second feature line.
[0089] The first characteristic information of the first characteristic line is obtained through step S231-1. The first characteristic information includes the length of the first characteristic line and the degree of inclination of the first characteristic line. The second characteristic information of the second characteristic line is obtained through step S231-2. The second characteristic information includes the length of the second characteristic line and the degree of inclination of the second characteristic line. The degree of the angle between the first characteristic line and the second characteristic line can be calculated based on the inclination degree of the second characteristic line and the inclination degree of the first characteristic line. Then, the original related parameters are calculated based on the length of the first characteristic line, the length of the second characteristic line, and the degree of the angle between the first characteristic line and the second characteristic line.
[0090] Step S232: Map the original related parameters to a value range of 0-1 to obtain related parameters.
[0091] In computer science, data processing often involves normalization for ease of calculation and accuracy. Normalization involves scaling data so that it falls within a specific range. A common normalization method is to map data to a range of 0-1, also known as minimum-maximum scaling or deviation normalization. To normalize a set of data, the maximum and minimum values within the data set are first determined. Each data point is then mapped to a range of 0-1 based on these values.
[0092] In this embodiment, the relevant parameters are normalized results of the original relevant parameters. In an optional implementation, obtaining the relevant parameters based on the original relevant parameters may specifically include the following steps S232-1 to S232-3:
[0093] Step S232 - 1 : Taking the first point as the position to be rendered, calculating original correlation parameters between the position to be rendered and the first feature line as first original correlation parameters.
[0094] Step S232 - 2 : Using the second point as the point to be rendered, calculating original correlation parameters between the point to be rendered and the first feature line as second original correlation parameters.
[0095] As mentioned above, the first point and the second point are reference points determined in the area to be rendered, the first point is the origin of the model coordinate system, and the original relevant parameters of the site to be rendered are the dot product results of the second characteristic line between the site to be rendered and the first point and the first characteristic line between the second point and the first point. The dot product operation is to multiply the lengths of the first characteristic line and the second characteristic line by the angle between the first characteristic line and the second characteristic line. Therefore, when the first point is regarded as the site to be rendered, the length of the second characteristic line is 0, and the dot product is the smallest, which is 0; when the second point is regarded as the site to be rendered, the first characteristic line coincides with the second characteristic line, and the angle between the two is 0. At this time, the dot product is the largest, which is the square value of the length of the first characteristic line.
[0096] When the first point is used as the site to be rendered, the calculated dot product is used as the minimum original correlation parameter. When the second point is used as the site to be rendered, the calculated dot product is used as the maximum original correlation parameter. In this embodiment, the minimum original correlation parameter is defined as the first original correlation parameter, and the maximum original correlation parameter is defined as the second original correlation parameter.
[0097] Step S232-3: Calculate the mapping value of the original relevant parameter corresponding to the point to be rendered within the value range of 0-1 according to the original relevant parameter, the first original relevant parameter, and the second original relevant parameter, and use the mapping value as the relevant parameter corresponding to the point to be rendered.
[0098] Based on the first original correlation parameter and the second original correlation parameter, the original correlation parameter corresponding to the site to be rendered is projected into the value range of 0-1 according to the minimum-maximum scaling method to obtain the correlation parameter corresponding to the site to be rendered. The calculation formula is as follows:
[0099] Among them, P represents the relevant parameters corresponding to the site to be rendered, L represents the original relevant parameters corresponding to the site to be rendered, and L min represents the first original correlation parameter, L max Represents the second original correlation parameter.
[0100] FIG3 is a schematic diagram of calculating relevant parameters of a location to be rendered provided by this embodiment.
[0101] As shown in Figure 3, assuming that the first point A and the second point B are located on the same plane of the model surface to be rendered, and the point C to be rendered is also located in the same plane as the first point A and the second point B, the calculation method of the relevant parameters corresponding to the point C to be rendered is as follows:
[0102] First, a model coordinate system 30 with the first point A as the origin is established. Since the first point A, the second point B, and the point to be rendered C are all located in the same plane of the model surface to be rendered, the model coordinate system 30 is established as a two-dimensional coordinate system.
[0103] Second, obtain the position information of the second point B and the point to be rendered C in the model coordinate system 30 . Assume that the position information of the second point B is (8, 6) and the position information of the point to be rendered C is (3, 4).
[0104] Third, based on the position information (8, 6) of the second point B, determine the first characteristic information of the first characteristic line AB between the second point B and the first point A. As shown in Figure 3, since the position information of the second point B is (8, 6), it can be seen that the length of the line segment BD is 6 (point D is the projection point of the second point B on the X-axis of the model coordinate system 30), and the length of the line segment AD is 8. Therefore, the length of the first characteristic line AB is 10, and the inclination angle θ1 of the first characteristic line AB is 30°. The first characteristic information includes: length information AB = 10, inclination information θ1 = 30°.
[0105] Fourth, based on the position information (3, 4) of the location C to be rendered, determine the second feature information of the second feature line AC between the location C to be rendered and the first location A. As shown in Figure 3, since the position information of the location C to be rendered is (3, 4), it can be seen that the length of the line segment CE is 4 (location E is the projection point of the location C to be rendered on the X-axis of the model coordinate system 30), and the length of the line segment AE is 3. Therefore, the length of the second feature line AC is 5, and the inclination angle θ2 of the second feature line AC is 60°. The second feature information includes: length information AC = 5, inclination information θ2 = 60°.
[0106] Fifth, the dot product of the first feature line AB and the second feature line AC is calculated based on the first feature information and the second feature information, and is used as the original correlation parameter L between the location C to be rendered and the first feature line AB. The calculation result is as follows:
[0107] Sixth, calculate the first original correlation parameter L between the first point A and the first characteristic line AB min Since the first point A is the origin of the model coordinate system 30, the position information of the first point A in the model coordinate system 30 is (0,0). Therefore, L min =0.
[0108] Seventh, calculate the second original correlation parameter L between the second point B and the first characteristic line AB max , the calculation results are as follows:
[0109] Eighth, according to the first original correlation parameter L min And the second original correlation parameter L maxCalculate the mapping value of the original related parameter L corresponding to the position C to be rendered within the value range of 0-1, and use it as the related parameter P corresponding to the position C to be rendered. The calculation results are as follows:
[0110] Through the above steps, the relevant parameters of the location C to be rendered and the first characteristic line AB are obtained. It should be noted that the above example assumes that the first location A, the second location B, and the location C to be rendered are located on the same plane of the surface of the model to be rendered, and the calculation method of the relevant parameters corresponding to the location C to be rendered is described. If the first location A and the second location B are located on different planes of the surface of the model to be rendered, the calculation method of the relevant parameters corresponding to the location C to be rendered is also consistent with the above method. The only difference is that the calculation of the length of the first characteristic line AB and the second characteristic line AC, and the angle θ between the first characteristic line AB and the second characteristic line AC, is relatively complex. The rest of the execution actions are the same and will not be listed here.
[0111] Step S240 , calculating the color information of the to-be-rendered point at the nth rendering moment according to relevant parameters and the time value corresponding to the nth rendering moment, where n is a positive integer greater than or equal to 1.
[0112] As the name implies, streamer refers to the flow of light. Therefore, the color corresponding to each point in the rendered area is not static; it changes over time, giving the overall rendered area a visual sense of flowing light. Therefore, after obtaining the relevant parameters corresponding to the points to be rendered through the above steps, it is necessary to associate the time information with them, so that each point is rendered with a different color at different times, achieving a dynamic streamer effect.
[0113] In an optional implementation provided by this embodiment, the time value corresponding to each rendering moment is associated with the relevant parameters corresponding to the location to be rendered, and the color information of the location to be rendered at each rendering moment is calculated. Specifically, the following steps S241 to S242 may be included:
[0114] Step S241 : Calculate a first parameter corresponding to the to-be-rendered position at the nth rendering moment according to relevant parameters and the time value corresponding to the nth rendering moment.
[0115] The first parameter can be understood as data obtained by associating the relevant parameters of the location to be rendered with the time value corresponding to the nth rendering moment. In an optional implementation, the relevant parameters and the time value can be associated by a processing method such as addition, which can specifically include the following steps S241-1 to S241-2:
[0116] Step S241 - 1 , adding the relevant parameter and the time value to obtain a second parameter.
[0117] If the first and second locations do not change, the relevant parameters corresponding to each location within the area to be rendered will remain unchanged. The relevant parameters are then summed with the time values at different rendering times. This combines the time values that vary with rendering time with the relevant parameters that do not. This ensures that the locations to be rendered are not only unique in geometric space but also fluid with respect to rendering time. In this embodiment, the result of summing the relevant parameters and the time values is defined as the second parameter.
[0118] Step S241 - 2 , taking the decimal part of the second parameter as the first parameter.
[0119] In order to obtain a more coherent streamer effect, the rendering moments need to be divided into smaller parts. For example, 1 second is divided into 50 rendering moments, that is, re-rendering is performed every 0.02 seconds. If the time interval is longer, the streamer effect will appear discontinuous. Since the rendering moments are divided into smaller parts, the difference between the multiple time values corresponding to the adjacent rendering moments is not large, and the integer part of the time value is basically the same, and the difference is only in the decimal part. The above steps define the relevant parameters corresponding to the to-be-rendered site as data within the value range of 0-1, that is, the relevant parameters corresponding to each site on the to-be-rendered area are basically decimals less than 1, and there is no integer part. In other words, the relevant parameter part constituting the second parameter is data less than 1, and the time value part constituting the second parameter is data with basically the same integer part and only the decimal part having a difference. Therefore, in order to reduce the calculation pressure and avoid invalid calculations, in an optional implementation method provided in this embodiment, the decimal part of the second parameter is obtained by the frac function, and the decimal part of the second parameter is used as the first parameter for subsequent color information calculation and processing. The first parameter can be expressed as: frac(P+T)
[0120] Among them, P represents the relevant parameters corresponding to the position to be rendered, and T represents the time value corresponding to the nth rendering moment.
[0121] Taking the calculation results of the relevant parameters shown in Figure 3 as an example, assuming that the time value of the n-th rendering moment is 10.02, then the first parameter corresponding to the rendering position C at the n-th rendering moment is: frac(P+T)=frac(0.43+10.02)=0.45
[0122] Step S242 : Calculate the color information of the to-be-rendered point at the nth rendering moment according to the first parameter, the first color information corresponding to the first preset color, and the second color information corresponding to the second preset color.
[0123] During the design phase of a business application, designers often preset the color of the flowing light to be rendered. For example, the color of the flowing light is set to change fluidly between green and blue. In this embodiment, the first color preset by the designer (e.g., green) is defined as the first preset color, and the preset second color (e.g., blue) is defined as the second preset color. Based on the first color information corresponding to the first preset color and the second color information corresponding to the second preset color, the color information corresponding to the rendering site can be calculated according to the first parameter.
[0124] Color information can be understood as a set of data used to describe colors, and can be represented in ways such as RGB (Red, Green, Blue) or HSB (Hue, Saturation, Brightness). In the RGB mode, color information consists of three values, which are the intensity values of red, green, and blue respectively. The value range of each color channel is 0 to 255, and various colors can be combined through different value combinations. For example, the RGB value of red is (255, 0, 0), the RGB value of black is (0, 0, 0), and the RGB value of white is (255, 255, 255).
[0125] In an optional implementation provided in this embodiment, the color information corresponding to the rendering site can be calculated through interpolation operations. Specifically: using the first parameter as the interpolation, and using the first color information and the second color information as the endpoint values, the color information corresponding to the first parameter is obtained through interpolation operations.
[0126] Interpolation operation is to perform interpolation calculations between two known points to obtain a new point located at a certain position between these two points. The calculation formula is: Lerp(A, B, C) = A × (1 - C) + B × C
[0127] Where, A and B represent two known points, and C represents a number between 0 and 1, indicating the position relationship of the new point relative to points A and B. When C = 0, the Lerp function returns A; when C = 1, the Lerp function returns B; when 0 < C < 1, the Lerp function returns the interpolation result between A and B. For example, when C is 0.5, the Lerp function returns the average value of A and B.
[0128] In this embodiment, taking the first color information of the first preset color as A, the second color information of the second preset color as B, and the first parameter corresponding to the rendering site as C, through the above interpolation function, the color information corresponding to the rendering site can be calculated. The calculation formula is as follows: FinalColor = Lerp(Color1, Color2, frac(P + T))
[0129] Among them, FinalColor represents the color information corresponding to the site to be rendered, Color1 represents the first color information corresponding to the first preset color, Color2 represents the second color information corresponding to the second preset color, frac(P+T) represents the first parameter corresponding to the site to be rendered, P represents the relevant parameters corresponding to the site to be rendered, and T represents the time value corresponding to the nth rendering moment.
[0130] Taking the calculation results of the relevant parameters shown in Figure 3 as an example, assuming that the time value of the n-th rendering moment is 10.02, then the first parameter corresponding to the rendering position C at the n-th rendering moment is: frac(P+T)=frac(0.43+10.02)=0.45
[0131] Assuming the first preset color is black and the second preset color is white, the first color information Color1 is RGB(0,0,0) and the second color information Color2 is RGB(255,255,255). When the first parameter corresponding to the rendering location C at the nth rendering time is 0.45, the color information FinalColor corresponding to the rendering location C at the nth rendering time is a mixture of 55% of the first color information and 45% of the second color information. The calculation formula is as follows: FinalColor = Lerp((0,0,0),(255,255,255),0.45)
[0132] Through the above steps S210 to S240, the color information of any point (the point to be rendered) on the area to be rendered of the model to be rendered at the nth rendering moment is calculated. Further, obtaining the streamer rendering effect may further include the following steps:
[0133] Step S250: obtaining color information of each to-be-rendered point on the to-be-rendered area at the nth rendering moment.
[0134] According to the method of step S210 to step S240, each point on the area to be rendered is used as a point to be rendered, and the color information of each point to be rendered on the area to be rendered at the nth rendering moment is calculated.
[0135] Step S260 : performing color rendering on the area to be rendered according to the color information corresponding to each position to be rendered, so as to obtain a streamer effect of the model to be rendered at the nth rendering moment.
[0136] After obtaining the color information corresponding to each location to be rendered at the nth rendering time, the corresponding color can be rendered on the to-be-rendered area of the model to be rendered based on the color information corresponding to each location to be rendered. The technology for rendering colors on models based on color information is relatively mature, and any color rendering method can be applied to the method provided in this embodiment. The specific rendering method will not be described here.
[0137] Through steps S210 to S260, the light streaming effect of the model to be rendered at the nth rendering time is obtained. By calculating the color information of each location to be rendered in real time over time, real-time color rendering is performed, resulting in a dynamic light streaming effect on the model to be rendered. Because the light streaming rendering method provided in this embodiment uses each location on the surface of the model to be rendered as an independent color rendering point, the resulting light streaming effect is multi-axial.
[0138] In an optional implementation provided by this embodiment, the model to be rendered is at least one of the following models: a cube model, a rectangular parallelepiped model, a cylindrical model, a spherical model, and an irregular shape model.
[0139] The model to be rendered can be a regular model, such as a cube model, a rectangular parallelepiped model, a cylindrical model, a spherical model, etc., or an irregular model, such as a cube model with a concave surface, etc. Regardless of the specific shape of the model to be rendered, the rendering method provided in this embodiment is applicable. Because the rendering method provided in this embodiment is a method based on geometric spatial relationships, that is, the color information of each to-be-rendered site at each rendering moment is calculated based on the geometric spatial relationship between each to-be-rendered site and the first and second sites on the to-be-rendered area of the model to be rendered. Specifically, regardless of the shape of the model to be rendered, and regardless of the shape of the area to be rendered located on the surface of the model to be rendered, the first and second sites can be determined on the to-be-rendered area, and the angle between the second characteristic line between the to-be-rendered site and the first point and the first characteristic line between the second site and the first point can be calculated based on the position information of any to-be-rendered site, thereby calculating the dot product of the first characteristic line and the second characteristic line, obtaining the relevant parameters of the to-be-rendered site and the first characteristic line, and then calculating the color information of the to-be-rendered site at each rendering moment. Therefore, the method for rendering the streamer effect provided in this embodiment can be applied to models of various shapes.
[0140] The above-mentioned first embodiment provides an optional method for rendering a streamer effect. It should be noted that the example in the first embodiment is only for explaining the method of the present disclosure and is not intended to be a limitation for actual use. The method for rendering a streamer effect provided by the present disclosure includes but is not limited to the method of the first embodiment.
[0141] The second embodiment of the present disclosure provides a method for rendering a streamer effect. In this embodiment, the method for rendering a streamer effect of the first embodiment of the present disclosure is illustrated by taking a specific example.
[0142] In this embodiment, the model to be rendered is a cube model, and the area to be rendered is at least a portion of the surface of the cube model.
[0143] The cube light box is a common model in the construction of virtual scenes such as games. In this embodiment, the cube light box is used as the model to be rendered, and the cube light box is rendered with a streaming effect. The rendering area can be the entire area of the cube light box surface or a partial area of the cube light box surface.
[0144] In this embodiment, the rendering of the streamer effect on a cube light box is specifically described, taking the area to be rendered as the entire surface of a cube model, the first and second points as two different vertices of the cube model, and the first characteristic line as a diagonal line of the cube model as an example. Figures 4 to 6 are schematic diagrams of rendering the streamer effect on a cube light box provided in this embodiment. The cube model 40 is a three-dimensional model of the cube light box. The streamer effect rendering process may include the following steps S410 to S450:
[0145] In step S410 , a first point and a second point are determined on the surface of the cube model 40 , and a model coordinate system is established.
[0146] As shown in FIG4 , vertex A of the cube model 40 is selected as the first point, and vertex B is selected as the second point. Then, the first characteristic line AB between the first point A and the second point B is the diagonal line of the cube model 40 .
[0147] The model coordinate system is established with the first point A as the origin. Since the first point A and the second point B are not on the same plane of the surface of the cube model 40, a three-dimensional coordinate system (X, Y, Z) as shown in FIG. 4 is established.
[0148] In step S420 , each pixel point on the surface of the cube model 40 is used as a location to be rendered, and parameters related to each location to be rendered on the surface of the cube model 40 and the first feature line AB are calculated.
[0149] As shown in FIG5 , any point D on the surface of the cube model 40 is used as a location to be rendered to calculate relevant parameters. The calculation steps are as follows:
[0150] Step S421 , obtaining the position information of the point D to be rendered and the position information of the second point B.
[0151] Assuming that the side length of the cube model 40 is a, the position information of the second point B and the point to be rendered D is obtained according to the positions of the second point B and the point to be rendered D in the model coordinate system. The position information of the second point B is (a, a, a), and the position information of the point to be rendered D is (x, y, z).
[0152] Step S422 : calculating original correlation parameters between the point D to be rendered and the first feature line AB according to the position information of the point D to be rendered and the position information of the second point B.
[0153] Based on the position information of the site D to be rendered and the position information of the second site B, the length of the first characteristic line AB between the first site A and the second site B, the length of the second characteristic line AD between the first site A and the site D to be rendered, and the angle between the first characteristic line AB and the second characteristic line AD can be calculated.
[0154] Furthermore, dot product processing is performed on the first feature line AB and the second feature line AD, and the dot product result is used as the original correlation parameter between the to-be-rendered point D and the first feature line AB. The calculation formula is as follows:
[0155] Wherein, L represents the original correlation parameter between the point to be rendered D and the first feature line AB, represents the first characteristic line AB, represents the second characteristic line AD, represents the modulus of the first characteristic line AB, represents the module length of the second characteristic line AD, and θ represents the angle between the first characteristic line AB and the second characteristic line AD.
[0156] Step S423 : Mapping the original related parameters corresponding to the to-be-rendered location D to a value range of 0-1 to obtain the related parameters corresponding to the to-be-rendered location D.
[0157] As shown in Figure 5 , when the location to be rendered is point A on the surface of the cube model 40, the original correlation parameter is minimum because the modulus of the characteristic line between the location to be rendered and the first point A is 0. When the location to be rendered is point B on the surface of the cube model 40, the angle between the second characteristic line and the first characteristic line AB between the location to be rendered and the first point A is 0 and the modulus is the longest, so the original correlation parameter is maximum. If the side length of the cube model 40 is 1, then the minimum original correlation parameter is 0, and the maximum original correlation parameter is 3.
[0158] According to the maximum original correlation parameter and the minimum original correlation parameter, the original correlation parameter corresponding to the to-be-rendered site D is mapped to a value range of 0-1, and the mapped value is used as the correlation parameter corresponding to the to-be-rendered site D. The calculation formula is as follows:
[0159] Among them, P represents the related parameters of the point D to be rendered and the first feature line AB, L represents the original related parameters of the point D to be rendered and the first feature line AB, and L min represents the minimum original correlation parameter, L max represents the maximum raw correlation parameter.
[0160] According to the above steps S421 to S423 , the parameters related to each to-be-rendered point on the surface of the cube model 40 and the first feature line AB are obtained.
[0161] Step S430 , calculating the color information of each to-be-rendered point on the surface of the cube model 40 at the nth rendering moment.
[0162] As shown in FIG5 , any point D on the surface of the cube model 40 is still used as a point to be rendered to calculate color information. The calculation steps are as follows:
[0163] Step S431 : Correlate the relevant parameters corresponding to the location D to be rendered with the time value corresponding to the nth rendering moment to obtain a second parameter corresponding to the location D to be rendered.
[0164] Specifically, the relevant parameters corresponding to the location D to be rendered and the time value corresponding to the nth rendering moment are summed, and the sum result is used as the second parameter corresponding to the location D to be rendered.
[0165] Step S432: Obtain the first parameter corresponding to the to-be-rendered location D according to the second parameter.
[0166] Specifically, the frac function is used to take the fractional part of the second parameter as the first parameter. The formula is as follows: frac(P+T)
[0167] Wherein, P represents the relevant parameters corresponding to the position D to be rendered, and T represents the time value corresponding to the nth rendering moment.
[0168] Step S433 , calculating the color information of the to-be-rendered point D at the nth rendering moment according to the first parameter corresponding to the to-be-rendered point D, the first color information corresponding to the first preset color, and the second color information corresponding to the second preset color.
[0169] Specifically, the Lerp interpolation function is used with the first parameter as the interpolation value, and the first color information and the second color information as the endpoint values to calculate the color information of the location D to be rendered. The calculation formula is as follows: FinalColor=Lerp(Color1,Color2,frac(P+T))
[0170] Among them, FinalColor represents the color information corresponding to the location D to be rendered, Color1 represents the first color information corresponding to the first preset color, Color2 represents the second color information corresponding to the second preset color, frac(P+T) represents the first parameter corresponding to the location D to be rendered, P represents the relevant parameters corresponding to the location D to be rendered, and T represents the time value corresponding to the nth rendering moment.
[0171] According to the above steps S431 to S433 , the color information of each to-be-rendered point on the surface of the cube model 40 at the nth rendering moment is obtained.
[0172] Step S440 , performing color rendering on each to-be-rendered point on the surface of the cube model 40 according to the color information of each to-be-rendered point on the surface of the cube model 40 at the nth rendering moment, to obtain the light effect of the cube model 40 at the nth rendering moment.
[0173] As shown in FIG6 , at the nth rendering moment, color rendering is performed on each pixel point on the surface of the cube model 40 , and a streamer effect as shown in FIG6 can be obtained.
[0174] In step S450 , the color information of each pixel on the surface of the cube model 40 is calculated in real time as time changes, and then real-time color rendering is performed, so that a multi-axial dynamic light effect can be presented on the cube light box.
[0175] The second embodiment described above uses a cube light box as an example to provide an optional method for rendering a streamer effect. It should be noted that the streamer effect rendering method provided in the first embodiment of the present disclosure can be applied not only to cube models, but also to other models such as cylindrical models, spherical models, and triangular models. The rendering method is consistent with the methods in the first and second embodiments of the present disclosure, differing only in the calculation of the geometric spatial relationship, which will not be further described here.
[0176] A third embodiment of the present disclosure provides a device for rendering a streamer effect. FIG7 is a schematic structural diagram of the device for rendering a streamer effect provided by this embodiment.
[0177] As shown in FIG7 , the apparatus for rendering the streamer effect provided by this embodiment includes: a position determination unit 710 , a position information determination unit 720 , a related parameter calculation unit 730 , and a color information calculation unit 740 .
[0178] The site determination unit 710 is used to determine a first site and a second site on a to-be-rendered area of the to-be-rendered model, wherein the to-be-rendered area is at least a portion of the surface of the model to be rendered, and the first site and the second site are different sites within the to-be-rendered area.
[0179] The position information determining unit 720 is used to determine the position information of the to-be-rendered point in the model coordinate system, wherein the to-be-rendered point is any point on the to-be-rendered area, and the model coordinate system is a coordinate system with the first point as the origin.
[0180] The related parameter calculation unit 730 is used to calculate related parameters between the site to be rendered and the first feature line according to the position information of the site to be rendered in the model coordinate system. The first feature line is a connecting line between the first point and the second point.
[0181] Optionally, according to the position information of the to-be-rendered location in the model coordinate system, the relevant parameters of the to-be-rendered location and the first characteristic line are calculated, including:
[0182] Based on the position information of the to-be-rendered point in the model coordinate system and the first position information of the second point in the model coordinate system, the original correlation parameters between the to-be-rendered point and the first feature line are calculated. The original correlation parameters are mapped to a value range of 0-1 to obtain the correlation parameters. The original correlation parameters are processed by normalization, which improves the calculation convenience and accuracy of the calculation results.
[0183] Optionally, calculating original correlation parameters between the site to be rendered and the first feature line according to the position information of the site to be rendered in the model coordinate system and the first position information of the second site in the model coordinate system includes:
[0184] According to the first position information of the second point in the model coordinate system, the first feature information of the first feature line is determined; according to the position information of the point to be rendered in the model coordinate system, the second feature information of the second feature line between the first point and the point to be rendered is determined; according to the first feature information and the second feature information, the dot product of the first feature line and the second feature line is calculated, and the dot product is used as the original correlation parameter of the point to be rendered and the first feature line.
[0185] Optionally, map the original related parameters to a value range of 0-1 to obtain related parameters, including:
[0186] Taking the first point as the site to be rendered, the original correlation parameters between the first point and the first feature line are calculated as the first original correlation parameters; taking the second point as the site to be rendered, the original correlation parameters between the second point and the first feature line are calculated as the second original correlation parameters; according to the original correlation parameters corresponding to the site to be rendered, the first original correlation parameters, and the second original correlation parameters, the mapping value of the original correlation parameter corresponding to the site to be rendered within the value range of 0-1 is calculated, and the mapping value is used as the correlation parameter corresponding to the site to be rendered.
[0187] The color information calculation unit 740 is configured to calculate the color information of the to-be-rendered point at the nth rendering moment according to relevant parameters and a time value corresponding to the nth rendering moment, where n is a positive integer greater than or equal to 1.
[0188] Optionally, the color information of the location to be rendered at the nth rendering moment is calculated according to relevant parameters and the time value corresponding to the nth rendering moment, including:
[0189] Based on the relevant parameters and the time value corresponding to the nth rendering moment, the first parameter corresponding to the site to be rendered at the nth rendering moment is calculated; based on the first parameter, the first color information corresponding to the first preset color, and the second color information corresponding to the second preset color, the color information of the site to be rendered at the nth rendering moment is calculated. The color corresponding to each site on the area to be rendered is not static, but will change over time, giving the entire area to be rendered a visual experience of flowing light. Therefore, after obtaining the relevant parameters corresponding to the site to be rendered, it is necessary to associate the time information with it so that each site is rendered with different colors at different times, achieving a dynamic streaming light effect.
[0190] Optionally, calculating the first parameter corresponding to the to-be-rendered position at the nth rendering moment according to the relevant parameters and the time value corresponding to the nth rendering moment includes:
[0191] The relevant parameters are added to the time value to obtain the second parameter; the fractional portion of the second parameter is taken as the first parameter. Combining the time value that changes with the rendering time with the relevant parameters that do not change with the rendering time ensures that the rendered location is not only unique in geometric space but also fluid with the rendering time.
[0192] Optionally, calculating the color information of the to-be-rendered location at the nth rendering moment according to the first parameter, the first color information corresponding to the first preset color, and the second color information corresponding to the second preset color includes:
[0193] The first parameter is used as an interpolation value, and the first color information and the second color information are used as endpoint values, and the color information corresponding to the first parameter is obtained through an interpolation operation.
[0194] Optionally, the device further includes a rendering unit, which is configured to:
[0195] Obtain the color information of each location to be rendered on the area to be rendered at the nth rendering time; perform color rendering on the area to be rendered based on the color information corresponding to each location to be rendered, thereby obtaining a streamer effect for the model to be rendered at the nth rendering time. After obtaining the streamer effect for the model to be rendered at the nth rendering time, the color information of each location to be rendered is calculated in real time as time changes, thereby performing real-time color rendering to obtain a dynamic streamer effect on the model to be rendered. Because the streamer effect rendering method provided in this embodiment uses each location on the surface of the model to be rendered in the area to be rendered as an independent color rendering point for streamer effect rendering, the resulting streamer rendering effect is also multi-axial.
[0196] Optionally, the model to be rendered is a cube model, and the area to be rendered is at least a partial area on the surface of the cube model.
[0197] Optionally, the area to be rendered is the entire area on the model surface of the cube model.
[0198] Optionally, the first point and the second point are two different vertices of the cube model.
[0199] Optionally, the first characteristic line is a diagonal line of the cube model.
[0200] The device is based on the geometric spatial relationship between each point in the area to be rendered on the surface of the model to be rendered, and establishes the relationship between the position information and color information of each point in the area to be rendered that changes with time, thereby realizing a multi-axial dynamic streamer effect on the surface of the model. The rendering method of the streamer effect provided by the present disclosure uses the geometric spatial relationship of each point on the surface of the model as the basis for rendering the streamer effect. Therefore, there is no need to perform special processing on the model and the model UV, and there will be no break in the streamer effect. In addition, the rendering method of the streamer effect provided by the present disclosure uses each point on the surface of the model as an independent point to be rendered for color rendering, and calculates the color information of each continuous point on the surface of the model at each continuous rendering moment. Therefore, the obtained streamer effect is multi-axial and has a strong sense of dynamics. In summary, the rendering method of the streamer effect provided by the present disclosure solves the technical problems of the existing streamer effect rendering method, such as the single streamer effect, poor dynamic sense, the need for special processing of the model texture image, and the appearance of obvious breakage marks at the seams of the model surface.
[0201] A fourth embodiment of the present disclosure provides an electronic device. FIG8 is a schematic structural diagram of the electronic device provided by this embodiment.
[0202] As shown in FIG8 , the electronic device provided in this embodiment includes: a memory 810 and a processor 820;
[0203] Memory 810, used for storing computer instructions for executing a rendering method for a streamer effect;
[0204] The processor 820 is configured to execute computer instructions stored in the memory 810 to perform the following operations:
[0205] Determining a first point and a second point on a to-be-rendered area of the to-be-rendered model, wherein the to-be-rendered area is at least a portion of an area on a surface of the to-be-rendered model, and the first point and the second point are different points within the to-be-rendered area;
[0206] Determine the position information of the to-be-rendered point in the model coordinate system, wherein the to-be-rendered point is any point on the to-be-rendered area, and the model coordinate system is a coordinate system with the first point as the origin;
[0207] Calculate the relevant parameters of the site to be rendered and the first feature line according to the position information of the site to be rendered in the model coordinate system, where the first feature line is the connecting line between the first point and the second point;
[0208] The color information of the location to be rendered at the nth rendering moment is calculated according to the relevant parameters and the time value corresponding to the nth rendering moment, where n is a positive integer greater than or equal to 1.
[0209] This method is based on the geometric spatial relationship between each point in the area to be rendered on the surface of the model to be rendered, and establishes the relationship between the position information and color information of each point in the area to be rendered that changes with time, thereby realizing a multi-axial dynamic streamer effect on the surface of the model. The rendering method of the streamer effect provided by the present disclosure uses the geometric spatial relationship of each point on the surface of the model as the basis for rendering the streamer effect. Therefore, there is no need to perform special processing on the model and the model UV, and there will be no break in the streamer effect. In addition, the rendering method of the streamer effect provided by the present disclosure uses each point on the surface of the model as an independent point to be rendered for color rendering, and calculates the color information of each continuous point on the surface of the model at each continuous rendering moment. Therefore, the obtained streamer effect is multi-axial and has a strong sense of dynamics. In summary, the rendering method of the streamer effect provided by the present disclosure solves the technical problems of the existing streamer effect rendering method, such as the single streamer effect, poor dynamic sense, the need for special processing of the model texture image, and the appearance of obvious breakage marks at the seams of the model surface.
[0210] Optionally, perform the following operations:
[0211] Obtain the color information of each location to be rendered on the area to be rendered at the nth rendering time; perform color rendering on the area to be rendered based on the color information corresponding to each location to be rendered, thereby obtaining a streamer effect for the model to be rendered at the nth rendering time. After obtaining the streamer effect for the model to be rendered at the nth rendering time, the color information of each location to be rendered is calculated in real time as time changes, thereby performing real-time color rendering to obtain a dynamic streamer effect on the model to be rendered. Because the streamer effect rendering method provided in this embodiment uses each location on the surface of the model to be rendered in the area to be rendered as an independent color rendering point for streamer effect rendering, the resulting streamer rendering effect is also multi-axial.
[0212] Optionally, according to the position information of the to-be-rendered location in the model coordinate system, the relevant parameters of the to-be-rendered location and the first characteristic line are calculated, including:
[0213] Based on the position information of the to-be-rendered point in the model coordinate system and the first position information of the second point in the model coordinate system, the original correlation parameters between the to-be-rendered point and the first feature line are calculated. The original correlation parameters are mapped to a value range of 0-1 to obtain the correlation parameters. The original correlation parameters are processed by normalization, which improves the calculation convenience and accuracy of the calculation results.
[0214] Optionally, calculating original correlation parameters between the site to be rendered and the first feature line according to the position information of the site to be rendered in the model coordinate system and the first position information of the second site in the model coordinate system includes:
[0215] According to the first position information of the second point in the model coordinate system, the first feature information of the first feature line is determined; according to the position information of the point to be rendered in the model coordinate system, the second feature information of the second feature line between the first point and the point to be rendered is determined; according to the first feature information and the second feature information, the dot product of the first feature line and the second feature line is calculated, and the dot product is used as the original correlation parameter of the point to be rendered and the first feature line.
[0216] Optionally, map the original related parameters to a value range of 0-1 to obtain related parameters, including:
[0217] Taking the first point as the site to be rendered, the original correlation parameters between the first point and the first feature line are calculated as the first original correlation parameters; taking the second point as the site to be rendered, the original correlation parameters between the second point and the first feature line are calculated as the second original correlation parameters; according to the original correlation parameters corresponding to the site to be rendered, the first original correlation parameters, and the second original correlation parameters, the mapping value of the original correlation parameter corresponding to the site to be rendered within the value range of 0-1 is calculated, and the mapping value is used as the correlation parameter corresponding to the site to be rendered.
[0218] Optionally, the color information of the location to be rendered at the nth rendering moment is calculated according to relevant parameters and the time value corresponding to the nth rendering moment, including:
[0219] Based on the relevant parameters and the time value corresponding to the nth rendering moment, the first parameter corresponding to the site to be rendered at the nth rendering moment is calculated; based on the first parameter, the first color information corresponding to the first preset color, and the second color information corresponding to the second preset color, the color information of the site to be rendered at the nth rendering moment is calculated. The color corresponding to each site on the area to be rendered is not static, but will change over time, giving the entire area to be rendered a visual experience of flowing light. Therefore, after obtaining the relevant parameters corresponding to the site to be rendered, it is necessary to associate the time information with it so that each site is rendered with different colors at different times, achieving a dynamic streaming light effect.
[0220] Optionally, calculating the first parameter corresponding to the to-be-rendered position at the nth rendering moment according to the relevant parameters and the time value corresponding to the nth rendering moment includes:
[0221] The relevant parameters are added to the time value to obtain the second parameter; the fractional portion of the second parameter is taken as the first parameter. Combining the time value that changes with the rendering time with the relevant parameters that do not change with the rendering time ensures that the rendered location is not only unique in geometric space but also fluid with the rendering time.
[0222] Optionally, calculating the color information of the to-be-rendered location at the nth rendering moment according to the first parameter, the first color information corresponding to the first preset color, and the second color information corresponding to the second preset color includes:
[0223] The first parameter is used as an interpolation value, and the first color information and the second color information are used as endpoint values, and the color information corresponding to the first parameter is obtained through an interpolation operation.
[0224] Optionally, the model to be rendered is a cube model, and the area to be rendered is at least a partial area on the surface of the cube model.
[0225] Optionally, the area to be rendered is the entire area on the model surface of the cube model.
[0226] Optionally, the first point and the second point are two different vertices of the cube model.
[0227] Optionally, the first characteristic line is a diagonal line of the cube model.
[0228] The fifth embodiment of the present disclosure provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed by a processor, they are used to implement the methods of various embodiments of the present disclosure. For example:
[0229] Determining a first point and a second point on a to-be-rendered area of the to-be-rendered model, wherein the to-be-rendered area is at least a portion of an area on a surface of the to-be-rendered model, and the first point and the second point are different points within the to-be-rendered area;
[0230] Determine the position information of the to-be-rendered point in the model coordinate system, wherein the to-be-rendered point is any point on the to-be-rendered area, and the model coordinate system is a coordinate system with the first point as the origin;
[0231] Calculate the relevant parameters of the site to be rendered and the first feature line according to the position information of the site to be rendered in the model coordinate system, where the first feature line is the connecting line between the first point and the second point;
[0232] The color information of the location to be rendered at the nth rendering moment is calculated according to the relevant parameters and the time value corresponding to the nth rendering moment, where n is a positive integer greater than or equal to 1.
[0233] This method is based on the geometric spatial relationship between each point in the area to be rendered on the surface of the model to be rendered, and establishes the relationship between the position information and color information of each point in the area to be rendered that changes with time, thereby realizing a multi-axial dynamic streamer effect on the surface of the model. The rendering method of the streamer effect provided by the present disclosure uses the geometric spatial relationship of each point on the surface of the model as the basis for rendering the streamer effect. Therefore, there is no need to perform special processing on the model and the model UV, and there will be no break in the streamer effect. In addition, the rendering method of the streamer effect provided by the present disclosure uses each point on the surface of the model as an independent point to be rendered for color rendering, and calculates the color information of each continuous point on the surface of the model at each continuous rendering moment. Therefore, the obtained streamer effect is multi-axial and has a strong sense of dynamics. In summary, the rendering method of the streamer effect provided by the present disclosure solves the technical problems of the existing streamer effect rendering method, such as the single streamer effect, poor dynamic sense, the need for special processing of the model texture image, and the appearance of obvious breakage marks at the seams of the model surface.
[0234] Optionally, perform the following operations:
[0235] Obtain the color information of each location to be rendered on the area to be rendered at the nth rendering time; perform color rendering on the area to be rendered based on the color information corresponding to each location to be rendered, thereby obtaining a streamer effect for the model to be rendered at the nth rendering time. After obtaining the streamer effect for the model to be rendered at the nth rendering time, the color information of each location to be rendered is calculated in real time as time changes, thereby performing real-time color rendering to obtain a dynamic streamer effect on the model to be rendered. Because the streamer effect rendering method provided in this embodiment uses each location on the surface of the model to be rendered in the area to be rendered as an independent color rendering point for streamer effect rendering, the resulting streamer rendering effect is also multi-axial.
[0236] Optionally, according to the position information of the to-be-rendered location in the model coordinate system, the relevant parameters of the to-be-rendered location and the first characteristic line are calculated, including:
[0237] Based on the position information of the to-be-rendered point in the model coordinate system and the first position information of the second point in the model coordinate system, the original correlation parameters between the to-be-rendered point and the first feature line are calculated. The original correlation parameters are mapped to a value range of 0-1 to obtain the correlation parameters. The original correlation parameters are processed by normalization, which improves the calculation convenience and accuracy of the calculation results.
[0238] Optionally, calculating original correlation parameters between the site to be rendered and the first feature line according to the position information of the site to be rendered in the model coordinate system and the first position information of the second site in the model coordinate system includes:
[0239] According to the first position information of the second point in the model coordinate system, the first feature information of the first feature line is determined; according to the position information of the point to be rendered in the model coordinate system, the second feature information of the second feature line between the first point and the point to be rendered is determined; according to the first feature information and the second feature information, the dot product of the first feature line and the second feature line is calculated, and the dot product is used as the original correlation parameter of the point to be rendered and the first feature line.
[0240] Optionally, map the original related parameters to a value range of 0-1 to obtain related parameters, including:
[0241] Taking the first point as the site to be rendered, the original correlation parameters between the first point and the first feature line are calculated as the first original correlation parameters; taking the second point as the site to be rendered, the original correlation parameters between the second point and the first feature line are calculated as the second original correlation parameters; according to the original correlation parameters corresponding to the site to be rendered, the first original correlation parameters, and the second original correlation parameters, the mapping value of the original correlation parameter corresponding to the site to be rendered within the value range of 0-1 is calculated, and the mapping value is used as the correlation parameter corresponding to the site to be rendered.
[0242] Optionally, the color information of the location to be rendered at the nth rendering moment is calculated according to relevant parameters and the time value corresponding to the nth rendering moment, including:
[0243] Based on the relevant parameters and the time value corresponding to the nth rendering moment, the first parameter corresponding to the site to be rendered at the nth rendering moment is calculated; based on the first parameter, the first color information corresponding to the first preset color, and the second color information corresponding to the second preset color, the color information of the site to be rendered at the nth rendering moment is calculated. The color corresponding to each site on the area to be rendered is not static, but will change over time, giving the entire area to be rendered a visual experience of flowing light. Therefore, after obtaining the relevant parameters corresponding to the site to be rendered, it is necessary to associate the time information with it so that each site is rendered with different colors at different times, achieving a dynamic streaming light effect.
[0244] Optionally, calculating the first parameter corresponding to the to-be-rendered position at the nth rendering moment according to the relevant parameters and the time value corresponding to the nth rendering moment includes:
[0245] The relevant parameters are added to the time value to obtain the second parameter; the fractional portion of the second parameter is taken as the first parameter. Combining the time value that changes with the rendering time with the relevant parameters that do not change with the rendering time ensures that the rendered location is not only unique in geometric space but also fluid with the rendering time.
[0246] Optionally, calculating the color information of the to-be-rendered location at the nth rendering moment according to the first parameter, the first color information corresponding to the first preset color, and the second color information corresponding to the second preset color includes:
[0247] The first parameter is used as an interpolation value, and the first color information and the second color information are used as endpoint values, and the color information corresponding to the first parameter is obtained through an interpolation operation.
[0248] Optionally, the model to be rendered is a cube model, and the area to be rendered is at least a partial area on the surface of the cube model.
[0249] Optionally, the area to be rendered is the entire area on the model surface of the cube model.
[0250] Optionally, the first point and the second point are two different vertices of the cube model.
[0251] Optionally, the first characteristic line is a diagonal line of the cube model.
[0252] It should be noted that the relational terms "first," "second," and the like in this document are used solely to distinguish one entity or operation from another, and do not require or imply any actual relationship or order between these entities or operations. Furthermore, the terms "include," "have," "include," and "includes" and similar forms are synonymous in meaning, and the ending of any one or more items following any of the above terms is open-ended, and none of the above terms indicates that the list of one or more items is exhaustive or limited to the listed one or more items.
[0253] As used herein, unless expressly stated otherwise, the term "or" includes all possible combinations, except those that are infeasible. For example, if a database is expressed as possibly including A or B, then unless otherwise specified or infeasible, it may include databases A, B, or A and B. As a second example, if a database is expressed as possibly including A, B, or C, then unless otherwise specified or infeasible, it may include databases A, B, or C, or A and B, or A and C, or B and C, or A, B, and C.
[0254] It is worth noting that the above embodiments can be implemented by hardware or software (program code), or a combination of hardware and software. If implemented by software, it can be stored in the above-mentioned computer-readable medium. When the software is executed by a processor, it can execute the above-mentioned disclosed method. The computing unit and other functional units described in this disclosure can be implemented by hardware or software, or a combination of hardware and software. Those of ordinary skill in the art will also understand that the above-mentioned multiple modules / units can be combined into one module / unit, and each of the above-mentioned modules / units can be further divided into multiple sub-modules / sub-units.
[0255] In the above detailed description, the embodiments have been described with reference to many specific details, which may vary from implementation to implementation. Certain adaptations and modifications may be made to the embodiments. For those skilled in the art, other embodiments will be readily apparent from the specific embodiments of the present disclosure. This description and examples are for illustrative purposes only, and the true scope and nature of the present disclosure are described in the claims. The order of steps shown in the figures is also for illustrative purposes only and is not intended to be limiting to any particular steps or order. Therefore, those skilled in the art will appreciate that these steps may be performed in different orders when implementing the same method.
[0256] In the figures and detailed description of the present disclosure, exemplary embodiments are disclosed. However, many variations and modifications may be made to these embodiments. Accordingly, although specific terms are used, these terms are used in a general and descriptive sense only and not for purposes of limitation.
Claims
1. A method for rendering a streamer effect, the method comprising: Determine a first point and a second point on a to-be-rendered area of the to-be-rendered model, wherein the to-be-rendered area is at least a partial area on a model surface of the to-be-rendered model, and the first point and the second point are different points within the to-be-rendered area; Determine position information of a to-be-rendered site in a model coordinate system, wherein the to-be-rendered site is any site on the to-be-rendered area, and the model coordinate system is a coordinate system with the first site as the origin; Calculating, according to the position information of the to-be-rendered site in the model coordinate system, relevant parameters of the to-be-rendered site and a first feature line, where the first feature line is a connecting line between the first site and the second site; According to the relevant parameters and the time value corresponding to the nth rendering moment, the color information of the to-be-rendered point at the nth rendering moment is calculated, where n is a positive integer greater than or equal to 1.
2. The method according to claim 1, wherein: The method further comprises: Obtaining color information of each to-be-rendered point on the to-be-rendered area at the nth rendering moment; According to the color information corresponding to each of the to-be-rendered positions, color rendering is performed on the to-be-rendered area to obtain a streamer effect of the to-be-rendered model at the nth rendering moment.
3. The method according to claim 1, wherein: The calculating, according to the position information of the to-be-rendered site in the model coordinate system, the relevant parameters of the to-be-rendered site and the first feature line includes: Calculating original correlation parameters of the site to be rendered and the first feature line according to the position information of the site to be rendered in the model coordinate system and the first position information of the second site in the model coordinate system; The original related parameters are mapped to a value range of 0-1 to obtain the related parameters.
4. The method according to claim 3, wherein: The calculating original correlation parameters between the site to be rendered and the first feature line according to the position information of the site to be rendered in the model coordinate system and the first position information of the second site in the model coordinate system includes: Determine first feature information of the first feature line according to the first position information of the second point in the model coordinate system; Determine second feature information of a second feature line between the first site and the site to be rendered according to the position information of the site to be rendered in the model coordinate system; The dot product of the first feature line and the second feature line is calculated according to the first feature information and the second feature information, and the dot product is used as an original correlation parameter between the to-be-rendered position and the first feature line.
5. The method according to claim 3, wherein: Mapping the original related parameters to a value range of 0-1 to obtain the related parameters includes: Taking the first position as the position to be rendered, calculating original correlation parameters between the first position and the first feature line as first original correlation parameters; Taking the second position as the position to be rendered, calculating original correlation parameters between the second position and the first feature line as second original correlation parameters; According to the original relevant parameters corresponding to the point to be rendered, the first original relevant parameters, and the second original relevant parameters, a mapping value of the original relevant parameters corresponding to the point to be rendered within a value range of 0-1 is calculated, and the mapping value is used as the relevant parameters corresponding to the point to be rendered.
6. The method according to claim 1, wherein: The calculating, according to the relevant parameters and the time value corresponding to the nth rendering moment, the color information of the to-be-rendered location at the nth rendering moment comprises: Calculate, according to the relevant parameters and the time value corresponding to the nth rendering moment, a first parameter corresponding to the to-be-rendered location at the nth rendering moment; The color information of the to-be-rendered location at the n-th rendering moment is calculated according to the first parameter, the first color information corresponding to the first preset color, and the second color information corresponding to the second preset color.
7. The method according to claim 6, wherein: The calculating, according to the relevant parameters and the time value corresponding to the nth rendering moment, a first parameter corresponding to the to-be-rendered position at the nth rendering moment includes: Adding the relevant parameter to the time value to obtain a second parameter; The decimal part of the second parameter is taken as the first parameter.
8. The method according to claim 6, wherein: The calculating the color information of the to-be-rendered position at the nth rendering moment according to the first parameter, the first color information corresponding to the first preset color, and the second color information corresponding to the second preset color includes: The color information corresponding to the first parameter is obtained by interpolation operation using the first parameter as an interpolation value and the first color information and the second color information as endpoint values.
9. The method according to any one of claims 1 to 8, wherein: The model to be rendered is at least one of the following models: a cube model, a rectangular parallelepiped model, a cylinder model, a spherical model, and an irregular shape model.
10. The method according to claim 9, wherein: The model to be rendered is a cube model, and the area to be rendered is at least a partial area on a model surface of the cube model.
11. The method according to claim 10, wherein: The area to be rendered is the entire area on the model surface of the cube model.
12. The method according to claim 11, wherein: The first point and the second point are two different vertices of the cube model.
13. The method according to claim 12, wherein: The first characteristic line is a diagonal line of the cube model.
14. A device for rendering a streamer effect, the device comprising: A site determination unit, a position information determination unit, a related parameter calculation unit, and a color information calculation unit; The site determination unit is used to determine a first site and a second site on a to-be-rendered area of the to-be-rendered model, wherein the to-be-rendered area is at least a partial area on a model surface of the to-be-rendered model, and the first site and the second site are different sites within the to-be-rendered area; The position information determining unit is used to determine the position information of the to-be-rendered site in the model coordinate system, wherein the to-be-rendered site is any site on the to-be-rendered area, and the model coordinate system is a coordinate system with the first site as the origin; The relevant parameter calculation unit is used to calculate the relevant parameters of the site to be rendered and a first feature line according to the position information of the site to be rendered in the model coordinate system, where the first feature line is a connecting line between the first site and the second site; The color information calculation unit is used to calculate the color information of the to-be-rendered location at the nth rendering moment according to the relevant parameters and a time value corresponding to the nth rendering moment, wherein n is a positive integer greater than or equal to 1.
15. An electronic device, comprising: Memory, processor; The memory is used to store one or more computer instructions; The processor is used to execute the one or more computer instructions to implement the method according to any one of claims 1-13.
16. A computer-readable storage medium having one or more computer instructions stored thereon, wherein when the instructions are executed by a processor, the method according to any one of claims 1 to 13 is executed.
Citation Information
Patent Citations
Method and device for streamer rendering
CN109224448A
Text special effect rendering method, device, electronic equipment and storage medium
CN112528596A
Streaming effect rendering method and device and electronic equipment
CN116740259A
Methods and Apparatus for Simulation Of Fluid Motion Using Procedural Shape Growth
US20130132053A1
