A layered rendering method and related apparatus for 3D models
By obtaining the face normal position and transparency of the 3D model, calculating the rendering level and performing rendering, the problem of incorrect rendering of semi-transparent faces in the 3D model is solved, and the display effect of the model is improved.
Patent Information
- Application Number
- CN202510874377.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-27
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2045-06-27
AI Technical Summary
In the virtual engine, the semi-transparent surfaces of a 3D model are treated as being on the same level, resulting in incorrect rendering and causing the display hierarchy to be disordered.
By acquiring the model surface description information of the 3D model, including the position of the surface normals and the transparency, the rendering level of each model surface is calculated, and rendering is performed according to the rendering level and transparency. Model textures are generated and 2D mapping is performed to determine the rendering order of the model surfaces.
The rendering layout of semi-transparent surfaces in the 3D model has been optimized, resolving the rendering error caused by treating semi-transparent surfaces as the same layer, and improving the display effect of the model.
Smart Images

Figure CN120388126B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of three-dimensional virtual reconstruction technology, and in particular to a layered rendering method and related apparatus for three-dimensional models. Background Technology
[0002] In a virtual engine, a 3D model is recognized as an object and a layer during rendering. When a 3D model contains semi-transparent surfaces, overlapping semi-transparent surfaces will result in incorrect rendering because they are treated as the same layer, and the layer order of the semi-transparent surfaces cannot be adjusted, leading to a problem of disordered display hierarchy. Summary of the Invention
[0003] In view of the above problems, this application provides a method and related apparatus for layered rendering of 3D models to achieve the purpose of layered rendering of 3D models. The specific solution is as follows:
[0004] The first aspect of this application provides a layered rendering method for a three-dimensional model, the layered rendering method for the three-dimensional model comprising:
[0005] Load the target 3D model to be rendered. The target 3D model contains multiple model vertices and multiple model faces. Each model face is a closed region composed of three adjacent model vertices.
[0006] Obtain the model surface description information of the target 3D model, which includes the position of the surface normal and the transparency of each model surface;
[0007] The rendering level of each model face is calculated based on the position of the face normal of each model face, and rendering is performed according to the rendering level and transparency of each model face.
[0008] In one possible implementation, obtaining the model surface description information of the target 3D model includes:
[0009] Generate a model texture map of the target 3D model. The model texture map contains multiple UV regions, each of which corresponds to one of the multiple model faces. Each UV region records the face normal position and transparency of the corresponding model face.
[0010] The multiple UV regions are read sequentially, and the face normal position and transparency of the corresponding model face are obtained from the read UV regions.
[0011] In one possible implementation, generating the model texture of the target 3D model includes:
[0012] Based on the vertex positions of the three model vertices that make up each model face in the first three-dimensional space, calculate the face normal position of each model face. The first three-dimensional space is the three-dimensional space used for cutting the face normal space.
[0013] Get the transparency of each model face;
[0014] The face normal position and transparency of each model face are used as RGBA channel values to generate a face map for each model face;
[0015] A UV view is obtained by performing a two-dimensional mapping on the target three-dimensional model, and the UV view records the UV regions mapped to each model face;
[0016] The surface texture of each model face is filled into the mapped UV area to generate the model texture.
[0017] In one possible implementation, calculating the rendering level of each model face based on the face normal position of each model face includes:
[0018] The position of the face normal of each model face is transformed to the second three-dimensional space to obtain the new face normal position of each model face. The second three-dimensional space is the three-dimensional space used for model rendering.
[0019] Obtain the camera position of the virtual camera in the second three-dimensional space, and calculate the distance between each model surface and the virtual camera based on the camera position and the new surface normal position of each model surface;
[0020] The rendering level of each model face is determined based on the distance between each model face and the virtual camera. The rendering level of each model face is negatively correlated with its distance from the virtual camera.
[0021] A second aspect of this application provides a layered rendering apparatus for a three-dimensional model, the layered rendering apparatus for the three-dimensional model comprising:
[0022] The model loading module is used to load the target 3D model to be rendered. The target 3D model contains multiple model vertices and multiple model faces. Each model face is a closed region composed of three adjacent model vertices.
[0023] The information acquisition module is used to acquire the model surface description information of the target 3D model, which includes the position of the surface normal and the transparency of each model surface;
[0024] The rendering module is used to calculate the rendering level of each model face based on the position of the face normal of each model face, and to render according to the rendering level and transparency of each model face.
[0025] In one possible implementation, the information acquisition module is specifically used for:
[0026] Generate a model texture map of the target 3D model. The model texture map contains multiple UV regions, each of which corresponds to a different model face. Each UV region records the face normal position and transparency of the corresponding model face. Read the multiple UV regions sequentially and obtain the face normal position and transparency of the corresponding model face from the read UV regions.
[0027] In one possible implementation, the information acquisition module for generating the model texture of the target 3D model is specifically used for:
[0028] Based on the vertex positions of the three model vertices that make up each model face in the first three-dimensional space, calculate the face normal position of each model face. The first three-dimensional space is a three-dimensional space used for cutting the face normal space. Obtain the transparency of each model face. Use the face normal position and transparency of each model face as RGBA channel values to generate a face map for each model face. Perform two-dimensional mapping on the target three-dimensional model to obtain a UV view. The UV view records the UV region of each model face that is mapped. Fill the face map of each model face into the mapped UV region to generate the model map.
[0029] A third aspect of this application provides a computer program product including computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the layered rendering method of a three-dimensional model according to the first aspect or any implementation thereof.
[0030] A fourth aspect of this application provides an electronic device, comprising at least one processor and a memory connected to the processor, wherein:
[0031] The memory is used to store computer programs;
[0032] The processor is used to execute the computer program so that the electronic device can implement the layered rendering method of the three-dimensional model of the first aspect or any implementation thereof.
[0033] The fifth aspect of this application provides a computer storage medium carrying one or more computer programs, which, when executed by an electronic device, enable the electronic device to implement the layered rendering method of the three-dimensional model described in the first aspect or any implementation thereof.
[0034] By employing the above technical solution, this application provides a layered rendering method and related apparatus for a 3D model. The method involves loading a target 3D model to be rendered, which includes multiple model vertices and multiple model faces. Each model face is a closed region composed of three adjacent model vertices. The method obtains the model face description information of the target 3D model, which includes the face normal position and transparency of each model face. It calculates the rendering level of each model face based on its face normal position and renders according to the rendering level and transparency of each model face. This application can divide a 3D model into different model faces according to its model vertices, thereby obtaining the face normal position and transparency of the model faces. Furthermore, it determines the rendering level of the model face based on its face normal position and finally renders the model face based on this rendering level and transparency. This maintains the layered stacking relationship of semi-transparent faces in the 3D model, optimizes the rendering arrangement of semi-transparent faces in the 3D model, solves the problem of incorrect rendering caused by treating semi-transparent faces as the same level, and improves the appearance and display effect of the model. Attached Figure Description
[0035] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.
[0036] Figure 1 A flowchart illustrating a layered rendering method for a three-dimensional model provided in an embodiment of this application;
[0037] Figure 2 An example diagram of a model surface provided in an embodiment of this application;
[0038] Figure 3 A partial flowchart illustrating a layered rendering method for a 3D model provided in an embodiment of this application;
[0039] Figure 4 This is another part of the flowchart illustrating a layered rendering method for a three-dimensional model provided in an embodiment of this application;
[0040] Figure 5 A three-dimensional space example diagram provided for an embodiment of this application;
[0041] Figure 6 An example diagram of a two-dimensional mapping provided in this application embodiment;
[0042] Figure 7 Another flowchart illustrating a layered rendering method for a three-dimensional model provided in an embodiment of this application;
[0043] Figure 8A schematic diagram of the structure of a layered rendering device for a three-dimensional model provided in an embodiment of this application;
[0044] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0045] The embodiments of this application are described below with reference to the accompanying drawings. The terminology used in the implementation section of this application is for explaining specific embodiments only and is not intended to limit the scope of this application.
[0046] The embodiments of this application will now be described with reference to the accompanying drawings. Those skilled in the art will recognize that, with technological advancements and the emergence of new scenarios, the technical solutions provided in the embodiments of this application are equally applicable to similar technical problems.
[0047] The terms "first," "second," etc., used in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such terms are interchangeable where appropriate; this is merely a way of distinguishing objects with the same attributes in the embodiments of this application. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion, so that a process, method, system, product, or apparatus that comprises a series of units is not necessarily limited to those units, but may include other units not explicitly listed or inherent to those processes, methods, products, or apparatuses.
[0048] See Figure 1 , Figure 1 This is a flowchart illustrating a layered rendering method for a 3D model provided in an embodiment of this application. Figure 1 As shown in the embodiment of this application, a layered rendering method for a three-dimensional model can be applied to a rendering engine and may include steps S101 to S103, which are described in detail below.
[0049] S101, Load the target 3D model to be rendered. The target 3D model contains multiple model vertices and multiple model faces. Each model face is a closed region composed of three adjacent model vertices.
[0050] In this embodiment, the target 3D model is a 3D model to be rendered. The user can import the target 3D model into the rendering engine, which will then load the target 3D model. Furthermore, the target 3D model contains multiple model vertices, and any closed region formed by three adjacent model vertices can serve as a model face.
[0051] See Figure 2 , Figure 2This is an example diagram of a model surface provided for an embodiment of this application. For example... Figure 2 As shown, when the target 3D model is a sphere, adjacent model vertices A, B, and C can form a model surface.
[0052] S102, Obtain the model surface description information of the target 3D model. The model surface description information includes the position of the surface normal and the transparency of each model surface.
[0053] In this embodiment, after loading the target 3D model, multiple model vertices and multiple model faces can be determined. Furthermore, by performing surface normal vector space segmentation on the target 3D model, the position of the surface normal for each model face can be calculated, and the transparency of each model face can be defined, thereby obtaining model face description information.
[0054] It should be noted that the position of a surface normal is the vector position of the corresponding model surface in three-dimensional space, which includes three positional components along the x, y, and z axes. Therefore, the model surface description information includes information about each model surface in four dimensions: the three positional components along the x, y, and z axes, and its transparency.
[0055] In one possible implementation, to achieve accurate and efficient information retrieval, model surface description information can be recorded using model textures. See also Figure 3 , Figure 3 This is a partial flowchart illustrating a layered rendering method for a 3D model provided in an embodiment of this application. Figure 3 As shown in the embodiment of this application, a layered rendering method for a three-dimensional model is provided. In step S102, "obtaining the model surface description information of the target three-dimensional model" may include steps S201 to S202. These steps are described in detail below.
[0056] S201, Generate the model texture of the target 3D model. The model texture contains multiple UV regions, which correspond one-to-one with multiple model faces. Each UV region records the position of the face normal and the transparency of the corresponding model face.
[0057] In this embodiment of the application, the position and transparency of the surface normals of all model faces in the target 3D model can be recorded in the model texture. Specifically, the model texture can be divided into multiple UV regions that correspond one-to-one with multiple model faces, and the position and transparency of the surface normals of the corresponding model face can be recorded in each UV region.
[0058] It should be noted that each UV region in the model texture is obtained by performing a two-dimensional mapping on the corresponding model face using UV mapping. Furthermore, the values for the face normal position and transparency recorded in the UV region are both in the range of 0 to 1.
[0059] Since current mainstream storage methods do not support adding custom content, this application uses the RGBA (Red, Green, Blue, Alpha) information storage method to generate model textures. See [link / reference] Figure 4 , Figure 4 This is another part of the flowchart illustrating a layered rendering method for a 3D model provided in an embodiment of this application. For example... Figure 4 As shown in the embodiment of this application, a layered rendering method for a three-dimensional model is provided. Step S201, "generating a model texture map of the target three-dimensional model", may include steps S301 to S305. These steps are described in detail below.
[0060] S301, calculate the position of the surface normal of each model surface based on the vertex positions of the three model vertices that make up each model surface in the first three-dimensional space. The first three-dimensional space is the three-dimensional space used for cutting the surface normal space.
[0061] See Figure 5 , Figure 5 This is an example diagram of a three-dimensional space provided for an embodiment of this application. For example... Figure 5 As shown, when the target 3D model is a sphere, its surrounding space can be divided into 3D vectors, and the directions and value ranges of the three axes x, y, and z can be set (minimum value is 0, maximum value is 1) to obtain the 3D space (i.e. the first 3D space) for cutting the surface normal space.
[0062] See also Figure 2 ,exist Figure 2 In the first three-dimensional space shown, the vertex positions of model vertices A, B, and C can be determined. Let's assume the vertex position of model vertex A is... The vertex position of vertex B in the model is The vertex position of vertex C in the model is Then, the position of the centroid G of the model surface formed by model vertices A, B, and C can be calculated. Draw a perpendicular line P from the centroid G. This perpendicular line P is the surface normal of the model face formed by model vertices A, B, and C. Therefore, the position of the surface normal is... The direction is generally set to face outwards from the sphere.
[0063] Based on this, the position of the surface normal of each model surface can be calculated, and the position of the surface normal is located in the first three-dimensional space.
[0064] S302, obtain the transparency of each model face.
[0065] In this embodiment, the transparency of each model face can be set according to actual needs, and the transparency is normalized, with a value range of 0 to 1. Specifically, when the transparency is 1, the model face is opaque; when the transparency is 0, the model face is fully transparent; and when the transparency is between 0 and 1, the model face is semi-transparent.
[0066] S303 uses the face normal position and transparency of each model face as RGBA channel values to generate a face texture for each model face.
[0067] In this embodiment, the surface normal position of each model face includes three positional components along the x, y, and z axes. Therefore, these three positional components can be used as RGB channel values. Additionally, the transparency of each model face is used as the A channel value, thereby generating a surface texture for each model face. In other words, the surface texture of each model face contains RGBA channels, where the RGB channel values represent the surface normal position of each model face, and the A channel value represents the transparency of each model face.
[0068] S304, perform two-dimensional mapping on the target 3D model to obtain a UV view, which records the UV area mapped to each model face.
[0069] In this embodiment, UV mapping is used to perform two-dimensional mapping on the target 3D model, thereby obtaining a UV view corresponding to the target 3D model. This UV view contains the UV regions mapped to each model face. See also Figure 6 , Figure 6 This is an example diagram of a two-dimensional mapping provided in an embodiment of this application. Figure 6 As shown, when the target 3D model is a sphere, its corresponding UV view can be obtained by performing 2D mapping on it. A model surface of the target 3D model is mapped to a UV region in the UV view, and the two have a mapping relationship.
[0070] S305 fills the surface texture of each model face into the mapped UV area to generate a model texture.
[0071] In this embodiment, according to the UV region of each model face in the UV view, its face texture can be filled into that UV region. After the face textures of all model faces are filled, the model texture of the target 3D model can be obtained.
[0072] S202, reads multiple UV regions sequentially, and obtains the face normal position and transparency of the corresponding model face from the read UV regions.
[0073] In this embodiment, for multiple UV regions in the model texture, the textures within each UV region can be read in a certain order, and the face normal positions and transparency of the corresponding model faces can be obtained from the read UV regions. This process continues until all UV regions in the model texture have been read, thus obtaining the face normal positions and transparency of all model faces of the target 3D model.
[0074] S103 calculates the rendering level of each model face based on the position of the face normal of each model face, and renders according to the rendering level and transparency of each model face.
[0075] In this embodiment, after obtaining the position of the surface normal of each model face, the distance to the virtual camera can be calculated based on that surface normal position. The rendering level of each model face is determined according to its distance from the virtual camera; the closer to the virtual camera, the higher the rendering level. Each model face is rendered separately according to its transparency, in ascending order of rendering level (i.e., in order of distance from the virtual camera), and the images are displayed by overlaying them. This allows for precise division of the rendering levels of different model faces (including semi-transparent faces), preventing rendering errors caused by treating them as the same level, ensuring normal display of the image, and achieving higher accuracy.
[0076] In one possible implementation, the 3D space used for model rendering often differs from the 3D space used for face normal space cutting. Therefore, a spatial transformation is needed for the face normal positions of each model face to calculate the rendering level of each model face. This allows for real-time acquisition of the current positional relationship between the target 3D model and the virtual camera, ensuring that the final effect is not affected even if the target 3D model moves and rotates continuously. See also Figure 7 , Figure 7 This is another schematic diagram illustrating a layered rendering method for a 3D model provided in an embodiment of this application. For example... Figure 7 As shown in the embodiment of this application, a layered rendering method for a three-dimensional model is provided. In step S103, "calculating the rendering level of each model surface based on the position of the surface normal of each model surface" may include steps S401 to S403. These steps are described in detail below.
[0077] S401 transforms the position of the face normal of each model face to the second three-dimensional space to obtain the new face normal position of each model face. The second three-dimensional space is the three-dimensional space used for model rendering.
[0078] In this embodiment, the position of the surface normal of each model face is transformed to the three-dimensional space used for model rendering (i.e., the second three-dimensional space). It is assumed that the origin of the first three-dimensional space is... The origin of the second three-dimensional space is Origin of space Compared to the origin of space The translation matrix is The rotation matrix is The scaling matrix is Then, the normal position of each model face can be translated, rotated, and scaled to obtain the new normal position of each model face.
[0079] Continuing with the position of the surface normal as For example, the position of the normal to the new face is .
[0080] Of course, in some scenarios, each vertex of the target 3D model can be transformed from the first 3D space to the second 3D space first, and then the new normal position of each model face can be calculated based on the transformed model vertices. This application does not limit this.
[0081] S402, obtain the camera position of the virtual camera in the second three-dimensional space, and calculate the distance between each model surface and the virtual camera based on the camera position and the position of the new surface normal of each model surface.
[0082] In this embodiment, the camera position of the virtual camera in the second three-dimensional space can be obtained, and then the distance between each model surface and the virtual camera can be calculated based on the new normal position of each model surface and the camera position.
[0083] Assuming camera position for The new normal position of a certain model surface for Then the distance between the model surface and the virtual camera .
[0084] S403 determines the rendering level of each model face based on its distance from the virtual camera. The rendering level of each model face is negatively correlated with its distance from the virtual camera.
[0085] In this embodiment, the distance between each model face and the virtual camera is sorted. The greater the distance, the farther the model face is from the virtual camera, and the higher its rendering level. This allows for the rendering sorting of all model faces in the target 3D model, with higher rendering levels resulting in earlier rendering order.
[0086] Based on the above description, the layered rendering method for a 3D model provided in this application can calculate the positions of the surface normals of different model faces in a 3D model and store them in the RGBA channels of their respective UV regions, combined with their transparency, to form a model texture. During rendering, the positions of the surface normals of different model faces can be determined by reading the RGBA channel values in different UV regions of the model texture. This allows for the determination of the rendering layer and optimization of the rendering arrangement of semi-transparent faces in the 3D model, resolving the problem of incorrect rendering caused by treating semi-transparent faces as the same layer, and improving the appearance and display effect of the model.
[0087] The above describes a layered rendering method for a three-dimensional model provided by an embodiment of this application. The following describes the apparatus for performing the above-described layered rendering method for a three-dimensional model.
[0088] See Figure 8 , Figure 8 This is a schematic diagram of the structure of a layered rendering device for a three-dimensional model provided in an embodiment of this application. Figure 8 As shown in the embodiment of this application, a layered rendering apparatus for a three-dimensional model includes:
[0089] The model loading module 501 is used to load the target 3D model to be rendered. The target 3D model contains multiple model vertices and multiple model faces. Each model face is a closed region composed of three adjacent model vertices.
[0090] The information acquisition module 502 is used to acquire the model surface description information of the target 3D model. The model surface description information includes the position of the surface normal and the transparency of each model surface.
[0091] Rendering module 503 is used to calculate the rendering level of each model face based on the position of the face normal of each model face, and to render according to the rendering level and transparency of each model face.
[0092] In one possible implementation, the information acquisition module 502 is specifically used for:
[0093] Generate a model texture map of the target 3D model. The model texture map contains multiple UV regions, which correspond one-to-one with multiple model faces. Each UV region records the face normal position and transparency of the corresponding model face. Read multiple UV regions sequentially and obtain the face normal position and transparency of the corresponding model face from the read UV regions.
[0094] In one possible implementation, the model texture information acquisition module 502 used to generate the target 3D model is specifically used for:
[0095] Based on the vertex positions of the three model vertices that make up each model face in the first 3D space, calculate the face normal position of each model face. The first 3D space is the 3D space used for cutting the face normal space. Obtain the transparency of each model face. Use the face normal position and transparency of each model face as RGBA channel values to generate a face map for each model face. Perform 2D mapping on the target 3D model to obtain a UV view. The UV view records the UV region that is mapped for each model face. Fill the face map of each model face into the mapped UV region to generate a model texture.
[0096] In one possible implementation, the rendering module 503, used to calculate the rendering level of each model face based on the face normal position of each model face, is specifically used for:
[0097] The normal position of each model face is transformed to a second 3D space to obtain a new normal position for each model face. The second 3D space is the 3D space used for model rendering. The camera position of the virtual camera in the second 3D space is obtained, and the distance between each model face and the virtual camera is calculated based on the camera position and the new normal position of each model face. The rendering level of each model face is determined based on the distance between each model face and the virtual camera. The rendering level of each model face is negatively correlated with its distance from the virtual camera.
[0098] It should be noted that the detailed functions of each module in the embodiments of this application can be found in the corresponding disclosure of the above-mentioned three-dimensional model layered rendering method embodiments, and will not be repeated here.
[0099] This application also provides an electronic device in its embodiments. See [link to relevant documentation]. Figure 9 , Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. The electronic device in this embodiment may include, but is not limited to, fixed terminals such as mobile phones, laptops, PDAs (personal digital assistants), PADs (tablet computers), desktop computers, etc. Figure 9 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.
[0100] like Figure 9As shown, the electronic device may include a processing unit (e.g., a central processing unit, a graphics processing unit, etc.) 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 602 or a program loaded from a storage device 608 into a random access memory (RAM) 603. When the electronic device is powered on, the RAM 603 also stores various programs and data required for the operation of the electronic device. The processing unit 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0101] Typically, the following devices can be connected to I / O interface 605: input devices 606 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 607 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 608 including, for example, memory cards, hard drives, etc.; and communication devices 609. Communication device 609 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. Although Figure 9 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown. More or fewer devices may be implemented or have alternatively.
[0102] This application also provides a computer program product including computer-readable instructions, which, when executed on an electronic device, cause the electronic device to implement any of the layered rendering methods for three-dimensional models provided in this application.
[0103] This application also provides a computer-readable storage medium that carries one or more computer programs. When the one or more computer programs are executed by an electronic device, the electronic device can implement any of the layered rendering methods for three-dimensional models provided in this application.
[0104] It should also be noted that the device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. In addition, in the device embodiment drawings provided in this application, the connection relationship between modules indicates that they have a communication connection, which can be implemented as one or more communication buses or signal lines.
[0105] Through the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware, or it can be implemented by special-purpose hardware including application-specific integrated circuits, special-purpose CPUs, special-purpose memory, special-purpose components, etc. Generally, any function performed by a computer program can be easily implemented by corresponding hardware, and the specific hardware structure used to implement the same function can also be diverse, such as analog circuits, digital circuits, or special-purpose circuits. However, for this application, software program implementation is more often the preferred implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a readable storage medium, such as a computer floppy disk, USB flash drive, mobile hard disk, ROM, RAM, magnetic disk, or optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, training equipment, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0106] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product.
[0107] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions may be transmitted from one website, computer, training device, or data center to another website, computer, training device, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a training device or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state drives (SSDs)).
Claims
1. A layered rendering method for a 3D model, characterized in that, The layered rendering method for the 3D model includes: Load the target 3D model to be rendered. The target 3D model contains multiple model vertices and multiple model faces. Each model face is a closed region composed of three adjacent model vertices. Obtain the model surface description information of the target 3D model, which includes the position of the surface normal and the transparency of each model surface; The rendering level of each model face is calculated based on the position of the face normal of each model face, and rendering is performed according to the rendering level and transparency of each model face. The rendering level of each model face is calculated based on the position of its normal, including: The normal position of each model face is transformed to the second three-dimensional space to obtain the new normal position of each model face; or, each model vertex of the target three-dimensional model is transformed from the first three-dimensional space to the second three-dimensional space, and the new normal position of each model face is calculated based on the transformed model vertices. The second three-dimensional space is the three-dimensional space used for model rendering. Obtain the camera position of the virtual camera in the second three-dimensional space, and calculate the distance between each model surface and the virtual camera based on the camera position and the new surface normal position of each model surface; The rendering level of each model face is determined based on the distance between each model face and the virtual camera. The rendering level of each model face is negatively correlated with its distance from the virtual camera.
2. The layered rendering method for a three-dimensional model according to claim 1, characterized in that, The step of obtaining the model surface description information of the target 3D model includes: Generate a model texture map of the target 3D model. The model texture map contains multiple UV regions, each of which corresponds to one of the multiple model faces. Each UV region records the face normal position and transparency of the corresponding model face. The multiple UV regions are read sequentially, and the face normal position and transparency of the corresponding model face are obtained from the read UV regions.
3. The layered rendering method for a three-dimensional model according to claim 2, characterized in that, The generation of the model texture of the target 3D model includes: Based on the vertex positions of the three model vertices that make up each model face in the first three-dimensional space, calculate the face normal position of each model face. The first three-dimensional space is the three-dimensional space used for cutting the face normal space. Get the transparency of each model face; The face normal position and transparency of each model face are used as RGBA channel values to generate a face map for each model face; A UV view is obtained by performing a two-dimensional mapping on the target three-dimensional model, and the UV view records the UV regions mapped to each model face; The surface texture of each model face is filled into the mapped UV area to generate the model texture.
4. A layered rendering device for a three-dimensional model, characterized in that, The layered rendering device for the 3D model includes: The model loading module is used to load the target 3D model to be rendered. The target 3D model contains multiple model vertices and multiple model faces. Each model face is a closed region composed of three adjacent model vertices. The information acquisition module is used to acquire the model surface description information of the target 3D model, which includes the position of the surface normal and the transparency of each model surface; The rendering module is used to calculate the rendering level of each model face based on the position of the face normal of each model face, and to render according to the rendering level and transparency of each model face. The rendering module, which calculates the rendering level of each model face based on the position of its surface normal, is specifically used for: The normal position of each model face is transformed to the second three-dimensional space to obtain the new normal position of each model face; or, each model vertex of the target three-dimensional model is transformed from the first three-dimensional space to the second three-dimensional space, and the new normal position of each model face is calculated based on the transformed model vertices. The second three-dimensional space is the three-dimensional space used for model rendering. Obtain the camera position of the virtual camera in the second three-dimensional space, and calculate the distance between each model surface and the virtual camera based on the camera position and the new surface normal position of each model surface; The rendering level of each model face is determined based on the distance between each model face and the virtual camera. The rendering level of each model face is negatively correlated with its distance from the virtual camera.
5. The layered rendering device for a three-dimensional model according to claim 4, characterized in that, The information acquisition module is specifically used for: Generate a model texture map of the target 3D model. The model texture map contains multiple UV regions, each of which corresponds to one of the multiple model faces. Each UV region records the face normal position and transparency of the corresponding model face. The multiple UV regions are read sequentially, and the face normal position and transparency of the corresponding model face are obtained from the read UV regions.
6. The layered rendering apparatus for a three-dimensional model according to claim 5, characterized in that, The information acquisition module used to generate the model texture of the target 3D model is specifically used for: Based on the vertex positions of the three model vertices that make up each model face in the first three-dimensional space, calculate the face normal position of each model face. The first three-dimensional space is a three-dimensional space used for cutting the face normal space. Obtain the transparency of each model face. Use the face normal position and transparency of each model face as RGBA channel values to generate a face map of each model face. Perform two-dimensional mapping on the target three-dimensional model to obtain a UV view. The UV view records the UV regions mapped to each model face. The surface texture of each model face is filled into the mapped UV area to generate the model texture.
7. A computer program product, characterized in that, It includes computer-readable instructions that, when executed on an electronic device, cause the electronic device to implement the layered rendering method for a three-dimensional model as described in any one of claims 1 to 3.
8. An electronic device, characterized in that, It includes at least one processor and a memory connected to the processor, wherein: The memory is used to store computer programs; The processor is used to execute the computer program to enable the electronic device to implement the layered rendering method of the three-dimensional model as described in any one of claims 1 to 3.
9. A computer storage medium, characterized in that, The storage medium carries one or more computer programs that, when executed by an electronic device, enable the electronic device to implement the layered rendering method for a three-dimensional model as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Volume rendering method and device, computer equipment and computer readable storage medium
CN116402931A
Three-dimensional model rendering method and device, electronic equipment and storage medium
CN117635799A