Delay coloring implementation method, system and device and storage medium
By filtering geometric data and reducing the number of buffers in deferred shading on mobile devices, the problem of insufficient memory bandwidth when implementing deferred shading on mobile devices is solved, achieving higher frame rates and better user experience. experience.
Patent Information
- Application Number
- CN202411282787.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2025-01-21
AI Technical Summary
When mobile devices implement delay coloring, due to limited memory bandwidth and excessive buffers, the device's heating, frequency reduction and frame rate drop, affecting the user experience.
By filtering the position of the dividing area according to the screen coordinates of the current fragment, the geometric data is screened, the screened geometric component data is stored in the target buffer position of a buffer, reducing the number of buffers, and in the stage of light processing phase pairs for The geometric component data of the target area is integrated to achieve light coloring of pixels.
With the premise of not affecting the coloring effect, the number of buffers is reduced, the equipment temperature is reduced, the frame rate is improved, and the user experience is improved.
Smart Images

Figure CN119327105A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a delayed shading implementation method, system, device and storage medium. Background Art
[0002] Deferred shading is a rendering pipeline commonly used in desktop games. It can reduce the amount of calculation of fragment shaders and reduce draw calls, greatly increasing the number of dynamic light sources. Deferred shading is divided into two stages: geometry processing stage and lighting processing stage. The geometry data is transmitted between the two stages through a buffer. Due to the wide variety of geometry data, at least two or more 4-channel buffers are required. However, the memory bandwidth of mobile terminals is limited. The more buffers there are, the more memory bandwidth will be occupied, causing the device to heat up and reduce the frequency, which in turn causes a drop in frame rate, affecting the experience. Summary of the invention
[0003] The purpose of the present invention is to solve one of the technical problems existing in the prior art to at least a certain extent.
[0004] To this end, an object of the present invention is to provide an efficient delayed shading implementation method, system, device and storage medium.
[0005] In order to achieve the above technical objectives, one aspect of an embodiment of the present invention provides a delayed shading implementation method, comprising the following steps: according to the position of the screen coordinates of the current fragment in the divided area, the geometric data of the current fragment is screened and processed, and the screened geometric component data is stored in a target buffer position of a buffer; the target buffer position corresponds to the screen coordinates; the divided area is an area formed by dividing the screen area to be colored according to the coordinates; if the geometric data of the entire screen has been stored in the buffer, at least 2 geometric component data are read from the target area of the buffer, the geometric component data are integrated into the total geometric data, and the pixel points of the divided area are illuminated and colored according to the total geometric data; the target area corresponds to the divided area. The embodiment of the present application screens the geometric data carried by the current fragment according to the screen coordinates of the current fragment, and stores the screened geometric component data in a buffer, which is conducive to reducing the number of buffers and improving the bandwidth occupancy of delayed shading on the mobile terminal. The embodiment of the present application realizes the illumination shading of the pixel points by reading and integrating the geometric component data of the target area of the buffer; and reduces the frame rate without affecting the shading effect. Therefore, the embodiment of the present application is conducive to reducing the number of buffers, reducing temperature, increasing frame rate, and improving experience.
[0006] In some embodiments, in the delayed shading implementation method of the embodiment of the present invention, the divided area is determined by the following steps:
[0007] Starting from the coordinate origin of the screen, the screen is divided horizontally by a first pixel length, and the screen is divided vertically by a second pixel length to determine a number of divided areas; wherein the first pixel length and the second pixel length are both in pixels.
[0008] In some embodiments, in one embodiment of the present invention, comprising:
[0009] The first pixel length is determined to be 2 pixels, and the second pixel length is determined to be 2 pixels.
[0010] In some embodiments, in one embodiment of the present invention, filtering the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and storing the filtered geometric component data into a target buffer position of a buffer zone includes the following steps:
[0011] Determine the target division position of the screen coordinates of the current fragment in the division area;
[0012] According to the target division position, based on the screening strategy, the geometric data of the current segment is screened to obtain geometric component data; wherein the screening strategy is the corresponding relationship between the target division position and the screening result;
[0013] The geometric component data is stored in the target buffer location.
[0014] In some embodiments, in one embodiment of the present invention, the target area includes a first buffer position and a second buffer position; the filtering of the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and storing the filtered geometric component data into the target buffer position of a buffer zone includes the following steps:
[0015] If the screen coordinates of the current fragment are at the first division position in the division area, the first gray value data of the current fragment is stored in the first channel of the first buffer position, the first component of the color data of the current fragment is stored in the second channel of the first buffer position, the second component of the color data of the current fragment is stored in the third channel of the first buffer position, and the smoothness data of the current fragment is stored in the fourth channel of the first buffer position;
[0016] Alternatively, if the screen coordinates of the current fragment are at the second division position in the division area, the second grayscale value data of the current fragment is stored in the first channel of the second buffer position, the first component of the normal data of the current fragment is stored in the second channel of the second buffer position, the second component of the normal data of the current fragment is stored in the third channel of the second buffer position, and the metalness data of the current fragment is stored in the fourth channel of the second buffer position.
[0017] In some embodiments, in one embodiment of the present invention, the reading at least two geometric component data from the target area of the buffer and integrating the geometric component data into total geometric data includes:
[0018] Reading first gray value data, a first component of color data, a second component of color data, smoothness data, second gray value data, a first component of normal data, a second component of normal data, and the metalness data from a target area of the buffer;
[0019] Determine the third component of the color data according to the first gray value data, the first component of the color data and the second component of the color data, determine the total geometric data as color, smoothness, normal and metalness, and perform lighting shading on the first pixel point of the divided area according to the total geometric data; wherein the first pixel point corresponds to the first buffer position;
[0020] Alternatively, the third component of the color data is determined based on the second grayscale value data, the first component of the color data and the second component of the color data, and the total geometric data is determined as color, smoothness, normal and metallicity, and the second pixel point of the divided area is illuminated and shaded based on the total geometric data; the second pixel point corresponds to the second buffer position.
[0021] In some embodiments, in one embodiment of the present invention, filtering the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and storing the filtered geometric component data into a target buffer position of a buffer, includes:
[0022] According to the parity of the screen coordinates of the current fragment, the geometric data of the current fragment is filtered and processed, and the filtered geometric component data is stored in a target buffer position of a buffer.
[0023] In some embodiments, in one embodiment of the present invention, the target area includes a first buffer position, a second buffer position, a third buffer position, and a fourth buffer position; the filtering of the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and storing the filtered geometric component data into a target buffer position of a buffer zone includes:
[0024] If the current screen coordinates are all odd numbers, the first gray value data of the current fragment is stored in the first channel of the first buffer position, the first component of the color data of the current fragment is stored in the second channel of the first buffer position, the second component of the color data of the current fragment is stored in the third channel of the first buffer position, and the smoothness data of the current fragment is stored in the fourth channel of the first buffer position;
[0025] Alternatively, if the current screen coordinates are all even numbers, the second gray value data of the current fragment is stored in the first channel of the second buffer position, the first component of the normal data of the current fragment is stored in the second channel of the second buffer position, the second component of the normal data of the current fragment is stored in the third channel of the second buffer position, and the metalness data of the current fragment is stored in the fourth channel of the second buffer position;
[0026] Alternatively, if the current first screen coordinate is an odd number and the second screen coordinate is an even number; the custom data is stored in the third buffer location;
[0027] Alternatively, if the current first screen coordinate is an even number and the second screen coordinate is an odd number, the custom data is stored in the fourth buffer position.
[0028] In some embodiments, in one embodiment of the present invention, the reading at least two geometric component data from the target area of the buffer includes:
[0029] If the geometric component data stored in the current buffer position is color data or smoothness data, determining the target area to be the upper left area starting from the current buffer position;
[0030] Alternatively, if the geometric component data stored in the current buffer position is normal data or metalness data, the target area is determined to be the lower right area starting from the current buffer position.
[0031] On the other hand, an embodiment of the present invention provides a delayed shading implementation system, including:
[0032] The first module is used to filter and process the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and store the filtered geometric component data into a target buffer position of a buffer; wherein the target buffer position corresponds to the screen coordinates; and the divided area is an area formed by dividing the screen area to be colored according to the coordinates;
[0033] The second module is used to read at least two geometric component data from the target area of the buffer if the geometric data of the entire screen has been stored in the buffer, integrate the geometric component data into total geometric data, and illuminate and color the pixel points of the divided area according to the total geometric data; wherein the target area corresponds to the divided area.
[0034] On the other hand, an embodiment of the present invention provides a device for implementing delayed shading, including:
[0035] at least one processor;
[0036] at least one memory for storing at least one program;
[0037] When the at least one program is executed by the at least one processor, the at least one processor implements the above-mentioned delayed shading implementation method.
[0038] On the other hand, an embodiment of the present invention provides a storage medium, in which a program executable by a processor is stored. When the program executable by the processor is executed by the processor, it is used to implement the above-mentioned delayed shading implementation method.
[0039] The embodiment of the present application proposes a delayed shading implementation method, system, device and storage medium, the method comprising: filtering and processing the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and storing the filtered geometric component data in the target buffer position of a buffer; the target buffer position corresponds to the screen coordinates; the divided area is the area formed by dividing the screen area to be colored according to the coordinates; if the geometric data of the entire screen has been stored in the buffer, at least 2 geometric component data are read from the target area of the buffer, the geometric component data are integrated into the total geometric data, and the pixel points of the divided area are illuminated and colored according to the total geometric data; the target area corresponds to the divided area. The embodiment of the present application filters the geometric data carried by the current fragment according to the screen coordinates of the current fragment, and stores the filtered geometric component data in a buffer, which is conducive to reducing the number of buffers and improving the bandwidth occupancy of delayed shading on the mobile terminal. The embodiment of the present application realizes the illumination shading of the pixel points by reading and integrating the geometric component data of the target area of the buffer; and reduces the frame rate without affecting the shading effect. Therefore, the embodiment of the present application is conducive to reducing the number of buffers, reducing temperature, increasing frame rate, and improving experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the embodiments of the present invention or the drawings of related technical solutions in the prior art are introduced below. It should be understood that the drawings introduced below are only for the convenience of clearly describing some embodiments of the technical solutions of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0041] Figure 1 A schematic diagram of an application scenario of an embodiment of the delayed shading implementation method provided by the present invention;
[0042] Figure 2 A schematic diagram of a flow chart of an embodiment of a method for implementing delayed shading provided by the present invention;
[0043] Figure 3 A schematic diagram of the structure of an embodiment of a buffer zone provided in an embodiment of the present application;
[0044] Figure 4 A schematic flow chart of an embodiment of the geometric processing stage is provided for the embodiment of the present application;
[0045] Figure 5 A schematic diagram of a process flow of an embodiment of the illumination processing stage is provided for the embodiment of the present application;
[0046] Figure 6 This is a schematic diagram of an interface of an embodiment of delayed shading processing through an embodiment of the present application;
[0047] Figure 7 A schematic diagram of an interface of an embodiment of conventional deferred shading processing;
[0048] Figure 8 A temperature comparison diagram of an embodiment of delayed coloring processing performed by an embodiment of the present application;
[0049] Fig. 9 A frame rate comparison diagram of an embodiment of delayed shading processing performed by an embodiment of the present application
[0050] Fig.10 A schematic diagram of the structure of an embodiment of a delayed shading implementation system provided by the present invention;
[0051] Fig.11 A schematic diagram of the structure of an embodiment of the delayed shading implementation device provided by the present invention. DETAILED DESCRIPTION
[0052] The embodiments of the present invention are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and are not to be construed as limitations of the present invention. For the step numbers in the following embodiments, they are only provided for the convenience of explanation, and the order between the steps is not limited in any way, and the execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.
[0053] Before describing the embodiments of the present application in detail, necessary explanations are given to the technical terms or characteristic terms that may be involved in the embodiments of the present application:
[0054] Deferred shading: It is a rendering technique in computer graphics that processes the scene's geometric information (position, normal, etc.) and material properties separately. In traditional rendering methods, for each pixel, the lighting effect must be calculated immediately based on the corresponding object material. Deferred shading first stores the rendered scene's geometric information in the geometry buffer (GeometryBuffer, G-Buffer), including position, normal, color, material index, etc. Then, in the subsequent lighting processing stage, the lighting effect of each light source on the pixel is calculated based on the information in the geometry buffer. Deferred shading can effectively handle complex lighting scenes, especially when there are a large number of light sources, reducing unnecessary lighting calculations and improving rendering efficiency.
[0055] Buffer: used to store the geometric information and material properties of each pixel. Commonly stored information includes: Position information: the position coordinates of the object surface in three-dimensional space. Normal information: a vector describing the orientation of the object surface. Color information: the basic color of the object. Material index: used to identify the type of material used by the object. By storing this information in the G-Buffer, the data can be quickly accessed and processed in the subsequent lighting calculation stage, thereby greatly improving rendering efficiency. Especially when dealing with complex lighting scenes and multiple light sources, it is not necessary to re-acquire the geometric and material information for each pixel every time the lighting is calculated.
[0056] Deferred shading is a rendering pipeline commonly used in desktop games. It can reduce the amount of calculation of fragment shaders and reduce draw calls, greatly increasing the number of dynamic light sources. Deferred shading is divided into two stages: geometry processing stage and lighting processing stage. The geometry data is transmitted between the two stages through a buffer, including basic color (3 channels), normal (2 channels), metalness (1 channel), smoothness (1 channel), ambient occlusion (1 channel) and user-defined data, etc. At least two or more 4-channel buffers are required. However, the memory bandwidth of the mobile terminal is limited and is not enough to support the reading and writing of more than two buffers. Continuous high memory bandwidth usage will cause the device to heat up and reduce the frequency, and the frequency reduction will cause the frame rate to drop.
[0057] In this regard, an embodiment of the present application proposes a delayed shading implementation method. In the geometry processing stage, the geometry data of the current fragment is screened according to the position of the screen coordinates of the fragment in the divided area. The screened geometry component data saves the number of buffers and the space occupied, which helps to alleviate the excessive occupation of memory resources by the buffer. Then, in the illumination processing stage, for any pixel on the screen, illumination shading processing is performed through all the geometry component data of the target area corresponding to the pixel, and the total geometry data composed of the geometry component data at similar positions is used to illuminate the pixel without reducing the illumination shading effect. Therefore, the embodiment of the present application can achieve delayed shading, which is beneficial to improve the bandwidth occupancy of delayed shading to reduce temperature and increase frame rate without reducing the illumination shading effect.
[0058] Figure 1 The following is a schematic diagram of an application scenario of a delayed shading implementation method provided by an embodiment of the present invention. In this application scenario, at least one terminal device 201 and a server 202 are included. The object can obtain fragment information through the terminal device, and filter and process the geometric data of the current fragment according to the position of the screen coordinates of the fragment in the divided area. Then, the geometric data is read and processed according to the generated buffer. In this application scenario, the terminal device can be any electronic product that can perform human-computer interaction through one or more methods such as a keyboard, a touch pad, a touch screen, a remote control, voice interaction or a handwriting device. The electronic product can render and color related images or scenes through a web page or an application (APP) such as video processing or playback installed therein. For example, the terminal device can be a personal computer (PC), a mobile phone, a smart phone, a personal digital assistant (PDA), a wearable device, a handheld computer PPC (Pocket PC), a tablet computer, etc. It can be understood that in this application scenario, the server can be an independent server, or a server cluster composed of several servers, or a cloud computing service center; the form of the server is not limited to the form described in the above example. In this application scenario, the delayed shading implementation method proposed in this application can also be implemented based on a server. The server is equipped with a software platform for delayed shading implementation provided by the application embodiment. The server obtains the fragment information generated during the rendering process, and filters the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and stores the filtered geometric component data in a target buffer position of a buffer; then reads at least 2 geometric component data from the target area of the buffer, integrates the geometric component data into total geometric data, and performs illumination and shading on the pixel points of the divided area according to the total geometric data.
[0059] It should be understood that the embodiments of the present invention are only Figure 1 An application scenario that can be implemented and a possible implementation result are exemplified. For example, in an online game scenario, or in cloud computing or remote rendering, the lighting shading process can be executed by the server. That is, the object logs in to the personal account through the device terminal 201. When the terminal screen is rendering, a large amount of fragment information is generated. The server 202 filters and processes the geometric information carried according to the fragment information; then, delayed shading processing is performed according to the filtered buffer, and the shading result is fed back to the terminal device 201 for visual display, so that the object can experience the scene in an immersive way. In other application scenarios of the embodiments of the present invention, such as local film and television special effects production, the delayed shading implementation software platform can also be directly installed on the terminal device 201. After the terminal device 201 disconnects the communication connection with the server 202, delayed shading processing can be performed according to the fragment information cached in the terminal device; after reconnecting to the server 202, the recognition results cached locally by the terminal device 201 are uploaded and updated to the server 202. The embodiments of the present invention do not limit the specific application scenarios. The above-mentioned Figure 1 The application scenarios are only described as examples.
[0060] like Figure 2 As shown, the embodiment of the present invention provides a delayed shading implementation method, which can be applied to the above Figure 1 The method can be implemented by the terminal device 201 or the server 202 in the embodiment, or can be executed on any device or equipment with data processing capability, for example, it can be executed on a smart phone. Figure 2 The method specifically includes but is not limited to steps S100-S200:
[0061] S100: Filter the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and store the filtered geometric component data into a target buffer position of a buffer; wherein the target buffer position corresponds to the screen coordinates; the divided area is the area formed by dividing the screen area to be colored according to the coordinates.
[0062] In the embodiment of the present application, a fragment refers to a basic processing unit after the rasterization stage in the graphics rendering pipeline during the rendering process. Specifically, during the rasterization process, geometric figures are converted into pixel-sized fragments. Each fragment corresponds to a pixel or a portion of a pixel on the screen (for example, in the case of anti-aliasing), and contains information such as the color, depth, and texture coordinates corresponding to each pixel. During conventional processing, the renderer performs various processes on these fragments, such as applying textures, performing lighting calculations, performing depth tests, etc., to finally determine the color and other attributes of each pixel by shading, thereby generating a complete rendered image. In a conventional rendering process, the maximum value of the computational complexity is the number of rendered objects multiplied by the number of light sources, i.e., O (number of objects * number of light sources). This method will generate a large number of repeated calculations, affecting processing efficiency. Unlike the traditional rendering algorithm that submits geometric elements for immediate shading and rasterization, delayed shading only requires submitting a rendering scene once, and storing the attributes of each pixel in the video memory (i.e., G cache) for subsequent rendering processes. In the subsequent rendering process, the screen parallelogram will be rendered, one-to-one corresponding to the attributes of each pixel in the G cache, and each pixel will be shaded independently. Therefore, compared with traditional rendering algorithms, the biggest advantage of deferred shading is that the maximum value of the computational complexity is O (number of objects + number of light sources); it can more effectively handle scenes with a large number of light sources; it alleviates the redundant operations of calculating lighting for invisible geometric bodies in the conventional processing process, which is conducive to saving computing resources and improving rendering efficiency.
[0063] It is understandable that shading is a process for performing illumination calculations and determining pixel colors based on the calculation results; delayed shading requires all geometric data of each pixel to be transmitted through a buffer, which usually requires multiple buffers, increasing the memory usage; when the amount of geometric data to be stored and processed is large, it affects the frame rate and user experience. In this regard, the embodiment of the present application divides the screen according to the coordinates to obtain a number of divided areas, screens the geometric data corresponding to each pixel in the divided area, and stores the screened geometric component data in the corresponding target buffer position in the buffer. The embodiment of the present application can reduce the number of buffers to one by filtering operations, greatly reducing the memory usage and improving the frame rate. It is understandable that the denser the screen area is divided, the more divided areas are obtained for the same screen, the smaller the impact on the accuracy of illumination shading, and the number of buffers is reduced to a certain extent, improving the frame rate (relative to the solution where the geometric data is not screened). On the contrary, the sparser the screen area is divided, the fewer the number of divided areas are obtained for the same screen, the greater the impact on the accuracy of illumination shading, and the number of buffers can be greatly reduced to improve the frame rate. Therefore, technicians in this field need to divide the screen areas into specific problems and set appropriate sizes of divided areas, which will not reduce the accuracy of lighting shading while improving the frame rate to a certain extent.
[0064] The embodiment of the present application filters the geometric data according to the position of the screen coordinates of the current fragment in the divided area. It can be understood that the geometric data includes but is not limited to basic color (3 channels), normal (2 channels), metalness (1 channel), smoothness (1 channel), ambient occlusion (1 channel) and custom data. Those skilled in the art can filter the geometric data of each pixel (i.e., the screen coordinates in the embodiment of the present application) according to actual needs. In some embodiments, during the data processing process, the screen coordinates of the current fragment and the geometric information of the current fragment can be obtained according to the current fragment information. Therefore, according to the position of the current screen coordinates, the current geometric data is filtered. Specifically, after each pixel point in the divided area is filtered, the geometric component data corresponding to each pixel point in the divided area can form a complete set of geometric data, so that the pixels in the area can be subsequently illuminated and colored.
[0065] It is understandable that the data in the buffer can be organized and stored according to the coordinate position of the pixel on the screen. The data is stored in a manner corresponding to the pixel position in the screen space, that is, the target buffer position corresponds to the screen coordinates. This storage method based on screen coordinates helps to quickly access and process the data related to each pixel in the subsequent lighting shading process, thereby improving the lighting shading efficiency and effect. In this regard, the embodiment of the present application reduces the data in the buffer, reduces memory usage, and improves the frame rate through screening processing.
[0066] S200: If the geometric data of the entire screen has been stored in the buffer, read at least two geometric component data from the target area of the buffer, integrate the geometric component data into total geometric data, and illuminate and shade the pixels of the divided area according to the total geometric data; wherein the target area corresponds to the divided area.
[0067] In some possible implementations, deferred shading can be divided into a geometric process (projection and hidden surface removal) and a physical process / illumination process (shading and texture mapping). In the geometric process, the geometric data is screened and stored through the above-mentioned step S100. If the geometric data corresponding to the image that currently needs to be processed by illumination shading are all stored in the buffer, that is, the screening and storage of the geometric data corresponding to all current fragments have been completed, and the illumination processing stage is entered. It should be noted that the geometric data in the embodiment of the present application is the original data in the fragment that can be used for shading during the rendering process; the geometric data is the original geometric data. The total geometric data in the embodiment of the present application is the new geometric data that is reintegrated after screening the original geometric data. After the illumination processing, there is no obvious difference in the corresponding shading effects of the original geometric data and the total geometric data. It can be understood that in the illumination process, the geometric data at each pixel point (screen coordinates) needs to be determined. Specifically, the target buffer position of the buffer corresponding to the current pixel point can be determined, and the target area where the target buffer position is located can be determined; then all the geometric component data of the target area are read, and the total geometric data is determined through all the geometric component data; and the current pixel point is subjected to lighting shading processing based on the total geometric data. It can be understood that when there is a lot of geometric data, the embodiment of the present application integrates the pixel points of the same divided area into one geometric data through the area division of the screen and the screening processing of the geometric data; or, the pixel points of the same divided area share multiple geometric component data, which does not affect the final lighting shading effect. The embodiment of the present application can reduce the number of buffers and alleviate the problem of frequent heating of the equipment through the above-mentioned screening and lighting processing.
[0068] Exemplarily, for virtual reality or augmented reality scenes, the delayed shading method provided by the present application can be used to perform image lighting shading processing. For images / scenes that require lighting shading, the position of the screen coordinates of the current fragment in the divided area is obtained in real time, the geometric data of the current fragment is filtered, and the filtered data is stored in a buffer; in the lighting processing stage, the geometric component data of the target area is integrated, and the pixel points are illuminated and shaded using the integrated total geometric data. The delayed shading method provided by the present application helps to maintain a high frame rate and good lighting effects in complex virtual or augmented environments.
[0069] Optionally, in one embodiment of the present invention, the divided areas are determined by the following steps:
[0070] Starting from the coordinate origin of the screen, the screen is divided horizontally by a first pixel length, and the screen is divided vertically by a second pixel length to determine a plurality of divided areas; wherein the first pixel length and the second pixel length are both in pixels.
[0071] In some possible implementations, the delayed shading method provided in the embodiment of the present application can be used for any form of terminal, and the screen type can be diverse. For different types of screens, those skilled in the art can divide the screen area according to the needs, and the present application is not specifically limited. Similarly, the embodiment of the present application does not limit the specific position of the screen origin. Screen coordinates generally refer to a reference system for determining the position of elements on the screen. Exemplarily, for the game scene of a mobile phone terminal, it is usually a touch screen, and the screen coordinates can be taken as the origin (0, 0) in the upper left corner, horizontally to the right as the positive direction of the X axis, and vertically downward as the positive direction of the Y axis. Of course, for different mobile operating systems (such as Android or iOS) and development frameworks, the way and processing of obtaining screen coordinates may be different. When developing mobile applications, developers can accurately define, obtain and use screen coordinates according to specific platforms and technologies.
[0072] On the other hand, the size of the divided area affects the amount of reduction in memory usage and the final lighting shading effect. To this end, those skilled in the art need to set a suitable size of the divided area. Specifically, according to the marking form of the screen coordinates, the embodiment of the present application sets the divided area as a square area, and divides it with the coordinate origin of the screen as the starting point; the screen is divided horizontally by the first pixel length, and the screen is divided vertically by the second pixel length to determine several square divided areas. It can be understood that the first pixel length and the second pixel length in the embodiment of the present application are both divided in pixels, that is, each divided area may include 2*2, 3*3 or 4*4 pixels. The embodiment of the present application divides the screen into several square divided areas, which is convenient for the subsequent geometric data screening and integration of the pixel points in the divided area, thereby improving the frame rate.
[0073] Optionally, in one embodiment of the present invention, the method further includes:
[0074] The first pixel length is determined to be 2 pixels, and the second pixel length is determined to be 2 pixels.
[0075] In some possible implementations, the embodiment of the present application sets the divided areas to contain 2*2 pixels in each divided area, which can achieve better display effects and lower memory consumption. It is understandable that the size of 2*2 is only an illustrative example and is not a specific limitation of the present application.
[0076] Optionally, in one embodiment of the present invention, according to the position of the screen coordinates of the current fragment in the divided area, the geometric data of the current fragment is filtered and processed, and the filtered geometric component data is stored in a target buffer position of a buffer, including the following steps:
[0077] Determine the target division position of the screen coordinates of the current fragment in the division area;
[0078] According to the target division position, based on the screening strategy, the geometric data of the current segment is screened and processed to obtain geometric component data; wherein the screening strategy is the corresponding relationship between the target division position and the screening result;
[0079] Store the geometry component data into the destination buffer location.
[0080] In some possible implementations, the target division position is used to characterize the specific position of the screen coordinates of the current segment in the divided area. In some embodiments, the target division position can be distinguished by numbering. Specifically, each pixel in the divided area is numbered, and each pixel corresponds to a screen coordinate, that is, each screen coordinate is numbered. The screen coordinates of the current segment are obtained, and the number of the screen coordinates in the divided area is determined, which is the target division position. In other embodiments, the target division position can be recorded in other forms. Exemplarily, for a 2*2 divided area, the target division position can be determined by the parity of the screen coordinates. The present application does not limit the specific form of the target division position.
[0081] The screening strategy in the embodiments of the present application can be embodied in a table form, specifically describing the geometric component data left after screening at each target division position; the screening strategy can also be embodied in a formula form, for the geometric data at different target division positions, different formulas / related parameters in the formula are set, and then the geometric component data is calculated; the screening strategy can also implement the screening of geometric data through an artificial intelligence model. The present application does not limit the specific form of the screening strategy, and those skilled in the art can design a feasible screening strategy according to demand, screen the geometric data of each pixel point to reduce the number of buffers, and thereby improve the frame rate.
[0082] Optionally, in one embodiment of the present invention, the target area includes a first buffer position and a second buffer position; filtering the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and storing the filtered geometric component data into a target buffer position of a buffer zone, comprises the following steps:
[0083] If the screen coordinates of the current fragment are at the first division position in the division area, the first gray value data of the current fragment is stored in the first channel of the first buffer position, the first component of the color data of the current fragment is stored in the second channel of the first buffer position, the second component of the color data of the current fragment is stored in the third channel of the first buffer position, and the smoothness data of the current fragment is stored in the fourth channel of the first buffer position;
[0084] Alternatively, if the screen coordinates of the current fragment are at the second division position in the division area, the second grayscale value data of the current fragment is stored in the first channel of the second buffer position, the first component of the normal data of the current fragment is stored in the second channel of the second buffer position, the second component of the normal data of the current fragment is stored in the third channel of the second buffer position, and the metalness data of the current fragment is stored in the fourth channel of the second buffer position.
[0085] In some possible implementations, for the screening process, the embodiments of the present application can set the type of geometric component data left after the screening process is performed on each target division position. Specifically, the buffer has four channels, and one of the geometric component quantities can be placed in each channel. The corresponding geometric data is also varied, and the above-mentioned screening data for each division position is an illustrative example; those skilled in the art can determine the pre-stored geometric component data for each division position based on the project situation and pipeline design situation. In other embodiments, because the human eye is more sensitive to brightness information, the brightness data is saved at full resolution. That is, in each screening process, the gray value data of the pixel point is retained, or each geometric component data includes a gray value. In some embodiments, the first gray value data or the second gray value data is determined by the color data of the current fragment. It should be noted that, referring to Figure 3 As shown, for a buffer containing four channels of RGBA, the first channel of each target buffer position can be the R channel, the G channel, the B channel or the A channel, and this application does not make specific limitations. The first component of the color data in the embodiment of the present application is the first channel data of the color data; similarly, the first component of the normal data is the first channel data of the normal data. It can be understood that the first division position and the second division position in the embodiment of the present application are the above-mentioned target division positions, and the first buffer position and the second buffer position in the embodiment of the present application are the above-mentioned target buffer positions.
[0086] It is understandable that the divided area in the embodiment of the present application includes several target divided positions, such as, for example, the first divided position and the second divided position. The target area in the embodiment of the present application includes several target buffer positions, such as, for example, the first buffer position, the second buffer position, the third buffer position and the fourth buffer position. It should be noted that the screen coordinates / pixel points of the fragment in the embodiment of the present application correspond to the target divided position and the target buffer position, and the divided area corresponds to the target area.
[0087] It should be noted that the above embodiment only describes the channel data filling scheme of two target buffer positions. In the delayed shading process, the data filled in the channels of other target buffer positions in the target area can be set according to the actual situation to place custom data. The embodiment of the present application filters the geometric data that needs to be stored in the buffer through the set filtering strategy to reduce the number of buffers and alleviate the problem of excessive memory usage.
[0088] Optionally, in one embodiment of the present invention, at least two geometric component data are read from the target area of the buffer, and the geometric component data are integrated into the total geometric data, including:
[0089] Reading first gray value data, a first component of color data, a second component of color data, smoothness data, second gray value data, a first component of normal data, a second component of normal data, and metalness data from a target area of a buffer;
[0090] Determine the third component of the color data according to the first gray value data, the first component of the color data, and the second component of the color data, and determine the total geometric data as color, smoothness, normal, and metalness, and perform lighting shading on the first pixel point of the divided area according to the total geometric data; the first pixel point corresponds to the first buffer position;
[0091] Alternatively, the third component of the color data is determined based on the second grayscale value data, the first component of the color data and the second component of the color data, and the total geometric data is determined as color, smoothness, normal and metallicity, and the second pixel point of the divided area is illuminated and shaded based on the total geometric data; wherein the second pixel point corresponds to the second buffer position.
[0092] In some possible implementations, during the illumination processing, the embodiments of the present application need to determine the geometric data of each pixel point, and based on the geometric data at the target division position (corresponding pixel point) in each division area in the previous geometric processing stage, the corresponding target area exists. During illumination processing, only geometric component data is stored for the target buffer position corresponding to the pixel point. First, corresponding to any pixel point on the screen, it is necessary to determine the target buffer position corresponding to the pixel point, and then determine the target area corresponding to the target buffer position; then, all geometric component data stored in the previous stage are read from the target area, and after integration processing, they are used as the geometric data of the current pixel point.
[0093] In some embodiments, in order to save the amount of stored data, only two components of the color data can be stored, and the third component of the color data can be determined by the gray value data and the two components of the known color. Exemplarily, for the RGB color mode, the gray value can be determined by a variety of algorithms. Specifically, the gray value can be determined by the average method: the three component values of R, G, and B of the color are added and divided by 3, that is, the gray value = (R + G + B) / 3. The gray value can also be determined by the weighted average method: taking into account the different sensitivities of the human eye to different colors, different weights are assigned. Commonly used weights are 0.299, 0.587, and 0.114, gray value = 0.299 * R + 0.587 * G + 0.114 * B. The gray value can also be determined by the maximum value method: the maximum value in the color component is taken as the gray value, that is, gray value = max (R, G, B). The gray value can also be determined by the minimum value method: the minimum value in the color component is taken as the gray value, that is, gray value = min (R, G, B). Those skilled in the art may select any feasible method to determine the grayscale value through the color component data, and similarly, determine the remaining color component data through the grayscale value and part of the color component data.
[0094] It is understandable that, based on the above scheme, each target buffer position stores a grayscale value, therefore, the color data and grayscale value data of the corresponding pixel points are different, and the total geometric data of each pixel point is also different; it is necessary to integrate the total geometric data of each pixel point. It is understandable that, in some embodiments, in the geometry processing stage, the same geometric component data of two different pixels can be stored for the same divided area. In the illumination processing stage, the geometric component data of each pixel point corresponding to the entire target area can be determined by weight calculation or average calculation. The embodiment of the present application determines the total geometric data of each pixel point by integrating the geometric component data, which is convenient for subsequent illumination shading processing.
[0095] Optionally, in one embodiment of the present invention, according to the position of the screen coordinates of the current fragment in the divided area, the geometric data of the current fragment is filtered and processed, and the filtered geometric component data is stored in a target buffer position of a buffer, including:
[0096] According to the parity of the screen coordinates of the current fragment, the geometric data of the current fragment is filtered and processed, and the filtered geometric component data is stored in a target buffer position of a buffer.
[0097] In some possible implementations, for a solution where the size of the divided area is 2*2, the position of the screen coordinates of the current segment in the divided area can be determined by the parity of the screen coordinates. For different parity combinations of the horizontal and vertical coordinates of the screen coordinates, different screening schemes are set to perform screening processing.
[0098] Optionally, in an embodiment of the present invention, the target area includes a first buffer position, a second buffer position, a third buffer position, and a fourth buffer position; filtering the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and storing the filtered geometric component data into a target buffer position of a buffer zone, including:
[0099] If the current screen coordinates are all odd numbers, the first gray value data of the current fragment is stored in the first channel of the first buffer position, the first component of the color data of the current fragment is stored in the second channel of the first buffer position, the second component of the color data of the current fragment is stored in the third channel of the first buffer position, and the smoothness data of the current fragment is stored in the fourth channel of the first buffer position;
[0100] Alternatively, if the current screen coordinates are all even numbers, the second gray value data of the current fragment is stored in the first channel of the second buffer position, the first component of the normal data of the current fragment is stored in the second channel of the second buffer position, the second component of the normal data of the current fragment is stored in the third channel of the second buffer position, and the metalness data of the current fragment is stored in the fourth channel of the second buffer position;
[0101] Alternatively, if the current first screen coordinate is an odd number and the second screen coordinate is an even number; the custom data is stored in the third buffer location;
[0102] Alternatively, if the current first screen coordinate is an even number and the second screen coordinate is an odd number, the custom data is stored in the fourth buffer position.
[0103] In some possible implementations, the first screen coordinate in the embodiment of the present application may be the horizontal coordinate of the screen coordinate or the vertical coordinate of the screen coordinate, and the present application does not make any specific limitation. Similarly, the above-mentioned screening process for the parity of the screen coordinates is an illustrative example, and the present application does not limit the binding relationship between the parity of the screen coordinates and the screened geometric component data.
[0104] Optionally, in one embodiment of the present invention, reading at least two geometric component data from the target area of the buffer includes:
[0105] If the geometric component data stored in the current buffer position is color data or smoothness data, the target area is determined to be the upper left area starting from the current buffer position;
[0106] Alternatively, if the geometric component data stored in the current buffer position is normal data or metalness data, the target area is determined to be the lower right area starting from the current buffer position.
[0107] In some possible implementations, the embodiment of the present application needs to determine the positional relationship between the current buffer position and the target area, or in other words, it is necessary to determine the positional relationship between the division position and the division area, and then determine the corresponding target area according to the current pixel. For the scheme where the size of the division area is 2*2, when determining the division position, the parity of the current fragment is used. Then, in the illumination processing stage, the target buffer position is determined by the current pixel, and then its specific meaning can be determined according to the form of the geometric component data stored in the buffer position, and then the specific position of the current position in the target area is determined to find the target area. In other embodiments, if the coordinates of the current pixel are all odd numbers, the target area is determined to be the upper left area with the current buffer position as the starting point. Or, if the coordinates of the current pixel are all even numbers, the target area is determined to be the lower right area with the current buffer position as the starting point. Or, if the first pixel coordinate of the current pixel is an even number and the second pixel coordinate is an odd number, the target area is determined to be the upper right area with the current buffer position as the starting point. Or, if the first pixel coordinate of the current pixel is an odd number and the second pixel coordinate is an even number, the target area is determined to be the lower left area with the current buffer position as the starting point. The current buffer position corresponds to the current pixel point. It should be noted that the above position correspondence is a process for determining the divided areas in one embodiment. For different divided areas or for different coordinate settings, the position correspondence needs to be changed. The embodiment of the present application correctly finds the corresponding number of geometric components by corresponding the positions of the target area and the target buffer area, thereby improving the accuracy of the total geometric data and the accuracy of the illumination shading.
[0108] The following is a detailed description of the delayed shading implementation method proposed in this application using a specific embodiment:
[0109] Reference Figure 4 The processing flow of the geometry processing stage shown in FIG. 1 includes the following steps:
[0110] Step S41, calculating the gray value according to the current basic color, and storing the gray value in the R channel of the buffer.
[0111] Step S42, obtaining the screen coordinates of the current fragment, when the x and y coordinates are both odd numbers: storing the R component of the color into the G channel of the buffer, storing the B component of the color into the B channel of the buffer, and storing the smoothness into the A channel of the buffer.
[0112] Step S43, obtaining the screen coordinates of the current fragment, when the x and y coordinates are both even numbers: storing the x component of the normal into the G channel, storing the y component of the normal into the B channel, and storing the metalness component into the A channel.
[0113] Step S44, obtaining the screen coordinates of the current fragment, when the x and y coordinates are odd and even numbers respectively: storing the ambient occlusion into the B channel; storing the custom data into the A channel.
[0114] Step S45, obtaining the screen coordinates of the current fragment, when the x and y coordinates are even and odd respectively: storing the custom data into the GBA channel.
[0115] Step S46, if the screening and processing of the geometric information of all fragments are completed, enter the lighting processing stage; otherwise, read the information of the next fragment and return to step S41.
[0116] Reference Figure 5 The processing flow of the illumination processing stage shown in FIG. 1 includes the following steps:
[0117] Step S51, obtaining the screen coordinates of the current fragment and reading the grayscale value from the buffer.
[0118] Step S52, read the R and B components of the color, normal, metalness, smoothness, ambient occlusion and custom data from the buffer according to the parity of the x and y coordinates of the screen coordinates of the current fragment.
[0119] Step S53, calculating the G component according to the gray value and the R and B components of the color.
[0120] Step S54, according to steps S51 to S54, the color, normal, metalness, smoothness, ambient occlusion and custom data of each position of the screen are obtained, and the screen is illuminated and colored.
[0121] The embodiment of the present application utilizes the human eye's sensitivity to brightness information to save brightness data at full resolution, and uses the coordinate parity 1 / 4 resolution to save other data, preserving the picture details as much as possible while saving the buffer to one. In a specific embodiment, based on the game scene, when building the game interface, the scene is built through the delayed shading implementation method provided by the embodiment of the present application. See the interface diagram for details. Figure 6 The result of scene construction based on the conventional delayed shading process is shown in Figure 7 As shown. It can be seen that the two scene interfaces are basically similar and cannot be distinguished by the human eye. Therefore, the embodiment of the present application can achieve delayed coloring without affecting the user experience. At the same time, the temperature effects of the two different delayed coloring schemes on the terminal are compared. Figure 8 As shown; the two solutions are compared to compare the frame rate of the rendering process, the results refer to Fig. 9 After testing, under the condition of 1920*1080 screen and 60 frames per second, the bandwidth can be reduced from 6G / s to 1.5G / s by delaying shading processing through the solution provided in the embodiment of the present application, effectively reducing the bandwidth by 75%.
[0122] In summary, the embodiment of the present application proposes a delayed shading implementation method, including the following steps: according to the position of the screen coordinates of the current fragment in the divided area, the geometric data of the current fragment is screened and processed, and the screened geometric component data is stored in the target buffer position of a buffer; the target buffer position corresponds to the screen coordinates; the divided area is the area formed by dividing the screen area to be colored according to the coordinates; if the geometric data of the entire screen has been stored in the buffer, at least 2 geometric component data are read from the target area of the buffer, the geometric component data are integrated into the total geometric data, and the pixel points of the divided area are illuminated and colored according to the total geometric data; the target area corresponds to the divided area. The embodiment of the present application screens the geometric data carried by the current fragment according to the screen coordinates of the current fragment, and stores the screened geometric component data in a buffer, which is conducive to reducing the number of buffers and improving the bandwidth occupancy of delayed shading on the mobile terminal. The embodiment of the present application realizes the illumination shading of the pixel points by reading and integrating the geometric component data of the target area of the buffer; and reduces the frame rate without affecting the shading effect. Therefore, the embodiment of the present application is conducive to reducing the number of buffers, reducing temperature, increasing frame rate, and improving the experience.
[0123] Secondly, refer to the attached Fig.10 A delayed shading implementation system proposed according to an embodiment of the present invention is described, and the system specifically includes:
[0124] The first module 301 is used to filter the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and store the filtered geometric component data into a target buffer position of a buffer; the target buffer position corresponds to the screen coordinates; the divided area is the area formed by dividing the screen area to be colored according to the coordinates;
[0125] The second module 302 is used to read at least two geometric component data from the target area of the buffer if the geometric data of the entire screen has been stored in the buffer, integrate the geometric component data into total geometric data, and illuminate and color the pixel points of the divided area according to the total geometric data; the target area corresponds to the divided area.
[0126] Optionally, in one embodiment of the present invention, the system also includes a third module for determining divided areas, starting from the coordinate origin of the screen, dividing the screen horizontally with a first pixel length, and dividing the screen vertically with a second pixel length, to determine a number of divided areas; the first pixel length and the second pixel length are both in pixels.
[0127] It can be seen that the contents of the above method embodiments are all applicable to the present system embodiments, the functions specifically implemented by the present system embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0128] Reference Fig.11 , an embodiment of the present invention provides a delayed shading implementation device, comprising:
[0129] at least one processor 410;
[0130] At least one memory 420, used to store at least one program;
[0131] When at least one program is executed by at least one processor 410, the at least one processor 410 implements the deferred shading implementation method.
[0132] Similarly, the contents of the above method embodiments are all applicable to the present device embodiments. The functions specifically implemented by the present device embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0133] An embodiment of the present invention further provides a computer-readable storage medium, in which a program executable by a processor is stored. When the program executable by the processor is executed by the processor, it is used to execute the above-mentioned delayed shading implementation method.
[0134] Similarly, the contents of the above method embodiments are all applicable to the present storage medium embodiments. The functions specifically implemented by the present storage medium embodiments are the same as those of the above method embodiments, and the beneficial effects achieved are also the same as those achieved by the above method embodiments.
[0135] In some selectable embodiments, the function / operation mentioned in the block diagram may not occur in the order mentioned in the operation diagram. For example, depending on the function / operation involved, the two boxes shown in succession can actually be executed substantially simultaneously or the boxes can sometimes be executed in reverse order. In addition, the embodiment presented and described in the flow chart of the present invention is provided by way of example, for the purpose of providing a more comprehensive understanding of technology. The disclosed method is not limited to the operation and logic flow presented herein. Selectable embodiments are expected, wherein the order of various operations is changed and the sub-operation of a part for which is described as a larger operation is performed independently.
[0136] In addition, although the present invention is described in the context of functional modules, it should be understood that, unless otherwise specified, one or more of the functions and / or features can be integrated into a single physical device and / or software module, or one or more functions and / or features can be implemented in a separate physical device or software module. It is also understood that a detailed discussion of the actual implementation of each module is unnecessary for understanding the present invention. More specifically, in view of the properties, functions and internal relationships of the various functional modules in the device disclosed herein, the actual implementation of the module will be understood within the conventional skills of the engineer. Therefore, those skilled in the art can implement the present invention set forth in the claims without excessive experimentation using ordinary techniques. It is also understood that the specific concepts disclosed are merely illustrative and are not intended to limit the scope of the present invention, which is determined by the full scope of the appended claims and their equivalents.
[0137] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several programs to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program codes.
[0138] The logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable programs for implementing the logical functions, and may be embodied in any computer-readable medium for use by a program execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch and execute a program from a program execution system, device or apparatus), or in conjunction with such program execution systems, devices or apparatuses. For purposes of this specification, a "computer-readable medium" may be any device that can contain, store, communicate, propagate or transmit a program for use by a program execution system, device or apparatus, or in conjunction with such program execution systems, devices or apparatuses.
[0139] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0140] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable program execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0141] In the above description of this specification, the description with reference to the terms "one embodiment / example", "another embodiment / example" or "certain embodiments / examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0142] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the claims and their equivalents.
[0143] The above is a specific description of the preferred implementation of the present invention, but the present invention is not limited to the embodiments. Those skilled in the art may make various equivalent modifications or substitutions without violating the spirit of the present invention. These equivalent modifications or substitutions are all included in the scope defined by the claims of the present invention.
Claims
1. A delayed shading implementation method, characterized in that: The following steps are involved: Filtering the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and storing the filtered geometric component data in a target buffer position of a buffer; wherein the target buffer position corresponds to the screen coordinates; and the divided area is an area formed by dividing the screen area to be colored according to the coordinates; If the geometric data of the entire screen has been stored in the buffer, at least two geometric component data are read from the target area of the buffer, the geometric component data are integrated into total geometric data, and the pixel points of the divided area are illuminated and shaded according to the total geometric data; wherein the target area corresponds to the divided area.
2. The delayed shading implementation method according to claim 1, characterized in that: The divided areas are determined by the following steps: Starting from the coordinate origin of the screen, the screen is divided horizontally by a first pixel length, and the screen is divided vertically by a second pixel length to determine a number of divided areas; wherein the first pixel length and the second pixel length are both in pixels.
3. The delayed shading implementation method according to claim 2, characterized in that: The method further comprises: The first pixel length is determined to be 2 pixels, and the second pixel length is determined to be 2 pixels.
4. The delayed shading implementation method according to claim 1, characterized in that: The method of filtering the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area and storing the filtered geometric component data into a target buffer position of a buffer zone includes: Determine the target division position of the screen coordinates of the current fragment in the division area; According to the target division position, based on the screening strategy, the geometric data of the current segment is screened to obtain geometric component data; wherein the screening strategy is the corresponding relationship between the target division position and the screening result; The geometric component data is stored in the target buffer location.
5. The delayed shading implementation method according to claim 1, characterized in that: The target area includes a first buffer position and a second buffer position; the filtering of the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and storing the filtered geometric component data into a target buffer position of a buffer zone, includes: If the screen coordinates of the current fragment are at the first division position in the division area, the first gray value data of the current fragment is stored in the first channel of the first buffer position, the first component of the color data of the current fragment is stored in the second channel of the first buffer position, the second component of the color data of the current fragment is stored in the third channel of the first buffer position, and the smoothness data of the current fragment is stored in the fourth channel of the first buffer position; Alternatively, if the screen coordinates of the current fragment are at the second division position in the division area, the second grayscale value data of the current fragment is stored in the first channel of the second buffer position, the first component of the normal data of the current fragment is stored in the second channel of the second buffer position, the second component of the normal data of the current fragment is stored in the third channel of the second buffer position, and the metalness data of the current fragment is stored in the fourth channel of the second buffer position.
6. The delayed shading implementation method according to claim 5, characterized in that: The step of reading at least two geometric component data from the target area of the buffer and integrating the geometric component data into total geometric data includes: Reading first gray value data, a first component of color data, a second component of color data, smoothness data, second gray value data, a first component of normal data, a second component of normal data, and the metalness data from a target area of the buffer; Determine the third component of the color data according to the first gray value data, the first component of the color data and the second component of the color data, determine the total geometric data as color, smoothness, normal and metalness, and perform lighting shading on the first pixel point of the divided area according to the total geometric data; wherein the first pixel point corresponds to the first buffer position; Alternatively, the third component of the color data is determined based on the second grayscale value data, the first component of the color data and the second component of the color data, and the total geometric data is determined as color, smoothness, normal and metallicity, and the second pixel point of the divided area is illuminated and shaded according to the total geometric data; wherein the second pixel point corresponds to the second buffer position.
7. The delayed shading implementation method according to claim 3, characterized in that: The method of filtering the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area and storing the filtered geometric component data into a target buffer position of a buffer zone includes: According to the parity of the screen coordinates of the current fragment, the geometric data of the current fragment is filtered and processed, and the filtered geometric component data is stored in a target buffer position of a buffer.
8. The delayed shading implementation method according to claim 1, characterized in that: The target area includes a first buffer position, a second buffer position, a third buffer position and a fourth buffer position; the filtering of the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and storing the filtered geometric component data into a target buffer position of a buffer zone, comprises: If the current screen coordinates are all odd numbers, the first gray value data of the current fragment is stored in the first channel of the first buffer position, the first component of the color data of the current fragment is stored in the second channel of the first buffer position, the second component of the color data of the current fragment is stored in the third channel of the first buffer position, and the smoothness data of the current fragment is stored in the fourth channel of the first buffer position; Alternatively, if the current screen coordinates are all even numbers, the second gray value data of the current fragment is stored in the first channel of the second buffer position, the first component of the normal data of the current fragment is stored in the second channel of the second buffer position, the second component of the normal data of the current fragment is stored in the third channel of the second buffer position, and the metalness data of the current fragment is stored in the fourth channel of the second buffer position; Alternatively, if the current first screen coordinate is an odd number and the second screen coordinate is an even number; storing the custom data into the third buffer location; Alternatively, if the current first screen coordinate is an even number and the second screen coordinate is an odd number, the custom data is stored in the fourth buffer position.
9. The delayed shading implementation method according to claim 8, characterized in that: The step of reading at least two geometric component data from a target area of the buffer comprises: If the geometric component data stored in the current buffer position is color data or smoothness data, determining the target area to be the upper left area starting from the current buffer position; Alternatively, if the geometric component data stored in the current buffer position is normal data or metalness data, the target area is determined to be the lower right area starting from the current buffer position.
10. A delayed shading implementation system, characterized in that: include: The first module is used to filter and process the geometric data of the current fragment according to the position of the screen coordinates of the current fragment in the divided area, and store the filtered geometric component data into a target buffer position of a buffer; wherein the target buffer position corresponds to the screen coordinates; and the divided area is an area formed by dividing the screen area to be colored according to the coordinates; The second module is used to read at least two geometric component data from the target area of the buffer if the geometric data of the entire screen has been stored in the buffer, integrate the geometric component data into total geometric data, and illuminate and color the pixel points of the divided area according to the total geometric data; wherein the target area corresponds to the divided area.
11. A delayed shading implementation device, characterized in that: include: at least one processor; at least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor implements the deferred shading implementation method according to any one of claims 1 to 9.
12. A computer-readable storage medium storing a program executable by a processor, characterized in that: The processor-executable program is used to implement the deferred shading implementation method according to any one of claims 1 to 9 when executed by the processor.