Disclosure of Invention
Therefore, in order to solve the technical problem that the network load is increased due to the fact that a large storage space is occupied by generating a wire frame Mesh in the graphics rendering process, the embodiment of the invention provides a method for determining vertex gravity center data, a wire frame generating method and a device, and specifically discloses the following technical scheme:
In a first aspect, an embodiment of the present invention discloses a method for determining vertex gravity center data, where the method may be applied to a processor CPU, or a processing chip, and the method includes:
The method comprises the steps of obtaining Mesh grid data, wherein the Mesh grid data comprises a plurality of triangles and vertex data of each triangle, determining public edges of all two adjacent triangles according to the triangles and the vertex data of each triangle, judging whether each public edge is located on a wire frame corresponding to the Mesh grid data, counting all public edges located on the wire frame to generate first wire frame data, the first wire frame data comprises N public edges, the N public edges are shared by M triangles, N is more than or equal to 1, M is more than or equal to 2, determining vertex gravity center data of each triangle according to indexes of the M triangles and the N public edges, and sending the vertex gravity center data to a graphics processor GPU when a client loads data.
With reference to the first aspect, in a possible implementation manner, determining whether each common edge is located on a wire frame corresponding to Mesh grid data includes determining whether a first common edge is located on the wire frame, where the first common edge is shared by the first triangle and the second triangle.
The method comprises the steps of judging whether a first public edge is located on a wire frame or not, judging whether an included angle between the normal line of a first triangle and the normal line of a second triangle is within a preset range or not, and if so, determining that the first public edge is located on the wire frame.
With reference to the first aspect, in another possible implementation manner, determining vertex gravity center data of each triangle according to indexes of M triangles and N common sides includes traversing the M triangles according to the indexes of the M triangles and the N common sides according to a distribution rule of vertex gravity centers and distributing the vertex gravity center data for each triangle.
With reference to the first aspect, in another possible implementation manner, after determining vertex barycenter data of each triangle according to indexes of the M triangles and the N common sides, determining whether collision occurs between all vertex barycenter data, if so, adding new vertex barycenter data to the vertex barycenter data with collision, and reassigning.
In a second aspect, an embodiment of the present invention further discloses a method for generating a wire frame based on vertex gravity center data, where the method is applicable to an image processor, such as a GPU, and the method includes:
When the client loads data, vertex barycenter data are received, the vertex barycenter data are determined by indexes of M triangles and N public sides corresponding to the indexes, barycenter coordinates of each triangle in the M triangles are determined according to the vertex barycenter data, differences between the distances between the vertex barycenter data of each triangle and barycenter coordinates of the current triangle are compared, if the differences between the distances are within a preset range, the current vertex barycenter data are determined to be located on a wire frame of the chip element, and the wire frame of the chip element is colored.
In a third aspect, the embodiment of the present invention further discloses a device for determining vertex gravity center data, where the device includes:
The acquisition module is used for acquiring Mesh grid data, wherein the Mesh grid data comprises a plurality of triangles and vertex data of each triangle;
A first determining module, configured to determine, according to the plurality of triangles and vertex data of each triangle, a common edge of all two adjacent triangles, where the number of common edges is one or more;
A detection module for judging whether each public edge is positioned on the wire frame corresponding to the Mesh grid data,
The generating module is used for counting all public edges on the wire frame to generate first wire frame data, the first wire frame data comprise N public edges, the N public edges are shared by M triangles, N is more than or equal to 1, M is more than or equal to 2, and M and N are positive integers;
The first determining module is further used for determining vertex gravity center data of each triangle according to indexes of the M triangles and N public sides;
And the sending module is used for sending the vertex gravity center data to the GPU when the client loads the data.
In a fourth aspect, an embodiment of the present invention further discloses a wire frame generating device based on vertex gravity center data, where the device includes:
The receiving module is used for receiving vertex gravity center data when the client loads data, wherein the vertex gravity center data is determined by indexes of M triangles and N corresponding public sides;
the second determining module is used for determining the barycentric coordinates of each triangle in the M triangles according to the vertex barycentric data;
the comparison module is used for comparing the difference between the vertex gravity center data of each triangle and the distance between the gravity center coordinates of the current triangle;
And the second determining module is also used for determining that the current vertex gravity center data is positioned on the wire frame of the element when the difference of the distances compared by the comparing module is in a preset range and coloring the wire frame of the element.
In a fifth aspect, the embodiments of the present invention also disclose a wire frame generation system, which includes a central processing unit CPU and a graphics processing unit GPU, wherein,
The CPU is used for acquiring Mesh grid data, and determining the public edges of all two adjacent triangles according to the triangles and the vertex data of each triangle, wherein the number of the public edges is one or more; judging whether each public edge is positioned on a wire frame corresponding to Mesh grid data, counting all public edges positioned on the wire frame, generating first wire frame data, determining vertex gravity center data of each triangle according to indexes of M triangles and N public edges, and sending the vertex gravity center data to a GPU (graphics processing Unit) when a client loads the data;
The GPU is used for receiving vertex gravity data sent by the CPU when the client loads data, determining the gravity center coordinates of each triangle in the M triangles according to the vertex gravity data, comparing the difference between the distances between the vertex gravity data of each triangle and the gravity center coordinates of the current triangle, determining that the current vertex gravity data is positioned on a wire frame of the chip element if the difference between the distances is within a preset range, and coloring the wire frame of the chip element.
The Mesh grid data comprises a plurality of triangles and vertex data of each triangle, the first frame data comprises N public sides, the N public sides are shared by M triangles, N is more than or equal to 1, and M is more than or equal to 2.
In a sixth aspect, an embodiment of the present invention further discloses an electronic device, including a processor and a memory, where the memory is coupled to the processor, and the memory stores computer readable program instructions thereon, which when executed by the processor, implement a method for determining vertex gravity center data according to the foregoing first aspect, and a wire frame generating method based on vertex gravity center data according to the foregoing second aspect.
Further, the present embodiment also discloses a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the steps of the method for determining vertex barycenter data as described in the foregoing first aspect, and the method for generating a wire frame based on vertex barycenter data as described in the foregoing second aspect.
According to the technical problems, aiming at the BIM model, the embodiment of the invention provides a method for determining vertex gravity center data, a wire frame generating method and a device, common edges of all two adjacent triangles are determined according to a plurality of triangles in Mesh data and vertex data of each triangle, wire frame data is generated according to whether each common edge is positioned on a wire frame corresponding to the Mesh data, finally vertex gravity center data of each triangle is determined according to indexes of the plurality of triangles and the common edges of the triangles, and the wire frame is determined by using the vertex center data of the triangles.
In addition, the method does not need independent rendering operation, and because the method can generate the wire frame in real time when Mesh grid data is rendered, CPU overhead is not additionally generated basically, and therefore the overhead of the GPU is correspondingly and greatly reduced, and the load performance is prevented from being influenced by larger network load.
Detailed Description
The following description of the embodiments of the present invention will be made apparent and fully in view of the accompanying drawings, in which some, but not all embodiments of the invention are shown. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
First, technical terms related to the technical scheme of the present application will be described.
Mesh, transliterated as a "Mesh", consists of a series of triangular patches containing indices (indices) of three points of a triangle by which the location (position), normal (Normal), color (Color), etc. of the corresponding point can be found in the vertex list. As shown in fig. 1, a dog-shaped three-dimensional model is shown, comprising a series of triangular panels, each of which may be triangular with 3 vertices, with information about vertex association location, normal, color, etc.
Rendering instructions. In the application stage, after the CPU prepares the data and completes the transmission task, the CPU issues a rendering instruction to the GPU, wherein the rendering instruction is called as a Draw Call, and the Draw Call refers to a primitive list to be rendered and comprises material information corresponding to the primitive list, namely, the CPU calls a graphic API interface to command the GPU to perform rendering operation.
Fig. 2 is a schematic software structure of an electronic device according to an embodiment of the present invention. Taking terminal equipment of an Android system as an example, a layered architecture divides software into a plurality of layers, and each layer has clear roles and division. The layers communicate with each other through a software interface. Referring to fig. 2, in some embodiments, the Android system in the software structure of the terminal device is an application layer (APP), a rendering layer and a data processing layer from top to bottom, and the data processing layer further includes a hardware abstraction layer (Hardware Abstraction Layer, HAL) (not shown in fig. 2).
Further, a series of application packages may be included at the application layer, such as Web APP, calendar APP, H5 (5 th generation HTML, hypertext markup language), PC, mobile phone mobile, etc. In this embodiment, the Web APP is an application program presented at a Web page end.
The rendering layer may be a Framework layer (Framework). The framework layer provides an application programming interface (Application Programming Interface, API) and programming framework for application programs of the application layer. The framework layer includes some predefined functions.
As shown in fig. 2, the rendering layer may be used to perform operations such as model loading, mesh loading, vertex data loading, material loading, and model rendering, mesh rendering, and outline rendering.
The data processing layer comprises at least one functional module for executing functions such as Mesh batch, vertex data generation, outline vertex gravity data generation, material preservation, texture preservation, material attribute preservation, data texture preservation and the like.
Furthermore, in the hardware abstraction layer HAL, the main role is to abstract the hardware. The method is to put the actions of control hardware into an Android HAL. In this embodiment, the HAL includes a graphics card, where the graphics card includes a vertex shader, a fragment shader, a memory, and other components.
The Pixel Shader (FRAGMENT SHADER) may also be referred to as a Pixel Shader (Pixel Shader), for computing colors for each Pixel, and using texture sampling, among other operations. Specifically, the fragment shader runs FRAGMENT SHADER for each pixel that needs to be rendered, sets the color of the pixel, and finally renders on the screen, once for each pixel.
It should be understood that other more or fewer modules may be included in the software architecture diagram, which is not limited in this embodiment.
Generally, the image generation and processing process comprises an application stage, a geometric stage, a rasterization stage and other processing flows. As shown in fig. 3, in the application phase, it is mainly responsible for the central processing unit CPU and can be managed and controlled by the developer. At this stage, the CPU passes the decision to the graphics processor GPU some data such as data texture, polygon Mesh vertices, framing settings, and light source data such as the lights in the rendered target scene, model of the scene, camera position, etc. In addition, the data transferred to the GPU may include rendering states of the data, such as texture data, vertex gravity data, materials, and the like.
The GPU performs the geometry stage and the rasterization stage mainly, and the GPU performs further processing on the data (such as vertex gravity data) sent by the CPU in the application stage in the geometry stage, where the stage includes a plurality of steps, such as performing operations on the geometric transformation sequentially through primitive data, vertex shader, tessellation shader, set shader, projection, clipping, screen mapping, and the like, and these processing processes can be analogically understood as a process performed on a factory pipeline.
In the stage of rasterization, mainly the operations of rasterization processing, illumination calculation and the like are executed, specifically, the GPU processes vertex information collected in the video memory through primitive assembly, triangle traversal, primitive shader, primitive-by-primitive operation and the like, and finally an image is generated and displayed through a display.
The method provided by the embodiment relates to the vertex barycenter data processing process of the application stage and the process of generating images by rendering at the geometric stage and the fragment shader of the rasterization node.
The method is mainly used for solving the following technical problems:
1. In the process of the rasterization stage, the wire frame Mesh data which are required to be additionally generated are rendered, the storage space occupied by the Mesh data is about 35% -300% of that of the original Mesh, and further the BIM model light engine is used as an engine for real-time network rendering, so that the storage space is occupied, the network load is increased, and the loading performance is influenced.
2. Wire frame Mesh grid data in the current scheme is required to be independently rendered, so that the cost of a CPU and a GPU is additionally increased, and the rendering performance and the smoothness of operation are affected.
In order to solve the technical problems in the rendering process, the embodiment of the application provides a technical scheme for generating a wire frame (outline) in real time during rendering based on vertex gravity data, and the technical scheme provided by the embodiment of the application is described in detail below.
The technical scheme of the application can be applied to electronic equipment such as a mobile phone. The mobile phone may also be other terminal devices, where the terminal device may be a portable device, such as a smart phone, a tablet computer, a personal computer (personal computer, PC), a foldable terminal, a User Equipment (UE), or a User Equipment (UE), and the specific device configuration of the terminal device is not limited in this embodiment.
In addition, android (Android) operating systems and/or Android-compatible systems are/is mounted in the various terminal devices.
Referring to fig. 4, a method for determining vertex gravity center data is provided in an embodiment of the present invention, where the method is based on a wire frame real-time generation technology in a BIM model lightweight engine, and a technical scheme for implementing wire frame real-time generation by using principles of vertex gravity center data, rasterization, edge search, and the like.
The method is executed by the CPU in an application stage, and specifically comprises the following steps:
step 101, mesh grid data are obtained, wherein the Mesh grid data comprise a plurality of triangles and vertex data of each triangle.
The mesh grid data is triangle grid data as shown in fig. 1 and described above. Specifically, one way to obtain Mesh grid data is that the CPU of the terminal device first obtains three-dimensional model data, such as three-dimensional model data (e.g., BIM model data) of a certain building, and then analyzes the three-dimensional model data to obtain Mesh grid data. The specific process of obtaining Mesh grid data through parsing may be a lightweight method or other methods, which will not be described in detail in this embodiment.
Resolved vertex data for a plurality of triangles, and vertex data for each triangle, the vertex data being represented by x, y, z three-axis coordinates. It should be understood that the vertex data includes, but is not limited to, vertex coordinates.
Step 102, determining the common edges of all two adjacent triangles according to the triangles and the vertex data of each triangle, wherein the number of the common edges is one or more.
Wherein two triangles are adjacent to each other resulting in a common edge, also known as a "shared edge" (CREASE EDGE).
CREASE EDGE are shared by two triangles, but the included angle exceeds a certain value (DIHEDRAL ANGLE, typically 60 degrees), for example a cube contains a plurality of CREASE EDGES.
Specifically, it may be determined whether the plurality includes a common edge (CREASE EDGE) by the vertex index of each triangle. For example, if the 3 vertex indices of the first triangle are 123 and the 3 vertex indices of the second triangle are 234, respectively, then a common edge of 23 exists between the two triangles.
And step 103, judging whether each public edge is positioned on a wire frame corresponding to the Mesh grid data, and counting all public edges positioned on the wire frame to generate first wire frame data.
The first frame data comprises N public sides, the N public sides are shared by M triangles, N is more than or equal to 1, M is more than or equal to 2, and M and N are positive integers. In this embodiment it is assumed that there is at least one common edge, i.e. the common edge is shared by both triangles.
And 104, determining vertex gravity center data of each triangle according to the indexes of the M triangles and the N public sides.
Wherein, the vertex data includes Position, color, normal, UV, and the like, and the image graphics are generated by rendering the vertex data. The vertex data includes vertex centroid data.
Specifically, according to an allocation rule of vertex barycenters, traversing M triangles according to indexes of the M triangles and N public sides, allocating vertex barycenter data for each triangle, and writing the vertex barycenter data into mesh grid data.
And step 105, when the client loads data, sending the vertex gravity center data to a graphics processor GPU.
When the client loading data is detected, the CPU transmits the mesh written in the vertex center data to the GPU for the GPU to perform rasterization processing and image rendering.
Each triangle is traced upon rasterization (rendering pipeline), so it is determined how far from the three edges of the triangle the current fragment is colored by the bounding box once it is less than the width of the box. At present, a barycentric coordinate system is constructed by using three vertexes of a triangle, and the barycentric coordinate corresponding to the current fragment can be obtained by utilizing interpolation of a fragment shader. And the barycentric coordinates are used as weights to determine the color of the fragment during the rasterization process.
Referring to FIG. 5, among three vertices C1, C2, and C3 of a triangle, weight values are determined to correspond to λ1, λ2, and λ3, respectively, and based on these 3 weight values, the center of gravity data Ppoint color is determined to be C1.λ1+C2.λ2+C3.λ3.
As shown in fig. 6, in one triangle, 3 vertices are A1, A2, and A3, respectively, wherein the vertex index of A1 is 0, the vertex centroid data is (1, 0), the vertex index of A2 is 2, the vertex centroid data is (0, 1), the vertex index of A3 is 1, and the vertex centroid data is (0, 1, 0). Judging whether 3 sides A1A2, A1A3 and A2A3 of the triangle are positioned on the wire frame or not can be determined by the following method:
In a specific embodiment, the step 103 of determining whether each common edge is located on the wire frame corresponding to the Mesh grid data includes determining, by way of example, whether a first common edge is located on the wire frame, where the first common edge is shared by a first triangle and a second triangle.
And step 103, judging whether the first public edge is positioned on the wire frame or not, wherein the step comprises judging whether an included angle between the normal line of the first triangle and the normal line of the second triangle is in a preset range or not, if so, determining that the first public edge is positioned on the wire frame, and if not, not positioning on the wire frame.
For example, CREASE EDGE is the common edge of triangle 1 and triangle 2, determine CREASE EDGE from triangle 1 and triangle 2 if triangle 1 is located on a wire frame, and if so, determine CREASE EDGE1 is part of the wire frame. According to the triangle normal angle, determining a method, for example, if the angle is judged to be within a preset range, such as 45-135 degrees, then CREASE EDGE is determined on the wire frame of the whole model, otherwise, the angle is not on the wire frame. In addition, it includes recording the relationship between triangle 1, triangle 2, CREASE EDGE1 if so, i.e., on the wire frame.
Similarly, other common edges CREASE EDGE may also be used to determine whether they belong to the frame, which is not an example.
In another embodiment, it is determined whether the common edge CREASE EDGE1 is located on the wire frame, and it may also be determined by calculating a distance, comparing whether the distance between the point Q on the current CREASE EDGE1 and the barycentric coordinates of the vertex is within a preset distance, if so, determining that the point Q on the current CREASE EDGE1 is located on the wire frame, otherwise, not on the wire frame.
The embodiment provides a method for determining vertex gravity center data, which determines common edges of all two adjacent triangles according to a plurality of triangles in Mesh data and vertex data of each triangle, generates line frame data according to whether each common edge is positioned on a line frame corresponding to the Mesh data, and finally determines vertex gravity center data of each triangle according to indexes of the plurality of triangles and the common edges of the triangles.
In addition, the method does not need independent rendering operation, and because the method can generate the wire frame in real time when Mesh grid data is rendered, CPU overhead is not additionally generated basically, and therefore the overhead of the GPU is correspondingly and greatly reduced, and the load performance is prevented from being influenced by larger network load.
In addition, after determining vertex gravity center data of each triangle according to indexes of M triangles and N common sides in the step 104, the method further includes judging whether collision occurs among all the vertex gravity center data, if so, adding new vertex gravity center data for the vertex gravity center data with collision, and reassigning.
After the triangle vertex position P is passed through the vertex gravity data, it also continuously judges if the vertex gravity data allocation is conflicted, i.e. the same vertex data is allocated to two or more triangles, if there is confliction, for example, the first vertex of triangle 1 and the second vertex of triangle 2 are the same point A1, but A1 is (1, 0) in triangle 1 vertex gravity data, A1 is (1, 0) in triangle 2 vertex gravity data, if the two are different, the replication point A1 obtains B1, the A1 vertex gravity data (1, 0) is allocated to triangle 1, the point B1 vertex gravity data (1, 0) is allocated to triangle 2, so as to avoid confliction.
If the vertex barycenter data do not conflict, generating the vertex barycenter data, and storing the vertex barycenter data for use in subsequent loading.
According to the method provided by the embodiment, after the vertex gravity center data are distributed, the conflict problem of vertex gravity center distribution is solved by using the vertex adding scheme, the reasonable and non-repeated use of the distributed vertex gravity center data is ensured, and the accuracy of using the Mesh data in the subsequent image rendering is improved.
The foregoing embodiment is a data processing procedure of the geometric phase, and a rasterization phase processing procedure is described below.
Referring to fig. 7, a wire frame generating method based on vertex gravity center data according to the present embodiment is applicable to a GPU, and generates a wire frame in real time by using vertex gravity center data determined by a CPU on the GPU side. The GPU comprises a fragment shader, and the fragment shader uses barycentric coordinates as weights to determine the colors of the fragments.
As shown in fig. 7, the method includes:
Step 201, receiving vertex gravity data when the client loads the data.
The vertex gravity center data is determined by indexes of M triangles and N corresponding public sides, and specifically, the vertex gravity center data can be data which is determined by a CPU and then written into a mesh, and is obtained through the written data. Further, the determining process of the vertex gravity center data refers to the method steps shown in fig. 3, and this embodiment is not repeated.
And 202, determining the barycenter coordinates of each triangle in the M triangles according to the vertex barycenter data.
And the GPU analyzes the vertex gravity center data in the mesh data to obtain M triangles and gravity center coordinates of each triangle.
Step 203 of comparing the difference between the vertex gravity data of each triangle and the distance of the gravity coordinates of the current triangle.
The graphics card interpolates three vertex data of the triangle in the rasterization process to obtain vertex data of the current fragment, wherein the vertex data comprises the barycentric coordinates of the current triangle. And the graphics card generates vertex data in real time.
The vertex gravity data of each triangle may be determined by the steps 101 to 105 of the above embodiments, and sent to the fragment shader by the GPU.
Step 204, if the difference between the distances is within the preset range, determining that the current vertex gravity center data is positioned on the wire frame of the element, and coloring the wire frame of the element.
Comparing the magnitude relation between each distance difference calculated in step 203 and the preset range d Is provided with, if d Is provided with is less than or equal to d, determining that the vertex center data is located on the wire frame, otherwise, not on the wire frame.
When the method is used for image rendering, vertex gravity data are rasterized and transmitted into a fragment Shader Pixel loader, according to the transmitted vertex gravity data, how large the distance between the current fragment and three sides of a triangle is can be calculated, and if the distance is smaller than a given frame width (namely a preset range d Is provided with), the method executes the preset frame color on the current fragment so as to complete real-time frame generation.
In the GPU image rendering stage, the wire frame real-time generation scheme in the BIM model lightweight engine is designed, the storage space of wire frame data is greatly reduced, the data loading scheduling efficiency is improved, the wire frames are generated in real time during rendering, and the wire frame rendering efficiency is improved.
In addition, the method does not need to additionally generate more Mesh data, does not need to bind a wire frame and the original Mesh, and can draw together with the original Mesh data, so that the rendering efficiency is improved.
In this embodiment, a determination method for determining vertex gravity center data in the above embodiment is further provided, and details thereof are omitted. As used below, the term "unit" or "module" may be a combination of software and/or hardware that implements the predetermined functionality. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated.
The present embodiment provides a device for determining vertex gravity center data, as shown in fig. 8, including:
An obtaining module 801, configured to obtain Mesh grid data, where the Mesh grid data includes a plurality of triangles and vertex data of each triangle.
A first determining module 802, configured to determine a common edge of all two adjacent triangles according to the triangles and vertex data of each triangle, where the number of common edges is one or more.
A detection module 803, configured to determine whether each common edge is located on a wire frame corresponding to the Mesh grid data,
The generating module 804 is configured to count all public edges on the wire frame, generate first wire frame data, where the first wire frame data includes N public edges, the N public edges are shared by M triangles, N is greater than or equal to 1, M is greater than or equal to 2, and M and N are positive integers.
The first determining module 802 is further configured to determine vertex gravity data of each triangle according to the indexes of the M triangles and the N common sides.
And the sending module 805 is configured to send the vertex barycenter data to the graphics processor GPU when the client loads the data.
In a specific implementation manner of this embodiment, the detection module 803 is specifically configured to determine whether a first common edge is located on the wire frame, where the first common edge is shared by the first triangle and the second triangle.
Further, the detection module 803 is specifically further configured to determine whether an included angle between a normal line of the first triangle and a normal line of the second triangle is within a preset range, and if so, determine that the first common edge is located on the wire frame.
Optionally, in another specific implementation manner of this embodiment, the first determining module 802 is specifically further configured to, according to an allocation rule of vertex barycenters, traverse the M triangles according to the indexes of the M triangles and the N common sides, and allocate vertex barycenter data to each triangle.
Optionally, in another specific implementation manner of this embodiment, the detection module 803 is further configured to determine whether a conflict occurs between all vertex gravity center data, and if so, add new vertex gravity center data to the vertex gravity center data having the conflict, and reassign the vertex gravity center data.
In addition, in another embodiment, as shown in fig. 9, there is also provided a wire frame generating device based on vertex gravity center data, for implementing the function of the foregoing wire frame generating method based on vertex gravity center data, the device including:
The receiving module 901 is configured to receive vertex barycenter data when the client loads data, where the vertex barycenter data is determined by indexes of M triangles and N public sides corresponding to the indexes.
A second determining module 902, configured to determine barycentric coordinates of each triangle in the M triangles according to the vertex barycentric data.
A comparison module 903, configured to compare a difference between the vertex barycentric data of each triangle and a distance between the barycentric coordinates of the current triangle.
The second determining module 904 is further configured to determine that the current vertex gravity center data is located on the wire frame of the primitive and color the wire frame of the primitive when the difference between the distances compared by the comparing module is within a preset range.
In addition, the apparatus may further include other more or fewer units/modules, such as a transmitting module, a storage module, and the like, which is not limited in this embodiment.
It should be noted that, the vertex gravity center data determining device and the wire frame generating device in the above embodiments are presented in the form of functional units, where the units refer to ASIC circuits, processors and memories that execute one or more software or firmware programs, and/or other devices that may provide the above functions.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding embodiments, and are not repeated here.
The embodiment of the invention also provides electronic equipment, which is provided with the device for determining the vertex gravity center data shown in the figure 8 and the wire frame generating device shown in the figure 9.
Referring to fig. 10, a schematic structural diagram of an electronic device according to an embodiment of the present invention includes a CPU, a bridge, a system memory, a GPU (Graphics Processing Unit, a graphics processor), and at least one video memory.
The CPU is connected with the GPU through the bridge, and is also connected with the system memory through the bridge. The GPU is connected with at least one video memory through an internal switching bus.
Referring to fig. 10, the GPU includes a driving interface, a data input assembly module, a vertex task distribution module, a pixel task distribution module, a computing task distribution module, a plurality of SMs (STREAMING MULTIPROEESSOR, stream processors), an internal switching bus, ROPs (Raster Operations Unit, a rasterizing processing unit), and an L2 Cache (Cache).
The CPU is used for acquiring Mesh grid data, determining common edges of all two adjacent triangles according to the triangles and vertex data of each triangle, judging whether each common edge is positioned on a wire frame corresponding to the Mesh grid data, counting all the common edges positioned on the wire frame, generating first wire frame data, determining vertex gravity center data of each triangle according to indexes of M triangles and N common edges, and sending the vertex gravity center data to the GPU when a client loads the data.
The GPU is used for receiving vertex gravity data sent by the CPU when the client loads data, determining the gravity center coordinates of each triangle in the M triangles according to the vertex gravity data, comparing the difference between the distances between the vertex gravity data of each triangle and the gravity center coordinates of the current triangle, determining that the current vertex gravity data is positioned on a wire frame of the chip element if the difference between the distances is within a preset range, and coloring the wire frame of the chip element.
The CPU sends Mesh grid data to the data input assembly module through the driving interface, and then distributes the data to each task distribution module, such as a vertex task distribution module, a pixel task distribution module, a calculation task distribution module and the like. These task distribution modules send the data to be processed to one or more SM stream processors that are used to perform processing operations such as viewport/clipping/rasterization/depth testing.
In one embodiment, each SM stream processor includes structure functions such as vertex shader, pixel shader, and texture unit, and the structure functions are used to process vertex coordinates, pixel values, and texture data. And sends the processed data to the ROP and L2 via the internal switching bus. Extraction and identification of different materials in the model are also included in the SM stream processor.
In addition, ROP represents the number of ROP raster operation processing units owned by the display GPU, and the rendering process of the ROP unit includes that firstly, picked materials and pixels processed by the SM stream processor are transmitted to corresponding z/step buffer, the ROP unit performs z/step check (i.e. front-back shading relation check) on the textures and the pixels, and the determination of depth and template information can enable the ROP to make a decision on which pixels are displayed, so that the completely shaded pixels are prevented from being displayed in front in error, and meanwhile, the pressure of a subsequent output part can be reduced.
Finally, the ROP processed image data is stored in a memory, including but not limited to DRAM (Dynamic Random Access Memory ).
As described above, CPU (Central Processing Unit) shown in FIG. 10 may be a central processing unit. The CPU may further include a hardware chip. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general-purpose array logic, or any combination thereof.
The system memory stores computer program instructions executable by the CPU to cause the CPU to perform the vertex gravity center data determining method according to the above embodiment.
The system memory may include high speed random access memory and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid state storage device. In some alternative embodiments, the system memory optionally includes memory located remotely from the CPU, the remote memory being connectable to the electronic device over a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The system memory may comprise volatile memory, such as random access memory, or nonvolatile memory, such as flash memory, hard disk, or solid state disk, or a combination of the foregoing.
The electronic equipment further comprises an input device and an output device. Including but not limited to a touch screen, a keypad, a mouse, a trackpad, a touch pad, a pointer stick, one or more mouse buttons, a trackball, a joystick, and the like. The output means may comprise a display device or the like. Such display devices include, but are not limited to, liquid crystal displays, light emitting diodes, displays and plasma displays.
The embodiments of the present invention also provide a computer readable storage medium, and the method according to the embodiments of the present invention described above may be implemented in hardware, firmware, or as a computer code which may be recorded on a storage medium, or as original stored in a remote storage medium or a non-transitory machine readable storage medium downloaded through a network and to be stored in a local storage medium, so that the method described herein may be stored on such software process on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium may be a magnetic disk, an optical disk, a read-only memory, a random-access memory, a flash memory, a hard disk, a solid state disk, or the like, and further, the storage medium may further include a combination of the above types of memories.
It will be appreciated that a computer, processor, microprocessor controller or programmable hardware includes a storage element that can store or receive software or computer code that, when accessed and executed by the computer, processor or hardware, implements the methods illustrated by the above embodiments.
Although embodiments of the present invention have been described in connection with the accompanying drawings, various modifications and variations may be made by those skilled in the art without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope of the invention as defined by the appended claims.