CN113205580A - Primitive rendering method, device and equipment and storage medium - Google Patents

Primitive rendering method, device and equipment and storage medium Download PDF

Info

Publication number
CN113205580A
CN113205580A CN202110506311.5A CN202110506311A CN113205580A CN 113205580 A CN113205580 A CN 113205580A CN 202110506311 A CN202110506311 A CN 202110506311A CN 113205580 A CN113205580 A CN 113205580A
Authority
CN
China
Prior art keywords
primitive
color
indication parameter
rendering
target
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110506311.5A
Other languages
Chinese (zh)
Inventor
曾仲光
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shenzhen Wanyi Digital Technology Co ltd
Original Assignee
Wanyi Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Wanyi Technology Co Ltd filed Critical Wanyi Technology Co Ltd
Priority to CN202110506311.5A priority Critical patent/CN113205580A/en
Publication of CN113205580A publication Critical patent/CN113205580A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/005General purpose rendering architectures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/001Texturing; Colouring; Generation of texture or colour
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/40Filling a planar surface by adding surface attributes, e.g. colour or texture
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/04Texture mapping
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Graphics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Generation (AREA)

Abstract

The method comprises the steps of obtaining a primitive rendering instruction of a target primitive in a target engineering drawing, wherein the primitive rendering instruction carries a color indication parameter used for indicating the color of the target primitive, and the storage space occupied by the color indication parameter is smaller than the storage space occupied by describing the target primitive by adopting an RGB color mode; analyzing the primitive rendering instruction to obtain the color indication parameter; acquiring a color value corresponding to the color indication parameter; and rendering the target primitive by adopting the acquired color value, wherein the problems that the existing VBO object occupies a large storage space and the rendering rate of the primitive is low are solved.

Description

Primitive rendering method, device and equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method, an apparatus, a device, and a storage medium for rendering a primitive.
Background
A primitive is a combination of several different points, lines, surface elements, or the same element.
RGB colors are the commonly-known three primary optical colors, R stands for Red (Red), G stands for Green (Green), and B stands for Blue (Blue), and colors visible to the naked eye in nature can be formed by mixing and superposing the three colors. The RGB color scheme is an additive color scheme, and any color is described by the amount of radiation R, G, B. When the color definition is displayed on a display screen, an RGB mode is often adopted, and the value range of R, G, B is 0-255.
The existing webGL records element information using a Vertex Buffer Object (VBO), wherein the VBO object includes a color (color) parameter (r.g.b.a), and it can be seen that each color parameter requires 4 bits (bit) to record. Wherein a in the color parameter represents transparency.
In Computer Aided Design (CAD), there are 256 color types, and it can be seen that 256 × 4 bits are required to record all colors.
Therefore, the existing recording mode needs to occupy a larger storage space, which causes the waste of data buffer resources.
Because of the existing recording mode of the VBO object, the VBO object occupies a larger space of a data buffer area, and the rendering rate of the graphic element is reduced.
Disclosure of Invention
The application provides a primitive rendering method, which is used for solving the problems that the existing VBO object occupies a large storage space and the primitive rendering rate is low.
In a first aspect, an embodiment of the present application provides a primitive rendering method, where the method includes:
acquiring a primitive rendering instruction of a target primitive in a target engineering drawing, wherein the primitive rendering instruction carries a color indication parameter for indicating the color of the target primitive, and the storage space occupied by the color indication parameter is smaller than the storage space occupied by describing the target primitive by adopting an RGB color mode;
analyzing the primitive rendering instruction to obtain the color indication parameter;
acquiring a color value corresponding to the color indication parameter;
and rendering the target graphic element by adopting the acquired color value.
Optionally, before the obtaining of the primitive rendering instruction for the target primitive in the target engineering drawing, the method further includes:
creating a two-dimensional matrix corresponding to a preset color quantity, wherein the preset color quantity is the quantity of colors corresponding to the target graphic primitive;
writing the color value corresponding to the target graphic element into the pixel of the created two-dimensional matrix;
configuring a corresponding relation between each position coordinate in the two-dimensional matrix written with the color values and the color indication parameters;
the obtaining of the color value corresponding to the obtained color indication parameter includes:
and acquiring the color value corresponding to the obtained color indication parameter based on the corresponding relation.
Optionally, the parsing the primitive rendering instruction to obtain the color indication parameter includes:
and inputting the primitive rendering instruction to a vertex shader, analyzing the primitive rendering instruction through the vertex shader to obtain the color indication parameter, and outputting the color indication parameter.
Optionally, the obtaining a color value corresponding to the color indication parameter includes:
and inputting the color indication parameter output by the vertex shader into a fragment shader, calculating a color value corresponding to the input color indication parameter through the fragment shader, and outputting the color value.
Optionally, the calculating, by the fragment shader, a color value corresponding to the input color indication parameter, and outputting the color value includes:
and determining the position coordinate corresponding to the color indication parameter through the fragment shader based on the corresponding relation, determining a color value corresponding to the position coordinate corresponding to the color indication parameter in the two-dimensional matrix, and outputting the color value.
Optionally, the preset number of colors is 256;
the creating of the two-dimensional matrix corresponding to the preset number of colors includes:
creating a two-dimensional matrix of 16 x 16 corresponding to said preset number of colors.
Optionally, the primitive rendering instruction further carries a primitive unique identifier for indicating the target primitive;
the rendering the target primitive by using the obtained color value comprises:
analyzing the primitive rendering instruction to obtain the unique identifier of the primitive;
determining each element with the primitive unique identifier, wherein one element corresponds to one primitive unique identifier, and the primitive unique identifiers of the elements in the same primitive are consistent;
and rendering each element by adopting the acquired color value.
In a second aspect, an embodiment of the present application provides a primitive rendering apparatus, including:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a primitive rendering instruction of a target primitive in a target engineering drawing, the primitive rendering instruction carries a color indication parameter for indicating the color of the target primitive, and the storage space occupied by the color indication parameter is smaller than the storage space occupied by describing the target primitive by adopting an RGB color mode;
the analysis module is used for analyzing the primitive rendering instruction to obtain the color indication parameter;
the second acquisition module is used for acquiring the color value corresponding to the color indication parameter;
and the rendering module is used for rendering the target graphic primitive by adopting the acquired color value.
In a third aspect, an embodiment of the present application provides an electronic device, including: the system comprises a processor, a memory and a communication bus, wherein the processor and the memory are communicated with each other through the communication bus;
the memory for storing a computer program;
the processor is configured to execute the program stored in the memory, and implement the primitive rendering method according to the first aspect.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the computer program implements the primitive rendering method according to the first aspect.
Compared with the prior art, the technical scheme provided by the embodiment of the application has the following advantages: according to the method provided by the embodiment of the application, the primitive rendering instruction of the target primitive in the target engineering drawing is obtained, the primitive rendering instruction carries the color indication parameter for indicating the color of the target primitive, and the storage space occupied by the color indication parameter is smaller than the storage space occupied by describing the target primitive by adopting an RGB color mode; analyzing the primitive rendering instruction to obtain a color indication parameter; acquiring a color value corresponding to the color indication parameter; adopt the colour value of acquireing to render target primitive, it is thus clear that this application can obtain the colour instruction parameter through analyzing primitive rendering instruction, directly obtains the colour value through the colour instruction parameter, the effectual acquisition rate that improves the colour value, further improvement primitive rendering rate.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
FIG. 1 is a schematic structural diagram of an application system of a primitive rendering method in an embodiment of the present application;
FIG. 2 is a schematic flowchart of a primitive rendering method in an embodiment of the present application;
FIG. 3 is a schematic diagram of a pre-creation process of a corresponding relationship in an embodiment of the present application;
FIG. 4 is a schematic flowchart illustrating a specific process of a primitive rendering method in an embodiment of the present application;
FIG. 5 is a schematic structural diagram of a primitive rendering apparatus according to an embodiment of the present disclosure;
fig. 6 is a schematic structural diagram of an electronic device in an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In the embodiment of the present application, a primitive rendering method is provided, which may be applied in a system environment composed of a terminal 101 and a server 102 as shown in fig. 1. As shown in fig. 1, a server 102 is connected to a terminal 101 through a network, which may be used to provide services for the terminal or a client installed on the terminal, and a database may be provided on the server or separately from the server, and is used to provide data storage services for the server 102, and the network includes but is not limited to: the terminal 101 is not limited to a computer, a mobile phone, a tablet, etc. in a wide area network, a metropolitan area network, or a local area network.
The primitive rendering method according to the embodiment of the present application may be executed by the server 102, or executed by the terminal 101, or executed by both the server 102 and the terminal 101. The terminal 101 may execute the primitive rendering method according to the embodiment of the present application, or may be executed by a client installed thereon, or may be executed by a processor installed thereon.
For example, when the method is applied to the server 102, an editable program for realizing image rendering is stored in the server. The editable program for image rendering may be a shader, the shader including: vertex shaders and fragment shaders. A vertex shader is a set of instruction code that is executed when a vertex is rendered. The role of the fragment shader is to process each fragment generated by the rasterization stage, eventually computing the final color of each pixel.
For example, when the method is applied to a processor installed on a terminal, an editable program for realizing image rendering is stored in the processor. The processor includes a microprocessor, the microprocessor includes a Graphics Processing Unit (GPU), the GPU is also called a display core, a visual processor, and a display chip, and the microprocessor is specially used for performing image and graphics related operations on a computer, a workstation, a game machine, and some mobile devices (such as a tablet computer, a smart phone, and the like).
The following description will be given by taking the method as an example applied to a GPU, but the method is only an example and is not intended to limit the scope of the present application. Moreover, other examples in the present application are not intended to limit the scope of the present application, and thus are not described in detail.
First, a 3D drawing protocol (Web Graphics Library, WebGL) is introduced. The shader code of WebGL includes: vertex shader code and fragment shader code. In the following, vertex shader code is collectively referred to as vertex shader, and fragment shader code is collectively referred to as fragment shader.
A vertex shader is a program used to describe the characteristics of a vertex, such as the position information of the vertex, the color parameters of the vertex, and the like, where a vertex refers to a point in two-dimensional or three-dimensional space, such as an intersection or an end point between two-dimensional or three-dimensional space lines and lines. The vertex shader determines the size, position and color of the vertices, provides a set of individual hue values for each vertex, and performs smoothing and blending on the colors of the vertices.
A fragment shader is a program that performs a process on a per-fragment basis, where a fragment is a term of WebGL and can be understood as a pixel. After the graph is drawn, the color of the graph fill is processed by the fragment shader.
Pixels are defined by tiles of the image that have a well-defined position and assigned color values.
WebGL uses a Vertex Buffer Object (VBO) to record element-related information for elements in primitives, including: vertex parameters and color parameters. The vertex parameters include position parameters (parameter 1, parameter 2, and parameter 3). The Position parameter is used in the prior art to record the coordinates of the vertices and the color parameter includes a color (color) parameter (r.g.b.a), wherein (r.g.b.a) is converted to a color value. In the execution process of the primitive rendering method, data such as vertex parameters and color parameters are transmitted to a vertex shader and a fragment shader through a related interface (API) of WebGL.
Wherein the elements include: any one or more of points, lines, and surfaces drawn on the target drawing.
Specifically, an implementation flow of the primitive rendering method of the present application is described with reference to fig. 2:
step 201, obtaining a primitive rendering instruction for a target primitive in a target engineering drawing.
The primitive rendering instruction carries a color indication parameter for indicating the color of the target primitive, and the storage space occupied by the color indication parameter is smaller than the storage space occupied by describing the target primitive by adopting an RGB color mode.
In particular, the primitive rendering instructions carry VBO objects that include color indication parameters.
The RGB color is red (R), green (G) and blue (B), and RGB represents the color of red, green and blue channels, so that the target graphic element is described by adopting an RGB color mode and needs to occupy 3 bit records. When the transparency (a) characteristic exists, 4 bits are required to be occupied for recording when the target primitive is described by adopting the RGB color mode.
The color parameter in the VBO object is (r.g.b.a), 4 bits are needed for recording, and the storage space occupied by the color indication parameter is smaller than the storage space occupied by describing the target graphic element by adopting the RGB color mode, so that only 1 bit or 2 bits are needed, the storage space is effectively saved, and the waste of buffer area resources is avoided.
Specifically, the target engineering drawing may be a drawing of various formats, such as a Computer Aided Design (CAD) drawing with a file extension of dwg or sat. When the target engineering drawing is previewed, the primitive in the target engineering drawing needs to be rendered, and at the moment, a primitive rendering instruction is generated. The primitive to be rendered is a target primitive, and the target primitive may be one primitive or a plurality of primitives.
In one embodiment, the corresponding relationship between the color indication parameter and the color value needs to be configured in advance, and the color value is determined by using the corresponding relationship to render the target primitive.
Specifically, before a primitive rendering instruction for a target primitive in a target engineering drawing is obtained, a correspondence between a color indication parameter and a color value is pre-stored, and specifically, the creation of the correspondence may be: and creating a mapping table corresponding to the preset color quantity, writing the color value corresponding to the target primitive into the created mapping table, and configuring the corresponding relation between each position coordinate in the mapping table written with the color value and the color indication parameter.
The mapping table may be a table, an array, or a matrix. When the mapping table is a table, the mapping table can be a one-row table or a multi-row table; when the mapping table is an array, the mapping table may be an N-dimensional array, where N is an integer greater than or equal to 1, where the array is an ordered sequence of elements, and a user may dynamically set N according to actual requirements. In the following, the mapping table is taken as an N-dimensional array as an example for explanation:
for example, when N is equal to 1, a one-dimensional array corresponding to the preset number of colors is created, wherein the one-dimensional array includes a sequence. Specifically, a sequence corresponding to a preset number of colors is created, wherein the sequence is an object arranged in a column, and each element is arranged in order.
For example, when N is equal to 2, a two-dimensional array corresponding to a preset compression number is created, where the two-dimensional array is a two-dimensional matrix. Specifically, a two-dimensional matrix corresponding to a preset number of colors is created, wherein the matrix is a set of complex or real numbers arranged in a rectangular matrix.
For example, when N is equal to 3, a three-dimensional array corresponding to the preset number of colors is created.
In the following, the mapping table is taken as a two-dimensional matrix as an example for specific description;
specifically, a specific implementation of creating the corresponding relationship is shown in fig. 3:
step 301, creating a two-dimensional matrix corresponding to a preset number of colors, where the preset number of colors is the number of colors corresponding to the target primitive.
Specifically, the number of preset colors may be dynamically set by a user according to an actual use condition, for example, rendering of a primitive requires twelve colors, which are: red, orange yellow, yellow green, blue violet, purplish red. At this point, a 3 x 4 two-dimensional matrix may be created.
For example, 256 colors are required for rendering of primitives, at which point a two-dimensional matrix of 16 × 16 may be created.
The preset color number is consistent with the number of the pixels of the two-dimensional matrix, so that the waste of storage space is avoided.
The following description will specifically take a two-dimensional matrix with a predetermined number of colors being 256 and a two-dimensional matrix being 16 × 16 as an example.
Specifically, the WebGL Texture interface is included in the WebGL, and provides Texture operations such as storage and state for opaque Texture objects, where the Texture objects are used for storing Texture data, and the Texture data includes color values.
Before using the texture object to store the color values, the texture object needs to be created in advance, the texture object is a two-dimensional matrix of 16 × 16, that is, the color values corresponding to 256 colors can be stored in advance by using the texture object.
Step 302, writing the color value corresponding to the target primitive into the pixel of the created two-dimensional matrix.
Specifically, the pre-created texture object has 256 pixels, and each pixel corresponds to a color value corresponding to the stored color indication parameter, where the color indication parameter includes: color number. Specifically, a fragment shader is used to store a color value corresponding to the target primitive in the texture object.
The texture object is essentially a data sequence, and data in the texture object can be read randomly during running of the shading program.
Specifically, the color number may be a number from 0 to 255, and at this time, the color parameter in the VBO object does not need to record 4 parameters (r.g.b.a), and only the color number needs to be stored.
The existing VBO object recording mode needs 256 bits by 4 bits, and only 8 bits are needed by storing the color sequence number, so that the storage space is effectively saved.
Step 303, configuring a corresponding relation between each position coordinate in the two-dimensional matrix of the written color values and the color indication parameter.
Specifically, the corresponding relation between each texture coordinate in the texture object and the color indication parameter is configured, wherein the texture coordinate is a two-dimensional coordinate of each element in the texture object and is represented by (u, v) through letters, wherein u is an abscissa and v is an ordinate. When the texture is applied to the primitive, the corresponding texture coordinates need to be specified for the vertex parameters of the primitive, that is, the association relationship between the vertex parameters and the texture coordinates is configured to establish the mapping relationship between the primitive and the texture object.
Specifically, after a primitive rendering instruction is obtained, a color value corresponding to the color indication parameter is obtained by using a pre-configured corresponding relationship.
Specifically, the texture object stored with the color value may be converted into a 16 × 16 texture picture and stored in the video memory.
Step 202, analyzing the primitive rendering instruction to obtain the color indication parameter.
In one embodiment, the primitive rendering instruction is input to a vertex shader, the primitive rendering instruction is parsed by the vertex shader to obtain a color indication parameter, and the color indication parameter is output.
Specifically, a VBO object carried by the primitive rendering instruction is input to the vertex shader, the VBO object is analyzed by the vertex shader, a color sequence number corresponding to a color parameter of the VBO object is obtained, and the color sequence number is output.
Step 203, obtaining a color value corresponding to the color indication parameter.
In one embodiment, after the color indication parameter is output by the vertex shader, the color indication parameter output by the vertex shader is input to the fragment shader, the fragment shader calculates a color value corresponding to the input color indication parameter, and outputs the color value.
Specifically, after the color serial number is output by the vertex shader, the color serial number output by the vertex shader is input to the fragment shader, the color value corresponding to the input color serial number is calculated by the fragment shader, and the calculated color value is output.
In one embodiment, the fragment shader output color values are implemented as: and determining the position coordinate corresponding to the color indication parameter through the fragment shader based on the corresponding relation, determining the color value corresponding to the position coordinate corresponding to the obtained color indication parameter in the two-dimensional matrix, and outputting the color value.
Specifically, the fragment shader calculates texture coordinates corresponding to the color sequence number according to the pre-configured corresponding relationship, and determines a pixel value corresponding to the texture coordinates in the texture picture. And generating a color obtaining instruction according to the determined pixel value, wherein the color obtaining instruction carries texture coordinates, and sending the color obtaining instruction to the color sampler. And sampling at a texture coordinate carried by the color acquisition instruction in the texture object by the color sampler to obtain a color value corresponding to the texture coordinate, and returning the obtained color value to the fragment shader. The fragment shader outputs the returned color value.
This application can obtain the colour instruction parameter through analyzing the primitive instruction of rendering, directly obtains the colour value through the colour instruction parameter, the effectual rate of obtaining that improves the colour value, further improvement primitive rendering rate.
And step 204, rendering the target primitive by using the acquired color value.
In one embodiment, the primitive rendering instructions also carry a primitive unique identifier that indicates the target primitive. When the primitive rendering instruction is analyzed, primitive unique identifications of a target primitive are obtained at the same time, and each element with the primitive unique identification is determined, wherein one element corresponds to one primitive unique identification, and the primitive unique identifications of the elements in the same primitive are consistent; and rendering each element by adopting the acquired color value.
Specifically, the primitive rendering instruction carries a VBO object, and the VBO object includes a primitive unique identifier.
Specifically, after obtaining the color value and the unique identifier of the primitive, the fragment shader renders each element by using the obtained color value, so that the target primitive displays the corresponding color.
Specifically, the fragment shader may also obtain vertex parameters corresponding to the texture coordinates according to a pre-established association relationship between the vertex parameters and the texture coordinates after obtaining the texture coordinates, obtain unique identifiers of the primitives through the vertex parameters, determine each element having the unique identifier of the primitive, and render each element of the target primitive by using the obtained color values.
The primitive rendering method is specifically described below with reference to fig. 4:
step 401, a fragment shader stores color values corresponding to colors of a preset number of colors in advance by using a texture object.
Step 402, respectively configuring the corresponding relationship between each pixel in the texture object and the color number.
And 403, acquiring a primitive rendering instruction of the target primitive in the target engineering drawing.
And the primitive rendering instruction carries the color indication parameter and the primitive unique identifier.
And step 404, analyzing the primitive rendering instruction through the vertex shader to obtain a color serial number and a primitive unique identifier corresponding to the color indication parameter, and transmitting the color serial number and the primitive unique identifier to the fragment shader.
Step 405, calculating a texture coordinate corresponding to the color sequence number through the fragment shader, determining a pixel value corresponding to the texture coordinate, generating a color obtaining instruction according to the pixel value, and sending the color obtaining instruction to the color sampler.
Wherein the color fetching instruction carries texture coordinates.
And step 406, sampling the texture coordinate carried by the color acquisition instruction through the color sampler to obtain a color value corresponding to the texture coordinate, and returning the obtained color value to the fragment shader.
And step 407, determining each element of the target primitive according to the unique identifier of the primitive through the fragment shader, and rendering all the elements by using the returned color values.
According to the method provided by the embodiment of the application, the primitive rendering instruction of the target primitive in the target engineering drawing is obtained, the primitive rendering instruction carries the color indication parameter for indicating the color of the target primitive, and the storage space occupied by the color indication parameter is smaller than the storage space occupied by describing the target primitive by adopting an RGB color mode; analyzing the primitive rendering instruction to obtain a color indication parameter; acquiring a color value corresponding to the color indication parameter; adopt the colour value of acquireing to render target primitive, it is thus clear that this application can obtain the colour instruction parameter through analyzing primitive rendering instruction, directly obtains the colour value through the colour instruction parameter, the effectual acquisition rate that improves the colour value, further improvement primitive rendering rate.
Based on the same concept, an embodiment of the present application provides a primitive rendering apparatus, and specific implementation of the apparatus may refer to descriptions in the method embodiment, and repeated details are not repeated, as shown in fig. 5, the apparatus mainly includes:
the first obtaining module 501 is configured to obtain a primitive rendering instruction for a target primitive in a target engineering drawing, where the primitive rendering instruction carries a color indication parameter for indicating a color of the target primitive, and a storage space occupied by the color indication parameter is smaller than a storage space occupied by describing the target primitive by using an RGB color mode;
an analyzing module 502, configured to analyze the primitive rendering instruction to obtain the color indication parameter;
a second obtaining module 503, configured to obtain a color value corresponding to the color indication parameter;
and a rendering module 504, configured to render the target primitive by using the obtained color value.
In a specific embodiment, the device further comprises a creating module, configured to create a two-dimensional matrix corresponding to a preset number of colors, where the preset number of colors is the number of colors corresponding to the target primitive; writing the color value corresponding to the target graphic element into the pixel of the created two-dimensional matrix; configuring the corresponding relation between each position coordinate in the two-dimensional matrix of the written color values and the color indication parameters; the second obtaining module 503 is specifically configured to obtain a color value corresponding to the obtained color indication parameter based on the corresponding relationship.
In an embodiment, the parsing module 502 is specifically configured to input the primitive rendering instruction to a vertex shader, parse the primitive rendering instruction through the vertex shader to obtain a color indication parameter, and output the color indication parameter.
In an embodiment, the second obtaining module 503 is specifically configured to input the color indication parameter output by the vertex shader to the fragment shader, calculate, by the fragment shader, a color value corresponding to the input color indication parameter, and output the color value.
In a specific embodiment, the second obtaining module 503 is specifically configured to determine, by the fragment shader, a position coordinate corresponding to the color indication parameter based on the correspondence, determine, in the two-dimensional matrix, a color value corresponding to the obtained position coordinate corresponding to the color indication parameter, and output the color value.
In one embodiment, the predetermined number of colors is 256. The creation module of the device further comprises a creation submodule for creating a 16 × 16 two-dimensional matrix corresponding to the preset number of colors.
In a specific embodiment, the primitive rendering instruction further carries a primitive unique identifier for indicating a target primitive; the rendering module 504 is specifically configured to analyze the primitive rendering instruction to obtain a primitive unique identifier; determining each element with a primitive unique identifier, wherein one element corresponds to one primitive unique identifier, and the primitive unique identifiers of the elements in the same primitive are consistent; and rendering each element by adopting the acquired color value.
Based on the same concept, an embodiment of the present application further provides an electronic device, as shown in fig. 6, the electronic device mainly includes: a processor 601, a memory 602, and a communication bus 603, wherein the processor 601 and the memory 602 communicate with each other via the communication bus 603. The memory 602 stores a program executable by the processor 601, and the processor 601 executes the program stored in the memory 602 to implement the following steps: acquiring a primitive rendering instruction of a target primitive in a target engineering drawing, wherein the primitive rendering instruction carries a color indication parameter for indicating the color of the target primitive, and the storage space occupied by the color indication parameter is smaller than the storage space occupied by describing the target primitive by adopting an RGB color mode; analyzing the primitive rendering instruction to obtain a color indication parameter; acquiring a color value corresponding to the color indication parameter; and rendering the target graphic element by using the acquired color value.
The communication bus 603 mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus 603 may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 6, but this is not intended to represent only one bus or type of bus.
The Memory 602 may include a Random Access Memory (RAM) or a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Alternatively, the memory may be at least one storage device located remotely from the processor 601.
The Processor 601 may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like, and may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic devices, discrete gates or transistor logic devices, and discrete hardware components.
In yet another embodiment of the present application, there is also provided a computer-readable storage medium having stored therein a computer program which, when run on a computer, causes the computer to execute the primitive rendering method described in the above embodiment.
In the above embodiments, the implementation may be wholly or partially realized by software, hardware, firmware, or any combination thereof. When implemented in software, may be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When loaded and executed on a computer, cause the processes or functions described in accordance with the embodiments of the application to occur, in whole or in part. The computer may be a general purpose computer, a special purpose computer, a network of computers, or other programmable device. The computer instructions may be stored on a computer readable storage medium or transmitted from one computer readable storage medium to another, for example, from one website site, computer, server, or data center to another website site, computer, server, or data center via wire (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wirelessly (e.g., infrared, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device, such as a server, a data center, etc., that includes one or more of the available media. The available media may be magnetic media (e.g., floppy disks, hard disks, tapes, etc.), optical media (e.g., DVDs), or semiconductor media (e.g., solid state drives), among others.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A method for primitive rendering, the method comprising:
acquiring a primitive rendering instruction of a target primitive in a target engineering drawing, wherein the primitive rendering instruction carries a color indication parameter for indicating the color of the target primitive, and the storage space occupied by the color indication parameter is smaller than the storage space occupied by describing the target primitive by adopting an RGB color mode;
analyzing the primitive rendering instruction to obtain the color indication parameter;
acquiring a color value corresponding to the color indication parameter;
and rendering the target graphic element by adopting the acquired color value.
2. The primitive rendering method according to claim 1, wherein before obtaining the primitive rendering instruction for the target primitive in the target engineering drawing, further comprising:
creating a two-dimensional matrix corresponding to a preset color quantity, wherein the preset color quantity is the quantity of colors corresponding to the target graphic primitive;
writing the color value corresponding to the target graphic element into the pixel of the created two-dimensional matrix;
configuring a corresponding relation between each position coordinate in the two-dimensional matrix written with the color values and the color indication parameters;
the obtaining of the color value corresponding to the obtained color indication parameter includes:
and acquiring the color value corresponding to the obtained color indication parameter based on the corresponding relation.
3. The method for primitive rendering according to claim 2, wherein the parsing the primitive rendering instruction to obtain the color indication parameter comprises:
and inputting the primitive rendering instruction to a vertex shader, analyzing the primitive rendering instruction through the vertex shader to obtain the color indication parameter, and outputting the color indication parameter.
4. The primitive rendering method of claim 3, wherein the obtaining a color value corresponding to the color indication parameter comprises:
and inputting the color indication parameter output by the vertex shader into a fragment shader, calculating a color value corresponding to the input color indication parameter through the fragment shader, and outputting the color value.
5. The primitive rendering method according to claim 4, wherein the calculating, by the fragment shader, a color value corresponding to the input color indication parameter and outputting the color value comprises:
and determining the position coordinate corresponding to the color indication parameter through the fragment shader based on the corresponding relation, determining a color value corresponding to the position coordinate corresponding to the color indication parameter in the two-dimensional matrix, and outputting the color value.
6. The primitive rendering method of claim 2, wherein the preset number of colors is 256;
the creating of the two-dimensional matrix corresponding to the preset number of colors includes:
creating a two-dimensional matrix of 16 x 16 corresponding to said preset number of colors.
7. The primitive rendering method according to claim 1, wherein the primitive rendering instruction further carries a primitive unique identifier for indicating the target primitive;
the rendering the target primitive by using the obtained color value comprises:
analyzing the primitive rendering instruction to obtain the unique identifier of the primitive;
determining each element with the primitive unique identifier, wherein one element corresponds to one primitive unique identifier, and the primitive unique identifiers of the elements in the same primitive are consistent;
and rendering each element by adopting the acquired color value.
8. A primitive rendering apparatus, comprising:
the system comprises a first acquisition module, a second acquisition module and a third acquisition module, wherein the first acquisition module is used for acquiring a primitive rendering instruction of a target primitive in a target engineering drawing, the primitive rendering instruction carries a color indication parameter for indicating the color of the target primitive, and the storage space occupied by the color indication parameter is smaller than the storage space occupied by describing the target primitive by adopting an RGB color mode;
the analysis module is used for analyzing the primitive rendering instruction to obtain the color indication parameter;
the second acquisition module is used for acquiring the color value corresponding to the color indication parameter;
and the rendering module is used for rendering the target graphic primitive by adopting the acquired color value.
9. An electronic device, comprising: the system comprises a processor, a memory and a communication bus, wherein the processor and the memory are communicated with each other through the communication bus;
the memory for storing a computer program;
the processor, configured to execute the program stored in the memory, and implement the primitive rendering method according to any one of claims 1 to 7.
10. A computer-readable storage medium, storing a computer program, wherein the computer program, when executed by a processor, implements the primitive rendering method of any one of claims 1-7.
CN202110506311.5A 2021-05-10 2021-05-10 Primitive rendering method, device and equipment and storage medium Pending CN113205580A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110506311.5A CN113205580A (en) 2021-05-10 2021-05-10 Primitive rendering method, device and equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110506311.5A CN113205580A (en) 2021-05-10 2021-05-10 Primitive rendering method, device and equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113205580A true CN113205580A (en) 2021-08-03

Family

ID=77030675

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110506311.5A Pending CN113205580A (en) 2021-05-10 2021-05-10 Primitive rendering method, device and equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113205580A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115830200A (en) * 2022-11-07 2023-03-21 北京力控元通科技有限公司 Three-dimensional model generation method, three-dimensional graph rendering method, device and equipment
CN116206029A (en) * 2022-12-13 2023-06-02 上海功存智能科技有限公司 Geological data rendering method, device, computer equipment and storage medium
CN116385253A (en) * 2023-01-06 2023-07-04 格兰菲智能科技有限公司 Primitive drawing method, device, computer equipment and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080122841A1 (en) * 2006-11-28 2008-05-29 Jeffrey Douglas Brown Ray Tracing Image Processing System
US20140327671A1 (en) * 2013-05-02 2014-11-06 Arm Limited Graphics processing systems
US20180232936A1 (en) * 2017-02-15 2018-08-16 Microsoft Technology Licensing, Llc Multiple shader processes in graphics processing
CN109395384A (en) * 2018-09-12 2019-03-01 Oppo广东移动通信有限公司 Game rendering method and Related product
CN110298780A (en) * 2018-03-23 2019-10-01 腾讯科技(深圳)有限公司 Map rendering method, device and computer storage medium
CN111443910A (en) * 2020-03-24 2020-07-24 北京奇艺世纪科技有限公司 Skin rendering method and device, electronic equipment and computer storage medium
CN112330785A (en) * 2020-11-02 2021-02-05 通号通信信息集团有限公司 Image-based urban road and underground pipe gallery panoramic image acquisition method and system
CN112416489A (en) * 2020-11-06 2021-02-26 万翼科技有限公司 Engineering drawing display method and related device

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080122841A1 (en) * 2006-11-28 2008-05-29 Jeffrey Douglas Brown Ray Tracing Image Processing System
US20140327671A1 (en) * 2013-05-02 2014-11-06 Arm Limited Graphics processing systems
US20180232936A1 (en) * 2017-02-15 2018-08-16 Microsoft Technology Licensing, Llc Multiple shader processes in graphics processing
CN110298780A (en) * 2018-03-23 2019-10-01 腾讯科技(深圳)有限公司 Map rendering method, device and computer storage medium
CN109395384A (en) * 2018-09-12 2019-03-01 Oppo广东移动通信有限公司 Game rendering method and Related product
CN111443910A (en) * 2020-03-24 2020-07-24 北京奇艺世纪科技有限公司 Skin rendering method and device, electronic equipment and computer storage medium
CN112330785A (en) * 2020-11-02 2021-02-05 通号通信信息集团有限公司 Image-based urban road and underground pipe gallery panoramic image acquisition method and system
CN112416489A (en) * 2020-11-06 2021-02-26 万翼科技有限公司 Engineering drawing display method and related device

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115830200A (en) * 2022-11-07 2023-03-21 北京力控元通科技有限公司 Three-dimensional model generation method, three-dimensional graph rendering method, device and equipment
CN115830200B (en) * 2022-11-07 2023-05-12 北京力控元通科技有限公司 Three-dimensional model generation method, three-dimensional graph rendering method, device and equipment
CN116206029A (en) * 2022-12-13 2023-06-02 上海功存智能科技有限公司 Geological data rendering method, device, computer equipment and storage medium
CN116206029B (en) * 2022-12-13 2023-09-22 上海功存智能科技有限公司 Geological data rendering method, device, computer equipment and storage medium
CN116385253A (en) * 2023-01-06 2023-07-04 格兰菲智能科技有限公司 Primitive drawing method, device, computer equipment and storage medium

Similar Documents

Publication Publication Date Title
CN113205580A (en) Primitive rendering method, device and equipment and storage medium
CN100357972C (en) Systems and methods for compressing computer graphics color data
KR101286318B1 (en) Displaying a visual representation of performance metrics for rendered graphics elements
JP6626691B2 (en) Texture processing method and apparatus
US11348308B2 (en) Hybrid frustum traced shadows systems and methods
CN113204296B (en) Method, device and equipment for highlighting graphics primitive and storage medium
CN114443577A (en) Drawing processing method, device, equipment and storage medium
CN115439609B (en) Three-dimensional model rendering method, system, equipment and medium based on map service
US11087511B1 (en) Automated vectorization of a raster image using a gradient mesh with arbitrary topology
US10403040B2 (en) Vector graphics rendering techniques
CN115908685A (en) Scene rendering method, device, equipment and storage medium
JP2017062789A (en) Graphics processing apparatus and method for determining lod for texturing
CN113457161A (en) Picture display method, information generation method, device, equipment and storage medium
CN111179390B (en) Method and device for efficiently previewing CG (content distribution) assets
US8232994B2 (en) Viewing multi-dimensional data in two dimensions
US10269168B2 (en) Graphics processing systems
US20230377265A1 (en) Systems for Efficiently Rendering Vector Objects
CN110599576A (en) File rendering system and method and electronic equipment
US10062191B2 (en) System and method for rendering points without gaps
US11869123B2 (en) Anti-aliasing two-dimensional vector graphics using a compressed vertex buffer
CN113205578B (en) Layer processing method, layer rendering method and related equipment
CN109767379B (en) Data normalization processing method and device, storage medium and electronic equipment
CN113204297B (en) Method and device for selecting elements in graphic primitive, electronic equipment and storage medium
CN114546555B (en) Graph pickup method, device and medium based on space geometry
US20230267570A1 (en) Data Processing Method and Related Apparatus

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right
TA01 Transfer of patent application right

Effective date of registration: 20230629

Address after: A601, Zhongke Naneng Building, No. 06 Yuexing 6th Road, Gaoxin District Community, Yuehai Street, Nanshan District, Shenzhen City, Guangdong Province, 518063

Applicant after: Shenzhen Wanyi Digital Technology Co.,Ltd.

Address before: 519085 room 105-24914, No.6 Baohua Road, Hengqin New District, Zhuhai City, Guangdong Province (centralized office area)

Applicant before: WANYI TECHNOLOGY Co.,Ltd.