Gem model rendering method and device, electronic equipment and readable storage medium
By pre-constructing the mesh structure map of the gem model and sampling it in real-time rendering, combined with lighting information, the problem of low gem rendering performance in game scenes is solved, achieving high-quality gem rendering effect and efficient rendering performance.
Patent Information
- Application Number
- CN202311235203.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2024-12-17
AI Technical Summary
It is difficult for the existing technology to achieve high-quality gem rendering effects in game scenes, especially under the requirements of real-time rendering, the rendering performance is low, making it difficult to simulate the gem brilliant effects in the real world.
By pre-constructing the geometric structure grid structure map of the gem model, and sampling the map during real-time rendering, combining the lighting rays from the current perspective to collect lighting information to realize the rendering of the gem model.
It greatly improves real-time rendering performance and achieves high-quality gem rendering effects, which can maintain efficient rendering performance under different viewing angles and lighting conditions.
Smart Images

Figure CN119152097A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a rendering method, device, electronic device and readable storage medium for a gemstone model. Background Art
[0002] Gems (or crystals) in the real world, such as diamonds, rubies, and emeralds, will present a dazzling luster effect under different lighting conditions. In online games, especially dress-up games, the rendering effect of gems is increasingly required, so game developers hope to simulate the dazzling effect of real-world gems as much as possible in the game scene.
[0003] Since real-time rendering is required in game scenes, high requirements are placed on rendering performance. In response to the need for real-time rendering, the rendering of gems in current game scenes is generally implemented using textures. For example, a cube map is used to save the normals of the gems in six different directions, and then an environment HDR (High Dynamic Range) map is sampled using the normals to simulate the lighting effects inside the gems. Alternatively, a bump map is used to make the surface of the gems look three-dimensional, thereby simulating the facet effects inside the gems. These methods can achieve the purpose of real-time rendering, but the rendering effect is far from the dazzling effect of gems in the real world.
[0004] Although the effect of gemstone rendering is good in some scenarios, such as the gemstone rendering effect in jewelry advertisements, its rendering performance is low and can only be used for offline rendering, and it is difficult to apply it to real-time rendering scenarios. Therefore, how to achieve high-quality gemstone rendering effects that meet the needs of real-time rendering is a problem that needs to be solved urgently. Summary of the invention
[0005] The objectives of the present invention include, for example, providing a method, device, electronic device and readable storage medium for rendering a gemstone model, which can achieve high-performance, high-quality gemstone rendering effects.
[0006] The embodiments of the present invention can be implemented as follows:
[0007] In a first aspect, the present invention provides a method for rendering a gemstone model, the method comprising:
[0008] For a gemstone model to be rendered, obtaining a pre-stored grid structure map constructed based on the geometric structure of the gemstone model;
[0009] Sampling the grid structure map to obtain a three-dimensional grid corresponding to the gemstone model;
[0010] Constructing an illumination ray at the current viewing angle, and using the illumination ray to illuminate the gemstone model surrounded by the three-dimensional grid;
[0011] The illumination information is obtained according to the intersection information of the illumination light in the three-dimensional grid and the gemstone model, and the rendering of the gemstone model is realized according to the illumination information.
[0012] In an optional embodiment, the method further comprises the step of pre-building a grid structure map, the step comprising:
[0013] Producing a three-dimensional grid according to the geometric structure of the gemstone model, wherein the three-dimensional grid includes a plurality of grids, and the gemstone model has a plurality of triangular faces;
[0014] Determine the triangular faces in each of the meshes to obtain triangular face information corresponding to each of the meshes;
[0015] Obtaining location information of each of the grids;
[0016] A grid structure map is constructed based on the position information of each grid and the corresponding triangle surface information.
[0017] In an optional implementation, the step of constructing a mesh structure map based on the position information of each mesh and the corresponding triangle surface information includes:
[0018] Converting the position information of each grid into color channel information;
[0019] Converting the triangle surface information corresponding to each mesh into alpha channel information;
[0020] Based on the color channel information and alpha channel information of each of the grids, a grid structure map is constructed.
[0021] In an optional embodiment, the three-dimensional grid includes a plurality of grids, the gemstone model includes a plurality of triangular faces, and each of the grids has one or more triangular faces;
[0022] The step of obtaining illumination information according to the intersection information of the illumination light in the three-dimensional grid and the gemstone model comprises:
[0023] For each grid in the three-dimensional grid, determining whether the illumination light intersects with the grid;
[0024] If the illumination ray does not intersect the mesh, stopping the tracing of the illumination ray in the mesh;
[0025] If the illumination ray intersects with the mesh, continue tracing the illumination ray in the mesh to determine the intersection point between the illumination ray and the triangular face in the mesh, obtain intersection information based on the intersection point, and obtain illumination information based on the intersection information.
[0026] In an optional embodiment, the illumination information includes color information of the illumination light at the intersection point;
[0027] The step of rendering the gemstone model according to the illumination information comprises:
[0028] Get the base color of the grid to which the intersection point belongs, and get the ambient color;
[0029] Obtaining a mixed color based on the color information of the illumination light at the intersection point, the base color and the ambient color;
[0030] The gemstone model is rendered according to the mixed color.
[0031] In an optional embodiment, the method further comprises:
[0032] For a static gemstone model to be rendered, a triangular mesh model of the gemstone model is obtained, wherein the three-dimensional mesh is a model whose geometric structure is consistent with the bounding box of the triangular mesh model and whose volume is a preset multiple of the bounding box;
[0033] According to the correspondence between the triangular mesh model and the three-dimensional mesh, the three-dimensional mesh information in the mesh structure map is updated;
[0034] The gemstone model is rendered according to the updated grid structure map and the obtained gemstone material.
[0035] In an optional implementation, the step of updating the three-dimensional mesh information in the mesh structure map according to the correspondence between the triangular mesh model and the three-dimensional mesh includes:
[0036] According to the correspondence between the triangular face mesh model and the meshes in the three-dimensional mesh, determining the meshes corresponding to the triangular faces included in the static gemstone model in the three-dimensional mesh;
[0037] Placing each of the triangular faces in a corresponding grid, and obtaining the position of each of the grids and the position of each of the triangular faces in the corresponding grid;
[0038] The position of each of the meshes and the position of each of the triangular faces in the corresponding mesh are written into the mesh structure map to update the mesh structure map.
[0039] In a second aspect, the present invention provides a rendering device for a gemstone model, the device comprising:
[0040] An acquisition module, for acquiring, for a gemstone model to be rendered, a pre-stored grid structure map constructed based on the geometric structure of the gemstone model;
[0041] A sampling module, used for sampling the grid structure map to obtain a three-dimensional grid corresponding to the gemstone model;
[0042] An illumination module, used for constructing an illumination light beam at a current viewing angle, and using the illumination light beam to illuminate the gemstone model surrounded by the three-dimensional grid;
[0043] The rendering module is used to obtain illumination information according to the intersection information of the illumination light in the three-dimensional grid and the gemstone model, and to render the gemstone model according to the illumination information.
[0044] In a third aspect, the present invention provides an electronic device comprising one or more storage media and one or more processors communicating with the storage media, wherein the one or more storage media store machine executable instructions executable by the processor, and when the electronic device is running, the processor executes the machine executable instructions to execute the method described in any one of the aforementioned embodiments.
[0045] In a fourth aspect, the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are executed by a processor, the method described in any one of the aforementioned embodiments is implemented.
[0046] The beneficial effects of the embodiments of the present invention include, for example:
[0047] The present application provides a rendering method, device, electronic device and readable storage medium for a gem model. For the gem model to be rendered, a pre-stored grid structure map based on the geometric structure of the gem model is obtained, and the grid structure map is sampled to obtain a three-dimensional grid corresponding to the gem model. An illumination ray at the current viewing angle is constructed, and the illumination ray is used to illuminate the gem model surrounded by the three-dimensional grid. The illumination information is obtained according to the intersection information of the illumination ray in the three-dimensional grid and the gem model, and the rendering of the gem model is realized according to the illumination information. In this scheme, on the one hand, a method of pre-constructing and saving a grid structure map is adopted. When rendering in real time, only the grid structure map needs to be sampled to realize rendering, which can greatly improve the real-time rendering performance; on the other hand, based on the transmission of the illumination ray in the three-dimensional grid and the gem model, and then based on the intersection information, rendering is realized, which can achieve a high-quality and brilliant gem effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0049] Figure 1 A flowchart of a method for rendering a gemstone model provided in an embodiment of the present application;
[0050] Figure 2 A flowchart of a method for constructing a grid structure map in a method for rendering a gemstone model provided in an embodiment of the present application;
[0051] Figure 3 for Figure 2 Flow chart of the sub-steps included in step S14;
[0052] Figure 4 A schematic diagram of a grid structure map in an embodiment of the present application;
[0053] Figure 5 for Figure 1 Flow chart of the sub-steps included in step S24;
[0054] Figure 6 for Figure 1 Another flow chart of the sub-steps included in step S24;
[0055] Figure 7 This is an overall schematic diagram of the illumination ray tracing process in an embodiment of the present application;
[0056] Figure 8 A flowchart of a method for rendering a static gemstone model in a method for rendering a gemstone model provided in an embodiment of the present application;
[0057] Fig. 9 A functional module block diagram of a rendering device for a gemstone model provided in an embodiment of the present application;
[0058] Fig.10 A structural block diagram of an electronic device provided in an embodiment of the present application.
[0059] Icons: 110 - rendering device of gemstone model; 111 - acquisition module; 112 - sampling module; 113 - illumination module; 114 - rendering module; 120 - processor; 130 - memory; 140 - communication module. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0061] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0062] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0063] In the description of the present invention, it should be noted that the features in the embodiments of the present invention can be combined with each other without conflict.
[0064] Figure 1 This is a flow chart of a method for rendering a gem model provided by an embodiment of the present application. This embodiment can be applied to scenes where a gem model is rendered in a certain game scene. The method can be executed by a gem model rendering device, which can be implemented in software and / or hardware, and can be configured in a terminal. Figure 1 As shown, the method includes:
[0065] S21, for a gemstone model to be rendered, obtaining a pre-stored grid structure map constructed based on the geometric structure of the gemstone model.
[0066] S22, sampling the grid structure map to obtain a three-dimensional grid corresponding to the gemstone model.
[0067] S23, constructing an illumination light at the current viewing angle, and using the illumination light to illuminate the gemstone model surrounded by the three-dimensional grid.
[0068] S24, obtaining illumination information according to the intersection information of the illumination light in the three-dimensional grid and the gemstone model, and rendering the gemstone model according to the illumination information.
[0069] In the game scene, the brilliant effects presented by the gem model at different viewing angles and different lighting are different. Therefore, it is necessary to realize the real-time rendering of the gem model at different viewing angles and different lighting. For the same gem model, although the rendering effects are different at different viewing angles, the geometric structure of the gem model itself is fixed and its geometric structure has not changed. In the existing traditional method, when the real-time rendering of the gem model is realized at different viewing angles and different lighting, the construction of the model related to the geometric structure of the gem model will be executed again at the new viewing angle and new lighting, resulting in a reduction in rendering speed and affecting rendering performance.
[0070] Based on this, in this embodiment, a grid structure map can be constructed based on the geometric structure of the gem model in advance, and the constructed grid structure map can be stored. The grid structure map can be understood as a map constructed based on the geometric structure of the gem model and used to record the geometric information of the gem model after conversion in a certain way.
[0071] In this way, when rendering the gem model in real time, even if the lighting conditions change, there is no need to rebuild the geometric model, and the pre-stored grid structure map can be directly sampled to obtain the three-dimensional grid corresponding to the gem model. Among them, the three-dimensional grid can be understood as a three-dimensional model composed of multiple grids constructed by the gem model in three-dimensional space. The surface of the gem model is composed of multiple triangular faces, so each triangular face of the gem model will fall into the grid included in the three-dimensional grid. The relationship between the three-dimensional grid and the gem model can be understood as that in three-dimensional space, the three-dimensional grid surrounds the gem model.
[0072] In real-time rendering, the rendering effect of the gem model is different under different viewing angles and different lighting rays. Generally speaking, different viewing angles correspond to different lighting rays, and the viewing angle changes with the change of the observer's viewing angle. At the current moment, the lighting ray under the current viewing angle is constructed with the viewing angle, and the lighting ray will be irradiated to the three-dimensional grid and the gem model.
[0073] Based on the geometric position information of the three-dimensional grid in the network structure map, and the information of the grid to which the triangular faces of the gem model belong, combined with the position and angle information of the illumination light, the intersection information of the illumination light in the three-dimensional grid and the gem model can be obtained, and then the illumination information can be obtained according to the intersection information, and then the gem model can be rendered according to the illumination information.
[0074] In the rendering method of the gem model provided in this embodiment, on the one hand, a method of pre-building and saving a grid structure map is adopted. During real-time rendering, only the grid structure map needs to be sampled to achieve rendering, which can greatly improve the real-time rendering performance. On the other hand, based on the transmission of light rays in the three-dimensional grid and the gem model, rendering is achieved based on the intersection information, which can achieve a high-quality, dazzling gem effect.
[0075] The following first introduces the process of pre-building a grid structure map.
[0076] See also Figure 2 In this embodiment, the grid structure map can be pre-constructed in the following manner:
[0077] S11, making a three-dimensional grid according to the geometric structure of the gemstone model, wherein the three-dimensional grid includes a plurality of grids, and the gemstone model has a plurality of triangular faces.
[0078] S12, determining the triangular faces in each of the meshes to obtain triangular face information corresponding to each of the meshes.
[0079] S13, obtaining the position information of each of the grids.
[0080] S14, constructing a grid structure map based on the position information of each grid and the corresponding triangle surface information.
[0081] In this embodiment, based on the overall geometric structure of the gem model, a minimum three-dimensional model that can surround the gem model can be made, and multiple parallel horizontal planes are constructed in the three-dimensional model, and multiple parallel vertical planes are constructed. In this way, multiple horizontal planes and multiple vertical planes divide the internal space of the three-dimensional model into multiple grids, thereby constructing a three-dimensional grid.
[0082] The surface of the gemstone model has multiple triangular faces. When the gemstone model is located inside the three-dimensional model, each triangular face will be in a grid contained in the three-dimensional grid, wherein each grid may have one or more triangular faces. In this way, the triangular face information corresponding to each grid can be obtained.
[0083] The triangular face information corresponding to each mesh may include the number of triangular faces included. In addition, the triangular faces on the gem model may be numbered according to certain rules, and each triangular face may have a number that is a unique identifier relative to the gem model. The triangular face information corresponding to each mesh may also include the number information of the triangular faces included.
[0084] In addition, the position information of each grid can be obtained, and the position information of each grid can be the position information in the object space constructed by the gemstone model. In this way, each grid will carry its own position information and its corresponding triangle face information.
[0085] On this basis, a grid structure map can be constructed based on the position information of each grid and the corresponding triangle surface information, and the grid structure map can be used to record the geometric information of the three-dimensional grid and the corresponding relationship between the three-dimensional grid and the gem model.
[0086] In this embodiment, in order to facilitate the subsequent processing of the graphics processor, when constructing a grid structure map based on the position information of each grid and the corresponding triangle surface information, it can be achieved in the following way, see Figure 3 :
[0087] S141, converting the position information of each grid into color channel information.
[0088] S142, converting the triangle surface information corresponding to each of the meshes into alpha channel information.
[0089] S143, constructing a grid structure map based on the color channel information and alpha channel information of each of the grids.
[0090] In order to facilitate the subsequent image processing of the graphics processor, in this embodiment, the obtained grid structure map can be a map in the Float RGB format. Specifically, the position information of each grid in the three-dimensional grid is the position information in the object space, including the coordinate information in the X direction, the Y direction and the Z direction. The coordinate information in the X direction can be converted into the R channel information in the color channel, the coordinate information in the Y direction can be converted into the G channel information in the color channel, and the coordinate information in the Z direction can be converted into the B channel information in the color channel.
[0091] In addition, the triangle surface information corresponding to each mesh can be converted into alpha channel information, so that the color channel information and alpha channel information corresponding to the position information and triangle surface of the mesh can be obtained.
[0092] The grid structure map in Float RGB format can be constructed from the color channel information and alpha channel information of each grid, such as Figure 4 as shown in .
[0093] After the grid structure map is pre-constructed and saved in the above manner, during subsequent real-time rendering, the three-dimensional grid corresponding to the gem model can be obtained by sampling the grid structure map, and then ray tracing can be performed based on the transmission of light rays in the three-dimensional grid and the gem model, and then the lighting information can be obtained based on the intersection information to realize the rendering of the gem model.
[0094] See also Figure 5 In this embodiment, the step of obtaining the illumination information according to the intersection information of the illumination light in the three-dimensional grid and the gemstone model can be implemented in the following manner:
[0095] S241, for each grid in the three-dimensional grid, determine whether the illumination light intersects with the grid.
[0096] S242: If the illumination ray does not intersect the grid, stop tracing the illumination ray in the grid.
[0097] S243, if the illumination ray intersects with the mesh, continue tracing the illumination ray in the mesh to determine the intersection point between the illumination ray and the triangular face in the mesh, obtain intersection information based on the intersection point, and obtain illumination information based on the intersection information.
[0098] As can be seen from the above, the three-dimensional grid includes multiple grids, the gemstone model includes multiple triangular faces, and each grid has one or more triangular faces. The position information of each grid in the three-dimensional grid can be obtained, and in each grid to which the triangular face belongs, the relative position of the triangular face in the grid can be obtained, and then the position information of the triangular face can be obtained by combining the position information of the grid and the relative position of the triangular face in the grid. After determining the illumination light at the current viewing angle, the angle and position information of the illumination light can be obtained.
[0099] In this embodiment, when the illumination light is irradiated to the three-dimensional grid and the gemstone model, an intersection test is first performed with the grids in the three-dimensional grid as the dimension. When the position information of each grid in the three-dimensional grid and the angle and position information of the illumination light are known, it can be determined whether each grid intersects with the illumination light.
[0100] Among them, if a certain mesh does not intersect with the lighting ray, the tracing of the lighting ray in the mesh can be terminated, and there is no need to perform an intersection test between the lighting ray and the triangle surface.
[0101] If a certain grid intersects with the illumination ray, the intersection test between the illumination ray and the triangular face in the grid is further continued. Specifically, the intersection point between the illumination ray and the triangular face in the grid is determined, and the intersection information including the intersection point information is obtained. Based on the intersection information, the incident direction, illumination intensity, color and other illumination information of the illumination ray at the intersection point are determined, and then the rendering of the gem model is realized based on the illumination information.
[0102] See also Figure 6 In a possible implementation, the gem model can be rendered according to the lighting information in the following manner:
[0103] S244, obtaining the basic color of the grid to which the intersection point belongs, and obtaining the ambient color.
[0104] S245, obtaining a mixed color based on the color information of the illumination light at the intersection point, the basic color and the ambient color.
[0105] S246, rendering the gemstone model according to the mixed color.
[0106] In the rendering effect of the gem model, in addition to the illumination color affecting the final rendering color of the pixel, the ambient color and the basic color of the grid itself will also affect the rendering color of the pixel. Therefore, after determining the intersection point of the illumination light and the triangle face, determine the refraction, reflection and other effects of the illumination light at the intersection point to obtain the color information of the illumination light at the intersection point.
[0107] Based on the color information of the illumination light at the intersection point, the basic color and the ambient color of the grid are superimposed to obtain a mixed color, which is used as the rendering color of the pixel point at the intersection point, thereby realizing the rendering of the gem model.
[0108] In this embodiment, since the three-dimensional grid includes multiple grids, and each grid has one or more triangular faces, to complete the rendering of the entire gemstone model, it is necessary to traverse each grid, and for the grid intersecting with the illumination ray, it is necessary to traverse each triangular face in the grid. This process is repeated until the last grid in the three-dimensional grid is processed, and the ray tracing of the last triangular face in the last grid is completed.
[0109] Please refer to Figure 7 ,The following introduces the overall process of ray tracing of illumination rays in gem models and three-dimensional meshes.
[0110] S31, constructing the lighting rays under the current viewing angle.
[0111] S32, sampling the grid structure map to obtain a three-dimensional grid, and traversing each grid in the three-dimensional grid to obtain position information of the traversed grid.
[0112] S33, determining whether the currently traversed grid is the last grid in the three-dimensional grid, if so, executing step S34, if not, executing step S35.
[0113] S34, calculating the intersection information of the triangular faces in the mesh currently traversed by the illumination light, and jumping to step S39.
[0114] S35, determine whether the illumination light intersects with the currently traversed grid. If not, return to step S33 to continue the intersection test between the illumination light and the next grid. If so, execute step S36.
[0115] S36, performing an intersection test between the illumination ray and the triangle faces in the currently traversed mesh.
[0116] S37, determine whether to perform the intersection test on the last triangle in the currently traversed mesh. If not, return to step S36 to continue the intersection test between the illumination light and the next triangle. If yes, execute step S38.
[0117] S38, calculating the intersection information of the intersection points of the illumination light on the triangular surface.
[0118] S39, obtaining illumination information based on the intersection information, superimposing the base color and the ambient color, and outputting a mixed color.
[0119] In this embodiment, firstly, a method of pre-building and saving a grid structure map is adopted. When rendering in real time, only the grid structure map needs to be sampled to realize rendering, which can greatly improve the real-time rendering performance. Furthermore, a method of constructing a three-dimensional grid based on a gem model is adopted, and the grids in the three-dimensional grid are used for intersection testing. In this way, the intersection test between the grids that do not intersect with the light and the triangles in the grid can be stopped, which can greatly reduce unnecessary workload and further improve the rendering performance. Based on the rendering method provided in this embodiment, the ray tracing process of the gem model can be accelerated, and the real-time rendering performance of the gem model ray tracing can be improved by more than 10 times.
[0120] In this embodiment, the above method can realize the real-time rendering of gem models in the game scene. In addition, there may be some static gem models that need to be rendered in the game scene, such as gem models displayed in the gem list. Such gem models do not need to be rendered in real time based on the conversion of the viewing angle, but only need to realize the brilliant display effect of the gems based on the settings.
[0121] In this embodiment, the pre-built grid structure map can also be applied to static grid models of any shape to achieve the rendering of static gem models. Figure 8 In a possible implementation, the method for rendering a gemstone model provided in this embodiment may further include the following steps:
[0122] S41, for a static gemstone model to be rendered, obtaining a triangular mesh model of the gemstone model, wherein the three-dimensional mesh is a model whose geometric structure is consistent with the bounding box of the triangular mesh model and whose volume is a preset multiple thereof.
[0123] S42, updating the three-dimensional mesh information in the mesh structure map according to the correspondence between the triangular mesh model and the three-dimensional mesh.
[0124] S43, rendering the gemstone model according to the updated grid structure map and the obtained gemstone material.
[0125] In this embodiment, for a static gemstone model that needs to be rendered, the gemstone model has a corresponding triangular mesh model. The triangular mesh model can also be understood as a three-dimensional model that can surround the gemstone model, and the triangular mesh model is composed of multiple meshes.
[0126] The geometric structure of the bounding box of the triangular mesh model and the above-mentioned pre-constructed three-dimensional mesh is consistent, that is, both are composed of multiple grids formed by the intersection of multiple horizontal planes in the horizontal direction and multiple vertical planes in the vertical direction. The difference between the triangular mesh model and the three-dimensional mesh is that the volume of the bounding box of the two may be different, that is, the volume of the three-dimensional mesh bounding box can be a preset multiple of the volume of the triangular mesh model bounding box. Among them, the preset multiple can be a multiple greater than 1, that is, it can be understood that the three-dimensional mesh is a larger three-dimensional model that can enclose the triangular mesh model.
[0127] Similarly, the gemstone model in a static state includes a plurality of triangular faces. When the triangular face mesh model surrounds the gemstone model, each triangular face in the gemstone model has a corresponding mesh.
[0128] The pre-obtained grid structure map contains the position information of each grid in the three-dimensional grid and the triangle surface information corresponding to each grid, and is stored in the grid structure map in RGB format.
[0129] After determining the mesh to which each triangular face in the static gemstone model belongs, the three-dimensional mesh information in the mesh structure map can be updated in combination with the corresponding relationship between the triangular face mesh model and the three-dimensional mesh.
[0130] Specifically, the geometric structure of the triangular mesh model is consistent with that of the three-dimensional mesh, so each mesh in the triangular mesh model has a corresponding relationship with each mesh in the three-dimensional mesh.
[0131] Therefore, the grid corresponding to each triangular face in the three-dimensional grid can be determined based on the correspondence between the grid in the triangular face grid model and the grid to which each triangular face included in the static gem model belongs in the triangular face grid model. Each triangular face is placed in the corresponding grid, and the position of each grid and the position of each triangular face in the corresponding grid are obtained, and the position of each grid and the position of each triangular face in the corresponding grid are written into the grid structure map to update the grid structure map.
[0132] The updated grid structure map obtained is the map corresponding to the static gem model, and the updated grid structure map can be saved. In addition, the gem material can be obtained, and a saving path can be pre-selected to save the gem material and the grid structure map.
[0133] In specific implementation, based on the saved gem material and mesh structure map, combined with the set lighting information, etc., the rendering of the gem model can be achieved.
[0134] In this embodiment, the above process can be implemented based on the UE editor, and the rendering effect of the static gem can be changed by adjusting parameters such as lighting direction, lighting color, static mesh color, and environment map in the UE editor.
[0135] This embodiment implements a rendering tool based on the UE editor through the above method, which can apply the gem rendering effect to triangular mesh models of any shape, thereby improving the efficiency of art in producing gem effects.
[0136] Based on the same application idea, please refer to Fig. 9 , shows a functional module schematic diagram of a rendering device 110 for a gem model provided in an embodiment of the present application. This embodiment can divide the functional modules of the rendering device 110 for the gem model according to the above method embodiment. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The above integrated modules can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic, which is only a logical functional division, and there may be other division methods in actual implementation.
[0137] For example, when each functional module is divided into corresponding functional modules, Fig. 9 The rendering device 110 of the gem model shown is only a schematic diagram of the device. The rendering device 110 of the gem model may include an acquisition module 111, a sampling module 112, an illumination module 113 and a rendering module 114. The functions of each functional module of the rendering device 110 of the gem model are described in detail below.
[0138] An acquisition module 111 is used to obtain a pre-stored grid structure map constructed based on the geometric structure of the gemstone model for the gemstone model to be rendered;
[0139] It can be understood that the obtaining module 111 can be used to execute the above step S21. The detailed implementation of the obtaining module 111 can refer to the relevant content of the above step S21.
[0140] A sampling module 112 is used to sample the grid structure map to obtain a three-dimensional grid corresponding to the gemstone model;
[0141] It can be understood that the sampling module 112 can be used to execute the above step S22. The detailed implementation of the sampling module 112 can refer to the content related to the above step S22.
[0142] An illumination module 113 is used to construct an illumination light beam at a current viewing angle, and use the illumination light beam to illuminate the gemstone model surrounded by the three-dimensional grid;
[0143] It can be understood that the irradiation module 113 can be used to perform the above step S23. The detailed implementation of the irradiation module 113 can refer to the relevant content of the above step S23.
[0144] The rendering module 114 is used to obtain illumination information according to the intersection information of the illumination light in the three-dimensional grid and the gemstone model, and to render the gemstone model according to the illumination information.
[0145] It can be understood that the rendering module 114 can be used to execute the above step S24. The detailed implementation of the rendering module 114 can refer to the relevant content of the above step S24.
[0146] In a possible implementation, the gemstone model rendering device 110 further includes a construction module, which can be used to:
[0147] Determine the triangular faces in each of the meshes to obtain triangular face information corresponding to each of the meshes;
[0148] Obtaining location information of each of the grids;
[0149] A grid structure map is constructed based on the position information of each grid and the corresponding triangle surface information.
[0150] In a possible implementation, the above building blocks may be specifically used for:
[0151] Converting the position information of each grid into color channel information;
[0152] Converting the triangle surface information corresponding to each mesh into alpha channel information;
[0153] Based on the color channel information and alpha channel information of each of the grids, a grid structure map is constructed.
[0154] In a possible implementation, the three-dimensional grid includes a plurality of grids, the gemstone model includes a plurality of triangular faces, each of the grids has one or more triangular faces, and the rendering module 114 can be specifically used for:
[0155] For each grid in the three-dimensional grid, determining whether the illumination light intersects with the grid;
[0156] If the illumination ray does not intersect the mesh, stopping the tracing of the illumination ray in the mesh;
[0157] If the illumination ray intersects with the mesh, continue tracing the illumination ray in the mesh to determine the intersection point between the illumination ray and the triangular face in the mesh, obtain intersection information based on the intersection point, and obtain illumination information based on the intersection information.
[0158] In a possible implementation, the illumination information includes color information of the illumination light at the intersection point, and the rendering module 114 may be specifically used for:
[0159] Get the base color of the grid to which the intersection point belongs, and get the ambient color;
[0160] Obtaining a mixed color based on the color information of the illumination light at the intersection point, the base color and the ambient color;
[0161] The gemstone model is rendered according to the mixed color.
[0162] In a possible implementation, the rendering module 114 may also be used to:
[0163] For a static gemstone model to be rendered, a triangular mesh model of the gemstone model is obtained, wherein the three-dimensional mesh is a model whose geometric structure is consistent with the bounding box of the triangular mesh model and whose volume is a preset multiple of the bounding box;
[0164] According to the correspondence between the triangular mesh model and the three-dimensional mesh, the three-dimensional mesh information in the mesh structure map is updated;
[0165] The gemstone model is rendered according to the updated grid structure map and the obtained gemstone material.
[0166] In a possible implementation, the rendering module 114 may be used to update the grid structure map in the following manner:
[0167] According to the correspondence between the triangular face mesh model and the meshes in the three-dimensional mesh, determining the meshes corresponding to the triangular faces included in the static gemstone model in the three-dimensional mesh;
[0168] Placing each of the triangular faces in a corresponding grid, and obtaining the position of each of the grids and the position of each of the triangular faces in the corresponding grid;
[0169] The position of each of the meshes and the position of each of the triangular faces in the corresponding mesh are written into the mesh structure map to update the mesh structure map.
[0170] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0171] See also Fig.10 , is a structural block diagram of an electronic device provided in an embodiment of the present application, wherein the electronic device includes a memory 130, a processor 120, and a communication module 140. The memory 130, the processor 120, and the communication module 140 are electrically connected to each other directly or indirectly to achieve data transmission or interaction. For example, these components can be electrically connected to each other via one or more communication buses or signal lines.
[0172] The memory 130 is used to store programs or data. The memory 130 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), etc.
[0173] The processor 120 is used to read / write data or programs stored in the memory 130 and execute the gemstone model rendering method provided in any embodiment of the present application.
[0174] The communication module 140 is used to establish a communication connection between the electronic device and other communication terminals through a network, and to send and receive data through the network.
[0175] It should be understood that Fig.10 The structure shown is only a schematic diagram of the structure of the electronic device, and the electronic device may also include Fig.10 More or fewer components as shown, or with Fig.10 Different configurations are shown.
[0176] Furthermore, an embodiment of the present application also provides a computer-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are executed, the method for rendering the gemstone model provided in the above embodiment is implemented.
[0177] Specifically, the computer-readable storage medium can be a general storage medium, such as a mobile disk, a hard disk, etc. When the computer program on the computer-readable storage medium is executed, the above-mentioned gemstone model rendering method can be executed. Regarding the processes involved when the computer-readable storage medium and its executable instructions are executed, reference can be made to the relevant descriptions in the above-mentioned method embodiments, which will not be described in detail here.
[0178] In summary, the rendering method, device, electronic device and readable storage medium of the gem model provided in the embodiments of the present application obtain a pre-stored grid structure map based on the geometric structure of the gem model for the gem model to be rendered, sample the grid structure map, and obtain a three-dimensional grid corresponding to the gem model. Construct an illumination light at the current viewing angle, and use the illumination light to illuminate the gem model surrounded by the three-dimensional grid, obtain illumination information based on the intersection information of the illumination light in the three-dimensional grid and the gem model, and render the gem model based on the illumination information. In this scheme, on the one hand, the method of pre-constructing and saving the grid structure map is adopted, and only the grid structure map needs to be sampled to realize rendering during real-time rendering, which can greatly improve the real-time rendering performance; on the other hand, based on the transmission of the illumination light in the three-dimensional grid and the gem model, and then based on the intersection information, rendering can be realized, which can achieve high-quality and brilliant gem effects.
[0179] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for rendering a gemstone model, characterized in that: The method comprises: For a gemstone model to be rendered, obtaining a pre-stored grid structure map constructed based on the geometric structure of the gemstone model; Sampling the grid structure map to obtain a three-dimensional grid corresponding to the gemstone model; Constructing an illumination ray at the current viewing angle, and using the illumination ray to illuminate the gemstone model surrounded by the three-dimensional grid; The illumination information is obtained according to the intersection information of the illumination light in the three-dimensional grid and the gemstone model, and the rendering of the gemstone model is realized according to the illumination information.
2. The method for rendering a gemstone model according to claim 1, characterized in that: The method further comprises the step of pre-building a grid structure map, the step comprising: Producing a three-dimensional grid according to the geometric structure of the gemstone model, wherein the three-dimensional grid includes a plurality of grids, and the gemstone model has a plurality of triangular faces; Determine the triangular faces in each of the meshes to obtain triangular face information corresponding to each of the meshes; Obtaining location information of each of the grids; A grid structure map is constructed based on the position information of each grid and the corresponding triangle surface information.
3. The method for rendering a gemstone model according to claim 2, characterized in that: The step of constructing a mesh structure map based on the position information of each mesh and the corresponding triangle surface information includes: Converting the position information of each grid into color channel information; Converting the triangle surface information corresponding to each mesh into alpha channel information; Based on the color channel information and alpha channel information of each of the grids, a grid structure map is constructed.
4. The method for rendering a gemstone model according to claim 1, characterized in that: The three-dimensional grid includes a plurality of grids, the gemstone model includes a plurality of triangular faces, and each of the grids has one or more triangular faces; The step of obtaining illumination information according to the intersection information of the illumination light in the three-dimensional grid and the gemstone model comprises: For each grid in the three-dimensional grid, determining whether the illumination light intersects with the grid; If the illumination ray does not intersect the mesh, stopping the tracing of the illumination ray in the mesh; If the illumination ray intersects with the mesh, continue tracing the illumination ray in the mesh to determine the intersection point between the illumination ray and the triangular face in the mesh, obtain intersection information based on the intersection point, and obtain illumination information based on the intersection information.
5. The method for rendering a gemstone model according to claim 4, characterized in that: The illumination information includes color information of the illumination light at the intersection point; The step of rendering the gemstone model according to the illumination information comprises: Get the base color of the grid to which the intersection point belongs, and get the ambient color; Obtaining a mixed color based on the color information of the illumination light at the intersection point, the base color and the ambient color; The gemstone model is rendered according to the mixed color.
6. The method for rendering a gemstone model according to claim 2, characterized in that: The method further comprises: For a static gemstone model to be rendered, a triangular mesh model of the gemstone model is obtained, wherein the three-dimensional mesh is a model whose geometric structure is consistent with the bounding box of the triangular mesh model and whose volume is a preset multiple of the bounding box; According to the correspondence between the triangular mesh model and the three-dimensional mesh, the three-dimensional mesh information in the mesh structure map is updated; The gemstone is rendered according to the updated grid structure map and the obtained gemstone material.
7. The method for rendering a gemstone model according to claim 6, characterized in that: The step of updating the three-dimensional mesh information in the mesh structure map according to the correspondence between the triangular mesh model and the three-dimensional mesh comprises: According to the correspondence between the triangular face mesh model and the meshes in the three-dimensional mesh, determining the meshes corresponding to the triangular faces included in the static gemstone model in the three-dimensional mesh; Placing each of the triangular faces in a corresponding grid, and obtaining the position of each of the grids and the position of each of the triangular faces in the corresponding grid; The position of each of the meshes and the position of each of the triangular faces in the corresponding mesh are written into the mesh structure map to update the mesh structure map.
8. A rendering device for a gemstone model, characterized in that: The device comprises: An acquisition module, for acquiring, for a gemstone model to be rendered, a pre-stored grid structure map constructed based on the geometric structure of the gemstone model; A sampling module, used for sampling the grid structure map to obtain a three-dimensional grid corresponding to the gemstone model; An illumination module, used for constructing an illumination light beam at a current viewing angle, and using the illumination light beam to illuminate the gemstone model surrounded by the three-dimensional grid; The rendering module is used to obtain illumination information according to the intersection information of the illumination light in the three-dimensional grid and the gemstone model, and to render the gemstone model according to the illumination information.
9. An electronic device, characterized in that: The electronic device comprises one or more storage media and one or more processors communicating with the storage media, wherein the one or more storage media store machine executable instructions executable by the processor, and when the electronic device is running, the processor executes the machine executable instructions to execute the method described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores machine-executable instructions, and when the machine-executable instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
