CN114913067A - Rendering method and device for dynamic resolution, electronic equipment and readable storage medium - Google Patents

Rendering method and device for dynamic resolution, electronic equipment and readable storage medium Download PDF

Info

Publication number
CN114913067A
CN114913067A CN202210403276.9A CN202210403276A CN114913067A CN 114913067 A CN114913067 A CN 114913067A CN 202210403276 A CN202210403276 A CN 202210403276A CN 114913067 A CN114913067 A CN 114913067A
Authority
CN
China
Prior art keywords
rendering
adjusted
resolution
texture
camera
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210403276.9A
Other languages
Chinese (zh)
Inventor
张凌云
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Perfect World Beijing Software Technology Development Co Ltd
Original Assignee
Perfect World Beijing Software Technology Development Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Perfect World Beijing Software Technology Development Co Ltd filed Critical Perfect World Beijing Software Technology Development Co Ltd
Priority to CN202210403276.9A priority Critical patent/CN114913067A/en
Publication of CN114913067A publication Critical patent/CN114913067A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T3/00Geometric image transformation in the plane of the image
    • G06T3/40Scaling the whole image or part thereof
    • G06T3/4023Decimation- or insertion-based scaling, e.g. pixel or line decimation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T13/00Animation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/40Analysis of texture

Abstract

The application discloses a rendering method and device of dynamic resolution, electronic equipment and a readable storage medium, relates to the technical field of computers, realizes resolution adjustment by sampling and rendering again on rendering textures, does not need to generate a rendering graph with a new size, avoids occupying a large amount of rendering resources, and achieves the purpose of saving resources. The method comprises the following steps: generating a target scaling ratio and a resolution to be adjusted; adjusting the rendering texture according to the resolution to be adjusted, and adjusting the size of a camera viewport of a scene camera of the animation scene according to the target zoom ratio; rendering the animation scene by using the adjusted camera viewport and the adjusted rendering texture to obtain a first rendering image; performing scaling sampling on the adjusted rendering texture to render the rendering texture back to a color buffer area, and rendering the color buffer area by using an interface camera of the animation scene to obtain a second rendering image; and overlaying the second rendering map to the first rendering map to generate a target rendering map.

Description

Rendering method and device of dynamic resolution, electronic equipment and readable storage medium
The application is a divisional application of a chinese patent application entitled "dynamic resolution rendering method, apparatus, electronic device, and readable storage medium" filed by chinese patent office on 30/6/2021 under application number 202110735362.5.
Technical Field
The present application relates to the field of computer technologies, and in particular, to a dynamic resolution rendering method and apparatus, an electronic device, and a readable storage medium.
Background
With the continuous development of computer technology, terminal devices such as smart phones and tablet computers are gradually popularized, become an indispensable part of life, study and entertainment of people, and deeply affect the aspects of social life of people. At present, terminal devices are configured differently, and when a software application is developed, in order to ensure that the resolution is high enough when the software application runs on the terminal device and avoid the fuzziness of characters, 2D pictures and the like displayed by the software application, the resolution of the software application needs to be continuously adjusted based on a software development tool.
In the related art, when the resolution of a software application is adjusted, a current frame rate of the software application needs to be determined, the resolution to be rendered is determined according to the current frame rate, a rendering graph with the size consistent with the resolution to be rendered is generated, and the resolution adjustment is realized by using the rendering graph to render a page of the software application at the current frame rate.
In carrying out the present application, the applicant has found that the related art has at least the following problems:
the resolution adjustment realized by adopting the mode of continuously generating the rendering graph needs to continuously generate the rendering graph with a new size in the running process of the software application, so that a large amount of rendering resources are occupied, and the waste of the resources is caused.
Disclosure of Invention
In view of this, the present application provides a rendering method and apparatus for dynamic resolution, an electronic device and a readable storage medium, and mainly aims to solve the problem that a rendering map with a new size is continuously generated at present, and a large amount of rendering resources are occupied, which results in resource waste.
According to a first aspect of the present application, there is provided a method for rendering a dynamic resolution, the method comprising: generating a target scaling ratio and a resolution to be adjusted; adjusting the rendered texture according to the resolution to be adjusted, and adjusting the size of a camera viewport of a scene camera of the animation scene according to the target zoom ratio; rendering the animation scene by using the adjusted camera viewport and the adjusted rendering texture to obtain a first rendering graph; performing scaling sampling on the adjusted rendering texture to render the rendering texture back to a color buffer area, and rendering the color buffer area by using an interface camera of the animation scene to obtain a second rendering image; and overlaying the second rendering map to the first rendering map to generate a target rendering map.
Optionally, the generating the target scaling ratio and the resolution to be adjusted includes: reading the current frame time consumption of the current frame of the animation scene; inquiring the time information of the historical frame, and carrying out average value calculation on the time information of the historical frame to obtain the average consumed time of the historical frame; determining a preset expected frame rate, calculating a first ratio of the current frame time consumption to the average time consumption, and a second ratio of the first ratio to the preset expected frame rate, and taking the second ratio as the target scaling ratio; reading the current resolution of the current frame, calculating a first product of the current resolution and the target scaling ratio, and taking the first product as the resolution to be adjusted.
Optionally, the scaling, sampling and rendering the adjusted rendering texture back to a color buffer area, and rendering the color buffer area by using an interface camera of the animation scene to obtain a second rendering map, including: stretching the adjusted rendering texture according to the target scaling ratio to obtain a rendering texture to be sampled; sampling the rendered texture to be sampled, and adding pixel points obtained by sampling to the color buffer area; and performing interface rendering according to the data of the color buffer area by using the interface camera to obtain the second rendering image.
Optionally, the method further comprises: determining a first axis of the first rendering map and a second axis of the second rendering map, and comparing the first axis with the second axis; when the first axis and the second axis have deviation, the second rendering graph is zoomed and subjected to position processing, and the first axis and the second axis are controlled to be overlapped.
Optionally, the method further comprises: and if the animation scene is associated with a high dynamic range rendering effect, deleting the rendering texture in each frame of the target rendering graph rendered for the animation scene.
According to a second aspect of the present application, there is provided a dynamic resolution rendering apparatus, comprising: the generating module is used for generating a target scaling ratio and a resolution to be adjusted; an adjusting module, configured to adjust a rendering texture according to the resolution to be adjusted, and adjust a size of a camera viewport of a scene camera of the animated scene according to the target zoom ratio; a first rendering module, configured to render the animation scene by using the adjusted camera viewport and the adjusted rendering texture, so as to obtain a first rendering map; the second rendering module is used for performing scaling sampling on the adjusted rendering textures and rendering the rendering textures back to a color buffer area, and rendering the color buffer area by using an interface camera of the animation scene to obtain a second rendering image; and the superposition module is used for superposing the second rendering map to the first rendering map to generate a target rendering map.
Optionally, the generating module is specifically configured to read a current frame time consumption of a current frame of the animation scene; inquiring the time information of the historical frame, and carrying out average calculation on the time information of the historical frame to obtain the average consumed time of the historical frame; determining a preset expected frame rate, calculating a first ratio of the current frame time consumption to the average time consumption, and a second ratio of the first ratio to the preset expected frame rate, and taking the second ratio as the target scaling ratio; reading the current resolution of the current frame, calculating a first product of the current resolution and the target scaling ratio, and taking the first product as the resolution to be adjusted.
Optionally, the second rendering module is specifically configured to stretch the adjusted rendering texture according to the target scaling ratio, so as to obtain a rendering texture to be sampled; sampling the rendered texture to be sampled, and adding pixel points obtained by sampling to the color buffer area; and performing interface rendering according to the data of the color buffer area by using the interface camera to obtain the second rendering image.
Optionally, the second rendering module is further configured to determine a first axis of the first rendering map and a second axis of the second rendering map, and compare the first axis with the second axis; when the first axis and the second axis have deviation, the second rendering graph is zoomed and processed in position, and the first axis and the second axis are controlled to coincide.
Optionally, the apparatus further comprises: and the deleting module is used for deleting the rendering texture in the target rendering graph rendered for the animation scene in each frame if the animation scene is associated with a high dynamic range rendering effect.
According to a third aspect of the present application, there is provided an electronic device comprising a memory storing a computer program and a processor implementing the steps of the method of any of the first aspect when the computer program is executed.
According to a fourth aspect of the present application, there is provided a readable storage medium having stored thereon a computer program which, when executed by a processor, carries out the steps of the method of any of the above-mentioned first aspects.
By means of the technical scheme, the dynamic resolution rendering method, the device, the electronic equipment and the readable storage medium are provided by the application, the application firstly determines a target zoom ratio and a resolution to be adjusted, adjusts a rendering texture according to the resolution to be adjusted, adjusts the size of a camera view port of a scene camera of an animation scene according to the target zoom ratio, renders the animation scene by using the adjusted camera view port and the adjusted rendering texture to obtain a first rendering image, performs zoom sampling on the adjusted rendering texture to render back to a color buffer area, renders the color buffer area by using an interface camera of the animation scene to obtain a second rendering image, further superposes the second rendering image on the first rendering image to generate a required target rendering image, and realizes dynamic resolution adjustment by performing sampling and rendering on the rendering texture again, and a rendering graph with a new size does not need to be generated, so that a large amount of rendering resources are avoided being occupied, and the purpose of saving resources is achieved.
The foregoing description is only an overview of the technical solutions of the present application, and the present application can be implemented according to the content of the description in order to make the technical means of the present application more clearly understood, and the following detailed description of the present application is given in order to make the above and other objects, features, and advantages of the present application more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the application. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 illustrates a flow chart of a rendering method of dynamic resolution provided in an embodiment of the present application;
fig. 2 is a flowchart illustrating a rendering method of dynamic resolution according to an embodiment of the present application;
fig. 3A is a schematic structural diagram illustrating a rendering apparatus with dynamic resolution according to an embodiment of the present application;
fig. 3B is a schematic structural diagram illustrating a rendering apparatus with dynamic resolution according to an embodiment of the present application;
fig. 3C is a schematic structural diagram illustrating a rendering apparatus with dynamic resolution according to an embodiment of the present application;
fig. 4 shows a schematic device structure diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Exemplary embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present application are shown in the drawings, it should be understood that the present application may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
An embodiment of the present application provides a rendering method of a dynamic resolution, as shown in fig. 1, the method includes:
101. and responding to a resolution adjustment instruction, and generating a target scaling ratio and a resolution to be adjusted according to the time information of the current frame and the historical frame of the animation scene.
102. And adjusting the rendered texture according to the resolution to be adjusted, and adjusting the size of a camera viewport of a scene camera of the animation scene according to the target zoom ratio.
103. And rendering the animation scene by using the adjusted camera viewport and the adjusted rendering texture to obtain a first rendering image.
104. And performing scaling sampling on the adjusted rendering texture to render the rendering texture back to the color buffer area, and rendering the color buffer area by using an interface camera of the animation scene to obtain a second rendering image.
105. And overlapping the second rendering map to the first rendering map to generate a target rendering map which accords with the resolution to be adjusted.
The method provided by the embodiment of the application determines a target zoom ratio and a resolution to be adjusted according to time information of a current frame and a historical frame of an animation scene in a game, adjusts a rendering texture according to the resolution to be adjusted, adjusts the size of a camera view port of a scene camera of the animation scene according to the target zoom ratio, renders the animation scene by using the adjusted camera view port and the adjusted rendering texture to obtain a first rendering map, performs zoom sampling on the adjusted rendering texture to render back to a color buffer area, renders the color buffer area by using an interface camera of the animation scene to obtain a second rendering map, further superimposes the second rendering map on the first rendering map to generate a target rendering map which accords with the resolution to be adjusted, realizes dynamic resolution adjustment by performing sampling and rendering on the rendering texture again without generating a rendering map with a new size, and a large amount of rendering resources are avoided being occupied, and the purpose of saving resources is achieved.
An embodiment of the present application provides a rendering method of a dynamic resolution, as shown in fig. 2, the method includes:
201. and responding to a resolution adjustment instruction, and generating a target scaling ratio and a resolution to be adjusted according to the time information of the current frame and the historical frame of the animation scene.
In recent years, computer technology has been developed, and game development platforms have been developed for the convenience of developers to develop games. The game development platform is a platform for creating and operating real-time 3D (three-dimensional) interactive content, such as a Unity platform. The game development platform provides a complete set of perfect software solutions, can be used for creating, operating and rendering any real-time interactive 2D (2 Dimensions) and 3D content, and the support platforms comprise mobile phones, tablet computers, PCs (Personal computers), game hosts, augmented reality and virtual reality equipment and the like. A game development platform is provided with a corresponding Interface for setting game resolution, but the Interface can cause the change of the whole game resolution, so that the resolution of a User Interface (UI) is reduced, and characters and 2D pictures in a game are blurred and cannot be directly viewed. Therefore, in the process of game development and operation, new scene rendering graphs with different sizes need to be continuously generated according to the frame rate for front-end display, so that the adjustment of the resolution is realized.
However, the applicant recognizes that continuously generating new scene rendering maps during the process of adjusting the resolution occupies a large amount of rendering resources, and the rendering cost is high, which not only wastes resources, but also may affect the performance of the game. Therefore, the application provides a rendering method of dynamic resolution, determining a target zoom ratio and a resolution to be adjusted according to time information of a current frame and a historical frame of an animation scene in a game, adjusting a rendering texture according to the resolution to be adjusted, adjusting the size of a camera view port of a scene camera of the animation scene according to the target zoom ratio, rendering the animation scene by using the adjusted camera view port and the adjusted rendering texture to obtain a first rendering image, performing zoom sampling on the adjusted rendering texture to render back to a color buffer area, rendering the color buffer area by using an interface camera of the animation scene to obtain a second rendering image, further overlaying the second rendering image to the first rendering image to generate a target rendering image which meets the resolution to be adjusted, and realizing dynamic resolution adjustment by performing sampling and rendering on the rendering texture again, and a rendering graph with a new size does not need to be generated, so that a large amount of rendering resources are avoided being occupied, and the purpose of saving resources is achieved.
In the process of practical application, the game development platform is divided into two versions, one is a C # (C sharp, an object-oriented programming language) version, and the other is a C + + (a computer programming language) version. Version C is a solution implemented in the form of a component, namely, a dynamic resolution layer is mounted on the scene camera and the interface camera. However, this component mounting method is not applicable to the C + + version, so in order to ensure that the resolution is successfully dynamically adjusted in the C + + version, initialization and setting of the original rendering map are required. Specifically, when initialization is performed, a preset number of class attributes need to be determined, and the preset number of class attributes are added to the quality setting class. The preset number of class attributes are a maximum zoom value, a minimum zoom value and a preset expected frame rate, the initialization is that the engine layer of the game development platform expands three class attributes, namely, maxResolution (maximum zoom value), minResolution (minimum zoom value) and dynamicresolution targetframe (preset expected frame rate) in a QualitySettings class, and the C # layer calls the assignment of the three class attributes before the Enable (operable). In addition, in the initialization process, a scene camera which needs to perform dynamic resolution needs to be set and started on the C # layer, and generally, the interface camera is not turned on by default. After the initialization is finished, the scene camera is called, a default rendering texture is set for the scene camera, namely a built-in rendering texture is set for the scene camera, and the subsequent application of the default rendering texture is ensured.
It should be noted that, for one animation scene, a plurality of main cameras may be provided, and therefore, when a scene camera is called, a camera list is formed based on the plurality of main cameras, and the camera list is all used as the called scene camera, so that the scene camera is one or more than one main camera in the animation scene, thereby achieving the purpose of supporting a plurality of 3D cameras.
Optionally, the rendering operation of the dynamic resolution in the embodiment of the present application may be triggered periodically or manually. Specifically, an adjustment period of the resolution may be set, for example, 0.5 second, and then the current time point is continuously detected, and when the current time point meets the adjustment period, it is determined that the resolution adjustment instruction is received, and the rendering of the dynamic resolution is started. Alternatively, when it is detected that the resolution adjustment entry is triggered, it may be determined that a resolution adjustment instruction is received, and the rendering of the dynamic resolution may be started. The present application does not specifically limit the manner in which the rendering of the dynamic resolution is triggered.
And responding to a resolution adjustment instruction, starting to generate a target scaling ratio and a resolution to be adjusted according to the time information of the current frame and the historical frame of the animation scene, and rendering the dynamic resolution according to the target scaling ratio and the resolution to be adjusted in the subsequent process. When the target scaling ratio is generated, it is necessary to first read the current frame time consumption (i.e., time. deltatime assignment) of the current frame of the animation scene, query the time information of the historical frame, and perform average calculation on the time information of the historical frame to obtain the average time consumption of the historical frame. Then, determining a preset expected frame rate, calculating a first ratio of the current frame time consumption to the average time consumption, and a second ratio of the first ratio to the preset expected frame rate, and taking the second ratio as a target scaling ratio. And after the target scaling ratio is generated, reading the current resolution of the current frame, calculating a first product of the current resolution and the target scaling ratio, and taking the first product as the resolution to be adjusted.
It should be noted that, if the process is performed based on the C + + version, a Statistics method may be registered in the initialization, and the Statistics method is called every frame, so that the calculation of the target scaling ratio and the resolution to be adjusted is completed every 0.5 seconds, so as to ensure the continuous update of the target scaling ratio.
202. And adjusting the rendered texture according to the resolution to be adjusted, and adjusting the size of a camera viewport of a scene camera of the animation scene according to the target zoom ratio.
In the embodiment of the application, after the target zoom ratio and the resolution to be adjusted are determined, rendering of the resolution is started again, rendering textures are adjusted according to the resolution to be adjusted, the size of a camera viewport of a scene camera of an animation scene is adjusted according to the target zoom ratio, and therefore the animation scene is rendered subsequently according to the adjusted camera viewport and the adjusted rendering textures. Since the game development platform is divided into two versions, different versions actually need to adjust the size of the camera view port in different ways.
For the C + + version, because the animation scene of the C + + version has the function of setting the scene camera, the scene camera mounted in the animation scene can be directly determined, the texture size of the rendered texture is obtained, the second product of the texture size and the target scaling ratio is calculated, and the length and the width of the camera viewport of the scene camera are adjusted according to the second product.
And for the C # version, because a scene camera needs to be called for the animation scene of the C # version, the scene camera called for the animation scene is determined in the animation scene, the texture size of the rendered texture is obtained, a second product of the texture size and the target zoom ratio is calculated, and the length and the width of a camera viewport of the scene camera are adjusted according to the second product.
203. And rendering the animation scene by using the adjusted camera viewport and the adjusted rendering texture to obtain a first rendering image.
In the embodiment of the present application, in order to ensure that an interface rendering operation can have a rendering basis in the subsequent interface rendering process, after the camera viewport and the rendering texture are adjusted, the adjusted camera viewport and the adjusted rendering texture are required to be used for rendering an animation scene, so as to obtain a first rendering map, so that the size of the first rendering map not only meets a target zoom ratio, but also includes all contents in the animation scene.
204. And performing scaling sampling on the adjusted rendering texture to render the rendering texture back to the color buffer area, and rendering the color buffer area by using an interface camera of the animation scene to obtain a second rendering image.
In the embodiment of the application, after the first rendering is generated, considering that interface contents capable of interacting with a player, such as keys and a map, need to be displayed on a rendering provided for the player in a game, therefore, it is necessary to perform scaling sampling on an adjusted rendering texture and render the rendering texture back to a color buffer area, and an interface camera of an animation scene is used to render the color buffer area to obtain a second rendering, thereby ensuring that the rendering conforms to an actual game scene while realizing dynamic resolution rendering.
When the second rendering is generated, firstly, since the screen of the terminal device carried by the front end has a certain size, and the interface camera in the version such as C + + does not have the function of automatically adjusting and controlling the size, the currently obtained rendering texture is reduced, and then the normal size is displayed on the terminal device, the adjusted rendering texture is stretched according to the target scaling ratio to obtain the rendering texture to be sampled, so that the target rendering with the size matched with the preset terminal display size is subsequently displayed for the player at the front end. And then sampling the rendering texture to be sampled, adding the sampled pixel points to a color buffer area, and performing interface rendering according to the data of the color buffer area by using an interface camera to obtain a second rendering image.
When the interface rendering is performed according to the data of the color buffer area, different modes can be adopted for different versions:
for the C + + version, when stretching the adjusted rendering texture, the C # layer may call a blittdynamicresolution interface to reduce the size of the adjusted rendering texture of the resolution to be adjusted and sample the rendering texture of the Blit back to the normal size. Then, when rendering is started, the resolution to be adjusted can be set in the interface camera, a render rectangle is obtained, the size of the render rectangle is adjusted to be a second product, and the render rectangle is used as an adjusted camera view port, so that the region with the resolution to be adjusted is rendered, and the purpose of saving rendering cost is achieved.
And aiming at the C # version, firstly, sampling rendering textures to be sampled, and adding pixel points obtained through sampling to a color buffer area. And then, performing interface rendering according to the data of the color buffer area by using an interface camera to obtain a second rendering image. In practical application, during rendering, rendering can be performed once before opaque rendering, so that colors in a to-be-sampled rendering texture are scaled, sampled and rendered back to a color buffer, and then a Shader (Shader) of an interface camera is set, thereby realizing the rendering processing and re-rendering of an animation scene.
205. And overlapping the second rendering map to the first rendering map to generate a target rendering map which accords with the resolution to be adjusted.
In the embodiment of the application, after the first rendering graph and the second rendering graph are generated, since the first rendering graph indicates content in an animation scene and the second rendering graph indicates content on an interface, the second rendering graph is superimposed on the first rendering graph, so that a target rendering graph conforming to the resolution to be adjusted can be generated.
It should be noted that, in order to ensure the accuracy of the overlay and avoid the overlay from deviating, the process of scaling and shifting the rendering map may be performed as follows: and determining a first axis of the first rendering map and a second axis of the second rendering map, and comparing the first axis with the second axis. And when the first axis and the second axis have deviation, zooming and position processing are carried out on the second rendering graph, and the first axis and the second axis are controlled to coincide. In addition, for the GrabPass (a type having a content capture and write function) effect, when a camera view port is set in an Interface camera, when an API (Application Program Interface) such as DX (data register) and Vulkan (cross-platform drawing Application Program Interface) is used, the built-in variable UNITY _ UV _ STARTS _ AT _ TOP has a problem that the captured texture is not located AT the same position on the scene model, and therefore, it is necessary to change RenderRectangle to the middle of the y-axis of the screen for compatibility. Furthermore, for some visual artifacts additionally set in the animation scene, the problem of incorrect UV coordinates also exists, and the UV needs to be adjusted in combination with a FrameDebugger.
In practical applications, if an animation scene is associated with a high dynamic range rendering effect, for example, a Bloom (glowing) function is turned on, a rendering texture needs to be deleted in a target rendering map rendered for the animation scene every frame. For example, if the scene camera turns on bloom (special effect), the rendering graph needs to be cleaned every frame, so as to prevent color convolution of the HDR Texture from being displayed in the interface displayed at the front end. In addition, for the HDR function, if the HDR is turned on for the animation scene, the format of the rendering texture needs to be adjusted to a format matching the HDR function, so as to ensure compatibility of the format.
In summary, the present application provides different technical solutions for different versions:
and aiming at the C # version, the method is realized in a component form, and the component is named as a dynamic resolution layer and is hung on a scene camera and an interface camera. The interface camera obtains rendering textures rendered by the scene camera, sets the rendering textures as main textures, sets the resolution to be adjusted, and zooms and samples pixels in the rendering textures back to the color buffer area to achieve dynamic resolution rendering of the components under the 3D camera.
And aiming at the C + + version, setting a maximum zoom value, a minimum zoom value and a preset expected frame rate by a C # logic layer, calculating by an engine of a game platform according to the values to obtain a resolution to be adjusted under a current frame, setting a scene camera as an offset green (camera view port), adjusting the size of the camera view port according to the resolution to be adjusted to save the overhead during rendering, calling a BlitDynamicResolution interface before post-processing, and returning a target rendering image with the size meeting the preset terminal display size by the interface for display.
The method provided by the embodiment of the application determines a target zoom ratio and a resolution to be adjusted according to time information of a current frame and a historical frame of an animation scene in a game, adjusts a rendering texture according to the resolution to be adjusted, adjusts the size of a camera view port of a scene camera of the animation scene according to the target zoom ratio, renders the animation scene by using the adjusted camera view port and the adjusted rendering texture to obtain a first rendering map, performs zoom sampling on the adjusted rendering texture to render back to a color buffer area, renders the color buffer area by using an interface camera of the animation scene to obtain a second rendering map, further superimposes the second rendering map on the first rendering map to generate a target rendering map which accords with the resolution to be adjusted, realizes dynamic resolution adjustment by performing sampling and rendering on the rendering texture again without generating a rendering map with a new size, and a large amount of rendering resources are avoided being occupied, and the purpose of saving resources is achieved.
Further, as a specific implementation of the method shown in fig. 1, an embodiment of the present application provides a rendering apparatus with dynamic resolution, and as shown in fig. 3A, the apparatus includes: a generation module 301, an adjustment module 302, a first rendering module 303, a second rendering module 304 and a superposition module 305.
The generating module 301 is configured to generate a target scaling ratio and a resolution to be adjusted according to time information of a current frame and a historical frame of an animation scene in response to a resolution adjustment instruction;
the adjusting module 302 is configured to adjust the rendered texture according to the resolution to be adjusted, and adjust a size of a camera viewport of a scene camera of the animation scene according to the target zoom ratio;
the first rendering module 303 is configured to render the animation scene by using the adjusted camera viewport and the adjusted rendering texture, so as to obtain a first rendering map;
the second rendering module 304 is configured to perform scaling sampling on the adjusted rendering texture and render the adjusted rendering texture back to a color buffer, and render the color buffer by using an interface camera of the animation scene to obtain a second rendering graph;
the superimposing module 305 is configured to superimpose the second rendering map onto the first rendering map, so as to generate a target rendering map that meets the resolution to be adjusted.
In a specific application scenario, as shown in fig. 3B, the apparatus further includes: a detection module 306.
The detecting module 306 is configured to detect a current time point, and determine that the resolution adjustment instruction is received when the current time point matches an adjustment period; or, when the resolution adjustment entrance is triggered, determining that the resolution adjustment instruction is received.
In a specific application scenario, the generating module 301 is configured to read a current frame time of a current frame of the animation scenario; inquiring the time information of the historical frame, and carrying out average value calculation on the time information of the historical frame to obtain the average consumed time of the historical frame; determining a preset expected frame rate, calculating a first ratio of the current frame time consumption to the average time consumption, and a second ratio of the first ratio to the preset expected frame rate, and taking the second ratio as the target scaling ratio; and reading the current resolution of the current frame, calculating a first product of the current resolution and the target scaling ratio, and taking the first product as the resolution to be adjusted.
In a specific application scenario, the adjusting module 302 is configured to determine the scene camera mounted in the animation scene; obtaining a texture size of the rendered texture, calculating a second product of the texture size and the target scaling ratio; adjusting a length and a width of a camera viewport of the scene camera according to the second product.
In a specific application scenario, the second rendering module 304 is configured to stretch the adjusted rendering texture according to the target scaling ratio to obtain a rendering texture to be sampled; sampling the rendered texture to be sampled, and adding pixel points obtained by sampling to the color buffer area; and performing interface rendering according to the data of the color buffer area by using the interface camera to obtain the second rendering graph.
In a specific application scenario, the second rendering module 304 is further configured to determine a first axis of the first rendering map and a second axis of the second rendering map, and compare the first axis with the second axis; when the first axis and the second axis have deviation, the second rendering graph is zoomed and processed in position, and the first axis and the second axis are controlled to coincide.
In a specific application scene, as shown in fig. 3C, the deleting module 307 is configured to delete the rendering texture in the target rendering map rendered for the animation scene in each frame if the animation scene is associated with a high dynamic range rendering effect.
The device provided by the embodiment of the application determines a target zoom ratio and a resolution to be adjusted according to time information of a current frame and a historical frame of an animation scene in a game, adjusts a rendering texture according to the resolution to be adjusted, adjusts the size of a camera view port of a scene camera of the animation scene according to the target zoom ratio, renders the animation scene by using the adjusted camera view port and the adjusted rendering texture to obtain a first rendering map, performs zoom sampling on the adjusted rendering texture to render back to a color buffer area, renders the color buffer area by using an interface camera of the animation scene to obtain a second rendering map, further superimposes the second rendering map on the first rendering map to generate a target rendering map which accords with the resolution to be adjusted, realizes dynamic resolution adjustment by performing sampling and rendering on the rendering texture again without generating a rendering map with a new size, and a large amount of rendering resources are avoided being occupied, and the purpose of saving resources is achieved.
It should be noted that other corresponding descriptions of the functional units related to the rendering apparatus with dynamic resolution provided in the embodiment of the present application may refer to the corresponding descriptions in fig. 1 and fig. 2, and are not repeated herein.
In an exemplary embodiment, referring to fig. 4, there is further provided a device including a communication bus, a processor, a memory, and a communication interface, and further including an input/output interface and a display device, wherein the functional units may communicate with each other through the bus. The memory stores a computer program, and the processor is configured to execute the program stored in the memory and execute the rendering method of dynamic resolution in the above embodiment.
A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method for rendering with dynamic resolution.
Through the description of the above embodiments, those skilled in the art can clearly understand that the present application can be implemented by hardware, and can also be implemented by software plus a necessary general hardware platform. Based on such understanding, the technical solution of the present application may be embodied in the form of a software product, which may be stored in a non-volatile storage medium (which may be a CD-ROM, a usb disk, a removable hard disk, etc.), and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method according to the implementation scenarios of the present application.
Those skilled in the art will appreciate that the figures are merely schematic representations of one preferred implementation scenario and that the blocks or flow diagrams in the figures are not necessarily required to practice the present application.
Those skilled in the art will appreciate that the modules in the devices in the implementation scenario may be distributed in the devices in the implementation scenario according to the description of the implementation scenario, or may be located in one or more devices different from the present implementation scenario with corresponding changes. The modules of the implementation scenario may be combined into one module, or may be further split into a plurality of sub-modules.
The above application serial number is merely for description and does not represent the superiority and inferiority of the implementation scenario.
The above disclosure is only a few specific implementation scenarios of the present application, but the present application is not limited thereto, and any variations that can be made by those skilled in the art are intended to fall within the scope of the present application.

Claims (10)

1. A method for rendering at a dynamic resolution, comprising:
generating a target scaling ratio and a resolution to be adjusted;
adjusting the rendered texture according to the resolution to be adjusted, and adjusting the size of a camera viewport of a scene camera of the animation scene according to the target zoom ratio;
rendering the animation scene by using the adjusted camera viewport and the adjusted rendering texture to obtain a first rendering graph;
performing scaling sampling on the adjusted rendering texture to render the rendering texture back to a color buffer area, and rendering the color buffer area by using an interface camera of the animation scene to obtain a second rendering image;
and overlaying the second rendering map to the first rendering map to generate a target rendering map.
2. The method of claim 1, wherein generating the target scaling ratio and the resolution to be adjusted comprises:
reading the current frame time consumption of the current frame of the animation scene;
inquiring the time information of the historical frame, and carrying out average value calculation on the time information of the historical frame to obtain the average consumed time of the historical frame;
determining a preset expected frame rate, calculating a first ratio of the current frame time consumption to the average time consumption, and a second ratio of the first ratio to the preset expected frame rate, and taking the second ratio as the target scaling ratio;
and reading the current resolution of the current frame, calculating a first product of the current resolution and the target scaling ratio, and taking the first product as the resolution to be adjusted.
3. The method of claim 1, wherein the scaling sampling of the adjusted rendering texture is performed to render the adjusted rendering texture back to a color buffer, and an interface camera of the animation scene is used to render the color buffer to obtain a second rendering map, comprising:
stretching the adjusted rendering texture according to the target scaling ratio to obtain a rendering texture to be sampled;
sampling the rendered texture to be sampled, and adding pixel points obtained by sampling to the color buffer area;
and performing interface rendering according to the data of the color buffer area by using the interface camera to obtain the second rendering image.
4. The method of claim 1, further comprising:
determining a first axis of the first rendering map and a second axis of the second rendering map, and comparing the first axis with the second axis;
when the first axis and the second axis have deviation, the second rendering graph is zoomed and processed in position, and the first axis and the second axis are controlled to coincide.
5. The method of claim 1, further comprising:
and if the animation scene is associated with a high dynamic range rendering effect, deleting the rendering texture in each frame of the target rendering graph rendered for the animation scene.
6. A dynamic resolution rendering apparatus, comprising:
the generating module is used for generating a target scaling ratio and a resolution to be adjusted;
an adjusting module, configured to adjust a rendering texture according to the resolution to be adjusted, and adjust a size of a camera viewport of a scene camera of the animated scene according to the target zoom ratio;
a first rendering module, configured to render the animation scene using the adjusted camera viewport and the adjusted rendering texture, so as to obtain a first rendering graph;
the second rendering module is used for performing scaling sampling on the adjusted rendering textures and rendering the rendering textures back to a color buffer area, and rendering the color buffer area by using an interface camera of the animation scene to obtain a second rendering image;
and the superposition module is used for superposing the second rendering map to the first rendering map to generate a target rendering map.
7. The apparatus of claim 6, wherein:
the generating module is specifically configured to read a current frame time consumption of a current frame of the animation scene; inquiring the time information of the historical frame, and carrying out average value calculation on the time information of the historical frame to obtain the average consumed time of the historical frame; determining a preset expected frame rate, calculating a first ratio of the current frame time consumption to the average time consumption, and a second ratio of the first ratio to the preset expected frame rate, and taking the second ratio as the target scaling ratio; reading the current resolution of the current frame, calculating a first product of the current resolution and the target scaling ratio, and taking the first product as the resolution to be adjusted.
8. The apparatus of claim 6, wherein:
the second rendering module is specifically configured to stretch the adjusted rendering texture according to the target scaling ratio to obtain a rendering texture to be sampled; sampling the rendered texture to be sampled, and adding pixel points obtained by sampling to the color buffer area; and performing interface rendering according to the data of the color buffer area by using the interface camera to obtain the second rendering image.
9. An electronic device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the dynamic resolution rendering method of any of claims 1 to 5.
10. A readable storage medium on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the dynamic resolution rendering method of any one of claims 1 to 5.
CN202210403276.9A 2021-06-30 2021-06-30 Rendering method and device for dynamic resolution, electronic equipment and readable storage medium Pending CN114913067A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210403276.9A CN114913067A (en) 2021-06-30 2021-06-30 Rendering method and device for dynamic resolution, electronic equipment and readable storage medium

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110735362.5A CN113469883B (en) 2021-06-30 2021-06-30 Rendering method and device of dynamic resolution, electronic equipment and readable storage medium
CN202210403276.9A CN114913067A (en) 2021-06-30 2021-06-30 Rendering method and device for dynamic resolution, electronic equipment and readable storage medium

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202110735362.5A Division CN113469883B (en) 2021-06-30 2021-06-30 Rendering method and device of dynamic resolution, electronic equipment and readable storage medium

Publications (1)

Publication Number Publication Date
CN114913067A true CN114913067A (en) 2022-08-16

Family

ID=77874410

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202210403276.9A Pending CN114913067A (en) 2021-06-30 2021-06-30 Rendering method and device for dynamic resolution, electronic equipment and readable storage medium
CN202110735362.5A Active CN113469883B (en) 2021-06-30 2021-06-30 Rendering method and device of dynamic resolution, electronic equipment and readable storage medium

Family Applications After (1)

Application Number Title Priority Date Filing Date
CN202110735362.5A Active CN113469883B (en) 2021-06-30 2021-06-30 Rendering method and device of dynamic resolution, electronic equipment and readable storage medium

Country Status (2)

Country Link
CN (2) CN114913067A (en)
WO (1) WO2023273114A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114913067A (en) * 2021-06-30 2022-08-16 完美世界(北京)软件科技发展有限公司 Rendering method and device for dynamic resolution, electronic equipment and readable storage medium
CN113963110B (en) * 2021-10-11 2022-10-25 北京百度网讯科技有限公司 Texture map generation method and device, electronic equipment and storage medium

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10311548B2 (en) * 2017-09-05 2019-06-04 Microsoft Technology Licensing, Llc Scaling render targets to a higher rendering resolution to display higher quality video frames
CN107742317B (en) * 2017-09-27 2020-11-03 杭州群核信息技术有限公司 Rendering method, device and system combining light sensation and convolution network and storage medium
CN108063938A (en) * 2017-12-21 2018-05-22 深圳市得色科技有限公司 The bore hole 3D imaging display methods and its system of a kind of game engine
US10776907B2 (en) * 2018-10-24 2020-09-15 Adobe Inc. Dynamic image resolution adjustment for rendering changes to graphical content
US10825200B2 (en) * 2019-01-30 2020-11-03 Trivver, Inc. Texture based pixel count determination
CN111918125B (en) * 2019-05-09 2023-03-24 腾讯科技(深圳)有限公司 Video playing method, device and system
CN110393921B (en) * 2019-08-08 2022-08-26 腾讯科技(深圳)有限公司 Cloud game processing method and device, terminal, server and storage medium
CN111309430B (en) * 2020-03-16 2021-12-10 广东趣炫网络股份有限公司 Method and related device for automatically caching user interaction interface nodes
CN112184877B (en) * 2020-09-30 2024-02-23 杭州电魂网络科技股份有限公司 Method and system for rendering optimization of glow effect
CN113041617B (en) * 2021-03-18 2022-07-26 深圳市腾讯网域计算机网络有限公司 Game picture rendering method, device, equipment and storage medium
CN114913067A (en) * 2021-06-30 2022-08-16 完美世界(北京)软件科技发展有限公司 Rendering method and device for dynamic resolution, electronic equipment and readable storage medium

Also Published As

Publication number Publication date
WO2023273114A1 (en) 2023-01-05
CN113469883A (en) 2021-10-01
CN113469883B (en) 2022-05-06

Similar Documents

Publication Publication Date Title
CN107888845B (en) Video image processing method and device and terminal
US10311548B2 (en) Scaling render targets to a higher rendering resolution to display higher quality video frames
CN113469883B (en) Rendering method and device of dynamic resolution, electronic equipment and readable storage medium
CN112652046B (en) Game picture generation method, device, equipment and storage medium
CN105389090B (en) Method and device, mobile terminal and the computer terminal of game interaction interface display
AU2014402162B2 (en) Method and apparatus for setting background of UI control, and terminal
US20070104360A1 (en) System and method for capturing 3D face
CN113225606B (en) Video barrage processing method and device
CN110968962B (en) Three-dimensional display method and system based on cloud rendering at mobile terminal or large screen
JP2010514011A (en) Post-render graphics rotation
CN111939567A (en) Game virtual scene transformation method and device and electronic terminal
CN107564085B (en) Image warping processing method and device, computing equipment and computer storage medium
CN114531553B (en) Method, device, electronic equipment and storage medium for generating special effect video
CN107564084B (en) Method and device for synthesizing motion picture and storage equipment
CN107644451B (en) Animation display method and device
CN112070854A (en) Image generation method, device, equipment and storage medium
CN109658495B (en) Rendering method and device for ambient light shielding effect and electronic equipment
CN113256785B (en) Image processing method, apparatus, device and medium
CN113393391B (en) Image enhancement method, image enhancement device, electronic apparatus, and storage medium
CN114428573B (en) Special effect image processing method and device, electronic equipment and storage medium
WO2022022260A1 (en) Image style transfer method and apparatus therefor
CN114693894A (en) Method, system and device for converting pictures into building blocks in virtual world
CN110874816B (en) Image processing method, device, mobile terminal and storage medium
CN107087114B (en) Shooting method and device
CN109729285B (en) Fuse grid special effect generation method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination