Model rendering method and device, electronic equipment and storage medium
By dividing the fluid model into multiple parts surrounded by the stereo model, the partition blocks perform fluid effect fitting and light stepping analysis, the problems of high performance consumption and low rendering efficiency in uneven fluid distribution scenes are solved, and more efficient rendering and improved user experience is achieved.
Patent Information
- Application Number
- CN202510052256.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-13
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-01-13
AI Technical Summary
The existing fluid models consume high performance and low rendering efficiency in scenarios with uneven fluid distribution, which affects the user experience.
The fluid model is divided into multiple fluid model parts surrounded by the stereo model, and the target fluid model part to be rendered is fitted in the block, and the optical depth information is determined through light step analysis for rendering.
It is suitable for various fluid distribution scenarios, especially in scenes where fluid distribution is uneven, effectively reduce performance consumption, improve rendering efficiency, and improve user experience.
Smart Images

Figure CN119991915A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of game technology, and in particular to a model rendering method, device, electronic device and storage medium. Background Art
[0002] The existing implementation methods of fluid models mainly determine the fluid density based on the height of the fluid, or perform ray stepping analysis on the area where the fluid is located to determine the fluid density. However, determining the fluid density based on the height of the fluid is not suitable for scenes with uneven fluid distribution. Other existing implementation methods of fluid models have problems such as high performance consumption and low rendering efficiency in scenes with uneven fluid distribution, which affects the user experience. Summary of the invention
[0003] The embodiments of the present application provide a model rendering method, device, electronic device and storage medium. The method can divide the fluid model into multiple fluid model parts surrounded by a three-dimensional model, and perform fluid effect fitting on the target fluid model part to be rendered in blocks. The method can be applicable to various fluid distribution scenarios, and in scenarios with uneven fluid distribution, the method can effectively reduce performance consumption, improve rendering efficiency and enhance user experience.
[0004] In a first aspect, an embodiment of the present application provides a model rendering method, the method comprising:
[0005] 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 of the fluid model parts is provided with a three-dimensional model surrounding the fluid model part, and the fluid density control information is control information for realizing fitting of the fluid model;
[0006] Determining a target fluid model portion to be rendered on the fluid model according to a portion of the fluid model passed through by a visual ray of a virtual camera in a virtual space on the fluid model;
[0007] Setting a bounding box for a target three-dimensional model corresponding to the target fluid model portion;
[0008] Determine a ray path of the visual ray in the bounding box;
[0009] Performing a light stepping analysis according to the fluid density control information and the light path to determine the optical depth information of the target fluid model portion;
[0010] Based on the optical depth information, the target fluid model portion is rendered.
[0011] Further, determining the light path of the visual ray in the bounding box includes:
[0012] Determine the position information of the incident point and the exit point of the visual ray on the bounding box;
[0013] Based on the position information of the incident point and the position information of the exit point, a light path of the visual ray in the bounding box is determined.
[0014] Further, the determining the position information of the incident point and the exit point of the visual ray on the bounding box includes:
[0015] Determining first position information of the bounding box in the virtual space;
[0016] 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 visual ray on the bounding box are determined.
[0017] Further, the determining the first position information of the bounding box in the virtual space includes:
[0018] Acquire third position information of a reference point on the target three-dimensional model in the virtual space, and size information of a bounding box surrounding the target three-dimensional model;
[0019] Based on the third position information and the size information, first position information of the bounding box in the virtual space is determined.
[0020] Further, the fluid density control information includes a mapping relationship between position information in a virtual space and fluid density; and performing light stepping analysis according to the fluid density control information and the light path to determine the optical depth information of the target fluid model portion includes:
[0021] Sampling the light path according to the stepping distance to obtain a plurality of sampling sections and fourth position information of the sampling sections;
[0022] Determine the fluid density corresponding to each of the sampling sections based on the fourth position information and the mapping relationship between the position information in the virtual space and the fluid density;
[0023] Acquiring an optical depth coefficient of the target fluid model portion;
[0024] The optical depth information of the target fluid model portion is determined by performing integral calculation based on the fluid density of each sampling section and the optical depth coefficient.
[0025] Furthermore, there are multiple target fluid model parts, and the fluid model is configured with a target storage space, and obtaining the optical depth coefficient of the target fluid model part includes:
[0026] Determine the first target fluid model portion through which the visual ray passes as the target fluid model portion currently being analyzed;
[0027] Determining an optical depth coefficient of the target fluid model portion currently being analyzed based on a visual ray direction and a light source direction, and storing the optical depth coefficient in the target storage space;
[0028] Determine the target fluid model portion that the visual ray passes through after the target fluid model portion currently being analyzed as a new target fluid model portion currently being analyzed;
[0029] Determine a new optical depth coefficient of the target fluid model portion currently being analyzed based on the visual ray direction, the light source direction, the new position indication information of the target fluid model portion currently being analyzed, and the optical depth coefficient stored in the target storage space, and store the optical depth coefficient in the target storage space;
[0030] The step of determining the target fluid model portion that the visual ray passes through after the target fluid model portion currently being analyzed as a new target fluid model portion currently being analyzed is performed again until the optical depth coefficients of all target fluid model portions are determined.
[0031] Further, before determining the target fluid model portion to be rendered on the fluid model according to the fluid model portion passed by the visual ray of the virtual camera in the virtual space on the fluid model, the method further comprises:
[0032] Obtaining a hit position of a pixel shader on a solid model of the fluid model portion;
[0033] Based on the hit position and the second position information of the virtual camera, a viewing ray direction of the virtual camera is determined.
[0034] Further, before determining the target fluid model portion to be rendered on the fluid model according to the fluid model portion passed by the visual ray of the virtual camera in the virtual space on the fluid model, the method further includes:
[0035] Acquiring dimension information of the fluid model;
[0036] Acquiring three-dimensional model specification information for dividing the fluid model;
[0037] According to the size information and the three-dimensional model specification information, the fluid model is divided into a plurality of fluid model parts, and a three-dimensional model surrounding the fluid model part is provided for each of the fluid model parts.
[0038] Furthermore, 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.
[0039] In a second aspect, an embodiment of the present application provides a model rendering device, comprising:
[0040] A fluid model acquisition module, used 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 of the fluid model parts is provided with a three-dimensional model surrounding the fluid model part, and the fluid density control information is control information for realizing the fitting of the fluid model;
[0041] a target fluid model part determination module, used for determining a target fluid model part to be rendered on the fluid model according to a fluid model part passed through by a visual ray of a virtual camera in a virtual space on the fluid model;
[0042] A bounding box setting module, used to set a bounding box for a target three-dimensional model corresponding to the target fluid model part;
[0043] A light path determination module, used to determine the light path of the visual ray in the bounding box;
[0044] A light stepping analysis module, used for performing light stepping analysis according to the fluid density control information and the light path, to determine the optical depth information of the target fluid model portion;
[0045] A rendering module is used 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 the 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 the steps of any model rendering method.
[0048] In the fifth aspect, an embodiment of the present application also provides a computer program product, including a computer program, which is 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 performs any step of the model rendering method provided in the embodiment of the present application.
[0049] According to the scheme of the embodiment of the present application, a fluid model and fluid density control information of the fluid model can be obtained, wherein the fluid model includes multiple 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 the fitting of the fluid model; according to the fluid model part through which the visual ray of the virtual camera in the virtual space passes on the fluid model, the target fluid model part to be rendered on the fluid model is determined; a bounding box is set for the target stereoscopic model corresponding to the target fluid model part; the light path of the visual ray in the bounding box is determined; according to the fluid density control information and the light path, a light stepping analysis is performed to determine the optical depth information of the target fluid model part; based on the optical depth information, the target fluid model part is rendered. Based on this, by dividing the fluid model into multiple fluid model parts surrounded by the stereoscopic model, the target fluid model part to be rendered is fitted with fluid effects by partitioning blocks, which can be applied to various fluid distribution scenes, and in scenes with uneven fluid distribution, it can effectively reduce performance consumption, improve rendering efficiency, and enhance user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0050] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0051] Figure 1 This is a schematic diagram of an implementation environment scene of the model rendering method provided in an embodiment of the present application;
[0052] Figure 2 This is a flow chart of an embodiment of the model rendering method provided in the embodiments of the present application;
[0053] Figure 3a is a schematic diagram of a three-dimensional model of a fluid model part provided in an embodiment of the present application;
[0054] Figure 3b is another schematic diagram of a three-dimensional model of a fluid model part provided in an embodiment of the present application;
[0055] Figure 3c is another schematic diagram of a three-dimensional model of a fluid model part provided in an embodiment of the present application;
[0056] Figure 3d is another schematic diagram of a three-dimensional model of a fluid model part provided in an embodiment of the present application;
[0057] Figure 3e It is a schematic diagram of the effect of performing fluid fitting on a target fluid model part provided in an embodiment of the present application;
[0058] Figure 3f It is a schematic diagram of the effect of performing fluid fitting on multiple target fluid model parts in an embodiment of the present application;
[0059] Figure 3g is another schematic diagram of the effect of performing fluid fitting on multiple target fluid model parts in an embodiment of the present application;
[0060] Figure 4 is a structural diagram of a model rendering device provided in an embodiment of the present application;
[0061] Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0062] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application. At the same time, in the description of the embodiments of the present application, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance. Thus, the features defined as "first" and "second" may 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 clearly and specifically defined.
[0063] The embodiment of the present application provides 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 or a terminal.
[0064] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. Terminals may include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. Terminals and servers can be directly or indirectly connected via wired or wireless communications, and this application does not limit this.
[0065] See also Figure 1 , taking the integration of the model rendering device into an electronic device as an example, Figure 1 A schematic diagram of an implementation scenario of a model rendering method provided in an embodiment of the present application, 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 multiple fluid model parts, each fluid model part is provided with a stereo model surrounding the fluid model part, and the fluid density control information is control information for realizing the fitting of the fluid model; according to the fluid model part through which the visual ray of the virtual camera in the virtual space passes on the fluid model, the target fluid model part to be rendered on the fluid model is determined; a bounding box is set for the target stereo model corresponding to the target fluid model part; the light path of the visual ray in the bounding box is determined; according to the fluid density control information and the light path, a light stepping analysis is performed to determine the optical depth information of the target fluid model part; based on the optical depth information, the target fluid model part is rendered. Based on this, by dividing the fluid model into multiple fluid model parts surrounded by stereo models, the fluid effect fitting of the fluid model part to be rendered is performed in partition blocks, which can be applied to various fluid distribution scenes, and in scenes with uneven fluid distribution, it can effectively reduce performance consumption, improve rendering efficiency, and enhance user experience.
[0066] It should be noted that Figure 1 The implementation environment scenario diagram of the model rendering method shown is only an example. The implementation environment scenario of the model rendering method described in the embodiment of the present application is to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided by the embodiment of the present application. It is known to those skilled in the art that with the evolution of data processing and the emergence of new business scenarios, the technical solution provided by the present application is also applicable to similar technical problems.
[0067] The solutions provided by the embodiments of the present application are specifically described by the following embodiments. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0068] This embodiment will be described from the perspective of a model rendering device, which may be integrated into an electronic device, which may be a terminal and / or a server, and this application does not limit this.
[0069] See also Figure 2 , Figure 2 The model rendering method provided by the embodiment of the present application, the specific process of the model rendering method can be as follows: Step 101 to Step 106, wherein:
[0070] Step 101, obtain a fluid model and fluid density control information of the fluid model, 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 for realizing the fitting of the fluid model.
[0071] Among them, the fluid model refers to a model of a virtual object with fluid properties in a simulated game screen in a virtual space. The virtual object can be a 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 using the fog model as an example.
[0072] The fluid density control information refers to control information used to implement the fitting of the fluid model.
[0073] Specifically, the fluid density control information includes information related to the fluid density distribution inside the fluid model, and its specific content can be adjusted according to the specific content of the fluid model and actual conditions, and the embodiments of the present application do not limit it.
[0074] There are many ways to obtain fluid density control information, which can be adjusted according to actual conditions and are not limited in the embodiments of the present application.
[0075] Taking the fluid model as a fog model as an example, in some embodiments, the fluid density control information can be used to represent the shape, concentration and distribution of the fog by using a 3D texture. 3D texture refers to a structure that defines data in three-dimensional space, which can be used to store the density information of the fog. Each voxel (volume pixel) contains a density value, which represents the fog concentration at that location. By storing the density value in the 3D texture, the distribution of the fog in space can be accurately controlled. During the rendering process, the 3D texture is used to find the density value to determine the light scattering and absorption effect when the light passes through the fog. The fluid density control information can also be used to represent the shape, concentration and distribution of the fog by using a mathematical modeling algorithm. Among them, the mathematical modeling algorithm includes but is not limited to a signed distance field, a particle system, etc. Among them, a signed distance field is a data structure in which each point stores a signed distance to the nearest surface. Positive values are outside the surface, and negative values are inside the surface. The signed distance field can be used to define the boundary and shape of the fog, and the concentration gradient of the fog is controlled by the distance value. When rendering, a signed distance field is used to determine the interaction between the light and the fog, and to calculate the path length and scattering effect of the light in the fog. For the controllability of the game art effects, preferably, the fluid density control information can be implemented using 3D textures to record information related to the fluid density distribution inside the fluid model.
[0076] It should be noted that the embodiment of the present application performs fitting processing on the fluid model by means of tile fitting.
[0077] Tile fitting refers to dividing a large area into multiple small, usually regular-shaped areas (such as rectangles, triangles, hexagons, etc.) for easy processing, storage or rendering. Each small area is called a "tile".
[0078] To this end, before rendering the fluid model, the fluid model (ie, the large area) needs to be divided into a plurality of fluid model parts, where the fluid model part is used to indicate a partial model in the fluid model.
[0079] The division standard and the division process can be adjusted according to the actual situation, and the embodiment of the present application does not limit it. The fluid model parts obtained after the division can be fluid model parts of the same size or fluid model parts of different sizes.
[0080] In some embodiments, the fluid model may be divided manually. Specifically, the fluid model may be divided into a plurality of fluid model parts by manually combining the shape information and size information of the fluid model, and the shape information and size information of the three-dimensional model surrounding each fluid model part may be determined.
[0081] For example, by determining the approximate shape and size information of the fluid model, selecting a suitable tile shape according to the approximate 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, and obtaining a fluid model portion corresponding to each tile, wherein the shape and size of the fluid model portion correspond to the tile.
[0082] Exemplarily, 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 five triangles indicating corners, and one pentagon indicating a pentagon located in the middle of the five-pointed star, that is, the fluid model is divided into six fluid model parts. It can also be determined that the fluid model is divided into four triangles indicating corners, and one large triangle indicating a pentagon located in the middle of the five-pointed star and the remaining corners, that is, the fluid model is divided into five fluid model parts.
[0083] In some embodiments, it is also possible to obtain size information of the fluid model; obtain specification information of a three-dimensional model used to divide the fluid model; divide the fluid model into multiple fluid model parts according to the size information and the three-dimensional model specification information, and set a three-dimensional model that surrounds the fluid model part for each fluid model part.
[0084] The three-dimensional model specification information includes shape information of the three-dimensional model and size information of the three-dimensional model.
[0085] It should be noted that the shape information of the three-dimensional model can be adjusted according to actual conditions. For example, the shape information indicates that the three-dimensional model includes a fixed shape, such as a regular hexahedron. For another example, the shape information indicates that the three-dimensional model includes multiple fixed shapes, such as a regular hexahedron, a sphere, a cylinder, etc.
[0086] The size information of the three-dimensional model can be adjusted according to the size information of the fluid model and the number of three-dimensional models, and there is no limitation here.
[0087] For example, by determining the size information of the fluid model (i.e., the large area) that needs to be divided, and selecting the appropriate tile size (such as width, length, and height, etc.) according to the size information of the fluid model, the large area where the fluid model is located can be divided into multiple fluid model parts (i.e., small areas, or tiles) that match the tile size according to rows and columns.
[0088] Among them, the three-dimensional model is used to indicate the model surrounding the fluid model part. The shape of the three-dimensional model can be adjusted according to actual conditions, and this application does not impose any restrictions.
[0089] It should be noted that, since the shape of the three-dimensional model is related to the consumption of rendering performance, the three-dimensional model surrounding the fluid model part in the embodiment of the present application can be a three-dimensional model with the smallest area surrounding the fluid model part, or the three-dimensional model surrounding the fluid model part can also be a three-dimensional model that needs to satisfy that the proportion of the fluid model part in the three-dimensional model is greater than the predetermined proportion, and the predetermined proportion can be adjusted according to actual conditions.
[0090] For example, see Figure 3a-3d , Figures 3a to 3d are schematic diagrams of a fluid model part and a three-dimensional model surrounding the fluid model part. Figures 3a to 3d The gray area in the figure indicates the fluid model part. Figure 3a The cube in the figure indicates a three-dimensional model. Figure 3b The hexahedron in the figure indicates a solid model. Figure 3c The cylinder in the figure indicates a three-dimensional model. Figure 3d The three hexahedrons in the figure all indicate a three-dimensional model. Figure 3a-3d It can be seen that using Figure 3a-3c The three-dimensional model shown in the figure surrounds the fluid model part, and there will be many blank areas without fluid inside the three-dimensional model, which will lead to high rendering performance consumption of the subsequent fluid model rendering based on the analysis of the three-dimensional model. Figure 3d The three-dimensional model shown is a three-dimensional model with the smallest area surrounding the fluid model part. Figure 3d The performance consumption required for rendering the fluid model with the three-dimensional model shown is lower than the performance consumption required for rendering the fluid model with the three-dimensional model shown in 3a-3c.
[0091] In some embodiments, in order to avoid over-drawing, 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.
[0092] By fitting the fluid effect through tiles, the fluid performance effect of the partitioned blocks can be fitted. By using the three-dimensional model surrounding the fluid model part to calculate the optical depth information, the calculation range can be flexibly modified by adjusting the shape and number of the three-dimensional model, while reducing the pixel area required for calculation.
[0093] Step 102: Determine a target fluid model portion to be rendered on the fluid model according to the portion of the fluid model that is passed through by the visual ray of the virtual camera in the virtual space.
[0094] The virtual space is a three-dimensional coordinate system used to represent and manipulate three-dimensional objects. The virtual camera is a tool used to capture views in the virtual space, similar to cameras in the real world. The virtual camera defines how to generate a two-dimensional image from a three-dimensional scene.
[0095] The visual ray is a ray extending from the camera position along the camera's line of sight, and is used to determine what the camera sees in the virtual space. The target fluid model portion refers to the fluid model portion to be rendered on the fluid model.
[0096] By determining the portion of the fluid model that the visual ray passes through on the fluid model, the target fluid model portion to be rendered on the fluid model can be determined.
[0097] It should be noted that if the fluid model part that the visual ray passes through on the fluid model is one fluid model part, the number of target fluid model parts is determined to be 1. If the fluid model part that the visual ray passes through on the fluid model 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 to be rendered on the fluid model based on the fluid model part passed by the visual ray of the virtual camera in the virtual space on the fluid model, the model rendering method includes: obtaining the hit position of the pixel shader on the three-dimensional model of the fluid model part; determining the direction of the visual ray of the virtual camera based on the hit position and the second position information of the virtual camera.
[0099] The hit position is used to indicate the position where the pixel shader actually hits on the three-dimensional 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 determining the direction of the visual ray based on the hit position, the target fluid model part to be rendered on the fluid model is determined based on the direction of the visual ray of the virtual camera in the virtual space and the part of the fluid model that the visual ray of the virtual camera in the virtual space passes through on the fluid model. The fluid effect is fitted to the target fluid model part, so that the model rendering scheme can be applicable to various fluid distribution scenarios, and in scenarios with uneven fluid distribution, it can effectively reduce performance consumption, improve rendering efficiency, and enhance user experience.
[0101] Step 103: Set a bounding box for the target three-dimensional model corresponding to the target fluid model part.
[0102] The bounding box indicates a hexahedron used to enclose the target stereo model. The hexahedron may include a regular hexahedron or other regular hexahedrons, which are adjusted according to actual conditions and are not limited in the embodiments of the present application.
[0103] It should be noted that, for various three-dimensional models with convex shapes, there must be a hexahedron that can completely surround the three-dimensional model, and the hexahedron that completely surrounds the three-dimensional model is the bounding box corresponding to the three-dimensional model.
[0104] Step 104: Determine the light path of the visual ray in the bounding box.
[0105] The ray path indicates the path formed by the visual ray of the virtual camera passing through the interior of the bounding box.
[0106] In some embodiments, the process of determining the light path of the visual ray in the bounding box may include determining the position information of the incident point and the exit point of the visual ray on the bounding box; based on the position information of the incident point and the exit point, determining the light path of the visual ray in the bounding box.
[0107] The incident point indicates the intersection point of the visual ray on the bounding box when the visual ray enters the bounding box, and the exit point indicates the intersection point of the visual ray on the bounding box when the visual ray leaves the bounding box.
[0108] Among them, the process of determining the position information of the incident point and the exit point of the visual ray on the bounding box can include determining 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, determining the position information of the incident point and the exit point of the visual ray on the bounding box.
[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 many ways to determine the first position information of the bounding box in the virtual space, which can be adjusted according to actual conditions and are not limited in the embodiments of the present application.
[0111] In some embodiments, the smallest hexahedron that can completely surround the target stereo model can be determined first, and the position information of the smallest hexahedron can be determined by determining the position information of multiple target reference points of the target stereo model in the virtual space and combining the position information of multiple reference points.
[0112] In some embodiments, third position information of a reference point on the target stereo model in the virtual space and size information of a bounding box surrounding the target stereo model can be obtained; based on the third position information and the size information, first position information of the bounding box in the virtual space can be determined.
[0113] The reference point may refer to the center point, the point where the center of mass is located, the point where the center of gravity is located, etc. of the target stereo model. The third position information indicates the position information of the reference point in the virtual space. The size information of the bounding box includes the size specification information such as the length, width, and height of the bounding box, which can be adjusted according to the actual situation and is not limited in the embodiments of the present application.
[0114] The following is an explanation of the process of determining the light path of the visual ray in the bounding box with a specific example, determining the center position and size (such as width, height, depth, etc.) of the hexahedron bounding box, determining the position information of the virtual camera and the direction of the visual ray of the virtual camera, etc. 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. Substitute the ray equation into the plane equation to calculate the intersection of the ray and the plane equation. In addition, it is necessary to determine whether the calculated intersection is located within the six faces of the hexahedron. The determination method can use the algorithm of the point in the polygon, that is, the algorithm of the point in the polygon can be used. Repeat the above steps for each face of the hexahedron, find all possible intersections, and form the determined intersections into the light path of the visual ray in the bounding box. Step 105, according to the fluid density control information and the light path, perform light stepping analysis to determine the optical depth information of the target fluid model part.
[0115] Among them, ray stepping is used to calculate the propagation of light in a medium, which is a fluid.
[0116] The optical depth information indicates the integral of the medium density and the absorption and scattering coefficients over the path from the starting point to the end point in the medium.
[0117] Light attenuation information can be determined based on the optical depth information, wherein the light attenuation information is used to describe the attenuation degree of light when propagating in a medium. In some embodiments, the fluid density control information includes a mapping relationship between position information in a virtual space and fluid density.
[0118] The fluid density control information may use a 3D texture to represent the mapping relationship between the position information in the virtual space and the fluid density, or may use a function corresponding to a signed distance field to represent the mapping relationship between the position information in the virtual space and the fluid density.
[0119] Based on this, the above-mentioned process of performing light stepping analysis based on fluid density control information and light path to determine the optical depth information of the target fluid model part may include: sampling the light path according to the stepping distance to obtain multiple sampling sections and fourth position information of the sampling sections; determining the fluid density corresponding to each sampling section 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 and optical depth coefficient of each sampling section to determine the optical depth information of the target fluid model part.
[0120] The step distance indicates the distance selected by the optical step.
[0121] The sampling segment indicates a line segment obtained by sampling on the light path based on the step distance, that is, a line segment intercepted from the light path starting from the starting point of the light path according to the step distance.
[0122] The fourth position information indicates position information of the sampling section in the virtual space.
[0123] The fluid density indicates the density of the medium in the sampling section. For example, when the medium is fog, the fluid density refers to the fog concentration.
[0124] Among them, the optical depth coefficient refers to a parameter used to describe the ability of light to be absorbed and scattered when propagating in a medium. The optical depth coefficient includes the absorption coefficient and the scattering coefficient, where 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 them by the density of the medium.
[0125] It should be noted that the above process of obtaining the optical depth coefficient of the target fluid model part can be obtained by calculating the dot product between the visual ray direction and the light source direction. The specific process can refer to the prior art.
[0126] Let's take fog as an example. Figure 3e and one For each target fluid model part, there is Figure 3e The figure shown. Among them, the green line indicates the surface of the three-dimensional model where the target fluid model part is located, the magenta line indicates the surface of the bounding box of the three-dimensional model where the target fluid model part is located, and the blue line is the target fluid model part, that is, the area where fog exists. The red line is the visual ray of the virtual camera. The intersection points of the visual ray of the virtual camera and the bounding box include: incident point A and exit point F. The intersection points of the visual ray of the virtual camera and the three-dimensional model include: incident point B and exit point E. The intersection points of the visual ray of the virtual camera and the target fluid model part include: incident point C and exit point D.
[0127] Specifically, according to the position of the model midpoint and the size information of the bounding box, the first distance AF between the visual 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 distance of the vector AF direction, AF is divided into multiple sections, and each section is sampled to obtain the approximate optical depth. According to the optical depth, the corresponding light attenuation effect is obtained.
[0128] Combination 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 virtual camera's visual ray and the bounding box surface obtained by solving the midpoint position of the corresponding stereo 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 exit point of the visual ray on the bounding box are determined; based on the position information of the incident point and the exit point, the light path of the visual ray in the bounding box is determined.
[0130] It should be noted that the camera needs to be displayed inside the model during rendering, so the face needs to be inverted during shading, that is, point E is the actual hit position in the pixel shader. However, since the shape of the three-dimensional model is unknown, the position of point B is uncertain. Therefore, the positions of points C and D can be determined according to the following formula:
[0131]
[0132] Among them, the methods for calculating the position of point C and point D are consistent, and in the above formula, and Same direction, but and The length of is unknown.
[0133] If n→∞ in the above function, the standard case is expressed as follows, that is, A increases the corresponding vector:
[0134]
[0135] The proof is that the above point-finding formula meets mathematical expectations. To this end, when performing ray stepping analysis, the above equation can be fitted with the distance coefficient x (i.e., the stepping distance in the ray stepping) and the number of layers l (i.e., the number of steps in the ray stepping). When l in the equation approaches positive infinity and x in the equation approaches 0, the accuracy of the equation is more in line with expectations, which is expressed as follows:
[0136]
[0137] By performing light stepping according to the above formula, the positions of the fitted points C and D can be determined, and CD is the fog area with concentration. Combining CD and fluid density control information, the optical depth information of the target fluid model part is determined.
[0138] It should be noted that the reason why AC and DF are considered is for performance considerations, so that a section of coefficients l that do not need to be considered can be excluded, that is, to avoid the coefficients being too large or too small.
[0139] In some embodiments, there are multiple target fluid model parts, that is, in the direction of the visual ray of the virtual camera in the virtual space, the visual 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 optical depth information of each target fluid model part is calculated correctly, a target storage space is configured for the above fluid model.
[0141] The target storage space is used to store optical depth information.
[0142] The implementation method of the target storage space can be set according to the actual situation, and the embodiment of the present application does not limit it. For example, a rendering target (RenderTarget, RT) can be created as the target storage space.
[0143] Based on the above content, the process of obtaining the optical depth coefficient of the target fluid model part may include: determining the first target fluid model part passed by the visual ray as the target fluid model part currently being analyzed; determining the optical depth coefficient of the target fluid model part currently being analyzed based on the visual ray direction and the light source direction, and storing the optical depth coefficient in a target storage space; determining the target fluid model part passed by the visual ray after the target fluid model part currently being analyzed as a new target fluid model part currently being analyzed; determining the optical depth coefficient of the new target fluid model part currently being analyzed based on the visual ray direction, the light source direction, 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, and storing the optical depth coefficient in the target storage space; returning to execute the step of determining the target fluid model part passed by the visual ray after the target fluid model part currently being analyzed as the new target fluid model part currently being analyzed, until the optical depth coefficients of all target fluid model parts are determined.
[0144] Specifically, when the three-dimensional models of multiple target fluid model parts need to be superimposed, if the fluid effect of a single three-dimensional model is correct, it is also necessary to ensure that the calculation effect of the three-dimensional models of multiple target fluid model parts is correct, that is, it is necessary to consider whether the occluding effect of the current fluid on the subsequent fluid is correct.
[0145] Let's take fog as an example. Figure 3f , Figure 3g and oneThe specific embodiment is explained. It should be noted that when light passes through fog, various scatterings will occur. The scattering coefficients used in this embodiment include Rayleigh scattering and Mie scattering. Considering Rayleigh scattering and Mie scattering, for the three-dimensional model of each target fluid model part, the scattering coefficient obtained by normal solution can be expressed according to the following formula:
[0146]
[0147] in, Indicates the area through which the line of sight passes through the fog, such as Figure 3f and Figure 3g Region A, Region B and Region C are shown. Indicates the intersection point between the sunlight passing through the fog and the sight line when the sight line passes through the fog area. Figure 3f and Figure 3g As shown, for area A, the intersection points of sunlight passing through the fog to the line of sight include intersection A and intersection B, for area B, the intersection points of sunlight passing through the fog to the line of sight include intersection B, intersection C, intersection E and intersection E, and for area C, the intersection points of sunlight passing through the fog to the line of sight include intersection E and intersection F.
[0148] It should be noted that if Figure 3f and Figure 3g As shown, the blue part is the area where fog exists, and the red line is the visual ray of the virtual camera. The sunlight is taken in from above, and the yellow area is the associated area of the optical depth coefficient. Area A, area B and area C all indicate a target fluid model part.
[0149] In order to calculate correctly when tiles are superimposed, an additional render target (RenderTarget, RT) is created as the target storage space to retain the solved optical depth coefficient. It should be noted that since indefinite calculus is actually not available in computers, accumulation is still used to fit the optical depth coefficient.
[0150] If the target fluid model part currently being analyzed is not the first target fluid model part passed by the visual ray, it is necessary to read the corresponding optical depth coefficient from RT, and store the Rayleigh scattering coefficient and the Mie scattering coefficient respectively 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 for this purpose).
[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] For area A, the intersection points of sunlight passing through the fog to the line of sight include intersection A and intersection B. For area B, the intersection points of sunlight passing through the fog to the line of sight include intersection B, intersection C, intersection E, and intersection E. For area C, the intersection points of sunlight passing through the fog to the line of sight include intersection E and intersection F. Assume that the light source direction is The direction of the visual ray is The origin of the virtual camera is Origin. Combining the above formula, the following process can be determined:
[0154]
[0155] Based on the above formula, when n approaches infinity, the function is equal to the original distance. That is, it can be expressed as follows:
[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 area B (non-yellow area) will be included in the calculation. This will cause errors in the lighting calculation, so it is necessary to calculate the positive domain of the length segment of the function, that is, the BE segment. When our function is clamped and each polynomial only calculates max(0,f(x)), the above equation can actually be expressed as follows:
[0158]
[0159] That is,
[0160] Since AB+BC+DE+EF is the distance through the fog, by substituting the distance coefficient x and the number of layers l of the light step, we can get the following formula:
[0161]
[0162] Similarly, when the number of layers l approaches infinity and the distance coefficient x approaches 0, the above function can be expressed as follows:
[0163]
[0164] Because the light source direction is The direction of the visual ray is And we only consider the positive number domain, so the equation is consistent with the actual integral, and the proof is complete.
[0165] Step 106: Render the target fluid model part based on the optical depth information.
[0166] Specifically, based on the optical depth information, the optical attenuation information is determined, and based on the optical attenuation information, the target fluid model portion is rendered.
[0167] The corresponding light attenuation effect is obtained through the optical depth, so as to render the target fluid model part based on the light attenuation effect.
[0168] By adopting the scheme of the embodiment of the present application, a fluid model and fluid density control information of the fluid model can be obtained, wherein the fluid model includes multiple fluid model parts, each fluid model part is provided with a stereo model surrounding the fluid model part, and the fluid density control information is control information for realizing the fitting of the fluid model; according to the fluid model part through which the visual ray of the virtual camera in the virtual space passes on the fluid model, the target fluid model part to be rendered on the fluid model is determined; a bounding box is set for the target stereo model corresponding to the target fluid model part; the light path of the visual ray in the bounding box is determined; according to the fluid density control information and the light path, a light stepping analysis is performed to determine the optical depth information of the target fluid model part; based on the optical depth information, the target fluid model part is rendered. Based on this, by dividing the fluid model into multiple fluid model parts surrounded by stereo models, the fluid effect fitting of the fluid model part to be rendered is performed by partitioning blocks, which can be applied to various fluid distribution scenes, and in scenes with uneven fluid distribution, it can effectively reduce performance consumption, improve rendering efficiency, and enhance user experience.
[0169] This embodiment also provides a model rendering device, which can be integrated into a terminal device. Figure 4 As shown, the model rendering device may include:
[0170] The fluid model acquisition module 201 is used to acquire the fluid model and the fluid density control information of the fluid model, wherein the fluid model includes a plurality of fluid model parts, each of which is provided with a three-dimensional model surrounding the fluid model part, and the fluid density control information is control information for realizing the fitting of the fluid model;
[0171] A target fluid model part determination module 202 is used to determine a target fluid model part to be rendered on the fluid model according to the fluid model part that the visual ray of the virtual camera in the virtual space passes through on the fluid model;
[0172] A bounding box setting module 203 is used to set a bounding box for a target three-dimensional model corresponding to a target fluid model portion;
[0173] A light path determination module 204, used to determine the light path of the visual ray in the bounding box;
[0174] A light stepping analysis module 205 is used to perform light stepping analysis according to the fluid density control information and the light path to determine the optical depth information of the target fluid model part;
[0175] The rendering module 206 is used to render the target fluid model part based on the optical depth information.
[0176] Optionally, in the device of the embodiment of the present application, the light path determination module 204 includes:
[0177] A position information determination unit, used to determine the position information of the incident point and the exit point of the visual ray on the bounding box;
[0178] The light path determination unit is used to determine the light path of the visual 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 device of the embodiment of the present application, the above-mentioned location information determining unit specifically includes:
[0180] Determine first position information of the bounding box in the virtual space;
[0181] 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 visual ray on the bounding box are determined.
[0182] Optionally, in the device of the embodiment of the present application, the determining the first position information of the bounding box in the virtual space specifically includes:
[0183] Acquire third position information of a reference point on the target three-dimensional model in the virtual space, and size information of a bounding box surrounding the target three-dimensional model;
[0184] Based on the third position information and the size information, first position information of the bounding box in the virtual space is determined.
[0185] Optionally, in the device of an embodiment of the present application, the above-mentioned fluid density control information includes a mapping relationship between position information in the virtual space and fluid density.
[0186] Based on this, the light stepping analysis module 205 includes:
[0187] A sampling unit, used for sampling the light path according to the stepping distance to obtain a plurality of sampling sections and fourth position information of the sampling sections;
[0188] a fluid density determining unit, configured to determine the fluid density corresponding to each sampling section based on the fourth position information and a mapping relationship between the position information in the virtual space and the fluid density;
[0189] An optical depth coefficient acquisition unit, used to acquire an optical depth coefficient of a target fluid model portion;
[0190] The optical depth information determination unit is used to perform integral calculation based on the fluid density of each sampling section and the optical depth coefficient to determine the optical depth information of the target fluid model part.
[0191] Optionally, in the device of the embodiment of the present application, there are multiple target fluid model parts, and the fluid model is configured with a target storage space.
[0192] Based on this, the optical depth coefficient acquisition unit specifically includes:
[0193] Determine the first target fluid model part through which the visual ray passes, as the target fluid model part for current analysis;
[0194] Determine an optical depth coefficient of a portion of a target fluid model currently being analyzed based on a visual ray direction and a light source direction, and store the optical depth coefficient in a target storage space;
[0195] Determine a target fluid model portion that the visual ray passes through after the target fluid model portion currently being analyzed as a new target fluid model portion currently being analyzed;
[0196] Determine a new optical depth coefficient of the target fluid model portion currently being analyzed based on the visual ray direction, the light source direction, the position indication information of the new target fluid model portion currently being analyzed, and the optical depth coefficient stored in the target storage space, and store the optical depth coefficient in the target storage space;
[0197] The step of determining the target fluid model portion that the visual ray passes through after the target fluid model portion currently being analyzed as the new target fluid model portion currently being analyzed is returned to the step of determining the optical depth coefficients of all target fluid model portions.
[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, used for acquiring a hit position of a pixel shader on a three-dimensional model of a fluid model part;
[0200] The visual ray direction determination module is used to determine the visual ray direction of the virtual camera based on the hit position and the 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, used to acquire size information of the fluid model;
[0203] A three-dimensional model specification information acquisition unit, used to acquire three-dimensional model specification information for dividing the fluid model;
[0204] The dividing unit is used to divide the fluid model into a plurality of fluid model parts according to the size information and the three-dimensional model specification information, and to set a three-dimensional model surrounding the fluid model part for each fluid model part.
[0205] Optionally, in the device of the embodiment of the present application, the shape of the above-mentioned 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.
[0206] By adopting the scheme of the embodiment of the present application, a fluid model and fluid density control information of the fluid model can be obtained, wherein the fluid model includes multiple fluid model parts, each fluid model part is provided with a stereo model surrounding the fluid model part, and the fluid density control information is control information for realizing the fitting of the fluid model; according to the fluid model part through which the visual ray of the virtual camera in the virtual space passes on the fluid model, the target fluid model part to be rendered on the fluid model is determined; a bounding box is set for the target stereo model corresponding to the target fluid model part; the light path of the visual ray in the bounding box is determined; according to the fluid density control information and the light path, a light stepping analysis is performed to determine the optical depth information of the target fluid model part; based on the optical depth information, the target fluid model part is rendered. Based on this, by dividing the fluid model into multiple fluid model parts surrounded by stereo models, the fluid effect fitting of the fluid model part to be rendered is performed by partitioning blocks, which can be applied to various fluid distribution scenes, and in scenes with uneven fluid distribution, it can effectively reduce performance consumption, improve rendering efficiency, and enhance user experience.
[0207] Accordingly, an embodiment of the present application further provides an electronic device, which may be a terminal, and the terminal may be a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC, Personal Computer), a personal digital assistant (Personal Digital Assistant, PDA) and other terminal devices. Alternatively, the electronic device may be a server.
[0208] like Figure 5 As shown, Figure 5A schematic diagram of the structure of an electronic device provided in an embodiment 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 in the memory 302 and executable on the processor. The processor 301 is electrically connected to the memory 302. Those skilled in the art will appreciate that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine certain components, or arrange components differently.
[0209] The processor 301 is the control center of the electronic device 300. It uses various interfaces and lines to connect various parts of the entire electronic device 300, and executes various functions and processes data of the electronic device 300 by running or loading software programs and / or units stored in the memory 302, and calling data stored in the memory 302, so as to monitor the electronic device 300 as a whole. The processor 301 can be a central processing unit CPU, a graphics processing unit GPU, a network processor (Network Processor, NP), etc., and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application.
[0210] In the embodiment of the present application, the processor 301 in the electronic device 300 will load instructions corresponding to the processes of one or more application programs into the memory 302 according to the following steps, and the processor 301 will run the application programs stored in the memory 302 to implement various functions, such as:
[0211] 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 three-dimensional model surrounding the fluid model part, and the fluid density control information is control information for realizing fitting of the fluid model;
[0212] Determine a target fluid model portion to be rendered on the fluid model according to the portion of the fluid model that the visual ray of the virtual camera in the virtual space passes through on the fluid model;
[0213] Setting a bounding box for a target solid model corresponding to a portion of the target fluid model;
[0214] Determine the ray path of the visual ray in the bounding box;
[0215] According to the fluid density control information and the light path, a light stepping analysis is performed to determine the optical depth information of the target fluid model part;
[0216] Based on the optical depth information, the target fluid model is partially rendered.
[0217] The electronic device provided by the embodiment of the present application can obtain a fluid model and fluid density control information for the fluid model, wherein the fluid model includes multiple fluid model parts, each fluid model part is provided with a stereo model surrounding the fluid model part, and the fluid density control information is control information for realizing the fitting of the fluid model; according to the fluid model part through which the visual ray of the virtual camera in the virtual space passes on the fluid model, the target fluid model part to be rendered on the fluid model is determined; a bounding box is set for the target stereo model corresponding to the target fluid model part; the light path of the visual ray in the bounding box is determined; according to the fluid density control information and the light path, a light stepping analysis is performed to determine the optical depth information of the target fluid model part; based on the optical depth information, the target fluid model part is rendered. Based on this, by dividing the fluid model into multiple fluid model parts surrounded by stereo models, the fluid effect fitting of the fluid model part to be rendered is performed by partitioning blocks, which can be applied to various fluid distribution scenes, and in scenes with uneven fluid distribution, it can effectively reduce performance consumption, improve rendering efficiency, and enhance user experience.
[0218] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0219] Optional, such as Figure 5 As shown, the electronic device 300 further includes: a touch 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 to the touch 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 Figure 5 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0220] The touch display screen 303 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 303 may include a display panel and a touch panel. Among them, the display panel can be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces 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, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and the like. The touch panel can be used to collect the user's touch operation on or near it (such as the user uses any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch direction, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 301, and can receive the command sent by the processor 301 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 301 to determine the type of touch event, and then the processor 301 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment 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 be used as two independent components to realize the input and output functions. That is, the touch display screen 303 can also be used as a part of the input unit 306 to realize the input function.
[0221] The radio frequency circuit 304 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to send and receive signals with the network device 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 a speaker and a microphone. The audio circuit 305 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal 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 sent to another electronic device through the radio frequency circuit 304, or the audio data is output to the memory 302 for further processing. The audio circuit 305 may also include an earplug jack to provide communication between an external headset and the electronic device.
[0223] The input unit 306 may be configured to receive shapes supported by the stereoscopic model, an upper limit on the number of stereoscopic models, or input information.
[0224] The power supply 307 is used to supply power to various components of the electronic device 300. Optionally, the power supply 307 can be logically connected to the processor 301 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 307 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0225] although Figure 5 Not shown, the electronic device 300 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0226] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0227] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may 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, in which multiple computer programs are stored, and the computer program can be loaded by a processor to execute any model rendering method provided in the embodiment of the present application. The computer program can execute the following steps of the model rendering method:
[0229] 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 three-dimensional model surrounding the fluid model part, and the fluid density control information is control information for realizing fitting of the fluid model;
[0230] Determine a target fluid model portion to be rendered on the fluid model according to the portion of the fluid model that the visual ray of the virtual camera in the virtual space passes through on the fluid model;
[0231] Setting a bounding box for a target solid model corresponding to a portion of the target fluid model;
[0232] Determine the ray path of the visual ray in the bounding box;
[0233] According to the fluid density control information and the light path, a light stepping analysis is performed to determine the optical depth information of the target fluid model part;
[0234] Based on the optical depth information, the target fluid model is partially rendered.
[0235] By using the computer-readable storage medium provided in the embodiment of the present application, a fluid model and fluid density control information of the fluid model can be obtained, wherein the fluid model includes multiple 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 the fitting of the fluid model; according to the fluid model part through which the visual ray of the virtual camera in the virtual space passes on the fluid model, the target fluid model part to be rendered on the fluid model is determined; a bounding box is set for the target stereoscopic model corresponding to the target fluid model part; the light path of the visual ray in the bounding box is determined; according to the fluid density control information and the light path, a light stepping analysis is performed to determine the optical depth information of the target fluid model part; based on the optical depth information, the target fluid model part is rendered. Based on this, by dividing the fluid model into multiple fluid model parts surrounded by the stereoscopic model, the fluid effect fitting is performed on the fluid model part to be rendered by partitioning blocks, which can be applied to various fluid distribution scenes, and in scenes with uneven fluid distribution, it can effectively reduce performance consumption, improve rendering efficiency, and enhance user experience.
[0236] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0237] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0238] Since the computer program stored in the computer-readable storage medium can execute any one of the model rendering methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the model rendering methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0239] According to one aspect of the present application, a computer program product or a computer program is also provided, the computer program product or the computer program including computer instructions, the computer instructions being 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, so that the electronic device executes the methods provided in various optional implementations of the above embodiments.
[0240] In the above-mentioned model rendering device, computer-readable storage medium, electronic device, and computer program product embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, reference can be made to the relevant description of other embodiments. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process and beneficial effects of the above-described model rendering device, computer-readable storage medium, computer program product, electronic device, and its corresponding units can refer to the description of the model rendering method in the above embodiment, and will not be repeated here.
[0241] The above is a detailed introduction to a model rendering method, device, electronic device, computer-readable storage medium and computer program product provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A model rendering method, characterized in that: The method comprises: 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 of the fluid model parts is provided with a three-dimensional 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 portion to be rendered on the fluid model according to a portion of the fluid model passed through by a visual ray of a virtual camera in a virtual space on the fluid model; Setting a bounding box for a target three-dimensional model corresponding to the target fluid model portion; Determine a ray path of the visual ray in the bounding box; Performing a light stepping analysis according to the fluid density control information and the light path to determine the optical depth information of the target fluid model portion; Based on the optical depth information, the target fluid model portion is rendered.
2. The model rendering method according to claim 1, characterized in that: Determining the light path of the visual ray in the bounding box includes: Determine the position information of the incident point and the exit point of the visual ray on the bounding box; Based on the position information of the incident point and the position information of the exit point, a light path of the visual ray in the bounding box is determined.
3. The model rendering method according to claim 2, characterized in that: The determining of the position information of the incident point and the exit point of the visual ray on the bounding box includes: Determining 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 visual ray on the bounding box are determined.
4. The model rendering method according to claim 3, characterized in that: The determining the first position information of the bounding box in the virtual space includes: Acquire third position information of a reference point on the target three-dimensional model in the virtual space, and size information of a bounding box surrounding the target three-dimensional model; Based on the third position information and the size information, first position information of the bounding box in the virtual space is determined.
5. The model rendering method according to claim 1, characterized in that: The fluid density control information includes a mapping relationship between position information in a virtual space and fluid density. The optical depth information of the target fluid model portion is determined by performing a light stepping analysis based on the fluid density control information and the light path, including: Sampling the light path according to the stepping distance to obtain a plurality of sampling sections and fourth position information of the sampling sections; Determine the fluid density corresponding to each of the sampling sections based on the fourth position information and the mapping relationship between the position information in the virtual space and the fluid density; Acquiring an optical depth coefficient of the target fluid model portion; The optical depth information of the target fluid model portion is determined by performing integral calculation based on the fluid density of each sampling section and the optical depth coefficient.
6. The model rendering method according to claim 5, characterized in that: There are multiple target fluid model parts, the fluid model is configured with a target storage space, and obtaining the optical depth coefficient of the target fluid model part includes: Determine the first target fluid model portion through which the visual ray passes as the target fluid model portion currently being analyzed; Determining an optical depth coefficient of the target fluid model portion currently being analyzed based on a visual ray direction and a light source direction, and storing the optical depth coefficient in the target storage space; Determine the target fluid model portion that the visual ray passes through after the target fluid model portion currently being analyzed as a new target fluid model portion currently being analyzed; Determine a new optical depth coefficient of the target fluid model portion currently being analyzed based on the visual ray direction, the light source direction, the new position indication information of the target fluid model portion currently being analyzed, and the optical depth coefficient stored in the target storage space, and store the optical depth coefficient in the target storage space; The step of determining the target fluid model portion that the visual ray passes through after the target fluid model portion currently being analyzed as a new target fluid model portion currently being analyzed is performed again until the optical depth coefficients of all target fluid model portions are 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 according to the fluid model portion passed by the visual ray of the virtual camera in the virtual space on the fluid model, the method includes: Obtaining a hit position of a pixel shader on a solid model of the fluid model portion; Based on the hit position and the second position information of the virtual camera, a viewing ray direction of the virtual camera is determined.
8. 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 according to the fluid model portion passed by the visual ray of the virtual camera in the virtual space on the fluid model, the method further includes: Acquiring dimension information of the fluid model; Acquiring three-dimensional model specification information for dividing the fluid model; According to the size information and the three-dimensional model specification information, the fluid model is divided into a plurality of fluid model parts, and a three-dimensional model surrounding the fluid model part is provided for each of the fluid model parts.
9. The model rendering method according to any one of claims 1 to 8, 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.
10. A model rendering device, characterized in that: The device comprises: A fluid model acquisition module, used 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 of the fluid model parts is provided with a three-dimensional model surrounding the fluid model part, and the fluid density control information is control information for realizing the fitting of the fluid model; a target fluid model part determination module, used for determining a target fluid model part to be rendered on the fluid model according to a fluid model part passed through by a visual ray of a virtual camera in a virtual space on the fluid model; A bounding box setting module, used to set a bounding box for a target three-dimensional model corresponding to the target fluid model part; A light path determination module, used to determine the light path of the visual ray in the bounding box; A light stepping analysis module, used for performing light stepping analysis according to the fluid density control information and the light path, to determine the optical depth information of the target fluid model portion; A rendering module is used to render the target fluid model part based on the optical depth information.
11. An electronic device, characterized in that: It comprises 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 the steps of the model rendering method described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: It includes a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the model rendering method described in any one of claims 1 to 9.
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
Scene rendering method and device, equipment, medium and program product
CN118674850A
Scene rendering method and apparatus, electronic device, and storage medium
WO2023231215A1