Image rendering method and device, electronic equipment and storage medium
By responsive to preset batch mixing switches in WebGL, the blend mode parameters of the target display object are obtained and set, and the rendering performance problem is solved due to frequent rendering target creation and destruction, batch rendering is realized and rendering performance is improved.
Patent Information
- Application Number
- CN202411499523.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-24
- Publication Date
- 2025-02-18
AI Technical Summary
In the prior art, the application of hybrid technology in WebGL involves frequent rendering target creation and destruction, resulting in lower rendering performance.
By responding to the on-off operation of the preset batch mixing switch, the mixing mode parameters of the target parent display object are obtained and determined as the target mixing mode parameters of each target display object. At the same time, the parameter is invalid for the target parent display object, so as to achieve no need Create a batch rendering that renders directly to the home screen.
Reduces the number of times of creation and state switching of rendering cache area, reduces the communication overhead between the CPU and GPU, thereby improving rendering performance.
Smart Images

Figure CN119478169A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to an image rendering method, device, electronic device and storage medium. Background Art
[0002] The rendering stage is the last step in computer graphics design, and it is also the stage that finally makes the image conform to the 3D scene. Rendering operations are used in many fields: for example, games, advertising design, movies, architectural design, etc.
[0003] In the prior art, graphics rendering operations are mainly implemented based on WebGL. In WebGL, blending is a graphics rendering technology used to determine how to blend new pixel colors with pixel colors already in the color buffer. This technology is particularly important when processing transparent and semi-transparent objects.
[0004] However, the application of hybrid technology in WebGL involves the creation of render targets (RenderTarget), and the creation of render targets involves many state switches and allocation of GPU resources. Frequent creation and destruction of RenderTarget may result in low rendering performance. Summary of the invention
[0005] The purpose of this application is to provide an image rendering method, device, electronic device and storage medium to improve rendering performance in view of the deficiencies in the above-mentioned prior art.
[0006] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0007] In a first aspect, the present invention provides an image rendering method, the method comprising:
[0008] For a target parent display object corresponding to a target frame image, in response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned on, obtaining a first mixing mode parameter of the target parent display object, the target parent display object being created based on a container, and the plurality of target display objects being child display objects of the target parent display object;
[0009] Determine the first blending mode parameter of the target parent display object as the target blending mode parameter of each target display object, and set the first blending mode parameter to be invalid for the target parent display object;
[0010] The target frame image is rendered and displayed according to the target mixing mode parameters of each target display object.
[0011] In a second aspect, the present invention provides an image rendering device, comprising:
[0012] an acquisition module, configured to acquire, for a target parent display object corresponding to a target frame image, a first mixing mode parameter of the target parent display object in response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned on, the target parent display object being created based on a container, and the plurality of target display objects being child display objects of the target parent display object;
[0013] A setting module, configured to determine the first blending mode parameter of the target parent display object as the target blending mode parameter of each target display object, and set the first blending mode parameter to be invalid for the target parent display object;
[0014] A rendering module is used to render and display the target frame image according to the target mixing mode parameters of each target display object.
[0015] In a third aspect, the present invention provides an electronic device, comprising: a processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the image rendering method as described in any of the aforementioned implementations.
[0016] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the image rendering method as described in any of the aforementioned embodiments are executed.
[0017] The beneficial effects of this application are:
[0018] The image rendering method, device, electronic device and storage medium provided by the embodiments of the present application include: for a target parent display object corresponding to a target frame image, in response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned on, obtaining a first mixing mode parameter of the target parent display object, the target parent display object being created based on a container; determining the first mixing mode parameter of the target parent display object as a target mixing mode parameter of each target display object, and setting the first mixing mode parameter to be invalid for the target parent display object; rendering and displaying the target frame image according to the target mixing mode parameter of each target display object, thereby achieving the goal of not creating a rendering target for the target parent display object, but only rendering to a main screen according to the target mixing mode parameter of the target display object, thereby achieving batch rendering, and then merging drawing operations with the same state together, reducing the number of state switching times, and reducing the communication overhead between the CPU and the GPU during graphics rendering, thereby improving rendering performance. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0020] Figure 1 A schematic diagram of a flow chart of an image rendering method provided in an embodiment of the present application;
[0021] Figure 2 A flowchart of another image rendering method provided in an embodiment of the present application;
[0022] Figure 3 A flowchart of another image rendering method provided in an embodiment of the present application;
[0023] Figure 4 A flowchart of another image rendering method provided in an embodiment of the present application;
[0024] Figure 5 A flowchart of another image rendering method provided in an embodiment of the present application;
[0025] Figure 6 A flowchart of another image rendering method provided in an embodiment of the present application;
[0026] Figure 7 A schematic diagram of functional modules of an image rendering device provided in an embodiment of the present application;
[0027] Figure 8 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0029] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0030] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0031] In the prior art, the application of hybrid technology in WebGL involves the creation of a render target (RenderTarget), and the creation of a render target involves many state switches and allocation of GPU resources. Frequent creation and destruction of RenderTarget may result in low rendering performance.
[0032] For example, let's take the game development scenario as an example. In game development, developers usually set a mix on a container to achieve a specific visual effect. If a mix operation is set on a container, the following steps will be involved:
[0033] Step 1: Create the first rendering target RenderTarget_1, and then draw all the contents in the container onto this RenderTarget_1;
[0034] Step 2: Draw the above RenderTarget_1 onto the second rendering target RenderTarget_2 (for example, the screen). Through this setting, all the contents in the container can be mixed onto the background in the specified mixing mode.
[0035] Among them, although the above operation switches the blending state once, it requires additional memory to create and store the RenderTarget, and if the size of the created RenderTarget is large, the process of drawing the RenderTarget may consume a lot of GPU resources, and creating a RenderTarget involves a lot of state switching and GPU resource allocation. For example, it is necessary to create an FBO, create a texture, attach the texture to the FBO, etc. These operations all require interaction with the GPU, and each state switch consumes a certain amount of time and resources.
[0036] In summary, it can be seen that the existing mixing operation will lead to low rendering performance of the rendering device. In view of this, an embodiment of the present application provides an image rendering method. The application of this method can reduce the creation of the rendering buffer area and the number of state switching, thereby improving the rendering performance.
[0037] Figure 1A flow chart of an image rendering method provided for an embodiment of the present application, the execution subject of the method can be a computer, server or other electronic device that can support the operation of a preset rendering engine. Optionally, the preset rendering engine can be an engine such as 3ds Max, Maya, Corona, V-Ray, Redshift, Unreal, Frostbite, Egret, etc., which is not limited here. Optionally, the preset rendering engine can support WebGL technology, and a preset batch mixing switch can be deployed in the preset engine. Of course, the present application does not limit the application scenario of the method of the present application. For example, it can be applied to the mixed rendering operation of any virtual object (for example, virtual character, virtual building, virtual equipment) in the game field, the construction field, the film field, the virtual reality field, etc.
[0038] like Figure 1 As shown, the method includes:
[0039] Step 101 : For a target parent display object corresponding to a target frame image, in response to determining that a preset batch mixing switch of target parent display objects corresponding to a plurality of target display objects is turned on, obtaining a first mixing mode parameter of the target parent display object.
[0040] The target parent display object is created based on the container, and the multiple target display objects are child display objects of the target parent display object.
[0041] Optionally, the target frame image can be any frame image that needs to be rendered, for example, it can be a frame image in an animation or a video, which is not limited here. The target frame image can correspond to multiple parent display objects, each parent display object can be constructed based on a container (Group), and optionally, the container corresponding to each parent display object can be a root container or a non-root container, which is not limited here.
[0042] Take the Egret engine as an example. In the Egret engine, if a display object can contain other display objects as its child objects, then the display object can be regarded as a container.
[0043] Optionally, each parent display object corresponding to the target frame image may be created based on classes such as Sprite, Stage, MovieClip, etc., which is not limited here.
[0044] Among them, each parent display object may include at least one child display object. Optionally, the child display object may be various visual or interactive elements such as a button, a text box, an image, a shape, a virtual elf, etc., which may vary according to the actual application scenario.
[0045] Optionally, the target parent display object may be any parent display object of multiple parent display objects corresponding to the target frame image. In addition, the present application does not limit the number of target display objects in the target parent display object, which may vary according to actual application scenarios; in addition, it should be noted that in some scenarios, each target display object may also include multiple child display objects, that is, each target display object may also be created based on a container.
[0046] The target parent display object may be pre-set with a first blending mode parameter, wherein the first blending mode parameter may include: a first blending factor of a source color (the color to be drawn) corresponding to the target parent display object under the blending mode and a second blending factor of a target color (the color already existing on the screen or in the buffer) currently corresponding to the target frame image, wherein the first blending factor and the second blending factor may be flexibly set according to the actual application scenario.
[0047] Of course, the present application does not limit the value of the first mixed mode parameter of the target parent display object, and it can be flexibly set according to the actual application scenario.
[0048] Based on the above description, the preset rendering engine can provide a preset batch mixing switch, which can include an on state and an off state. For the target parent display object, if the preset batch mixing switch is set to the on state, the target mixing mode parameters of the target display object will be obtained.
[0049] Step 102: Determine the first blending mode parameter of the target parent display object as the target blending mode parameter of each target display object, and set the first blending mode parameter to be invalid for the target parent display object.
[0050] The target parent display object may include multiple target display objects.
[0051] Step 103: Render and display the target frame image according to the target blending mode parameters of each target display object.
[0052] After obtaining the first blending mode parameter of the target parent display object, the blending mode of the target display object can be set accordingly, that is, the first blending mode parameter of the target parent display object is determined as the target blending mode parameter of all corresponding target display objects, and the first blending mode parameter is set to be invalid for the target parent display object. It can be understood that since the first blending mode parameter is invalid for the target parent display object at this time, there is no need to create a rendering target for the target parent display object at this time, but only needs to be rendered directly to the main screen according to the target blending mode parameter of the target display object, thereby realizing batch rendering, and then drawing operations with the same state can be merged together, reducing the number of state switching times, and reducing the communication overhead between the CPU and GPU during graphics rendering, thereby improving rendering performance.
[0053] For example, a target frame image corresponds to a target parent display object a, and the first mixing mode parameter of the target parent display object a is A1. The child display objects of the target parent display object a include: target display objects b and c. The first sub-mixing mode parameters of the target display objects b and c are not set. Then, applying the method provided in the embodiment of the present application will make the first sub-mixing mode parameters of the target display objects b and c A1, and the first mixing mode parameters of the target parent display object a are invalid.
[0054] It should be noted that if the target display object includes multiple sub-display objects, the target mixed mode parameters of the target display object will be confirmed as the target mixed mode parameters of its sub-display objects, and the target mixed mode parameters of the target display object will be set to invalid.
[0055] Based on the above example, if the target display object b also includes: child display objects c and d, the target mixing mode parameters of the child display objects c and d will be set to A1 (that is, the target mixing mode parameters of the target display object b). At the same time, the first mixing mode parameters of the target parent display object a will be set to invalid, and the target mixing mode parameters of the target display object b will be set to invalid.
[0056] Compared with the prior art, in the prior art, when the target display object has multiple child display objects, a rendering target RenderTarget is created by default, wherein the creation of RenderTarget involves a lot of state switching and allocation of GPU resources, and frequent creation and destruction of RenderTarget may result in low rendering performance; however, by applying the embodiments of the present application, even if the target display object has multiple child display objects, RenderTarget will not be created, thereby not involving state switching and GPU resource allocation operations, and can improve rendering performance.
[0057] In summary, the present application provides an image rendering method, which includes: for a target parent display object corresponding to a target frame image, in response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned on, obtaining a first mixing mode parameter of the target parent display object, the target parent display object is created based on a container, and the plurality of target display objects belong to child display objects of the target parent display object; determining the first mixing mode parameter of the target parent display object as a target mixing mode parameter of each target display object, and setting the first mixing mode parameter to be invalid for the target parent display object; rendering and displaying the target frame image according to the target mixing mode parameter of each target display object, thereby achieving the goal of not creating a rendering target for the target parent display object, but only rendering to a main screen according to the target mixing mode parameter of the target display object, thereby achieving batch rendering, and then merging drawing operations with the same state together, reducing the number of state switching times, and reducing the communication overhead between the CPU and the GPU during graphics rendering, thereby improving rendering performance.
[0058] Figure 2 A flowchart of another image rendering method provided in an embodiment of the present application is shown below. Figure 2 As shown, the method also includes:
[0059] Step 201: In response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned off, create a rendering target corresponding to the target parent display object.
[0060] Step 202: Draw the target display object in the rendering target.
[0061] Step 203: Obtain the second blending mode parameters of the target parent display object.
[0062] Step 204: Render and display the target frame image according to the second blending mode parameter of the target parent display object and the rendering target.
[0063] Among them, for the target parent display object, if its corresponding preset batch mixing switch is set to the off state, the second mixing mode parameter of the target parent display object will be obtained; according to the second mixing mode parameter of the target parent display object, the target frame image is rendered by creating a rendering target, so as to obtain the mixed rendering effect of the target frame image.
[0064] The description of the second mixing mode parameter can refer to the description of the first mixing mode parameter, which will not be repeated here. In addition, it should be noted that the mixing factors indicated by the second mixing mode parameter and the first mixing mode parameter can be the same or different, which is not limited here.
[0065] Among them, if the target frame image is rendered and displayed according to the second mixing mode parameter of the target parent display object, a rendering target (RenderTarget) corresponding to the target parent display object will be created; the target parent display object and its corresponding target display object are drawn onto the rendering target, and the rendering target is set to be rendered using the mixing mode indicated by the second mixing mode parameter, so as to obtain a mixed rendering effect of the target frame image.
[0066] It should be noted that the rendering target corresponding to each target parent display object may be a screen, a texture, a frame buffer, etc., which is not limited here and may vary according to actual application scenarios.
[0067] If the rendering target is a screen, it means that the rendering result is directly displayed on the screen, which is used to render the scene in real time and display the result to the user; if the rendering target is a texture, it means that the rendering result is drawn into a texture object, for example, the rendering result can be used as a texture map for subsequent rendering or calculation. For example, the rendering result can be used as a reflection map or shadow map of the scene; if the rendering target is a frame buffer, it means that the rendering result is drawn into a frame buffer object, where a frame buffer is a buffer for storing rendering results, which can include a color buffer, a depth buffer, a template buffer, etc. By using a frame buffer, advanced rendering techniques such as off-screen rendering and multiple rendering targets can be implemented.
[0068] By applying the embodiments of the present application, it is possible to complete mixed rendering by creating a rendering target, which can meet the rendering requirements of some rendering scenes and improve the flexibility of the method of the present application; in addition, the introduction of a preset batch mixing switch is compatible with the mixing operation of existing containers, that is, it will not affect the mixing operation of existing containers, which can improve the applicability of the method of the present application.
[0069] In summary, it can be seen that the state of the preset batch mixing switch can determine the mixing mode of the target parent display object. For the target parent display object, when the preset batch mixing switch is in the on state, the target display object will obtain the mixing mode parameters of the target parent display object as its own mixing mode parameters. At this time, the mixing mode parameters of the target parent object itself are invalid; when the preset batch mixing switch is in the off state, the target parent display object will use its own mixing mode parameters to set the mixing mode of itself and its target display object, that is, the target frame image is rendered by creating a rendering target, so as to meet the rendering requirements in different scenarios.
[0070] In an optional implementation manner, the above-mentioned rendering and displaying the target frame image according to the target mixed mode parameter of the target display object includes:
[0071] The target mixing mode parameters are passed into the preset mixing operation function, and the target mixing mode parameters include: a first mixing factor of the source color corresponding to the target display object and a second mixing factor of the target color currently corresponding to the target frame image; the preset mixing operation function is run to obtain the target mixing color corresponding to the target frame image, and the target frame image is rendered and displayed using the target mixing color.
[0072] The preset blending operation function is used to control how to blend the source color corresponding to the target display object (the color to be drawn) and the target color currently corresponding to the target frame image (the color already existing on the screen or in the buffer). Therefore, the preset blending operation function can also input a second blending factor of the target display color corresponding to the target frame image.
[0073] Optionally, the preset blending operation function is gl.blendFunc() as an example for explanation, which may include two input parameters src_factor and dst_factor, wherein src_factor is used to specify the first blending factor of the source color, and dst_factor is used to indicate the second blending factor of the target color. The formula for calculating the mixed color is: mixed color = source color × src_factor + target color × dst_factor. By selecting different combinations of src_factor and dst_factor, various different blending effects can be achieved, such as additive blending, subtractive blending, etc.
[0074] Optionally, src_factor and dst_factor can be some predefined constants, for example, src_factor can be gl.SRC_ALPHA, dst_factor can be gl.ONE_MINUS_SRC_ALPHA, then in the preset blending operation function gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA), gl.SRC_ALPHA means using the alpha value (transparency) of the source color as the first blending factor of the source color, and gl.ONE_MINUS_SRC_ALPHA means using 1 minus the alpha value of the source color as the second blending factor of the target color. Of course, it should be noted that the setting method of the first blending factor and the second blending factor is not limited to this, and can be flexibly set according to the actual application scenario.
[0075] Based on the above description, after setting the first mixing factor and the second mixing factor in the preset mixing function, the preset mixing operation function can be run. By running the preset mixing operation function, the source color corresponding to each target display object and the target display color corresponding to the target frame image are batch mixed, and then the drawing operations with the same state can be merged together, reducing the number of state switching times and reducing the communication overhead between the CPU and GPU during the graphics rendering process, thereby improving the rendering performance.
[0076] Figure 3 A flowchart of another image rendering method provided in an embodiment of the present application is shown below. Figure 3 As shown, the above method also includes:
[0077] Step 301: For a target parent display object, in response to a first editing operation on a mixed mode control in a preset rendering engine, set a mixed mode parameter of the target parent display object.
[0078] Optionally, the preset rendering engine may provide a blending mode control, which may be used to set blending mode parameters of a specified target parent display object.
[0079] Specifically, when setting, the mixed mode parameters of the target parent display object can be set for the selected target parent display object through the mixed mode control. In some embodiments, the mixed mode control can include an input box, and the user can manually edit the input box to input the mixed mode parameters; of course, the mixed mode control can also be set to include a preset box option, and the mixed mode parameters can be determined by box selection, wherein each preset box option is configured to correspond to the preset mixed mode parameters.
[0080] Optionally, the blending mode indicated by the blending mode parameter of the target parent object can be any of the following: no blending mode, adding the original color value of the current display object to its background color, erasing its background color according to the value of the alpha channel of the current display object, wherein the area with an alpha value not equal to 0 will be erased. The setting of the blending mode is not limited to this.
[0081] In combination with the above description, optionally, the first mixed mode parameter and the second mixed mode parameter of the target parent display object can be set through the mixed mode control.
[0082] It should be noted that the present application does not limit the execution order of step 301 and other steps. For example, it can be executed before executing step 101 to pre-set the first blending mode parameters of the target parent display object; of course, it can also be executed after executing step 103 to further adjust the blending mode parameters of the target parent display object, thereby meeting the scene requirements of different rendering scenes and improving the flexibility and applicability of the method of the present application.
[0083] In an optional embodiment, the above method further includes:
[0084] Step 302: When the preset batch mixing switch is in an off state, in response to a second editing operation on a mixing mode control corresponding to a first target display object among the multiple target display objects, set a third mixing mode parameter of the target display object.
[0085] Step 303: Render and display the target frame image according to the third mixed mode parameter of the first target display object.
[0086] Of course, in some embodiments, the above-mentioned mixed mode control can also be used to set the mixed mode parameters of any target display object. Optionally, the first target display object can be any target display object among multiple target display objects, which is not limited here.
[0087] The method for setting the mixed mode parameters of the first target display object through the mixed mode control can refer to the method for setting the target parent display object mentioned above, which will not be described in detail here.
[0088] Optionally, the third blending mode parameters of the set first target display object include: a first blending factor of the source color (the color to be drawn) corresponding to the first target display object in the blending mode and a second blending factor of the target color (the color already existing on the screen or in the buffer) currently corresponding to the target frame image, wherein the first blending factor and the second blending factor can be flexibly set according to the actual application scenario.
[0089] It should be noted that step 302 of the embodiment of the present application can be executed at any rendering stage. For example, after executing step 103, step 302 can be used to fine-tune the blending mode parameters of some target display objects in the target parent display object. Of course, it can also be executed before step 101 to meet the scene requirements of different rendering scenes and improve the flexibility and applicability of the method of the present application.
[0090] Figure 4 A flowchart of another image rendering method provided in an embodiment of the present application is shown below. Figure 4 As shown, the above method also includes:
[0091] Step 401: In response to a triggering operation on a performance monitoring control in a preset rendering engine, a preset performance monitoring script is run.
[0092] Step 402: Count and display the total number of state switching times corresponding to the target frame image rendering process through a preset performance monitoring script.
[0093] Optionally, in order to allow the user to compare the rendering effects of two hybrid rendering methods during the hybrid rendering process, the preset rendering engine can provide a performance monitoring control. During the rendering process, the performance monitoring control can be triggered, and a preset performance monitoring script can be pre-run in the background. The preset performance monitoring script can count the corresponding total number of state switching during the target frame image rendering process (denoted as setpassCalls) to achieve quantitative evaluation of the rendering effect, that is, the number of rendering state switching during the target frame image rendering process.
[0094] Among them, the smaller the corresponding total state switching times during the target frame image rendering process, the higher the corresponding rendering performance.
[0095] Optionally, the rendering states involved in the target frame image rendering process may include, but are not limited to: shaders, textures, materials, lights, etc., which are not limited here and may vary according to actual application scenarios.
[0096] Figure 5 A flowchart of another image rendering method provided in an embodiment of the present application is shown below. Figure 5 As shown, the above method also includes:
[0097] Step 501: for a target parent display object, a preset performance monitoring script is used to count the first total state switching times and the second total state switching times corresponding to a target frame image rendering process when a preset batch mixing switch is in an on state and in an off state.
[0098] Among them, when monitoring the target parent display object specifically, a preset performance monitoring script can be used to count the first total state switching number corresponding to the target frame image rendering process when the preset batch mixing switch is in the on state; and the second total state switching number corresponding to the target frame image rendering process when the preset batch mixing switch is in the off state.
[0099] Step 502: According to the first total state switching number and the second total state switching number, the current switch state of the preset batch mixing switch corresponding to the target parent display object is adjusted.
[0100] Based on the above description, the current switch state of the preset batch mixed switch corresponding to the target parent display object can be adjusted according to the size relationship between the counted first total state switching number and the second total state switching number, so that the switch state with a smaller total state switching number can be selected as the target switch state of the preset batch mixed switch.
[0101] Among them, when the preset batch mixing switch corresponding to the target parent display object is in the target switch state, not only can each child target display object in the target parent display object meet the target mixing rendering requirements, but also the number of rendering targets created in the rendering process can be reduced, and the number of state switching times can be reduced, thereby reducing the communication overhead between the CPU and GPU in the graphics rendering process and improving the rendering performance.
[0102] Figure 6 A flowchart of another image rendering method provided in an embodiment of the present application is shown below. Figure 6 As shown, optionally, the above-mentioned adjusting the current switch state of the preset batch mixed switch corresponding to the target parent display object according to the first total state switching number and the second total state switching number includes:
[0103] Step 601: If the first total state switching number is less than the second total state switching number, and the current switch state of the preset batch mixing switch corresponding to the target parent display object is the off state, the preset batch mixing switch is switched from the off state to the on state.
[0104] Step 602: If the first total state switching number is greater than the second total state switching number, and the current switch state of the preset batch mixing switch corresponding to the target parent display object is on, the preset batch mixing switch is switched from on to off.
[0105] Among them, if the first total state switching number is less than the second total state switching number, it means that when the preset batch mixing switch is in the on state, the total state switching number corresponding to the target frame image is small. At this time, the current switch state of the preset batch mixing switch corresponding to the target parent display object can be adjusted to the on state; otherwise, it means that when the preset batch mixing switch is in the off state, the total state switching number corresponding to the target frame image is small. At this time, the current switch state of the preset batch mixing switch corresponding to the target parent display object can be adjusted to the off state.
[0106] Based on the above description, it can be understood that by obtaining the total number of state switching times corresponding to the target frame image rendering process under different states of the preset batch mixing switch, a quantitative evaluation of the rendering effect is achieved, and then based on this, the final rendering method of the target parent display object can be obtained, which can improve the applicability of the method of the present application.
[0107] In summary, the rendering method of the present application has the characteristics of simple operation. Compared with the existing method of setting the blending mode of the sub-display object by modifying and editing the animation files in large quantities, the present application can reduce the amount of modification; and through the setting of preset batch mixing switches, the rendering effects before and after being turned on can be quickly and in real time compared; by introducing the indicator of the total number of state switching times, the quantitative evaluation of the rendering effect can be achieved, thereby improving the accuracy of the comparison.
[0108] Figure 7 This is a functional module diagram of an image rendering device provided in an embodiment of the present application. The basic principle and technical effects of the device are the same as those of the corresponding method embodiment described above. For the sake of brief description, the parts not mentioned in this embodiment can be referred to the corresponding contents in the method embodiment. Figure 7 As shown, the image rendering device 100 includes:
[0109] The acquisition module 110 is used to acquire, for a target parent display object corresponding to a target frame image, a first mixing mode parameter of the target parent display object in response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned on, the target parent display object being created based on a container, and the plurality of target display objects being child display objects of the target parent display object;
[0110] A setting module 120, configured to determine the first blending mode parameter of the target parent display object as the target blending mode parameter of each target display object, and set the first blending mode parameter to be invalid for the target parent display object;
[0111] The rendering module 130 is used to render and display the target frame image according to the target mixing mode parameters of each target display object.
[0112] In an optional embodiment, the image rendering apparatus further comprises: a processing module, configured to create a rendering target corresponding to the target parent display object in response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned off;
[0113] drawing the target display object in the render target;
[0114] Obtain a second blending mode parameter of the target parent display object;
[0115] The target frame image is rendered and displayed according to the second blending mode parameter of the target parent display object and the rendering target.
[0116] In an optional embodiment, the rendering model is specifically used to pass the target mixing mode parameters of each target display object into a preset mixing operation function, wherein the target mixing mode parameters include: a first mixing factor of the source color corresponding to each target display object and a second mixing factor of the target color currently corresponding to the target frame image;
[0117] The preset mixing operation function is run to obtain a target mixed color corresponding to the target frame image, and the target mixed color is used to render and display the target frame image.
[0118] In an optional implementation, the processing module is further configured to set, for the target parent display object, a mixed mode parameter of the target parent display object in response to a first editing operation on a mixed mode control in a preset rendering engine.
[0119] In an optional embodiment, the processing module is further used to set a third mixing mode parameter of a first target display object among the multiple target display objects in response to a second editing operation on a mixing mode control corresponding to the first target display object when the preset batch mixing switch is in an off state; and render and display the target frame image according to the third mixing mode parameter of the first target display object.
[0120] In an optional embodiment, the image rendering device further includes: a monitoring module, configured to run a preset performance monitoring script in response to a triggering operation on a performance monitoring control in a preset rendering engine;
[0121] The preset performance monitoring script is used to count and display the total number of state switching times corresponding to the target frame image rendering process.
[0122] In an optional implementation manner, the monitoring module is specifically used to count, for the target parent display object, the first total state switching number and the second total state switching number corresponding to the target frame image rendering process when the preset batch mixing switch is in the on state and the off state respectively through the preset performance monitoring script;
[0123] According to the first total state switching number and the second total state switching number, the current switch state of the preset batch mixing switch corresponding to the target parent display object is adjusted.
[0124] In an optional implementation manner, the monitoring module is specifically configured to switch the preset batch mixing switch from the closed state to the open state if the first total state switching number is less than the second total state switching number and the current switch state of the preset batch mixing switch corresponding to the target parent display object is the closed state;
[0125] If the first total state switching times is greater than the second total state switching times, and the current switch state of the preset batch mixing switch corresponding to the target parent display object is on, the preset batch mixing switch is switched from on to off.
[0126] The above-mentioned device is used to execute the method provided by the aforementioned embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0127] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASICs), or one or more microprocessors, or one or more field programmable gate arrays (FPGAs). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0128] Figure 8 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, and the electronic device can be integrated into the above-mentioned image rendering device. Figure 8 As shown, the electronic device may include: a processor 210, a storage medium 220 and a bus 230, the storage medium 220 stores machine-readable instructions executable by the processor 210, when the electronic device is running, the processor 210 and the storage medium 220 communicate through the bus 230, and the processor 210 executes the machine-readable instructions to perform the steps of the above method embodiment. The specific implementation method and technical effect are similar and will not be repeated here.
[0129] Optionally, the present application further provides a storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the following method embodiment are executed:
[0130] For a target parent display object corresponding to a target frame image, in response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned on, obtaining a first mixing mode parameter of the target parent display object, the target parent display object being created based on a container, and the plurality of target display objects being child display objects of the target parent display object;
[0131] Determine the first blending mode parameter of the target parent display object as the target blending mode parameter of each target display object, and set the first blending mode parameter to be invalid for the target parent display object;
[0132] The target frame image is rendered and displayed according to the target mixing mode parameters of each target display object.
[0133] In an optional embodiment, the method further comprises:
[0134] In response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned off, creating a rendering target corresponding to the target parent display object;
[0135] drawing the target display object in the render target;
[0136] Obtain a second blending mode parameter of the target parent display object;
[0137] The target frame image is rendered and displayed according to the second blending mode parameter of the target parent display object and the rendering target.
[0138] In an optional implementation manner, rendering and displaying the target frame image according to the target blending mode parameters of each target display object includes:
[0139] Passing target mixing mode parameters of each target display object into a preset mixing operation function, wherein the target mixing mode parameters include: a first mixing factor of a source color corresponding to each target display object and a second mixing factor of a target color currently corresponding to the target frame image;
[0140] The preset mixing operation function is run to obtain a target mixed color corresponding to the target frame image, and the target mixed color is used to render and display the target frame image.
[0141] In an optional embodiment, the method further comprises:
[0142] For the target parent display object, in response to a first editing operation on a mixed mode control in a preset rendering engine, a mixed mode parameter of the target parent display object is set.
[0143] In an optional embodiment, the method further comprises:
[0144] When the preset batch mixing switch is in an off state, in response to a second editing operation on a mixing mode control corresponding to a first target display object among the multiple target display objects, a third mixing mode parameter of the first target display object is set; and according to the third mixing mode parameter of the first target display object, the target frame image is rendered and displayed.
[0145] In an optional embodiment, the method further comprises:
[0146] In response to a triggering operation on a performance monitoring control in a preset rendering engine, running a preset performance monitoring script;
[0147] The preset performance monitoring script is used to count and display the total number of state switching times corresponding to the target frame image rendering process.
[0148] In an optional embodiment, the method further comprises:
[0149] For the target parent display object, the preset performance monitoring script is used to count the first total state switching times and the second total state switching times corresponding to the target frame image rendering process when the preset batch mixing switch is in the on state and the off state respectively;
[0150] According to the first total state switching number and the second total state switching number, the current switch state of the preset batch mixing switch corresponding to the target parent display object is adjusted.
[0151] In an optional implementation, adjusting the current switch state of the preset batch mixing switch corresponding to the target parent display object according to the first total state switching number and the second total state switching number includes:
[0152] If the first total state switching times are less than the second total state switching times, and the current switch state of the preset batch mixing switch corresponding to the target parent display object is the off state, then the preset batch mixing switch is switched from the off state to the on state;
[0153] If the first total state switching times is greater than the second total state switching times, and the current switch state of the preset batch mixing switch corresponding to the target parent display object is on, the preset batch mixing switch is switched from on to off.
[0154] The specific implementation method and technical effects of the above method embodiment are similar to those described above and will not be repeated here.
[0155] Optionally, the present application further provides a computer program product, the computer program product comprising instructions, which, when executed on an electronic device, enable the electronic device to implement the steps of the following method embodiment:
[0156] For a target parent display object corresponding to a target frame image, in response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned on, obtaining a first mixing mode parameter of the target parent display object, the target parent display object being created based on a container, and the plurality of target display objects being child display objects of the target parent display object;
[0157] Determine the first blending mode parameter of the target parent display object as the target blending mode parameter of each target display object, and set the first blending mode parameter to be invalid for the target parent display object;
[0158] The target frame image is rendered and displayed according to the target mixing mode parameters of each target display object.
[0159] In an optional embodiment, the method further comprises:
[0160] In response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned off, creating a rendering target corresponding to the target parent display object;
[0161] drawing the target display object in the render target;
[0162] Obtain a second blending mode parameter of the target parent display object;
[0163] The target frame image is rendered and displayed according to the second blending mode parameter of the target parent display object and the rendering target.
[0164] In an optional implementation manner, rendering and displaying the target frame image according to the target blending mode parameters of each target display object includes:
[0165] Passing target mixing mode parameters of each target display object into a preset mixing operation function, wherein the target mixing mode parameters include: a first mixing factor of a source color corresponding to each target display object and a second mixing factor of a target color currently corresponding to the target frame image;
[0166] The preset mixing operation function is run to obtain a target mixed color corresponding to the target frame image, and the target mixed color is used to render and display the target frame image.
[0167] In an optional embodiment, the method further comprises:
[0168] For the target parent display object, in response to a first editing operation on a mixed mode control in a preset rendering engine, a mixed mode parameter of the target parent display object is set.
[0169] In an optional embodiment, the method further comprises:
[0170] When the preset batch mixing switch is in an off state, in response to a second editing operation on a mixing mode control corresponding to a first target display object among the multiple target display objects, a third mixing mode parameter of the first target display object is set; and according to the third mixing mode parameter of the first target display object, the target frame image is rendered and displayed.
[0171] In an optional embodiment, the method further comprises:
[0172] In response to a triggering operation on a performance monitoring control in a preset rendering engine, running a preset performance monitoring script;
[0173] The preset performance monitoring script is used to count and display the total number of state switching times corresponding to the target frame image rendering process.
[0174] In an optional embodiment, the method further comprises:
[0175] For the target parent display object, the preset performance monitoring script is used to count the first total state switching times and the second total state switching times corresponding to the target frame image rendering process when the preset batch mixing switch is in the on state and the off state respectively;
[0176] According to the first total state switching number and the second total state switching number, the current switch state of the preset batch mixing switch corresponding to the target parent display object is adjusted.
[0177] In an optional implementation, adjusting the current switch state of the preset batch mixing switch corresponding to the target parent display object according to the first total state switching number and the second total state switching number includes:
[0178] If the first total state switching times are less than the second total state switching times, and the current switch state of the preset batch mixing switch corresponding to the target parent display object is the off state, then the preset batch mixing switch is switched from the off state to the on state;
[0179] If the first total state switching times is greater than the second total state switching times, and the current switch state of the preset batch mixing switch corresponding to the target parent display object is on, the preset batch mixing switch is switched from on to off.
[0180] The specific implementation method and technical effects of the above method embodiment are similar to those described above and will not be repeated here.
[0181] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0182] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0183] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0184] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the methods of each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.
[0185] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0186] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings. The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. An image rendering method, characterized in that: The method comprises: For a target parent display object corresponding to a target frame image, in response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned on, obtaining a first mixing mode parameter of the target parent display object, the target parent display object being created based on a container, and the plurality of target display objects being child display objects of the target parent display object; Determine the first blending mode parameter of the target parent display object as the target blending mode parameter of each target display object, and set the first blending mode parameter to be invalid for the target parent display object; The target frame image is rendered and displayed according to the target mixing mode parameters of each target display object.
2. The method according to claim 1, characterized in that The method further comprises: In response to determining that a preset batch mixing switch of target parent display objects corresponding to the plurality of target display objects is turned off, creating a rendering target corresponding to the target parent display object; drawing the target display object in the render target; Obtain a second blending mode parameter of the target parent display object; The target frame image is rendered and displayed according to the second blending mode parameter of the target parent display object and the rendering target.
3. The method according to claim 1, characterized in that The rendering and displaying of the target frame image according to the target blending mode parameters of each target display object includes: Passing target mixing mode parameters of each target display object into a preset mixing operation function, wherein the target mixing mode parameters include: a first mixing factor of a source color corresponding to each target display object and a second mixing factor of a target color currently corresponding to a target frame image; The preset mixing operation function is run to obtain a target mixed color corresponding to the target frame image, and the target mixed color is used to render and display the target frame image.
4. The method according to claim 1, characterized in that The method further comprises: For the target parent display object, in response to a first editing operation on a mixed mode control in a preset rendering engine, a mixed mode parameter of the target parent display object is set.
5. The method according to claim 1, characterized in that The method further comprises: When the preset batch mixing switch is in an off state, in response to a second editing operation on a mixing mode control corresponding to a first target display object among the plurality of target display objects, setting a third mixing mode parameter of the first target display object; The target frame image is rendered and displayed according to the third mixed mode parameter of the first target display object.
6. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: In response to a triggering operation on a performance monitoring control in a preset rendering engine, running a preset performance monitoring script; The preset performance monitoring script is used to count and display the total number of state switching times corresponding to the target frame image rendering process.
7. The method according to claim 6, characterized in that The method further comprises: For the target parent display object, the preset performance monitoring script is used to count the first total state switching times and the second total state switching times corresponding to the target frame image rendering process when the preset batch mixing switch is in the on state and the off state respectively; According to the first total state switching number and the second total state switching number, the current switch state of the preset batch mixing switch corresponding to the target parent display object is adjusted.
8. The method according to claim 7, characterized in that The adjusting the current switch state of the preset batch mixing switch corresponding to the target parent display object according to the first total state switching number and the second total state switching number includes: If the first total state switching times are less than the second total state switching times, and the current switch state of the preset batch mixing switch corresponding to the target parent display object is the off state, then the preset batch mixing switch is switched from the off state to the on state; If the first total state switching times is greater than the second total state switching times, and the current switch state of the preset batch mixing switch corresponding to the target parent display object is on, the preset batch mixing switch is switched from on to off.
9. An image rendering device, characterized in that: include: an acquisition module, configured to acquire, for a target parent display object corresponding to a target frame image, a first mixing mode parameter of the target parent display object in response to determining that a preset batch mixing switch of a target parent display object corresponding to a plurality of target display objects is turned on, the target parent display object being created based on a container, and the plurality of target display objects being child display objects of the target parent display object; a determination module, configured to determine the first blending mode parameter of the target parent display object as the target blending mode parameter of each target display object, and set the first blending mode parameter to be invalid for the target parent display object; A rendering module is used to render and display the target frame image according to the target mixing mode parameters of each target display object.
10. An electronic device, characterized in that: include: A processor, a storage medium and a bus, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the image rendering method as described in any one of claims 1-8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the image rendering method according to any one of claims 1 to 8 are executed.