A method, apparatus, device, and readable storage medium for screen rendering
By cached three-dimensional scene element information and multiplexed between different viewports, the problem of CPU repeatedly processing three-dimensional element information in the prior art is solved, and efficient multi-viewport picture rendering is achieved, saving CPU resources.
Patent Information
- Application Number
- CN202311404536.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-26
- Publication Date
- 2025-05-30
- Estimated Expiration
- 2043-10-26
AI Technical Summary
When the prior art displays three-dimensional elements in the same three-dimensional scene from different viewports at the same time, the device CPU needs to repeatedly process the relevant information of the three-dimensional elements, resulting in high equipment performance requirements.
By obtaining the target three-dimensional scene, determining the current rendering timestamp and configuring at least two viewports for the current device, calculating the element information of each element in the three-dimensional scene under the rendering timestamp, and cache the element information and rendering timestamps to the preset cache area, and rendering the picture of different viewports based on the element information in the cache area.
The rendering multiplexing of element information under the same rendering timestamp in different viewports is realized, avoiding the device CPU repeatedly processing the relevant information of three-dimensional elements at the same time, saving CPU resources, and reserving more time for picture rendering of different viewports.
Smart Images

Figure CN117372596B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and particularly to a method, apparatus, device, and readable storage medium for rendering a picture. Background Art
[0002] Currently, three-dimensional elements in the same three-dimensional scene can be displayed in a planar manner from different viewports. In order to display the three-dimensional elements in the same three-dimensional scene from different viewports at the same time, it is necessary for the device's CPU (Central Processing Unit) to repeatedly process the relevant information of the three-dimensional elements in the same three-dimensional scene from different viewports at the same time for use in rendering the pictures under different viewports. This method performs a complete set of rendering operation processes for each different viewport respectively, and has relatively high performance requirements for the device executing the rendering operation process.
[0003] Therefore, how to perform picture rendering for different viewports of a three-dimensional scene in combination with the device performance is a problem that those skilled in the art need to solve. Summary of the Invention
[0004] In view of this, the purpose of this application is to provide a method, apparatus, device, and readable storage medium for rendering a picture, so as to perform picture rendering for different viewports of a three-dimensional scene in combination with the device performance. The specific solutions are as follows:
[0005] In a first aspect, this application provides a method for rendering a picture, including:
[0006] Obtain a target three-dimensional scene;
[0007] Determine the current rendering timestamp and at least two viewports configured for the current device;
[0008] Calculate the element information of each element in the target three-dimensional scene at the rendering timestamp, and cache the element information and the rendering timestamp in a preset buffer;
[0009] Based on the element information in the preset buffer, render the pictures of the at least two viewports at the rendering timestamp.
[0010] Optionally, the determining the current rendering timestamp and at least two viewports configured for the current device includes:
[0011] Use the current real timestamp as the rendering timestamp; or determine the rendering timestamp according to a preset frame marking rule;
[0012] Configure the at least two viewports for the current device according to the amount of idle resources of the current device.
[0013] Optionally, calculating the element information of each element in the target three-dimensional scene at the rendering timestamp includes:
[0014] For each element in the target three-dimensional scene, calculate the texture information, frame buffer information, position information, rotation information, scaling information, and element action information of the current element itself, to obtain the element information of the current element at the rendering timestamp.
[0015] Optionally, caching the element information and the rendering timestamp to a preset buffer includes:
[0016] Make the element information and the rendering timestamp form a data pair;
[0017] Cache the data pair to the preset buffer according to the free resources of the current device and the remaining space of the preset buffer.
[0018] Optionally, caching the data pair to the preset buffer according to the free resources of the current device and the remaining space of the preset buffer includes:
[0019] If the free resources of the current device are greater than the preset resource threshold and the remaining space of the preset buffer is greater than the preset space threshold, store the data pair to the free address of the preset buffer;
[0020] If the free resources of the current device are not greater than the preset resource threshold, store the data pair to the preset buffer in a covering manner.
[0021] Optionally, the rendering process of the picture of any viewport at the rendering timestamp includes:
[0022] Obtain the camera parameters under the current viewport;
[0023] Process the element information in the preset buffer according to the camera parameters to obtain the element occlusion information and the elements outside the current viewport;
[0024] Process the element occlusion information and the elements outside the current viewport in a perspective projection manner, and render to obtain the picture of the current viewport at the rendering timestamp.
[0025] Optionally, rendering the pictures of the at least two viewports at the rendering timestamp based on the element information in the preset buffer includes:
[0026] Determine the main viewport among the at least two viewports;
[0027] After rendering the picture of the main viewport at the rendering timestamp based on the element information in the preset buffer, render the pictures of other viewports except the main viewport at the rendering timestamp based on the element information in the preset buffer;
[0028] Display the pictures of the at least two viewports at the rendering timestamp on the same page.
[0029] In a second aspect, the present application provides a picture rendering device, including:
[0030] An acquisition module, configured to acquire a target three-dimensional scene;
[0031] A determination module, configured to determine the current rendering timestamp and at least two viewports configured for the current device;
[0032] A processing module, configured to calculate the element information of each element in the target three-dimensional scene at the rendering timestamp, and cache the element information and the rendering timestamp into a preset buffer;
[0033] A rendering module, configured to render the pictures of the at least two viewports at the rendering timestamp based on the element information in the preset buffer.
[0034] In a third aspect, the present application provides an electronic device, including:
[0035] A memory, configured to store a computer program;
[0036] A processor, configured to execute the computer program to implement the picture rendering method disclosed above.
[0037] In a fourth aspect, the present application provides a readable storage medium, configured to store a computer program, wherein the computer program, when executed by a processor, implements the picture rendering method disclosed above.
[0038] As can be seen from the above solutions, the present application provides a picture rendering method, including: acquiring a target three-dimensional scene; determining the current rendering timestamp and at least two viewports configured for the current device; calculating the element information of each element in the target three-dimensional scene at the rendering timestamp, and caching the element information and the rendering timestamp into a preset buffer; rendering the pictures of the at least two viewports at the rendering timestamp based on the element information in the preset buffer.
[0039] It can be seen that after determining the current rendering timestamp and at least two viewports configured for the current device, the present application first calculates the element information of each element in the target three-dimensional scene at the current rendering timestamp, and then caches the element information and the rendering timestamp in a preset buffer. Subsequently, when rendering the images under each viewport, the rendering is based on the element information in the preset buffer. Thus, the rendering reuse of the element information at the same rendering timestamp under different viewports is achieved, which can avoid the device CPU from repeatedly processing the relevant information of three-dimensional elements at the same moment, saving the device CPU resources. Moreover, more time can be reserved for the device GPU (Graphics Processing Unit) to render the images of different viewports, which is conducive to the simultaneous presentation and rendering of the images under multiple viewports. The entire process also matches the device performance and requires relatively few resources, making the solution have good universality.
[0040] Correspondingly, a screen rendering device, device, and readable storage medium provided by the present application also have the above technical effects. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained according to the provided drawings without creative efforts.
[0042] Figure 1 It is a flowchart of a screen rendering method disclosed in the present application;
[0043] Figure 2 It is a flowchart of another screen rendering method disclosed in the present application;
[0044] Figure 3 It is a schematic diagram of a screen display disclosed in the present application;
[0045] Figure 4 It is a schematic diagram of a coordinate conversion process disclosed in the present application;
[0046] Figure 5 It is a schematic diagram of a screen rendering device disclosed in the present application;
[0047] Figure 6 It is a server structure diagram provided by the present application;
[0048] Figure 7 It is a terminal structure diagram provided by the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0049] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.
[0050] Currently, it is necessary for the device CPU to repeatedly process the relevant information of the three-dimensional elements in the same three-dimensional scene from different viewports at the same moment for use in the rendering of the pictures under different viewports. This method performs a complete set of rendering operation processes for each of the different viewports separately, which requires a high performance of the device executing the rendering operation process. For this reason, the present application provides a picture rendering solution, which can avoid the device CPU from repeatedly processing the relevant information of the three-dimensional elements at the same moment, saves the device CPU resources, and can reserve more time for the rendering of the pictures of different viewports.
[0051] See Figure 1 As shown, the embodiments of the present application disclose a picture rendering method, including:
[0052] S101. Obtain a target three-dimensional scene.
[0053] In this embodiment, the target three-dimensional scene may be a game three-dimensional scene, an animation three-dimensional scene, or a real-scene three-dimensional scene, etc. A target three-dimensional scene may include at least one three-dimensional element, such as: people, trees, houses, etc. That is: the elements in the target three-dimensional scene are three-dimensional objects such as people, trees, and houses in the target three-dimensional scene.
[0054] S102. Determine the current rendering timestamp and at least two viewports configured for the current device.
[0055] It should be noted that this embodiment can be applied to a software client (such as a game client, etc.), and this software client is installed and run on the current device, and the current device may be a terminal device such as a personal computer. Since the storage resources, CPU computing resources, etc. of the current device as a terminal are relatively small, it may not support the rendering of the pictures of multiple viewports at the same timestamp. Multiple viewports such as: the main viewport (i.e., the perspective where the human eye is located), the left viewport, the right viewport, and the rear viewport, etc.
[0056] It should be noted that when the camera is located at different positions, there can be multiple perspectives (i.e., viewports). For example: one camera is at the same height as the bottom surface of a three-dimensional object, is set parallel, and the closest straight-line distance between the camera and the contour line of the three-dimensional object is 1 centimeter; another camera is at the same height as the top surface of a three-dimensional object, is set parallel, and the closest straight-line distance between the camera and the contour line of the three-dimensional object is 5 centimeters. It can be seen that these two cameras are located at different positions in three-dimensional space. Looking at the same three-dimensional object from these two cameras will result in different pictures, that is, the pictures under two viewports are obtained. Thus, different viewports correspond to cameras at different positions.
[0057] Among them, the way to determine the camera position is as follows: Generally, the camera position is determined by the caller of the SDK (Software Development Kit) setting the world coordinates of the camera in the 3D (3 Dimension) scene. If the caller of the SDK has never set the camera world coordinates, a default position will be set for the camera (the default position is provided by the 3D designer according to the scene design). With the world coordinates of the camera in the 3D scene, the picture of the viewport where the camera is located can be rendered according to MVP (Model model, View observation, Projection projection transformation).
[0058] In order to enable the current device to render the pictures of as many different viewports as possible at the same timestamp, in this embodiment, at least two viewports are configured for the current device according to the idle resource amount of the current device. For example: a main viewport and a left viewport are configured for the current device; among them, the main viewport is the viewport that must be configured, and other viewports can be flexibly configured as needed.
[0059] In one implementation manner, determining the current rendering timestamp and at least two viewports configured for the current device includes: using the current real timestamp (such as the clock time of the current device) as the rendering timestamp; or determining the rendering timestamp according to a preset frame marking rule. The preset frame marking rule is as follows: when the target three-dimensional scene is initially displayed, the rendering timestamp is recorded as 1, and every time the display time of a single-frame picture (such as 10 milliseconds) passes, the rendering timestamp increases by 1, that is: the current frame is marked as the picture of the nth frame with an increasing integer sequence; configuring at least two viewports for the current device according to the idle resource amount of the current device. Among them, the idle resource amount of the current device is the sum of resource amounts such as the remaining memory and the remaining CPU resources.
[0060] S103. Calculate the element information of each element in the target three-dimensional scene at the rendering timestamp, and cache the element information and the rendering timestamp into a preset buffer.
[0061] In this embodiment, calculating the element information of each element in the target three-dimensional scene at the rendering timestamp includes: for each element in the target three-dimensional scene, calculating the texture information, frame buffer information (FBO information), position information, rotation information, scaling information, and element action information of the current element itself, so as to obtain the element information of the current element at the rendering timestamp.
[0062] In one implementation manner, caching the element information and the rendering timestamp into a preset buffer includes: making the element information and the rendering timestamp form a data pair; specifically, the data pair can be a key-value pair obtained by using the rendering timestamp as the key and the element information at this rendering timestamp as the value; caching the data pair into the preset buffer according to the free resource amount of the current device and the remaining space of the preset buffer. The preset buffer can be located on the memory external to the current device or in the CPU of the current device. Apply for this preset buffer to the current device before executing step S103. The size of the applied preset buffer can be a preset value or a value determined based on the free resource amount of the current device. For example, the preset buffer is not larger than the free cache resource of the CPU of the current device; and / or the preset buffer is not larger than the free storage space of the memory external to the current device.
[0063] In one implementation manner, caching the data pair into the preset buffer according to the free resource amount of the current device and the remaining space of the preset buffer includes: if the free resource amount of the current device is greater than the preset resource amount threshold and the remaining space of the preset buffer is greater than the preset space threshold, storing the data pair to the free address in the preset buffer; if the free resource amount of the current device is not greater than the preset resource amount threshold, storing the data pair to the preset buffer in a covering manner.
[0064] Of course, in order to save the resources of the current device and improve the rendering efficiency, only the element information at one rendering timestamp can be cached in the preset buffer. Then, except for the first frame of the picture, the element information at other timestamps is stored in the preset buffer in a covering manner.
[0065] S104. Based on the element information in the preset buffer, rendering the pictures of at least two viewports at the rendering timestamp.
[0066] In one example, the rendering process of the picture of any viewport at the rendering timestamp includes: obtaining the camera parameters under the current viewport, such as the position of the camera in the scene, the camera focus position, and the field of view of the camera, etc.; processing the element information in the preset buffer according to the camera parameters to obtain the element occlusion information and the elements outside the current viewport; processing the element occlusion information and the elements outside the current viewport in the perspective projection manner and rendering the picture of the current viewport at the rendering timestamp.
[0067] In one embodiment, based on the element information in a preset buffer, a picture of at least two viewports at a rendering timestamp is rendered, including: determining a main viewport among the at least two viewports; after rendering a picture of the main viewport at the rendering timestamp based on the element information in the preset buffer, then rendering a picture of other viewports except the main viewport at the rendering timestamp based on the element information in the preset buffer; and presenting the pictures of the at least two viewports at the rendering timestamp on the same page. Among them, rendering a picture of other viewports except the main viewport at the rendering timestamp based on the element information in the preset buffer includes: after obtaining the camera parameters of other viewports, first determining whether the element information at the current rendering timestamp is stored in the preset buffer; if so, rendering a picture of other viewports at the current rendering timestamp based on the element information in the preset buffer; if not, calculating the element information of each element in the target three-dimensional scene at the current rendering timestamp, and caching this element information and the current rendering timestamp into the preset buffer; and then rendering a picture of other viewports at the current rendering timestamp based on the element information in the preset buffer.
[0068] It can be seen that after determining the current rendering timestamp and at least two viewports configured for the current device, the present application first calculates the element information of each element in the target three-dimensional scene at the current rendering timestamp, and then caches the element information and the rendering timestamp into the preset buffer. Subsequently, when rendering the pictures of each viewport, the rendering is performed based on the element information in the preset buffer. Thus, the rendering reuse of the element information at the same rendering timestamp under different viewports (i.e., perspectives) is achieved, which can avoid the device CPU from repeatedly processing the relevant information of three-dimensional elements at the same moment, saving the device CPU resources, and can reserve more time for rendering pictures from different perspectives, facilitating the simultaneous presentation and rendering of pictures under multiple viewports. The entire process also matches the device performance and requires relatively fewer resources, making the solution have good universality.
[0069] Please refer to Figure 2 , the picture rendering process of the main viewport at timestamp A may include:
[0070] (1) Obtain the camera-related parameters of the main viewport. The camera-related parameters include: the position of the camera in the scene, the focus position of the camera, and the field of view of the camera; the field of view can be the camera wide-angle parameter, etc.
[0071] (2) Obtain the timestamp of the current frame of the three-dimensional scene (generally, the real timestamp can be taken, or an increasing integer sequence starting from 0 can be taken, which is used to identify which frame picture in the entire rendering sequence the current frame is).
[0072] (3) Calculate the texture information, FBO (FrameBuffer Object) information, position information, rotation information, scaling information, and information about the actions that the elements in the 3D scene are performing corresponding to the current timestamp respectively. The actions that the elements are performing include, for example, the waving action and the head-shaking action of the characters in the 3D scene. An FBO is a container to which buffers can be added. Textures or render buffer objects can be added to it. The FBO itself cannot be used for rendering. Only after adding a texture or a render buffer can it be used as a rendering target. It provides three types of attachments, namely color attachment, depth attachment, and stencil attachment.
[0073] (4) Record the calculated scene element information into the cache pool.
[0074] A. When recording the element information, use the timestamp as the key value, which is convenient for directly obtaining the corresponding element information from the cache when rendering the content of other cameras at the same timestamp later. By using the timestamp, the rendering timing consistency of different camera views belonging to the same timestamp can be ensured.
[0075] B. Considering the resource limitations of mobile hardware devices, in this embodiment, it is set to store only the element information corresponding to 1 timestamp. At this time, the memory consumption of the terminal is the lowest, and at the same time, the function of rendering information caching can be well satisfied. For example: at timestamp 1, the cache pool records the element information. When reaching timestamp 2, since the element information recorded in the cache pool is not applicable to timestamp 2, all of them will be cleared, and at the same time, the element information corresponding to timestamp 2 will be recorded into the cache pool, which is convenient for other viewports to use when rendering the timestamp 2 screen.
[0076] C. Each time the element information corresponding to a new timestamp is written into the cache pool, clear the element information corresponding to the original timestamp recorded in the cache pool.
[0077] Among them, at the same timestamp, generally, the main viewport screen is rendered first, and then the other viewport screens are rendered. That is: when the main viewport renders the first frame, the other viewports also render the content of the first frame, and there will be no situation where the main viewport renders the first frame while the other viewports render the second or third frame.
[0078] (5) According to the position of the camera of the main viewport in the scene, the camera focus position, and the field of view range of the camera, use the frustum culling technology of OpenGL to calculate the occlusion information between scene elements and determine the elements outside the viewing angle. The elements outside the viewing angle do not participate in the rendering. The principle of the frustum culling technology is: calculate the spatial plane equations of the six faces of the frustum, substitute the point coordinates on the element into the plane equations of the six faces for comparison, so as to judge whether the point is inside the frustum. The elements corresponding to the points not inside the frustum are considered invisible and do not participate in the current rendering.
[0079] (6) Render the final frame of the camera in the main viewport at timestamp A onto the display window of the main viewport according to the perspective projection scheme.
[0080] Please refer to Figure 2 , and the rendering process of the other viewports at timestamp A may include:
[0081] (1) After the current frame rendering of the main viewport at timestamp A is completed and before the next frame rendering of the main viewport starts, trigger the rendering process of the other viewports at timestamp A.
[0082] (2) Obtain the camera-related parameters of the current other viewports, such as the position of the camera in the scene, the position of the camera focus, and the field of view of the camera, etc.
[0083] (3) Obtain timestamp A.
[0084] (4) Try to obtain the element information that has been calculated for the main viewport at timestamp A from the cache pool. If the acquisition fails, execute (5) to (8); if the acquisition is successful, execute (7) to (8).
[0085] (5) Calculate the corresponding position information, rotation information, scaling information, and information about the actions that the elements are performing for each element in the scene at timestamp A respectively.
[0086] (6) Record the calculated element information into the cache pool.
[0087] (7) According to the position of the current other viewport's camera in the scene, the position of the camera focus, and the field of view of the camera, use the frustum culling technology to calculate the occlusion information between the scene elements and determine the elements outside the viewing angle.
[0088] (8) According to the perspective projection scheme, render the final frame of the current other viewport at timestamp A onto the display window of the current other viewport, so as to realize the simultaneous display of the multi-viewport images at timestamp A on the same page.
[0089] Among them, the three-dimensional scene can be a virtual character as Figure 3 shown. According to this embodiment, if the user manually adjusts the outline, headdress, etc. of the virtual character on the page of the terminal device, then the rendered images under different viewports on this page will synchronously display the adjusted content in real time. Figure 3The large window screen in is the rendering screen under the main perspective detail camera, and the small window screen above is the rendering screen under the main perspective panoramic camera. In this example, the main perspective panoramic camera shows the global effect screen of the virtual character, and the main perspective detail camera is used to finely display the detail effect screen of the virtual character. At the same time, it can also be realized that: according to the different facial regions currently edited by the user, the position of the detail camera is dynamically adjusted to ensure that the detail camera screen is always focused on the user's editing area. As Figure 3 shown, in the same screen, the global style of the virtual human face currently being edited and the detail style window of the edited part are displayed at the same time. During the process of finely editing the character, the user can view the global changes brought by the editing in real time, greatly improving the user's creative imagination space and enabling the user to smoothly experience the face pinching function on the mobile device.
[0090] In this embodiment, OpenGL can be specifically used for screen rendering. OpenGL is a widely used 3D graphics library on terminal devices. Since the display device is a 2D plane, OpenGL maps 3D graphics to the 2D screen through coordinate transformation. Through OpenGL coordinate transformation, a 3D object can be projected onto the 2D screen from a given viewing perspective, and then through subsequent rasterization and fragment shading, the entire 3D object is mapped into pixels on the 2D screen. Please refer to Figure 4 , the coordinate transformation process of OpenGL is as Figure 4 shown, Figure 4 The model transformation, view transformation, and projection transformation in are completed by the vertex shader, which determines the position of a primitive in 3D space; the perspective division and viewport transformation are completed in the primitive assembly stage, which determines the position of a primitive on the screen.
[0091] In this embodiment, the time stamp in the 3D space is used as the key value to record and cache the rendering information of the scene elements obtained during the rendering operation of the main viewport. When rendering the content of other viewports at the same time point, this cache is retrieved for the rendering of the content of other viewports, reducing a large amount of repeated rendering operations and data operations, reducing the total rendering duration, and supporting screen rendering on mid - to - low - end devices.
[0092] Next, a screen rendering device provided by an embodiment of the present application will be introduced. The screen rendering device described below can be referred to each other with other embodiments described in this article.
[0093] Refer to Figure 5 shown, an embodiment of the present application discloses a screen rendering device, including:
[0094] An acquisition module 501, configured to acquire a target three - dimensional scene;
[0095] A determination module 502, configured to determine a current rendering timestamp and at least two viewports configured for the current device;
[0096] A processing module 503, configured to calculate element information of each element in a target three-dimensional scene at the rendering timestamp, and cache the element information and the rendering timestamp in a preset buffer;
[0097] A rendering module 504, configured to render, based on the element information in the preset buffer, images of at least two viewports at the rendering timestamp.
[0098] In one implementation, determining a current rendering timestamp and at least two viewports configured for the current device includes:
[0099] Using the current real timestamp as the rendering timestamp; or determining the rendering timestamp according to a preset frame marking rule;
[0100] Configuring at least two viewports for the current device according to the amount of idle resources of the current device.
[0101] In one implementation, calculating element information of each element in a target three-dimensional scene at the rendering timestamp includes:
[0102] For each element in the target three-dimensional scene, calculating the texture information, frame buffer information, position information, rotation information, scaling information, and element action information of the current element itself, to obtain the element information of the current element at the rendering timestamp.
[0103] In one implementation, caching the element information and the rendering timestamp in a preset buffer includes:
[0104] Making the element information and the rendering timestamp form a data pair;
[0105] Caching the data pair in the preset buffer according to the amount of idle resources of the current device and the remaining space of the preset buffer.
[0106] In one implementation, caching the data pair in the preset buffer according to the amount of idle resources of the current device and the remaining space of the preset buffer includes:
[0107] If the amount of idle resources of the current device is greater than a preset resource amount threshold and the remaining space of the preset buffer is greater than a preset space threshold, storing the data pair at an idle address in the preset buffer;
[0108] If the amount of idle resources of the current device is not greater than the preset resource amount threshold, storing the data pair in the preset buffer in a covering manner.
[0109] In one implementation, the rendering process of an image of any viewport at the rendering timestamp includes:
[0110] Obtain the camera parameters under the current viewport;
[0111] Process the element information in the preset buffer according to the camera parameters to obtain the occlusion information between elements and the elements outside the current viewport;
[0112] Process the occlusion information between elements and the elements outside the current viewport in the perspective projection manner, and render to obtain the image of the current viewport at the rendering timestamp.
[0113] In one implementation manner, based on the element information in the preset buffer, render to obtain the images of at least two viewports at the rendering timestamp, including:
[0114] Determine the main viewport among at least two viewports;
[0115] After rendering to obtain the image of the main viewport at the rendering timestamp based on the element information in the preset buffer, then render to obtain the images of the other viewports except the main viewport at the rendering timestamp based on the element information in the preset buffer;
[0116] Display the images of at least two viewports at the rendering timestamp on the same page.
[0117] Among them, for the more specific working processes of each module and unit in this embodiment, reference can be made to the corresponding content disclosed in the foregoing embodiments, and details will not be elaborated herein.
[0118] It can be seen that this embodiment provides a screen rendering device, which can avoid the device CPU from repeatedly processing the relevant information of three-dimensional elements at the same time, save the device CPU resources, and reserve more time for rendering the screens of different viewports.
[0119] Next, an electronic device provided by an embodiment of the present application will be introduced. The electronic device described below can be mutually referred to with other embodiments described herein.
[0120] An embodiment of the present application discloses an electronic device, including:
[0121] A memory for storing a computer program;
[0122] A processor for executing the computer program to implement the method disclosed in any of the foregoing embodiments.
[0123] Further, an embodiment of the present application also provides an electronic device. Among them, the above-mentioned electronic device can be either a server as shown in Figure 6 or a terminal as shown in Figure 7 . Figure 6 And Figure 7These are structural diagrams of electronic devices shown according to an exemplary embodiment. The content in the figures should not be construed as any limitation on the scope of use of this application.
[0124] Figure 6 This is a schematic structural diagram of a server provided by an embodiment of this application. Specifically, the server may include: at least one processor, at least one memory, a power supply, a communication interface, an input / output interface, and a communication bus. Among them, the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the relevant steps in the screen rendering disclosed in any of the foregoing embodiments.
[0125] In this embodiment, the power supply is used to provide working voltage for each hardware device on the server; the communication interface can create a data transmission channel between the server and external devices, and the communication protocol it follows is any communication protocol applicable to the technical solution of this application, and no specific limitation is imposed on it here; the input / output interface is used to obtain external input data or output data to the outside, and its specific interface type can be selected according to specific application needs, and no specific limitation is made here.
[0126] In addition, as a carrier for resource storage, the memory can be a read-only memory, a random access memory, a disk, or an optical disc, etc. The resources stored thereon include an operating system, a computer program, and data, etc., and the storage method can be temporary storage or permanent storage.
[0127] Among them, the operating system is used to manage and control each hardware device and computer program on the server to enable the processor to perform operations and processing on the data in the memory. It can be Windows Server, Netware, Unix, Linux, etc. In addition to the computer program that can be used to complete the screen rendering method disclosed in any of the foregoing embodiments, the computer program can further include a computer program that can be used to complete other specific tasks. In addition to data such as update information of the application program, the data can also include data such as developer information of the application program.
[0128] Figure 7 This is a schematic structural diagram of a terminal provided by an embodiment of this application. Specifically, the terminal may include, but is not limited to, a smart phone, a tablet computer, a notebook computer, or a desktop computer, etc.
[0129] Generally, the terminal in this embodiment includes: a processor and a memory.
[0130] Among them, the processor may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor may also include a main processor and a coprocessor. The main processor is a processor used to process data in the wake state, also known as the CPU (Central Processing Unit); the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor may be integrated with a GPU (Graphics Processing Unit), and the GPU is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor may further include an AI (Artificial Intelligence) processor, and the AI processor is used to process computational operations related to machine learning.
[0131] The memory may include one or more computer-readable storage media, and the computer-readable storage media may be non-transitory. The memory may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices and flash storage devices. In this embodiment, the memory is at least used to store the following computer programs. After the computer programs are loaded and executed by the processor, the relevant steps in the screen rendering method executed by the terminal side disclosed in any of the foregoing embodiments can be implemented. In addition, the resources stored in the memory may also include an operating system and data, etc., and the storage method may be temporary storage or permanent storage. Among them, the operating system may include Windows, Unix, Linux, etc. The data may include, but is not limited to, update information of the application program.
[0132] In some embodiments, the terminal may further include a display screen, an input / output interface, a communication interface, sensors, a power supply, and a communication bus.
[0133] Those skilled in the art can understand that Figure 7 the structure shown in
[0134] does not constitute a limitation on the terminal, and it may include more or fewer components than shown in the figure.
[0135] An embodiment of the present application discloses a readable storage medium for storing a computer program. When the computer program is executed by a processor, it implements the screen rendering method disclosed in the foregoing embodiments. The readable storage medium is a computer-readable storage medium. As a carrier for storing resources, it can be a read-only memory, a random access memory, a magnetic disk, or an optical disc, etc. The resources stored thereon include an operating system, a computer program, and data, etc. The storage method can be short-term storage or permanent storage.
[0136] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. For the same or similar parts among the various embodiments, reference can be made to each other.
[0137] The steps of the method or algorithm described in combination with the embodiments disclosed in this article can be directly implemented by hardware, a software module executed by a processor, or a combination of both. The software module can be placed in a random access memory (RAM), memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, register, hard disk, removable disk, CD-ROM, or any other form of readable storage medium known in the technical field.
[0138] Specific examples are used in this article to elaborate on the principles and implementation manners of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present application.
Claims
1. A method for rendering a picture, characterized in that, it includes: Obtain a target three-dimensional scene; Determine the current rendering timestamp and at least two viewports configured for the current device; wherein, the at least two viewports are configured for the current device according to the amount of idle resources of the current device; the amount of idle resources is the sum of the remaining memory and the remaining CPU resources; Calculate the element information of each element in the target three-dimensional scene at the rendering timestamp, and cache the element information and the rendering timestamp into a preset buffer; Based on the element information in the preset buffer, render the pictures of the at least two viewports at the rendering timestamp; Among them, the rendering the pictures of the at least two viewports at the rendering timestamp based on the element information in the preset buffer includes: Determine a main viewport among the at least two viewports; After rendering the picture of the main viewport at the rendering timestamp based on the element information in the preset buffer, then render the pictures of other viewports except the main viewport at the rendering timestamp based on the element information in the preset buffer; Display the pictures of the at least two viewports at the rendering timestamp on the same page.
2. The method according to claim 1, characterized in that, Determining the current rendering timestamp includes: Taking the current real timestamp as the rendering timestamp; or determining the rendering timestamp according to a preset frame marking rule.
3. The method according to claim 1, characterized in that, The calculating the element information of each element in the target three-dimensional scene at the rendering timestamp includes: For each element in the target three-dimensional scene, calculate the texture information, frame buffer information, position information, rotation information, scaling information and element action information of the current element itself respectively, to obtain the element information of the current element at the rendering timestamp.
4. The method according to claim 1, characterized in that, The caching the element information and the rendering timestamp into a preset buffer includes: Making the element information and the rendering timestamp form a data pair; Caching the data pair into the preset buffer according to the amount of idle resources of the current device and the remaining space of the preset buffer.
5. The method according to claim 4, characterized in that, The caching the data pair into the preset buffer according to the amount of idle resources of the current device and the remaining space of the preset buffer includes: If the amount of idle resources of the current device is greater than a preset resource amount threshold and the remaining space of the preset buffer is greater than a preset space threshold, then store the data pair in the idle address of the preset buffer; If the amount of idle resources of the current device is not greater than the preset resource amount threshold, then store the data pair in the preset buffer in a covering manner.
6. The method according to any one of claims 1 to 5, characterized in that, The rendering process of the picture of any viewport at the rendering timestamp includes: Obtain the camera parameters under the current viewport; Process the element information in the preset buffer according to the camera parameters to obtain the occlusion information between elements and the elements outside the current viewport; Process the occlusion information between elements and the elements outside the current viewport in accordance with the perspective projection method, and render to obtain the image of the current viewport at the rendering timestamp.
7. A picture rendering device, Characterized in that, It includes: An acquisition module for acquiring a target three-dimensional scene; A determination module for determining the current rendering timestamp and at least two viewports configured for the current device; wherein, the at least two viewports are configured for the current device according to the amount of idle resources of the current device; the amount of idle resources is the sum of the remaining memory and the remaining CPU resources; A processing module for calculating the element information of each element in the target three-dimensional scene at the rendering timestamp, and caching the element information and the rendering timestamp into a preset buffer; A rendering module for rendering to obtain the images of the at least two viewports at the rendering timestamp based on the element information in the preset buffer; Wherein, the rendering to obtain the images of the at least two viewports at the rendering timestamp based on the element information in the preset buffer includes: Determine the main viewport among the at least two viewports; After rendering to obtain the image of the main viewport at the rendering timestamp based on the element information in the preset buffer, then render to obtain the images of the other viewports except the main viewport at the rendering timestamp based on the element information in the preset buffer; Display the images of the at least two viewports at the rendering timestamp on the same page.
8. An electronic device, Characterized in that, It includes: A memory for storing a computer program; A processor for executing the computer program to implement the method according to any one of claims 1 to 6.
9. A readable storage medium, Characterized in that, For saving a computer program, wherein the computer program, when executed by a processor, implements the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Real-time interactive control method and real-time interactive control device of virtual object
CN104866101A
Method and system for processing frame at cache
KR100651824B1