Image rendering method and device, storage medium and electronic device
By determining the post-processing data group list and using the renderer plug-in in the game engine, the problem of the Cocos2dx engine's lack of a post-processing system was solved, and efficient rendering and hot updates of the game screen were achieved.
Patent Information
- Application Number
- CN202211116428.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-14
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2042-09-14
AI Technical Summary
Existing game engines such as Cocos2dx lack a post-processing system, making it difficult to meet the demands of game products for improved graphics.
Provided is an image rendering method that implements post-processing functions in a game engine using a renderer plug-in by determining a post-processing data group list, including determining an input frame buffer and an output frame buffer, and generating a corresponding rendered image.
It implements effective post-processing functions in various game engines, supports hot updates, and improves the rendering effect of game graphics.
Smart Images

Figure CN115501588B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image rendering, and in particular to an image rendering method, device, storage medium and electronic equipment. BACKGROUND
[0002] Post-processing is a general term for full-screen image rendering effects, which can greatly improve the visual effect of a product. Post-processing occurs after a camera renders a scene but before the scene is rendered onto a screen.
[0003] At present, most game engines include a post-processing system, but some game engines, such as the Cocos2dx engine, do not. As the demand for picture improvement of game products is becoming higher and higher, it is extremely important for each game engine to implement a post-processing function. SUMMARY
[0004] The present application provides an image rendering method, device, storage medium and electronic equipment, which can implement a post-processing function in a game engine.
[0005] The present application provides an image rendering method, device, storage medium and electronic equipment, which can implement a post-processing function in a game engine.
[0006] In response to a post-processing request for a target virtual camera in a game scene, a post-processing data group list corresponding to the target virtual camera is determined. The post-processing data group list includes at least one post-processing data group. Each post-processing data group includes rendering content of a corresponding post-processing operation, attribute data of the rendering content, and a renderer identifier.
[0007] According to the post-processing data group list, input frame buffers and output frame buffers corresponding to each post-processing operation are determined.
[0008] According to the renderer identifier, a target renderer plug-in used by the corresponding post-processing operation is determined.
[0009] According to the target renderer plug-in, the rendering content, and the input frame buffer, a rendering image corresponding to the corresponding post-processing operation is generated in the output frame buffer.
[0010] The present application provides an image rendering method, device, storage medium and electronic equipment, which can implement a post-processing function in a game engine.
[0011] A first determining module is configured to, in response to a post-processing request for a target virtual camera in a game scene, determine a post-processing data group list corresponding to the target virtual camera. The post-processing data group list includes at least one post-processing data group. Each post-processing data group includes rendering content of a corresponding post-processing operation, attribute data of the rendering content, and a renderer identifier.
[0012] A second determining module is configured to determine an input frame buffer and an output frame buffer corresponding to each of the post-processing operations according to the post-processing data group list;
[0013] A third determining module is used to determine a target renderer plug-in used for a corresponding post-processing operation according to the renderer identifier;
[0014] A generation module is configured to generate a rendered image corresponding to a corresponding post-processing operation in the output frame buffer according to the target renderer plug-in, the rendering content, and the input frame buffer.
[0015] In some implementations, the first determining module is specifically configured to:
[0016] Determining at least one post-processing data group corresponding to the target virtual camera and a priority corresponding to each of the post-processing data groups;
[0017] A post-processing data set list is generated according to the priority and all the post-processing data sets.
[0018] In some implementations, the second determining module is specifically configured to:
[0019] Traversing the attribute data in the post-processing data list;
[0020] During the traversal process, the input frame buffer and the output frame buffer corresponding to the corresponding post-processing operation are determined based on the attribute data obtained in each traversal operation, the traversal order and the stored frame buffer management pool, and the frame buffer management pool includes at least one unoccupied first frame buffer.
[0021] In some implementations, the second determining module is specifically configured to:
[0022] If the current traversal operation is the first traversal, obtain the camera frame buffer corresponding to the target virtual camera as the input frame buffer corresponding to the current post-processing operation, and determine the output frame buffer corresponding to the current post-processing operation based on the attribute data obtained by the current traversal operation and the stored frame buffer management pool;
[0023] If the current traversal operation is an intermediate traversal, the output frame buffer corresponding to the previous post-processing operation is used as the input frame buffer of the current post-processing operation, and the output frame buffer corresponding to the current post-processing operation is determined based on the attribute data obtained from the current traversal operation and the frame buffer management pool;
[0024] If the current traversal operation is the last traversal, the output frame buffer corresponding to the previous post-processing operation is used as the input frame buffer of the current post-processing operation, and the off-screen frame buffer is used as the output frame buffer corresponding to the current post-processing operation.
[0025] In some embodiments, the second determining module is specifically configured to:
[0026] detect whether there is preset attribute data matching the attribute data obtained by the current traversal operation in a stored first dictionary, the first dictionary storing a plurality of preset attribute data and a pointer list corresponding to each of the preset attribute data, each pointer in the pointer list indicating a first frame buffer in the frame buffer management pool;
[0027] if there is, determine a target pointer from the pointer list corresponding to the matching preset attribute data, and take the first frame buffer corresponding to the target pointer as an output frame buffer corresponding to the current post-processing operation;
[0028] if there is not, create a frame buffer according to the attribute data as an output frame buffer corresponding to the current post-processing operation, and update the frame buffer management pool and the first dictionary according to the created frame buffer.
[0029] In some embodiments, the frame buffer management pool further includes at least one occupied second frame buffer, and the second determining module is further configured to:
[0030] in response to a release request for the second frame buffer, release the second frame buffer;
[0031] update a stored second dictionary according to identification information of the released second frame buffer, the second dictionary storing a plurality of preset identification information and a pointer corresponding to the preset identification information, each pointer indicating a second frame buffer in the frame buffer management pool;
[0032] update the first dictionary according to attribute data of the released second frame buffer.
[0033] In some embodiments, the generating module is specifically configured to:
[0034] invoke the target renderer plug-in to draw the rendering content and the stored content in the input frame buffer in the output frame buffer to generate a rendering image corresponding to the corresponding post-processing operation.
[0035] In some embodiments, the image rendering apparatus further includes a setting module configured to:
[0036] in response to a post-processing setting request for a target virtual camera in the game scene, display a post-processing operation setting interface corresponding to the target virtual camera in a graphical user interface, the post-processing operation setting interface providing a plurality of input interfaces, each of the input interfaces corresponding to a post-processing operation;
[0037] generate at least one post-processing data group corresponding to the target virtual camera in response to the user input information in the input interface.
[0038] In some embodiments, the setting module is further configured to:
[0039] run a preset game engine before responding to the post-processing setting request for the target virtual camera in the game scene;
[0040] construct the game scene through the running preset game engine, and display the game scene in a graphical user interface.
[0041] The embodiments of the present application also provide a computer readable storage medium, which stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute any one of the above image rendering methods.
[0042] The embodiments of the present application also provide an electronic device, which comprises a coupled memory and a processor, the memory stores a computer program, and the processor is configured to run the computer program in the memory to execute any one of the above image rendering methods.
[0043] The image rendering method, device, storage medium and electronic device provided by the present application can determine a post-processing data group list corresponding to a target virtual camera in response to a post-processing request for the target virtual camera in a game scene, the post-processing data group list comprises at least one post-processing data group, each post-processing data group comprises rendering content of a corresponding post-processing operation, attribute data of the rendering content, and a renderer identifier, then determine input frame buffers and output frame buffers corresponding to each post-processing operation according to the post-processing data group list, then determine a target renderer plug-in used by the corresponding post-processing operation according to the renderer identifier, and generate a rendering image corresponding to the corresponding post-processing operation in the output frame buffer according to the target renderer plug-in, the rendering content and the input frame buffer, so that the post-processing function can be implemented in various game engines, and since the post-processing function is implemented by using the renderer plug-in, the implementation of the post-processing effect is responsible for the script each time, and thus the hot update of the post-processing function is implemented. BRIEF DESCRIPTION OF DRAWINGS
[0044] The technical solutions and other beneficial effects of the present application will become apparent after a specific embodiment of the present application is described in detail below with reference to the accompanying drawings.
[0045] Figure 1 A flowchart of an image rendering method provided by the embodiments of the present application is shown.
[0046] Figure 2Another flowchart of the image rendering method provided in an embodiment of the present application.
[0047] Figure 3 This is a schematic diagram showing the post-processing operation setting interface corresponding to the target virtual camera provided in an embodiment of the present application.
[0048] Figure 4 A schematic diagram of the framework of the rendering process in the electronic device provided in an embodiment of the present application.
[0049] Figure 5 A schematic diagram of the structure of an image rendering device provided in an embodiment of the present application.
[0050] Figure 6 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0051] Figure 7 Another structural schematic diagram of the electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without making creative efforts are within the scope of protection of this application.
[0053] It should be noted that the terms "first," "second," etc., herein are used to distinguish similar objects and are not necessarily used to describe a specific order or precedence. In addition, the terms "include" and / or "comprise" as used herein specify the presence of stated features, integers, steps, operations, units, and / or components, but do not preclude the presence or addition of one or more other features, integers, steps, operations, units, components, and / or combinations thereof.
[0054] Embodiments of the present application provide an image rendering method, apparatus, storage medium, and electronic device.
[0055] See Figure 1 , Figure 1 : This is a flow chart of an image rendering method provided in an embodiment of the present application. The image rendering method is applied to an electronic device such as a server or a terminal device, in which a game engine such as Cocos2dx can be installed. The specific process may include the following steps S101-S104, wherein:
[0056] S101. In response to a post-processing request for a target virtual camera in a game scene, a list of post-processing data groups corresponding to the target virtual camera is determined, the list of post-processing data groups including at least one post-processing data group, each post-processing data group including rendering content of a corresponding post-processing operation, attribute data of the rendering content, and a renderer identifier.
[0057] The game scene can be a three-dimensional model created by a game engine, and elements in the game scene include a virtual camera. The target virtual camera refers to a virtual camera that needs to be post-processed. The virtual camera is actually a simulation of the law of the human eye looking at an object, such as a small distance and a large distance. In the case of a virtual camera, the objects displayed in the game scene are affected by the position of the virtual camera. The virtual camera is equivalent to the human eye, and when looking at an object through the virtual camera, the shape of the object will be affected by the position and rotation angle of the camera. Generally, multiple virtual cameras can be set in the game scene, each virtual camera is provided with a flag (FLAG), and different virtual cameras are distinguished by the flag. Each object to be displayed also has a camera mask to determine which cameras the object is "seen" by.
[0058] The post-processing operation on the target virtual camera is essentially a further rendering operation on the image drawn by the camera, such as anti-aliasing, depth of field, color grading, motion blur, etc. Each post-processing data group corresponds to a post-processing operation, and the number of post-processing data groups can be determined according to actual needs. For example, when the final post-processing effect needs to be realized through multiple post-processing operations, multiple post-processing data groups can be included in the list of post-processing data groups. When the final post-processing effect can be realized through only one post-processing operation, only one post-processing data group can be included in the list of post-processing data groups.
[0059] The renderer identifier is mainly used to identify the renderer, which can be represented as an ID number. The rendering content mainly includes a frame buffer, each frame buffer corresponds to a frame image, and the frame buffer can include color buffer, depth buffer, and stencil buffer, i.e., color information, depth information, and stencil information, etc. Each post-processing operation can be regarded as a further rendering operation on the rendering image, which can be the drawing image of the camera itself or the rendering image after further rendering of the camera drawing image. The attribute data mainly indicates the category of the frame buffer area to which the frame buffer is written. The attribute data can include frame buffer size, number of color buffers, use of depth stencil, and stencil format, etc. Generally, the frame buffer obtained by the post-processing operation needs to be written to the frame buffer area of the corresponding category.
[0060] In some embodiments, a post-processing component (PostProcessVolume) can be built in the electronic device, and a user can design a post-processing effect on a virtual camera by invoking the post-processing component, i.e., please refer to Figure 2 Before step S101, the image rendering method can further include S1051 and S1052, wherein:
[0061] S1051. In response to a post-processing setting request for a target virtual camera in a game scene, display a post-processing operation setting interface corresponding to the target virtual camera in a graphical user interface, and provide a plurality of input interfaces on the post-processing operation setting interface, each input interface corresponding to a post-processing operation.
[0062] The post-processing operation setting interface can be a display interface providing various post-processing components, each input interface corresponding to a post-processing component, and a user can select a desired post-processing component through the input interface for addition and set a corresponding post-processing effect (post-processing data set). Each input interface can be associated with a parameter setting page, and a user can enter the corresponding parameter setting page through the input interface for parameter setting to obtain corresponding input information.
[0063] For example, please refer to Figure 3 , Figure 3 A post-processing operation setting interface corresponding to a target virtual camera is shown, and the post-processing operation setting interface can provide an input interface for setting an anti-aliasing effect, an input interface for setting an auto-exposure effect, an input interface for setting a motion blur effect, and an input interface for setting a depth-of-field effect, etc. A desired input interface can be selected to enter a corresponding parameter setting page for information input. Different input information of the same input interface can achieve different processing effects of the same type of post-processing operation, and input information in different input interfaces can achieve different types of post-processing operations.
[0064] In some embodiments, before setting a post-processing effect, a game scene needs to be constructed, i.e., before the above step "in response to a post-processing setting request for a target virtual camera in a game scene", the image rendering method further includes:
[0065] running a preset game engine;
[0066] constructing the game scene by running the preset game engine, and displaying the game scene in a graphical user interface.
[0067] The preset game engine can be a Cocos2dx engine, and the building of the game scene mainly refers to drawing and running a three-dimensional model corresponding to the game scene and elements in the three-dimensional model, such as a virtual camera. When the game scene is displayed on the graphical user interface, the user can select a virtual camera as a target virtual camera, and trigger the generation of a post-processing setting request for the target virtual camera through a specified function key on the graphical user interface, such as selecting the specified function key by clicking or other touch methods.
[0068] It should be noted that when building the game scene, each virtual camera is correspondingly provided with a frame buffer (which can be referred to as a camera frame buffer), and the display screen in the electronic device is also correspondingly provided with a frame buffer (which can be referred to as an off-screen frame buffer). These frame buffers are encapsulated in the game engine in advance, and the mapping relationship between the virtual camera and the frame buffer and between the display screen and the frame buffer needs to be set in advance, so that when the rendering operation process is performed subsequently, each virtual camera can write its own drawing image into its own frame buffer based on the mapping relationship, and the final rendering image displayed on the display screen is written into the off-screen frame buffer.
[0069] For example, please refer to Figure 4 , Figure 4 A frame diagram of a rendering process in an electronic device is shown, the electronic device can be built-in with a game engine, a renderer module and a post-processing module, and the game engine can encapsulate frame buffers. When the game engine is running, the screen resolution needs to be set, and one of the frame buffers is selected as an off-screen frame buffer. Then, the game scene is drawn by a main thread, and the game scene and the remaining frame buffers are initialized (cleared). Then, the game scene is run, and a frame buffer (camera frame buffer) corresponding to each virtual camera is set from the remaining frame buffers, and the scene background is initialized. Then, the game scene is rendered by the renderer module to display the game scene in the graphical user interface, wherein the renderer module can call a local renderer or a renderer plug-in to perform the rendering operation. Then, the post-processing module performs post-processing operation in the game scene. Finally, when all the post-processing operations are completed, the final rendering image (game picture) is written into the off-screen frame buffer, and then the rendering image is obtained from the off-screen frame buffer and displayed on the display screen to present to the user.
[0070] S1052. In response to the user input information in the input interface, at least one post-processing data set corresponding to the target virtual camera is generated.
[0071] The post-processing data set for this post-processing operation can be generated based on the user input information obtained from all input interfaces. Since different post-processing data sets usually have different processing sequences, when there are multiple post-processing data sets, they need to be sorted first, that is, the above step of "determining a post-processing data set list corresponding to the target virtual camera" can specifically include:
[0072] determining at least one post-processing data set corresponding to the target virtual camera, and a priority of each post-processing data set;
[0073] generating a post-processing data set list according to the priority and all post-processing data sets.
[0074] The priority of each post-processing data set, that is, the priority of the corresponding post-processing component, is usually set in advance. When the user selects a post-processing component for the target virtual camera and sets the corresponding post-processing data set, the priority of the post-processing component can be bound to the post-processing data set. Then, based on the binding relationship, the post-processing data sets can be sorted in order of priority from high to low to obtain the list.
[0075] S102. According to the post-processing data set list, determine the input frame buffer and the output frame buffer corresponding to each post-processing operation.
[0076] The input frame buffer and the output frame buffer are both one of the encapsulated frame buffers in the game engine, which can be some default set frame buffers, such as camera frame buffers corresponding to virtual cameras, off-screen frame buffers corresponding to display screens, or other frame buffers. Different post-processing operations usually need to use different frame buffers for image rendering of post-processing effects.
[0077] In some embodiments, to avoid setting a dedicated frame buffer for each post-processing operation, thereby causing waste of frame buffers and excessive consumption of memory, the encapsulated frame buffers can be managed by a management pool, so that various post-processing operations can be implemented based on a small number of frame buffers, thereby improving the utilization rate of frame buffers and avoiding excessive consumption of memory.
[0078] For example, please continue to refer to Figure 2 The above step S102 can specifically include:
[0079] S1021. Traverse the attribute data in the post-processing data list;
[0080] S1022. In the traversal process, the input frame buffer and the output frame buffer corresponding to the post-processing operation are determined according to the attribute data obtained in each traversal operation, the traversal order and the stored frame buffer management pool, and the frame buffer management pool includes at least one first frame buffer that is not occupied.
[0081] In the context structure, the source is used to record the input frame buffer, and the destination is used to record the output frame buffer. In addition to the default frame buffers (such as the camera frame buffer and the off-screen frame buffer), other frame buffers encapsulated in the game engine and not occupied can be managed by the frame buffer management pool.
[0082] When there are multiple post-processing operations, a post-processing data group is obtained from the post-processing data list one by one to perform the corresponding post-processing operation, and the list arrangement order of each post-processing data group is the execution order of the corresponding post-processing operation. Since each post-processing operation is a further rendering operation on the rendered image, it is necessary to determine the rendered image that needs to be further rendered, and the rendered image is usually the content stored in the input frame buffer. At the same time, it is necessary to determine which frame buffer (i.e., the output frame buffer) the rendering result needs to be written to after further rendering.
[0083] In some embodiments, the step of "determining the input frame buffer and the output frame buffer corresponding to the post-processing operation according to the attribute data obtained in each traversal operation, the traversal order and the stored frame buffer management pool" specifically includes:
[0084] If the current traversal operation is the first traversal, a preset frame buffer corresponding to the target virtual camera is obtained as the input frame buffer corresponding to the current post-processing operation, and the output frame buffer corresponding to the current post-processing operation is determined according to the attribute data obtained in the current traversal operation and the stored frame buffer management pool.
[0085] If the current traversal operation is the intermediate traversal, the output frame buffer corresponding to the previous post-processing operation is taken as the input frame buffer of the current post-processing operation, and the output frame buffer corresponding to the current post-processing operation is determined according to the attribute data obtained in the current traversal operation and the frame buffer management pool.
[0086] If the current traversal operation is the last traversal, the output frame buffer corresponding to the previous post-processing operation is taken as the input frame buffer of the current post-processing operation, and the off-screen frame buffer is taken as the output frame buffer corresponding to the current post-processing operation.
[0087] The content in the input frame buffer is usually taken as the input content of the corresponding post-processing operation, and the output frame buffer is usually taken as the storage area of the rendering result after the corresponding post-processing operation is completed. Specifically, if the current post-processing operation is the first post-processing operation, the source of the context structure is set as the pointer of the camera frame buffer of the target virtual camera, indicating that the initial input content (source image) is obtained from the camera frame buffer; if the current post-processing operation is the last post-processing operation, the destination of the context structure is set as the pointer of the off-screen frame buffer, indicating that the rendering result needs to be written into the off-screen frame buffer; in other cases, the source is set as the destination, indicating that the input content of the current post-processing operation is the rendering result (i.e., the output of the previous post-processing operation) of the previous post-processing operation, and the destination is set as null, indicating that the rendering result needs to be written into a frame buffer in the frame buffer management pool.
[0088] In some embodiments, the step of "determining the output frame buffer corresponding to the current post-processing operation according to the attribute data obtained by the current traversal operation and the stored frame buffer management pool" can specifically include:
[0089] determining whether there is preset attribute data matching the attribute data obtained by the current traversal operation in a first dictionary, the first dictionary storing a plurality of preset attribute data and a pointer list corresponding to each preset attribute data, each pointer in the pointer list indicating a first frame buffer in the frame buffer management pool;
[0090] if there is, determining a target pointer from the pointer list corresponding to the matching preset attribute data, and taking the first frame buffer corresponding to the target pointer as the output frame buffer corresponding to the current post-processing operation;
[0091] if there is not, creating a frame buffer according to the attribute data as the output frame buffer corresponding to the current post-processing operation, and updating the frame buffer management pool and the first dictionary according to the created frame buffer.
[0092] The management of the unoccupied frame buffer in the frame buffer management pool can be completed by a first dictionary, which is constantly updated and maintained. The first dictionary composed of keys and values can be constructed by taking preset attribute data as the key and taking a pointer list as the value. The preset attribute data can be created in advance according to the situation of all frame buffers encapsulated in the game engine, and each preset attribute data represents a type of frame buffer. Each type can correspond to multiple or one unoccupied frame buffer, and any one of them can be selected as the output frame buffer corresponding to the current post-processing operation. If there is no matching unoccupied frame buffer in the frame buffer management pool, a new frame buffer can be created as the output frame buffer according to the attribute data, and the newly created frame buffer is added to the frame buffer management pool as the first frame buffer, and the newly created frame buffer and the corresponding attribute data are stored in the first dictionary for association, so as to update the frame buffer management pool and the first dictionary.
[0093] In addition, the frame buffer management pool can manage not only the unoccupied frame buffer but also the occupied frame buffer, that is, the frame buffer management pool can also include at least one occupied second frame buffer. At this time, the image rendering method further includes:
[0094] releasing the second frame buffer in response to a release request for the second frame buffer;
[0095] updating a stored second dictionary according to the identification information of the released second frame buffer, the second dictionary storing a plurality of preset identification information and a pointer corresponding to the preset identification information, each pointer indicating a second frame buffer in the frame buffer management pool;
[0096] updating the first dictionary according to the attribute data of the released second frame buffer.
[0097] The release of the second frame buffer can include clearing the content written in the second frame buffer. The identification information can be an ID code, and all frame buffers in the game engine have their own ID code. The second dictionary composed of keys and values can be constructed by taking the identification information as the key and taking the pointer as the value, and the occupied frame buffer in the frame buffer management pool is managed by the second dictionary. Once a second frame buffer in the frame buffer management pool is released, it needs to be removed from the second dictionary and added to the first dictionary.
[0098] S103. Determine the target renderer plug-in used by the corresponding post-processing operation according to the renderer identifier.
[0099] In some embodiments, a local renderer can be installed in the electronic device, and a plurality of renderer plugins, such as a sunshafts effect renderer plugin, a bloom effect renderer plugin, and the like, can also be installed. Each renderer plugin can be provided with a unique renderer identifier, by which a target renderer plugin is determined from the plurality of renderer plugins. The renderer plugin and the game engine have different implementation ends, such as the game engine can be implemented at a C++ end, and the renderer plugin can be implemented at a lua end, that is, the implementation of the render function and the start function of the renderer module in the above Figure 4 start function is mainly used to perform initialization operations before rendering, and the render function is mainly used to perform rendering operations.
[0100] S104. According to the target renderer plugin, the rendering content, and the input frame buffer, a rendering image corresponding to the post-processing operation is generated in the output frame buffer.
[0101] Once all post-processing operations are completed, that is, the rendering image of the current processing operation is written into the off-screen frame buffer, it can be obtained from the off-screen frame buffer and displayed in the graphical user interface. In each execution of the post-processing operation, once the context structure is set, the renderer identifier corresponding renderer plugin can be called to work, which involves accessing the context structure in the game engine (C++ end) and the frame buffer management pool. The called renderer plugin can access the input frame buffer corresponding to the post-processing operation in the game engine (which can be regarded as accessing the frame buffer management pool) by accessing the set context structure, and further access the output frame buffer corresponding to the post-processing operation (which can be regarded as accessing the frame buffer management pool) by accessing the set context structure, and further render the object in the output frame buffer. That is, the above step S104 can specifically include: calling the target renderer plugin to draw the rendering content and the stored content in the input frame buffer in the output frame buffer to generate a rendering image corresponding to the post-processing operation.
[0102] It should be noted that, to realize the access of the renderer plug-in to the context structure and the frame buffer management pool, the context structure and the frame buffer management pool in the C++ end of the game engine need to be bound in the lua end; to realize the calling of the renderer plug-in based on the renderer identifier, the renderer plug-in with the same name as the renderer identifier needs to be set in the lua end. When the render function of the renderer module in the electronic device is executed, the renderer plug-in is called to realize it. When the post-processing rendering operation is performed in this binding mode, the implementation of each post-processing effect is responsible for the script, and the long time is not needed from the production to the presentation to the user, and the hot update is realized.
[0103] It should be noted that, in the execution process of the plurality of post-processing operations, when any post-processing operation is executed, the content in the output frame buffer of the previous post-processing operation is taken as the input content of the current processing operation, and then the output frame buffer can be released and the first dictionary and the second dictionary are updated. Once the content is written in the output frame buffer, that is, the single post-processing operation is completed, it indicates that the output frame buffer is occupied, and the first dictionary and the second dictionary need to be updated.
[0104] In addition, the above steps S101-S104 are only for the post-processing operation of a single target virtual camera, if the virtual cameras that need to be post-processed are multiple, the post-processing operation of each virtual camera can be sequentially executed in sequence. Generally, the execution order is determined according to the game level of the virtual camera, for example, the game level of the virtual camera corresponding to the skybox is lower, and the game level of the virtual camera corresponding to the user interface UI is higher, the virtual cameras can be sorted in order from low to high according to the game level, and the corresponding post-processing operation is sequentially executed according to the sorting order.
[0105] As can be seen from the above, the image rendering method provided by the embodiment, in response to the post-processing request of the target virtual camera in the game scene, determines the post-processing data group list corresponding to the target virtual camera, the post-processing data group list includes at least one post-processing data group, each post-processing data group includes the rendering content of the corresponding post-processing operation, the attribute data of the rendering content, and the renderer identifier; the input frame buffer and the output frame buffer corresponding to each post-processing operation are determined according to the post-processing data group list; the target renderer plug-in used by the corresponding post-processing operation is determined according to the renderer identifier; the rendering image corresponding to the corresponding post-processing operation is generated in the output frame buffer according to the target renderer plug-in, the rendering content and the input frame buffer, so that the post-processing function can be realized in various game engines, and since the post-processing function is realized by the renderer plug-in, the implementation of each post-processing effect is responsible for the script, and the hot update of the post-processing function is realized.
[0106] Based on the method described in the above embodiments, this embodiment will be further described from the perspective of an image rendering device, which can be implemented as an independent entity, and can be applied to a server or a terminal, etc. The terminal can include a mobile phone, a tablet computer, a personal PC, etc. The server can be a server capable of providing image rendering services.
[0107] Please refer to Figure 5 , Figure 5 The image rendering device provided by the embodiments of the present application is specifically described, which can include a first determination module 10, a second determination module 20, a third determination module 30, and a generation module 40, wherein:
[0108] (1) The first determination module 10
[0109] The first determination module 10 is configured to determine a post-processing data group list corresponding to a target virtual camera in a game scene in response to a post-processing request of the target virtual camera, wherein the post-processing data group list includes at least one post-processing data group, and each post-processing data group includes rendering content of a corresponding post-processing operation, attribute data of the rendering content, and a renderer identifier.
[0110] In some embodiments, the first determination module 10 is specifically configured to:
[0111] determine at least one post-processing data group corresponding to the target virtual camera, and a priority corresponding to each post-processing data group;
[0112] generate the post-processing data group list according to the priority and all post-processing data groups.
[0113] In some embodiments, the image rendering device further includes a setting module configured to:
[0114] display a post-processing operation setting interface corresponding to the target virtual camera in a graphical user interface in response to a post-processing setting request of the target virtual camera in the game scene, wherein the post-processing operation setting interface provides a plurality of input interfaces, and each input interface corresponds to one post-processing operation;
[0115] generate at least one post-processing data group corresponding to the target virtual camera in response to user input information in the input interface.
[0116] In some embodiments, the setting module is further configured to:
[0117] run a preset game engine before responding to the post-processing setting request of the target virtual camera in the game scene;
[0118] construct the game scene through the running preset game engine, and display the game scene in the graphical user interface.
[0119] (2) the second determining module 20
[0120] The second determining module 20 is configured to determine, according to the post-processing data list, an input frame buffer and an output frame buffer corresponding to each post-processing operation.
[0121] In some embodiments, the second determining module 20 is specifically configured to:
[0122] traverse the attribute data in the post-processing data list;
[0123] In the process of traversal, the input frame buffer and the output frame buffer corresponding to the current post-processing operation are determined according to the attribute data obtained in each traversal operation, the traversal order, and the stored frame buffer management pool, and the frame buffer management pool includes at least one unoccupied first frame buffer.
[0124] In some embodiments, the second determining module 20 is specifically configured to:
[0125] If the current traversal operation is the first traversal, the camera frame buffer corresponding to the target virtual camera is obtained as the input frame buffer corresponding to the current post-processing operation, and the output frame buffer corresponding to the current post-processing operation is determined according to the attribute data obtained in the current traversal operation and the stored frame buffer management pool;
[0126] If the current traversal operation is the intermediate traversal, the output frame buffer corresponding to the previous post-processing operation is taken as the input frame buffer of the current post-processing operation, and the output frame buffer corresponding to the current post-processing operation is determined according to the attribute data obtained in the current traversal operation and the frame buffer management pool;
[0127] If the current traversal operation is the last traversal, the output frame buffer corresponding to the previous post-processing operation is taken as the input frame buffer of the current post-processing operation, and the off-screen frame buffer is taken as the output frame buffer corresponding to the current post-processing operation.
[0128] In some embodiments, the second determining module 20 is specifically configured to:
[0129] It is detected whether there is preset attribute data matching the attribute data obtained in the current traversal operation in the stored first dictionary, the first dictionary stores a plurality of preset attribute data and a pointer list corresponding to each preset attribute data, and each pointer in the pointer list indicates a first frame buffer in the frame buffer management pool;
[0130] If there is, a target pointer is determined from the pointer list corresponding to the matching preset attribute data, and the first frame buffer corresponding to the target pointer is taken as the output frame buffer corresponding to the current post-processing operation;
[0131] If not, a frame buffer is created according to the attribute data as an output frame buffer corresponding to the current post-processing operation, and the frame buffer management pool and the first dictionary are updated according to the created frame buffer.
[0132] In some embodiments, the frame buffer management pool further includes at least one occupied second frame buffer, and the second determining module 20 is further configured to:
[0133] In response to a release request for the second frame buffer, the second frame buffer is released;
[0134] According to the identification information of the released second frame buffer, the stored second dictionary is updated, the second dictionary storing a plurality of preset identification information and a pointer corresponding to the preset identification information, each pointer indicating a second frame buffer in the frame buffer management pool;
[0135] According to the attribute data of the released second frame buffer, the first dictionary is updated.
[0136] (3) Third determining module 30
[0137] The third determining module 30 is configured to determine a target renderer plug-in used by a corresponding post-processing operation according to a renderer identifier.
[0138] (4) Generation module 40
[0139] The generation module 40 is configured to generate a rendered image corresponding to a corresponding post-processing operation in an output frame buffer according to the target renderer plug-in, the rendering content and the input frame buffer.
[0140] In some embodiments, the generation module 40 is specifically configured to:
[0141] Call the target renderer plug-in to draw the rendering content and the stored content in the input frame buffer in the output frame buffer to generate a rendered image corresponding to a corresponding post-processing operation.
[0142] In specific implementation, each of the above modules can be implemented as an independent entity, or can be combined as the same or several entities, and the specific implementation of each of the above modules can be referred to the method embodiments above, which will not be described here.
[0143] In addition, the embodiments of the present application also provide an electronic device, which can be a smart phone, a tablet computer or the like. As shown in Figure 6 The electronic device 200 includes a processor 201 and a memory 202. The processor 201 is electrically connected to the memory 202.
[0144] The processor 201 is the control center of the electronic device 200. It uses various interfaces and lines to connect various parts of the entire electronic device. By running or loading applications stored in the memory 202 and calling data stored in the memory 202, it executes various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole.
[0145] In this embodiment, the processor 201 in the electronic device 200 will load the instructions corresponding to the processes of one or more applications into the memory 202 according to the following steps, and the processor 201 will run the applications stored in the memory 202 to realize various functions.
[0146] Figure 7 Another structural diagram (specific structural block diagram) of an electronic device provided in an embodiment of the present application is shown, which can be used to implement the image rendering method provided in the above embodiment. The electronic device may include a smartphone or a server.
[0147] The electronic device may include one or more processors 301 of processing cores, one or more computer-readable storage media memories 302, a radio frequency (RF) circuit 303, a power supply 304, an input unit 305, and a display unit 306. Those skilled in the art will appreciate that the electronic device structure shown in the figure does not limit the electronic device and may include more or fewer components than shown, or combine certain components, or arrange the components differently.
[0148] The processor 301 is the control center of the electronic device. The processor utilizes various interfaces and lines to connect the various parts of the entire electronic device. By running or executing software programs and / or modules stored in the memory 302 and calling data stored in the memory 302, the processor performs various functions of the electronic device and processes data, thereby monitoring the electronic device as a whole. Optionally, the processor may include one or more processing cores; preferably, the processor may integrate an application processor and a modem processor, wherein the application processor primarily processes the operating system, user interface, and application programs, and the modem processor primarily processes wireless communications. It is understandable that the modem processor may not be integrated into the processor.
[0149] The memory 302 can be used to store software programs (computer programs) and modules. The processor 301 executes various functional applications and data processing by running the software programs and modules stored in the memory 302. The memory 302 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 302 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other volatile solid-state storage device. Accordingly, the memory 302 may also include a memory controller to provide the processor 301 with access to the memory 302.
[0150] The RF circuit 303 can be used to receive and transmit signals during the information transmission and reception process. In particular, after receiving downlink information from the base station, it is handed over to one or more processors 301 for processing; in addition, uplink data is sent to the base station. Generally, the RF circuit 303 includes but is not limited to an antenna, at least one amplifier, a tuner, one or more oscillators, a subscriber identity module (SIM) card, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF circuit 303 can also communicate with the network and other devices via wireless communication. This wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile Communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0151] The electronic device also includes a power supply 304 (e.g., a battery) for supplying power to various components. Preferably, the power supply 304 can be logically connected to the processor 301 via a power management system, thereby enabling the power management system to manage charging, discharging, and power consumption. The power supply 304 can also include one or more DC or AC power supplies, a recharging system, a power failure detection circuit, a power converter or inverter, a power status indicator, and other arbitrary components.
[0152] The electronic device can further include an input unit 305 that can be used to receive inputted digital or character information, and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function controls. Specifically, in one particular embodiment, the input unit 305 can include a touch-sensitive surface and other input devices. The touch-sensitive surface, also known as a touch display or touchpad, can collect touch operations by a user thereon or proximate thereto (such as operations by a user using a finger, a stylus, or any suitable object or accessory on or proximate to the touch-sensitive surface), and drive corresponding connected devices according to pre-set programs. Optionally, the touch-sensitive surface can include two parts, a touch detection device and a touch controller. The touch detection device detects the touch position of a user and detects signals resulting from touch operations, and transmits the signals to the touch controller. The touch controller receives touch information from the touch detection device, converts it into touch coordinates, and sends it to the processor 301, and can also receive commands from the processor 301 and execute them. In addition, the touch-sensitive surface can be implemented in various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch-sensitive surface, the input unit 305 can also include other input devices. Specifically, the other input devices can include one or more of a physical keyboard, function keys (such as volume control keys, on / off keys, etc.), a trackball, a mouse, a joystick, etc.
[0153] The electronic device can further include a display unit 306 that can be used to display information input by a user or information provided to a user, as well as various graphical user interfaces of the electronic device, which can be composed of graphics, text, icons, video, and any combination thereof. The display unit 306 includes a plurality of hardware display processing units, a video frame processing module, a display screen, etc. The plurality of hardware display processing units and the video frame processing module can be integrated in a processing chip. The display screen can include a display panel, which can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch-sensitive surface can cover the display panel, and when the touch-sensitive surface detects a touch operation thereon or proximate thereto, it transmits to the processor 301 to determine the type of touch event, and then the processor 301 provides corresponding visual output on the display panel according to the type of touch event. Although in the figure, the touch-sensitive surface and the display panel are implemented as two independent components to achieve input and output functions, in some embodiments, the touch-sensitive surface and the display panel can be integrated to achieve input and output functions.
[0154] Although not shown, the electronic device can further include a camera, a Bluetooth module, etc., which will not be described herein. In the present embodiment, the processor 301 in the electronic device loads the executable file corresponding to the process of one or more application programs into the memory 302 according to the following instructions, and runs the application program stored in the memory 302 by the processor 301, thereby realizing various functions, as follows:
[0155] In response to the post-processing request of the target virtual camera in the game scene, a post-processing data group list corresponding to the target virtual camera is determined, the post-processing data group list including at least one post-processing data group, each post-processing data group including rendering content of a corresponding post-processing operation, attribute data of the rendering content, and a renderer identifier;
[0156] According to the post-processing data group list, input frame buffers and output frame buffers corresponding to each post-processing operation are determined;
[0157] According to the renderer identifier, a target renderer plug-in used by the corresponding post-processing operation is determined;
[0158] According to the target renderer plug-in, the rendering content, and the input frame buffer, a rendering image corresponding to the corresponding post-processing operation is generated in the output frame buffer.
[0159] In some embodiments, determining the post-processing data group list corresponding to the target virtual camera includes:
[0160] Determining at least one post-processing data group corresponding to the target virtual camera and a priority corresponding to each post-processing data group;
[0161] According to the priority and all post-processing data groups, the post-processing data group list is generated.
[0162] In some embodiments, according to the post-processing data group list, the input frame buffers and the output frame buffers corresponding to each post-processing operation are determined, including:
[0163] Traversing the attribute data in the post-processing data list;
[0164] In the traversal process, according to the attribute data obtained by each traversal operation, the traversal order, and a stored frame buffer management pool, the input frame buffer and the output frame buffer corresponding to the corresponding post-processing operation are determined, the frame buffer management pool including at least one unoccupied first frame buffer.
[0165] In some embodiments, according to the attribute data obtained by each traversal operation, the traversal order, and the stored frame buffer management pool, the input frame buffer and the output frame buffer corresponding to the corresponding post-processing operation are determined, including:
[0166] If the current traversal operation is the first traversal, a camera frame buffer corresponding to a target virtual camera is obtained as an input frame buffer corresponding to a current post-processing operation, and an output frame buffer corresponding to the current post-processing operation is determined according to attribute data obtained by the current traversal operation and a stored frame buffer management pool;
[0167] If the current traversal operation is the intermediate traversal, an output frame buffer corresponding to a previous post-processing operation is taken as an input frame buffer of the current post-processing operation, and an output frame buffer corresponding to the current post-processing operation is determined according to attribute data obtained by the current traversal operation and the frame buffer management pool;
[0168] If the current traversal operation is the last traversal, an output frame buffer corresponding to a previous post-processing operation is taken as an input frame buffer of the current post-processing operation, and an off-screen frame buffer is taken as an output frame buffer corresponding to the current post-processing operation.
[0169] In some embodiments, the output frame buffer corresponding to the current post-processing operation is determined according to the attribute data obtained by the current traversal operation and the stored frame buffer management pool, including:
[0170] It is detected whether there is preset attribute data matched with the attribute data obtained by the current traversal operation in a stored first dictionary, the first dictionary storing a plurality of preset attribute data and a pointer list corresponding to each preset attribute data, each pointer in the pointer list indicating a first frame buffer in the frame buffer management pool;
[0171] If there is, a target pointer is determined from the pointer list corresponding to the matched preset attribute data, and a first frame buffer corresponding to the target pointer is taken as the output frame buffer corresponding to the current post-processing operation;
[0172] If there is not, a frame buffer is created according to the attribute data as the output frame buffer corresponding to the current post-processing operation, and the frame buffer management pool and the first dictionary are updated according to the created frame buffer.
[0173] In some embodiments, the frame buffer management pool further includes at least one occupied second frame buffer, and the image rendering method further includes:
[0174] In response to a release request for the second frame buffer, the second frame buffer is released;
[0175] According to identification information of the released second frame buffer, a stored second dictionary is updated, the second dictionary storing a plurality of preset identification information and a pointer corresponding to the preset identification information, each pointer indicating a second frame buffer in the frame buffer management pool;
[0176] According to attribute data of the released second frame buffer, the first dictionary is updated.
[0177] In some embodiments, the rendering image corresponding to the post-processing operation is generated in the output frame buffer according to the target renderer plug-in, the rendering content, and the input frame buffer, including:
[0178] The target renderer plug-in is called to draw the rendering content and the stored content in the input frame buffer in the output frame buffer to generate the rendering image corresponding to the post-processing operation.
[0179] In some embodiments, before responding to the post-processing request of the target virtual camera in the game scene, the image rendering method further includes:
[0180] In response to the post-processing setting request of the target virtual camera in the game scene, a post-processing operation setting interface corresponding to the target virtual camera is displayed in the graphical user interface, and a plurality of input interfaces are provided on the post-processing operation setting interface, each input interface corresponding to a post-processing operation.
[0181] In response to user input information in the input interface, at least one post-processing data set corresponding to the target virtual camera is generated.
[0182] In some embodiments, before responding to the post-processing setting request of the target virtual camera in the game scene, the image rendering method further includes:
[0183] A preset game engine is run;
[0184] The game scene is constructed by the running preset game engine, and the game scene is displayed in the graphical user interface.
[0185] The electronic device can implement the steps in any embodiment of the image rendering method provided by the embodiments of the present application, and thus can implement the beneficial effects of any image rendering method provided by the embodiments of the present application. Details are described above, and will not be repeated here.
[0186] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructions (computer programs) or by instructions (computer programs) controlling related hardware, which can be stored in a computer readable storage medium and loaded and executed by a processor.
[0187] To this end, the embodiments of the present application provide a computer readable storage medium, which stores a computer program capable of being loaded by a processor to execute the steps of any embodiment of the image rendering method provided by the embodiments of the present application. For example, the computer program can execute the following steps:
[0188] In response to the post-processing request of the target virtual camera in the game scene, a post-processing data group list corresponding to the target virtual camera is determined, the post-processing data group list including at least one post-processing data group, each post-processing data group including rendering content of a corresponding post-processing operation, attribute data of the rendering content, and a renderer identifier;
[0189] According to the post-processing data group list, input frame buffers and output frame buffers corresponding to each post-processing operation are determined;
[0190] According to the renderer identifier, a target renderer plug-in used by the corresponding post-processing operation is determined;
[0191] According to the target renderer plug-in, the rendering content, and the input frame buffer, a rendered image corresponding to the corresponding post-processing operation is generated in the output frame buffer.
[0192] In some embodiments, determining the post-processing data group list corresponding to the target virtual camera includes:
[0193] At least one post-processing data group corresponding to the target virtual camera and a priority corresponding to each post-processing data group are determined;
[0194] According to the priority and all post-processing data groups, the post-processing data group list is generated.
[0195] In some embodiments, according to the post-processing data group list, the input frame buffers and the output frame buffers corresponding to each post-processing operation are determined, including:
[0196] Attribute data in the post-processing data list is traversed;
[0197] In the traversal process, according to the attribute data obtained by each traversal operation, the traversal order, and a stored frame buffer management pool, the input frame buffer and the output frame buffer corresponding to the corresponding post-processing operation are determined, the frame buffer management pool including at least one unoccupied first frame buffer.
[0198] In some embodiments, according to the attribute data obtained by each traversal operation, the traversal order, and the stored frame buffer management pool, the input frame buffer and the output frame buffer corresponding to the corresponding post-processing operation are determined, including:
[0199] If the current traversal operation is the first traversal, a camera frame buffer corresponding to the target virtual camera is obtained as the input frame buffer corresponding to the current post-processing operation, and according to the attribute data obtained by the current traversal operation and the stored frame buffer management pool, the output frame buffer corresponding to the current post-processing operation is determined;
[0200] If the current traversal operation is the intermediate traversal, the output frame buffer corresponding to the previous post-processing operation is taken as the input frame buffer of the current post-processing operation, and the output frame buffer corresponding to the current post-processing operation is determined according to the attribute data obtained by the current traversal operation and the stored frame buffer management pool.
[0201] If the current traversal operation is the last traversal, the output frame buffer corresponding to the previous post-processing operation is taken as the input frame buffer of the current post-processing operation, and the off-screen frame buffer is taken as the output frame buffer corresponding to the current post-processing operation.
[0202] In some embodiments, the output frame buffer corresponding to the current post-processing operation is determined according to the attribute data obtained by the current traversal operation and the stored frame buffer management pool, comprising:
[0203] It is detected whether there is preset attribute data matched with the attribute data obtained by the current traversal operation in the stored first dictionary, the first dictionary storing a plurality of preset attribute data and a pointer list corresponding to each preset attribute data, each pointer in the pointer list indicating a first frame buffer in the frame buffer management pool;
[0204] If there is, a target pointer is determined from the pointer list corresponding to the matched preset attribute data, and the first frame buffer corresponding to the target pointer is taken as the output frame buffer corresponding to the current post-processing operation;
[0205] If there is not, a frame buffer is created according to the attribute data as the output frame buffer corresponding to the current post-processing operation, and the frame buffer management pool and the first dictionary are updated according to the created frame buffer.
[0206] In some embodiments, the frame buffer management pool further comprises at least one occupied second frame buffer, and the image rendering method further comprises:
[0207] In response to a release request for the second frame buffer, the second frame buffer is released;
[0208] According to the identification information of the released second frame buffer, the stored second dictionary is updated, the second dictionary storing a plurality of preset identification information and a pointer corresponding to the preset identification information, each pointer indicating a second frame buffer in the frame buffer management pool;
[0209] According to the attribute data of the released second frame buffer, the first dictionary is updated.
[0210] In some embodiments, the rendering image corresponding to the corresponding post-processing operation is generated in the output frame buffer according to the target renderer plug-in, the rendering content and the input frame buffer, comprising:
[0211] The target renderer plug-in is called to draw the rendered content and the stored content in the input frame buffer into the output frame buffer to generate the rendered image corresponding to the corresponding post-processing operation.
[0212] In some embodiments, before responding to the post-processing request for the target virtual camera in the game scene, the image rendering method further includes:
[0213] In response to a post-processing setting request for a target virtual camera in a game scene, a post-processing operation setting interface corresponding to the target virtual camera is displayed in a graphical user interface, wherein a plurality of input interfaces are provided on the post-processing operation setting interface, each input interface corresponding to a post-processing operation;
[0214] In response to user input information in the input interface, at least one post-processing data group corresponding to the target virtual camera is generated.
[0215] In some embodiments, before responding to the post-processing setting request for the target virtual camera in the game scene, the image rendering method further includes:
[0216] Run the preset game engine;
[0217] By running the preset game engine, the game scene is constructed and displayed in the graphical user interface.
[0218] The specific implementation of the above operations can be found in the previous embodiments and will not be repeated here.
[0219] The computer-readable storage medium may include a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0220] Since the computer program stored in the storage medium can execute the steps in any of the image rendering method embodiments provided in the embodiments of the present application, the beneficial effects that can be achieved by any of the image rendering methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0221] The above is a detailed introduction to an image rendering method, device, electronic device and storage medium provided in the embodiments of the present application. Specific examples are used herein to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for those skilled in the art, based on the ideas of the present application, there may be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. An image rendering method, characterized in that: The method comprises: In response to a post-processing request for a target virtual camera in a game scene, determining a post-processing data group list corresponding to the target virtual camera, the post-processing data group list including at least one post-processing data group, each post-processing data group including rendering content of a corresponding post-processing operation, attribute data of the rendering content, and a renderer identifier; Determining an input frame buffer and an output frame buffer corresponding to each of the post-processing operations according to the post-processing data group list; Determine the target renderer plug-in used for the corresponding post-processing operation according to the renderer identifier; generating, in the output frame buffer, a rendered image corresponding to a corresponding post-processing operation according to the target renderer plug-in, the rendering content, and the input frame buffer; The determining, according to the post-processing data group list, an input frame buffer and an output frame buffer corresponding to each post-processing operation includes: Traversing the attribute data in the post-processing data group list; During the traversal process, the input frame buffer and output frame buffer corresponding to the corresponding post-processing operation are determined based on the attribute data obtained in each traversal operation, the traversal order and the stored frame buffer management pool, and the frame buffer management pool includes at least one unoccupied first frame buffer and an occupied second frame buffer.
2. The image rendering method according to claim 1, wherein: The determining of a post-processing data group list corresponding to the target virtual camera includes: Determining at least one post-processing data group corresponding to the target virtual camera and a priority corresponding to each of the post-processing data groups; A post-processing data set list is generated according to the priority and all the post-processing data sets.
3. The image rendering method according to claim 1, wherein: Determining the input frame buffer and the output frame buffer corresponding to the corresponding post-processing operation according to the attribute data obtained in each traversal operation, the traversal order, and the stored frame buffer management pool includes: If the current traversal operation is the first traversal, obtain the camera frame buffer corresponding to the target virtual camera as the input frame buffer corresponding to the current post-processing operation, and determine the output frame buffer corresponding to the current post-processing operation based on the attribute data obtained by the current traversal operation and the stored frame buffer management pool; If the current traversal operation is an intermediate traversal, the output frame buffer corresponding to the previous post-processing operation is used as the input frame buffer of the current post-processing operation, and the output frame buffer corresponding to the current post-processing operation is determined based on the attribute data obtained from the current traversal operation and the frame buffer management pool; If the current traversal operation is the last traversal, the output frame buffer corresponding to the previous post-processing operation is used as the input frame buffer of the current post-processing operation, and the off-screen frame buffer is used as the output frame buffer corresponding to the current post-processing operation.
4. The image rendering method according to claim 3, wherein: Determining an output frame buffer corresponding to a current post-processing operation based on the attribute data obtained from the current traversal operation and a stored frame buffer management pool includes: detecting whether there is preset attribute data matching the attribute data obtained by the current traversal operation in a stored first dictionary, wherein the first dictionary stores a plurality of preset attribute data and a pointer list corresponding to each preset attribute data, wherein each pointer in the pointer list indicates a first frame buffer in the frame buffer management pool; If so, determining a target pointer from the pointer list corresponding to the matching preset attribute data, and using the first frame buffer corresponding to the target pointer as the output frame buffer corresponding to the current post-processing operation; If not, create a frame buffer according to the attribute data as the output frame buffer corresponding to the current post-processing operation, and update the frame buffer management pool and the first dictionary according to the created frame buffer.
5. The image rendering method according to claim 4, wherein: The frame buffer management pool further includes at least one occupied second frame buffer, and the method further includes: In response to a release request for the second frame buffer, releasing the second frame buffer; updating a stored second dictionary according to the identification information of the released second frame buffer, wherein the second dictionary stores a plurality of preset identification information and pointers corresponding to the preset identification information, each pointer indicating a second frame buffer in the frame buffer management pool; The first dictionary is updated according to the released attribute data of the second frame buffer.
6. The image rendering method according to claim 1, wherein: Generating a rendered image corresponding to a corresponding post-processing operation in the output frame buffer according to the target renderer plug-in, the rendering content, and the input frame buffer includes: The target renderer plug-in is called to draw the rendered content and the stored content in the input frame buffer into the output frame buffer to generate a rendered image corresponding to the corresponding post-processing operation.
7. The image rendering method according to claim 1, wherein: Before responding to the post-processing request for the target virtual camera in the game scene, it also includes: In response to a post-processing setting request for a target virtual camera in the game scene, displaying a post-processing operation setting interface corresponding to the target virtual camera in a graphical user interface, wherein the post-processing operation setting interface provides a plurality of input interfaces, each of the input interfaces corresponding to a post-processing operation; In response to user input information in the input interface, at least one post-processing data group corresponding to the target virtual camera is generated.
8. The image rendering method according to claim 7, wherein: Before responding to the post-processing setting request for the target virtual camera in the game scene, the method further includes: Run the preset game engine; The game scene is constructed by running the preset game engine, and the game scene is displayed in a graphical user interface.
9. An image rendering device, characterized in that: include: A first determining module is configured to determine, in response to a post-processing request for a target virtual camera in a game scene, a list of post-processing data groups corresponding to the target virtual camera, wherein the list of post-processing data groups includes at least one post-processing data group, each of the post-processing data groups including rendering content of a corresponding post-processing operation, attribute data of the rendering content, and a renderer identifier; A second determining module is configured to determine an input frame buffer and an output frame buffer corresponding to each of the post-processing operations according to the post-processing data group list; A third determining module is used to determine a target renderer plug-in used for a corresponding post-processing operation according to the renderer identifier; a generation module, configured to generate a rendered image corresponding to a corresponding post-processing operation in the output frame buffer according to the target renderer plug-in, the rendering content, and the input frame buffer; The determining, according to the post-processing data group list, an input frame buffer and an output frame buffer corresponding to each post-processing operation includes: Traversing the attribute data in the post-processing data group list; During the traversal process, the input frame buffer and output frame buffer corresponding to the corresponding post-processing operation are determined based on the attribute data obtained in each traversal operation, the traversal order and the stored frame buffer management pool, and the frame buffer management pool includes at least one unoccupied first frame buffer and an occupied second frame buffer.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the image rendering method according to any one of claims 1 to 8.
11. An electronic device, characterized in that: The method comprises a coupled memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program in the memory to execute the steps in the image rendering method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Post-processing special effect production system and method, and AR special effect rendering method and device
CN114742981A