Three-dimensional rendering method, device, electronic device and storage medium
By combining small square faces in three-dimensional rendering objects into large rectangular faces, the problems of high computing load and low operation efficiency of the three-dimensional rendering engine in the prior art are solved, and a more efficient rendering process is achieved.
Patent Information
- Application Number
- CN202010988094.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-18
- Publication Date
- 2025-03-04
- Estimated Expiration
- 2040-09-18
AI Technical Summary
When rendering objects, existing three-dimensional rendering engines need to calculate each face independently, resulting in large calculation load and low operating efficiency.
By combining small square faces with the same color in the target object into large rectangular faces, and calling the 3D rendering engine to render the target object by rendering the merged faces.
Reduces the number of faces independently rendered by the 3D rendering engine when rendering the target object, thereby reducing the amount of calculation and improving operational efficiency.
Smart Images

Figure CN112184865B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of three-dimensional rendering, and in particular to a three-dimensional rendering method, device, electronic device and storage medium. Background Art
[0002] In the field of virtual object rendering, it is necessary to call a 3D rendering engine to render the virtual object to achieve the corresponding rendering effect. In the prior art, when rendering an object, the 3D rendering engine needs to independently calculate each face of the object. The more independent faces there are, the more faces the 3D rendering engine needs to independently calculate and render, and the greater the calculation load of the 3D rendering engine, resulting in low operating efficiency of the 3D rendering engine and low rendering frame rate. Summary of the invention
[0003] An object of the present disclosure is to provide a three-dimensional rendering method, device, electronic device and storage medium, which can improve the operating efficiency of a three-dimensional rendering engine.
[0004] According to one aspect of an embodiment of the present disclosure, a three-dimensional rendering method is disclosed, the method comprising:
[0005] Acquire a target object to be rendered, wherein the target object is composed of a plurality of unit cubes, wherein six unit faces of each unit cube have colors;
[0006] Merge at least one unit face with the same color and filling a rectangular area on the same plane to obtain a target rectangular face included in the target object;
[0007] A three-dimensional rendering engine is called to render the target object by rendering the target rectangular surface.
[0008] According to one aspect of an embodiment of the present disclosure, a three-dimensional rendering device is disclosed, the device comprising:
[0009] An acquisition module is configured to acquire a target object to be rendered, wherein the target object is composed of a plurality of unit cubes, wherein six unit faces of each unit cube have colors;
[0010] A merging module, configured to merge at least one unit surface with the same color and filling the rectangular area on the same plane to obtain a target rectangular surface included in the target object;
[0011] The rendering module is configured to call a three-dimensional rendering engine to render the target object by rendering the target rectangular surface.
[0012] In an exemplary embodiment of the present disclosure, the device is configured as follows:
[0013] Selecting a plane to be rendered in the target object as a target plane;
[0014] Based on the traversal of the vertices of the unit faces in the target plane, two unit faces with the same color and sharing two vertices in the target plane are merged in pairs, wherein each unit face is merged at most once.
[0015] In an exemplary embodiment of the present disclosure, the device is configured as follows:
[0016] Selecting a plane to be rendered in the target object as a target plane, and selecting a unit plane from each unit plane in the target plane as a starting plane;
[0017] Based on the traversal of the vertices of each unit face in the target plane, whenever another unit face is traversed that has the same color as the starting face and shares two vertices with the starting face, the other unit face is merged into the starting face.
[0018] In an exemplary embodiment of the present disclosure, the device is configured as follows:
[0019] Select a plane to be rendered in the target object as the target plane, and set the number of loop merging times to 0;
[0020] In each merging cycle, based on the traversal of the vertices of the independent faces in the target plane, two independent faces with the same color and sharing two vertices in the target plane are merged in pairs, wherein each independent face is merged at most once in each merging cycle;
[0021] Each time a loop merge is completed, the number of loop merges is increased by one and the next loop merge is continued until the number of loop merges reaches a preset number threshold and the loop merge is terminated.
[0022] In an exemplary embodiment of the present disclosure, the device is configured to keep the merging order of the two merges consistent during each cycle merging process.
[0023] In an exemplary embodiment of the present disclosure, the device is configured as follows:
[0024] Get the user's current perspective;
[0025] The order of the planes to be rendered of the target object as the target planes is determined in the viewing angle, and the target planes are selected according to the order.
[0026] In an exemplary embodiment of the present disclosure, the apparatus is configured to remove, from the target object, unit cubes whose six unit faces are all surrounded by other unit cubes.
[0027] In an exemplary embodiment of the present disclosure, the apparatus is configured to generate and render a miniature model of the target object based on proportional reduction of the rendered target object.
[0028] According to one aspect of an embodiment of the present disclosure, a three-dimensional rendering electronic device is disclosed, including: a memory storing computer-readable instructions; and a processor reading the computer-readable instructions stored in the memory to execute the method described in any of the above exemplary embodiments.
[0029] According to one aspect of an embodiment of the present disclosure, a computer program medium is disclosed, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer is caused to execute the method described in any one of the above exemplary embodiments.
[0030] In the disclosed embodiment, before calling the 3D rendering engine to render the target object, the small square faces of the same color to be rendered in the target object are first merged into a large rectangular face, and then the 3D rendering engine is called to render the target object by rendering the merged large rectangular face. This method reduces the number of faces that the 3D rendering engine needs to render independently when rendering the target object, thereby reducing the amount of calculation of the 3D rendering engine and improving the operating efficiency of the 3D rendering engine.
[0031] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by the practice of the present disclosure.
[0032] It is to be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The above and other objects, features and advantages of the present disclosure will become more apparent by describing in detail example embodiments thereof with reference to the attached drawings.
[0034] Figure 1 A flow chart of a three-dimensional rendering method according to an embodiment of the present disclosure is shown.
[0035] Figure 2 A schematic diagram of merging unit surfaces according to an embodiment of the present disclosure is shown.
[0036] Figure 3 A schematic diagram of merging unit surfaces according to an embodiment of the present disclosure is shown.
[0037] Figure 4 A schematic diagram of merging unit surfaces according to an embodiment of the present disclosure is shown.
[0038] Figure 5A schematic diagram of merging unit surfaces according to an embodiment of the present disclosure is shown.
[0039] Figure 6 A schematic diagram of rendering and miniaturizing a target object according to an embodiment of the present disclosure is shown.
[0040] Figure 7 A block diagram of a device for three-dimensional rendering according to an embodiment of the present disclosure is shown.
[0041] Figure 8 A three-dimensionally rendered hardware diagram of an electronic device according to one embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0042] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these example embodiments are provided so that the description of the present disclosure will be more comprehensive and complete and the concepts of the example embodiments will be fully conveyed to those skilled in the art. The accompanying drawings are only schematic illustrations of the present disclosure and are not necessarily drawn to scale. The same reference numerals in the figures represent the same or similar parts, and thus their repeated description will be omitted.
[0043] In addition, the described features, structures or characteristics may be combined in one or more example embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the example embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure may be practiced while omitting one or more of the specific details, or other methods, components, steps, etc. may be adopted. In other cases, well-known structures, methods, implementations or operations are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0044] Some of the blocks shown in the accompanying drawings are functional entities that do not necessarily correspond to physically or logically independent entities. These functional entities can be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0045] The present disclosure provides a three-dimensional rendering method, specifically, a method for three-dimensionally rendering a target object with colors in a virtual data environment. The types and arrangements of the colors of the target object are not limited.
[0046] Figure 1 A three-dimensional rendering method according to an embodiment of the present disclosure is shown, and as shown in the figure, the method includes:
[0047] Step S110, obtaining a target object to be rendered, wherein the target object is composed of a plurality of unit cubes, wherein six unit faces of each unit cube have colors;
[0048] Step S120, merging at least one unit surface that is in the same plane and has the same color and fills the rectangular area to obtain a target rectangular surface included in the target object;
[0049] Step S130: calling a three-dimensional rendering engine to render the target object by rendering the target rectangular surface.
[0050] In the disclosed embodiment, before calling the 3D rendering engine to render the target object, the small square faces of the same color to be rendered in the target object are first merged into a large rectangular face, and then the 3D rendering engine is called to render the target object by rendering the merged large rectangular face. This method reduces the number of faces that the 3D rendering engine needs to render independently when rendering the target object, thereby reducing the amount of calculation of the 3D rendering engine and improving the operating efficiency of the 3D rendering engine.
[0051] It should be noted that in the embodiments of the present disclosure, a square is a special kind of rectangle.
[0052] The disclosed embodiments are mainly applied to the scene of virtual 3D object rendering that interacts with the user, for example: after the user logs in to the virtual 3D object control system through the terminal, the target object is built by generating and scheduling unit cubes in the system, and then the cloud server of the system calls the 3D rendering engine to perform 3D rendering on the target object. The 3D rendering of the target object includes rendering the general performance of the surface of the target object and rendering the performance of the surface of the target object under the influence of ambient light and shadow.
[0053] It should be noted that, for the purpose of facilitating the explanation of the embodiments of the present disclosure, in the subsequent description of the embodiments of the present disclosure, the cloud server is exemplarily taken as the execution entity, and the application scenario is exemplarily taken as the user identified by the cloud server generating and scheduling unit cubes to build a target object to be rendered.
[0054] In the disclosed embodiment, the acquired target object to be rendered is composed of a plurality of unit cubes, wherein the six unit faces of each unit cube have colors. Generally, the colors of the six unit faces of a single unit cube are the same. For example: in a virtual three-dimensional object control system, each cube brick generated and scheduled by the user as the basic unit of a virtual building has a color. Specifically, there are six bricks with green faces, six bricks with red faces, and six bricks with yellow faces.
[0055] In the disclosed embodiment, the target object is composed of a plurality of unit cubes, each of which has six unit faces. The target object is rendered, that is, the unit faces of the target object are rendered. In order to reduce the amount of calculation of the three-dimensional rendering engine when rendering the target object, at least one unit face with the same color and filling the rectangular area in the same plane is merged to obtain the target rectangular face contained in the target object, and then the three-dimensional rendering engine can be called to render the target object by rendering the target rectangular face.
[0056] In one embodiment, merging at least one unit surface that is in the same plane and has the same color and fills a rectangular area includes:
[0057] Select a plane to be rendered in the target object as the target plane;
[0058] Based on the traversal of the vertices of the unit faces in the target plane, two unit faces with the same color and sharing two vertices in the target plane are merged in pairs, wherein each unit face is merged at most once.
[0059] In this embodiment, by merging unit surfaces in pairs, at least one unit surface that is in the same plane and has the same color and fills the rectangular area is merged.
[0060] Specifically, the cloud server selects a plane to be rendered in the target object as the target plane, and traverses the vertices of each unit face in the target plane to determine which two unit faces of the same color share two vertices. Since a unit face has only four vertices, if two unit faces of the same color share two vertices, it means that the two unit faces of the same color fill a rectangular area together, so the two unit faces of the same color are merged. Moreover, each unit face is merged at most once to avoid merging the same unit face with two or more other unit faces at the same time.
[0061] The advantage of this embodiment is that by merging unit surfaces in pairs, the number of surfaces that need to be rendered by the three-dimensional rendering engine can be quickly reduced.
[0062] Figure 2 A schematic diagram of merging unit surfaces according to an embodiment of the present disclosure is shown.
[0063] refer to Figure 2 As shown, in this embodiment, by merging unit surfaces in pairs, at least one unit surface that is in the same plane and has the same color and fills the rectangular area is merged.
[0064] Specifically, there are 12 unit faces on the target plane, and each unit face has a color. Since unit faces 1 and 2 are both red and share two vertices, unit faces 1 and 2 are merged; similarly, unit faces 3 and 4 are merged, unit faces 5 and 9 are merged, unit faces 10 and 11 are merged, and unit faces 8 and 12 are merged.
[0065] It should be noted that this embodiment is only an exemplary description and should not limit the function and scope of use of the present disclosure.
[0066] In one embodiment, merging at least one unit surface that is in the same plane and has the same color and fills a rectangular area includes:
[0067] Selecting a plane to be rendered in the target object as a target plane, and selecting a unit plane from each unit plane in the target plane as a starting plane;
[0068] Based on the traversal of the vertices of each unit face in the target plane, whenever another unit face with the same color as the starting face and sharing two vertices with the starting face is traversed, the other unit face is merged into the starting face.
[0069] In this embodiment, by continuously merging unit surfaces, at least one unit surface that is in the same plane and has the same color and fills the rectangular area is merged.
[0070] Specifically, the cloud server selects a plane to be rendered in the target object as the target plane, and selects a unit face from each unit face in the target plane as the starting face. Then, the vertices of each unit face in the target plane are traversed, and the starting face is used as the merging basis. Whenever another unit face with the same color as the starting face and sharing two vertices with the starting face is traversed, the other unit face is merged into the starting face. The area of the starting face merged with the other unit face is expanded, and the vertices are changed accordingly.
[0071] Continue traversing and merging until there is no other unit face in the target plane that has the same color as the starting face and shares two vertices with the starting face.
[0072] Furthermore, the cloud server selects a unit face from the unit faces that have not been merged in the target plane as another starting face, and then uses the same method to take the other starting face as the merging basis to merge other unit faces that have the same color as the other starting face and share two vertices with the other starting face into the other starting face.
[0073] The advantage of this embodiment is that, by continuously merging unit surfaces, the degree and continuity of merging are improved, and the number of surfaces that need to be rendered by the three-dimensional rendering engine is further reduced.
[0074] Figure 3 A schematic diagram of merging unit surfaces according to an embodiment of the present disclosure is shown.
[0075] refer to Figure 3 As shown, in this embodiment, by continuously merging unit surfaces, at least one unit surface that is in the same plane and has the same color and fills the rectangular area is merged.
[0076] Specifically, there are 12 unit faces on the target plane, and each unit face has a color. Take unit face 1 as the starting face - since unit face 1 and unit face 2 are both red and share two vertices, unit face 2 is merged into unit face 1, the area of unit face 1 is expanded, and the vertices are changed accordingly; continuing, since unit face 1 and unit face 3 are both red after unit face 2 is merged, unit face 3 is merged into unit face 1 after unit face 2 is merged, the area of unit face 1 is expanded again, and the vertices are changed again accordingly. Similarly, the subsequent merging process will not be repeated.
[0077] It should be noted that this embodiment is only an exemplary description and should not limit the function and scope of use of the present disclosure.
[0078] In one embodiment, merging at least one unit surface that is in the same plane and has the same color and fills a rectangular area includes:
[0079] Select a plane to be rendered in the target object as the target plane, and set the number of loop merging times to 0;
[0080] In each merging cycle, based on the traversal of the vertices of the independent faces in the target plane, two independent faces with the same color and sharing two vertices in the target plane are merged in pairs, wherein each independent face is merged at most once in each merging cycle;
[0081] Each time a loop merge is completed, the number of loop merges is increased by one and the next loop merge is continued until the number of loop merges reaches a preset number threshold and the loop merge is terminated.
[0082] In this embodiment, two independent surfaces are merged in pairs cyclically, so as to merge at least one unit surface that has the same color and fills the rectangular area and is located in the same plane.
[0083] Specifically, the cloud server may pre-set a counter to record the number of loop merging, and initialize the counter to 0 before the loop merging starts. At the same time, a number threshold is pre-set, and once the value of the counter reaches the number threshold, the loop merging is terminated.
[0084] The cloud server selects a plane to be rendered in the target object as the target plane.
[0085] During each merging cycle, the cloud server traverses the vertices of the independent faces on the target plane, thereby merging two independent faces with the same color and two common vertices. The independent faces can be independent unit faces A and B, independent unit faces A and face B after merging, or independent face A and face B after merging. In addition, during each merging cycle, each independent face is merged at most once to avoid merging the same face with two or more other faces at the same time.
[0086] After each loop merge is completed, the cloud server increases the value of the counter by one and continues the next loop merge until the value of the counter reaches the number threshold and terminates the loop merge.
[0087] The advantage of this embodiment is that by merging two independent surfaces cyclically in pairs, the number of surfaces that the three-dimensional rendering engine needs to render is reduced to a near maximum extent, thereby improving the operating efficiency of the three-dimensional rendering engine to a near maximum extent.
[0088] Figure 4 A schematic diagram of merging unit surfaces according to an embodiment of the present disclosure is shown.
[0089] refer to Figure 4 As shown, in this embodiment, by merging two independent surfaces in pairs cyclically, at least one unit surface that is in the same plane and has the same color and fills the rectangular area is merged.
[0090] Specifically, there are 12 unit faces on the target plane, and each unit face has a color.
[0091] In the first cycle of merging, the 12 independent unit faces are merged in pairs. Since both unit faces 1 and 2 are red and share two vertices, unit faces 1 and 2 are merged to obtain merged face 13; similarly, unit faces 3 and 4 are merged to obtain merged face 14; unit faces 5 and 9 are merged to obtain merged face 15; unit faces 10 and 11 are merged to obtain merged face 16; unit faces 8 and 12 are merged to obtain merged face 17.
[0092] In the second merging cycle, the independent faces 13, 14, 15, unit face 7, unit face 9, 16, and 17 are merged in pairs. Since faces 13 and 14 are both red and share two vertices, faces 13 and 14 are merged to obtain the merged face 18.
[0093] It should be noted that this embodiment is only an exemplary description and should not limit the function and scope of use of the present disclosure.
[0094] In one embodiment, the method further comprises:
[0095] Keep the merging order consistent during each cycle merging process.
[0096] In this embodiment, during each cyclic merging process, the cloud server performs two-by-two merging in the same merging order to ensure the orderliness of the merging.
[0097] Figure 5 A schematic diagram of merging unit surfaces according to an embodiment of the present disclosure is shown.
[0098] refer to Figure 5 As shown, in this embodiment, in each cyclic merging process, two-by-two merging is performed in the same merging order.
[0099] Specifically, there are 12 unit faces on the target plane, and each unit face has a color. And the preset merging order is: merge from left to right first, and then merge from top to bottom.
[0100] During the first cycle of merging, the independent unit faces in the first row are first merged in pairs from left to right, thereby obtaining face 13 which is the merger of unit face 1 and unit face 2, and face 14 which is the merger of unit face 3 and unit face 4; then, in the second row, the independent unit faces are merged in pairs from left to right, thereby obtaining face 15 which is the merger of unit face 5 and unit face 6; then, in the third row, the independent unit faces are merged in pairs from left to right, thereby obtaining face 16 which is the merger of unit face 10 and unit face 11; then, in the order from top to bottom, the independent unit faces that have not yet been merged are merged in pairs, thereby obtaining face 17 which is the merger of unit face 8 and unit face 12.
[0101] During the second merging cycle, independent faces are still merged in pairs from left to right in the first row, so as to obtain face 18 which is the merger of face 13 and face 14; similarly, independent faces are merged in pairs from left to right in the second row, and then in pairs from left to right in the third row, and then independent faces that have not been merged are merged in pairs from top to bottom.
[0102] It should be noted that this embodiment is only an exemplary description and should not limit the function and scope of use of the present disclosure.
[0103] In one embodiment, selecting a plane to be rendered in the target object as the target plane includes:
[0104] Get the user's current perspective;
[0105] The order of the planes to be rendered of the target object as the target plane is determined in the viewing angle, and the target plane is selected according to the order.
[0106] In this embodiment, the cloud server preferentially selects the target plane based on the user's current viewing angle.
[0107] Specifically, the cloud server can determine the specific perspective from which the user is currently viewing the target object by reading the status of the user's virtual identity in the virtual 3D control system. After determining the user's current perspective, the cloud server then determines the order of the planes to be rendered as target planes based on the perspective, and selects the target plane according to the order.
[0108] For example: the cloud server pre-sets the order of selecting target planes as follows: the plane located in front of the viewing angle, the plane located on the left side of the viewing angle, the plane located on the back side of the viewing angle, the plane located on the right side of the viewing angle, the plane located on the top side of the viewing angle, and the plane located on the bottom side of the viewing angle.
[0109] The user uses bricks to build a virtual rectangular building to be rendered in the system. The six planes to be rendered of the virtual building are surface A, surface B, surface C, surface D, surface E and surface F.
[0110] The cloud server reads the status of the user's virtual identity in the system to determine that in the user's current perspective, surface B is located at the front, surface C is located at the left, surface D is located at the back, surface A is located at the right, surface E is located at the top, and surface F is located at the bottom.
[0111] The cloud server first uses surface B as the target plane to merge unit surfaces; after completing the merge on surface B, it uses surface C as the target plane to merge unit surfaces. Similarly, it uses surfaces D, E, and F as target planes and merges unit surfaces respectively.
[0112] The advantage of this embodiment is that by preferentially selecting the target plane from the user's current viewing angle, the rendering of the target object can preferentially meet the user's visual needs.
[0113] It should be noted that this embodiment is only an exemplary description and should not limit the function and scope of use of the present disclosure. It is understandable that in addition to preferentially selecting the target plane from the user's current viewing angle, the target plane can also be selected randomly.
[0114] In the disclosed embodiment, as long as a merge is successfully performed once, the number of target rectangular faces will be less than the number of unit faces, so that the amount of calculation required to call the three-dimensional rendering engine to render the target object by rendering the target rectangular faces is less than the amount of calculation required to call the three-dimensional rendering engine to render the target object by rendering the unit faces, thereby improving the operating efficiency of the three-dimensional rendering engine.
[0115] In one embodiment, before merging at least one unit surface that is in the same plane and has the same color and fills the rectangular area, the method further includes:
[0116] A unit cube whose six unit faces are all surrounded by other unit cubes is removed from the target object.
[0117] In this embodiment, before merging the unit faces, the cloud server removes from the target object the unit cubes whose six unit faces are all surrounded by other unit cubes, that is, removes from the target object the unit cubes wrapped inside the target object.
[0118] The advantage of this embodiment is that since the unit cube wrapped inside the target object cannot be seen by the user, no rendering is required from the user's perspective, so the unit cube wrapped inside the target object can be removed from the target object, thereby reducing the calculation amount of the 3D rendering engine and improving the operating efficiency of the 3D rendering engine.
[0119] In one embodiment, the method further comprises:
[0120] Based on the proportional reduction of the rendered target object, a miniature model of the target object is generated and rendered.
[0121] In this embodiment, after the rendering of the target object is completed, the cloud server scales down the target object in proportion to a preset ratio to generate a miniature model of the target object, and renders the miniature model using the same three-dimensional rendering method.
[0122] The advantage of this embodiment is that, by generating and rendering a miniature model of the target object, the user can view the overall structure and overall rendering effect of the target object, thereby improving the richness of the user's visual information.
[0123] Figure 6 A schematic diagram of rendering and miniaturizing a target object according to an embodiment of the present disclosure is shown.
[0124] refer to Figure 6 As shown, in this embodiment, the user generates and schedules bricks to build Figure 6 The target object is shown on the left half. By merging at least one unit face with the same color and filling the rectangular area in the same plane, a target rectangular face is obtained, and the target object is rendered by calling a 3D rendering engine to render the merged target rectangular face. The rendering effect is as follows Figure 6 As shown on the right; and the target object is proportionally reduced, and a miniature model of the target object is generated and rendered, such as Figure 6 Shown on the right.
[0125] It should be noted that this embodiment is only an exemplary description and should not limit the function and scope of use of the present disclosure.
[0126] Figure 7 A three-dimensional rendering device according to an embodiment of the present disclosure is shown, the device comprising:
[0127] An acquisition module 210 is configured to acquire a target object to be rendered, wherein the target object is composed of a plurality of unit cubes, wherein six unit faces of each unit cube have colors;
[0128] A merging module 220 is configured to merge at least one unit surface that is in the same plane and has the same color and fills the rectangular area to obtain a target rectangular surface included in the target object;
[0129] The rendering module 230 is configured to call a three-dimensional rendering engine to render the target object by rendering the target rectangular surface.
[0130] In an exemplary embodiment of the present disclosure, the device is configured as follows:
[0131] Selecting a plane to be rendered in the target object as a target plane;
[0132] Based on the traversal of the vertices of the unit faces in the target plane, two unit faces with the same color and sharing two vertices in the target plane are merged in pairs, wherein each unit face is merged at most once.
[0133] In an exemplary embodiment of the present disclosure, the device is configured as follows:
[0134] Selecting a plane to be rendered in the target object as a target plane, and selecting a unit plane from each unit plane in the target plane as a starting plane;
[0135] Based on the traversal of the vertices of each unit face in the target plane, whenever another unit face is traversed that has the same color as the starting face and shares two vertices with the starting face, the other unit face is merged into the starting face.
[0136] In an exemplary embodiment of the present disclosure, the device is configured as follows:
[0137] Select a plane to be rendered in the target object as the target plane, and set the number of loop merging times to 0;
[0138] In each merging cycle, based on the traversal of the vertices of the independent faces in the target plane, two independent faces with the same color and sharing two vertices in the target plane are merged in pairs, wherein each independent face is merged at most once in each merging cycle;
[0139] Each time a loop merge is completed, the number of loop merges is increased by one and the next loop merge is continued until the number of loop merges reaches a preset number threshold and the loop merge is terminated.
[0140] In an exemplary embodiment of the present disclosure, the device is configured to keep the merging order of the two merges consistent during each cycle merging process.
[0141] In an exemplary embodiment of the present disclosure, the device is configured as follows:
[0142] Get the user's current perspective;
[0143] The order of the planes to be rendered of the target object as the target planes is determined in the viewing angle, and the target planes are selected according to the order.
[0144] In an exemplary embodiment of the present disclosure, the apparatus is configured to remove, from the target object, unit cubes whose six unit faces are all surrounded by other unit cubes.
[0145] In an exemplary embodiment of the present disclosure, the apparatus is configured to generate and render a miniature model of the target object based on proportional reduction of the rendered target object.
[0146] Reference below Figure 8 The electronic device 30 for three-dimensional rendering according to an embodiment of the present disclosure is described. Figure 8 The electronic device 30 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present disclosure.
[0147] like Figure 8As shown, the electronic device 30 is in the form of a general computing device. The components of the electronic device 30 may include but are not limited to: at least one processing unit 310, at least one storage unit 320, and a bus 330 connecting different system components (including the storage unit 320 and the processing unit 310).
[0148] The storage unit stores program codes, which can be executed by the processing unit 310, so that the processing unit 310 performs the steps according to various exemplary embodiments of the present invention described in the description of the exemplary method described above in this specification. For example, the processing unit 310 can perform the following steps: Figure 1 The steps shown in .
[0149] The storage unit 320 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 3201 and / or a cache memory unit 3202 , and may further include a read-only memory unit (ROM) 3203 .
[0150] The storage unit 320 may also include a program / utility 3204 having a set (at least one) of program modules 3205, such program modules 3205 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0151] Bus 330 may represent one or more of several types of bus structures, including a memory unit bus or memory unit controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0152] The electronic device 30 may also communicate with one or more external devices 400 (e.g., keyboards, pointing devices, Bluetooth devices, etc.), may also communicate with one or more devices that enable a user to interact with the electronic device 30, and / or may communicate with any device that enables the electronic device 30 to communicate with one or more other computing devices (e.g., routers, modems, etc.). Such communication may be performed via an input / output (I / O) interface 350. The input / output (I / O) interface 350 is connected to a display unit 340. Furthermore, the electronic device 30 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) via a network adapter 360. As shown, the network adapter 360 communicates with other modules of the electronic device 30 via a bus 330. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the electronic device 30, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0153] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0154] In an exemplary embodiment of the present disclosure, a computer-readable storage medium is further provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor of a computer, the computer executes the method described in the above method embodiment.
[0155] According to one embodiment of the present disclosure, a program product for implementing the method in the above method embodiment is also provided, which can adopt a portable compact disk read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto, and in this document, a readable storage medium can be any tangible medium containing or storing a program, which can be used by or in combination with an instruction execution system, an apparatus or a device.
[0156] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0157] Computer readable signal media may include data signals propagated in baseband or as part of a carrier wave, in which readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Readable signal media may also be any readable medium other than a readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0158] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the foregoing.
[0159] Program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as JAVA, C++, etc., and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a separate software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device may be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., through the Internet using an Internet service provider).
[0160] It should be noted that, although several modules or units of the device for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into multiple modules or units to be embodied.
[0161] In addition, although the steps of the method in the present disclosure are described in a specific order in the drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. Additionally or alternatively, some steps may be omitted, multiple steps may be combined into one step, and / or one step may be decomposed into multiple steps, etc.
[0162] Through the description of the above implementation, it is easy for those skilled in the art to understand that the example implementation described here can be implemented by software, or by software combined with necessary hardware. Therefore, the technical solution according to the implementation of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable a computing device (which can be a personal computer, a server, a mobile terminal, or a network device, etc.) to execute the method according to the implementation of the present disclosure.
[0163] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modification, use or adaptation of the present disclosure, which follows the general principles of the present disclosure and includes common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The specification and examples are intended to be exemplary only, and the true scope and spirit of the present disclosure are indicated by the appended claims.
Claims
1. A three-dimensional rendering method, characterized in that: The method comprises: Acquire a target object to be rendered, wherein the target object is composed of a plurality of unit cubes, wherein six unit faces of each unit cube have colors; Merge at least one unit face with the same color and filling a rectangular area on the same plane to obtain a target rectangular face included in the target object, wherein the target rectangular face is composed of adjacent unit faces with the same color; A three-dimensional rendering engine is called to render the target object by rendering the target rectangular surface.
2. The method according to claim 1, characterized in that Merge at least one unit face with the same color and filling the rectangular area on the same plane, including: Selecting a plane to be rendered in the target object as a target plane; Based on the traversal of the vertices of the unit faces in the target plane, two unit faces with the same color and sharing two vertices in the target plane are merged in pairs, wherein each unit face is merged at most once.
3. The method according to claim 1, characterized in that Merge at least one unit face with the same color and filling the rectangular area on the same plane, including: Selecting a plane to be rendered in the target object as a target plane, and selecting a unit plane from each unit plane in the target plane as a starting plane; Based on the traversal of the vertices of each unit face in the target plane, whenever another unit face is traversed that has the same color as the starting face and shares two vertices with the starting face, the other unit face is merged into the starting face.
4. The method according to claim 1, characterized in that: Merge at least one unit face with the same color and filling the rectangular area on the same plane, including: Select a plane to be rendered in the target object as the target plane, and set the number of loop merging times to 0; In each merging cycle, based on the traversal of the vertices of the independent faces in the target plane, two independent faces with the same color and sharing two vertices in the target plane are merged in pairs, wherein each independent face is merged at most once in each merging cycle; Each time a loop merge is completed, the number of loop merges is increased by one and the next loop merge is continued until the number of loop merges reaches a preset number threshold and the loop merge is terminated.
5. The method according to claim 4, characterized in that The method further comprises: Keep the merging order consistent during each cycle merging process.
6. The method according to claim 2, 3 or 4, characterized in that: Selecting a plane to be rendered in the target object as a target plane includes: Get the user's current perspective; The order of the planes to be rendered of the target object as the target planes is determined in the viewing angle, and the target planes are selected according to the order.
7. The method according to claim 1, characterized in that Before merging at least one unit surface that is in the same plane and has the same color and fills the rectangular area, the method further includes: A unit cube whose six unit faces are all surrounded by other unit cubes is removed from the target object.
8. The method according to claim 1, characterized in that: The method further comprises: Based on the proportional reduction of the rendered target object, a miniature model of the target object is generated and rendered.
9. A three-dimensional rendering device, characterized in that: The device comprises: An acquisition module is configured to acquire a target object to be rendered, wherein the target object is composed of a plurality of unit cubes, wherein six unit faces of each unit cube have colors; a merging module configured to merge at least one unit face with the same color and filling a rectangular area on the same plane to obtain a target rectangular face included in the target object, wherein the target rectangular face is composed of adjacent unit faces with the same color; The rendering module is configured to call a three-dimensional rendering engine to render the target object by rendering the target rectangular surface.
10. An electronic device for three-dimensional rendering, characterized in that: include: a memory storing computer-readable instructions; The processor reads the computer readable instructions stored in the memory to execute the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Image rendering method and device, terminal and storage medium
CN109961498A
Front-end image rendering method and device and electronic equipment
CN111143018A