WO2023197762A1 - Image rendering method and apparatus, electronic device, computer-readable storage medium, and computer program product - Google Patents

Image rendering method and apparatus, electronic device, computer-readable storage medium, and computer program product Download PDF

Info

Publication number
WO2023197762A1
WO2023197762A1 PCT/CN2023/078405 CN2023078405W WO2023197762A1 WO 2023197762 A1 WO2023197762 A1 WO 2023197762A1 CN 2023078405 W CN2023078405 W CN 2023078405W WO 2023197762 A1 WO2023197762 A1 WO 2023197762A1
Authority
WO
WIPO (PCT)
Prior art keywords
vertex
rendered
index data
vertices
rendering
Prior art date
Application number
PCT/CN2023/078405
Other languages
French (fr)
Chinese (zh)
Inventor
连冠荣
昔文博
Original Assignee
腾讯科技(深圳)有限公司
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 腾讯科技(深圳)有限公司 filed Critical 腾讯科技(深圳)有限公司
Publication of WO2023197762A1 publication Critical patent/WO2023197762A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformations in the plane of the image
    • G06T3/40Scaling of whole images or parts thereof, e.g. expanding or contracting
    • G06T3/4053Scaling of whole images or parts thereof, e.g. expanding or contracting based on super-resolution, i.e. the output image resolution being higher than the sensor resolution
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/048Activation functions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T5/00Image enhancement or restoration
    • G06T5/73Deblurring; Sharpening
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10004Still image; Photographic image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10024Color image
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20084Artificial neural networks [ANN]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • G06T2207/30201Face

Definitions

  • Embodiments of the present application relate to the field of Internet technology, and relate to but are not limited to an image rendering method, device, electronic equipment, computer-readable storage media, and computer program products.
  • a mesh refers to a structure containing vertices and faces.
  • the mesh is a common method for displaying three-dimensional (3D, 3-dimension) game objects.
  • 3D game object rendering and display technology the smallest unit (triangle) in the mesh is usually used.
  • ) performs vertex rendering for the rendering unit.
  • the vertex buffer (VB, Vertex Buffer) is a continuous array of vertex data. In some image rendering scenarios, intermittent vertex rendering of the mesh needs to be performed from the vertex buffer.
  • the methods in the related art need to call multiple draw calls when implementing intermittent vertex rendering, which will greatly increase the rendering time and reduce the rendering efficiency; while the graphics drawing interface that requires a high-end GPU has insufficient adaptability. , a problem that is not applicable to all models; at the same time, there will be a certain delay in the data copy process, which will greatly affect the image rendering efficiency. It can be seen that the intermittent vertex rendering methods in related technologies all have the problem of low image rendering efficiency.
  • Embodiments of the present application provide an image rendering method, device, electronic device, computer-readable storage medium and computer program product, which are at least used in the field of image rendering and game technology and can perform vertex processing on some vertices in a vertex set based on index data. Eliminate processing so that intermittent vertex rendering of data to be rendered can be achieved by calling a single draw call, thereby improving image rendering efficiency.
  • An embodiment of the present application provides an image rendering method, which includes:
  • An embodiment of the present application provides an image rendering device.
  • the device includes: an acquisition module configured to acquire the to-be- Rendering data and an index data set used to reflect rendering requirement information; the data to be rendered corresponds to a vertex set; an elimination module is configured to eliminate the vertices based on the data to be rendered and the index data in the index data set. Part of the vertices in the set are subjected to vertex elimination processing to obtain a set of vertices to be rendered; a vertex rendering module is configured to sequentially perform vertex rendering on the vertices to be rendered in the set of vertices to be rendered to obtain a rendered image.
  • An embodiment of the present application provides an electronic device, including: a memory for storing executable instructions; and a processor for implementing the above image rendering method when executing the executable instructions stored in the memory.
  • Embodiments of the present application provide a computer program product or computer program.
  • the computer program product or computer program includes executable instructions, and the executable instructions are stored in a computer-readable storage medium; wherein, the processor of the electronic device obtains the information from the computer-readable storage medium.
  • the executable instructions are read and executed, the above image rendering method is implemented.
  • Embodiments of the present application provide a computer-readable storage medium that stores executable instructions for causing a processor to execute the executable instructions to implement the above image rendering method.
  • the embodiments of the present application have the following beneficial effects: based on the acquired data to be rendered and the index data in the index data set, vertex elimination processing is performed on some vertices in the vertex set corresponding to the data to be rendered, and a set of vertices to be rendered is obtained.
  • the rendering vertex set includes the remaining vertices after vertex elimination processing of the vertex set.
  • vertex rendering can be achieved by calling a draw call, that is, by calling a draw call.
  • Intermittent vertex rendering of vertices in a vertex collection can be implemented. In this way, not only the image rendering efficiency can be improved, but also the intermittent vertex rendering method is suitable for devices with different configurations, thereby improving device adaptability.
  • Figure 1A is a schematic structural diagram of a grid provided by an embodiment of the present application.
  • Figure 1B is a schematic diagram of the relationship between vertices-face-edges provided by the embodiment of the present application.
  • Figure 2 is a schematic diagram of intermittent vertex rendering
  • Figure 3 is a schematic diagram of calling multiple draw calls for intermittent vertex rendering in related technologies
  • Figure 4 is a schematic diagram of intermittent vertex rendering using the graphics rendering interface of a high-end GPU in related technologies
  • Figure 5 is a schematic diagram of intermittent vertex rendering through data copying in the related art
  • Figure 6 is a schematic diagram of intermittent vertex rendering through multiple renderings in the related art
  • Figure 7 is an optional architectural schematic diagram of the image rendering system provided by the embodiment of the present application.
  • Figure 8 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • Figure 9 is an optional flow diagram of the image rendering method provided by the embodiment of the present application.
  • Figure 10 is another optional flow diagram of the image rendering method provided by the embodiment of the present application.
  • Figure 11 is another optional flow diagram of the image rendering method provided by the embodiment of the present application.
  • Figure 12A is an original image before rendering of enabling/disabling certain parts of the body according to an embodiment of the present application
  • Figure 12B is an image of disabling the rendering of the hair part of the body according to the embodiment of the present application.
  • Figure 13 is a flow chart of an image rendering method provided by an embodiment of the present application.
  • Figure 14 is another flow chart of the image rendering method provided by the embodiment of the present application.
  • Figure 15 is a schematic diagram of the effect of the method according to the embodiment of the present application applied to a low-end machine
  • Figure 16 is a schematic diagram of the effect of the method according to the embodiment of the present application applied to a mid-range machine
  • Figure 17 is a schematic diagram of the effect of applying the method according to the embodiment of the present application to a high-end machine.
  • Mesh refers to the structure containing vertices and faces. Grids are a common method of displaying 3D game objects. A mesh is a data structure that contains arrays of vertices and arrays of faces. As shown in FIG. 1A , it is a schematic structural diagram of a grid. During the image rendering process, rendering is performed in units of grid units in the grid, where the grid includes multiple grid units 101 .
  • Face It is a data structure containing three index integers.
  • the index data can indicate the vertices used by this face.
  • Each face has three sides.
  • Rendering instantiation is also called GPU instantiation.
  • GPU instantiation you can use a small number of draw calls (Drawcall) to draw (or render) multiple copies of the same mesh at once.
  • Drawcall draw calls
  • GPU instancing simply renders the same mesh on each draw call, but each instance can have different parameters (for example, color or scale) to increase variation and reduce repetition in appearance.
  • GPU instancing can reduce the number of draw calls used per scene. GPU instancing can significantly improve your project's rendering performance.
  • Draw call It is the call command of the central processing unit (CPU, Central Processing Unit) to the underlying graphics drawing interface to instruct the GPU to perform rendering operations.
  • the rendering process is implemented using a pipeline.
  • the CPU and GPU work in parallel, and there is a gap between the CPU and the GPU.
  • the CPU sends rendering commands to the command buffer, and the GPU receives and executes the corresponding rendering commands.
  • preparation work includes but is not limited to: detecting rendering status, submitting rendering Data and submission rendering state, etc.
  • the GPU itself has very powerful computing power and can handle rendering tasks quickly.
  • Graphics drawing interface of high-end GPU refers to the open graphics interface (OpenGLES, Open Graphics Library). These interfaces require high-end GPU (supporting OpenGLES 3.1 or above) hardware to use graphics drawing. interface. Among them, high-end GPU refers to a GPU whose rendering performance is higher than that of a conventional GPU.
  • Vertex buffer It is a buffer stored in the GPU such as OpenGL/Directx (an image application programming interface, these image application programming interfaces are used to render two-dimensional or three-dimensional images), and is used to store the number of vertices.
  • Data array, vertex buffer provides a method to upload vertex data (position, normal vector, color, etc.) to the GPU for non-immediate mode rendering.
  • Vertex buffers provide significant performance improvements over immediate mode rendering, primarily because the data resides in GPU memory rather than system memory, so the data can be fetched by the GPU and rendered directly.
  • the vertex buffer is a continuous array of vertex data. Some scenes require intermittent rendering of vertices from a single draw call of the vertex buffer, that is, it is not from vertex 1 to vertex within a single draw call. n are all rendered sequentially, but vertices 1-10, vertices 31-100, vertices 221-300..., and vertices 1000-n are rendered intermittently within a single draw call, and some vertices in the middle are skipped. As shown in Figure 2, it is a schematic diagram of intermittent vertex rendering. Before intermittent vertex rendering, only a small amount of processing needs to be done to determine whether the intermediate vertices are displayed.
  • the first row in Figure 2 represents all 20 vertices in the vertex data array: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20.
  • intermittent vertex rendering is required, that is, only vertices 1, 2, 3, 4, 5, 6, 7 and vertices 13, 14, 15, 16, 17, 18, 19, 20 need to be rendered. Therefore, The middle vertices 8, 9, 10, 11, and 12 will be skipped and not rendered.
  • one implementation method in related technologies is to separate multiple draw calls to implement intermittent vertex rendering. That is to say, intermittent vertex rendering needs to be implemented by calling multiple draw calls.
  • Figure 3 it is a schematic diagram of calling multiple draw calls for intermittent vertex rendering in related technologies. For all 20 vertices in the vertex data array: 1, 2, 3, 4, 5, 6, 7, 8, 9 , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, among which, during the rendering process of the first row of image data, vertices 4, 5, 6, and 7 are vertices that do not need to be rendered.
  • vertices 8, 9, 10, 11, 12 and 13, 14, 15, 16, 17, 18, 19, 20 are vertices that do not need to be rendered, therefore, the overall rendering process , 5 draw calls need to be called for rendering.
  • the 5 draw calls are: glDrawArray(1, 2, 3), used to render vertices 1, 2, 3; glDrawArray(8, 9, 10, 11, 12 ), used to render vertices 8, 9, 10, 11, 12; glDrawArray(13, 14, 15, 16, 17, 18, 19, 20), used to render vertices 13, 14, 15, 16, 17, 18 , 19, 20; glDrawArray (1, 2, 3), used to render vertices 1, 2, 3; glDrawArray (4, 5, 6, 7), used to render vertices 4, 5, 6, 7.
  • FIG. 4 it is a schematic diagram of using the graphics drawing interface of a high-end GPU to perform intermittent vertex rendering in the related art.
  • vertex data array All 20 vertices: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, among which, in the first During the rendering process of the row image data, vertices 4, 5, 6, and 7 are vertices that do not need to be rendered.
  • vertices 8, 9, 10, 11, 12 and 13, 14, 15 , 16, 17, 18, 19, and 20 are vertices that do not need to be rendered.
  • the graphics rendering interface of the high-end GPU is used to call one draw call for rendering.
  • This draw call is: glDrawArray( 1, 2, 3, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 1, 2, 3, 4, 5, 6, 7 ).
  • FIG. 5 it is a schematic diagram of intermittent vertex rendering through data copying in the related art.
  • vertices 4 1, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, among which, in the rendering process of the first row of image data, vertices 4, 5, 6, and 7 are vertices that do not need to be rendered, and in the second row of image data During the rendering process, vertices 8, 9, 10, 11, 12 and 13, 14, 15, 16, 17, 18, 19, 20 are vertices that do not need to be rendered. Therefore, during the overall rendering process, the data to be rendered can be Copy it to the vertex buffer and render.
  • this method involves a data copy process, so there is a bottleneck limit on performance.
  • FIG. 6 it is a schematic diagram of intermittent vertex rendering through multiple renderings in related technologies.
  • component 1, component 2, component 3 and component 4 are the same components and need to be rendered.
  • the data and content are exactly the same, but the components that do not need to be rendered in object one, object two and object three are different. Therefore, for the same component, multiple renderings may be required in different objects. This will obviously reduce image rendering efficiency.
  • the image rendering method is a GPU rendering call optimization method with wider adaptability. This method solves the problem in certain scenarios. , the need to implement intermittent vertex rendering from a single draw call in the vertex buffer, that is, not all vertices 1 to vertex n are rendered sequentially within a single draw call, but vertices 1-10, vertices 31-100 are intermittently rendered within a single draw call , vertices 221-300..., vertices 1000-n are rendered, and some vertices in the middle will be skipped and not rendered.
  • the data to be rendered and the index data set are obtained; the data to be rendered corresponds to a vertex set; then, based on the data to be rendered and the index data in the index data set, the vertex set in the vertex set is Vertex elimination is performed on some vertices to obtain a set of vertices to be rendered; finally, vertex rendering is performed on the vertices to be rendered in the set of vertices to be rendered to obtain a rendered image.
  • the image rendering device is an electronic device used to implement the image rendering method according to the embodiment of the present application.
  • the image rendering device ie, electronic device
  • the image rendering device provided by the embodiment of the present application can be implemented as a terminal or as a server.
  • the image rendering device provided by the embodiment of the present application can be implemented as a notebook computer, a tablet computer, a desktop computer, a mobile device (for example, a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, a portable Game equipment), smart robots, smart home appliances, smart vehicle-mounted equipment, and other terminals with image processing functions, video display functions, and image rendering functions; in another implementation, the image rendering device provided by the embodiment of the present application can also Implemented as a server, where the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or it can provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, and networks.
  • a server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or it can provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, and networks.
  • the terminal and the server can be connected directly or indirectly through wired or wireless communication methods, which are not limited in the embodiments of this application.
  • an exemplary application when the image rendering device is implemented as a server will be described.
  • Figure 7 is an optional architectural schematic diagram of an image rendering system provided by an embodiment of the present application.
  • the image rendering system 10 at least includes a terminal 100, a network 200 and a server. 300, where the server 300 is a server for a video application or an image display application, and the server 300 may constitute the image rendering device in the embodiment of the present application.
  • the terminal 100 connects to the server 300 through the network 200.
  • the network 200 may be a wide area network or a local area network, or a combination of the two.
  • the terminal 100 sends the image rendering request to the server 300 through the network 200.
  • the server 300 After obtaining the data to be rendered and the index data set used to reflect the rendering requirement information, the server 300 performs the processing based on the data to be rendered and the index data set. Index data, perform vertex elimination processing on some vertices in the vertex set corresponding to the to-be-rendered data, and obtain the to-be-rendered vertex set; then perform vertex rendering on the to-be-rendered vertices in the to-be-rendered vertex set in sequence to obtain the rendered image. in getting After rendering the image, the rendered image is sent to the terminal 100 through the network 200, and the rendered image is displayed on the terminal 100.
  • the image rendering method provided by the embodiment of the present application can also be based on a cloud platform and implemented through cloud technology.
  • the above-mentioned server 300 can be a cloud server, and the cloud server can perform vertex mapping based on the data to be rendered and the index data in the index data set. Vertex elimination is performed on some vertices in the set to obtain a set of vertices to be rendered, and the vertices to be rendered in the set of vertices to be rendered are sequentially rendered through the cloud server to obtain a rendered image.
  • the rendered image may be stored in the cloud storage, or the index data set may be stored in the cloud storage, or the data to be rendered and the rendered image may be mapped and stored in the cloud. in memory. In this way, when the image rendering data needs to be rendered again later, the rendered image can be read directly from the cloud storage.
  • cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to realize data calculation, storage, processing, and sharing.
  • Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool and use it on demand, which is flexible and convenient. Cloud computing technology will become an important support.
  • the background services of technical network systems require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the rapid development and application of the Internet industry, in the future each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data at different levels will be processed separately, and all types of industry data need to be powerful. System backing support can only be achieved through cloud computing.
  • FIG. 8 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • the electronic device shown in Figure 8 includes: at least one processor 310, a memory 350, at least one network interface 320 and a user interface 330.
  • the various components in the electronic device are coupled together through bus system 340 .
  • the bus system 340 is used to implement connection communication between these components.
  • the bus system 340 also includes a power bus, a control bus and a status signal bus.
  • the various buses are labeled bus system 340 in FIG. 8 .
  • the processor 310 may be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware Components, etc., wherein the general processor can be a microprocessor or any conventional processor, etc.
  • User interface 330 includes one or more output devices 331 that enable the presentation of media content, and one or more input devices 332.
  • Memory 350 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, etc.
  • Memory 350 optionally includes one or more storage devices physically located remotely from processor 310 .
  • Memory 350 includes volatile memory or non-volatile memory, and may include both volatile and non-volatile memory.
  • Non-volatile memory can be read-only memory (ROM, Read Only Memory), and volatile memory can be random access memory (RAM, Random Access Memory).
  • ROM read-only memory
  • RAM random access memory
  • the memory 350 described in the embodiments of this application is intended to include any suitable type of memory.
  • the memory 350 is capable of storing data to support various operations, examples of which include programs, modules, and data structures, or subsets or supersets thereof, as exemplarily described below.
  • Operating system 351 including system programs used to process various basic system services and perform hardware-related tasks, such as framework layer, core library layer, driver layer, etc., used to implement various basic services and process hardware-based tasks; network communication Module 352 for reaching other computing devices via one or more (wired or wireless) network interfaces 320, example network interfaces 320 include: Bluetooth, Wireless Compliance (WiFi), and Universal Serial Bus (USB, Universal Serial Bus), etc.; input processing module 353 for detecting one or more user inputs or interactions from one or more input devices 332 and translating the detected inputs or interactions.
  • WiFi Wireless Compliance
  • USB Universal Serial Bus
  • the device provided by the embodiment of the present application can be implemented in software.
  • Figure 8 shows an image rendering device 354 stored in the memory 350.
  • the image rendering device 354 can be an image rendering device in an electronic device. Like the rendering device, it can be software in the form of programs and plug-ins, including the following software modules: acquisition module 3541, vertex elimination module 3542 and vertex rendering module 3543. These modules are logical, so any implementation can be performed according to the functions implemented. combination or further split. The functions of each module are explained below.
  • the device provided by the embodiment of the present application can be implemented in hardware.
  • the device provided by the embodiment of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the present application.
  • the image rendering method provided by the embodiment, for example, the processor in the form of a hardware decoding processor can use one or more Application Specific Integrated Circuits (ASIC, Application Specific Integrated Circuit), DSP, Programmable Logic Device (PLD, Programmable Logic Device) ), Complex Programmable Logic Device (CPLD, Complex Programmable Logic Device), Field Programmable Gate Array (FPGA, Field-Programmable Gate Array) or other electronic components.
  • ASIC Application Specific Integrated Circuit
  • DSP Programmable Logic Device
  • PLD Programmable Logic Device
  • CPLD Complex Programmable Logic Device
  • FPGA Field Programmable Gate Array
  • the image rendering method provided by each embodiment of the present application can be executed by an image rendering device, where the image rendering device can be any terminal with image processing functions, video display functions and image rendering functions, or it can also be a server, That is, the image rendering method in each embodiment of the present application can be executed through a terminal, a server, or the terminal interacts with a server.
  • the image rendering device can be any terminal with image processing functions, video display functions and image rendering functions, or it can also be a server, That is, the image rendering method in each embodiment of the present application can be executed through a terminal, a server, or the terminal interacts with a server.
  • FIG 9 is an optional flow diagram of the image rendering method provided by the embodiment of the present application. The following will be described in conjunction with the steps shown in Figure 9. It should be noted that the image rendering method in Figure 9 uses the server as the execution subject. To illustrate with an example. Referring to Figure 9, the image rendering method includes the following steps S101 to S103:
  • Step S101 Obtain the data to be rendered and the index data set; the data to be rendered corresponds to a vertex set.
  • the data to be rendered is the original data used to render the rendered image.
  • the data to be rendered includes the data corresponding to each pixel on the rendered image.
  • the original image can be obtained.
  • the original image is the unused image. Images that undergo any processing and do not reflect any rendering requirement information are images that do not reflect any rendering requirements of the user.
  • the original data in the data to be rendered may include the pixel value of each pixel of the rendered image, and all vertices in the vertex set are evenly arranged in the rendered image.
  • each pixel point can correspond to a vertex, and the position of the pixel point is the position of the vertex; or, multiple pixel points can correspond to one vertex, and the center position of the multiple pixel points is the position of the corresponding vertex.
  • the index data set is a data set based on the user's rendering requirement information. That is to say, the index data in the index data set is data that can reflect the user's rendering requirement.
  • the index data in the index data set is used to perform scaling processing on the vertex position information of each vertex in the vertex set, thereby determining whether each vertex is to be rendered.
  • the vertex set includes at least three vertices, where every three vertices can form a triangle.
  • triangle is the smallest unit of image rendering.
  • four vertices can also be connected to form a quadrilateral, five vertices can be connected to form a pentagon, etc.
  • These triangles, quadrilaterals, pentagons and other graphics are superimposed to form a grid corresponding to the image in the embodiment of the present application.
  • the image is divided into triangles, and the triangles are used as rendering units for rendering.
  • the index data in the index data set may be preset, or may be calculated based on the user's rendering instructions.
  • the setting process of the index data and the calculation process based on the rendering instructions will be described in detail below. .
  • Step S102 Based on the data to be rendered and the index data in the index data set, perform vertex elimination processing on some of the vertices in the vertex set to obtain a vertex set to be rendered.
  • the vertex elimination operation can be performed on each vertex in the vertex set corresponding to the to-be-rendered data to obtain the operation result of each vertex, and then it is determined whether each vertex needs to be eliminated based on the operation result.
  • the index data since the index data is preset or calculated based on the user's rendering instructions, the index data can represent the user's rendering needs. Then, the operation result obtained by performing the vertex elimination operation based on the index data can be Accurately reflects whether each vertex is a vertex to be eliminated. Alternatively, the vertices can be distinguished through label data, and it can be quickly and accurately determined whether each vertex is a vertex to be eliminated.
  • Vertex elimination processing refers to deleting some vertices in the vertex set from the vertex set, so that some vertices in the vertex set can not be rendered during the rendering process.
  • the set of vertices to be rendered includes at least one vertex to be rendered, and the vertex to be rendered is a vertex that actually needs to be rendered.
  • the number of vertices to be rendered in the vertex set to be rendered is less than the number of vertices in the vertex set.
  • some vertices are not rendered, that is, intermittent vertex rendering is performed. That is to say, instead of continuously rendering all the vertices in the vertex set in sequence, a part of the vertices is intermittently skipped, and the part of the vertices is not rendered. To render.
  • Step S103 Perform vertex rendering on the vertices to be rendered in the vertex set to be rendered in sequence to obtain a rendered image.
  • vertex rendering is performed on all the vertices to be rendered in the set of vertices to be rendered, to obtain a rendered image (i.e., a rendered image).
  • a rendered image i.e., a rendered image.
  • the vertices to be rendered in the vertex set to be rendered can be triangulated to obtain multiple triangles, and then the triangular image is rendered in units of each triangle to obtain a rendered image.
  • the image rendering method provided by the embodiment of the present application performs vertex elimination processing on some vertices in the vertex set corresponding to the data to be rendered based on the acquired data to be rendered and the index data in the index data set, to obtain the set of vertices to be rendered; and
  • the vertices to be rendered in the rendering vertex set are rendered in sequence to obtain the rendered image.
  • intermittent vertex rendering can be implemented by calling a draw call, which not only improves the image rendering efficiency, but also the image rendering method is suitable for different devices and has high performance. device compatibility.
  • the image rendering system for implementing the image rendering method includes at least a terminal and a server.
  • a video application or an image display application is running on the terminal.
  • an image display application is running on the terminal, and the image display application is a game application.
  • FIG 10 is another optional flow diagram of the image rendering method provided by the embodiment of the present application. As shown in Figure 10, the method includes the following steps S201 to S213:
  • Step S201 The terminal obtains input data to be rendered and preset rendering requirement information.
  • the data to be rendered corresponds to a vertex set.
  • the rendering requirement information can be input by the user through the terminal.
  • the areas, pixels or vertices that do not need to be rendered can be marked corresponding to the data to be rendered. Then all the data marked at this time constitute Information about the rendering requirements.
  • prompt information when performing image rendering, can be displayed on the current interface of the game application.
  • the prompt information is used to prompt the user to input rendering requirement information.
  • the user can enter commands through the command line input box to form the rendering requirement information. , you can also select and mark areas, pixels or vertices through the mouse or keyboard, from And generate rendering requirement information.
  • Step S202 The terminal generates an image rendering request based on the data to be rendered and preset rendering requirement information.
  • the data to be rendered and the preset rendering requirement information are encapsulated into the image rendering request.
  • Step S203 The terminal sends an image rendering request to the server.
  • Step S204 The server parses the rendering requirement information to obtain index data corresponding to each vertex in the vertex set.
  • the rendering requirement information includes processing instructions for each vertex.
  • step S204 can be implemented in the following manner: first, initialize and set the index data of each vertex to obtain initialization index data; then, The rendering requirement information is parsed to obtain the processing instruction of each vertex; finally, when the processing instruction is a rendering instruction, the initial index data of the vertex is updated to the second type index data; and, when the processing instruction is a non-rendering instruction, Update the initial index data of the vertex to the first type index data.
  • the initialization setting may be to set the index data of each vertex to the same initial value, and the initial value constitutes the initialization index data. For example, set the index data of each vertex to 0. At this time, the initial index data is 0.
  • the processing corresponding to the vertex is designated as a rendering instruction; when a certain vertex does not need to be rendered, the processing instruction corresponding to the vertex is designated as a non-rendering instruction.
  • the processing corresponding to the vertex is designated as a non-rendering instruction; when a certain vertex does not need to be eliminated, the processing instruction corresponding to the vertex is designated as a rendering instruction.
  • the first type of index data and the second type of index data are index data used to represent two relative vertex processing states.
  • the first type of index data is index data used to represent vertices that are not to be rendered.
  • the second type of index data is index data used to represent the vertices to be rendered.
  • the index data of any vertex is the second type of index data, it can be determined that the vertex does not need to be eliminated and is a vertex that needs to be rendered.
  • the initialization index data of the vertex is updated, and a rendering tag is added to the corresponding vertex through the second type of index data.
  • the rendering processing method of the corresponding vertex can be determined based on the second type of index data.
  • the initialization index data of the vertex is updated, and a rendering tag is added to the corresponding vertex through the first type of index data.
  • the rendering processing method of the corresponding vertex can be determined based on the first type of index data.
  • Step S205 The server integrates the index data corresponding to all vertices in the vertex set to obtain an index data set.
  • the index data corresponding to all vertices in the vertex set is integrated, which may include counting the index data of all vertices to form an index data set.
  • the index data set includes the index data of each vertex, and the mapping relationship between the vertex identifier of the vertex and the index data. Through the vertex identifier and the mapping relationship, the index data corresponding to the vertex can be determined.
  • the terminal can also obtain the input data to be rendered and the index data corresponding to each vertex, integrate the index data corresponding to all vertices to obtain an index data set, and then generate an image based on the data to be rendered and the index data set.
  • Rendering request includes the data to be rendered and the index data collection. That is to say, the server can obtain the rendering requirement information sent by the terminal, then parse the rendering requirement information, obtain the index data of each vertex, and further integrate the index data to obtain the index data set; or, it can also be The terminal parses the user's rendering requirement information to obtain the index data of each vertex, and further integrates the index data to obtain an index data set.
  • Step S206 The server obtains the vertex position information of each vertex in the vertex set.
  • the vertex position information refers to the position information of each vertex in the image.
  • the vertex position information may be a coordinate data, that is, the vertex position information is presented in the form of coordinate data.
  • Step S207 The server obtains index data corresponding to each vertex from the index data set.
  • the index data corresponding to each vertex can be determined from the index data set based on the vertex identifier of each vertex.
  • Step S208 The server performs scaling processing on the vertex position information of each vertex based on the index data to obtain a scaling result.
  • step S208 can be implemented in the following manner: multiply the vertex position information of each vertex with the index data corresponding to the vertex to obtain a vertex position product; after obtaining the vertex position product of each vertex, determine the vertex position product is the scaling result of the corresponding vertex.
  • scaling processing refers to reducing or amplifying the coordinate data of the vertex position information.
  • the index data can take on any positive number. When the index data of any vertex is a positive number less than 1, the coordinate data of the vertex can be reduced through the index data; when the index data of any vertex is a number greater than 1, the coordinate data of the vertex can be reduced through the index data. The coordinate data of the vertex is enlarged; when the index data of any vertex is equal to 1, the coordinate data of the vertex does not change based on the index data.
  • the index data can take the value 0 or 1.
  • the coordinate data of the vertex can be reduced through the index data; when the index data is equal to 1, the coordinate data of the vertex does not change based on the index data.
  • Step S209 The server determines the vertex to be eliminated from the vertex set based on the scaling result of each vertex.
  • the vertices in the vertex set can also be triangulated based on the vertex position information to obtain at least one initial triangle; wherein, each The initial triangle includes three vertices.
  • each The initial triangle includes three vertices.
  • determine the vertex to be eliminated from the vertex set based on the scaling result of each vertex. This can be when the product of the vertex positions corresponding to the three vertices of any initial triangle is the same, determine the three vertices of the initial triangle as Vertices to be eliminated.
  • the vertex position products corresponding to the three vertices of any initial triangle are all the same, it may be when the vertex position products corresponding to the three vertices of any initial triangle are all 0.
  • the three vertices of this initial triangle can be determined as the vertices to be eliminated.
  • the products of the vertex positions corresponding to the three vertices are all 0, that is, the coordinate data of the three vertices are all 0, and the three vertices are at the same position, the three vertices can be shrunk to the same position, thereby hiding the three vertices. two of them.
  • these three vertices are all vertices to be eliminated and do not need to be rendered.
  • determining the vertex to be eliminated from the vertex set may be: when the vertex position product is the first type of position data, determine the vertex corresponding to the vertex position product as Vertices to be eliminated; when the vertex position product is the second type of position data, the vertex corresponding to the vertex position product is determined as the vertex to be rendered.
  • the first type of position data and the second type of position data are two opposite types of position data. That is to say, the vertex position product is either the first type of position data or the second type of position data, and the first type of position data and The second type of position data is state data used to represent two completely opposite elimination states of a vertex.
  • the elimination state includes a state to be eliminated and a non-elimination state.
  • the first type of position data may be 0. Then when the product of the vertex position of any vertex is 0, the vertex will be The point is determined as a vertex to be eliminated; the second type of position data can be 1, then when the vertex position product of any vertex is 1, the vertex is determined to be a vertex to be rendered, that is, a non-eliminated vertex.
  • Step S210 The server deletes the vertices to be eliminated in the vertex set to obtain a set of vertices to be rendered.
  • Step S211 The server sequentially performs vertex rendering on the vertices to be rendered in the vertex set to be rendered, and obtains a rendered image.
  • step S212 the server sends the rendered image to the terminal.
  • Step S213 The terminal displays the rendered image on the current interface.
  • the image rendering method provided by the embodiment of the present application performs scaling processing on the vertex position information of each vertex based on the index data of each vertex to obtain a scaling result, and based on the scaling result of each vertex, determines the desired vertex set from the vertex set. Eliminate vertices. In this way, judgment is made based on the calculated vertex position product to determine which of the first type of position data and the second type of position data the vertex position product belongs to, so that the elimination state of the vertex can be accurately determined, and the vertex set can be accurately analyzed.
  • the vertices to be eliminated are obtained to obtain an accurate set of vertices to be rendered, so as to accurately respond to the user's rendering needs.
  • a draw call when performing image rendering, a draw call (Drawcall) may be called to implement the image rendering method in the embodiment of the present application.
  • Figure 11 is another optional flow diagram of the image rendering method provided by the embodiment of the present application. As shown in Figure 11, the method includes the following steps S301 to step S312:
  • Step S301 The terminal obtains input data to be rendered and preset rendering requirement information.
  • the data to be rendered corresponds to a vertex set.
  • Step S302 The terminal generates an image rendering request based on the data to be rendered and preset rendering requirement information.
  • Step S303 The terminal sends the image rendering request to the server.
  • Step S304 The server parses the rendering requirement information to obtain index data corresponding to each vertex in the vertex set.
  • Step S305 The server integrates the index data corresponding to all vertices in the vertex set to obtain an index data set.
  • Step S306 The server obtains index data corresponding to each vertex from the index data set.
  • Step S307 The server determines the vertex processing status corresponding to each vertex based on the index data.
  • the server can also obtain the vertex position information of each vertex; and based on the vertex position information, triangulate the vertices in the vertex set to obtain at least one initial triangle; wherein each initial triangle includes three vertex.
  • determining the vertex processing status corresponding to each vertex based on the index data may be that when the index data corresponding to the three vertices of any initial triangle are all preset type index data, the vertex processing of the three vertices of the initial triangle
  • the state is determined to be the elimination state, that is, the three vertices of the initial triangle are determined as the vertices to be eliminated.
  • determining the vertex processing status corresponding to each vertex based on the index data may be: when the index data is the first type of index data, determining the vertex processing status of the vertex that has a mapping relationship with the index data as Elimination state; when the index data is the second type of index data, the vertex processing state of the vertex that has a mapping relationship with the index data is determined to be a non-elimination state, where the first type of index data and the second type of index data are used to represent Index data for the two relative vertex processing states.
  • the vertices that have a mapping relationship with the index data are determined as the vertices to be eliminated; when the index data is the second type of index data, the vertices that have a mapping relationship with the index data are determined Identified as the vertex to be rendered.
  • Step S308 When the vertex processing status of any vertex is the elimination state, the server determines the vertex as the vertex to be eliminated.
  • Step S309 The server deletes the vertices to be eliminated in the vertex set to obtain a set of vertices to be rendered.
  • Step S310 The server sequentially performs vertex rendering on the vertices to be rendered in the vertex set to be rendered, and obtains a rendered image.
  • step S310 can be implemented in the following manner: first, obtain the vertex position information of each vertex to be rendered; then, based on the vertex position information, triangulate the vertices to be rendered in the vertex set to be rendered to obtain at least one The triangle to be rendered; finally, vertex rendering is performed with each triangle to be rendered as the rendering unit, and the rendered image is obtained.
  • Step S311 the server sends the rendered image to the terminal.
  • Step S312 The terminal displays the rendered image on the current interface.
  • the server determines the vertex processing status corresponding to each vertex based on the index data.
  • the server determines the vertex as the vertex to be eliminated, thereby performing Vertex elimination is performed on some vertices in the vertex set to obtain a vertex set to be rendered; and vertex rendering is performed on the vertices to be rendered in the vertex set to be rendered sequentially to obtain a rendered image.
  • a specific game screen is displayed corresponding to each operation of the user.
  • the server of the game application P1 renders each game screen, due to the screen in the game application
  • the continuity of the game screen in several consecutive frames may not be much different, with only local differences. Therefore, at the moment of implementation, batch rendering can be performed on the continuous game screen, and the local differences can be extracted to obtain each game Vertex rendering is performed on the vertices of the screen to be rendered.
  • the rendering data of the previous game screen can constitute the data to be rendered for the next game screen.
  • the parts of the latter game screen that do not need to be rendered are determined, thereby obtaining the data of the latter game screen.
  • the vertices to be rendered are the problem that the method of the embodiment of the present application can solve.
  • the problem that the method of the embodiment of the present application can solve is the rapid and accurate rendering of consecutive similar video frames.
  • the data to be rendered of the game screen and the index data set corresponding to the user's operation are first obtained.
  • the index data set corresponds to the user's operation, that is, it can be based on the user's operation.
  • the operation determines the index data set; the data to be rendered corresponds to a vertex set; then based on the data to be rendered and the index data in the index data set, vertex elimination is performed on some vertices in the vertex set to obtain the vertex set to be rendered; finally Vertex rendering is performed sequentially on the vertices to be rendered in the vertex set to be rendered, and the game screen is obtained.
  • Figure 12A presents the original face image (i.e., the original image) before the user performs any operation
  • Figure 12B presents the game screen that needs to be displayed after the user performs any operation (i.e., rendering).
  • the resulting image), corresponding to the user's operation, the game screen that needs to be displayed is compared with the original face image, and part of the hair 121 is not rendered. Therefore, it is necessary to obtain data to be rendered that does not include part of the hair 121 .
  • the user's operation instruction K1 under the original face image can be obtained, and the rendering requirement information corresponding to the operation instruction K1 is determined based on K1, and then the rendering requirement information is analyzed to obtain the same as in Figure 12A
  • the index data of each vertex in the vertex set corresponding to the data to be rendered of the original face image wherein, based on the index data, the vertex processing state corresponding to each vertex can be determined, and the vertex processing state includes the elimination state and the non-elimination state.
  • vertex elimination processing is performed on the vertices of the partial hair 121 area in the original face image to obtain the game screen.
  • a set of vertices to be rendered, and then the vertices to be rendered in the set of vertices to be rendered are sequentially rendered to obtain a game screen of the unrendered hair 121 area.
  • the corresponding index data set is determined based on the user's operation instructions.
  • the index data set can represent the user's rendering needs, that is, based on the index data in the index data set, the corresponding index data set can be determined. Which vertices in the game screen need to be rendered and which vertices do not need to be rendered, so as to realize the control Fast and accurate rendering of consecutive similar video frames.
  • Embodiments of the present application provide an image rendering method, which is a GPU rendering call optimization method with wider adaptability. This method solves the need to implement intermittent vertex rendering from a single draw call of the vertex buffer in some scenarios, that is, not all rendering from vertex 1 to vertex n is performed in sequence within a single draw call, but intermittently within a single draw call. Render vertices 1-10, vertices 31-100, vertices 221-300..., and vertices 1000-n. During the rendering process, some vertices in the middle will be skipped.
  • an index value i.e., the above-mentioned index data
  • index the scale factor array i.e., scaleFactors[], the scale factor array includes multiple scale factors
  • Figure 12A is the original image
  • Figure 12B is an image in which the rendering of the hair part of the body is disabled.
  • the rendering of part of the hair 121 in Figure 12B can be prohibited.
  • the method of the embodiment of the present application can use any hardware environment of a device with a GPU and at least supporting the OpenGL-ES 2.0 standard.
  • the vertex elimination algorithm used in implementing vertex elimination processing in the embodiments of this application mainly involves the following principles: adding a vertex index data (scaleFactorIdx) to each vertex, and the vertex index data is used to index the scale factor array (scaleFactors).
  • scaleFactorIdx a vertex index data
  • scaleFactors scale factor array
  • the GPU has the following characteristics: when the three vertices of the triangle are all at the same position, no pixels will be rendered. Exploiting this property in conjunction with the vertex elimination algorithm above can produce very useful results.
  • Figure 13 is a flow chart of an image rendering method provided by an embodiment of the present application. As shown in Figure 13, the method includes the following steps S401 to S407:
  • Step S401 load the value of the scale factor array (i.e. scaleFactors[], corresponding to the index in the above embodiment data collection).
  • scaleFactor represents the scale factor corresponding to the product of the i-th vertex (vertices[i]) and the scale factor index (scaleFactorIdx) (corresponding to the index data in the above embodiment).
  • verticesIdx represents the vertex index, which is used to index specific vertices
  • vertices[verticesIdx].xyz represents the position of the vertex corresponding to the vertex index.
  • Step S405 Render vertex p.
  • Step S407 determine whether i is less than the total number of vertices.
  • step S403 If the judgment result is yes, then return to step S403 to continue; if the judgment result is no, the process ends, vertex rendering is completed, and the rendering result is cached.
  • FIG 14 is another flow chart of the image rendering method provided by the embodiment of the present application. As shown in Figure 14, the method includes the following steps S501 to S508:
  • Step S503 Determine whether to enable rendering of vertex i (i.e., the i-th vertex).
  • step S504 is executed; if the judgment result is no, step S505 is executed.
  • Step S505 determine whether to turn on the rendering of vertex i.
  • step S506 is executed; if the judgment result is no, step S507 is executed.
  • Step S508 determine whether i is less than the total number of values in the scale factor array.
  • step S503 If the judgment result is yes, return to continue executing step S503; if the judgment result is no, the process ends and the process of changing whether the vertex is rendered is completed.
  • Figures 15 to 17 are schematic diagrams of the effects of applying the method of the embodiment of the present application to three devices with different device performance (such as low-end machines, mid-range machines and high-end machines).
  • the average number of frames transmitted per second (FPS, Frames Per Second) is 58.9, and during operation, the FPS change curve 151 is relatively stable.
  • the FPS after 00:06 in Figure 15 is relatively stable, but there is a large valley value at 00:06.
  • the main reason is: the influence of other interference factors, such as the game has just started, needs to be dealt with There are many other things that are not related to the image rendering process of the embodiment of the present application, so the low value can be ignored.
  • the average FPS is 59.6, and during operation, the FPS change curve 161 is also relatively stable (ignoring the trough at 00:06).
  • the average FPS is 59.6, and during operation, the FPS change curve 171 is also relatively stable (ignoring the low value at 00:06).
  • the method of the embodiments of the present application in realizing the problem of intermittent vertex rendering, since there is no need to copy vertex data or a high-end GPU, the method of the embodiments of the present application has wider adaptability and higher rendering efficiency. None is lost by enabling or disabling the rendering of certain parts of the image to be rendered.
  • the content related to user information such as data to be rendered, index data sets, rendered images and other information, if it involves data related to user information or enterprise information, when this application
  • user permission or consent needs to be obtained, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
  • the image rendering device 354 includes: an acquisition module 3541 configured to acquire data to be rendered. and an index data set used to reflect rendering requirement information; the data to be rendered corresponds to a vertex set; the vertex elimination module 3542 is configured to eliminate the vertex set in the vertex set based on the data to be rendered and the index data in the index data set.
  • the vertex rendering module 3543 is configured to sequentially perform vertex rendering on the vertices to be rendered in the set of vertices to be rendered to obtain a rendered image.
  • the vertex elimination module is further configured to: obtain the index of each vertex in the vertex set. Vertex position information; obtain index data corresponding to each vertex from the index data set; perform scaling processing on the vertex position information of each vertex based on the index data, and obtain the scaling result of each vertex correspondingly; based on each vertex
  • the scaling result of a vertex determines the vertex to be eliminated from the vertex set; deletes the vertex to be eliminated in the vertex set to obtain the vertex set to be rendered.
  • the vertex elimination module is further configured to: multiply the vertex position information of each vertex with the index data corresponding to the corresponding vertex to obtain the vertex position product of each vertex; multiply the vertex position product of each vertex , determined as the scaling result of the corresponding vertex.
  • the device further includes: a first triangulation module configured to triangulate the vertices in the vertex set based on the vertex position information to obtain at least one initial triangle; wherein each The initial triangle includes three vertices; the vertex elimination module is also configured to: when the products of the vertex positions of the three vertices of any initial triangle are the same, determine the three vertices of the initial triangle as the vertices to be eliminated. .
  • a first triangulation module configured to triangulate the vertices in the vertex set based on the vertex position information to obtain at least one initial triangle; wherein each The initial triangle includes three vertices; the vertex elimination module is also configured to: when the products of the vertex positions of the three vertices of any initial triangle are the same, determine the three vertices of the initial triangle as the vertices to be eliminated.
  • the vertex elimination module is further configured to: when the vertex position product is the first type of position data, determine the vertex corresponding to the vertex position product as the vertex to be eliminated; when the vertex position product When it is the second type of position data, the vertex corresponding to the vertex position product is determined as the vertex to be rendered; the first type of position data and the second type of position data are used to represent two relative elimination states. status data.
  • the vertex elimination module is further configured to: obtain the data associated with each vertex from the index data set. Index data corresponding to the vertex; based on the index data, determine the vertex processing state corresponding to each vertex; when the vertex processing state of any vertex is the elimination state, determine the vertex as the vertex to be eliminated; from the vertex set Delete the vertices to be eliminated to obtain the set of vertices to be rendered.
  • the device further includes: a position information acquisition module configured to obtain vertex position information of each vertex; a second triangulation module configured to, based on the vertex position information, obtain the vertex position information in the vertex set.
  • the vertices are triangulated to obtain at least one initial triangle; wherein each initial triangle includes three vertices; the vertex elimination module is also configured to: when the index data corresponding to the three vertices of any initial triangle is preset When type indexing data, the vertex processing status of the three vertices of the initial triangle is determined to be the elimination status.
  • the vertex elimination module is further configured to: when the index data is the first type of index data, determine the vertex processing status of the vertex having the mapping relationship with the index data as the elimination status; When the index data is second type index data, the vertex processing state of the vertex having the mapping relationship with the index data is determined to be a non-elimination state; the first type index data and the second type index Data is index data used to characterize two relative vertex processing states.
  • the vertex rendering module is further configured to: obtain the vertex position information of each vertex to be rendered. information; based on the vertex position information, triangulate the vertices to be rendered in the vertex set to be rendered to obtain at least one triangle to be rendered; taking each triangle to be rendered as a rendering unit, triangulate the vertices to be rendered Vertex rendering is performed on the vertices to be rendered in the set to obtain the rendered image.
  • the device further includes: a request acquisition module configured to obtain an image rendering request, the image rendering request including the data to be rendered and preset rendering requirement information; a parsing module configured to perform rendering The demand information is parsed to obtain index data corresponding to each vertex in the vertex set; an integration module is configured to integrate index data corresponding to all vertices in the vertex set to obtain the index data set.
  • a request acquisition module configured to obtain an image rendering request, the image rendering request including the data to be rendered and preset rendering requirement information
  • a parsing module configured to perform rendering The demand information is parsed to obtain index data corresponding to each vertex in the vertex set
  • an integration module is configured to integrate index data corresponding to all vertices in the vertex set to obtain the index data set.
  • the rendering requirement information includes processing instructions for each vertex; the parsing module is also configured to: initialize and set the index data of each vertex to obtain initialization index data; and set the rendering requirement The information is parsed to obtain the processing instruction of each vertex; when the processing instruction is a rendering instruction, the initialization index data of the vertex is updated to the second type index data; when the processing instruction is a non-rendering instruction, the The initialization index data of the vertex is updated to the first type of index data.
  • Embodiments of the present application provide a computer program product or computer program.
  • the computer program product or computer program includes executable instructions.
  • the executable instructions are computer instructions; the executable instructions are stored in a computer-readable storage medium.
  • the processor of the electronic device reads the executable instruction from the computer-readable storage medium and the processor executes the executable instruction, the image rendering device is caused to perform the method described above in the embodiment of the present application.
  • Embodiments of the present application provide a storage medium in which executable instructions are stored. When the executable instructions are executed by a processor, they will cause the processor to execute the method provided by embodiments of the present application. For example, as shown in Figure 9 shows the method.
  • the storage medium may be a computer-readable storage medium, such as ferroelectric memory (FRAM, Ferromagnetic Random Access Memory), read-only memory (ROM, Read Only Memory), programmable read-only memory (PROM, Programmable Read Only Memory), Erasable Programmable Read Only Memory (EPROM, Erasable Programmable Read Only Memory), Electrically Erasable Programmable Read Only Memory (EEPROM, Electrically Erasable Programmable Read Only Memory), flash memory, magnetic surface memory, optical disk, Or memory such as CD-ROM (Compact Disk-Read Only Memory); it can also be various devices including one of the above memories or any combination thereof.
  • FRAM ferroelectric memory
  • ROM Read Only Memory
  • PROM programmable read-only memory
  • EPROM Erasable Programmable Read Only Memory
  • EEPROM Electrically Erasable Programmable Read Only Memory
  • flash memory magnetic surface memory, optical disk, Or memory such as CD-ROM (Compact Disk-Read Only Memory); it can also be various devices including one of the above memories or any combination thereof
  • executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages, and their May be deployed in any form, including deployed as a stand-alone program or deployed as a module, component, subroutine, or other unit suitable for use in a computing environment.
  • executable instructions may, but do not necessarily correspond to, files in a file system and may be stored as part of a file holding other programs or data, for example, in a Hyper Text Markup Language (HTML) document. in one or more scripts, in a single file that is specific to the program in question, or in multiple collaborative files (e.g., files that store one or more modules, subroutines, or portions of code).
  • executable instructions may be deployed for execution on one computing device (which may be a job runtime determination device), or on multiple computing devices located at one location, or distributed across multiple locations and via Execute on multiple computing devices interconnected by a communication network.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Biophysics (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • Biomedical Technology (AREA)
  • Health & Medical Sciences (AREA)
  • Computational Linguistics (AREA)
  • Data Mining & Analysis (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • General Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Image Generation (AREA)

Abstract

Embodiments of the present application provide an image rendering method and apparatus, an electronic device, a computer-readable storage medium, and a computer program product, at least applied to the field of image rendering and the technical field of games. The method comprises: obtaining data to be rendered and an index data set, the data to be rendered corresponding to a vertex set; performing, on the basis of the data to be rendered and index data in the index data set, vertex elimination processing on some of vertices in the vertex set to obtain a vertex set to be rendered; and sequentially performing vertex rendering on vertices to be rendered in the vertex set to be rendered to obtain a rendered image.

Description

图像渲染方法、装置、电子设备、计算机可读存储介质及计算机程序产品Image rendering methods, devices, electronic equipment, computer-readable storage media and computer program products
相关申请的交叉引用Cross-references to related applications
本申请基于申请号为202210384063.6、申请日为2022年04月13日的中国专利申请提出,并要求该中国专利申请的优先权,该中国专利申请的全部内容在此引入本申请作为参考。This application is filed based on a Chinese patent application with application number 202210384063.6 and a filing date of April 13, 2022, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby incorporated by reference into this application.
技术领域Technical field
本申请实施例涉及互联网技术领域,涉及但不限于一种图像渲染方法、装置、电子设备、计算机可读存储介质及计算机程序产品。Embodiments of the present application relate to the field of Internet technology, and relate to but are not limited to an image rendering method, device, electronic equipment, computer-readable storage media, and computer program products.
背景技术Background technique
网格是指包含顶点和面的结构,网格是三维(3D,3-dimension)游戏对象显示的常用方法,在3D游戏对象渲染和显示技术中,通常是以网格中的最小单元(三角形)为渲染单位进行顶点渲染。顶点缓冲区(VB,Vertex Buffer)是一个连续的顶点数据数组,在一些图像渲染场景下,需要从顶点缓冲区中对网格进行间歇顶点渲染。A mesh refers to a structure containing vertices and faces. The mesh is a common method for displaying three-dimensional (3D, 3-dimension) game objects. In 3D game object rendering and display technology, the smallest unit (triangle) in the mesh is usually used. ) performs vertex rendering for the rendering unit. The vertex buffer (VB, Vertex Buffer) is a continuous array of vertex data. In some image rendering scenarios, intermittent vertex rendering of the mesh needs to be performed from the vertex buffer.
相关技术中,在实现间歇顶点渲染时,通常需要分开调用多个绘制调用(Drawcall)才能够实现;或者,需要高阶图形处理器(GPU,Graphics Processing Unit)(即渲染性能高于常规GPU的渲染性能)的图形绘制接口来实现;或者,需要按照待渲染对象的零部件是否启用渲染,来实时填充需要渲染的数据到VB,该填充步骤涉及数据拷贝过程。In related technologies, when implementing intermittent vertex rendering, it is usually necessary to call multiple draw calls (Drawcall) separately; or, a high-end graphics processor (GPU, Graphics Processing Unit) is required (that is, the rendering performance is higher than that of a conventional GPU). Rendering performance); or, the data to be rendered needs to be filled in VB in real time according to whether the components of the object to be rendered are enabled for rendering. This filling step involves a data copy process.
显然,相关技术中的方法在实现间歇顶点渲染时需要调用多个绘制调用,会极大的增大渲染时长,降低渲染效率;而需要高阶GPU的图形绘制接口,则存在适配性不够广,不是所有机型都能适用的问题;同时,数据拷贝过程会存在一定的时延,会极大的影响图像渲染效率。由此可见,相关技术中的间歇性顶点渲染方法,均存在图像渲染效率低的问题。Obviously, the methods in the related art need to call multiple draw calls when implementing intermittent vertex rendering, which will greatly increase the rendering time and reduce the rendering efficiency; while the graphics drawing interface that requires a high-end GPU has insufficient adaptability. , a problem that is not applicable to all models; at the same time, there will be a certain delay in the data copy process, which will greatly affect the image rendering efficiency. It can be seen that the intermittent vertex rendering methods in related technologies all have the problem of low image rendering efficiency.
发明内容Contents of the invention
本申请实施例提供一种图像渲染方法、装置、电子设备、计算机可读存储介质及计算机程序产品,至少应用于图像渲染领域和游戏技术领域,能够基于索引数据对顶点集合中的部分顶点进行顶点消除处理,从而能够通过调用一个绘制调用即可实现对待渲染数据的间歇顶点渲染,从而提高图像渲染效率。Embodiments of the present application provide an image rendering method, device, electronic device, computer-readable storage medium and computer program product, which are at least used in the field of image rendering and game technology and can perform vertex processing on some vertices in a vertex set based on index data. Eliminate processing so that intermittent vertex rendering of data to be rendered can be achieved by calling a single draw call, thereby improving image rendering efficiency.
本申请实施例的技术方案是这样实现的:The technical solution of the embodiment of this application is implemented as follows:
本申请实施例提供一种图像渲染方法,所述方法包括:An embodiment of the present application provides an image rendering method, which includes:
获取待渲染数据和用于反映渲染需求信息的索引数据集合;所述待渲染数据对应一顶点集合;基于所述待渲染数据和所述索引数据集合中的索引数据,对所述顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合;对所述待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。Obtain data to be rendered and an index data set used to reflect rendering requirement information; the data to be rendered corresponds to a vertex set; based on the data to be rendered and the index data in the index data set, calculate the vertex set in the vertex set Perform vertex elimination processing on some vertices to obtain a set of vertices to be rendered; perform vertex rendering on the vertices to be rendered in the set of vertices to be rendered in order to obtain a rendered image.
本申请实施例提供一种图像渲染装置,所述装置包括:获取模块,配置为获取待 渲染数据和用于反映渲染需求信息的索引数据集合;所述待渲染数据对应一顶点集合;消除模块,配置为基于所述待渲染数据和所述索引数据集合中的索引数据,对所述顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合;顶点渲染模块,配置为对所述待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。An embodiment of the present application provides an image rendering device. The device includes: an acquisition module configured to acquire the to-be- Rendering data and an index data set used to reflect rendering requirement information; the data to be rendered corresponds to a vertex set; an elimination module is configured to eliminate the vertices based on the data to be rendered and the index data in the index data set. Part of the vertices in the set are subjected to vertex elimination processing to obtain a set of vertices to be rendered; a vertex rendering module is configured to sequentially perform vertex rendering on the vertices to be rendered in the set of vertices to be rendered to obtain a rendered image.
本申请实施例提供一种电子设备,包括:存储器,用于存储可执行指令;处理器,用于执行所述存储器中存储的可执行指令时,实现上述图像渲染方法。An embodiment of the present application provides an electronic device, including: a memory for storing executable instructions; and a processor for implementing the above image rendering method when executing the executable instructions stored in the memory.
本申请实施例提供一种计算机程序产品或计算机程序,计算机程序产品或计算机程序包括可执行指令,可执行指令存储在计算机可读存储介质中;其中,电子设备的处理器从计算机可读存储介质中读取可执行指令,并执行可执行指令时,实现上述的图像渲染方法。Embodiments of the present application provide a computer program product or computer program. The computer program product or computer program includes executable instructions, and the executable instructions are stored in a computer-readable storage medium; wherein, the processor of the electronic device obtains the information from the computer-readable storage medium. When the executable instructions are read and executed, the above image rendering method is implemented.
本申请实施例提供一种计算机可读存储介质,存储有可执行指令,用于引起处理器执行所述可执行指令时,实现上述图像渲染方法。Embodiments of the present application provide a computer-readable storage medium that stores executable instructions for causing a processor to execute the executable instructions to implement the above image rendering method.
本申请实施例具有以下有益效果:基于所获取的待渲染数据和索引数据集合中的索引数据,对待渲染数据对应的顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合,这样,待渲染顶点集合中包括的则是对顶点集合进行顶点消除处理后剩余的部分顶点,对于这些剩余的部分顶点,能够通过调用一个绘制调用即可实现顶点渲染,也就是说,通过调用一个绘制调用即可实现对顶点集合中的顶点进行间歇顶点渲染。如此,不仅能够提高图像渲染效率,而且该间歇顶点渲染方法适用于不同配置的设备,从而能够提高设备适配性。The embodiments of the present application have the following beneficial effects: based on the acquired data to be rendered and the index data in the index data set, vertex elimination processing is performed on some vertices in the vertex set corresponding to the data to be rendered, and a set of vertices to be rendered is obtained. In this way, after The rendering vertex set includes the remaining vertices after vertex elimination processing of the vertex set. For these remaining vertices, vertex rendering can be achieved by calling a draw call, that is, by calling a draw call. Intermittent vertex rendering of vertices in a vertex collection can be implemented. In this way, not only the image rendering efficiency can be improved, but also the intermittent vertex rendering method is suitable for devices with different configurations, thereby improving device adaptability.
附图说明Description of the drawings
图1A是本申请实施例提供的网格的结构示意图;Figure 1A is a schematic structural diagram of a grid provided by an embodiment of the present application;
图1B是本申请实施例提供的顶点-面-边之间的关系示意图;Figure 1B is a schematic diagram of the relationship between vertices-face-edges provided by the embodiment of the present application;
图2是间歇顶点渲染的示意图;Figure 2 is a schematic diagram of intermittent vertex rendering;
图3是相关技术中调用多个绘制调用进行间歇顶点渲染的示意图;Figure 3 is a schematic diagram of calling multiple draw calls for intermittent vertex rendering in related technologies;
图4是相关技术中采用高阶GPU的图形绘制接口进行间歇顶点渲染的示意图;Figure 4 is a schematic diagram of intermittent vertex rendering using the graphics rendering interface of a high-end GPU in related technologies;
图5是相关技术中通过数据拷贝进行间歇顶点渲染的示意图;Figure 5 is a schematic diagram of intermittent vertex rendering through data copying in the related art;
图6是相关技术中通过多次渲染进行间歇顶点渲染的示意图;Figure 6 is a schematic diagram of intermittent vertex rendering through multiple renderings in the related art;
图7是本申请实施例提供的图像渲染系统的一个可选的架构示意图;Figure 7 is an optional architectural schematic diagram of the image rendering system provided by the embodiment of the present application;
图8是本申请实施例提供的电子设备的结构示意图;Figure 8 is a schematic structural diagram of an electronic device provided by an embodiment of the present application;
图9是本申请实施例提供的图像渲染方法的一个可选的流程示意图;Figure 9 is an optional flow diagram of the image rendering method provided by the embodiment of the present application;
图10是本申请实施例提供的图像渲染方法的另一个可选的流程示意图;Figure 10 is another optional flow diagram of the image rendering method provided by the embodiment of the present application;
图11是本申请实施例提供的图像渲染方法的再一个可选的流程示意图;Figure 11 is another optional flow diagram of the image rendering method provided by the embodiment of the present application;
图12A是本申请实施例的启用/禁用身体某些部分的渲染前的原始图像;Figure 12A is an original image before rendering of enabling/disabling certain parts of the body according to an embodiment of the present application;
图12B是本申请实施例的禁用身体头发部分渲染的图像;Figure 12B is an image of disabling the rendering of the hair part of the body according to the embodiment of the present application;
图13是本申请实施例提供的图像渲染方法的流程图;Figure 13 is a flow chart of an image rendering method provided by an embodiment of the present application;
图14是本申请实施例提供的图像渲染方法的另一流程图;Figure 14 is another flow chart of the image rendering method provided by the embodiment of the present application;
图15是本申请实施例的方法应用于低端机的效果示意图;Figure 15 is a schematic diagram of the effect of the method according to the embodiment of the present application applied to a low-end machine;
图16是本申请实施例的方法应用于中端机的效果示意图;Figure 16 is a schematic diagram of the effect of the method according to the embodiment of the present application applied to a mid-range machine;
图17是本申请实施例的方法应用于高端机的效果示意图。 Figure 17 is a schematic diagram of the effect of applying the method according to the embodiment of the present application to a high-end machine.
具体实施方式Detailed ways
为了使本申请的目的、技术方案和优点更加清楚,下面将结合附图对本申请作进一步地详细描述,所描述的实施例不应视为对本申请的限制,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其它实施例,都属于本申请保护的范围。In order to make the purpose, technical solutions and advantages of the present application clearer, the present application will be described in further detail below in conjunction with the accompanying drawings. The described embodiments should not be regarded as limiting the present application. Those of ordinary skill in the art will not make any All other embodiments obtained under the premise of creative work belong to the scope of protection of this application.
在以下的描述中,涉及到“一些实施例”,其描述了所有可能实施例的子集,但是可以理解,“一些实施例”可以是所有可能实施例的相同子集或不同子集,并且可以在不冲突的情况下相互结合。除非另有定义,本申请实施例所使用的所有的技术和科学术语与属于本申请实施例的技术领域的技术人员通常理解的含义相同。本申请实施例所使用的术语只是为了描述本申请实施例的目的,不是旨在限制本申请。In the following description, reference is made to "some embodiments" which describe a subset of all possible embodiments, but it is understood that "some embodiments" may be the same subset or a different subset of all possible embodiments, and Can be combined with each other without conflict. Unless otherwise defined, all technical and scientific terms used in the embodiments of the present application have the same meanings as commonly understood by those skilled in the technical field belonging to the embodiments of the present application. The terms used in the embodiments of the present application are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
在说明本申请实施例的方案之前,首先对本申请实施例涉及的名词进行解释:Before describing the solutions of the embodiments of the present application, first, the terms involved in the embodiments of the present application are explained:
(1)网格:是指包含顶点和面的结构。网格是3D游戏对象显示的常用方法。网格是包含顶点数组和面数组的数据结构。如图1A所示,是网格的结构示意图,在图像渲染过程中,是以网格中的网格单元为单位进行渲染的,其中网格中包括多个网格单元101。(1) Mesh: refers to the structure containing vertices and faces. Grids are a common method of displaying 3D game objects. A mesh is a data structure that contains arrays of vertices and arrays of faces. As shown in FIG. 1A , it is a schematic structural diagram of a grid. During the image rendering process, rendering is performed in units of grid units in the grid, where the grid includes multiple grid units 101 .
(2)顶点:是一个数据结构,包含一个三度空间向量,每个顶点对应有该顶点的位置[x,y,z]。如图1B所示,是顶点-面-边之间的关系示意图,顶点(即顶点=[x,y,z])在图1B中分别包括顶点0、顶点1和顶点2。(2) Vertex: It is a data structure that contains a three-dimensional space vector. Each vertex corresponds to the position of the vertex [x, y, z]. As shown in Figure 1B, it is a schematic diagram of the relationship between vertices-faces-edges. The vertices (i.e. vertices = [x, y, z]) in Figure 1B include vertex 0, vertex 1 and vertex 2 respectively.
(3)面:是一个包含三个索引整数的数据结构,通过索引数据能够指示这个面所使用的顶点。如图1B所示,面1表示为:面1=[0,1,2]。(3) Face: It is a data structure containing three index integers. The index data can indicate the vertices used by this face. As shown in Figure 1B, face 1 is expressed as: face 1 = [0, 1, 2].
(4)边:每个面有三条边。边是包含两个索引整数的数据结构。如图1B所示,三条边(边0、边1和边2)分别表示为:边0=[0,1]、边1=[1,2]、边2=[2,0]。(4) Sides: Each face has three sides. An edge is a data structure containing two indexed integers. As shown in Figure 1B, the three edges (edge 0, edge 1, and edge 2) are respectively represented as: edge 0=[0,1], edge 1=[1,2], and edge 2=[2,0].
(5)渲染实例化:渲染实例化又称GPU实例化,使用GPU实例化可使用少量绘制调用(Drawcall)一次绘制(或渲染)同一网格的多个副本。对于绘制诸如建筑物、树木、草地或其他在场景中重复出现的对象非常有用。在每次绘制调用时,GPU实例化仅渲染相同的网格,但每个实例可以具有不同的参数(例如,颜色或比例),以增加变化并减少外观上的重复。GPU实例化可以降低每个场景使用的绘制调用数量。GPU实例化可以显着提高项目的渲染性能。(5) Rendering instantiation: Rendering instantiation is also called GPU instantiation. Using GPU instantiation, you can use a small number of draw calls (Drawcall) to draw (or render) multiple copies of the same mesh at once. Useful for drawing objects such as buildings, trees, grass, or other objects that recur in a scene. GPU instancing simply renders the same mesh on each draw call, but each instance can have different parameters (for example, color or scale) to increase variation and reduce repetition in appearance. GPU instancing can reduce the number of draw calls used per scene. GPU instancing can significantly improve your project's rendering performance.
(6)绘制调用:是中央处理器(CPU,Central Processing Unit)对底层图形绘制接口的调用命令,以命令GPU执行渲染操作,渲染流程采用流水线实现,CPU和GPU并行工作,CPU和GPU之间通过命令缓冲区连接,CPU向命令缓冲区中发送渲染命令,GPU接收并执行对应的渲染命令。这里,绘制调用影响绘制的原因主要是因为每次绘制时,CPU都需要调用一个绘制调用,而每个绘制调用都需要很多准备工作,例如,准备工作包括但不限于:检测渲染状态、提交渲染数据和提交渲染状态等。而GPU本身具有很强大的计算能力,可以很快就处理完渲染任务。当绘制调用过多,CPU就需要提供很多额外开销用于准备工作,CPU本身负载较高,而这时GPU可能闲置了。由于过多的绘制调用会造成CPU的性能瓶颈,因此大量时间消耗在绘制调用的准备工作上。对于绘制调用影响绘制的情况,一个优化方向就是:尽量把小的绘制调用合并到一个大的绘制调用中。(6) Draw call: It is the call command of the central processing unit (CPU, Central Processing Unit) to the underlying graphics drawing interface to instruct the GPU to perform rendering operations. The rendering process is implemented using a pipeline. The CPU and GPU work in parallel, and there is a gap between the CPU and the GPU. Through the command buffer connection, the CPU sends rendering commands to the command buffer, and the GPU receives and executes the corresponding rendering commands. Here, the main reason why draw calls affect drawing is because every time you draw, the CPU needs to call a draw call, and each draw call requires a lot of preparation work. For example, preparation work includes but is not limited to: detecting rendering status, submitting rendering Data and submission rendering state, etc. The GPU itself has very powerful computing power and can handle rendering tasks quickly. When there are too many draw calls, the CPU needs to provide a lot of extra overhead for preparation work. The CPU itself is under high load, and the GPU may be idle at this time. Since too many draw calls will cause a CPU performance bottleneck, a lot of time is spent on the preparation of draw calls. For situations where draw calls affect drawing, one optimization direction is to try to merge small draw calls into one large draw call.
(7)高阶GPU(例如GPU glMulti)的图形绘制接口:指的是开放图形接口(OpenGLES,Open Graphics Library),这些接口需要高端GPU(支持OpenGLES 3.1甚至以上)硬件才能用的上的图形绘制接口。其中,高阶GPU是指渲染性能高于常规GPU的渲染性能的GPU。(7) Graphics drawing interface of high-end GPU (such as GPU glMulti): refers to the open graphics interface (OpenGLES, Open Graphics Library). These interfaces require high-end GPU (supporting OpenGLES 3.1 or above) hardware to use graphics drawing. interface. Among them, high-end GPU refers to a GPU whose rendering performance is higher than that of a conventional GPU.
(8)顶点缓冲区:是OpenGL/Directx(一种图像应用编程接口,这些图像应用编程接口用于渲染二维或者三维图像)等的一种存放在GPU的缓冲区,用作存放顶点数 据数组,顶点缓冲区提供了将顶点数据(位置、法线向量和颜色等)上传到GPU以进行非即时模式渲染的方法。顶点缓冲区相比于立即模式渲染提供了显著的性能提升,主要是因为数据驻留在GPU内存中而不是系统内存中,因此数据可以由GPU取出并直接渲染。(8) Vertex buffer: It is a buffer stored in the GPU such as OpenGL/Directx (an image application programming interface, these image application programming interfaces are used to render two-dimensional or three-dimensional images), and is used to store the number of vertices. Data array, vertex buffer provides a method to upload vertex data (position, normal vector, color, etc.) to the GPU for non-immediate mode rendering. Vertex buffers provide significant performance improvements over immediate mode rendering, primarily because the data resides in GPU memory rather than system memory, so the data can be fetched by the GPU and rendered directly.
(9)单绘制调用的间歇顶点渲染:顶点缓冲区是一个连续的顶点数据数组,某些场景需要从顶点缓冲区的单个绘制调用进行间歇渲染顶点,即单个绘制调用内不是由顶点1至顶点n顺序全部渲染,而是单个绘制调用内间歇地进行顶点1-10,顶点31-100,顶点221-300…,顶点1000-n的渲染,中间有一些顶点会略过。如图2所示,是间歇顶点渲染的示意图,在进行间歇顶点渲染之前,只需要做少量处理来判定中间顶点是否显示。例如,在图2中第一行表示顶点数据数组中的全部20个顶点:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20。而在实际渲染过程中需要进行间歇顶点渲染,即只需要渲染顶点1,2,3,4,5,6,7和顶点13,14,15,16,17,18,19,20,因此,中间的顶点8,9,10,11,12会略过不进行渲染。(9) Intermittent vertex rendering of a single draw call: The vertex buffer is a continuous array of vertex data. Some scenes require intermittent rendering of vertices from a single draw call of the vertex buffer, that is, it is not from vertex 1 to vertex within a single draw call. n are all rendered sequentially, but vertices 1-10, vertices 31-100, vertices 221-300..., and vertices 1000-n are rendered intermittently within a single draw call, and some vertices in the middle are skipped. As shown in Figure 2, it is a schematic diagram of intermittent vertex rendering. Before intermittent vertex rendering, only a small amount of processing needs to be done to determine whether the intermediate vertices are displayed. For example, the first row in Figure 2 represents all 20 vertices in the vertex data array: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20. In the actual rendering process, intermittent vertex rendering is required, that is, only vertices 1, 2, 3, 4, 5, 6, 7 and vertices 13, 14, 15, 16, 17, 18, 19, 20 need to be rendered. Therefore, The middle vertices 8, 9, 10, 11, and 12 will be skipped and not rendered.
在解释本申请实施例的图像渲染方法之前,首先对相关技术中的方法进行说明。Before explaining the image rendering method in the embodiment of the present application, the method in the related art will first be described.
在间歇顶点渲染过程中,相关技术中的一种实现方式是将多个绘制调用分开,从而实现间歇顶点渲染,也就是说需要通过调用多个绘制调用才能够实现间歇顶点渲染。如图3所示,是相关技术中调用多个绘制调用进行间歇顶点渲染的示意图,对于顶点数据数组中的全部20个顶点:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,其中,在第一行图像数据的渲染过程中,顶点4,5,6,7是不需要渲染的顶点,在第二行图像数据的渲染过程中,顶点8,9,10,11,12和13,14,15,16,17,18,19,20是不需要渲染的顶点,因此,整体渲染过程中,需要调用5个绘制调用来进行渲染,其中5个绘制调用分别是:glDrawArray(1,2,3),用于渲染顶点1,2,3;glDrawArray(8,9,10,11,12),用于渲染顶点8,9,10,11,12;glDrawArray(13,14,15,16,17,18,19,20),用于渲染顶点13,14,15,16,17,18,19,20;glDrawArray(1,2,3),用于渲染顶点1,2,3;glDrawArray(4,5,6,7),用于渲染顶点4,5,6,7。During the intermittent vertex rendering process, one implementation method in related technologies is to separate multiple draw calls to implement intermittent vertex rendering. That is to say, intermittent vertex rendering needs to be implemented by calling multiple draw calls. As shown in Figure 3, it is a schematic diagram of calling multiple draw calls for intermittent vertex rendering in related technologies. For all 20 vertices in the vertex data array: 1, 2, 3, 4, 5, 6, 7, 8, 9 , 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, among which, during the rendering process of the first row of image data, vertices 4, 5, 6, and 7 are vertices that do not need to be rendered. , during the rendering process of the second row of image data, vertices 8, 9, 10, 11, 12 and 13, 14, 15, 16, 17, 18, 19, 20 are vertices that do not need to be rendered, therefore, the overall rendering process , 5 draw calls need to be called for rendering. The 5 draw calls are: glDrawArray(1, 2, 3), used to render vertices 1, 2, 3; glDrawArray(8, 9, 10, 11, 12 ), used to render vertices 8, 9, 10, 11, 12; glDrawArray(13, 14, 15, 16, 17, 18, 19, 20), used to render vertices 13, 14, 15, 16, 17, 18 , 19, 20; glDrawArray (1, 2, 3), used to render vertices 1, 2, 3; glDrawArray (4, 5, 6, 7), used to render vertices 4, 5, 6, 7.
相关技术中的另一种实现方式是需要高阶GPU的图形绘制接口,如图4所示,是相关技术中采用高阶GPU的图形绘制接口进行间歇顶点渲染的示意图,对于顶点数据数组中的全部20个顶点:1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,其中,在第一行图像数据的渲染过程中,顶点4,5,6,7是不需要渲染的顶点,在第二行图像数据的渲染过程中,顶点8,9,10,11,12和13,14,15,16,17,18,19,20是不需要渲染的顶点,因此,整体渲染过程中,采用高阶GPU的图形绘制接口,调用1个绘制调用来进行渲染,其中这一个绘制调用是:
glDrawArray(
1,2,3,
8,9,10,11,12,
13,14,15,16,17,18,19,20,
1,2,3,
4,5,6,7
)。
Another implementation method in the related art requires a graphics drawing interface of a high-end GPU. As shown in Figure 4, it is a schematic diagram of using the graphics drawing interface of a high-end GPU to perform intermittent vertex rendering in the related art. For the vertex data array All 20 vertices: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, among which, in the first During the rendering process of the row image data, vertices 4, 5, 6, and 7 are vertices that do not need to be rendered. During the rendering process of the second row of image data, vertices 8, 9, 10, 11, 12 and 13, 14, 15 , 16, 17, 18, 19, and 20 are vertices that do not need to be rendered. Therefore, during the overall rendering process, the graphics rendering interface of the high-end GPU is used to call one draw call for rendering. This draw call is:
glDrawArray(
1, 2, 3,
8, 9, 10, 11, 12,
13, 14, 15, 16, 17, 18, 19, 20,
1, 2, 3,
4, 5, 6, 7
).
但是这种方法适配性不够广,不是所有机型都能适用。However, the adaptability of this method is not wide enough, and not all models can be applied.
相关技术中的再一种实现方式是按照对象的零部件是否启用渲染,来实时填充需要渲染的数据到VB,如图5所示,是相关技术中通过数据拷贝进行间歇顶点渲染的示意图,对于顶点数据数组中的全部20个顶点:1,2,3,4,5,6,7,8,9,10,11,12, 13,14,15,16,17,18,19,20,其中,在第一行图像数据的渲染过程中,顶点4,5,6,7是不需要渲染的顶点,在第二行图像数据的渲染过程中,顶点8,9,10,11,12和13,14,15,16,17,18,19,20是不需要渲染的顶点,因此,整体渲染过程中,可以将待渲染数据拷贝至顶点缓冲区中,然后进行渲染。但是,这种方法涉及一个数据拷贝过程,因此性能有瓶颈上限。Another implementation method in the related art is to fill the data that needs to be rendered into VB in real time according to whether the components of the object enable rendering. As shown in Figure 5, it is a schematic diagram of intermittent vertex rendering through data copying in the related art. For All 20 vertices in the vertex data array: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, among which, in the rendering process of the first row of image data, vertices 4, 5, 6, and 7 are vertices that do not need to be rendered, and in the second row of image data During the rendering process, vertices 8, 9, 10, 11, 12 and 13, 14, 15, 16, 17, 18, 19, 20 are vertices that do not need to be rendered. Therefore, during the overall rendering process, the data to be rendered can be Copy it to the vertex buffer and render. However, this method involves a data copy process, so there is a bottleneck limit on performance.
相关技术中的又一种实现方式是,如果没有高阶GPU的图形绘制接口,因为同类物件的零部件有不同的启用状态,所以不能实例化,需要多次渲染。如图6所示,是相关技术中通过多次渲染进行间歇顶点渲染的示意图,对于物件一、物件二和物件三,其中部件1、部件2、部件3和部件4为相同部件,需要渲染的数据和内容完全相同,但是物件一、物件二和物件三中不需要渲染的部件不同,因此,对于相同的部件,在不同物件中可能需要进行多次渲染。这样,显然会降低图像渲染效率。Another implementation method in the related technology is that if there is no graphics drawing interface of a high-end GPU, because the components of similar objects have different enabled states, they cannot be instantiated and need to be rendered multiple times. As shown in Figure 6, it is a schematic diagram of intermittent vertex rendering through multiple renderings in related technologies. For object one, object two and object three, component 1, component 2, component 3 and component 4 are the same components and need to be rendered. The data and content are exactly the same, but the components that do not need to be rendered in object one, object two and object three are different. Therefore, for the same component, multiple renderings may be required in different objects. This will obviously reduce image rendering efficiency.
基于相关技术中所存在的上述至少一个问题,本申请实施例提供一种图像渲染方法,该图像渲染方法是一种适配性更广的GPU渲染调用优化方法,该方法解决了某些场景下,从顶点缓冲区的单个绘制调用实现间歇顶点渲染的需求,即单个绘制调用内不是由顶点1至顶点n顺序全部渲染,而是单个绘制调用内间歇地对顶点1-10,顶点31-100,顶点221-300…,顶点1000-n进行渲染,中间有一些顶点会略过不进行渲染。Based on at least one of the above problems existing in related technologies, embodiments of the present application provide an image rendering method. The image rendering method is a GPU rendering call optimization method with wider adaptability. This method solves the problem in certain scenarios. , the need to implement intermittent vertex rendering from a single draw call in the vertex buffer, that is, not all vertices 1 to vertex n are rendered sequentially within a single draw call, but vertices 1-10, vertices 31-100 are intermittently rendered within a single draw call , vertices 221-300..., vertices 1000-n are rendered, and some vertices in the middle will be skipped and not rendered.
本申请实施例提供的图像渲染方法中,首先,获取待渲染数据和索引数据集合;待渲染数据对应一顶点集合;然后,基于待渲染数据和索引数据集合中的索引数据,对顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合;最后,对待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。如此,由于基于索引数据对顶点集合中的部分顶点进行顶点消除处理,从而能够调用一个绘制调用即可实现间歇顶点渲染,不仅提高图像渲染效率,而且适用于不同的设备,具有高的适配性。In the image rendering method provided by the embodiment of the present application, first, the data to be rendered and the index data set are obtained; the data to be rendered corresponds to a vertex set; then, based on the data to be rendered and the index data in the index data set, the vertex set in the vertex set is Vertex elimination is performed on some vertices to obtain a set of vertices to be rendered; finally, vertex rendering is performed on the vertices to be rendered in the set of vertices to be rendered to obtain a rendered image. In this way, since the vertex elimination process is performed on some vertices in the vertex set based on the index data, intermittent vertex rendering can be implemented with a single draw call, which not only improves image rendering efficiency, but is also suitable for different devices and has high adaptability. .
下面说明本申请实施例的图像渲染设备的示例性应用,该图像渲染设备是用于实现本申请实施例的图像渲染方法的电子设备。本申请实施例提供的图像渲染设备(即电子设备)可以实施为终端,也可以实施为服务器。在一种实现方式中,本申请实施例提供的图像渲染设备可以实施为笔记本电脑,平板电脑,台式计算机,移动设备(例如,移动电话,便携式音乐播放器,个人数字助理,专用消息设备,便携式游戏设备)、智能机器人、智能家电和智能车载设备等任意的具备图像处理功能、视频显示功能和图像渲染功能的终端;在另一种实现方式中,本申请实施例提供的图像渲染设备还可以实施为服务器,其中,服务器可以是独立的物理服务器,也可以是多个物理服务器构成的服务器集群或者分布式系统,还可以是提供云服务、云数据库、云计算、云函数、云存储、网络服务、云通信、中间件服务、域名服务、安全服务、内容分发网络(CDN,Content Delivery Network)、以及大数据和人工智能平台等基础云计算服务的云服务器。终端以及服务器可以通过有线或无线通信方式进行直接或间接地连接,本申请实施例中不做限制。下面,将说明图像渲染设备实施为服务器时的示例性应用。The following describes an exemplary application of the image rendering device according to the embodiment of the present application. The image rendering device is an electronic device used to implement the image rendering method according to the embodiment of the present application. The image rendering device (ie, electronic device) provided by the embodiment of the present application can be implemented as a terminal or as a server. In one implementation, the image rendering device provided by the embodiment of the present application can be implemented as a notebook computer, a tablet computer, a desktop computer, a mobile device (for example, a mobile phone, a portable music player, a personal digital assistant, a dedicated messaging device, a portable Game equipment), smart robots, smart home appliances, smart vehicle-mounted equipment, and other terminals with image processing functions, video display functions, and image rendering functions; in another implementation, the image rendering device provided by the embodiment of the present application can also Implemented as a server, where the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or it can provide cloud services, cloud databases, cloud computing, cloud functions, cloud storage, and networks. Services, cloud communications, middleware services, domain name services, security services, content delivery network (CDN, Content Delivery Network), and cloud servers for basic cloud computing services such as big data and artificial intelligence platforms. The terminal and the server can be connected directly or indirectly through wired or wireless communication methods, which are not limited in the embodiments of this application. Next, an exemplary application when the image rendering device is implemented as a server will be described.
参见图7,图7是本申请实施例提供的图像渲染系统的一个可选的架构示意图,为实现支撑任意一个视频应用或者图像显示应用,图像渲染系统10中至少包括终端100、网络200和服务器300,其中服务器300是视频应用或者图像显示应用的服务器,服务器300可以构成本申请实施例的图像渲染设备。终端100通过网络200连接服务器300,网络200可以是广域网或者局域网,又或者是二者的组合。在图像渲染过程中,终端100将图像渲染请求通过网络200发送给服务器300,服务器300在获取到待渲染数据和用于反映渲染需求信息的索引数据集合后,基于待渲染数据和索引数据集合中的索引数据,对待渲染数据对应的顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合;然后对待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。在得到 渲染后的图像后,通过网络200将渲染后的图像发送给终端100,并在终端100上显示该渲染后的图像。Referring to Figure 7, Figure 7 is an optional architectural schematic diagram of an image rendering system provided by an embodiment of the present application. In order to support any video application or image display application, the image rendering system 10 at least includes a terminal 100, a network 200 and a server. 300, where the server 300 is a server for a video application or an image display application, and the server 300 may constitute the image rendering device in the embodiment of the present application. The terminal 100 connects to the server 300 through the network 200. The network 200 may be a wide area network or a local area network, or a combination of the two. During the image rendering process, the terminal 100 sends the image rendering request to the server 300 through the network 200. After obtaining the data to be rendered and the index data set used to reflect the rendering requirement information, the server 300 performs the processing based on the data to be rendered and the index data set. Index data, perform vertex elimination processing on some vertices in the vertex set corresponding to the to-be-rendered data, and obtain the to-be-rendered vertex set; then perform vertex rendering on the to-be-rendered vertices in the to-be-rendered vertex set in sequence to obtain the rendered image. in getting After rendering the image, the rendered image is sent to the terminal 100 through the network 200, and the rendered image is displayed on the terminal 100.
本申请实施例所提供的图像渲染方法还可以基于云平台并通过云技术来实现,例如,上述服务器300可以是云端服务器,通过云端服务器基于待渲染数据和索引数据集合中的索引数据,对顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合,以及,通过云端服务器对待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。The image rendering method provided by the embodiment of the present application can also be based on a cloud platform and implemented through cloud technology. For example, the above-mentioned server 300 can be a cloud server, and the cloud server can perform vertex mapping based on the data to be rendered and the index data in the index data set. Vertex elimination is performed on some vertices in the set to obtain a set of vertices to be rendered, and the vertices to be rendered in the set of vertices to be rendered are sequentially rendered through the cloud server to obtain a rendered image.
在一些实施例中,还可以具有云端存储器,可以将渲染后的图像存储至云端存储器中,或者将索引数据集合存储至云端存储器中,或者将待渲染数据与渲染后的图像映射后存储至云端存储器中。这样,在后续需要再次对待渲染数据进行图像渲染时,可以直接从云端存储器中读取该渲染后的图像。In some embodiments, there may also be cloud storage. The rendered image may be stored in the cloud storage, or the index data set may be stored in the cloud storage, or the data to be rendered and the rendered image may be mapped and stored in the cloud. in memory. In this way, when the image rendering data needs to be rendered again later, the rendered image can be read directly from the cloud storage.
这里需要说明的是,云技术(Cloud technology)是指在广域网或局域网内将硬件、软件、网络等系列资源统一起来,实现数据的计算、储存、处理和共享的一种托管技术。云技术基于云计算商业模式应用的网络技术、信息技术、整合技术、管理平台技术、应用技术等的总称,可以组成资源池,按需所用,灵活便利。云计算技术将变成重要支撑。技术网络系统的后台服务需要大量的计算、存储资源,如视频网站、图片类网站和更多的门户网站。伴随着互联网行业的高度发展和应用,将来每个物品都有可能存在自己的识别标志,都需要传输到后台系统进行逻辑处理,不同程度级别的数据将会分开处理,各类行业数据皆需要强大的系统后盾支撑,只能通过云计算来实现。What needs to be explained here is that cloud technology refers to a hosting technology that unifies a series of resources such as hardware, software, and networks within a wide area network or local area network to realize data calculation, storage, processing, and sharing. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool and use it on demand, which is flexible and convenient. Cloud computing technology will become an important support. The background services of technical network systems require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the rapid development and application of the Internet industry, in the future each item may have its own identification mark, which needs to be transmitted to the backend system for logical processing. Data at different levels will be processed separately, and all types of industry data need to be powerful. System backing support can only be achieved through cloud computing.
图8是本申请实施例提供的电子设备的结构示意图,图8所示的电子设备包括:至少一个处理器310、存储器350、至少一个网络接口320和用户接口330。电子设备中的各个组件通过总线系统340耦合在一起。可理解,总线系统340用于实现这些组件之间的连接通信。总线系统340除包括数据总线之外,还包括电源总线、控制总线和状态信号总线。但是为了清楚说明起见,在图8中将各种总线都标为总线系统340。Figure 8 is a schematic structural diagram of an electronic device provided by an embodiment of the present application. The electronic device shown in Figure 8 includes: at least one processor 310, a memory 350, at least one network interface 320 and a user interface 330. The various components in the electronic device are coupled together through bus system 340 . It can be understood that the bus system 340 is used to implement connection communication between these components. In addition to the data bus, the bus system 340 also includes a power bus, a control bus and a status signal bus. However, for the sake of clarity, the various buses are labeled bus system 340 in FIG. 8 .
处理器310可以是一种集成电路芯片,具有信号的处理能力,例如通用处理器、数字信号处理器(DSP,Digital Signal Processor),或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等,其中,通用处理器可以是微处理器或者任何常规的处理器等。用户接口330包括使得能够呈现媒体内容的一个或多个输出装置331,以及一个或多个输入装置332。存储器350可以是可移除的,不可移除的或其组合。示例性的硬件设备包括固态存储器,硬盘驱动器,光盘驱动器等。存储器350可选地包括在物理位置上远离处理器310的一个或多个存储设备。存储器350包括易失性存储器或非易失性存储器,也可包括易失性和非易失性存储器两者。非易失性存储器可以是只读存储器(ROM,Read Only Memory),易失性存储器可以是随机存取存储器(RAM,Random Access Memory)。本申请实施例描述的存储器350旨在包括任意适合类型的存储器。在一些实施例中,存储器350能够存储数据以支持各种操作,这些数据的示例包括程序、模块和数据结构或者其子集或超集,下面示例性说明。操作系统351,包括用于处理各种基本系统服务和执行硬件相关任务的系统程序,例如框架层、核心库层、驱动层等,用于实现各种基础业务以及处理基于硬件的任务;网络通信模块352,用于经由一个或多个(有线或无线)网络接口320到达其他计算设备,示例性的网络接口320包括:蓝牙、无线相容性认证(WiFi)、和通用串行总线(USB,Universal Serial Bus)等;输入处理模块353,用于对一个或多个来自一个或多个输入装置332之一的一个或多个用户输入或互动进行检测以及翻译所检测的输入或互动。The processor 310 may be an integrated circuit chip with signal processing capabilities, such as a general-purpose processor, a digital signal processor (DSP, Digital Signal Processor), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware Components, etc., wherein the general processor can be a microprocessor or any conventional processor, etc. User interface 330 includes one or more output devices 331 that enable the presentation of media content, and one or more input devices 332. Memory 350 may be removable, non-removable, or a combination thereof. Exemplary hardware devices include solid state memory, hard disk drives, optical disk drives, etc. Memory 350 optionally includes one or more storage devices physically located remotely from processor 310 . Memory 350 includes volatile memory or non-volatile memory, and may include both volatile and non-volatile memory. Non-volatile memory can be read-only memory (ROM, Read Only Memory), and volatile memory can be random access memory (RAM, Random Access Memory). The memory 350 described in the embodiments of this application is intended to include any suitable type of memory. In some embodiments, the memory 350 is capable of storing data to support various operations, examples of which include programs, modules, and data structures, or subsets or supersets thereof, as exemplarily described below. Operating system 351, including system programs used to process various basic system services and perform hardware-related tasks, such as framework layer, core library layer, driver layer, etc., used to implement various basic services and process hardware-based tasks; network communication Module 352 for reaching other computing devices via one or more (wired or wireless) network interfaces 320, example network interfaces 320 include: Bluetooth, Wireless Compliance (WiFi), and Universal Serial Bus (USB, Universal Serial Bus), etc.; input processing module 353 for detecting one or more user inputs or interactions from one or more input devices 332 and translating the detected inputs or interactions.
在一些实施例中,本申请实施例提供的装置可采用软件方式实现,图8示出了存储在存储器350中的一种图像渲染装置354,该图像渲染装置354可以是电子设备中的图 像渲染装置,其可以是程序和插件等形式的软件,包括以下软件模块:获取模块3541、顶点消除模块3542和顶点渲染模块3543,这些模块是逻辑上的,因此根据所实现的功能可以进行任意的组合或进一步拆分。将在下文中说明各个模块的功能。In some embodiments, the device provided by the embodiment of the present application can be implemented in software. Figure 8 shows an image rendering device 354 stored in the memory 350. The image rendering device 354 can be an image rendering device in an electronic device. Like the rendering device, it can be software in the form of programs and plug-ins, including the following software modules: acquisition module 3541, vertex elimination module 3542 and vertex rendering module 3543. These modules are logical, so any implementation can be performed according to the functions implemented. combination or further split. The functions of each module are explained below.
在另一些实施例中,本申请实施例提供的装置可以采用硬件方式实现,作为示例,本申请实施例提供的装置可以是采用硬件译码处理器形式的处理器,其被编程以执行本申请实施例提供的图像渲染方法,例如,硬件译码处理器形式的处理器可以采用一个或多个应用专用集成电路(ASIC,Application Specific Integrated Circuit)、DSP、可编程逻辑器件(PLD,Programmable Logic Device)、复杂可编程逻辑器件(CPLD,Complex Programmable Logic Device)、现场可编程门阵列(FPGA,Field-Programmable Gate Array)或其他电子元件。In other embodiments, the device provided by the embodiment of the present application can be implemented in hardware. As an example, the device provided by the embodiment of the present application can be a processor in the form of a hardware decoding processor, which is programmed to execute the present application. The image rendering method provided by the embodiment, for example, the processor in the form of a hardware decoding processor can use one or more Application Specific Integrated Circuits (ASIC, Application Specific Integrated Circuit), DSP, Programmable Logic Device (PLD, Programmable Logic Device) ), Complex Programmable Logic Device (CPLD, Complex Programmable Logic Device), Field Programmable Gate Array (FPGA, Field-Programmable Gate Array) or other electronic components.
本申请各实施例提供的图像渲染方法可以由图像渲染设备来执行,其中,该图像渲染设备可以是任意一种具备图像处理功能、视频显示功能和图像渲染功能的终端,或者也可以是服务器,即本申请各实施例的图像渲染方法可以通过终端来执行,也可以通过服务器来执行,或者还可以通过终端与服务器进行交互来执行。The image rendering method provided by each embodiment of the present application can be executed by an image rendering device, where the image rendering device can be any terminal with image processing functions, video display functions and image rendering functions, or it can also be a server, That is, the image rendering method in each embodiment of the present application can be executed through a terminal, a server, or the terminal interacts with a server.
图9是本申请实施例提供的图像渲染方法的一个可选的流程示意图,下面将结合图9示出的步骤进行说明,需要说明的是,图9中的图像渲染方法是通过服务器作为执行主体为例来说明的。参见图9,图像渲染方法包括以下步骤S101至S103:Figure 9 is an optional flow diagram of the image rendering method provided by the embodiment of the present application. The following will be described in conjunction with the steps shown in Figure 9. It should be noted that the image rendering method in Figure 9 uses the server as the execution subject. To illustrate with an example. Referring to Figure 9, the image rendering method includes the following steps S101 to S103:
步骤S101,获取待渲染数据和索引数据集合;待渲染数据对应一顶点集合。Step S101: Obtain the data to be rendered and the index data set; the data to be rendered corresponds to a vertex set.
这里,待渲染数据是用于渲染得到渲染图像的原始数据,待渲染数据中包括渲染图像上每一像素点对应的数据,通过待渲染数据进行图像渲染,可以得到原始图像,该原始图像是未进行任何处理,且未体现任何渲染需求信息的图像,即未体现用户的任何渲染需求的图像。Here, the data to be rendered is the original data used to render the rendered image. The data to be rendered includes the data corresponding to each pixel on the rendered image. By performing image rendering on the data to be rendered, the original image can be obtained. The original image is the unused image. Images that undergo any processing and do not reflect any rendering requirement information are images that do not reflect any rendering requirements of the user.
本申请实施例中,待渲染数据中的原始数据可以包括渲染图像的每一像素点的像素值,顶点集合中的全部顶点均匀排布在渲染图像中。其中,每一像素点可以对应一个顶点,像素点的位置就是顶点所在的位置;或者,多个像素点可以对应一个顶点,该多个像素点的中心位置就是所对应的顶点所在的位置。In this embodiment of the present application, the original data in the data to be rendered may include the pixel value of each pixel of the rendered image, and all vertices in the vertex set are evenly arranged in the rendered image. Among them, each pixel point can correspond to a vertex, and the position of the pixel point is the position of the vertex; or, multiple pixel points can correspond to one vertex, and the center position of the multiple pixel points is the position of the corresponding vertex.
索引数据集合是基于用户的渲染需求信息得到的数据集合,也就是说,索引数据集合中的索引数据是能够反映用户渲染需求的数据。索引数据集合中的索引数据用于对顶点集合中的每一顶点的顶点位置信息进行缩放处理,从而确定出每一顶点是否要被渲染。The index data set is a data set based on the user's rendering requirement information. That is to say, the index data in the index data set is data that can reflect the user's rendering requirement. The index data in the index data set is used to perform scaling processing on the vertex position information of each vertex in the vertex set, thereby determining whether each vertex is to be rendered.
本申请实施例中,顶点集合中包括至少三个顶点,其中,每三个顶点可以形成一个三角形。在进行图像渲染过程中,三角形是图像渲染的最小单位。当然,也可以由四个顶点连接形成四边形,由五个顶点连接形成五边形等。这些三角形、四边形和五边形等图形叠加后构成本申请实施例中图像对应的网格。在实际渲染过程中,针对网格中的图形,均是将图像划分成三角形,以三角形为渲染单位进行渲染。In this embodiment of the present application, the vertex set includes at least three vertices, where every three vertices can form a triangle. In the process of image rendering, triangle is the smallest unit of image rendering. Of course, four vertices can also be connected to form a quadrilateral, five vertices can be connected to form a pentagon, etc. These triangles, quadrilaterals, pentagons and other graphics are superimposed to form a grid corresponding to the image in the embodiment of the present application. In the actual rendering process, for the graphics in the grid, the image is divided into triangles, and the triangles are used as rendering units for rendering.
在一些实施例中,索引数据集合中的索引数据可以是预先设置的,也可以是基于用户的渲染指令计算得到的,将在下文中对索引数据的设置过程和基于渲染指令的计算过程进行详细说明。In some embodiments, the index data in the index data set may be preset, or may be calculated based on the user's rendering instructions. The setting process of the index data and the calculation process based on the rendering instructions will be described in detail below. .
步骤S102,基于待渲染数据和索引数据集合中的索引数据,对顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合。Step S102: Based on the data to be rendered and the index data in the index data set, perform vertex elimination processing on some of the vertices in the vertex set to obtain a vertex set to be rendered.
这里,可以通过对待渲染数据对应的顶点集合中的每一顶点进行顶点消除运算,得到每一顶点的运算结果,然后基于运算结果确定每一顶点是否要被消除。或者,还可以通过确定每一顶点对应的索引数据的数据类型,确定出该顶点是否要被消除,也就是说,每一顶点对应的索引数据中可以具有一标签数据,该标签数据是能够标识该顶点的消除状态的,通过该消除状态可以确定出该顶点是否要被消除。 Here, the vertex elimination operation can be performed on each vertex in the vertex set corresponding to the to-be-rendered data to obtain the operation result of each vertex, and then it is determined whether each vertex needs to be eliminated based on the operation result. Alternatively, you can also determine whether the vertex is to be eliminated by determining the data type of the index data corresponding to each vertex. That is to say, the index data corresponding to each vertex can have a label data, and the label data can identify The elimination status of the vertex can be used to determine whether the vertex is to be eliminated.
本申请实施例中,由于索引数据是预先设置的或者是基于用户的渲染指令计算得到的,因此索引数据能够表征用户的渲染需求,那么,基于索引数据进行顶点消除运算得到的运算结果,就能够准确的反应出每一顶点是否是要被消除掉的顶点。或者,通过标签数据对顶点可以进行区分,能够快速和准确的确定出每一顶点是否是要被消除掉的顶点。In the embodiment of this application, since the index data is preset or calculated based on the user's rendering instructions, the index data can represent the user's rendering needs. Then, the operation result obtained by performing the vertex elimination operation based on the index data can be Accurately reflects whether each vertex is a vertex to be eliminated. Alternatively, the vertices can be distinguished through label data, and it can be quickly and accurately determined whether each vertex is a vertex to be eliminated.
顶点消除处理是指将顶点集合中的部分顶点从顶点集合中删除掉,进而实现在渲染的过程中可以对顶点集合中的部分顶点不进行渲染。待渲染顶点集合中包括至少一个待渲染顶点,待渲染顶点是实际需要进行渲染的顶点。待渲染顶点集合中的待渲染顶点的数量小于顶点集合中的顶点的数量。Vertex elimination processing refers to deleting some vertices in the vertex set from the vertex set, so that some vertices in the vertex set can not be rendered during the rendering process. The set of vertices to be rendered includes at least one vertex to be rendered, and the vertex to be rendered is a vertex that actually needs to be rendered. The number of vertices to be rendered in the vertex set to be rendered is less than the number of vertices in the vertex set.
本申请实施例中,对部分顶点不进行渲染即间歇顶点渲染,也就是说,不是对顶点集合中的全部顶点按序进行连续渲染,而是间歇性的跳过一部分顶点,对这部分顶点不进行渲染。In the embodiment of the present application, some vertices are not rendered, that is, intermittent vertex rendering is performed. That is to say, instead of continuously rendering all the vertices in the vertex set in sequence, a part of the vertices is intermittently skipped, and the part of the vertices is not rendered. To render.
步骤S103,对待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。Step S103: Perform vertex rendering on the vertices to be rendered in the vertex set to be rendered in sequence to obtain a rendered image.
本申请实施例中,在得到消除了部分顶点的待渲染顶点集合之后,对待渲染顶点集合中的全部待渲染顶点进行顶点渲染,得到渲染后的图像(即渲染图像)。在渲染过程中,可以将待渲染顶点集合中的待渲染顶点进行三角划分,得到多个三角形,然后以每一三角形为单位进行三角图像渲染,得到渲染后的图像。In the embodiment of the present application, after obtaining a set of vertices to be rendered with some vertices eliminated, vertex rendering is performed on all the vertices to be rendered in the set of vertices to be rendered, to obtain a rendered image (i.e., a rendered image). During the rendering process, the vertices to be rendered in the vertex set to be rendered can be triangulated to obtain multiple triangles, and then the triangular image is rendered in units of each triangle to obtain a rendered image.
本申请实施例提供的图像渲染方法,基于所获取的待渲染数据和索引数据集合中的索引数据,对待渲染数据对应的顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合;并对待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。如此,由于基于索引数据对顶点集合中的部分顶点进行顶点消除处理,从而能够调用一个绘制调用即可实现间歇顶点渲染,不仅提高图像渲染效率,而且该图像渲染方法适用于不同的设备,具有高的设备适配性。The image rendering method provided by the embodiment of the present application performs vertex elimination processing on some vertices in the vertex set corresponding to the data to be rendered based on the acquired data to be rendered and the index data in the index data set, to obtain the set of vertices to be rendered; and The vertices to be rendered in the rendering vertex set are rendered in sequence to obtain the rendered image. In this way, since the vertex elimination process is performed on some vertices in the vertex set based on the index data, intermittent vertex rendering can be implemented by calling a draw call, which not only improves the image rendering efficiency, but also the image rendering method is suitable for different devices and has high performance. device compatibility.
在一些实施例中,用于实现图像渲染方法的图像渲染系统中至少包括终端和服务器。终端上运行有视频应用或者图像显示应用,这里以终端上运行有图像显示应用,且图像显示应用为游戏应用为例进行说明。In some embodiments, the image rendering system for implementing the image rendering method includes at least a terminal and a server. A video application or an image display application is running on the terminal. Here, an image display application is running on the terminal, and the image display application is a game application.
在游戏每一帧画面的渲染过程中,可以预先定义该帧画面中哪些部分(即哪些像素)是需要渲染的,哪些部分是不需要渲染的,这样,可以基于同一待渲染数据和用户的预定义信息渲染得到不同的游戏画面。举例来说,当对同一操作对象进行游戏操作时,前后两帧的游戏画面的差异可能非常小,仅是局部上显示信息不同,因此,在图像渲染之前可以预先定义这两帧游戏画面中哪些局部区域的信息需要渲染,哪些局部区域的信息不需要渲染。在渲染的过程中,基于预定义信息,可以采用本申请实施例提供的图像渲染方法进行图像渲染,得到最终显示的游戏画面。During the rendering process of each frame of the game, you can pre-define which parts of the frame (i.e. which pixels) need to be rendered and which parts do not need to be rendered. In this way, based on the same to-be-rendered data and the user's preset Define information to render different game screens. For example, when performing a game operation on the same operating object, the difference between the two frames of the game screen may be very small, and only the local display information is different. Therefore, it is possible to predefine which of the two frames of the game screen before rendering the image. Information in local areas needs to be rendered, and information in local areas does not need to be rendered. During the rendering process, based on the predefined information, the image rendering method provided by the embodiment of the present application can be used to perform image rendering to obtain the final displayed game screen.
图10是本申请实施例提供的图像渲染方法的另一个可选的流程示意图,如图10所示,方法包括以下步骤S201至S213:Figure 10 is another optional flow diagram of the image rendering method provided by the embodiment of the present application. As shown in Figure 10, the method includes the following steps S201 to S213:
步骤S201,终端获取输入的待渲染数据和预设的渲染需求信息,待渲染数据对应一顶点集合。Step S201: The terminal obtains input data to be rendered and preset rendering requirement information. The data to be rendered corresponds to a vertex set.
这里,渲染需求信息可以是用户通过终端输入的,例如,可以在输入待渲染数据时,对应于待渲染数据标记出不需要被渲染的区域、像素点或者顶点,则此时标记的全部数据构成该渲染需求信息。Here, the rendering requirement information can be input by the user through the terminal. For example, when inputting the data to be rendered, the areas, pixels or vertices that do not need to be rendered can be marked corresponding to the data to be rendered. Then all the data marked at this time constitute Information about the rendering requirements.
在一些实施例中,在进行图像渲染时,可以在游戏应用的当前界面上显示提示信息,该提示信息用于提示用户输入渲染需求信息,用户可以通过命令行输入框输入命令,形成渲染需求信息,也可以通过鼠标或键盘进行区域、像素点或者顶点的选择和标记,从 而生成渲染需求信息。In some embodiments, when performing image rendering, prompt information can be displayed on the current interface of the game application. The prompt information is used to prompt the user to input rendering requirement information. The user can enter commands through the command line input box to form the rendering requirement information. , you can also select and mark areas, pixels or vertices through the mouse or keyboard, from And generate rendering requirement information.
步骤S202,终端基于待渲染数据和预设的渲染需求信息生成图像渲染请求。Step S202: The terminal generates an image rendering request based on the data to be rendered and preset rendering requirement information.
这里,将待渲染数据和预设的渲染需求信息封装至图像渲染请求中。Here, the data to be rendered and the preset rendering requirement information are encapsulated into the image rendering request.
步骤S203,终端将图像渲染请求发送给服务器。Step S203: The terminal sends an image rendering request to the server.
步骤S204,服务器对渲染需求信息进行解析,得到与顶点集合中的每一顶点对应的索引数据。Step S204: The server parses the rendering requirement information to obtain index data corresponding to each vertex in the vertex set.
在一些实施例中,渲染需求信息中包括针对每一顶点的处理指令,对应地,步骤S204可以通过以下方式实现:首先,对每一顶点的索引数据进行初始化设置,得到初始化索引数据;然后,对渲染需求信息进行解析,得到每一顶点的处理指令;最后,当处理指令为渲染指令时,将顶点的初始化索引数据更新为第二类型索引数据;以及,当处理指令为非渲染指令时,将顶点的初始化索引数据更新为第一类型索引数据。In some embodiments, the rendering requirement information includes processing instructions for each vertex. Correspondingly, step S204 can be implemented in the following manner: first, initialize and set the index data of each vertex to obtain initialization index data; then, The rendering requirement information is parsed to obtain the processing instruction of each vertex; finally, when the processing instruction is a rendering instruction, the initial index data of the vertex is updated to the second type index data; and, when the processing instruction is a non-rendering instruction, Update the initial index data of the vertex to the first type index data.
这里,初始化设置可以是将每一顶点的索引数据设置为相同的初始值,由该初始值构成初始化索引数据。例如,将每一顶点的索引数据都设置为0,此时,初始化索引数据即为0。Here, the initialization setting may be to set the index data of each vertex to the same initial value, and the initial value constitutes the initialization index data. For example, set the index data of each vertex to 0. At this time, the initial index data is 0.
本申请实施例中,可以通过解析渲染需求信息,确定出针对每一顶点是否要进行渲染。当需要对某一顶点进行渲染时,该顶点对应的处理指定为渲染指令;当不需要对某一顶点进行渲染时,该顶点对应的处理指令为非渲染指令。In this embodiment of the present application, it can be determined whether rendering is required for each vertex by parsing the rendering requirement information. When a certain vertex needs to be rendered, the processing corresponding to the vertex is designated as a rendering instruction; when a certain vertex does not need to be rendered, the processing instruction corresponding to the vertex is designated as a non-rendering instruction.
在一些实施例中,还可以通过解析渲染需求信息,确定出针对每一顶点是否要进行消除处理。当需要对某一顶点进行消除处理时,该顶点对应的处理指定为非渲染指令;当不需要对某一顶点进行消除处理时,该顶点对应的处理指令为渲染指令。In some embodiments, it can also be determined whether elimination processing is to be performed on each vertex by parsing the rendering requirement information. When a certain vertex needs to be eliminated, the processing corresponding to the vertex is designated as a non-rendering instruction; when a certain vertex does not need to be eliminated, the processing instruction corresponding to the vertex is designated as a rendering instruction.
第一类型索引数据与第二类型索引数据是用于表征相对的两种顶点处理状态的索引数据。第一类型索引数据是用于表征要对顶点不进行渲染处理的索引数据。当任一顶点的索引数据为第一类型索引数据,则可以确定出该顶点是需要进行消除处理,且是不需要进行渲染的顶点。第二类型索引数据是用于表征要对顶点进行渲染处理的索引数据。当任一顶点的索引数据为第二类型索引数据,则可以确定出该顶点是不需要进行消除处理,且是需要进行渲染的顶点。The first type of index data and the second type of index data are index data used to represent two relative vertex processing states. The first type of index data is index data used to represent vertices that are not to be rendered. When the index data of any vertex is the first type of index data, it can be determined that the vertex needs to be eliminated and does not need to be rendered. The second type of index data is index data used to represent the vertices to be rendered. When the index data of any vertex is the second type of index data, it can be determined that the vertex does not need to be eliminated and is a vertex that needs to be rendered.
本申请实施例中,响应于处理指令为渲染指令,对顶点的初始化索引数据进行更新,并通过第二类型索引数据为相应顶点添加渲染标签。如此,能够使得在后续渲染过程中,可以基于第二类型索引数据确定出相应顶点的渲染处理方式。In the embodiment of the present application, in response to the processing instruction being a rendering instruction, the initialization index data of the vertex is updated, and a rendering tag is added to the corresponding vertex through the second type of index data. In this way, in the subsequent rendering process, the rendering processing method of the corresponding vertex can be determined based on the second type of index data.
本申请实施例中,响应于处理指令为非渲染指令,对顶点的初始化索引数据进行更新,并通过第一类型索引数据为相应顶点添加渲染标签。如此,能够使得在后续渲染过程中,可以基于第一类型索引数据确定出相应顶点的渲染处理方式。In the embodiment of the present application, in response to the processing instruction being a non-rendering instruction, the initialization index data of the vertex is updated, and a rendering tag is added to the corresponding vertex through the first type of index data. In this way, in the subsequent rendering process, the rendering processing method of the corresponding vertex can be determined based on the first type of index data.
步骤S205,服务器对顶点集合中的全部顶点对应的索引数据进行整合,得到索引数据集合。Step S205: The server integrates the index data corresponding to all vertices in the vertex set to obtain an index data set.
本申请实施例中,索引数据集合中的每一索引数据与一个顶点之间具有映射关系。这里,对顶点集合中的全部顶点对应的索引数据进行整合,可以是统计全部顶点的索引数据,形成索引数据集合。在该索引数据集合中,包括每一顶点的索引数据,以及,顶点的顶点标识与索引数据之间的映射关系。通过顶点标识和该映射关系,则可以确定出顶点对应的索引数据。In this embodiment of the present application, there is a mapping relationship between each index data in the index data set and a vertex. Here, the index data corresponding to all vertices in the vertex set is integrated, which may include counting the index data of all vertices to form an index data set. The index data set includes the index data of each vertex, and the mapping relationship between the vertex identifier of the vertex and the index data. Through the vertex identifier and the mapping relationship, the index data corresponding to the vertex can be determined.
在一些实施例中,终端还可以获取输入的待渲染数据和每一顶点对应的索引数据,并对全部顶点对应的索引数据进行整合得到索引数据集合,再基于待渲染数据和索引数据集合生成图像渲染请求,此时图像渲染请求中包括待渲染数据和索引数据集合。也就是说,可以由服务器获取终端发送的渲染需求信息,进而解析该渲染需求信息,得到每一顶点的索引数据,并进一步对索引数据进行整合得到索引数据集合;或者,也可以由 终端对用户的渲染需求信息进行解析,得到每一顶点的索引数据,并进一步对索引数据进行整合得到索引数据集合。In some embodiments, the terminal can also obtain the input data to be rendered and the index data corresponding to each vertex, integrate the index data corresponding to all vertices to obtain an index data set, and then generate an image based on the data to be rendered and the index data set. Rendering request. At this time, the image rendering request includes the data to be rendered and the index data collection. That is to say, the server can obtain the rendering requirement information sent by the terminal, then parse the rendering requirement information, obtain the index data of each vertex, and further integrate the index data to obtain the index data set; or, it can also be The terminal parses the user's rendering requirement information to obtain the index data of each vertex, and further integrates the index data to obtain an index data set.
步骤S206,服务器获取顶点集合中的每一顶点的顶点位置信息。Step S206: The server obtains the vertex position information of each vertex in the vertex set.
这里,顶点位置信息是指每一顶点在图像中的位置信息。顶点位置信息可以是一坐标数据,即顶点位置信息以坐标数据的形式呈现。Here, the vertex position information refers to the position information of each vertex in the image. The vertex position information may be a coordinate data, that is, the vertex position information is presented in the form of coordinate data.
步骤S207,服务器从索引数据集合中获取与每一顶点对应的索引数据。Step S207: The server obtains index data corresponding to each vertex from the index data set.
这里,可以基于每一顶点的顶点标识,从索引数据集合中确定出与每一顶点对应的索引数据。Here, the index data corresponding to each vertex can be determined from the index data set based on the vertex identifier of each vertex.
步骤S208,服务器基于索引数据,对每一顶点的顶点位置信息进行缩放处理,得到缩放结果。Step S208: The server performs scaling processing on the vertex position information of each vertex based on the index data to obtain a scaling result.
在一些实施例中,步骤S208可以通过以下方式实现:将每一顶点的顶点位置信息与顶点对应的索引数据相乘得到顶点位置乘积;在得到每一顶点的顶点位置乘积,将顶点位置乘积确定为相应顶点的缩放结果。In some embodiments, step S208 can be implemented in the following manner: multiply the vertex position information of each vertex with the index data corresponding to the vertex to obtain a vertex position product; after obtaining the vertex position product of each vertex, determine the vertex position product is the scaling result of the corresponding vertex.
本申请实施例中,缩放处理是指对顶点位置信息进行坐标数据的缩减或放大。在一种实现方式中,索引数据可以取值为任意的正数。当任一顶点的索引数据为小于1的正数时,则通过索引数据可以对该顶点的坐标数据进行缩减;当任一顶点的索引数据为大于1的数时,则通过索引数据可以对该顶点的坐标数据进行放大;当任一顶点的索引数据等于1时,则基于索引数据,该顶点的坐标数据不做变化。In the embodiment of the present application, scaling processing refers to reducing or amplifying the coordinate data of the vertex position information. In one implementation, the index data can take on any positive number. When the index data of any vertex is a positive number less than 1, the coordinate data of the vertex can be reduced through the index data; when the index data of any vertex is a number greater than 1, the coordinate data of the vertex can be reduced through the index data. The coordinate data of the vertex is enlarged; when the index data of any vertex is equal to 1, the coordinate data of the vertex does not change based on the index data.
在另一种实现方式中,索引数据可以取值为0或1。当索引数据等于0时,则通过索引数据可以对该顶点的坐标数据进行缩减;当索引数据等于1时,则基于索引数据,该顶点的坐标数据不做变化。In another implementation, the index data can take the value 0 or 1. When the index data is equal to 0, the coordinate data of the vertex can be reduced through the index data; when the index data is equal to 1, the coordinate data of the vertex does not change based on the index data.
步骤S209,服务器基于每一顶点的缩放结果,从顶点集合中确定待消除顶点。Step S209: The server determines the vertex to be eliminated from the vertex set based on the scaling result of each vertex.
在一种实现方式中,在获取到顶点集合中的每一顶点的顶点位置信息之后,还可以基于顶点位置信息,对顶点集合中的顶点进行三角划分,得到至少一个初始三角形;其中,每一初始三角形包括三个顶点。对应地,基于每一顶点的缩放结果,从顶点集合中确定出待消除顶点,可以是当任一初始三角形的三个顶点对应的顶点位置乘积均相同时,将初始三角形的三个顶点确定为待消除顶点。In one implementation, after obtaining the vertex position information of each vertex in the vertex set, the vertices in the vertex set can also be triangulated based on the vertex position information to obtain at least one initial triangle; wherein, each The initial triangle includes three vertices. Correspondingly, based on the scaling result of each vertex, determine the vertex to be eliminated from the vertex set. This can be when the product of the vertex positions corresponding to the three vertices of any initial triangle is the same, determine the three vertices of the initial triangle as Vertices to be eliminated.
这里,当任一初始三角形的三个顶点对应的顶点位置乘积均相同时,可以是当任一初始三角形的三个顶点对应的顶点位置乘积均为0时。此时,可以将这个初始三角形的三个顶点确定为待消除顶点。这样,由于三个顶点对应的顶点位置乘积均为0,即三个顶点的坐标数据均为0,三个顶点位于同一位置,因此可以将三个顶点收缩到同一位置,从而隐藏了三个顶点中的其中两个。在实现的过程中,这三个顶点均为待消除顶点,无需进行渲染。Here, when the vertex position products corresponding to the three vertices of any initial triangle are all the same, it may be when the vertex position products corresponding to the three vertices of any initial triangle are all 0. At this time, the three vertices of this initial triangle can be determined as the vertices to be eliminated. In this way, since the products of the vertex positions corresponding to the three vertices are all 0, that is, the coordinate data of the three vertices are all 0, and the three vertices are at the same position, the three vertices can be shrunk to the same position, thereby hiding the three vertices. two of them. During the implementation process, these three vertices are all vertices to be eliminated and do not need to be rendered.
在另一种实现方式中,基于每一顶点的缩放结果,从顶点集合中确定出待消除顶点,可以是:当顶点位置乘积为第一类型位置数据时,将顶点位置乘积对应的顶点确定为待消除顶点;当顶点位置乘积为第二类型位置数据时,将顶点位置乘积对应的顶点确定为待渲染顶点。In another implementation, based on the scaling result of each vertex, determining the vertex to be eliminated from the vertex set may be: when the vertex position product is the first type of position data, determine the vertex corresponding to the vertex position product as Vertices to be eliminated; when the vertex position product is the second type of position data, the vertex corresponding to the vertex position product is determined as the vertex to be rendered.
这里,第一类型位置数据与第二类型位置数据为相对的两种类型位置数据,也就是说,顶点位置乘积不是第一类型位置数据,就是第二类型位置数据,且第一类型位置数据和第二类型位置数据是用于表征顶点的完全相对的两种消除状态的状态数据。其中,消除状态包括待消除状态和非消除状态,当基于第一类型位置数据确定出顶点为待消除状态时,则该顶点为待消除顶点;当基于第二类型位置数据确定出顶点为非消除状态时,则该顶点为待渲染顶点。Here, the first type of position data and the second type of position data are two opposite types of position data. That is to say, the vertex position product is either the first type of position data or the second type of position data, and the first type of position data and The second type of position data is state data used to represent two completely opposite elimination states of a vertex. The elimination state includes a state to be eliminated and a non-elimination state. When a vertex is determined to be in a state to be eliminated based on the first type of location data, the vertex is a vertex to be eliminated; when a vertex is determined to be in a non-elimination state based on the second type of location data. state, the vertex is the vertex to be rendered.
例如,第一类型位置数据可以是0,则当任一顶点的顶点位置乘积为0时,将该顶 点确定为待消除顶点;第二类型位置数据可以是1,则当任一顶点的顶点位置乘积为1时,将该顶点确定为待渲染顶点,即非消除顶点。For example, the first type of position data may be 0. Then when the product of the vertex position of any vertex is 0, the vertex will be The point is determined as a vertex to be eliminated; the second type of position data can be 1, then when the vertex position product of any vertex is 1, the vertex is determined to be a vertex to be rendered, that is, a non-eliminated vertex.
步骤S210,服务器删除顶点集合中的待消除顶点,得到待渲染顶点集合。Step S210: The server deletes the vertices to be eliminated in the vertex set to obtain a set of vertices to be rendered.
步骤S211,服务器对待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。Step S211: The server sequentially performs vertex rendering on the vertices to be rendered in the vertex set to be rendered, and obtains a rendered image.
步骤S212,服务器将渲染后的图像发送给终端。In step S212, the server sends the rendered image to the terminal.
步骤S213,终端在当前界面上显示渲染后的图像。Step S213: The terminal displays the rendered image on the current interface.
本申请实施例提供的图像渲染方法,基于每一顶点的索引数据,对每一顶点的顶点位置信息进行缩放处理,得到缩放结果,并基于每一顶点的缩放结果,从顶点集合中确定出待消除顶点。如此,基于计算得到的顶点位置乘积进行判断,确定顶点位置乘积属于第一类型位置数据和第二类型位置数据中哪一个,从而能够准确的确定出顶点的消除状态,进而准确的分析出顶点集合中的待消除顶点,得到准确的待渲染顶点集合,实现对用户的渲染需求进行准确的响应。The image rendering method provided by the embodiment of the present application performs scaling processing on the vertex position information of each vertex based on the index data of each vertex to obtain a scaling result, and based on the scaling result of each vertex, determines the desired vertex set from the vertex set. Eliminate vertices. In this way, judgment is made based on the calculated vertex position product to determine which of the first type of position data and the second type of position data the vertex position product belongs to, so that the elimination state of the vertex can be accurately determined, and the vertex set can be accurately analyzed. The vertices to be eliminated are obtained to obtain an accurate set of vertices to be rendered, so as to accurately respond to the user's rendering needs.
在一些实施例中,在进行图像渲染时,可以调用一个绘制调用(Drawcall)实现本申请实施例的图像渲染方法。图11是本申请实施例提供的图像渲染方法的再一个可选的流程示意图,如图11所示,方法包括以下步骤S301至步骤S312:In some embodiments, when performing image rendering, a draw call (Drawcall) may be called to implement the image rendering method in the embodiment of the present application. Figure 11 is another optional flow diagram of the image rendering method provided by the embodiment of the present application. As shown in Figure 11, the method includes the following steps S301 to step S312:
步骤S301,终端获取输入的待渲染数据和预设的渲染需求信息,待渲染数据对应一顶点集合。Step S301: The terminal obtains input data to be rendered and preset rendering requirement information. The data to be rendered corresponds to a vertex set.
步骤S302,终端基于待渲染数据和预设的渲染需求信息生成图像渲染请求。Step S302: The terminal generates an image rendering request based on the data to be rendered and preset rendering requirement information.
步骤S303,终端将图像渲染请求发送给服务器。Step S303: The terminal sends the image rendering request to the server.
步骤S304,服务器对渲染需求信息进行解析,得到与顶点集合中的每一顶点对应的索引数据。Step S304: The server parses the rendering requirement information to obtain index data corresponding to each vertex in the vertex set.
步骤S305,服务器对顶点集合中的全部顶点对应的索引数据进行整合,得到索引数据集合。Step S305: The server integrates the index data corresponding to all vertices in the vertex set to obtain an index data set.
这里,索引数据集合中的每一索引数据与一个顶点之间具有映射关系。Here, there is a mapping relationship between each index data in the index data set and a vertex.
步骤S306,服务器从索引数据集合中获取与每一顶点对应的索引数据。Step S306: The server obtains index data corresponding to each vertex from the index data set.
步骤S307,服务器基于索引数据,确定每一顶点对应的顶点处理状态。Step S307: The server determines the vertex processing status corresponding to each vertex based on the index data.
在一种实现方式中,服务器还可以获取每一顶点的顶点位置信息;并基于顶点位置信息,对顶点集合中的顶点进行三角划分,得到至少一个初始三角形;其中,每一初始三角形包括三个顶点。对应地,基于索引数据确定每一顶点对应的顶点处理状态,可以是当任一初始三角形的三个顶点对应的索引数据均为预设类型索引数据时,将初始三角形的三个顶点的顶点处理状态确定为消除状态,也就是说,将初始三角形的三个顶点确定为待消除顶点。在另一种实现方式中,基于索引数据确定每一顶点对应的顶点处理状态,可以是:当索引数据为第一类型索引数据时,将与索引数据具有映射关系的顶点的顶点处理状态确定为消除状态;当索引数据为第二类型索引数据时,将与索引数据具有映射关系的顶点的顶点处理状态确定为非消除状态,其中,第一类型索引数据与第二类型索引数据是用于表征相对的两种顶点处理状态的索引数据。也就是说,当索引数据为第一类型索引数据时,将与索引数据具有映射关系的顶点确定为待消除顶点;当索引数据为第二类型索引数据时,将与索引数据具有映射关系的顶点确定为待渲染顶点。In one implementation, the server can also obtain the vertex position information of each vertex; and based on the vertex position information, triangulate the vertices in the vertex set to obtain at least one initial triangle; wherein each initial triangle includes three vertex. Correspondingly, determining the vertex processing status corresponding to each vertex based on the index data may be that when the index data corresponding to the three vertices of any initial triangle are all preset type index data, the vertex processing of the three vertices of the initial triangle The state is determined to be the elimination state, that is, the three vertices of the initial triangle are determined as the vertices to be eliminated. In another implementation, determining the vertex processing status corresponding to each vertex based on the index data may be: when the index data is the first type of index data, determining the vertex processing status of the vertex that has a mapping relationship with the index data as Elimination state; when the index data is the second type of index data, the vertex processing state of the vertex that has a mapping relationship with the index data is determined to be a non-elimination state, where the first type of index data and the second type of index data are used to represent Index data for the two relative vertex processing states. That is to say, when the index data is the first type of index data, the vertices that have a mapping relationship with the index data are determined as the vertices to be eliminated; when the index data is the second type of index data, the vertices that have a mapping relationship with the index data are determined Identified as the vertex to be rendered.
步骤S308,当任一顶点的顶点处理状态为消除状态时,服务器将该顶点确定为待消除顶点。Step S308: When the vertex processing status of any vertex is the elimination state, the server determines the vertex as the vertex to be eliminated.
步骤S309,服务器删除顶点集合中的待消除顶点,得到待渲染顶点集合。Step S309: The server deletes the vertices to be eliminated in the vertex set to obtain a set of vertices to be rendered.
步骤S310,服务器对待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。 Step S310: The server sequentially performs vertex rendering on the vertices to be rendered in the vertex set to be rendered, and obtains a rendered image.
在一些实施例中,步骤S310可以通过以下方式实现:首先,获取每一待渲染顶点的顶点位置信息;然后,基于顶点位置信息,对待渲染顶点集合中的待渲染顶点进行三角划分,得到至少一个待渲染三角形;最后,以每一待渲染三角形为渲染单位进行顶点渲染,得到渲染后的图像。In some embodiments, step S310 can be implemented in the following manner: first, obtain the vertex position information of each vertex to be rendered; then, based on the vertex position information, triangulate the vertices to be rendered in the vertex set to be rendered to obtain at least one The triangle to be rendered; finally, vertex rendering is performed with each triangle to be rendered as the rendering unit, and the rendered image is obtained.
步骤S311,服务器将渲染后的图像发送给终端。Step S311, the server sends the rendered image to the terminal.
步骤S312,终端在当前界面上显示渲染后的图像。Step S312: The terminal displays the rendered image on the current interface.
本申请实施例提供的图像渲染方法,服务器基于索引数据,确定每一顶点对应的顶点处理状态,当任一顶点的顶点处理状态为消除状态时,服务器将该顶点确定为待消除顶点,从而进行对顶点集合中的部分顶点进行顶点消除,得到待渲染顶点集合;并对待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。如此,由于基于索引数据对顶点集合中的部分顶点进行顶点消除处理,从而能够调用一个绘制调用即可实现间歇顶点渲染,不仅提高图像渲染效率,而且适用于不同的设备,具有高的设备适配性。另外,由于能够准确的确定出待消除顶点,得到准确的待渲染顶点集合,因此实现了对用户的渲染需求进行准确的响应。In the image rendering method provided by the embodiment of the present application, the server determines the vertex processing status corresponding to each vertex based on the index data. When the vertex processing status of any vertex is the elimination status, the server determines the vertex as the vertex to be eliminated, thereby performing Vertex elimination is performed on some vertices in the vertex set to obtain a vertex set to be rendered; and vertex rendering is performed on the vertices to be rendered in the vertex set to be rendered sequentially to obtain a rendered image. In this way, since the vertex elimination process is performed on some vertices in the vertex set based on the index data, intermittent vertex rendering can be implemented with a single draw call, which not only improves the image rendering efficiency, but also is suitable for different devices and has high device adaptability. sex. In addition, since the vertices to be eliminated can be accurately determined and an accurate set of vertices to be rendered is obtained, accurate response to the user's rendering needs is achieved.
下面,以任一游戏应用P1的游戏画面渲染为例,对本申请实施例的图像渲染方法进行说明。Next, taking the game screen rendering of any game application P1 as an example, the image rendering method according to the embodiment of the present application will be described.
当用户作为玩家在终端上运行游戏应用P1开始玩游戏时,对应于用户的每一操作,均显示有特定的游戏画面,在游戏应用P1的服务器渲染每一游戏画面时,由于游戏应用中画面的连续性,前后连续几帧的游戏画面可能差别不大,仅具有局部的差异,因此,在实现的时刻,对于连续的游戏画面可以进行批渲染,并提取出局部的差异,得到每一游戏画面的待渲染顶点进行顶点渲染。在这种情况下,前一游戏画面的渲染数据就可以构成后一游戏画面的待渲染数据,同时基于用户的操作,确定出后一游戏画面不需要渲染的部分,从而得到后一游戏画面的待渲染顶点。也就是说,本申请实施例的方法,能够解决的问题正是对连续相似视频帧的快速准确渲染。为了实现对连续相似视频帧的快速准确渲染,本申请实施例中,首先获取该游戏画面的待渲染数据和对应用户操作的索引数据集合,这里索引数据集合与用户的操作对应,即可以基于用户的操作确定出索引数据集合;该待渲染数据对应一顶点集合;然后基于待渲染数据和索引数据集合中的索引数据,对顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合;最后对待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到游戏画面。When a user runs the game application P1 on the terminal and starts playing the game as a player, a specific game screen is displayed corresponding to each operation of the user. When the server of the game application P1 renders each game screen, due to the screen in the game application The continuity of the game screen in several consecutive frames may not be much different, with only local differences. Therefore, at the moment of implementation, batch rendering can be performed on the continuous game screen, and the local differences can be extracted to obtain each game Vertex rendering is performed on the vertices of the screen to be rendered. In this case, the rendering data of the previous game screen can constitute the data to be rendered for the next game screen. At the same time, based on the user's operation, the parts of the latter game screen that do not need to be rendered are determined, thereby obtaining the data of the latter game screen. The vertices to be rendered. In other words, the problem that the method of the embodiment of the present application can solve is the rapid and accurate rendering of consecutive similar video frames. In order to achieve fast and accurate rendering of consecutive similar video frames, in the embodiment of the present application, the data to be rendered of the game screen and the index data set corresponding to the user's operation are first obtained. Here, the index data set corresponds to the user's operation, that is, it can be based on the user's operation. The operation determines the index data set; the data to be rendered corresponds to a vertex set; then based on the data to be rendered and the index data in the index data set, vertex elimination is performed on some vertices in the vertex set to obtain the vertex set to be rendered; finally Vertex rendering is performed sequentially on the vertices to be rendered in the vertex set to be rendered, and the game screen is obtained.
参见图12A和图12B,其中,图12A呈现的是用户未进行操作之前的原始人脸图像(即原始图像),图12B呈现的是用户进行任一操作后所需要显示的游戏画面(即渲染后的图像),对应于用户的操作,需要显示的游戏画面相比于原始人脸图像,对部分头发121不进行渲染。因此,需要得到能够渲染出不包括部分头发121的待渲染数据。在实现的过程中,可以获取用户在原始人脸图像下的操作指令K1,并基于K1确定出与该操作指令K1对应的渲染需求信息,然后对渲染需求信息进行解析,得到与图12A中的原始人脸图像的待渲染数据对应的顶点集合中的每一顶点的索引数据;其中,基于索引数据能够确定每一顶点对应的顶点处理状态,顶点处理状态包括消除状态和非消除状态。在得到每一顶点的索引数据之后,基于原始人脸图像的待渲染数据和索引数据集合中的索引数据,对原始人脸图像中的部分头发121区域的顶点进行顶点消除处理,得到游戏画面的待渲染顶点集合,然后对待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到未渲染部分头发121区域的游戏画面。Referring to Figures 12A and 12B, Figure 12A presents the original face image (i.e., the original image) before the user performs any operation, and Figure 12B presents the game screen that needs to be displayed after the user performs any operation (i.e., rendering). The resulting image), corresponding to the user's operation, the game screen that needs to be displayed is compared with the original face image, and part of the hair 121 is not rendered. Therefore, it is necessary to obtain data to be rendered that does not include part of the hair 121 . During the implementation process, the user's operation instruction K1 under the original face image can be obtained, and the rendering requirement information corresponding to the operation instruction K1 is determined based on K1, and then the rendering requirement information is analyzed to obtain the same as in Figure 12A The index data of each vertex in the vertex set corresponding to the data to be rendered of the original face image; wherein, based on the index data, the vertex processing state corresponding to each vertex can be determined, and the vertex processing state includes the elimination state and the non-elimination state. After obtaining the index data of each vertex, based on the data to be rendered of the original face image and the index data in the index data set, vertex elimination processing is performed on the vertices of the partial hair 121 area in the original face image to obtain the game screen. A set of vertices to be rendered, and then the vertices to be rendered in the set of vertices to be rendered are sequentially rendered to obtain a game screen of the unrendered hair 121 area.
本申请实施例中,在进行游戏画面渲染时,基于用户的操作指令确定出对应的索引数据集合,该索引数据集合能够表征用户的渲染需求,即基于该索引数据集合中的索引数据能够确定出游戏画面中哪些顶点需要渲染,哪些顶点不需要渲染,从而能够实现对 连续相似视频帧的快速准确渲染。In the embodiment of the present application, when rendering the game screen, the corresponding index data set is determined based on the user's operation instructions. The index data set can represent the user's rendering needs, that is, based on the index data in the index data set, the corresponding index data set can be determined. Which vertices in the game screen need to be rendered and which vertices do not need to be rendered, so as to realize the control Fast and accurate rendering of consecutive similar video frames.
下面,将说明本申请实施例在一个实际的应用场景中的示例性应用。本申请实施例提供一种图像渲染方法,该图像渲染方法是一种适配性更广的GPU渲染调用优化方法。该方法解决了某些场景下,从顶点缓冲区的单个绘制调用实现间歇顶点渲染的需求,即单个绘制调用内不是由顶点1至顶点n按照顺序进行全部渲染,而是单个绘制调用内间歇地对顶点1-10,顶点31-100,顶点221-300…,顶点1000-n进行渲染,在渲染的过程中,中间有一些顶点会略过。Below, an exemplary application of the embodiment of the present application in an actual application scenario will be described. Embodiments of the present application provide an image rendering method, which is a GPU rendering call optimization method with wider adaptability. This method solves the need to implement intermittent vertex rendering from a single draw call of the vertex buffer in some scenarios, that is, not all rendering from vertex 1 to vertex n is performed in sequence within a single draw call, but intermittently within a single draw call. Render vertices 1-10, vertices 31-100, vertices 221-300..., and vertices 1000-n. During the rendering process, some vertices in the middle will be skipped.
本申请实施例中,只需做一些处理来判定中间顶点是否显示,且这些处理对应的算法不需高端GPU硬件的支持,无需使用OpenGL3.1或以上的图像应用编程接口才能支持的glMultiDraw(一种图形绘制调用)的图形绘制接口,只需使用间歇渲染函数(例如,可以是glDrawElements函数)即可实现通过一个绘制调用为顶点缓冲区进行间歇渲染顶点。本申请实施例中,通过在顶点数据添加一个索引值(即上述索引数据),用以索引比例因子数组(即scaleFactors[],比例因子数组中包括多个比例因子),从而控制顶点收缩到[0,0,0],以达到隐藏部分顶点或三角形面,实现间歇渲染顶点的目的。In the embodiment of this application, only some processing is needed to determine whether the intermediate vertices are displayed, and the algorithms corresponding to these processes do not require the support of high-end GPU hardware, and there is no need to use glMultiDraw (a) that can be supported by the OpenGL3.1 or above image application programming interface. Graphics drawing interface), you only need to use the intermittent rendering function (for example, it can be the glDrawElements function) to achieve intermittent rendering of vertices for the vertex buffer through one draw call. In the embodiment of the present application, an index value (i.e., the above-mentioned index data) is added to the vertex data to index the scale factor array (i.e., scaleFactors[], the scale factor array includes multiple scale factors), thereby controlling the vertex shrinkage to [ 0, 0, 0] to hide some vertices or triangular faces and achieve the purpose of intermittently rendering vertices.
本申请实施例中,通过将把顶点收缩到同一位置(比如说[0,0,0]),利用GPU渲染特性(当三角形的三个顶点都在同一位置时,不会渲染任何像素),达到是否渲染顶点(以及三角形)的目的。利用把顶点收缩到同一位置(比如说[0,0,0]),控制是否渲染顶点以及三角形,达到间歇地渲染顶点缓冲的顶点(以及三角形)。In the embodiment of this application, by shrinking the vertices to the same position (for example, [0, 0, 0]) and utilizing the GPU rendering characteristics (when the three vertices of the triangle are all at the same position, no pixels will be rendered), To achieve the purpose of whether to render vertices (and triangles). By shrinking the vertices to the same position (such as [0, 0, 0]), you can control whether to render vertices and triangles to intermittently render the vertices (and triangles) of the vertex buffer.
本申请实施例的方法至少可以应用于以下场景:在衣服系统中,在单个绘图调用中,需要启用/禁用身体某些部分的渲染。如图12A和图12B所示,其中,图12A为原始图像,图12B为禁用身体头发部分渲染的图像,针对于图像中人物的头发,可以禁止对图12B中的部分头发121进行渲染。The method of the embodiment of the present application can be applied to at least the following scenarios: in a clothing system, in a single drawing call, it is necessary to enable/disable the rendering of certain parts of the body. As shown in Figures 12A and 12B, Figure 12A is the original image, and Figure 12B is an image in which the rendering of the hair part of the body is disabled. For the hair of the person in the image, the rendering of part of the hair 121 in Figure 12B can be prohibited.
本申请实施例的方法可以使用任何有GPU,并最少支持OpenGL-ES 2.0标准的设备的硬件环境。本申请实施例在实现顶点消除处理时所使用的顶点消除算法主要涉及以下原理:为每个顶点添加一个顶点索引数据(scaleFactorIdx),该顶点索引数据用于索引比例因子数组(scaleFactors)。在渲染时每个顶点位置(vertices[i].xyz)(对应上述的顶点位置信息)都用这个比例因子数组做缩放,例如,可以通过scaleFactors[vertices[i].scaleFactorIdx]计算做缩放,则缩放结果表示为以下公式(1):
p=vertices[i].xyz*scaleFactors[vertices[i].scaleFactorIdx]  (1)。
The method of the embodiment of the present application can use any hardware environment of a device with a GPU and at least supporting the OpenGL-ES 2.0 standard. The vertex elimination algorithm used in implementing vertex elimination processing in the embodiments of this application mainly involves the following principles: adding a vertex index data (scaleFactorIdx) to each vertex, and the vertex index data is used to index the scale factor array (scaleFactors). During rendering, each vertex position (vertices[i].xyz) (corresponding to the above vertex position information) is scaled using this scale factor array. For example, scaling can be calculated through scaleFactors[vertices[i].scaleFactorIdx], then The scaling result is expressed as the following formula (1):
p=vertices[i].xyz*scaleFactors[vertices[i].scaleFactorIdx] (1).
这里,*表示相乘。经过上述缩放处理后,可以把缩放过的结果(即顶点P缩放后的结果)渲染。因此,如果scaleFactors[vertices[i].scaleFactorIdx]=1,顶点p的位置没有变化(等于vertices[i].xyz),否则scaleFactors[vertices[i].scaleFactorIdx]=0,顶点p的位置变为原点[0,0,0]。Here, * means multiplication. After the above scaling process, the scaled result (that is, the scaled result of vertex P) can be rendered. Therefore, if scaleFactors[vertices[i].scaleFactorIdx]=1, the position of vertex p does not change (equal to vertices[i].xyz), otherwise scaleFactors[vertices[i].scaleFactorIdx]=0, the position of vertex p becomes Origin [0, 0, 0].
本申请实施例中,因为GPU有以下特性:当三角形的三个顶点都在同一位置时,不会渲染任何像素。利用此特性加上以上顶点消除算法,可以产生非常有用的结果。In the embodiment of this application, because the GPU has the following characteristics: when the three vertices of the triangle are all at the same position, no pixels will be rendered. Exploiting this property in conjunction with the vertex elimination algorithm above can produce very useful results.
当三角形的三个顶点的scaleFactors[vertices[i].scaleFactorIdx]为1时,顶点位置不变,因此三角形的形状被正常渲染。When the scaleFactors[vertices[i].scaleFactorIdx] of the three vertices of a triangle is 1, the vertex positions do not change, so the shape of the triangle is rendered normally.
然而,如果三角形三个顶点的scaleFactors[vertices[i].scaleFactorIdx]都为0,三角形的所有顶点都收缩[0,0,0],三角形收缩到单个点[0,0,0]。三角形隐藏不被渲染。However, if the scaleFactors[vertices[i].scaleFactorIdx] of the three vertices of the triangle are all 0, all vertices of the triangle shrink to [0, 0, 0], and the triangle shrinks to a single point [0, 0, 0]. Triangles are hidden and not rendered.
通过顶点的缩放,可以控制三角形是否渲染。所以,整个三角形数组中间的三角形可以随意的选择隐藏,这样便可以达到间歇顶点(三角形)渲染的效果。Through the scaling of the vertices, you can control whether the triangle is rendered. Therefore, the triangles in the middle of the entire triangle array can be hidden at will, so that the effect of intermittent vertex (triangle) rendering can be achieved.
图13是本申请实施例提供的图像渲染方法的流程图,如图13所示,方法包括以下步骤S401至S407:Figure 13 is a flow chart of an image rendering method provided by an embodiment of the present application. As shown in Figure 13, the method includes the following steps S401 to S407:
步骤S401,加载比例因子数组的数值(即scaleFactors[],对应上述实施例中的索引 数据集合)。Step S401, load the value of the scale factor array (i.e. scaleFactors[], corresponding to the index in the above embodiment data collection).
步骤S402,定义i=0。Step S402, define i=0.
步骤S403,基于顶点索引数据(scaleFactorIdx),计算scaleFactor=scaleFactors[vertices[i].scaleFactorIdx]。Step S403: Calculate scaleFactor=scaleFactors[vertices[i].scaleFactorIdx] based on the vertex index data (scaleFactorIdx).
这里,scaleFactor表示第i个顶点(vertices[i])与比例因子索引(scaleFactorIdx)之间的乘积对应的比例因子(对应上述实施例中的索引数据)。Here, scaleFactor represents the scale factor corresponding to the product of the i-th vertex (vertices[i]) and the scale factor index (scaleFactorIdx) (corresponding to the index data in the above embodiment).
步骤S404,在顶点渲染时,每个顶点的位置(即vertices[i].xyz)都用scaleFactors[vertices[i].scaleFactorIdx](即scaleFactor)做缩放,那么,通过以下公式(2)可以计算顶点p缩放过的结果p.xyz:
p.xyz=vertices[verticesIdx].xyz*scaleFactor  (2)。
Step S404, during vertex rendering, the position of each vertex (i.e. vertices[i].xyz) is scaled using scaleFactors[vertices[i].scaleFactorIdx] (i.e. scaleFactor). Then, it can be calculated by the following formula (2) The scaled result of vertex p p.xyz:
p.xyz=vertices[verticesIdx].xyz*scaleFactor (2).
其中,verticesIdx表示顶点索引,用于索引特定的顶点;vertices[verticesIdx].xyz表示顶点索引对应的顶点的位置。Among them, verticesIdx represents the vertex index, which is used to index specific vertices; vertices[verticesIdx].xyz represents the position of the vertex corresponding to the vertex index.
步骤S405,渲染顶点p。Step S405: Render vertex p.
步骤S406,定义i=i+1。Step S406, define i=i+1.
步骤S407,判断i是否小于顶点总数。Step S407, determine whether i is less than the total number of vertices.
如果判断结果为是,则返回继续执行步骤S403;如果判断结果为否,则结束流程,完成顶点渲染,并对渲染结果进行缓存。If the judgment result is yes, then return to step S403 to continue; if the judgment result is no, the process ends, vertex rendering is completed, and the rendering result is cached.
图14是本申请实施例提供的图像渲染方法的另一流程图,如图14所示,方法包括以下步骤S501至S508:Figure 14 is another flow chart of the image rendering method provided by the embodiment of the present application. As shown in Figure 14, the method includes the following steps S501 to S508:
步骤S501,初始化比例因子数组的数值等于1(即,scaleFactors[]=1)。Step S501, initialize the value of the scale factor array to be equal to 1 (that is, scaleFactors[]=1).
步骤S502,定义i=0。Step S502, define i=0.
步骤S503,判断是否要开启顶点i(即第i个顶点)的渲染。Step S503: Determine whether to enable rendering of vertex i (i.e., the i-th vertex).
如果判断结果为是,则执行步骤S504;如果判断结果为否,则执行步骤S505。If the judgment result is yes, step S504 is executed; if the judgment result is no, step S505 is executed.
步骤S504,定义第i个比例因子数组的数值等于0(即scaleFactors[i]=0)。Step S504: Define the value of the i-th scale factor array to be equal to 0 (that is, scaleFactors[i]=0).
步骤S505,判断是否要打开顶点i的渲染。Step S505, determine whether to turn on the rendering of vertex i.
如果判断结果为是,则执行步骤S506;如果判断结果为否,则执行步骤S507。If the judgment result is yes, step S506 is executed; if the judgment result is no, step S507 is executed.
步骤S506,定义第i个比例因子数组的数值等于1(即scaleFactors[i]=1)。Step S506: Define the value of the i-th scale factor array to be equal to 1 (that is, scaleFactors[i]=1).
步骤S507,定义i=i+1。Step S507, define i=i+1.
步骤S508,判断i是否小于比例因子数组中的数值的总数。Step S508, determine whether i is less than the total number of values in the scale factor array.
如果判断结果为是,返回继续执行步骤S503;如果判断结果为否,则结束流程,完成更改顶点是否渲染的流程。If the judgment result is yes, return to continue executing step S503; if the judgment result is no, the process ends and the process of changing whether the vertex is rendered is completed.
图15至图17是本申请实施例的方法分别应用于三种具有不同设备性能的设备(例如低端机、中端机和高端机)的效果示意图,如图15所示,在低端机上,平均每秒传输帧数(FPS,Frames Per Second)为58.9,且在运行过程中,FPS的变化曲线151是比较平稳的。需要说明的是,图15中在00:06时之后的FPS比较稳定,而在00:06时出现较大的低谷值,原因主要是:其他干扰因素的影响,比如游戏刚启动,是需要处理很多其他事情,而这些事情是与本申请实施例的图像渲染过程没有关系的,因此,可以忽略该低谷值。Figures 15 to 17 are schematic diagrams of the effects of applying the method of the embodiment of the present application to three devices with different device performance (such as low-end machines, mid-range machines and high-end machines). As shown in Figure 15, on the low-end machine , the average number of frames transmitted per second (FPS, Frames Per Second) is 58.9, and during operation, the FPS change curve 151 is relatively stable. It should be noted that the FPS after 00:06 in Figure 15 is relatively stable, but there is a large valley value at 00:06. The main reason is: the influence of other interference factors, such as the game has just started, needs to be dealt with There are many other things that are not related to the image rendering process of the embodiment of the present application, so the low value can be ignored.
如图16所示,在中端机上,平均FPS为59.6,且在运行过程中,FPS的变化曲线161也是比较平稳的(忽略00:06时的低谷值)。As shown in Figure 16, on mid-range machines, the average FPS is 59.6, and during operation, the FPS change curve 161 is also relatively stable (ignoring the trough at 00:06).
如图17所示,在高端机上,平均FPS为59.6,且在运行过程中,FPS的变化曲线171也是比较平稳的(忽略00:06时的低谷值)。As shown in Figure 17, on high-end machines, the average FPS is 59.6, and during operation, the FPS change curve 171 is also relatively stable (ignoring the low value at 00:06).
基于以上本申请实施例提供的图像渲染方法,在实现间歇顶点渲染问题中,因为不需拷贝顶点数据,不需高端GPU,所以本申请实施例的方法的适配性更广,且渲染效率 没有因为启用或禁用待渲染图像中的某些部分的渲染而有损失。Based on the image rendering method provided by the above embodiments of the present application, in realizing the problem of intermittent vertex rendering, since there is no need to copy vertex data or a high-end GPU, the method of the embodiments of the present application has wider adaptability and higher rendering efficiency. Nothing is lost by enabling or disabling the rendering of certain parts of the image to be rendered.
可以理解的是,在本申请实施例中,涉及到用户信息的内容,例如,待渲染数据、索引数据集合、渲染后的图像等信息,如果涉及与用户信息或企业信息相关的数据,当本申请实施例运用到具体产品或技术中时,需要获得用户许可或者同意,且相关数据的收集、使用和处理需要遵守相关国家和地区的相关法律法规和标准。It can be understood that in the embodiment of the present application, the content related to user information, such as data to be rendered, index data sets, rendered images and other information, if it involves data related to user information or enterprise information, when this application When application embodiments are applied to specific products or technologies, user permission or consent needs to be obtained, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
下面继续说明本申请实施例提供的图像渲染装置354实施为软件模块的示例性结构,在一些实施例中,如图8所示,图像渲染装置354包括:获取模块3541,配置为获取待渲染数据和用于反映渲染需求信息的索引数据集合;待渲染数据对应一顶点集合;顶点消除模块3542,配置为基于所述待渲染数据和所述索引数据集合中的索引数据,对所述顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合;顶点渲染模块3543,配置为对所述待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。The following continues to describe an exemplary structure in which the image rendering device 354 provided by the embodiment of the present application is implemented as a software module. In some embodiments, as shown in Figure 8 , the image rendering device 354 includes: an acquisition module 3541 configured to acquire data to be rendered. and an index data set used to reflect rendering requirement information; the data to be rendered corresponds to a vertex set; the vertex elimination module 3542 is configured to eliminate the vertex set in the vertex set based on the data to be rendered and the index data in the index data set. Perform vertex elimination processing on some of the vertices to obtain a set of vertices to be rendered; the vertex rendering module 3543 is configured to sequentially perform vertex rendering on the vertices to be rendered in the set of vertices to be rendered to obtain a rendered image.
在一些实施例中,所述索引数据集合中的每一索引数据与顶点集合中的一个顶点之间具有映射关系;所述顶点消除模块还配置为:获取所述顶点集合中的每一顶点的顶点位置信息;从所述索引数据集合中获取与每一顶点对应的索引数据;基于所述索引数据,对每一顶点的顶点位置信息进行缩放处理,对应得到每一顶点的缩放结果;基于每一顶点的缩放结果,从所述顶点集合中确定出待消除顶点;删除所述顶点集合中的待消除顶点,得到所述待渲染顶点集合。In some embodiments, there is a mapping relationship between each index data in the index data set and a vertex in the vertex set; the vertex elimination module is further configured to: obtain the index of each vertex in the vertex set. Vertex position information; obtain index data corresponding to each vertex from the index data set; perform scaling processing on the vertex position information of each vertex based on the index data, and obtain the scaling result of each vertex correspondingly; based on each vertex The scaling result of a vertex determines the vertex to be eliminated from the vertex set; deletes the vertex to be eliminated in the vertex set to obtain the vertex set to be rendered.
在一些实施例中,所述顶点消除模块还配置为:将每一顶点的顶点位置信息与相应顶点对应的索引数据相乘,得到每一顶点的顶点位置乘积;将每一顶点的顶点位置乘积,确定为相应顶点的所述缩放结果。In some embodiments, the vertex elimination module is further configured to: multiply the vertex position information of each vertex with the index data corresponding to the corresponding vertex to obtain the vertex position product of each vertex; multiply the vertex position product of each vertex , determined as the scaling result of the corresponding vertex.
在一些实施例中,所述装置还包括:第一三角划分模块,配置为基于所述顶点位置信息,对所述顶点集合中的顶点进行三角划分,得到至少一个初始三角形;其中,每一所述初始三角形包括三个顶点;所述顶点消除模块还配置为:当任一初始三角形的三个顶点的顶点位置乘积均相同时,将所述初始三角形的三个顶点确定为所述待消除顶点。In some embodiments, the device further includes: a first triangulation module configured to triangulate the vertices in the vertex set based on the vertex position information to obtain at least one initial triangle; wherein each The initial triangle includes three vertices; the vertex elimination module is also configured to: when the products of the vertex positions of the three vertices of any initial triangle are the same, determine the three vertices of the initial triangle as the vertices to be eliminated. .
在一些实施例中,所述顶点消除模块还配置为:当顶点位置乘积为第一类型位置数据时,将所述顶点位置乘积对应的顶点确定为所述待消除顶点;当所述顶点位置乘积为第二类型位置数据时,将所述顶点位置乘积对应的顶点确定为所述待渲染顶点;所述第一类型位置数据与所述第二类型位置数据是用于表征相对的两种消除状态的状态数据。In some embodiments, the vertex elimination module is further configured to: when the vertex position product is the first type of position data, determine the vertex corresponding to the vertex position product as the vertex to be eliminated; when the vertex position product When it is the second type of position data, the vertex corresponding to the vertex position product is determined as the vertex to be rendered; the first type of position data and the second type of position data are used to represent two relative elimination states. status data.
在一些实施例中,所述索引数据集合中的每一索引数据与顶点集合中的一个顶点之间具有映射关系;所述顶点消除模块还配置为:从所述索引数据集合中获取与每一顶点对应的索引数据;基于所述索引数据,确定每一顶点对应的顶点处理状态;当任一顶点的顶点处理状态为消除状态时,将所述顶点确定为待消除顶点;从所述顶点集合中删除所述待消除顶点,得到所述待渲染顶点集合。In some embodiments, there is a mapping relationship between each index data in the index data set and a vertex in the vertex set; the vertex elimination module is further configured to: obtain the data associated with each vertex from the index data set. Index data corresponding to the vertex; based on the index data, determine the vertex processing state corresponding to each vertex; when the vertex processing state of any vertex is the elimination state, determine the vertex as the vertex to be eliminated; from the vertex set Delete the vertices to be eliminated to obtain the set of vertices to be rendered.
在一些实施例中,所述装置还包括:位置信息获取模块,配置为获取每一顶点的顶点位置信息;第二三角划分模块,配置为基于所述顶点位置信息,对所述顶点集合中的顶点进行三角划分,得到至少一个初始三角形;其中,每一所述初始三角形包括三个顶点;所述顶点消除模块还配置为:当任一初始三角形的三个顶点对应的索引数据均为预设类型索引数据时,将所述初始三角形的三个顶点的顶点处理状态确定为消除状态。In some embodiments, the device further includes: a position information acquisition module configured to obtain vertex position information of each vertex; a second triangulation module configured to, based on the vertex position information, obtain the vertex position information in the vertex set. The vertices are triangulated to obtain at least one initial triangle; wherein each initial triangle includes three vertices; the vertex elimination module is also configured to: when the index data corresponding to the three vertices of any initial triangle is preset When type indexing data, the vertex processing status of the three vertices of the initial triangle is determined to be the elimination status.
在一些实施例中,所述顶点消除模块还配置为:当所述索引数据为第一类型索引数据时,将与所述索引数据具有所述映射关系的顶点的顶点处理状态确定为消除状态;当所述索引数据为第二类型索引数据时,将与所述索引数据具有所述映射关系的顶点的顶点处理状态确定为非消除状态;所述第一类型索引数据与所述第二类型索引数据是用于表征相对的两种顶点处理状态的索引数据。In some embodiments, the vertex elimination module is further configured to: when the index data is the first type of index data, determine the vertex processing status of the vertex having the mapping relationship with the index data as the elimination status; When the index data is second type index data, the vertex processing state of the vertex having the mapping relationship with the index data is determined to be a non-elimination state; the first type index data and the second type index Data is index data used to characterize two relative vertex processing states.
在一些实施例中,所述顶点渲染模块还配置为:获取每一待渲染顶点的顶点位置信 息;基于所述顶点位置信息,对所述待渲染顶点集合中的待渲染顶点进行三角划分,得到至少一个待渲染三角形;以每一所述待渲染三角形为渲染单位,对所述待渲染顶点集合中的待渲染顶点进行顶点渲染,得到所述渲染后的图像。In some embodiments, the vertex rendering module is further configured to: obtain the vertex position information of each vertex to be rendered. information; based on the vertex position information, triangulate the vertices to be rendered in the vertex set to be rendered to obtain at least one triangle to be rendered; taking each triangle to be rendered as a rendering unit, triangulate the vertices to be rendered Vertex rendering is performed on the vertices to be rendered in the set to obtain the rendered image.
在一些实施例中,所述装置还包括:请求获取模块,配置为获取图像渲染请求,所述图像渲染请求中包括所述待渲染数据和预设的渲染需求信息;解析模块,配置为对渲染需求信息进行解析,得到与所述顶点集合中的每一顶点对应的索引数据;整合模块,配置为对所述顶点集合中的全部顶点对应的索引数据进行整合,得到所述索引数据集合。In some embodiments, the device further includes: a request acquisition module configured to obtain an image rendering request, the image rendering request including the data to be rendered and preset rendering requirement information; a parsing module configured to perform rendering The demand information is parsed to obtain index data corresponding to each vertex in the vertex set; an integration module is configured to integrate index data corresponding to all vertices in the vertex set to obtain the index data set.
在一些实施例中,所述渲染需求信息中包括针对每一顶点的处理指令;所述解析模块还配置为:对每一顶点的索引数据进行初始化设置,得到初始化索引数据;对所述渲染需求信息进行解析,得到每一顶点的处理指令;当所述处理指令为渲染指令时,将所述顶点的初始化索引数据更新为第二类型索引数据;当所述处理指令为非渲染指令时,将所述顶点的初始化索引数据更新为第一类型索引数据。In some embodiments, the rendering requirement information includes processing instructions for each vertex; the parsing module is also configured to: initialize and set the index data of each vertex to obtain initialization index data; and set the rendering requirement The information is parsed to obtain the processing instruction of each vertex; when the processing instruction is a rendering instruction, the initialization index data of the vertex is updated to the second type index data; when the processing instruction is a non-rendering instruction, the The initialization index data of the vertex is updated to the first type of index data.
需要说明的是,本申请实施例装置的描述,与上述方法实施例的描述是类似的,具有同方法实施例相似的有益效果,因此不做赘述。对于本装置实施例中未披露的技术细节,请参照本申请方法实施例的描述而理解。It should be noted that the description of the device in the embodiment of the present application is similar to the description of the above-mentioned method embodiment, and has similar beneficial effects as the method embodiment, and therefore will not be described again. For technical details not disclosed in the device embodiment, please refer to the description of the method embodiment of this application for understanding.
本申请实施例提供了一种计算机程序产品或计算机程序,该计算机程序产品或计算机程序包括可执行指令,该可执行指令是一种计算机指令;该可执行指令存储在计算机可读存储介质中。当电子设备的处理器从计算机可读存储介质读取该可执行指令,处理器执行该可执行指令时,使得该图像渲染设备执行本申请实施例上述的方法。Embodiments of the present application provide a computer program product or computer program. The computer program product or computer program includes executable instructions. The executable instructions are computer instructions; the executable instructions are stored in a computer-readable storage medium. When the processor of the electronic device reads the executable instruction from the computer-readable storage medium and the processor executes the executable instruction, the image rendering device is caused to perform the method described above in the embodiment of the present application.
本申请实施例提供一种存储有可执行指令的存储介质,其中存储有可执行指令,当可执行指令被处理器执行时,将引起处理器执行本申请实施例提供的方法,例如,如图9示出的方法。Embodiments of the present application provide a storage medium in which executable instructions are stored. When the executable instructions are executed by a processor, they will cause the processor to execute the method provided by embodiments of the present application. For example, as shown in Figure 9 shows the method.
在一些实施例中,存储介质可以是计算机可读存储介质,例如,铁电存储器(FRAM,Ferromagnetic Random Access Memory)、只读存储器(ROM,Read Only Memory)、可编程只读存储器(PROM,Programmable Read Only Memory)、可擦除可编程只读存储器(EPROM,Erasable Programmable Read Only Memory)、带电可擦可编程只读存储器(EEPROM,Electrically Erasable Programmable Read Only Memory)、闪存、磁表面存储器、光盘、或光盘只读存储器(CD-ROM,Compact Disk-Read Only Memory)等存储器;也可以是包括上述存储器之一或任意组合的各种设备。In some embodiments, the storage medium may be a computer-readable storage medium, such as ferroelectric memory (FRAM, Ferromagnetic Random Access Memory), read-only memory (ROM, Read Only Memory), programmable read-only memory (PROM, Programmable Read Only Memory), Erasable Programmable Read Only Memory (EPROM, Erasable Programmable Read Only Memory), Electrically Erasable Programmable Read Only Memory (EEPROM, Electrically Erasable Programmable Read Only Memory), flash memory, magnetic surface memory, optical disk, Or memory such as CD-ROM (Compact Disk-Read Only Memory); it can also be various devices including one of the above memories or any combination thereof.
在一些实施例中,可执行指令可以采用程序、软件、软件模块、脚本或代码的形式,按任意形式的编程语言(包括编译或解释语言,或者声明性或过程性语言)来编写,并且其可按任意形式部署,包括被部署为独立的程序或者被部署为模块、组件、子例程或者适合在计算环境中使用的其它单元。In some embodiments, executable instructions may take the form of a program, software, software module, script, or code, written in any form of programming language, including compiled or interpreted languages, or declarative or procedural languages, and their May be deployed in any form, including deployed as a stand-alone program or deployed as a module, component, subroutine, or other unit suitable for use in a computing environment.
作为示例,可执行指令可以但不一定对应于文件系统中的文件,可以可被存储在保存其它程序或数据的文件的一部分,例如,存储在超文本标记语言(HTML,Hyper Text Markup Language)文档中的一个或多个脚本中,存储在专用于所讨论的程序的单个文件中,或者,存储在多个协同文件(例如,存储一个或多个模块、子程序或代码部分的文件)中。作为示例,可执行指令可被部署为在一个计算设备(可以是作业运行时长确定设备)上执行,或者在位于一个地点的多个计算设备上执行,又或者,在分布在多个地点且通过通信网络互连的多个计算设备上执行。As an example, executable instructions may, but do not necessarily correspond to, files in a file system and may be stored as part of a file holding other programs or data, for example, in a Hyper Text Markup Language (HTML) document. in one or more scripts, in a single file that is specific to the program in question, or in multiple collaborative files (e.g., files that store one or more modules, subroutines, or portions of code). As examples, executable instructions may be deployed for execution on one computing device (which may be a job runtime determination device), or on multiple computing devices located at one location, or distributed across multiple locations and via Execute on multiple computing devices interconnected by a communication network.
以上所述,仅为本申请的实施例而已,并非用于限定本申请的保护范围。凡在本申请的精神和范围之内所作的任何修改、等同替换和改进等,均包含在本申请的保护范围之内。 The above descriptions are only examples of the present application and are not used to limit the protection scope of the present application. Any modifications, equivalent substitutions and improvements made within the spirit and scope of this application are included in the protection scope of this application.

Claims (15)

  1. 一种图像渲染方法,所述方法由电子设备执行,所述方法包括:An image rendering method, the method is executed by an electronic device, the method includes:
    获取待渲染数据和用于反映渲染需求信息的索引数据集合;所述待渲染数据对应一顶点集合;Obtain data to be rendered and an index data set used to reflect rendering requirement information; the data to be rendered corresponds to a vertex set;
    基于所述待渲染数据和所述索引数据集合中的索引数据,对所述顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合;Based on the data to be rendered and the index data in the index data set, perform vertex elimination processing on some of the vertices in the vertex set to obtain a set of vertices to be rendered;
    对所述待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。Vertex rendering is performed on the to-be-rendered vertices in the to-be-rendered vertex set sequentially to obtain a rendered image.
  2. 根据权利要求1所述的方法,其中,所述索引数据集合中的每一索引数据与所述顶点集合中的一个顶点之间具有映射关系;The method according to claim 1, wherein there is a mapping relationship between each index data in the index data set and a vertex in the vertex set;
    所述基于所述待渲染数据和所述索引数据集合中的索引数据,对所述顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合,包括:The step of performing vertex elimination processing on some of the vertices in the vertex set based on the data to be rendered and the index data in the index data set to obtain a set of vertices to be rendered includes:
    获取所述顶点集合中的每一顶点的顶点位置信息;Obtain the vertex position information of each vertex in the vertex set;
    从所述索引数据集合中获取与每一顶点对应的索引数据;Obtain index data corresponding to each vertex from the index data set;
    基于所述索引数据,对每一顶点的顶点位置信息进行缩放处理,对应得到每一顶点的缩放结果;Based on the index data, perform scaling processing on the vertex position information of each vertex, and correspondingly obtain the scaling result of each vertex;
    基于每一顶点的缩放结果,从所述顶点集合中确定待消除顶点;Based on the scaling result of each vertex, determine the vertex to be eliminated from the vertex set;
    从所述顶点集合中删除所述待消除顶点,得到所述待渲染顶点集合。The vertex to be eliminated is deleted from the vertex set to obtain the vertex set to be rendered.
  3. 根据权利要求2所述的方法,其中,所述基于所述索引数据,对每一顶点的顶点位置信息进行缩放处理,对应得到每一顶点的缩放结果,包括:The method according to claim 2, wherein the scaling process is performed on the vertex position information of each vertex based on the index data, and the corresponding scaling result of each vertex is obtained, including:
    将每一顶点的顶点位置信息与相应顶点对应的索引数据相乘,得到每一顶点的顶点位置乘积;Multiply the vertex position information of each vertex with the index data corresponding to the corresponding vertex to obtain the vertex position product of each vertex;
    将每一顶点的顶点位置乘积,确定为相应顶点的所述缩放结果。The product of the vertex position of each vertex is determined as the scaling result of the corresponding vertex.
  4. 根据权利要求3所述的方法,其中,所述方法还包括:The method of claim 3, further comprising:
    基于所述顶点位置信息,对所述顶点集合中的顶点进行三角划分,得到至少一个初始三角形;其中,每一所述初始三角形包括三个顶点;Based on the vertex position information, triangulate the vertices in the vertex set to obtain at least one initial triangle; wherein each of the initial triangles includes three vertices;
    所述基于每一顶点的缩放结果,从所述顶点集合中确定待消除顶点,包括:Determining the vertex to be eliminated from the vertex set based on the scaling result of each vertex includes:
    当任一初始三角形的三个顶点的所述顶点位置乘积均相同时,将所述初始三角形的三个顶点确定为所述待消除顶点。When the vertex position products of the three vertices of any initial triangle are the same, the three vertices of the initial triangle are determined as the vertices to be eliminated.
  5. 根据权利要求3所述的方法,其中,所述基于每一顶点的缩放结果,从所述顶点集合中确定待消除顶点,包括:The method of claim 3, wherein determining the vertices to be eliminated from the vertex set based on the scaling result of each vertex includes:
    当所述顶点位置乘积为第一类型位置数据时,将所述顶点位置乘积对应的顶点确定为所述待消除顶点;When the vertex position product is the first type of position data, determine the vertex corresponding to the vertex position product as the vertex to be eliminated;
    当所述顶点位置乘积为第二类型位置数据时,将所述顶点位置乘积对应的顶点确定为所述待渲染顶点;所述第一类型位置数据与所述第二类型位置数据是用于表征相对的两种消除状态的状态数据。When the vertex position product is the second type of position data, the vertex corresponding to the vertex position product is determined as the vertex to be rendered; the first type of position data and the second type of position data are used to represent Status data of the two relative elimination states.
  6. 根据权利要求1所述的方法,其中,所述索引数据集合中的每一索引数据与所述顶点集合中的一个顶点之间具有映射关系;The method according to claim 1, wherein there is a mapping relationship between each index data in the index data set and a vertex in the vertex set;
    所述基于所述待渲染数据和所述索引数据集合中的索引数据,对所述顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合,包括:The step of performing vertex elimination processing on some of the vertices in the vertex set based on the data to be rendered and the index data in the index data set to obtain a set of vertices to be rendered includes:
    从所述索引数据集合中获取与每一顶点对应的索引数据;Obtain index data corresponding to each vertex from the index data set;
    基于所述索引数据,确定每一顶点对应的顶点处理状态;Based on the index data, determine the vertex processing status corresponding to each vertex;
    当任一顶点的顶点处理状态为消除状态时,将所述顶点确定为待消除顶点;When the vertex processing status of any vertex is the elimination state, the vertex is determined as the vertex to be eliminated;
    从所述顶点集合中删除所述待消除顶点,得到所述待渲染顶点集合。 The vertex to be eliminated is deleted from the vertex set to obtain the vertex set to be rendered.
  7. 根据权利要求6所述的方法,其中,所述方法还包括:The method of claim 6, further comprising:
    获取每一顶点的顶点位置信息;Get the vertex position information of each vertex;
    基于所述顶点位置信息,对所述顶点集合中的顶点进行三角划分,得到至少一个初始三角形;其中,每一所述初始三角形包括三个顶点;Based on the vertex position information, triangulate the vertices in the vertex set to obtain at least one initial triangle; wherein each of the initial triangles includes three vertices;
    所述基于所述索引数据,确定每一顶点对应的顶点处理状态,包括:Determining the vertex processing status corresponding to each vertex based on the index data includes:
    当任一初始三角形的三个顶点对应的索引数据均为预设类型索引数据时,将所述初始三角形的三个顶点的顶点处理状态确定为消除状态。When the index data corresponding to the three vertices of any initial triangle is preset type index data, the vertex processing state of the three vertices of the initial triangle is determined to be the elimination state.
  8. 根据权利要求6所述的方法,其中,所述基于所述索引数据,确定每一顶点对应的顶点处理状态,包括:The method of claim 6, wherein determining the vertex processing status corresponding to each vertex based on the index data includes:
    当所述索引数据为第一类型索引数据时,将与所述索引数据具有所述映射关系的顶点对应的顶点处理状态确定为消除状态;When the index data is the first type of index data, determine the vertex processing state corresponding to the vertex having the mapping relationship with the index data as the elimination state;
    当所述索引数据为第二类型索引数据时,将与所述索引数据具有所述映射关系的顶点对应的顶点处理状态确定为非消除状态;所述第一类型索引数据与所述第二类型索引数据是用于表征相对的两种顶点处理状态的索引数据。When the index data is the second type of index data, the vertex processing state corresponding to the vertex having the mapping relationship with the index data is determined to be a non-elimination state; the first type of index data is different from the second type of index data. Index data is index data used to characterize two relative vertex processing states.
  9. 根据权利要求1至8任一项所述的方法,其中,所述对所述待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像,包括:The method according to any one of claims 1 to 8, wherein said sequentially performing vertex rendering on the to-be-rendered vertices in the to-be-rendered vertex set to obtain a rendered image includes:
    获取每一待渲染顶点的顶点位置信息;Obtain the vertex position information of each vertex to be rendered;
    基于所述顶点位置信息,对所述待渲染顶点集合中的待渲染顶点进行三角划分,得到至少一个待渲染三角形;Based on the vertex position information, triangulate the vertices to be rendered in the set of vertices to be rendered to obtain at least one triangle to be rendered;
    以每一所述待渲染三角形为渲染单位,对所述待渲染顶点集合中的待渲染顶点进行顶点渲染,得到所述渲染后的图像。Using each triangle to be rendered as a rendering unit, perform vertex rendering on the vertices to be rendered in the vertex set to be rendered, to obtain the rendered image.
  10. 根据权利要求1至8任一项所述的方法,其中,所述方法还包括:The method according to any one of claims 1 to 8, wherein the method further includes:
    获取图像渲染请求,所述图像渲染请求中包括所述待渲染数据和预设的渲染需求信息;Obtain an image rendering request, which includes the data to be rendered and preset rendering requirement information;
    对所述渲染需求信息进行解析,得到与所述顶点集合中的每一顶点对应的索引数据;Parse the rendering requirement information to obtain index data corresponding to each vertex in the vertex set;
    对所述顶点集合中的全部顶点对应的索引数据进行整合,得到所述索引数据集合。The index data corresponding to all vertices in the vertex set is integrated to obtain the index data set.
  11. 根据权利要求10所述的方法,其中,所述渲染需求信息中包括针对每一顶点的处理指令;所述对所述渲染需求信息进行解析,得到与所述顶点集合中的每一顶点对应的索引数据,包括:The method according to claim 10, wherein the rendering requirement information includes processing instructions for each vertex; the rendering requirement information is parsed to obtain the rendering requirement information corresponding to each vertex in the vertex set. Index data, including:
    对每一顶点的索引数据进行初始化设置,得到初始化索引数据;Initialize the index data of each vertex to obtain the initialized index data;
    对所述渲染需求信息进行解析,得到每一顶点的处理指令;Analyze the rendering requirement information to obtain processing instructions for each vertex;
    当所述处理指令为渲染指令时,将所述顶点的初始化索引数据更新为第二类型索引数据;When the processing instruction is a rendering instruction, update the initialization index data of the vertex to the second type of index data;
    当所述处理指令为非渲染指令时,将所述顶点的初始化索引数据更新为第一类型索引数据。When the processing instruction is a non-rendering instruction, the initialization index data of the vertex is updated to the first type of index data.
  12. 一种图像渲染装置,所述装置包括:An image rendering device, the device includes:
    获取模块,配置为获取待渲染数据和用于反映渲染需求信息的索引数据集合;所述待渲染数据对应一顶点集合;An acquisition module configured to acquire data to be rendered and an index data set used to reflect rendering requirement information; the data to be rendered corresponds to a vertex set;
    顶点消除模块,配置为基于所述待渲染数据和所述索引数据集合中的索引数据,对所述顶点集合中的部分顶点进行顶点消除处理,得到待渲染顶点集合;A vertex elimination module configured to perform vertex elimination processing on some of the vertices in the vertex set based on the to-be-rendered data and the index data in the index data set to obtain a to-be-rendered vertex set;
    顶点渲染模块,配置为对所述待渲染顶点集合中的待渲染顶点依次进行顶点渲染,得到渲染后的图像。The vertex rendering module is configured to sequentially perform vertex rendering on the vertices to be rendered in the set of vertices to be rendered to obtain a rendered image.
  13. 一种电子设备,包括:An electronic device including:
    存储器,配置为存储可执行指令;处理器,配置为执行所述存储器中存储的可执行 指令时,实现权利要求1至11任一项所述的图像渲染方法。a memory configured to store executable instructions; a processor configured to execute the executable instructions stored in the memory When instructed, the image rendering method described in any one of claims 1 to 11 is implemented.
  14. 一种计算机可读存储介质,存储有可执行指令,配置为引起处理器执行所述可执行指令时,实现权利要求1至11任一项所述的图像渲染方法。A computer-readable storage medium stores executable instructions and is configured to cause a processor to implement the image rendering method according to any one of claims 1 to 11 when the processor executes the executable instructions.
  15. 一种计算机程序产品或计算机程序,所述计算机程序产品或计算机程序包括可执行指令,所述可执行指令存储在计算机可读存储介质中;A computer program product or computer program that includes executable instructions stored in a computer-readable storage medium;
    当电子设备的处理器从所述计算机可读存储介质读取所述可执行指令,并执行所述可执行指令时,实现权利要求1至11任一项所述的图像渲染方法。 When the processor of the electronic device reads the executable instructions from the computer-readable storage medium and executes the executable instructions, the image rendering method according to any one of claims 1 to 11 is implemented.
PCT/CN2023/078405 2022-04-13 2023-02-27 Image rendering method and apparatus, electronic device, computer-readable storage medium, and computer program product WO2023197762A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210384063.6A CN114494024B (en) 2022-04-13 2022-04-13 Image rendering method, device and equipment and storage medium
CN202210384063.6 2022-04-13

Publications (1)

Publication Number Publication Date
WO2023197762A1 true WO2023197762A1 (en) 2023-10-19

Family

ID=81488105

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/078405 WO2023197762A1 (en) 2022-04-13 2023-02-27 Image rendering method and apparatus, electronic device, computer-readable storage medium, and computer program product

Country Status (2)

Country Link
CN (1) CN114494024B (en)
WO (1) WO2023197762A1 (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117576249A (en) * 2024-01-19 2024-02-20 弈芯科技(杭州)有限公司 Chip layout data processing method and device

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114494024B (en) * 2022-04-13 2022-08-02 腾讯科技(深圳)有限公司 Image rendering method, device and equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7292239B1 (en) * 2004-08-06 2007-11-06 Nvidia Corporation Cull before attribute read
US20120069036A1 (en) * 2010-09-18 2012-03-22 Makarand Dharmapurikar Method and mechanism for delivering applications over a wan
CN112419463A (en) * 2020-12-04 2021-02-26 Oppo广东移动通信有限公司 Model data processing method, device and equipment and readable storage medium
CN114266874A (en) * 2021-12-17 2022-04-01 先临三维科技股份有限公司 Three-dimensional data generation method, device, equipment and storage medium
CN114494024A (en) * 2022-04-13 2022-05-13 腾讯科技(深圳)有限公司 Image rendering method, device and equipment and storage medium

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP1255227A1 (en) * 2001-04-27 2002-11-06 STMicroelectronics Limited Vertices index processor
US9418437B2 (en) * 2013-03-15 2016-08-16 Nvidia Corporation Stencil then cover path rendering with shared edges
US9589388B1 (en) * 2013-07-10 2017-03-07 Thinci, Inc. Mechanism for minimal computation and power consumption for rendering synthetic 3D images, containing pixel overdraw and dynamically generated intermediate images
US9495767B2 (en) * 2014-05-15 2016-11-15 Google Inc. Indexed uniform styles for stroke rendering
CN108196835A (en) * 2018-01-29 2018-06-22 东北大学 Pel storage and the method rendered in a kind of game engine
CN109529342B (en) * 2018-11-27 2022-03-04 北京像素软件科技股份有限公司 Data rendering method and device
GB2592604B (en) * 2020-03-03 2023-10-18 Sony Interactive Entertainment Inc Image generation system and method
CN112933599B (en) * 2021-04-08 2022-07-26 腾讯科技(深圳)有限公司 Three-dimensional model rendering method, device, equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7292239B1 (en) * 2004-08-06 2007-11-06 Nvidia Corporation Cull before attribute read
US20120069036A1 (en) * 2010-09-18 2012-03-22 Makarand Dharmapurikar Method and mechanism for delivering applications over a wan
CN112419463A (en) * 2020-12-04 2021-02-26 Oppo广东移动通信有限公司 Model data processing method, device and equipment and readable storage medium
CN114266874A (en) * 2021-12-17 2022-04-01 先临三维科技股份有限公司 Three-dimensional data generation method, device, equipment and storage medium
CN114494024A (en) * 2022-04-13 2022-05-13 腾讯科技(深圳)有限公司 Image rendering method, device and equipment and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117576249A (en) * 2024-01-19 2024-02-20 弈芯科技(杭州)有限公司 Chip layout data processing method and device
CN117576249B (en) * 2024-01-19 2024-04-02 弈芯科技(杭州)有限公司 Chip layout data processing method and device

Also Published As

Publication number Publication date
CN114494024B (en) 2022-08-02
CN114494024A (en) 2022-05-13

Similar Documents

Publication Publication Date Title
US11344806B2 (en) Method for rendering game, and method, apparatus and device for generating game resource file
WO2022116759A1 (en) Image rendering method and apparatus, and computer device and storage medium
WO2023197762A1 (en) Image rendering method and apparatus, electronic device, computer-readable storage medium, and computer program product
CN108010112B (en) Animation processing method, device and storage medium
US9715750B2 (en) System and method for layering using tile-based renderers
US9928637B1 (en) Managing rendering targets for graphics processing units
CN109260708A (en) Map rendering method, device and computer equipment
CN110750664B (en) Picture display method and device
CN108765539B (en) OpenGLES-based image rendering method, device, equipment and storage medium
CN107154063A (en) The shape method to set up and device in image shows region
US11094036B2 (en) Task execution on a graphics processor using indirect argument buffers
CN110555900B (en) Rendering instruction processing method and device, storage medium and electronic equipment
CN109448123B (en) Model control method and device, storage medium and electronic equipment
CN109634611B (en) Mobile terminal three-dimensional model ply file analysis and display method based on OpenGL
US20230343021A1 (en) Visible element determination method and apparatus, storage medium, and electronic device
US8203567B2 (en) Graphics processing method and apparatus implementing window system
EP4270321A1 (en) Graphic rendering method and apparatus, and storage medium
CN113419806B (en) Image processing method, device, computer equipment and storage medium
US10235798B2 (en) System and method for rendering shadows for a virtual environment
EP4231243A1 (en) Data storage management method, object rendering method, and device
CN113888684A (en) Method and apparatus for graphics rendering and computer storage medium
CN114913277A (en) Method, device, equipment and medium for three-dimensional interactive display of object
CN113192173A (en) Image processing method and device for three-dimensional scene and electronic equipment
CN112416489A (en) Engineering drawing display method and related device
US20240033625A1 (en) Rendering method and apparatus for virtual scene, electronic device, computer-readable storage medium, and computer program product

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23787410

Country of ref document: EP

Kind code of ref document: A1