A model rendering method and device, electronic equipment and storage medium

By dividing the fluid model into multiple parts surrounded by a 3D model, and utilizing fluid density control information and ray stepping analysis, the high performance consumption and low rendering efficiency of the fluid model in non-uniform scenes are solved, achieving a more efficient rendering effect.

CN119991915BActive Publication Date: 2025-11-25NETEASE (HANGZHOU) NETWORK CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510052256.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-13
Publication Date
2025-11-25
Estimated Expiration
2045-01-13

AI Technical Summary

Technical Problem

Existing fluid models suffer from high performance consumption and low rendering efficiency in scenarios with uneven fluid distribution, which negatively impacts user experience.

Method used

The fluid model is divided into multiple fluid model parts surrounded by a 3D model. The fluid effect is fitted to the target fluid model part to be rendered by dividing the parts into blocks. The optical depth information is determined by using fluid density control information and light stepping analysis for rendering.

Benefits of technology

It effectively reduces performance consumption, improves rendering efficiency, and enhances user experience in scenarios with uneven fluid distribution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119991915B_ABST
    Figure CN119991915B_ABST
Patent Text Reader

Abstract

The application discloses a model rendering method and device, electronic equipment and storage medium. The method comprises the following steps: acquiring a fluid model comprising a plurality of fluid model parts surrounded by solid models and fluid density control information of the fluid model; determining a target fluid model part to be rendered on the fluid model according to a fluid model part through which a view ray of a virtual camera passes on the fluid model; setting a bounding box for a target solid model corresponding to the target fluid model part, and determining a ray path of the view ray in the bounding box; performing ray stepping analysis according to the fluid density control information and the ray path, determining optical depth information, and rendering the target fluid model part. Based on this, the fluid model is divided into a plurality of fluid model parts surrounded by solid models, so that the fluid model rendering mode is suitable for various fluid distribution scenes, and in the scene where the fluid distribution is uneven, the performance consumption is reduced, the rendering efficiency is improved, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of games, in particular to a model rendering method and device, electronic equipment and a storage medium. BACKGROUND

[0002] The existing implementation of the fluid model mainly determines the fluid density based on the height at which the fluid is located, or performs ray marching analysis on the area where the fluid is located to determine the fluid density. However, determining the fluid density based on the height at which the fluid is located is not suitable for a scenario in which the fluid is not uniformly distributed. Other existing implementations of the fluid model have problems such as high performance consumption and low rendering efficiency in a scenario in which the fluid is not uniformly distributed, which affects the user experience. SUMMARY

[0003] The embodiments of the present application provide a model rendering method and device, electronic equipment and a storage medium, which can divide a fluid model into a plurality of fluid model parts surrounded by solid models, and fit the fluid effect of a target fluid model part to be rendered in a block-by-block manner, so as to be applicable to various fluid distribution scenarios, effectively reduce performance consumption, improve rendering efficiency and enhance user experience in a scenario in which the fluid is not uniformly distributed.

[0004] In a first aspect, the embodiments of the present application provide a model rendering method, which comprises:

[0005] obtaining a fluid model and fluid density control information of the fluid model, wherein the fluid model comprises a plurality of fluid model parts, each fluid model part is provided with a solid model surrounding the fluid model part, and the fluid density control information is control information used for implementing fitting of the fluid model;

[0006] determining a target fluid model part to be rendered on the fluid model according to a fluid model part through which a view ray of a virtual camera in a virtual space passes on the fluid model;

[0007] setting a bounding box for a target solid model corresponding to the target fluid model part;

[0008] determining a ray path of the view ray in the bounding box;

[0009] performing ray marching analysis according to the fluid density control information and the ray path to determine optical depth information of the target fluid model part;

[0010] rendering the target fluid model part based on the optical depth information.

[0011] Further, the determination of the ray path of the view ray in the bounding box comprises:

[0012] determine position information of an incident point and position information of an exit point of the view ray on the bounding box;

[0013] determine a ray path of the view ray in the bounding box based on the position information of the incident point and the position information of the exit point.

[0014] Further, the determining the position information of the incident point and the position information of the exit point of the view ray on the bounding box comprises:

[0015] determine first position information of the bounding box in the virtual space;

[0016] determine the position information of the incident point and the position information of the exit point of the view ray on the bounding box based on the first position information of the bounding box and second position information of the virtual camera in the virtual space.

[0017] Further, the determining the first position information of the bounding box in the virtual space comprises:

[0018] obtain third position information of a reference point on the target solid model in the virtual space and size information of a bounding box surrounding the target solid model;

[0019] determine the first position information of the bounding box in the virtual space based on the third position information and the size information.

[0020] Further, the fluid density control information comprises a mapping relationship between position information in a virtual space and fluid density; and the determining the optical depth information of the target fluid model part based on the fluid density control information and the ray path comprises:

[0021] sample the ray path according to a step distance to obtain a plurality of sampling segments and fourth position information of the sampling segments;

[0022] determine fluid density corresponding to each of the sampling segments based on the fourth position information and the mapping relationship between position information in a virtual space and fluid density.

[0023] obtain an optical depth coefficient of the target fluid model part;

[0024] perform integral calculation based on the fluid density of each of the sampling segments and the optical depth coefficient to determine the optical depth information of the target fluid model part.

[0025] Further, the number of the target fluid model parts is plural, and the fluid model is configured with a target storage space, the method comprises:

[0026] determining a first target fluid model part through which the view ray passes as a target fluid model part for current analysis;

[0027] based on the view ray direction and the light source direction, determining an optical depth coefficient of the target fluid model part for current analysis, and storing the optical depth coefficient in the target storage space;

[0028] determining a target fluid model part through which the view ray passes after the target fluid model part for current analysis as a new target fluid model part for current analysis;

[0029] based on the view ray direction, the light source direction, position indication information of the new target fluid model part for current analysis, and the optical depth coefficient stored in the target storage space, determining an optical depth coefficient of the new target fluid model part for current analysis, and storing the optical depth coefficient in the target storage space;

[0030] returning to execute the step of determining a target fluid model part through which the view ray passes after the target fluid model part for current analysis as a new target fluid model part for current analysis until the optical depth coefficients of all target fluid model parts are determined.

[0031] Further, before determining the target fluid model part to be rendered on the fluid model according to the fluid model part through which the view ray of the virtual camera in the virtual space passes on the fluid model, the method comprises:

[0032] acquiring a hit position of a pixel shader on a solid model of the fluid model part;

[0033] based on the hit position and second position information of the virtual camera, determining a view ray direction of the virtual camera.

[0034] Further, before determining the target fluid model part to be rendered on the fluid model according to the fluid model part through which the view ray of the virtual camera in the virtual space passes on the fluid model, the method further comprises:

[0035] acquiring size information of the fluid model;

[0036] acquiring solid model specification information for dividing the fluid model;

[0037] According to the size information and the volume model specification information, the fluid model is divided into a plurality of fluid model parts, and a volume model surrounding each fluid model part is set for each fluid model part.

[0038] Further, the shape of the volume model comprises a convex body, wherein the convex body comprises at least one or more of a convex polyhedron, a sphere, and a cylinder.

[0039] In a second aspect, an embodiment of the present application provides a model rendering device, comprising:

[0040] A fluid model acquisition module is configured to acquire a fluid model and fluid density control information of the fluid model, wherein the fluid model comprises a plurality of fluid model parts, each fluid model part is provided with a volume model surrounding the fluid model part, and the fluid density control information is control information used to realize fitting of the fluid model.

[0041] A target fluid model part determination module is configured to determine a target fluid model part to be rendered on the fluid model according to a fluid model part through which a view ray of a virtual camera in a virtual space passes on the fluid model.

[0042] A bounding box setting module is configured to set a bounding box for a target volume model corresponding to the target fluid model part.

[0043] A ray path determination module is configured to determine a ray path of the view ray in the bounding box.

[0044] A ray step analysis module is configured to perform ray step analysis according to the fluid density control information and the ray path, and determine optical depth information of the target fluid model part.

[0045] A rendering module is configured to render the target fluid model part based on the optical depth information.

[0046] In a third aspect, an embodiment of the present application further provides an electronic device comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes steps of any model rendering method.

[0047] In a fourth aspect, an embodiment of the present application further provides a computer readable storage medium comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes steps of any model rendering method.

[0048] In a fifth aspect, an embodiment of the present application further provides a computer program product, comprising a computer program stored in a computer readable storage medium; when a processor of an electronic device reads the computer program from the computer readable storage medium, the processor executes the computer program, so that the electronic device executes steps of any one of the model rendering methods provided by the embodiments of the present application.

[0049] By adopting the scheme provided in the embodiments of the present application, the fluid model and the fluid density control information of the fluid model are acquired, the fluid model comprises a plurality of fluid model parts, each fluid model part is provided with a solid model surrounding the fluid model part, and the fluid density control information is control information used for realizing fitting of the fluid model; a target fluid model part to be rendered on the fluid model is determined according to a fluid model part through which a view ray of a virtual camera in a virtual space passes on the fluid model; a bounding box is set for a target solid model corresponding to the target fluid model part; a ray path of the view ray in the bounding box is determined; optical depth information of the target fluid model part is determined according to the fluid density control information and the ray path; and the target fluid model part is rendered based on the optical depth information. Based on this, by dividing the fluid model into a plurality of fluid model parts surrounded by solid models, the fluid effect fitting of the target fluid model part to be rendered is performed in a block manner, which can be applicable to various fluid distribution scenes, can effectively reduce performance consumption, improve rendering efficiency and enhance user experience in a scene where fluid distribution is uneven. BRIEF DESCRIPTION OF DRAWINGS

[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed in the embodiment description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can also be obtained by those skilled in the art without creative labor.

[0051] Figure 1 is a schematic diagram of an implementation environment scene of the model rendering method provided in the embodiments of the present application;

[0052] Figure 2 is a schematic diagram of an embodiment flow of the model rendering method provided in the embodiments of the present application;

[0053] Figure 3a is a schematic diagram of a solid model for a fluid model part provided in the embodiments of the present application;

[0054] Figure 3b is another schematic diagram of a solid model for a fluid model part provided in the embodiments of the present application;

[0055] Figure 3c is another schematic diagram of a three-dimensional model for a fluid model part provided in an embodiment of the present application;

[0056] Figure 3d is another schematic diagram of a three-dimensional model for a fluid model part provided in an embodiment of the present application;

[0057] Figure 3e is an effect schematic diagram of fluid fitting for a target fluid model part provided in an embodiment of the present application;

[0058] Figure 3f is an effect schematic diagram of fluid fitting for a plurality of target fluid model parts provided in an embodiment of the present application;

[0059] Figure 3g is another effect schematic diagram of fluid fitting for a plurality of target fluid model parts provided in an embodiment of the present application;

[0060] Figure 4 is a structural schematic diagram of a model rendering device provided in an embodiment of the present application;

[0061] Figure 5 is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0062] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application. Meanwhile, in the description of the embodiments of the present application, the terms "first", "second", etc. are only used for differentiation and description, and cannot be understood as indicating or implying relative importance. Therefore, the features with "first" and "second" can explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise specifically limited.

[0063] The embodiments of the present application provide a model rendering method, device, electronic device and computer readable storage medium. The model rendering device can be integrated in an electronic device, which can be a server, a terminal or other device.

[0064] The server can be a standalone physical server, a server cluster composed of multiple physical servers, or a distributed system, and can also be a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN), and basic cloud computing services such as big data and artificial intelligence platforms. The terminal can include but is not limited to a mobile phone, a computer, a smart voice interaction device, a smart home appliance, a vehicle-mounted terminal, an aircraft, and the like. The terminal and the server can be connected directly or indirectly through wired or wireless communication, which is not limited in the present application.

[0065] Please refer to Figure 1 For example, the model rendering device is integrated in an electronic device, Figure 1 The implementation scenario of the model rendering method provided by the embodiments of the present application is shown in the figure, wherein the electronic device can be a terminal device, by obtaining a fluid model and fluid density control information of the fluid model, wherein the fluid model includes a plurality of fluid model parts, each fluid model part is provided with a solid model surrounding the fluid model part, and the fluid density control information is control information for realizing fitting of the fluid model; determining a target fluid model part to be rendered on the fluid model according to a fluid model part through which a view ray of a virtual camera in a virtual space passes on the fluid model; setting a bounding box for a target solid model corresponding to the target fluid model part; determining a ray path of the view ray in the bounding box; performing ray stepping analysis according to the fluid density control information and the ray path to determine optical depth information of the target fluid model part; and rendering the target fluid model part based on the optical depth information. Based on this, by dividing the fluid model into a plurality of fluid model parts surrounded by solid models, the fluid effect fitting of the fluid model part to be rendered is performed in blocks, which can be applied to various fluid distribution scenarios, and in the scenario where the fluid distribution is uneven, the performance consumption can be effectively reduced, the rendering efficiency can be improved, and the user experience can be improved.

[0066] It should be noted that Figure 1 The implementation environment scenario of the model rendering method shown in the figure is only an example, and the implementation environment scenario of the model rendering method described in the embodiments of the present application is used to more clearly illustrate the technical solutions of the embodiments of the present application, and does not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art can know that, with the evolution of data processing and the emergence of new business scenarios, the technical solutions provided by the present application are also applicable to similar technical problems.

[0067] The scheme provided by the embodiments of the present application is described in detail through the following embodiments. It should be noted that the order of the following embodiments is not limited as the preferred order of the embodiments.

[0068] The embodiment will be described from the perspective of a model rendering device, which can be integrated in an electronic device, which can be a terminal and / or a server, without limitation.

[0069] Please refer to Figure 2 , Figure 2 is a model rendering method provided by the embodiment of the application, and the specific process of the model rendering method can be steps 101-106, wherein:

[0070] Step 101, acquiring a fluid model and fluid density control information of the fluid model, wherein the fluid model includes a plurality of fluid model parts, each fluid model part is provided with a solid model surrounding the fluid model part, and the fluid density control information is control information for realizing fitting of the fluid model.

[0071] The fluid model refers to a model of a virtual object with fluid properties in a game picture in a virtual space. The virtual object can be cloud, fog, etc., which can be adjusted according to actual conditions. For example, the fluid model refers to a fog model in a virtual space. For example, the fluid model refers to a cloud model in a virtual space. The subsequent embodiments are explained and described by taking the fog model as an example.

[0072] The fluid density control information refers to control information for realizing fitting of the fluid model.

[0073] Specifically, the fluid density control information includes information indicating the fluid density distribution inside the fluid model, and the specific content can be adjusted according to the specific content of the fluid model and actual conditions, without limitation of the embodiment of the application.

[0074] The fluid density control information can be obtained in various ways, which can be adjusted according to actual conditions, without limitation of the embodiment of the application.

[0075] For example, taking the fluid model as the fog model, in some embodiments, the fluid density control information can represent the shape, concentration and distribution of the fog by using a 3D texture. A 3D texture refers to a structure that defines data in three-dimensional space and can be used to store the density information of the fog. Each voxel (volume pixel) contains a density value representing the fog concentration at that position. By storing density values in a 3D texture, the distribution of the fog in space can be accurately controlled. During rendering, the 3D texture is used to look up the density value to determine the light scattering and absorption effect when the light ray passes through the fog. The fluid density control information can also be represented by using mathematical modeling algorithms. The mathematical modeling algorithms include but are not limited to directed distance field, particle system, etc. The directed distance field is a data structure in which each point stores the directed distance to the nearest surface. A positive value indicates that it is outside the surface, and a negative value indicates that it is inside the surface. The directed distance field can be used to define the boundary and shape of the fog, and the distance value can be used to control the concentration gradient of the fog. During rendering, the directed distance field is used to determine the interaction between the light ray and the fog, and to calculate the path length and scattering effect of the light ray in the fog. In order to control the artistic effect of the game, preferably, the fluid density control information can be implemented by using a 3D texture to record the fluid density distribution information inside the fluid model.

[0076] It should be noted that the embodiments of the present application perform fitting processing on the fluid model by tile fitting.

[0077] The tile fitting refers to dividing a large area into multiple small areas, usually regular shapes such as rectangles, triangles, hexagons, etc., for processing, storage or rendering. Each small area is called a "tile".

[0078] Therefore, before rendering the fluid model, the fluid model (i.e. a large area) needs to be divided into multiple fluid model parts, which are used to indicate part of the fluid model.

[0079] The division criteria and the division process can be adjusted according to actual conditions, and the embodiments of the present application do not limit them. The fluid model parts obtained after division can be fluid model parts of the same size or fluid model parts of different sizes.

[0080] In some embodiments, the fluid model can be divided by artificial division. Specifically, by combining the shape information and size information of the fluid model, the fluid model is divided into multiple fluid model parts, and the shape information and size information of the solid model surrounding each fluid model part are determined.

[0081] For example, by determining the approximate shape of the fluid model, and the size information of the fluid model. According to the approximate shape, selecting a proper tile shape, combining the size information of the fluid model and the tile shape, determining a plurality of tiles of the same or different shapes, and the size of each tile, dividing the fluid model according to the selected tile shape and the shape and size of each tile, to obtain a fluid model part corresponding to each tile, and the shape and size of the fluid model part correspond to the tile.

[0082] For example, assuming that the shape of the fluid model is similar to a five-pointed star. It can be determined that the fluid model is divided into 5 triangular pyramids indicating the corners, and 1 pentagonal pyramid indicating the pentagon in the middle of the five-pointed star, that is, the fluid model is divided into 6 fluid model parts. It can also be determined that the fluid model is divided into 4 triangular pyramids indicating the corners, and 1 large triangular pyramid indicating the pentagon in the middle of the five-pointed star and the remaining corners, that is, the fluid model is divided into 5 fluid model parts.

[0083] In some embodiments, the fluid model can also be divided into a plurality of fluid model parts by obtaining the size information of the fluid model, obtaining the stereoscopic model specification information for dividing the fluid model, and dividing the fluid model into a plurality of fluid model parts according to the size information and the stereoscopic model specification information, and setting a stereoscopic model for each fluid model part.

[0084] The stereoscopic model specification information includes shape information of the stereoscopic model and size information of the stereoscopic model.

[0085] It should be noted that the shape information of the stereoscopic model can be adjusted according to actual conditions. For example, the shape information indicates that the stereoscopic model includes a fixed shape, such as a regular hexahedron. For another example, the shape information indicates that the stereoscopic model includes a plurality of fixed shapes, such as a regular hexahedron, a sphere, a cylinder, etc.

[0086] The size information of the stereoscopic model can be adjusted according to the size information of the fluid model and the number of stereoscopic models, which is not limited here.

[0087] For example, by determining the size information of the fluid model (i.e., a large area) to be divided, selecting a proper tile size (such as width, length, and height, etc.) according to the size information of the fluid model, and dividing the large area where the fluid model is located into a plurality of fluid model parts (i.e., small areas, or tiles) matching the size of the tile according to the rows and columns.

[0088] The stereoscopic model is used to indicate a model surrounding the fluid model part, and the shape of the stereoscopic model can be adjusted according to actual conditions, which is not limited by the present application.

[0089] It should be noted that the shape of the 3D model is related to the rendering performance consumption. In the embodiments of this application, the 3D model surrounding the fluid model can be a 3D model with the smallest area surrounding the fluid model, or the 3D model surrounding the fluid model can also be one that requires the fluid model portion to occupy a proportion greater than a predetermined proportion in the 3D model, and the predetermined proportion can be adjusted according to the actual situation.

[0090] For example, please see Figures 3a-3d , Figures 3a to 3d These are schematic diagrams of a fluid model portion and a three-dimensional model surrounding that fluid model portion. The fluid model portion is... Figures 3a to 3d The gray area in the text indicates the fluid model portion. Figure 3a The cube indicates the three-dimensional model. Figure 3b The hexahedral indicator solid model in the middle, Figure 3c The cylindrical indicator 3D model in the middle, Figure 3d The three hexahedrons in the diagram all indicate a three-dimensional model. Combined with... Figures 3a-3d It can be seen that, using such Figures 3a-3c The 3D model shown encloses the fluid model. Within the 3D model, there are many blank areas where no fluid exists, resulting in high rendering performance overhead for subsequent analysis and rendering of the fluid model based on the 3D model. And as... Figure 3d The 3D model shown is the 3D model with the smallest area surrounding the fluid model. Therefore, subsequent models based on this will be used... Figure 3d The performance required to render the fluid model from the 3D model shown is lower than that required to render the fluid model from the 3D model shown in 3a-3c.

[0091] In some embodiments, to avoid over-drawing, the shape of the solid model includes a convex body, wherein the convex body includes at least one or more of a convex polyhedron, a sphere, and a cylinder.

[0092] By fitting the fluid effect with tiles, the fluid representation effect of the partitioned blocks is achieved. Optical depth information is calculated by using a 3D model that surrounds the fluid model. The calculation range can be flexibly modified by adjusting the shape and number of the 3D model, while reducing the pixel area required for calculation.

[0093] Step 102: Determine the target fluid model portion to be rendered on the fluid model based on the portion of the fluid model through which the view ray of the virtual camera in the virtual space passes.

[0094] In this context, virtual space is a three-dimensional coordinate system used to represent and manipulate three-dimensional objects. A virtual camera is a tool used to capture views in virtual space, similar to a camera in the real world. The virtual camera defines how to generate two-dimensional images from a three-dimensional scene.

[0095] A view ray is a ray extending from the camera position along the view direction of the camera, and is used to determine what the camera sees in the virtual space. The target fluid model part refers to the fluid model part on the fluid model to be rendered.

[0096] By determining the fluid model part on the fluid model through which the view ray passes, the target fluid model part on the fluid model to be rendered can be determined.

[0097] It should be noted that if the fluid model part on the fluid model through which the view ray passes is one fluid model part, the number of target fluid model parts is determined to be 1. If the fluid model part on the fluid model through which the view ray passes is multiple fluid model parts, the number of target fluid model parts is determined to be multiple.

[0098] In some embodiments, before determining the target fluid model part on the fluid model to be rendered according to the fluid model part on the fluid model through which the view ray of the virtual camera in the virtual space passes, the model rendering method comprises: obtaining a hit position of a pixel shader on a solid model of the fluid model part; determining a view ray direction of the virtual camera based on the hit position and second position information of the virtual camera.

[0099] The hit position is used to indicate the actual hit position of the pixel shader on the solid model of the fluid model part. The second position information is used to indicate the position information of the virtual camera in the virtual space.

[0100] By the hit position, the view ray direction is determined, so that subsequently, based on the view ray direction of the virtual camera in the virtual space, the target fluid model part on the fluid model to be rendered is determined according to the fluid model part on the fluid model through which the view ray of the virtual camera in the virtual space passes, the fluid effect fitting is performed on the target fluid model part, so that the model rendering scheme can be suitable for various fluid distribution scenes, and in the scene where the fluid distribution is uneven, the performance consumption can be effectively reduced, the rendering efficiency is improved, and the user experience is improved.

[0101] Step 103, setting a bounding box for the target solid model corresponding to the target fluid model part.

[0102] The bounding box indicates a hexahedron used to enclose the target solid model. The hexahedron can include a regular hexahedron or other regular hexahedron, which is adjusted according to actual conditions, and the embodiments of the present application are not limited.

[0103] It should be noted that for various solid models in the shape of convex bodies, there must be a hexahedron that can completely enclose them, and the hexahedron that completely encloses the solid model is the bounding box corresponding to the solid model.

[0104] Step 104, determining a ray path of the view ray in the bounding box.

[0105] The ray path indicates a path formed by the view ray of the virtual camera passing through the interior of the bounding box.

[0106] In some embodiments, the process of determining the ray path of the view ray in the bounding box can include determining position information of an incident point and position information of an exit point of the view ray on the bounding box; determining the ray path of the view ray in the bounding box based on the position information of the incident point and the position information of the exit point.

[0107] The incident point indicates the intersection of the view ray on the bounding box when the view ray enters the bounding box, and the exit point indicates the intersection of the view ray on the bounding box when the view ray exits the bounding box.

[0108] The process of determining the position information of the incident point and the position information of the exit point of the view ray on the bounding box can include determining first position information of the bounding box in the virtual space; determining the position information of the incident point and the position information of the exit point of the view ray on the bounding box based on the first position information of the bounding box and second position information of the virtual camera in the virtual space.

[0109] The first position information indicates the position information of the bounding box in the virtual space. The second position information is used to indicate the position information of the virtual camera in the virtual space.

[0110] There are various ways to determine the first position information of the bounding box in the virtual space, which can be adjusted according to actual conditions, and the embodiments of the present application are not limited.

[0111] In some embodiments, a minimum hexahedron capable of completely enclosing the target solid model can be determined first, and the position information of the minimum hexahedron can be determined by determining the position information of a plurality of target reference points of the target solid model in the virtual space and combining the position information of the plurality of reference points.

[0112] In some embodiments, the first position information of the bounding box in the virtual space can be determined by obtaining third position information of a reference point on the target solid model in the virtual space and size information of the bounding box enclosing the target solid model; and based on the third position information and the size information, determining the first position information of the bounding box in the virtual space.

[0113] The reference point can be a point where the center of the target solid model, the centroid, the barycenter, etc. are located. The third position information indicates the position information of the reference point in the virtual space. The size information of the bounding box includes size specification information indicating the length, width, height, etc. of the bounding box, which can be adjusted according to actual conditions, and the embodiments of the present application are not limited.

[0114] The process of determining the ray path of the view ray in the bounding box is explained below with a specific example. The center position and size (such as width, height, depth, etc.) of the hexahedral bounding box are determined, as well as the position information of the virtual camera and the direction of the view ray of the virtual camera. The hexahedron can be represented by its eight vertices or six faces. Each face can be represented by a plane equation. For each face, the intersection formula of the ray and the plane is used to calculate the intersection point. The ray equation is substituted into the plane equation to calculate the intersection point of the ray and the plane equation. In addition, it is also necessary to determine whether the calculated intersection point is located within the six faces of the hexahedron. The determination method can use the point-in-polygon algorithm, that is, the point-in-polygon algorithm can be used. Repeat the above steps for each face of the hexahedron to find all possible intersection points, and form the ray path of the view ray in the bounding box from the determined intersection points. Step 105, according to the fluid density control information and the ray path, the optical depth information of the target fluid model part is determined by ray stepping analysis.

[0115] Wherein, the ray stepping is used to calculate the propagation of the light ray in the medium, that is, the fluid.

[0116] The optical depth information indicates the integral of the product of the medium density and the absorption and scattering coefficients on the path from the starting point to the ending point in the medium.

[0117] Based on the optical depth information, the light attenuation information can be determined, wherein the light attenuation information is used to describe the degree of attenuation of the light ray when propagating in the medium. In some embodiments, the fluid density control information includes a mapping relationship between the position information in the virtual space and the fluid density.

[0118] Wherein, the fluid density control information can use a 3D texture to represent the mapping relationship between the position information in the virtual space and the fluid density, and can also use a function corresponding to the directional distance field to represent the mapping relationship between the position information in the virtual space and the fluid density.

[0119] Based on this, the process of determining the optical depth information of the target fluid model part according to the fluid density control information and the ray path by ray stepping analysis can include: sampling the ray path according to the stepping distance to obtain a plurality of sampling segments and fourth position information of the sampling segments; determining the fluid density corresponding to each sampling segment based on the fourth position information and the mapping relationship between the position information in the virtual space and the fluid density; obtaining the optical depth coefficient of the target fluid model part; and performing integral calculation based on the fluid density of each sampling segment and the optical depth coefficient to determine the optical depth information of the target fluid model part.

[0120] Wherein, the stepping distance indicates the distance selected by the optical stepping.

[0121] The sampling segment indicates a line segment obtained by sampling the light path at a step distance, i.e., a line segment intercepted from the light path according to the step distance, starting from the starting point of the light path.

[0122] The fourth position information indicates position information of the sampling segment in the virtual space.

[0123] The fluid density indicates the density of the medium in the sampling segment. For example, when the medium is fog, the fluid density refers to the fog concentration.

[0124] The optical depth coefficient refers to a parameter for describing the ability of light to be absorbed and scattered when propagating in the medium. The optical depth coefficient includes an absorption coefficient and a scattering coefficient. The absorption coefficient is used to describe the ability of the medium to absorb light, indicating the proportion of light intensity absorbed per unit length. The absorption coefficient depends on the physical and chemical properties of the medium, such as color, composition, and density. The scattering coefficient is used to describe the ability of the medium to scatter light, indicating the proportion of light intensity scattered per unit length. The scattering coefficient is related to the particle size, shape, and distribution of the medium. The optical depth is obtained by integrating the absorption coefficient and the scattering coefficient and multiplying the medium density.

[0125] It should be noted that the process of obtaining the optical depth coefficient of the target fluid model part can be obtained by calculating the dot product of the view ray direction and the light source direction, and the specific process can refer to the prior art.

[0126] The following will take fog as an example, combined with Figure 3e and One specific embodiments are explained. For each target fluid model part, there is a diagram as shown in Figure 3e . Among them, the green line indicates the face of the solid model where the target fluid model part is located, the magenta indicates the face of the bounding box of the solid model where the target fluid model part is located, and the blue is the target fluid model part, i.e., the area where the fog exists. The red line is the view ray of the virtual camera. The intersection of the view ray of the virtual camera and the bounding box includes: the incident point A and the exit point F. The intersection of the view ray of the virtual camera and the solid model includes: the incident point B and the exit point E. The intersection of the view ray of the virtual camera and the target fluid model part includes: the incident point C and the exit point D.

[0127] Specifically, according to the position of the model point and the size information of the bounding box, the first distance AF between the view ray of the virtual camera and the bounding box is determined. Then, the positions of points A and F are obtained according to the instance center of the model where the fog is located and the corresponding bounding box size. And since the ray hits the position E. According to the direction of the vector AF, the AF is divided into multiple segments, and the approximate optical depth is obtained by sampling each segment. The corresponding light attenuation effect is obtained according to the optical depth.

[0128] Combining Figure 3e It can be seen that CD = AF - AC - DF = AF - (AC) - (DE + EF).

[0129] In the above equation, the light path AF can be determined by the intersection of the view ray of the virtual camera and the bounding box surface, which is solved by the midpoint position of the corresponding solid model of the target fluid model part and the size information of the bounding box. That is, the position information of the incident point and the position information of the exit point of the view ray on the bounding box are determined; based on the position information of the incident point and the position information of the exit point, the light path of the view ray in the bounding box is determined.

[0130] It should be noted that the camera needs to be displayed in the model during rendering, and therefore the surface needs to be reversed during shading, that is, E point is the actual hit position in the pixel shader. However, the position of B point is uncertain because the shape of the solid model is unknown. Therefore, the position of C point and the position of D point can be determined according to the following formula:

[0131]

[0132] Wherein, the determination of the position of C point and the position of D point is consistent, and in the above formula, and are in the same direction, but and length is unknown.

[0133] If n→∞ in the above function, the standard case can be represented according to the following formula, that is, A increases the corresponding vector:

[0134]

[0135] Q.E.D., that is, the above point formula meets the mathematical expectation. Therefore, when performing ray stepping analysis, the above equation can be fitted using the distance coefficient x (i.e. the step distance in ray stepping) and the number of layers l (i.e. the number of steps in ray stepping), when l in the equation approaches positive infinity, and x in the equation approaches 0, the equation accuracy is more in line with the expectation, that is, represented according to the following formula:

[0136]

[0137] By ray stepping according to the above formula, the fitted position of C point and the position of D point can be determined, and CD is the fog area with concentration. Combined with CD and the fluid density control information, the optical depth information of the target fluid model part is determined.

[0138] It should be noted that AC and DF are considered for performance considerations, so that a segment of the coefficient l that does not need to be considered can be excluded, that is, to avoid too large or too small coefficients.

[0139] In some embodiments, the number of the above target fluid model parts is more, that is, in the direction of the view ray of the virtual camera in the virtual space, the view ray of the virtual camera passes through multiple fluid model parts.

[0140] In order to superimpose multiple target fluid model parts and ensure that the calculation of the optical depth information of each target fluid model part is correct, a target storage space is configured for the above fluid model.

[0141] The target storage space is used to store the optical depth information.

[0142] The implementation of the target storage space can be set according to actual conditions, and the embodiments of the present application are not limited. For example, a rendering target (RenderTarget, RT) can be made as the target storage space.

[0143] Based on the above, the process of obtaining the optical depth coefficient of the target fluid model part can include: determining the first target fluid model part through which the view ray passes as the target fluid model part currently analyzed; determining the optical depth coefficient of the target fluid model part currently analyzed based on the direction of the view ray and the direction of the light source, and storing the optical depth coefficient in the target storage space; determining the target fluid model part through which the view ray passes after the target fluid model part currently analyzed as a new target fluid model part currently analyzed; determining the optical depth coefficient of the new target fluid model part currently analyzed based on the direction of the view ray, the direction of the light source, the position indication information of the new target fluid model part currently analyzed, and the optical depth coefficient stored in the target storage space, and storing the optical depth coefficient in the target storage space; returning to the step of determining the target fluid model part through which the view ray passes after the target fluid model part currently analyzed as a new target fluid model part currently analyzed until the optical depth coefficients of all target fluid model parts are determined.

[0144] Specifically, when the stereoscopic models of multiple target fluid model parts need to be superimposed, if the fluid effect of a single stereoscopic model is correctly represented, it is also necessary to ensure that the calculation effect of the stereoscopic models of multiple target fluid model parts is correct, that is, it is necessary to consider whether the occlusion effect of the current fluid on the subsequent fluid is correct.

[0145] Next, taking fog as an example, combining Figure 3f , Figure 3g and OneThe specific embodiments are explained. It should be noted that when light passes through the fog, various scattering occurs, and the scattering coefficients used in the embodiments include Rayleigh scattering and Mie scattering. In the case of considering Rayleigh scattering and Mie scattering, for the solid model of each target fluid model part, the scattering coefficient obtained by normal solving can be expressed as follows:

[0146]

[0147] wherein, indicates the area through which the line of sight passes through the fog, such as Figure 3f and Figure 3g the areas A, B and C shown in indicates the intersection between the sunlight passing through the fog and the line of sight when the line of sight passes through the area of the fog. As shown in Figure 3f and Figure 3g , for area A, the intersection between the sunlight passing through the fog and the line of sight includes intersection A and intersection B, for area B, the intersection between the sunlight passing through the fog and the line of sight includes intersection B, intersection C, intersection E and intersection E, and for area C, the intersection between the sunlight passing through the fog and the line of sight includes intersection E and intersection F.

[0148] It should be noted that, as shown in Figure 3f and Figure 3g , the blue part is the range area where the fog exists, and the red line is the view line of the virtual camera. The sunlight is taken from above, and the yellow area is the associated area of the optical depth coefficient. Areas A, B and C all indicate a target fluid model part.

[0149] In order to calculate correctly in the case of tile overlay, by making an additional rendering target (RenderTarget, RT) as a target storage space, the solved optical depth coefficient can be reserved. It should be noted that since non-deterministic calculus is actually not solvable in a computer, for this purpose, accumulation is still used for fitting the optical depth coefficient.

[0150] If the currently analyzed target fluid model part is not the first target fluid model part through which the view line passes, the corresponding optical depth coefficient needs to be read from the RT, and the Rayleigh scattering coefficient and the Mie scattering coefficient are stored according to the corresponding required scattering equation, that is, the RG channel (other scattering coefficients can be stored in other channels, but since the Rayleigh scattering coefficient and the Mie scattering coefficient contribute more, the Rayleigh scattering coefficient and the Mie scattering coefficient are stored).

[0151] Based on this, in the case of multiple target fluid model parts, the sum of the actual optical depth can be expressed as follows:

[0152]

[0153] Since for region A, the intersection of sunlight passing through the fog to the line of sight includes intersection A and intersection B, for region B, the intersection of sunlight passing through the fog to the line of sight includes intersection B, intersection C, intersection E and intersection E, for region C, the intersection of sunlight passing through the fog to the line of sight includes intersection E and intersection F. Assuming the light source direction is The direction of the view ray is The origin of the virtual camera is Origin, which can be determined according to the above formula as follows:

[0154]

[0155] Based on the above formula, when n tends to infinity, the function is equal to the original distance. That is, it can be expressed according to the following formula:

[0156]

[0157] It should be noted that when integrating, the negative domain will cause the function to be actually subtracted, that is, the negative interval of region B (non-yellow region) will be calculated. This will cause errors in light calculation, so the length segment of the function, that is, the BE segment, needs to be calculated for the positive domain. When our function is clamped, each polynomial only calculates max(0, f(x)), the above equation can actually be expressed according to the following formula:

[0158]

[0159] That is,

[0160] Since AB+BC+DE+EF is the distance passing through the fog, the distance coefficient x and the number of layers l of the light ray step can be obtained as follows:

[0161]

[0162] Similarly, when the number of layers l approaches infinity and the distance coefficient x approaches 0, the above function can be expressed according to the following formula:

[0163]

[0164] Because the light source direction is The direction of the view ray is And only consider the positive domain, so the equation is consistent with the actual integral, and the proof is complete.

[0165] Step 106, based on the optical depth information, rendering the target fluid model part.

[0166] Specifically, based on the optical depth information, the optical attenuation information is determined, and the target fluid model part is rendered based on the optical attenuation information.

[0167] A corresponding light attenuation effect is obtained by optical depth, and the target fluid model part is rendered based on the light attenuation effect.

[0168] By adopting the scheme of the embodiments of the present application, the fluid model and the fluid density control information of the fluid model are acquired, the fluid model includes a plurality of fluid model parts, each fluid model part is provided with a solid model surrounding the fluid model part, and the fluid density control information is control information used for realizing fitting of the fluid model; a target fluid model part to be rendered on the fluid model is determined according to a fluid model part through which a view ray of a virtual camera in a virtual space passes on the fluid model; a bounding box is set for a target solid model corresponding to the target fluid model part; a light ray path of the view ray in the bounding box is determined; optical depth information of the target fluid model part is determined by performing light ray stepping analysis according to the fluid density control information and the light ray path; and the target fluid model part is rendered based on the optical depth information. Based on this, by dividing the fluid model into a plurality of fluid model parts surrounded by solid models, the fluid effect fitting of the fluid model part to be rendered is performed in a block manner, which can be applicable to various fluid distribution scenes, can effectively reduce performance consumption in a scene where fluid distribution is uneven, can improve rendering efficiency, and can improve user experience.

[0169] The embodiments also provide a model rendering device, which can be integrated in a terminal device. For example, as shown in Figure 4 The model rendering device can include:

[0170] The fluid model acquisition module 201 is configured to acquire a fluid model and fluid density control information of the fluid model, wherein the fluid model includes a plurality of fluid model parts, each fluid model part is provided with a solid model surrounding the fluid model part, and the fluid density control information is control information used for realizing fitting of the fluid model.

[0171] The target fluid model part determination module 202 is configured to determine a target fluid model part to be rendered on the fluid model according to a fluid model part through which a view ray of a virtual camera in a virtual space passes on the fluid model.

[0172] The bounding box setting module 203 is configured to set a bounding box for a target solid model corresponding to the target fluid model part.

[0173] The light ray path determination module 204 is configured to determine a light ray path of the view ray in the bounding box.

[0174] The light ray stepping analysis module 205 is configured to determine optical depth information of the target fluid model part by performing light ray stepping analysis according to the fluid density control information and the light ray path.

[0175] rendering module 206, configured to render the target fluid model part based on the optical depth information.

[0176] Optionally, in the apparatus according to an embodiment of the present application, the light path determination module 204 comprises:

[0177] a position information determination unit, configured to determine position information of an incident point and position information of an exit point of the view ray on the bounding box;

[0178] a light path determination unit, configured to determine a light path of the view ray in the bounding box based on the position information of the incident point and the position information of the exit point.

[0179] Optionally, in the apparatus according to an embodiment of the present application, the position information determination unit comprises:

[0180] determining first position information of the bounding box in the virtual space;

[0181] determining the position information of the incident point and the position information of the exit point of the view ray on the bounding box based on the first position information of the bounding box and second position information of the virtual camera in the virtual space.

[0182] Optionally, in the apparatus according to an embodiment of the present application, the determination of the first position information of the bounding box in the virtual space comprises:

[0183] obtaining third position information of a reference point on the target solid model in the virtual space and size information of a bounding box surrounding the target solid model;

[0184] determining the first position information of the bounding box in the virtual space based on the third position information and the size information.

[0185] Optionally, in the apparatus according to an embodiment of the present application, the fluid density control information comprises a mapping relationship between position information in the virtual space and fluid density.

[0186] Based on this, the light step analysis module 205 comprises:

[0187] a sampling unit, configured to sample the light path according to the step distance to obtain a plurality of sampling segments and fourth position information of the sampling segments;

[0188] a fluid density determination unit, configured to determine fluid density corresponding to each sampling segment based on the fourth position information and the mapping relationship between position information in the virtual space and fluid density.

[0189] an optical depth coefficient acquisition unit, configured to acquire an optical depth coefficient of the target fluid model part.

[0190] an optical depth information determination unit configured to determine optical depth information of the target fluid model part based on fluid density of each sampling section and optical depth coefficient.

[0191] Optionally, in the device of the embodiment of the present application, the number of the target fluid model parts is multiple, and the fluid model is configured with a target storage space.

[0192] Based on this, the optical depth coefficient acquisition unit specifically includes:

[0193] determining the first target fluid model part through which the view ray passes as the target fluid model part for current analysis;

[0194] based on the view ray direction and the light source direction, determining the optical depth coefficient of the target fluid model part for current analysis, and storing the optical depth coefficient in the target storage space;

[0195] determining the target fluid model part through which the view ray passes after the target fluid model part for current analysis as a new target fluid model part for current analysis;

[0196] based on the view ray direction, the light source direction, the position indication information of the new target fluid model part for current analysis, and the optical depth coefficient stored in the target storage space, determining the optical depth coefficient of the new target fluid model part for current analysis, and storing the optical depth coefficient in the target storage space;

[0197] returning to the step of determining the target fluid model part through which the view ray passes after the target fluid model part for current analysis as a new target fluid model part for current analysis until the optical depth coefficients of all the target fluid model parts are determined.

[0198] Optionally, in the device of the embodiment of the present application, before the target fluid model part determination module 202, the model rendering device further includes:

[0199] a hit position acquisition module configured to acquire a hit position of the pixel shader on the three-dimensional model of the fluid model part;

[0200] a view ray direction determination module configured to determine a view ray direction of the virtual camera based on the hit position and second position information of the virtual camera.

[0201] Optionally, in the device of the embodiment of the present application, before the target fluid model part determination module 202, the device further includes:

[0202] a size information acquisition unit configured to acquire size information of the fluid model;

[0203] The stereoscopic model specification information acquisition unit is configured to acquire stereoscopic model specification information for dividing the fluid model.

[0204] The division unit is configured to divide the fluid model into a plurality of fluid model parts according to the size information and the stereoscopic model specification information, and set a stereoscopic model surrounding each fluid model part for each fluid model part.

[0205] Optionally, in the device of the embodiment of the present application, the shape of the stereoscopic model includes a convex body, and the convex body includes at least one or more of a convex polyhedron, a sphere, and a cylinder.

[0206] According to the scheme of the embodiment of the present application, the fluid model and the fluid density control information of the fluid model are acquired, the fluid model includes a plurality of fluid model parts, each fluid model part is provided with a stereoscopic model surrounding the fluid model part, and the fluid density control information is control information for realizing fitting of the fluid model; the target fluid model part to be rendered on the fluid model is determined according to the fluid model part through which the view ray of the virtual camera in the virtual space passes on the fluid model; the bounding box of the target stereoscopic model corresponding to the target fluid model part is set; the light path of the view ray in the bounding box is determined; the optical depth information of the target fluid model part is determined according to the fluid density control information and the light path; and the target fluid model part is rendered based on the optical depth information. Based on this, by dividing the fluid model into a plurality of fluid model parts surrounded by stereoscopic models, the fluid effect fitting of the fluid model part to be rendered is performed in blocks, which can be suitable for various fluid distribution scenes, can effectively reduce performance consumption in a scene where fluid distribution is uneven, can improve rendering efficiency, and can improve user experience.

[0207] Correspondingly, the embodiment of the present application further provides an electronic device, which can be a terminal, such as a smart phone, a tablet computer, a notebook computer, a touch screen, a game console, a personal computer (PC), a personal digital assistant (PDA), and the like. Alternatively, the electronic device can be a server.

[0208] As shown in Figure 5 , the electronic device can be a terminal, such as a smart phone, a tablet computer, a notebook computer, a touch screen, a game console, a personal computer (PC), a personal digital assistant (PDA), and the like. Alternatively, the electronic device can be a server. Figure 5A structural schematic diagram of an electronic device is provided in the embodiments of the present application. The electronic device 300 includes a processor 301 having one or more processing cores, a memory 302 having one or more computer readable storage media, and a computer program stored on the memory 302 and executable on the processor. The processor 301 is electrically connected to the memory 302. Those skilled in the art can understand that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and can include more or fewer components than shown, or combine certain components, or different component arrangements.

[0209] The processor 301 is the control center of the electronic device 300, and connects various parts of the entire electronic device 300 through various interfaces and lines. By running or loading the software program and / or unit stored in the memory 302, and calling the data stored in the memory 302, the processor 301 performs various functions and processes data of the electronic device 300, thereby overall monitoring the electronic device 300. The processor 301 can be a central processing unit CPU, a graphics processing unit GPU, a network processor NP, etc., and can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application.

[0210] In the embodiments of the present application, the processor 301 in the electronic device 300 will load the instructions corresponding to the processes of one or more application programs into the memory 302, and run the application programs stored in the memory 302 by the processor 301, thereby realizing various functions, for example:

[0211] Obtaining a fluid model and fluid density control information of the fluid model, wherein the fluid model includes a plurality of fluid model parts, each fluid model part is provided with a solid model surrounding the fluid model part, and the fluid density control information is control information used to realize fitting of the fluid model;

[0212] Determining a target fluid model part to be rendered on the fluid model according to a fluid model part through which a view ray of a virtual camera in a virtual space passes on the fluid model;

[0213] Setting a bounding box for a target solid model corresponding to the target fluid model part;

[0214] Determining a ray path of the view ray in the bounding box;

[0215] Performing ray marching analysis according to the fluid density control information and the ray path to determine optical depth information of the target fluid model part;

[0216] Rendering the target fluid model part based on the optical depth information.

[0217] According to the electronic device provided in the embodiments of the present application, the fluid model and fluid density control information of the fluid model can be acquired, the fluid model includes a plurality of fluid model parts, each fluid model part is provided with a solid model surrounding the fluid model part, and the fluid density control information is control information used for realizing fitting of the fluid model; a target fluid model part to be rendered on the fluid model is determined according to a fluid model part through which a view ray of a virtual camera in a virtual space passes on the fluid model; a bounding box is set for a target solid model corresponding to the target fluid model part; a light path of the view ray in the bounding box is determined; optical depth information of the target fluid model part is determined according to the fluid density control information and the light path; and the target fluid model part is rendered based on the optical depth information. In this way, by dividing the fluid model into a plurality of fluid model parts surrounded by solid models, the fluid effect fitting of the fluid model part to be rendered is performed in a block manner, which can be suitable for various fluid distribution scenes, can effectively reduce performance consumption, improve rendering efficiency and enhance user experience in a scene where fluid distribution is uneven.

[0218] The specific implementation of each operation can refer to the foregoing embodiments, and will not be described here.

[0219] Optionally, as shown in Figure 5 The electronic device 300 further includes a touch display screen 303, a radio frequency circuit 304, an audio circuit 305, an input unit 306 and a power supply 307. The processor 301 is electrically connected with the touch display screen 303, the radio frequency circuit 304, the audio circuit 305, the input unit 306 and the power supply 307 respectively. Those skilled in the art can understand that the electronic device structure shown in the Figure 5 The electronic device structure shown in the

[0220] The touch display screen 303 can be used to display a graphical user interface and receive operation instructions generated by user acting on the graphical user interface. The touch display screen 303 can include a display panel and a touch panel. The display panel can be used to display information input by the user or provided to the user and various graphical user interfaces of the electronic device, which can be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. The touch panel can be used to collect touch operations (such as operations of the user using a finger, a stylus or any suitable object or accessory on or near the touch panel) of the user on or near it and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel can include two parts of a touch detection device and a touch controller. The touch detection device detects the touch position of the user and detects the signals brought by the touch operation and transmits the signals to the touch controller; the touch controller receives the touch information from the touch detection device and converts it into touch coordinates and sends it to the processor 301, and can also receive commands from the processor 301 and execute them. The touch panel can cover the display panel, and when the touch panel detects a touch operation on or near it, it transmits to the processor 301 to determine the type of the touch event, and then the processor 301 provides corresponding visual output on the display panel according to the type of the touch event. In the embodiments of the present application, the touch panel and the display panel can be integrated into the touch display screen 303 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can realize the input and output functions as two independent components. That is, the touch display screen 303 can also realize the input function as part of the input unit 306.

[0221] The radio frequency circuit 304 can be used to transceive radio frequency signals to establish wireless communication with network devices or other electronic devices.

[0222] The audio circuit 305 can be used to provide an audio interface between the user and the electronic device through the speaker and the microphone. The audio circuit 305 can convert the received audio data into an electrical signal and transmit it to the speaker, which converts it into a sound signal output; on the other hand, the microphone collects the sound signal and converts it into an electrical signal, which is received by the audio circuit 305 and converted into audio data, and then the audio data is output to the processor 301 for processing, and then transmitted to another electronic device through the radio frequency circuit 304, or output to the memory 302 for further processing. The audio circuit 305 can also include an earphone jack to provide communication between the external earphone and the electronic device.

[0223] The input unit 306 can be configured to receive a shape supported by the solid model, an upper limit of the number of solid models, or input information.

[0224] The power supply 307 is configured to supply power to each component of the electronic device 300. Optionally, the power supply 307 can be logically connected to the processor 301 through a power management system, so as to realize functions such as management of charging, discharging, and power consumption management through the power management system. The power supply 307 can also include one or more than one direct current or alternating current power supply, a recharging system, a power supply fault detection circuit, a power supply converter or inverter, a power supply state indicator, or any other component.

[0225] Although Figure 5 The electronic device 300 can also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, and the like, which are not shown in the embodiments, and will not be described herein.

[0226] In the above embodiments, the description of each embodiment focuses on different aspects, and the parts not described in detail in a certain embodiment can be referred to the related description of other embodiments.

[0227] Those skilled in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions, or by controlling related hardware by the instructions, which can be stored in a computer readable storage medium and loaded and executed by a processor.

[0228] To this end, an embodiment of the present application provides a computer readable storage medium, which stores a plurality of computer programs. The computer programs can be loaded by a processor to execute any model rendering method provided by an embodiment of the present application. The computer programs can execute the steps of the following model rendering method:

[0229] Obtaining a fluid model and fluid density control information of the fluid model, wherein the fluid model includes a plurality of fluid model parts, each fluid model part is provided with a solid model surrounding the fluid model part, and the fluid density control information is control information used to realize fitting of the fluid model;

[0230] Determining a target fluid model part to be rendered on the fluid model according to a fluid model part through which a view ray of a virtual camera in a virtual space passes on the fluid model;

[0231] Setting a bounding box for a target solid model corresponding to the target fluid model part;

[0232] Determining a light path of the view ray in the bounding box;

[0233] According to the fluid density control information and the ray path, ray stepping analysis is performed to determine optical depth information of the target fluid model part.

[0234] Based on the optical depth information, the target fluid model part is rendered.

[0235] According to the computer readable storage medium provided in the embodiments of the present application, the fluid model and the fluid density control information of the fluid model are obtained, the fluid model includes a plurality of fluid model parts, each fluid model part is provided with a solid model surrounding the fluid model part, and the fluid density control information is control information used for realizing fitting of the fluid model; the target fluid model part to be rendered on the fluid model is determined according to a fluid model part through which a view ray of a virtual camera in a virtual space passes on the fluid model; a bounding box is set for a target solid model corresponding to the target fluid model part; a ray path of the view ray in the bounding box is determined; according to the fluid density control information and the ray path, ray stepping analysis is performed to determine optical depth information of the target fluid model part; and based on the optical depth information, the target fluid model part is rendered. Based on this, by dividing the fluid model into a plurality of fluid model parts surrounded by solid models, fluid effect fitting of the fluid model part to be rendered is performed in a block manner, which can be suitable for various fluid distribution scenes, can effectively reduce performance consumption in a scene where fluid distribution is uneven, improve rendering efficiency, and improve user experience.

[0236] The specific implementation of each operation can be referred to the foregoing embodiments, which will not be described herein again.

[0237] The computer readable storage medium can include a read only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0238] Due to the computer program stored in the computer readable storage medium, any model rendering method provided in the embodiments of the present application can be executed, and thus the beneficial effects of any model rendering method provided in the embodiments of the present application can be achieved. Details are described in the foregoing embodiments, which will not be described herein again.

[0239] According to an aspect of the present application, a computer program product or a computer program is also provided, which includes computer instructions stored in a computer readable storage medium. A processor of an electronic device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to enable the electronic device to perform the method provided in various optional implementation manners in the foregoing embodiments.

[0240] In the model rendering apparatus, the computer readable storage medium, the electronic device, and the computer program product, the description of each embodiment has its own focus, and the parts not described in detail in a certain embodiment can be referred to the relevant description of other embodiments. It can be clearly understood by those skilled in the art that, for the convenience and brevity of description, the specific working process of the model rendering apparatus, the computer readable storage medium, the computer program product, the electronic device, and the corresponding units thereof and the beneficial effects brought by the above description can be referred to the description of the model rendering method in the above embodiments, and will not be described here in detail.

[0241] The model rendering method, the model rendering apparatus, the electronic device, the computer readable storage medium, and the computer program product provided by the embodiments of the present application are described in detail above, the principles and implementation manners of the present application are described by applying specific examples, the above embodiment description is only used to help understand the method and the core idea of the present application; meanwhile, for those skilled in the art, according to the idea of the present application, the specific implementation manner and application range will be changed, and the above description should not be understood as the limitation of the present application.

Claims

1. A model rendering method, characterized in that, The method includes: A fluid model and fluid density control information of the fluid model are obtained, wherein the fluid model includes multiple fluid model parts, each fluid model part is provided with a three-dimensional model surrounding the fluid model part, and the fluid density control information is control information used to achieve fitting of the fluid model; Based on the portion of the fluid model that the view ray of the virtual camera in the virtual space passes through on the fluid model, determine the target fluid model portion to be rendered on the fluid model. Set a bounding box for the target 3D model corresponding to the target fluid model part; Determine the ray path of the visible ray within the bounding box; Based on the fluid density control information and the light path, light stepping analysis is performed to determine the optical depth information of the target fluid model portion; Based on the optical depth information, the target fluid model is rendered. The fluid density control information includes a mapping relationship between position information in virtual space and fluid density. The step of determining the optical depth information of the target fluid model portion based on the fluid density control information and the light path through ray stepping analysis includes: Based on the step distance, the light path is sampled to obtain multiple sampled segments and the fourth position information of the sampled segments; Based on the fourth location information and the mapping relationship between location information and fluid density in virtual space, the fluid density corresponding to each sampling segment is determined; Obtain the optical depth coefficient of the target fluid model portion; The optical depth information of the target fluid model is determined by integral calculation based on the fluid density of each sampling segment and the optical depth coefficient.

2. The model rendering method according to claim 1, characterized in that, Determining the ray path of the visible ray within the bounding box includes: Determine the position information of the incident point and the position information of the exit point of the ray on the bounding box; Based on the location information of the incident point and the location information of the exit point, the light path of the ray in the bounding box is determined.

3. The model rendering method according to claim 2, characterized in that, Determining the position information of the incident point and the exit point of the ray on the bounding box includes: Determine the first position information of the bounding box in the virtual space; Based on the first position information of the bounding box and the second position information of the virtual camera in the virtual space, the position information of the incident point and the position information of the exit point of the viewing ray on the bounding box are determined.

4. The model rendering method according to claim 3, characterized in that, Determining the first position information of the bounding box in the virtual space includes: Obtain the third position information of the reference point on the target 3D model in the virtual space, as well as the size information of the bounding box surrounding the target 3D model; Based on the third location information and the size information, the first location information of the bounding box in the virtual space is determined.

5. The model rendering method according to claim 1, characterized in that, There are multiple target fluid model parts, and each fluid model is configured with target storage space. Obtaining the optical depth coefficients of the target fluid model parts includes: The first target fluid model portion through which the ray of sight passes is identified as the target fluid model portion for the current analysis. Based on the direction of the ray of sight and the direction of the light source, the optical depth coefficient of the target fluid model part currently being analyzed is determined, and the optical depth coefficient is stored in the target storage space; The target fluid model portion that the ray passes through after the target fluid model portion of the current analysis is determined as the new target fluid model portion of the current analysis; Based on the direction of the ray, the direction of the light source, the position indication information of the new target fluid model part currently being analyzed, and the optical depth coefficient stored in the target storage space, the optical depth coefficient of the new target fluid model part currently being analyzed is determined, and the optical depth coefficient is stored in the target storage space. Return to the step of determining the target fluid model portion through which the ray passes after the target fluid model portion of the current analysis, as the new target fluid model portion of the current analysis, until the optical depth coefficient of all target fluid model portions is determined.

6. The model rendering method according to claim 1, characterized in that, Before determining the target fluid model portion to be rendered on the fluid model based on the portion of the fluid model traversed by the view ray of the virtual camera in virtual space, the process includes: Obtain the hit position of the pixel shader on the 3D model of the fluid model section; Based on the hit location and the second position information of the virtual camera, the direction of the virtual camera's line of sight is determined.

7. The model rendering method according to claim 1, characterized in that, Before determining the target fluid model portion to be rendered on the fluid model based on the portion of the fluid model traversed by the view ray of the virtual camera in virtual space, the method further includes: Obtain the dimensional information of the fluid model; Obtain the 3D model specification information used to divide the fluid model; Based on the size information and the specifications of the 3D model, the fluid model is divided into multiple fluid model parts, and a 3D model surrounding each fluid model part is set.

8. The model rendering method according to any one of claims 1-7, characterized in that, The shape of the three-dimensional model includes a convex body, wherein the convex body includes at least one or more of a convex polyhedron, a sphere, and a cylinder.

9. A model rendering device, characterized in that, The device includes: A fluid model acquisition module is used to acquire a fluid model and fluid density control information of the fluid model. The fluid model includes multiple fluid model parts, each of which is provided with a three-dimensional model surrounding it. The fluid density control information is control information used to achieve fitting of the fluid model. The target fluid model part determination module is used to determine the target fluid model part to be rendered on the fluid model based on the fluid model part that the view ray of the virtual camera in the virtual space passes through on the fluid model; The bounding box setting module is used to set a bounding box for the target 3D model corresponding to the target fluid model part; A ray path determination module is used to determine the ray path of the ray in the bounding box; The ray stepping analysis module is used to perform ray stepping analysis based on the fluid density control information and the ray path to determine the optical depth information of the target fluid model portion; A rendering module is used to render the target fluid model portion based on the optical depth information; The fluid density control information includes a mapping relationship between location information in virtual space and fluid density. The ray stepping analysis module is further used for: Based on the step distance, the light path is sampled to obtain multiple sampled segments and the fourth position information of the sampled segments; Based on the fourth location information and the mapping relationship between location information and fluid density in virtual space, the fluid density corresponding to each sampling segment is determined; Obtain the optical depth coefficient of the target fluid model portion; The optical depth information of the target fluid model is determined by integral calculation based on the fluid density of each sampling segment and the optical depth coefficient.

10. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the steps of the model rendering method according to any one of claims 1 to 8.

11. A computer-readable storage medium, characterized in that, It includes a computer program that, when run on an electronic device, causes the electronic device to perform the steps of the model rendering method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Three-dimensional fluid simulation method based on graphic processing unit (GPU)

    CN102402791A

  • Volume rendering acceleration method and device for sparse scalar field data

    CN117496024A