Scene rendering method and device, computer equipment and storage medium
Through the hybrid rendering method, the dynamic elements of the virtual scene are rendered in three-dimensional space and the static elements are rendered in two-dimensional space, solving the problem of high consumption of traditional three-dimensional rendering computing resources and achieving the effect of efficient rendering of complex virtual scenes.
Patent Information
- Application Number
- CN202410026098.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-03
- Publication Date
- 2025-07-04
AI Technical Summary
The traditional virtual scene three-dimensional rendering technology consumes a lot of computing resources, resulting in high performance overhead and making it difficult to efficiently render complex virtual scenes.
The hybrid rendering method is adopted to three-dimensional rendering of target dynamic elements in the virtual scene in three-dimensional space and other elements in two-dimensional space. Combined with three-dimensional and two-dimensional rendering technology, it ensures the display effect of the scene screen and saves computing resources.
While ensuring the display effect of scene screens, it effectively saves computing resources, reduces performance overhead, and improves rendering efficiency.
Smart Images

Figure CN120259515A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and particularly to a scene rendering method, apparatus, computer device, storage medium, and computer program product. Background Art
[0002] With the development of computer technology, virtual scenes have emerged. A virtual scene is a visual environment simulated through computer graphics technology, allowing users to operate and interact within it. The display of the virtual scene is usually achieved by rendering the elements in the virtual scene.
[0003] In traditional technologies, three-dimensional rendering is usually performed on the elements in the virtual scene in real time to obtain a three-dimensional virtual scene image with rich visual effects. However, the technical complexity of three-dimensional rendering is relatively high, requiring a large performance overhead and consuming a large amount of computing resources. Summary of the Invention
[0004] Based on this, to address the above technical problems, it is necessary to provide a scene rendering method, apparatus, computer device, computer-readable storage medium, and computer program product that can save computing resources.
[0005] This application provides a scene rendering method, including:
[0006] Obtain a set of scene elements to be displayed in the current viewport of the virtual scene;
[0007] Determine a target dynamic element from the set of scene elements;
[0008] Based on the camera viewing angle in three-dimensional space, map the two-dimensional position of the target dynamic element in the current viewport to the element placement plane in three-dimensional space to obtain the three-dimensional position corresponding to the target dynamic element;
[0009] Based on the three-dimensional position corresponding to the target dynamic element, render the target dynamic element on a three-dimensional scene layer for three-dimensional rendering, and based on the two-dimensional positions of other scene elements in the set of scene elements in the current viewport, render the other scene elements on a two-dimensional scene layer for two-dimensional rendering, to obtain and display the scene image of the virtual scene in the current viewport.
[0010] This application also provides a scene rendering apparatus, including:
[0011] An obtaining module, configured to obtain a set of scene elements to be displayed in the current viewport of the virtual scene;
[0012] A determining module, configured to determine a target dynamic element from the set of scene elements;
[0013] A mapping module, configured to map the two-dimensional position of the target dynamic element in the current viewport to the element placement plane in the three-dimensional space based on the camera viewing angle in the three-dimensional space, so as to obtain the three-dimensional position corresponding to the target dynamic element;
[0014] A rendering module, configured to render the target dynamic element on the three-dimensional scene layer for three-dimensional rendering based on the three-dimensional position corresponding to the target dynamic element, and render the other scene elements on the two-dimensional scene layer for two-dimensional rendering based on the two-dimensional positions of the other scene elements in the scene element set in the current viewport, so as to obtain and display the scene picture of the virtual scene in the current viewport.
[0015] This application also provides a computer device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the steps of the above-mentioned scene rendering method are implemented.
[0016] This application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned scene rendering method are implemented.
[0017] This application also provides a computer program product, including a computer program. When the computer program is executed by a processor, the steps of the above-mentioned scene rendering method are implemented.
[0018] For the above-mentioned scene rendering method, device, computer device, storage medium and computer program product, the scene element set to be displayed in the current viewport of the virtual scene is obtained, the target dynamic element is determined from the scene element set, and based on the camera viewing angle in the three-dimensional space, the two-dimensional position of the target dynamic element in the current viewport is mapped to the element placement plane in the three-dimensional space to obtain the three-dimensional position corresponding to the target dynamic element. Based on the three-dimensional position corresponding to the target dynamic element, the target dynamic element is rendered on the three-dimensional scene layer for three-dimensional rendering, and based on the two-dimensional positions of the other scene elements in the scene element set in the current viewport, the other scene elements are rendered on the two-dimensional scene layer for two-dimensional rendering, so as to obtain and display the scene picture of the virtual scene in the current viewport. In this way, the target dynamic elements of the virtual scene are rendered on the three-dimensional scene layer, and the other scene elements are rendered on the two-dimensional scene layer. When displaying the scene picture of the virtual scene, three-dimensional rendering and two-dimensional rendering are combined, which can effectively save computing resources and performance overhead on the basis of ensuring the display effect of the scene picture. Moreover, based on the camera viewing angle in the three-dimensional space, accurate mapping of the same scene element between the two-dimensional scene layer and the three-dimensional scene layer is realized, ensuring the alignment of the scene elements between the two-dimensional scene layer and the three-dimensional scene layer, and further ensuring the display effect of the scene picture. Description of the Drawings
[0019] To more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the following will briefly introduce the accompanying drawings required for the description of the embodiments or related technologies. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can also be obtained based on these drawings.
[0020] Figure 1 It is an application environment diagram of the scene rendering method in an embodiment;
[0021] Figure 2 It is a schematic flowchart of the scene rendering method in an embodiment;
[0022] Figure 3 It is a schematic diagram of the 2D plane scene layer and the 3D space scene layer in an embodiment;
[0023] Figure 4 It is a schematic diagram of the mapping scheme of 2D coordinates and 3D coordinates in an embodiment;
[0024] Figure 5 It is a schematic diagram of the dynamic and static switching of single elements in an embodiment;
[0025] Figure 6 It is a schematic diagram of the same-screen playback strategy in an embodiment;
[0026] Figure 7 It is a schematic diagram of various situations for triggering dynamic and static switching events in an embodiment;
[0027] Figure 8 It is a schematic diagram of the contact dynamic square in an embodiment;
[0028] Figure 9 It is a schematic flowchart of the scene rendering method in another embodiment;
[0029] Figure 10 It is a schematic diagram of the home page of the instant messaging application in an embodiment;
[0030] Figure 11 It is a schematic diagram of the status setting page in an embodiment;
[0031] Figure 12 It is a schematic diagram of the friend dynamic square in an embodiment;
[0032] Figure 13 It is a structural block diagram of the scene rendering device in an embodiment;
[0033] Figure 14 It is an internal structure diagram of a computer device in an embodiment. Detailed implementation manners
[0034] In order to make the purpose, technical solutions and advantages of this application clearer, the following further details this application in combination with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not used to limit this application.
[0035] Artificial Intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. In other words, artificial intelligence is a comprehensive technology in computer science. It attempts to understand the essence of intelligence and produce a new intelligent machine that can react in a way similar to human intelligence. Artificial intelligence also studies the design principles and implementation methods of various intelligent machines, enabling the machines to have the functions of perception, reasoning and decision-making.
[0036] Artificial intelligence technology is an interdisciplinary subject, involving a wide range of fields, including both hardware-level and software-level technologies. Artificial intelligence basic technologies generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technology, pre-trained model technology, operation / interaction systems, and mechatronics. Among them, pre-trained models, also known as large models or basic models, can be widely applied to downstream tasks in various directions of artificial intelligence after fine-tuning. Artificial intelligence software technologies mainly include several major directions such as computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning.
[0037] Computer Vision (CV) is a science that studies how to enable machines to "see". Further, it refers to using cameras and computers to replace human eyes to perform machine vision such as object recognition, tracking and measurement on targets, and further performing graphic processing to make the computer-processed images more suitable for human eyes to observe or be transmitted to instruments for detection. As a scientific discipline, computer vision studies related theories and technologies, and attempts to establish an artificial intelligence system that can obtain information from images or multi-dimensional data. Large model technology has brought important changes to the development of computer vision technology. Pre-trained models in the visual field such as swin-transformer, ViT, V-MOE, and MAE can be quickly and widely applied to downstream specific tasks after fine-tuning. Computer vision technology usually includes technologies such as image processing, image recognition, image semantic understanding, image retrieval, OCR, video processing, video semantic understanding, video content / behavior recognition, three-dimensional object reconstruction, 3D technology, virtual reality, augmented reality, simultaneous localization and mapping, and also includes common biometric recognition technologies such as face recognition and fingerprint recognition.
[0038] The solution provided by the embodiments of this application relates to technologies such as computer vision technology in artificial intelligence, and is specifically illustrated through the following embodiments:
[0039] The scene rendering method provided by the embodiments of this application can be applied to an application environment as Figure 1 shown. Among them, the terminal 102 communicates with the server 104 through the network. The data storage system can store the data that the server 104 needs to process. The data storage system can be integrated on the server 104, or placed in the cloud or other network servers. The terminal 102 can be, but is not limited to, various personal computers, laptop computers, smart phones, tablet computers, Internet of Things devices, and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. The portable wearable devices can be smart watches, smart bracelets, head-mounted devices, etc. The server 104 can be implemented by an independent server or a server cluster or cloud server composed of multiple servers.
[0040] Specifically, the terminal obtains the set of scene elements to be displayed in the current viewport of the virtual scene from the server. The terminal determines the target dynamic element from the set of scene elements, and based on the camera viewing angle in the three-dimensional space, maps the two-dimensional position of the target dynamic element in the current viewport to the element placement plane in the three-dimensional space to obtain the three-dimensional position corresponding to the target dynamic element. The terminal renders the target dynamic element on the three-dimensional scene layer for three-dimensional rendering based on the three-dimensional position corresponding to the target dynamic element, and renders the other scene elements on the two-dimensional scene layer for two-dimensional rendering based on the two-dimensional positions of the other scene elements in the current viewport, and obtains and displays the scene picture of the virtual scene in the current viewport.
[0041] In one embodiment, as Figure 2 shown, a scene rendering method is provided, and this method is illustrated by taking the terminal in Figure 1 as an example. Among them:
[0042] Step S202, obtain the set of scene elements to be displayed in the current viewport of the virtual scene.
[0043] Among them, a virtual scene refers to a digital environment constructed through technologies such as computer technology, digital media, and network communication. The virtual scene can be a purely fictional environment, a simulated environment of the real world, or a semi-simulated and semi-fictional virtual environment. The application scenarios of virtual scenes are very extensive. For example, in the business field, virtual scenes can be used for product display; in the education field, virtual scenes can be used for teaching activities such as experimental simulation and practical operation; in the game field, virtual scenes can be used for game design; in the field of architectural design, virtual scenes can be used for architectural design, interior decoration, etc.; in the social field, virtual scenes can be used for social interaction; and so on.
[0044] The current viewport refers to the interface of the terminal currently used to display the virtual scene. For example, when displaying a virtual scene on a mobile device, the current viewport usually refers to the display window of the mobile device.
[0045] Scene elements refer to the elements included in the virtual scene. For example, scene elements can be buildings, props, and characters in the virtual scene. The scene element set includes multiple elements included in the virtual scene. The scene element set includes at least one of the dynamic elements and static elements included in the virtual scene. Dynamic elements refer to scene elements that will change, will undergo complex changes, or need to play animations in the virtual scene. For example, dynamic elements can be characters that need to play animations, character props that need to move with the characters, etc. Static elements refer to scene elements that are static or will undergo simple changes in the virtual scene. For example, static elements can be static background images, buildings. Static elements are the basic framework and background for constructing the virtual scene, while dynamic elements are the key factors that endow the virtual scene with life and vitality. Through the method of the present application, in the virtual scene, reasonably using static elements and dynamic elements can create a more realistic and vivid effect, improving the user's immersion and experience.
[0046] The scene element set to be displayed in the current viewport of the virtual scene includes multiple scene elements to be displayed in the current viewport of the virtual scene. It can be understood that the display area of the current viewport is limited, and the current viewport usually displays a partial area of the virtual scene. Users can view other areas of the virtual scene by moving or zooming in the current viewport.
[0047] Specifically, the terminal can obtain the scene element set to be displayed in the current viewport of the virtual scene from the server, perform three-dimensional rendering on a part of the scene elements in the scene element set, perform two-dimensional rendering on another part of the elements, and obtain and display the scene picture of the virtual scene in the current viewport.
[0048] Step S204, determine the target dynamic elements from the scene element set.
[0049] Specifically, the terminal can determine the target dynamic element from the scene element set. For example, considering the characteristics of dynamic elements and static elements, each dynamic element in the scene element set can be used as a target dynamic element; further considering the rendering performance, several dynamic elements can be randomly selected from the scene element set as target dynamic elements; and so on. The target dynamic element is used for three-dimensional rendering (i.e., 3D rendering) to ensure the visual expressiveness of the scene picture.
[0050] Step S206, based on the camera observation angle in the three-dimensional space, the two-dimensional position of the target dynamic element in the current viewport is mapped to the element placement plane in the three-dimensional space to obtain the three-dimensional position corresponding to the target dynamic element.
[0051] Among them, the camera observation angle refers to the observation direction of the camera in three-dimensional space (i.e., 3D space). In 3D space, the camera observation angle is used to observe 3D scenes and is usually determined by the position and orientation of the camera. The camera observation angle usually determines how the user sees the virtual scene. By adjusting the position and orientation of the camera, different perspective effects can be created, such as observing from a distance, looking down from the air, and looking sideways from a corner. The camera observation angle is pre-set and can be determined according to specific application scenarios and needs to achieve the best visual effects and user experience. For example, for game scenarios, game developers set the camera observation angle when developing games to achieve the best visual effects for the game screen.
[0052] The element placement plane refers to the plane in 3D space used to place scene elements. In 3D space, 3D elements are placed on a specific plane to create a visual effect. The element placement plane is pre-set and can be determined according to specific application scenarios and requirements to achieve the best visual effect and user experience. For example, for game scenes, game developers set the element placement plane when developing games to achieve the best visual effect for the game screen.
[0053] The two-dimensional position of the scene element in the current viewport refers to the two-dimensional position of the scene element on the display interface. For example, a two-dimensional coordinate system is established according to the current viewport, and the coordinates of the scene element in the two-dimensional coordinate system are the two-dimensional position of the scene element in the current viewport.
[0054] Specifically, the terminal knows the two-dimensional positions of each scene element in the current viewport in the set of scene elements. The target dynamic element in the set of scene elements can enrich the visual effect and sense of space through 3D rendering. To perform 3D rendering on the target dynamic element, it is necessary to determine the corresponding three-dimensional position of the target dynamic element. To ensure the accurate display of the target dynamic element, it is necessary to align the two-dimensional position and the three-dimensional position corresponding to the target dynamic element. The terminal can map the two-dimensional position of the target dynamic element in the current viewport to the element placement plane in the three-dimensional space based on the camera viewing angle in the three-dimensional space, and obtain the corresponding three-dimensional position of the target dynamic element. The camera viewing angle is the angle for observing the 3D scene. Based on the camera viewing angle, mapping the two-dimensional position of the target dynamic element in the current viewport to the element placement plane in the three-dimensional space can accurately align the two-dimensional position and the mapped three-dimensional position, that is, it can make the two-dimensional position and the three-dimensional position overlap when displayed, thereby ensuring that the display positions of each scene element are correct when combining 2D rendering and 3D rendering.
[0055] In one embodiment, the element placement plane in the three-dimensional space is a plane that is not parallel to the coordinate axes of the space coordinate system in the three-dimensional space. That is, the element placement plane in the three-dimensional space is an inclined plane. Such an element placement plane can reduce the phenomenon of crosstalk between different scene elements during display. The crosstalk phenomenon refers to the phenomenon where different scene elements penetrate and overlap each other.
[0056] Step S208: Render the target dynamic element on the three-dimensional scene layer for 3D rendering based on the corresponding three-dimensional position of the target dynamic element, and render other scene elements on the two-dimensional scene layer for 2D rendering based on the two-dimensional positions of other scene elements in the current viewport, to obtain and display the scene image of the virtual scene in the current viewport.
[0057] Among them, the three-dimensional scene layer refers to the canvas responsible for 3D rendering. That is, the three-dimensional scene layer refers to the layer responsible for 3D rendering. Correspondingly, the two-dimensional scene layer refers to the canvas responsible for 2D rendering. That is, the two-dimensional scene layer refers to the layer responsible for 2D rendering. It can be understood that 2D rendering mainly refers to the drawing and processing of images on a two-dimensional plane, while 3D rendering is to create, process, and present realistic images in a three-dimensional space. 2D rendering is a rendering technology based on a plane, implemented based on a plane coordinate system and 2D image information, usually simpler, faster, and suitable for planar and simple scenes. 2D rendering can use pixels or vector graphics to generate images. 3D rendering is more complex and realistic, implemented based on a three-dimensional coordinate system and 3D image information, and can create images with depth, perspective, and a sense of reality. 3D rendering uses technologies such as three-dimensional models, texture mapping, lighting, and shadows to generate images.
[0058] Specifically, the target dynamic elements in the scene element set need to be rendered in 3D to ensure the visual expressiveness of the scene picture, and other dynamic elements and static elements in the scene element set need to be rendered in 2D to balance the performance overhead of scene rendering. For the target dynamic elements in the scene element set, the terminal renders the target dynamic elements in the three-dimensional scene layer based on the three-dimensional position corresponding to the target dynamic elements, and improves the visual expressiveness of the target dynamic elements through 3D rendering. For other scene elements in the scene element set, the terminal renders other scene elements in the two-dimensional scene layer based on the two-dimensional position of other scene elements in the current viewport, and saves computing resources through 2D rendering to balance the performance overhead required for scene rendering. The terminal obtains the scene picture of the virtual scene in the current viewport based on the rendering results of each scene element in the scene element set, and the terminal displays the scene picture.
[0059] For example, if a user starts a game on the terminal, the terminal obtains a set of scene elements to be displayed in the current viewport of the game scene. The scene element set includes dynamic elements and static elements. The dynamic elements can be game characters, and the static elements can be game backgrounds. Based on the camera observation angle in the three-dimensional space, the two-dimensional position of the dynamic elements in the current viewport is mapped to the element placement plane in the three-dimensional space to obtain the three-dimensional position corresponding to the dynamic elements. Based on the three-dimensional position corresponding to the dynamic elements, the dynamic elements are rendered in 3D on the 3D canvas. Based on the two-dimensional position of the static elements in the current viewport, the static elements are rendered in 2D on the 2D canvas. The game screen of the game scene in the current viewport is obtained by rendering, and the terminal displays the game screen to the user.
[0060] In one embodiment, when developing a virtual scene, the developer can design the two-dimensional position of each scene element in the virtual scene in the two-dimensional scene layer, that is, determine the position of all scene elements in the virtual scene on a large two-dimensional canvas. When displaying the virtual scene, the two-dimensional position of the scene element to be displayed in the virtual scene in the current viewport in the two-dimensional scene layer can be converted to the two-dimensional position in the current viewport.
[0061] In the above scene rendering method, a set of scene elements to be displayed in the current viewport of the virtual scene is obtained, a target dynamic element is determined from the set of scene elements, and based on the camera viewing angle in the three-dimensional space, the two-dimensional position of the target dynamic element in the current viewport is mapped to the element placement plane in the three-dimensional space to obtain the three-dimensional position corresponding to the target dynamic element. Based on the three-dimensional position corresponding to the target dynamic element, the target dynamic element is rendered on the three-dimensional scene layer for three-dimensional rendering. Based on the two-dimensional positions of other scene elements in the set of scene elements in the current viewport, the other scene elements are rendered on the two-dimensional scene layer for two-dimensional rendering, and the scene image of the virtual scene in the current viewport is obtained and displayed. In this way, the target dynamic elements of the virtual scene are rendered on the three-dimensional scene layer, and other scene elements are rendered on the two-dimensional scene layer. By combining three-dimensional rendering and two-dimensional rendering when displaying the scene image of the virtual scene, it is possible to effectively save computing resources and performance overhead while ensuring the display effect of the scene image. Moreover, based on the camera viewing angle in the three-dimensional space, an accurate mapping of the same scene element between the two-dimensional scene layer and the three-dimensional scene layer is realized, ensuring the alignment of the scene elements between the two-dimensional scene layer and the three-dimensional scene layer, and further ensuring the display effect of the scene image.
[0062] In one embodiment, refer to Figure 3 , the canvas for rendering is divided into two layers, the upper layer is the two-dimensional scene layer, and the lower layer is the three-dimensional scene layer. The two-dimensional scene layer can be a 2D plane scene layer implemented based on Native, which is responsible for rendering 2D plane elements. Native is an application development framework developed based on native languages. The three-dimensional scene layer can be a 3D space scene layer implemented based on a 3D engine, which is responsible for rendering 3D elements with model animations. The display interface of the terminal is mapped to the two-dimensional scene layer to obtain a 2D viewport. What the user sees through the terminal is usually presented in the 2D viewport. The display interface of the terminal is mapped to the three-dimensional scene layer to obtain a 3D camera viewport (i.e., a 3D viewport). The 2D viewport and the 3D viewport theoretically coincide. The absolute sizes of the 2D viewport and the 3D viewport are the size of the display interface. The two-dimensional scene layer is also responsible for intercepting user interaction events (such as single-click, double-click, swipe, two-finger zoom, etc.) and processing the user interaction events. The two-dimensional scene layer can also transfer the user interaction events and the intermediate processing results of the user interaction events to the three-dimensional scene layer. For example, the two-dimensional scene layer can be responsible for the mapping between 2D coordinates and 3D coordinates, and transfer the mapped 3D coordinates to the three-dimensional scene layer so that the three-dimensional scene layer can process the user interaction events. When the 2D viewport changes, it will synchronously drive the 3D viewport to change. For example, when the user swipes in the display interface of the terminal, the 2D viewport will move, and correspondingly, the 3D viewport will also move; when the user zooms in the display interface of the terminal, the content of the 2D viewport will change, and correspondingly, the content of the 3D viewport will change.
[0063] In one embodiment, determining a target dynamic element from a set of scene elements includes:
[0064] Obtain the current upper limit of the number of elements played on the same screen; when the number of dynamic elements in the set of scene elements is greater than the current upper limit of the number of elements played on the same screen, select dynamic elements matching the current upper limit of the number of elements played on the same screen from the set of scene elements as the target dynamic elements respectively; when the number of dynamic elements in the set of scene elements is less than or equal to the current upper limit of the number of elements played on the same screen, use each dynamic element in the set of scene elements as the target dynamic element respectively.
[0065] Wherein, the upper limit of the number of elements played on the same screen refers to the upper limit of the number of scene elements allowed to be 3D-rendered in a viewport. That is, the upper limit of the number of elements played on the same screen refers to the upper limit of the number of scene elements allowed to play 3D animations in a viewport. The upper limit of the number of elements played on the same screen can be a preset fixed value or a dynamic value that changes. The current upper limit of the number of elements played on the same screen refers to the upper limit of the number of elements played on the same screen corresponding to the current viewport.
[0066] Specifically, in order to further save computing resources, the dynamic elements that need to be 3D-rendered can be controlled. The terminal can obtain the current upper limit of the number of elements played on the same screen, compare the number of dynamic elements in the set of scene elements with the current upper limit of the number of elements played on the same screen. If the number of dynamic elements in the set of scene elements is greater than the current upper limit of the number of elements played on the same screen, select dynamic elements matching the current upper limit of the number of elements played on the same screen from the set of scene elements as the target dynamic elements respectively to save computing resources. For example, if the current upper limit of the number of elements played on the same screen is 10 and the number of dynamic elements in the set of scene elements is 30, randomly select 10 dynamic elements from the 30 dynamic elements as the target dynamic elements for 3D rendering respectively. It can be understood that when selecting dynamic elements from the set of scene elements, it can be random selection or selection according to certain rules. If the number of dynamic elements in the set of scene elements is less than or equal to the current upper limit of the number of elements played on the same screen, use each dynamic element in the set of scene elements as the target dynamic element respectively to ensure the visual effect.
[0067] In the above embodiment, when the number of dynamic elements in the set of scene elements is greater than the current upper limit of the number of elements played on the same screen, selecting dynamic elements matching the current upper limit of the number of elements played on the same screen from the set of scene elements as the target dynamic elements respectively can reduce the performance overhead during rendering. When the number of dynamic elements in the set of scene elements is less than or equal to the current upper limit of the number of elements played on the same screen, using each dynamic element in the set of scene elements as the target dynamic element respectively can ensure the visual expressiveness of the rendering result.
[0068] In one embodiment, the obtaining method of the current upper limit of the number of elements played on the same screen includes at least one of the following:
[0069] Determine the upper limit of the current simultaneous playback quantity based on the current terminal load level; the upper limit of the current simultaneous playback quantity is positively correlated with the current terminal load level, and the current terminal load level is positively correlated with the current terminal load quantity;
[0070] Determine the upper limit of the current simultaneous playback quantity based on the content display size corresponding to the current viewport; the upper limit of the current simultaneous playback quantity is negatively correlated with the content display size.
[0071] Among them, the terminal load level is used to reflect the load situation of the mobile phone. The terminal load level is related to the terminal load quantity. The larger the terminal load quantity, the higher the terminal load level. The terminal load quantity is determined based on the usage conditions of at least one performance parameter such as the CPU, memory, and GPU of the terminal. The current terminal load level refers to the terminal load level corresponding to the terminal currently. The current terminal load quantity refers to the terminal load quantity corresponding to the terminal currently. The current terminal load level and the current terminal load quantity are positively correlated, that is, the larger the current terminal load quantity, the higher the current terminal load level.
[0072] Specifically, the upper limit of the simultaneous playback quantity can be a dynamic value that will change. The terminal can obtain the current terminal load level and determine the upper limit of the current simultaneous playback quantity based on the current terminal load level. The upper limit of the current simultaneous playback quantity is positively correlated with the current terminal load level. The higher the current terminal load level, it indicates that there are more or more complex tasks to be processed by the current terminal. At this time, when rendering the virtual scene, adopting a smaller upper limit of the current simultaneous playback quantity can avoid greatly increasing the terminal computing pressure.
[0073] Among them, the content display size corresponding to the current viewport refers to the display ratio of the scene elements in the current viewport. The larger the content display size, the larger the size of the scene elements in the current viewport. It can be understood that the user can trigger a zoom-out operation in the current viewport to reduce the content display size, so as to reduce the scene elements so that the current viewport can display more scene elements. The user can trigger a zoom-in operation in the current viewport to enlarge the content display size to enlarge the scene elements.
[0074] Specifically, the upper limit of the simultaneous playback quantity can be a dynamic value that will change. The terminal can obtain the content display size corresponding to the current viewport and determine the upper limit of the current simultaneous playback quantity based on the content display size corresponding to the current viewport. The upper limit of the current simultaneous playback quantity is negatively correlated with the content display size. The smaller the content display size, it indicates that there are more scene elements to be displayed by the current terminal. At this time, when rendering the virtual scene, adopting a larger upper limit of the current simultaneous playback quantity can enrich the visual expressiveness of the rendering result.
[0075] It can be understood that the terminal can also determine the upper limit of the current simultaneous playback quantity based on the current terminal load level and the content display size corresponding to the current viewport.
[0076] In one embodiment, selecting dynamic elements that match the current upper limit of the number of elements played on the same screen from the set of scene elements as target dynamic elements respectively includes:
[0077] Based on the distance between the two-dimensional position of the dynamic elements in the scene element set and the center position of the current viewport, determining the selection weights corresponding to each dynamic element in the scene element set respectively; the selection weight is negatively correlated with the distance; based on the selection weights corresponding to each dynamic element respectively, selecting dynamic elements that match the current upper limit of the number of elements played on the same screen from the scene element set as target dynamic elements respectively.
[0078] Among them, the selection weight corresponding to a dynamic element refers to the weight and probability of selecting the dynamic element as a target dynamic element. The selection weight corresponding to a dynamic element is related to the distance between the dynamic element and the center position in the current viewport. The closer the distance, the higher the selection weight.
[0079] Specifically, the terminal can randomly select several dynamic elements from the scene element set as target dynamic elements respectively, and the number of selected elements is equal to the current upper limit of the number of elements played on the same screen. The terminal can also select several dynamic elements from the scene element set as target dynamic elements respectively based on the selection weights corresponding to each dynamic element in the scene element set, and the number of selected elements is equal to the current upper limit of the number of elements played on the same screen. The closer the distance between the two-dimensional position of the dynamic element in the current viewport and the center position of the current viewport, the more centered the dynamic element is, and the user usually pays more attention to the scene elements in the middle of the screen. Therefore, the more centered the dynamic element is, the higher the selection weight corresponding to the dynamic element, and the higher the probability that the dynamic element is selected as a target dynamic element for 3D rendering.
[0080] In the above embodiment, when selecting dynamic elements from the scene element set as target dynamic elements, the selection is made according to the selection weights corresponding to the dynamic elements. The more centered the dynamic element is in the current viewport, the higher the selection weight, so as to increase the probability of 3D rendering of the more centered dynamic elements in the current viewport, making the dynamic elements in the area that the user pays more attention to in the current viewport have stronger visual expressiveness. In terms of the user's senses, the perspective effect obtained by selecting relatively centered dynamic elements for 3D rendering is better than the perspective effect obtained by randomly selecting dynamic elements for 3D rendering.
[0081] In one embodiment, based on the camera viewing angle in the three-dimensional space, mapping the two-dimensional position of the target dynamic element in the current viewport to the element placement plane in the three-dimensional space to obtain the corresponding three-dimensional position of the target dynamic element, including:
[0082] Determine the viewport position of the current viewport in three-dimensional space based on the camera viewing range in three-dimensional space and the viewport size of the current viewport; within the viewport position of the current viewport in three-dimensional space, starting from the two-dimensional coordinate point of the target dynamic element in the current viewport, emit a ray along the camera viewing angle direction in three-dimensional space, and use the three-dimensional coordinates corresponding to the intersection point of the ray and the element placement plane in three-dimensional space as the three-dimensional position corresponding to the target dynamic element.
[0083] Among them, the camera viewing range refers to the viewing range of the camera in three-dimensional space. The camera viewing range is the space visible to the camera in three-dimensional space. The camera viewing range is usually a frustum of a cone, and the frustum of a cone is a conical field of view formed from near to far. If the frustum of a cone is regarded as a pyramid structure, the camera is located at the top of the pyramid.
[0084] The viewport size of the current viewport refers to the size of the current viewport. The viewport position of the current viewport in three-dimensional space is used to indicate the area occupied by the current viewport in three-dimensional space.
[0085] Specifically, when determining the 3D coordinates of the target dynamic element based on the 2D coordinates of the target dynamic element, the terminal determines the viewport position of the current viewport in three-dimensional space, and then maps the 2D coordinates along the camera viewing angle within the viewport position to the element placement plane to obtain the 3D coordinates aligned with the 2D coordinates.
[0086] The terminal determines the viewport position of the current viewport in three-dimensional space based on the camera viewing range in three-dimensional space and the viewport size of the current viewport. A plane that matches the viewport size can be used as the viewport position of the current viewport from the camera viewing range. For example, the position of a plane parallel to the top surface of the frustum of a cone and with a plane size equal to the viewport size within the frustum of a cone can be used as the viewport position. The two-dimensional position of the target dynamic element in the current viewport is the position of the target dynamic element in the viewport plane coordinate system established based on the current viewport, and the two-dimensional position is represented by a two-dimensional coordinate point in the viewport plane coordinate system. Within the viewport position of the current viewport in three-dimensional space, starting from the two-dimensional coordinate point of the target dynamic element in the current viewport, emit a ray along the camera viewing angle direction in three-dimensional space, and the ray intersects the element placement plane in three-dimensional space. The terminal uses the three-dimensional coordinates corresponding to the intersection point of the ray and the element placement plane in three-dimensional space as the three-dimensional position corresponding to the target dynamic element.
[0087] In one embodiment, refer to Figure 4Describe the mapping process between 2D coordinates and 3D coordinates. Among them, the x-axis, y-axis, and z-axis form a 3D coordinate system (i.e., 3D space coordinate system). The plane filled with oblique lines is the plane for placing elements in 3D space. After the 2D coordinates of the scene elements are converted through coordinate conversion, they will eventually fall on the element placement plane. The unfilled rectangle is the current viewport (which can also be called the camera viewport). The two solid arrows passing through the current viewport describe the plane coordinate system with the lower left corner of the current viewport as the origin, that is, the viewport coordinate system. The four dashed arrows passing through the current viewport are used to determine the camera view range, and the intersection point of the four dashed arrows is the position of the camera in 3D space. (x, y) is the plane coordinate of the dynamic element after being converted from the plane coordinate in the two-dimensional scene layer to the viewport coordinate system. (x’, y’, z’) is the spatial coordinate of (x, y) mapped to the 3D space coordinate system, and (x’, y’, z’) is located on the element placement plane.
[0088] Calculate the plane coordinates (x, y) of the dynamic element in the plane coordinate system with the lower left corner of the current viewport as the origin, the right direction as the positive direction of the X-axis, and the upper direction as the positive direction of the Y-axis. Then, in 3D space, start from (x, y) and emit a ray along the camera viewing angle (i.e., the viewing direction of the camera in 3D space). The intersection point (x’, y’, z’) of the ray and the preset element placement plane in 3D space is the 3D coordinate point of the dynamic element in 3D space. In this way, based on the 2D coordinates, the 3D coordinates mapped along the camera viewing angle can be perfectly aligned with the 2D coordinates.
[0089] In the above embodiment, the two-dimensional coordinate point of the target dynamic element in the current viewport is the 2D coordinate of the target dynamic element. The camera viewing angle and the element placement plane in the three-dimensional space determine the way the user sees the 3D element. From the viewport position of the current viewport in the three-dimensional space, mapping the 2D coordinates along the camera viewing angle to the element placement plane to obtain the 3D coordinates can accurately align the 2D coordinates and the 3D coordinates. The positions of the target dynamic element displayed based on the 2D coordinates and the 3D coordinates are the same.
[0090] In one embodiment, based on the three-dimensional position corresponding to the target dynamic element, render the target dynamic element in the three-dimensional scene layer for three-dimensional rendering. Based on the two-dimensional positions of other scene elements in the current viewport in the scene element set, render the other scene elements in the two-dimensional scene layer for two-dimensional rendering, and obtain and display the scene picture of the virtual scene in the current viewport, including:
[0091] Based on the three-dimensional position corresponding to the target dynamic element, render the three-dimensional model information of the target dynamic element on the three-dimensional scene layer for three-dimensional rendering to obtain the three-dimensional animation corresponding to the target dynamic element; based on the two-dimensional positions of other scene elements in the scene element set in the current viewport, render the two-dimensional plane information of the other scene elements on the two-dimensional scene layer to obtain the two-dimensional images corresponding to the other scene elements; the two-dimensional plane information includes any one of two-dimensional static image information, two-dimensional animated image information, and two-dimensional video information; based on the three-dimensional animation corresponding to the target dynamic element and the two-dimensional images corresponding to the other scene elements, obtain the scene image of the virtual scene in the current viewport and display it.
[0092] Among them, the three-dimensional model information of the dynamic element is used to describe the 3D model of the dynamic element. The three-dimensional model information of the dynamic element includes various attributes and features of the 3D model of the dynamic element. For example, it includes the geometric shape, material, texture, lighting, etc. of the 3D model. The 3D model information is the basis for 3D animation production. Based on the 3D model information, 3D rendering is performed to obtain a three-dimensional animation. The three-dimensional animation shows the process of the movement and change of an object through a series of continuous 3D images.
[0093] The two-dimensional plane information of the scene element is used to describe the two-dimensional image information of the scene element. The two-dimensional plane information includes any one of two-dimensional static image information, two-dimensional animated image information, and two-dimensional video information. The two-dimensional static image information is used to describe the two-dimensional static image of the scene element. The two-dimensional static image refers to a static two-dimensional picture. The two-dimensional static image information includes various attributes and features of the two-dimensional static image. The two-dimensional animated image information is used to describe the two-dimensional animated image of the scene element. The two-dimensional animated image is composed of a series of continuous two-dimensional static images. The two-dimensional static image information includes various attributes and features of a series of two-dimensional static images. The two-dimensional animated image can be regarded as an animation presented in the form of a plane picture. The two-dimensional video information is used to describe the two-dimensional video of the scene element. The two-dimensional video is composed of a series of continuous two-dimensional static images. Compared with the two-dimensional animated image, the two-dimensional video can also have audio. The two-dimensional video information includes various attributes and features of a series of two-dimensional static images, and can even include audio features. The two-dimensional static images, two-dimensional animated images, and two-dimensional videos of the scene element can be pre-set. For example, for a game scene, developers design the two-dimensional static images of the scene element, design the two-dimensional animated images of the scene element, and design the two-dimensional videos of the scene element when developing the game. The two-dimensional plane information is the basis for 2D plane production. Based on the two-dimensional plane information, 2D rendering is performed to obtain a two-dimensional image. The two-dimensional image shows an object through one or a series of continuous 2D images. The two-dimensional static images, two-dimensional animated images, and two-dimensional videos of the scene element can also be determined based on the 3D rendering results.
[0094] Specifically, when performing 3D rendering, the terminal obtains the three-dimensional model information of the target dynamic element in the scene element set, and based on the three-dimensional position corresponding to the target dynamic element, renders the three-dimensional model information of the target dynamic element on the three-dimensional scene layer to obtain the three-dimensional animation corresponding to the target dynamic element. The three-dimensional position corresponding to the target dynamic element is used to determine the display position of the three-dimensional animation, and the three-dimensional model information of the target dynamic element is used to determine the content of the three-dimensional animation. When performing 2D rendering, the terminal obtains the two-dimensional plane information of other scene elements in the scene element set, and based on the two-dimensional position of other scene elements in the current viewport, renders the two-dimensional plane information of other scene elements on the two-dimensional scene layer to obtain the two-dimensional picture corresponding to other scene elements. The two-dimensional position of other scene elements in the current viewport is used to determine the display position of the two-dimensional picture, and the two-dimensional plane information of other scene elements is used to determine the content of the two-dimensional picture. Finally, the terminal combines the three-dimensional animation corresponding to the target dynamic element and the two-dimensional picture corresponding to other scene elements to obtain the scene picture of the virtual scene in the current viewport, and displays the scene picture of the virtual scene in the current viewport.
[0095] In the above embodiment, the scene element obtains a 3D animation through 3D rendering, and the scene element obtains a 2D picture (2D still image or 2D animated image or 2D video) through 2D rendering. The 3D animation and the 2D picture are combined to obtain the scene picture. The 3D animation in the scene picture can enrich the visual expression, and the 2D picture in the scene picture helps to reduce the computing resources and performance overhead.
[0096] In one embodiment, the scene rendering method further includes:
[0097] In response to the static-dynamic switching event for the target dynamic element, remove the target dynamic element from the three-dimensional scene layer, add the target dynamic element to the two-dimensional scene layer; based on the two-dimensional position of the target dynamic element in the current viewport, render the target dynamic element on the two-dimensional scene layer.
[0098] Among them, the static-dynamic switching event refers to the event of switching between 2D rendering and 3D rendering of the scene element. If the static-dynamic switching event is triggered when the scene element uses 3D rendering, the scene element is switched from using 3D rendering to using 2D rendering. If the static-dynamic switching event is triggered when the scene element uses 2D rendering, the scene element is switched from using 2D rendering to using 3D rendering. The static-dynamic switching event can be triggered by the user. For example, the user performs a zoom operation on the display interface of the terminal, triggering the static-dynamic switching event corresponding to the dynamic element. The static-dynamic switching event can also be automatically triggered when a preset condition is met. For example, when the three-dimensional animation corresponding to the dynamic element is played to completion, the static-dynamic switching event corresponding to the dynamic element is generated.
[0099] When the target dynamic element is rendered in 3D, the dynamic-static switching event for the target dynamic element refers to the event of switching the target dynamic element from 3D rendering to 2D rendering.
[0100] Specifically, when the target dynamic element is rendered in 3D, if the terminal detects a dynamic-static switching event for the target dynamic element, in response to the dynamic-static switching event for the target dynamic element, the target dynamic element is removed from the three-dimensional scene layer, and the target dynamic element is added to the two-dimensional scene layer, so that the target dynamic element is switched from 3D rendering to 2D rendering. When rendering in 2D, the terminal renders the target dynamic element in the two-dimensional scene layer based on the two-dimensional position of the target dynamic element in the current viewport.
[0101] In the above embodiments, by triggering the dynamic-static switching event for the target dynamic element, the target dynamic element can be transferred from being rendered in the three-dimensional scene layer to being rendered in the two-dimensional scene layer, which helps to improve the flexibility of rendering.
[0102] In one embodiment, the dynamic-static switching event for the target dynamic element is generated when the three-dimensional animation corresponding to the target dynamic element in the scene screen is played to completion, in the case where the scene elements rendered in the two-dimensional scene layer include dynamic elements.
[0103] The scene rendering method further includes:
[0104] In response to the dynamic-static switching event for the target dynamic element, determine a first dynamic element from the dynamic elements rendered in the two-dimensional scene layer that is used to receive the three-dimensional playback right of the target dynamic element; based on the camera viewing angle in the three-dimensional space, map the two-dimensional position of the first dynamic element in the current viewport to the element placement plane in the three-dimensional space to obtain the three-dimensional position corresponding to the first dynamic element; add the first dynamic element to the three-dimensional scene layer, render the first dynamic element in the three-dimensional scene layer based on the three-dimensional position corresponding to the first dynamic element, and remove the first dynamic element from the two-dimensional scene layer.
[0105] Among them, the three-dimensional playback right refers to the right to play a three-dimensional animation, that is, the right to use 3D rendering. The first dynamic element is a dynamic element selected from the dynamic elements rendered in 2D and used to receive the three-dimensional playback right.
[0106] Specifically, the dynamic-static switching event for the target dynamic element is generated when the three-dimensional animation corresponding to the target dynamic element in the scene screen is played to completion, in the case where the scene elements rendered in the two-dimensional scene layer include dynamic elements. When the three-dimensional animation corresponding to the target dynamic element is played to completion, the three-dimensional playback right of the target dynamic element can be transferred to the dynamic elements in the scene elements rendered in 2D.
[0107] When the 3D animation corresponding to the target dynamic element in the scene screen finishes playing, the terminal determines a first dynamic element from the scene elements rendered in 2D for receiving the 3D playback right of the target dynamic element. For example, a dynamic element can be randomly selected from the scene elements rendered in 2D as the first dynamic element; a dynamic element can be selected as the first dynamic element based on the selection weights corresponding to each dynamic element in the scene elements rendered in 2D. The terminal switches the first dynamic element from 2D rendering to 3D rendering. Specifically, the first dynamic element is added to the 3D scene layer for rendering and removed from the 2D scene layer. For 3D rendering, based on the camera viewing angle in the 3D space, the terminal maps the 2D position of the first dynamic element in the current viewport to the element placement plane in the 3D space to obtain the 3D position corresponding to the first dynamic element, adds the first dynamic element to the 3D scene layer, and renders the first dynamic element in the 3D scene layer based on the 3D position corresponding to the first dynamic element.
[0108] In one embodiment, when the number of dynamic elements in the 3D scene layer is equal to the current upper limit of the number of simultaneous screen playbacks, the scene elements rendered in 2D can include dynamic elements. Specifically, if the number of dynamic elements in the 3D scene layer is less than the current upper limit of the number of simultaneous screen playbacks, it indicates that the terminal still has the ability to perform 3D rendering of more dynamic elements. Therefore, the 3D playback right of the target dynamic element can be retained. If the number of dynamic elements in the 3D scene layer is equal to the current upper limit of the number of simultaneous screen playbacks, due to the limited number of simultaneous screen playbacks, when the 3D animation corresponding to the target dynamic element finishes playing, the 3D playback right of the target dynamic element is transferred to other dynamic elements rendered in 2D to further enrich the visual expressiveness of the scene screen on the basis of saving computing resources.
[0109] In the above embodiment, in the case where the scene elements rendered in 2D include dynamic elements, when the 3D animation corresponding to the target dynamic element in the scene screen finishes playing, a first dynamic element for receiving the 3D playback right of the target dynamic element is determined from the scene elements rendered in 2D, the target dynamic element is switched from 3D rendering to 2D rendering, and the first dynamic element is switched from 2D rendering to 3D rendering. In this way, in the user's perception, 3D animations of multiple dynamic elements can be seen successively, further enriching the visual expressiveness of the scene screen.
[0110] In one embodiment, the scene rendering method further includes:
[0111] When the first dynamic element finishes rendering the first frame of the 3D animation in the 3D scene layer, the 2D picture corresponding to the first dynamic element is removed from the 2D scene layer.
[0112] Among them, completing the rendering of the first frame of a 3D animation means that the rendering of the first frame in the 3D animation is completed. A 3D animation shows the process of the movement and change of an object through a series of consecutive 3D images. The first frame in a 3D animation is the first 3D image in the 3D animation.
[0113] Specifically, after determining the first dynamic element for receiving the 3D playback right of the target dynamic element, first add the first dynamic element to the 3D scene layer for 3D rendering. When the rendering of the first frame of the 3D animation is completed, then remove the first dynamic element from the 2D scene layer to achieve seamless switching of the first dynamic element between 2D rendering and 3D rendering. When the first dynamic element completes the rendering of the first frame of the 3D animation in the 3D scene layer, the user can see the first frame of the 3D animation on the terminal. At this time, removing the 2D picture corresponding to the first dynamic element from the 2D scene layer will not affect the user's viewing of the first animation element.
[0114] In the above embodiment, when the first dynamic element completes the rendering of the first frame of the 3D animation in the 3D scene layer, the terminal displays the first frame of the 3D animation to the user. At this time, removing the 2D picture corresponding to the first dynamic element from the 2D scene layer, the user cannot perceive the movement and stillness switching event of the first dynamic element, thereby achieving seamless switching of the first dynamic element between 2D rendering and 3D rendering.
[0115] In one embodiment, rendering the target dynamic element on the 2D scene layer based on the 2D position of the target dynamic element in the current viewport includes:
[0116] Obtaining a 2D still image corresponding to the target dynamic element based on the first frame in the 3D animation corresponding to the target dynamic element; displaying the 2D still image corresponding to the target dynamic element on the 2D scene layer based on the 2D position of the target dynamic element in the current viewport.
[0117] Specifically, in response to a movement and stillness switching event for the target dynamic element, the terminal switches the target dynamic element from the 3D scene layer to the 2D scene layer. It can make full use of the 3D animation obtained by 3D rendering of the target dynamic element to save computing resources for 2D rendering. The terminal can obtain the first frame in the 3D animation corresponding to the target dynamic element, obtain a 2D still image corresponding to the target dynamic element based on the first frame in the 3D animation corresponding to the target dynamic element, add the 2D still image corresponding to the target dynamic element to the 2D scene layer, and display the 2D still image corresponding to the target dynamic element on the 2D scene layer based on the 2D position of the target dynamic element in the current viewport.
[0118] In the above embodiment, when switching the target dynamic element from 3D rendering to 2D rendering, obtaining a 2D still image corresponding to the target dynamic element based on the first frame in the 3D animation corresponding to the target dynamic element and adding the 2D still image corresponding to the target dynamic element to the 2D scene layer for display can effectively save computing resources for 2D rendering.
[0119] In one embodiment, with reference to Figure 5 the process of dynamic and static switching of a single element (i.e., a single scene element) is described. When a certain scene element is rendered in 2D, if a dynamic and static switching event is triggered, the scene element is added to the 3D space (i.e., added to the three-dimensional scene layer) for 3D rendering. When the first frame of the three-dimensional animation corresponding to the scene element is rendered, the scene element is removed from the two-dimensional scene layer, specifically, the 2D still image of the scene element is removed. After the scene element is switched to 3D rendering, the three-dimensional animation corresponding to the scene element is played on the terminal. If no dynamic and static switching event is triggered again, the three-dimensional animation corresponding to the scene element is continuously looped. If a dynamic and static switching event is triggered again, after the three-dimensional animation is completed, the scene element is removed from the three-dimensional scene layer (i.e., the 3D element is removed), and the 2D still image of the scene element is displayed on the two-dimensional scene layer.
[0120] In one embodiment, the scene rendering method further includes:
[0121] In response to a dynamic element addition event for a set of scene elements, based on the two-dimensional position of the newly added dynamic element in the current viewport, the newly added dynamic element is rendered on the two-dimensional scene layer; in response to a dynamic and static switching event for the newly added dynamic element, based on the camera viewing angle in the three-dimensional space, the two-dimensional position of the newly added dynamic element in the current viewport is mapped to the element placement plane in the three-dimensional space to obtain the three-dimensional position corresponding to the newly added dynamic element; the newly added dynamic element is added to the three-dimensional scene layer, and based on the three-dimensional position corresponding to the newly added dynamic element, the newly added dynamic element is rendered on the three-dimensional scene layer, and the newly added dynamic element is removed from the two-dimensional scene layer.
[0122] Among them, the dynamic element addition event refers to an event of adding a dynamic element to be displayed in the current viewport. The dynamic and static switching event can be triggered by the user. For example, when the user performs a zoom-out operation on the display interface of the terminal, the dynamic element addition event is triggered; when the user performs a movement operation on the display interface of the terminal, the dynamic element addition event is triggered. The dynamic element addition event can also be triggered by meeting a preset condition. For example, if the dynamic element in the virtual scene is a character, the dynamic element addition event is triggered when a new character goes online.
[0123] The newly added dynamic element refers to a newly added scene element. The dynamic and static switching event for the newly added dynamic element refers to an event of switching the newly added dynamic element from 2D rendering to 3D rendering.
[0124] Specifically, after the terminal renders and displays the set of scene elements to be displayed in the current viewport of the virtual scene, if the terminal detects a dynamic element addition event for the set of scene elements, in response to the dynamic element addition event for the set of scene elements, the newly added dynamic element is rendered and displayed.
[0125] To improve the display efficiency, first perform 2D rendering of the newly added dynamic elements on the two-dimensional scene layer. Specifically, based on the two-dimensional position of the newly added dynamic elements in the current viewport, render the newly added dynamic elements on the two-dimensional scene layer. Subsequently, the terminal can switch the newly added dynamic elements to the three-dimensional scene layer for 3D rendering as needed. If a dynamic-static switching event for the newly added dynamic elements is detected, then in response to the dynamic-static switching event for the newly added dynamic elements, add the newly added dynamic elements to the three-dimensional scene layer and remove the newly added dynamic elements from the two-dimensional scene layer, so that the newly added dynamic elements are switched from 2D rendering to 3D rendering. For 3D rendering, the terminal maps the two-dimensional position of the newly added dynamic elements in the current viewport to the element placement plane in the three-dimensional space based on the camera viewing angle in the three-dimensional space, obtains the corresponding three-dimensional position of the newly added dynamic elements, and renders the newly added dynamic elements on the three-dimensional scene layer based on the corresponding three-dimensional position of the newly added dynamic elements.
[0126] For example, in response to a sliding operation on the current viewport, determine the newly added dynamic elements, first perform 2D rendering of the newly added dynamic elements on the two-dimensional scene layer to quickly display the newly added dynamic elements, and then switch the newly added dynamic elements from 2D rendering to 3D rendering to enhance the visual expressiveness of the newly added dynamic elements.
[0127] For example, first perform 2D rendering of the newly added dynamic elements on the two-dimensional scene layer. When the number of currently 3D-rendered dynamic elements is equal to the current upper limit of the number of simultaneously played elements on the screen, the newly added dynamic elements continue to stay on the two-dimensional scene layer. If the three-dimensional animation corresponding to a 3D-rendered dynamic element finishes playing, transfer the three-dimensional playback right of that dynamic element to the newly added dynamic elements, and switch the newly added dynamic elements from 2D rendering to 3D rendering.
[0128] In the above embodiments, the speed of 2D rendering is faster than that of 3D rendering. In response to a dynamic element addition event for the scene element set, first perform 2D rendering of the newly added dynamic elements on the two-dimensional scene layer to quickly display the newly added dynamic elements. In response to a dynamic-static switching event for the newly added dynamic elements, transfer the newly added dynamic elements from the two-dimensional scene layer to the three-dimensional scene layer for 3D rendering, which can enhance the visual expressiveness of the newly added dynamic elements.
[0129] In one embodiment, the scene rendering method further includes:
[0130] In response to a dynamic element deletion event for a target dynamic element, remove the target dynamic element from the three-dimensional scene layer; determine a second dynamic element from the dynamic elements rendered in the two-dimensional scene layer for receiving the three-dimensional playback right of the target dynamic element; based on the camera viewing angle in the three-dimensional space, map the two-dimensional position of the second dynamic element in the current viewport to the element placement plane in the three-dimensional space to obtain the three-dimensional position corresponding to the second dynamic element; add the second dynamic element to the three-dimensional scene layer, and render the second dynamic element in the three-dimensional scene layer based on the three-dimensional position corresponding to the second dynamic element, and remove the second dynamic element from the two-dimensional scene layer.
[0131] Among them, the dynamic element deletion event refers to an event of canceling the display of a dynamic element in the current viewport. The dynamic element deletion event can be triggered by a user. For example, when the user performs a zoom-in operation on the display interface of the terminal, a dynamic element deletion event is triggered; when the user performs a movement operation on the display interface of the terminal, a dynamic element deletion event is triggered. The dynamic element deletion event can also be triggered by meeting a preset condition. For example, if the target dynamic element is a person in the virtual scene who is in an online state, a dynamic element deletion event is triggered when the person goes offline.
[0132] The second dynamic element is a dynamic element selected from the dynamically rendered elements using 2D for receiving the three-dimensional playback right of the target dynamic element when canceling the display of the target dynamic element.
[0133] Specifically, after the target dynamic element is rendered and displayed in 3D, if the terminal detects a dynamic element deletion event for the target dynamic element, in response to the dynamic element deletion event for the target dynamic element, remove the target dynamic element from the three-dimensional scene layer, thereby deleting the target dynamic element from the scene picture. Further, the terminal determines a second dynamic element from the dynamic elements rendered in the two-dimensional scene layer for receiving the three-dimensional playback right of the target dynamic element. For example, a dynamic element can be randomly selected from the scene elements rendered in 2D as the second dynamic element; a dynamic element can be selected based on the selection weights corresponding to each dynamic element in the scene elements rendered in 2D. The terminal switches the second dynamic element from 2D rendering to 3D rendering. Specifically, add the second dynamic element to the three-dimensional scene layer for rendering and remove the second dynamic element from the two-dimensional scene layer. For 3D rendering, based on the camera viewing angle in the three-dimensional space, the terminal maps the two-dimensional position of the second dynamic element in the current viewport to the element placement plane in the three-dimensional space to obtain the three-dimensional position corresponding to the second dynamic element, adds the second dynamic element to the three-dimensional scene layer, and renders the second dynamic element in the three-dimensional scene layer based on the three-dimensional position corresponding to the second dynamic element.
[0134] For example, when the user slides on the current viewport such that the target dynamic element moves outside the current viewport, a dynamic element deletion event for the target dynamic element is triggered. In response to the dynamic element deletion event for the target dynamic element, the target dynamic element is removed from the three-dimensional scene layer, a second dynamic element is determined from the dynamic elements rendered in the two-dimensional scene layer, the three-dimensional playback right of the target dynamic element is transferred to the second dynamic element, the second dynamic element is added to the three-dimensional scene layer for rendering, and the second dynamic element is removed from the two-dimensional scene layer.
[0135] In the above embodiment, in response to the dynamic element deletion event for the target dynamic element, the target dynamic element is removed from the three-dimensional scene layer, a second dynamic element for receiving the three-dimensional playback right of the target dynamic element is determined from the dynamic elements rendered in the two-dimensional scene layer, the second dynamic element is added to the three-dimensional scene layer for rendering, and the second dynamic element is removed from the two-dimensional scene layer. In this way, when deleting the target dynamic element, the three-dimensional playback right of the target dynamic element is timely transferred to other dynamic elements, which can improve the utilization rate of the three-dimensional playback right and ensure the visual expressiveness of the scene picture.
[0136] In one embodiment, refer to Figure 6 to illustrate the simultaneous screen playback strategy of the method of the present application. When the terminal load level changes, the upper limit of the simultaneous screen playback quantity is dynamically adjusted to ensure smooth scene operation. Multiple terminal load levels are preset in advance. When it is detected that the loads of the terminal CPU, memory, and GPU change, the current terminal load level is determined. Based on the current terminal load level, the current upper limit of the simultaneous screen playback quantity is determined. The scene elements to be displayed are traversed, and under the constraint of the current upper limit of the simultaneous screen playback quantity, a dynamic and static switching event of the scene elements is generated.
[0137] Refer to Figure 7 , the dynamic and static switching event can be generated when there is an addition or deletion of scene elements. When there is an addition of scene elements, if the number of dynamic elements currently rendered in 3D is less than the current upper limit of the simultaneous screen playback quantity, there is no need to perform dynamic and static switching on the dynamic elements already rendered in 3D. If the number of dynamic elements currently rendered in 3D is equal to the current upper limit of the simultaneous screen playback quantity, a dynamic element is selected from the dynamic elements rendered in 3D, and the three-dimensional playback right of the selected dynamic element is transferred to the newly added dynamic element. When there is a deletion of scene elements, the three-dimensional playback right of the deleted dynamic element can be transferred to the dynamic elements rendered in 2D.
[0138] The dynamic and static switching event can be generated when there is a movement of the viewport. For example, when the user slides the display screen of the terminal with a finger, moving the scene display of the current viewport or zooming in or out on the scene display of the current viewport, there will be an addition or deletion of scene elements, and thus a dynamic and static switching event may be generated.
[0139] The dynamic-static switching event can be generated when the animation of a dynamic element finishes playing. Since the number of simultaneous screen plays is limited, whenever the animation of a dynamic element finishes playing, the 3D playback right of this dynamic element can be transferred to other dynamic elements rendered in 2D. For example, adopting a random playback strategy, the 3D playback right can be randomly transferred to other dynamic elements rendered in 2D.
[0140] Through the simultaneous screen playback strategy of the method of this application, it is possible to effectively reduce the performance overhead on the basis of ensuring the visual effect of the virtual scene.
[0141] In one embodiment, the scene rendering method further includes:
[0142] In response to a trigger operation on the contact status query entry in the communication application, the contact dynamic square for displaying the contact status in the communication application is used as the virtual scene, and the step of obtaining the set of scene elements to be displayed in the current viewport of the virtual scene is executed.
[0143] Among them, the set of scene elements to be displayed in the current viewport of the virtual scene is determined based on the dynamic element set and the static element set corresponding to the contact dynamic square; the dynamic element set is obtained by acquiring the target contacts of the current logged-in account in the communication application, and is determined based on the target contacts and the virtual roles of the current logged-in account in the communication application; the static element set is determined based on the square background design information.
[0144] A communication application refers to an application that realizes data communication through a network based on computer technology. For example, a communication application can be various communication-enabled applications such as an instant messaging application, a game application, etc. Users can add contacts in the communication application to communicate quickly with contacts in the communication application. For example, users can add social friends in the instant messaging application, and users can chat and communicate with social friends through conversations in the instant messaging application; users can add game friends in the game application, and users can communicate and play games with game friends through conversations in the instant messaging application.
[0145] The communication application provides an entry for querying the contact status. The entry for querying the contact status is the entry to the contact dynamic square, which can be specifically implemented through various interface elements such as buttons, sliders, text, graphics, hyperlinks, etc. The entry for querying the contact status can be displayed in the communication application. For example, a contact status button can be displayed, and the user can enter the contact dynamic square by clicking the contact status button. The contact dynamic square is a dynamic square for displaying the contact status. After the user logs in to the communication application, the user can set the status. Through status setting, the user can tell other users their current status, such as online, away, busy, invisible, do not disturb, listening to music, studying, exercising, watching dramas, etc. The contact status refers to the status set by the contact for themselves. The dynamic square is a multi-person and multi-prop interaction scene under a fixed perspective. In the dynamic square, the corresponding character images and statuses of each contact are displayed. The user can move up, down, left, and right parallelly and zoom in and out with two fingers in the dynamic square to observe the dynamic square and perform some interactive operations. For example, when the user double-clicks on the character image corresponding to a certain contact in the dynamic square, a private conversation with that contact can be quickly opened; when the user clicks on the status icon corresponding to a certain contact in the dynamic square for displaying the status, the status comment interface can be quickly opened, and the user can comment on the contact status in the status comment interface; when the user clicks on their own character image in the dynamic square, the image setting interface can be quickly opened, and the user can adjust the character image in the image setting interface; the function access entrances corresponding to each derivative function of the communication application can also be displayed in the dynamic square, and when the user clicks on the function access entrance of a certain derivative function in the dynamic square, the derivative function home page can be quickly entered.
[0146] The current logged-in account of the communication application refers to the application account that the user is currently using to log in to the communication application. The target contacts of the current logged-in account in the communication application can be all the contacts of the current logged-in account in the communication application, or the contacts of the current logged-in account in the communication application who have logged in to the communication application.
[0147] The virtual role of the user in the communication application is the virtual image designed by the user for themselves in the communication application. The user can design their own virtual image in the communication application, including hairstyle, clothes, accessories, etc. The dynamic element set corresponding to the contact dynamic square includes the target contacts and the virtual role of the current logged-in account in the communication application. In the contact dynamic square, the virtual role needs to play animations. The virtual role can play animations in a breathing state or an interactive state. The virtual role can loop-play the corresponding animations in the contact dynamic square according to its own status. For example, if the status corresponding to the current logged-in account is listening to music, the virtual role corresponding to the current logged-in account can loop-play the animation of the virtual role listening to music.
[0148] The square background design information is the background information designed for the contact dynamic square. The square background design information can be general information. For example, users of the communication application all adopt the default square background design information, which is designed and set by the communication application developers. The square background design information can also be personalized information. For example, the communication application provides multiple square background design information for users to choose from, and users can choose according to their needs. The set of static elements corresponding to the contact dynamic square includes each background element that makes up the square background, such as buildings, flowers and trees, etc.
[0149] In one embodiment, the set of dynamic elements corresponding to the contact dynamic square includes virtual characters and the character props of the virtual characters. The set of static elements includes background elements and the character pendants of the virtual characters. The virtual character is a virtual image designed by the user himself. The character props and character pendants are items used to decorate the virtual image. For example, the character props can be riding props, attack knives, etc. used by the virtual character, and the character pendants can be nameplates, background light effects, health bars, etc. of the virtual character. It can be understood that the character props are usually items that will change or will change complexly. For example, the posture of the riding prop will change during the riding process. The character pendants are usually items that will not change or only change simply. For example, the nameplate will only move with the movement of the virtual character, and the nameplate itself will not change.
[0150] For example, referring to Figure 8 , the square elements (which can also be called map elements) of the contact dynamic square include background pictures, characters, character props, character pendants (such as the top bubbles, bottom labels, side labels, etc. of the characters), buildings, billboards, etc. Among them, for the characters and character props, animations of breathing states or interactive states need to be played, and the character images support dressing up, which are suitable to be implemented in the 3D scene layer. Other elements are basically in a static state or a simple planar animation state, and have a lot of business logic, which are suitable to be implemented in the 2D scene layer.
[0151] Specifically, the user can log in to the communication application on the terminal. The communication application provides an entry for querying the contact status. The user can trigger the entry for querying the contact status to enter the contact dynamic square. In response to the trigger operation on the entry for querying the contact status in the communication application, the terminal uses the contact dynamic square for displaying the contact status in the communication application as a virtual scene, obtains the square elements of the contact dynamic square for rendering, and thus displays the contact dynamic square to the user.
[0152] In response to a trigger operation on the contact status query entry in the communication application, the terminal obtains a set of scene elements to be displayed in the current viewport of the contact dynamic square from the application server corresponding to the communication application. The terminal performs 3D rendering and 2D rendering on the scene elements in the set of scene elements as needed, and obtains and displays the scene picture of the contact dynamic square in the current viewport.
[0153] In response to a trigger operation on the contact status query entry in the communication application, the terminal sends a scene element acquisition request to the application server. The scene element acquisition request carries the current login account of the communication application. The application server queries the target contacts of the current login account of the communication application in the communication application, obtains the virtual roles of the target contacts and the current login account in the communication application, and determines a set of dynamic elements corresponding to the contact dynamic square based on the virtual roles of the target contacts and the current login account in the communication application. The application server queries the square background design information and determines a set of static elements corresponding to the contact dynamic square based on the square background design information. It can be that the application server returns the set of dynamic elements and the set of static elements corresponding to the contact dynamic square to the terminal, and the terminal determines the set of scene elements to be displayed in the current viewport of the contact dynamic square based on the set of dynamic elements and the set of static elements. It can also be that the application server determines the set of scene elements to be displayed in the current viewport of the contact dynamic square based on the set of dynamic elements and the set of static elements, and returns the set of scene elements to be displayed in the current viewport of the contact dynamic square to the terminal.
[0154] In one embodiment, the set of dynamic elements corresponding to the contact dynamic square further includes the virtual roles of strangers of the current login account in the communication application in the communication application. In addition to being able to display the virtual roles corresponding to the target contacts of the current login account in the communication application, the contact dynamic square can also display the virtual roles corresponding to the strangers of the current login account in the communication application.
[0155] For example, referring to Figure 8 , the contact dynamic square includes a topic discussion area. Users can take their seats in the topic discussion area through the "Sit back and relax" control and have topic discussions with strangers using the communication application.
[0156] In the above embodiment, the method of the present application can be applied to display the contact dynamic square in the communication application. Place the scene elements that are easy to implement in 2D, such as the square background, on the 2D scene layer for rendering, and place the scene elements that require complex animation display, such as virtual roles, on the 3D scene layer for rendering, so as to effectively save computing resources and save performance overhead on the basis of ensuring the visual effect.
[0157] In a specific embodiment, as Figure 9 shown, a scene rendering method is provided. Taking the method applied to the terminal in Figure 1 as an example for description. Among them:
[0158] Step S902: Obtain the set of scene elements to be displayed in the current viewport of the virtual scene.
[0159] Step S904: Determine the upper limit of the current simultaneous playback quantity based on at least one of the current terminal load level and the content display size corresponding to the current viewport. When the number of dynamic elements in the set of scene elements is greater than the upper limit of the current simultaneous playback quantity, select dynamic elements that match the upper limit of the current simultaneous playback quantity from the set of scene elements as target dynamic elements respectively. When the number of dynamic elements in the set of scene elements is less than or equal to the upper limit of the current simultaneous playback quantity, use each dynamic element in the set of scene elements as a target dynamic element respectively.
[0160] Step S906: Based on the camera viewing angle in the three-dimensional space, map the two-dimensional positions of the target dynamic elements in the current viewport to the element placement plane in the three-dimensional space to obtain the corresponding three-dimensional positions of the target dynamic elements. Based on the corresponding three-dimensional positions of the target dynamic elements, render the target dynamic elements on the three-dimensional scene layer for three-dimensional rendering. Based on the two-dimensional positions of other scene elements in the current viewport in the set of scene elements, render other scene elements on the two-dimensional scene layer for two-dimensional rendering.
[0161] Step S908: In response to the dynamic-static switching event for the target dynamic element, remove the target dynamic element from the three-dimensional scene layer, add the target dynamic element to the two-dimensional scene layer, and render the target dynamic element on the two-dimensional scene layer based on the two-dimensional position of the target dynamic element in the current viewport.
[0162] Step S910: In response to the dynamic-static switching event for the target dynamic element, determine the first dynamic element for receiving the three-dimensional playback right of the target dynamic element from the dynamic elements rendered on the two-dimensional scene layer. Based on the camera viewing angle in the three-dimensional space, map the two-dimensional position of the first dynamic element in the current viewport to the element placement plane in the three-dimensional space to obtain the corresponding three-dimensional position of the first dynamic element. Add the first dynamic element to the three-dimensional scene layer, render the first dynamic element on the three-dimensional scene layer based on the corresponding three-dimensional position of the first dynamic element, and remove the first dynamic element from the two-dimensional scene layer.
[0163] Step S912: In response to a dynamic element addition event for a set of scene elements, based on the two-dimensional position of the newly added dynamic element in the current viewport, render the newly added dynamic element on the two-dimensional scene layer. In response to a static-dynamic switching event for the newly added dynamic element, based on the camera viewing perspective in three-dimensional space, map the two-dimensional position of the newly added dynamic element in the current viewport to the element placement plane in three-dimensional space to obtain the corresponding three-dimensional position of the newly added dynamic element, add the newly added dynamic element to the three-dimensional scene layer, render the newly added dynamic element on the three-dimensional scene layer based on the corresponding three-dimensional position of the newly added dynamic element, and remove the newly added dynamic element from the two-dimensional scene layer.
[0164] Step S914: In response to a dynamic element deletion event for a target dynamic element, remove the target dynamic element from the three-dimensional scene layer, determine a second dynamic element from the dynamic elements rendered on the two-dimensional scene layer that is used to receive the three-dimensional playback right of the target dynamic element, map the two-dimensional position of the second dynamic element in the current viewport to the element placement plane in three-dimensional space based on the camera viewing perspective in three-dimensional space to obtain the corresponding three-dimensional position of the second dynamic element, add the second dynamic element to the three-dimensional scene layer, render the second dynamic element on the three-dimensional scene layer based on the corresponding three-dimensional position of the second dynamic element, and remove the second dynamic element from the two-dimensional scene layer.
[0165] In the above scene rendering method, the target dynamic elements of the virtual scene are rendered on the three-dimensional scene layer, and other scene elements are rendered on the two-dimensional scene layer. By combining three-dimensional rendering and two-dimensional rendering when displaying the scene picture of the virtual scene, it can effectively save computing resources and performance overhead while ensuring the display effect of the scene picture. Moreover, based on the camera viewing perspective in three-dimensional space, accurate mapping of the same scene elements between the two-dimensional scene layer and the three-dimensional scene layer is achieved, ensuring the alignment of the scene elements between the two-dimensional scene layer and the three-dimensional scene layer, and further ensuring the display effect of the scene picture.
[0166] In a specific embodiment, the method of the present application can be applied to the friend dynamic square in an instant messaging application. The friend dynamic square in the instant messaging application can display the statuses posted by each online friend of the user in the instant messaging application. The online friends of the user in the instant messaging application refer to the friends who are currently logged in to the instant messaging application among all the friends of the user in the instant messaging application. The friend dynamic square is a multi-person multi-prop interaction scene under a fixed perspective, which includes animated character images, character props with loop playback, as well as static background images, buildings, character pendants, etc. The user can move up, down, left, and right parallelly and zoom in and out with two fingers on the friend dynamic square to observe square elements such as character images and buildings, and perform some interactive operations.
[0167] The terminal renders the content that is easy to implement in 2D, such as the square background and character accessories in the friend dynamic square, on the 2D scene layer to improve the rendering efficiency. It renders the character images, character props, etc. in the friend dynamic square that require complex animation displays and interactions on the 3D scene layer to solve the problems of insufficient 2D expressiveness and single interaction feedback, and enhance the visual expressiveness of the friend dynamic square. That is, static elements are rendered on the 2D scene layer, and dynamic elements are rendered on the 3D scene layer. Moreover, based on the 2D coordinates of the scene elements in the current viewport, along the camera viewing angle in the three-dimensional space, the 2D coordinates are mapped to the element placement plane in the three-dimensional space to obtain the 3D space coordinates of the scene elements. The 3D space coordinates of the scene elements are perfectly aligned with the 2D plane coordinates of the scene elements, which can ensure that the same scene element is displayed in the same position whether it is rendered on the 2D scene layer or the 3D scene layer.
[0168] Furthermore, by comprehensively considering the real-time load of the terminal and the content display size corresponding to the current viewport, the terminal controls the number of dynamic elements played on the same screen in real time (i.e., the upper limit of the number of elements played on the same screen) to further reduce the running overhead. When the number of dynamic elements to be rendered is greater than the current upper limit of the number of elements played on the same screen, dynamic elements that match the current upper limit of the number of elements played on the same screen are obtained from the dynamic elements to be rendered and rendered on the 3D scene layer, and other dynamic elements are rendered on the 2D scene layer. When a dynamic switching event for the dynamic elements rendered on the 3D scene layer is triggered, the three-dimensional playback right of the dynamic element can be transferred to the dynamic element rendered on the 2D scene layer, so that the dynamic element rendered on the 2D scene layer switches to the 3D scene layer to further enhance the visual expressiveness of the friend dynamic square on the basis of reducing the running overhead. If the dynamic element that surrenders the three-dimensional playback right still needs to be displayed, the dynamic element that surrenders the three-dimensional playback right will be removed from the 3D scene layer and placed in the 2D scene layer for display through a 2D texture map to ensure a smooth user experience and the user has no perception of the switching process.
[0169] Through the method of this application, when the user uses the friend dynamic square, only the moving characters and character props seen are 3D rendered, and other square elements are 2D rendered. Moreover, the 2D coordinates and 3D coordinates of the same square element are accurately aligned and can be moved and scaled synchronously, providing the user with a complete and consistent experience. In short, the method of this application balances issues such as development efficiency and running overhead while ensuring the display effect.
[0170] For example, the terminal displays an access entry to an instant messaging application. The user triggers the access entry to the instant messaging application and performs a login operation, and then enters the application home page of the instant messaging application. The application home page of the instant messaging application can refer to Figure 10 . The application home page of the instant messaging application displays the user information of the logged-in user and the message information of the logged-in user. Refer to Figure 10Among 1002, the user information of the logged-in user includes the user avatar, username, and user status. When the user triggers the user status, the user can enter the status setting page, where the user can set the status. The status setting page can refer to Figure 11 . In the status setting interface, there is an access entry to the friend dynamic square. When the user triggers the access entry to the friend dynamic square, the user enters the friend dynamic square. The access entry to the friend dynamic square can refer to Figure 11 Among 1102, the friend dynamic square can refer to Figure 12 .
[0171] In a specific embodiment, the method of the present application can be applied to the game screen in a game application. The terminal places the static elements in the game scene (such as the game background, game character attachments (such as health bars, background light effects, nameplates, etc.)) that are easy to implement in 2D on the 2D scene layer for rendering to improve the rendering efficiency, and places the dynamic elements in the game scene (such as game characters, game props) that require complex animation display and interaction on the 3D scene layer for rendering to solve the problems of insufficient 2D expressiveness and single interaction feedback, and enhance the visual expressiveness of the game screen.
[0172] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear description in this article, the execution of these steps has no strict order limit, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or alternately with at least a part of other steps or steps or stages in other steps.
[0173] Based on the same inventive concept, the embodiments of the present application also provide a scene rendering device for implementing the above-mentioned scene rendering method. The implementation solutions provided by this device to solve problems are similar to the implementation solutions described in the above method. Therefore, the specific limitations in one or more embodiments of the following scene rendering devices can refer to the limitations on the scene rendering method in the above text, and will not be repeated here.
[0174] In one embodiment, as Figure 13 shown, a scene rendering device is provided, including: an acquisition module 1302, a determination module 1304, a mapping module 1306, and a rendering module 1308, where:
[0175] An acquisition module 1302, configured to acquire a set of scene elements to be displayed in a current viewport of a virtual scene.
[0176] A determination module 1304, configured to determine a target dynamic element from the set of scene elements.
[0177] A mapping module 1306, configured to map a two-dimensional position of the target dynamic element in the current viewport to an element placement plane in a three-dimensional space based on a camera viewing angle in the three-dimensional space, so as to obtain a three-dimensional position corresponding to the target dynamic element.
[0178] A rendering module 1308, configured to render the target dynamic element on a three-dimensional scene layer for three-dimensional rendering based on the three-dimensional position corresponding to the target dynamic element, and render other scene elements on a two-dimensional scene layer for two-dimensional rendering based on two-dimensional positions of other scene elements in the current viewport, so as to obtain and display a scene picture of the virtual scene in the current viewport.
[0179] In one embodiment, the determination module 1304 is further configured to:
[0180] Obtain a current upper limit of the number of elements played on the same screen;
[0181] When the number of dynamic elements in the set of scene elements is greater than the current upper limit of the number of elements played on the same screen, select dynamic elements matching the current upper limit of the number of elements played on the same screen from the set of scene elements as the target dynamic elements respectively;
[0182] When the number of dynamic elements in the set of scene elements is less than or equal to the current upper limit of the number of elements played on the same screen, use each dynamic element in the set of scene elements as the target dynamic element respectively.
[0183] In one embodiment, the obtaining method of the current upper limit of the number of elements played on the same screen includes at least one of the following:
[0184] Determine the current upper limit of the number of elements played on the same screen based on the current terminal load level; the current upper limit of the number of elements played on the same screen is negatively correlated with the current terminal load level, and the current terminal load level is positively correlated with the current terminal load;
[0185] Determine the current upper limit of the number of elements played on the same screen based on the content display size corresponding to the current viewport; the current upper limit of the number of elements played on the same screen is negatively correlated with the content display size.
[0186] In one embodiment, the determination module 1304 is further configured to:
[0187] Based on the distances between the dynamic elements in the set of scene elements and the center position of the current viewport in the two-dimensional position, determine selection weights corresponding to the respective dynamic elements in the set of scene elements; the selection weights are negatively correlated with the distances;
[0188] Based on the selection weights corresponding to each dynamic element, select dynamic elements that match the current upper limit of the number of elements played on the same screen from the set of scene elements as target dynamic elements respectively.
[0189] In one embodiment, the mapping module 1306 is further configured to:
[0190] Based on the camera view range in the three-dimensional space and the viewport size of the current viewport, determine the viewport position of the current viewport in the three-dimensional space;
[0191] Within the viewport position of the current viewport in the three-dimensional space, starting from the two-dimensional coordinate point of the target dynamic element in the current viewport, emit a ray along the camera viewing angle direction in the three-dimensional space, and use the three-dimensional coordinates corresponding to the intersection point of the ray and the element placement plane in the three-dimensional space as the three-dimensional position corresponding to the target dynamic element.
[0192] In one embodiment, the rendering module 1308 is further configured to:
[0193] Based on the three-dimensional position corresponding to the target dynamic element, render the three-dimensional model information of the target dynamic element on the three-dimensional scene layer for three-dimensional rendering to obtain the three-dimensional animation corresponding to the target dynamic element;
[0194] Based on the two-dimensional positions of other scene elements in the current viewport in the set of scene elements, render the two-dimensional plane information of other scene elements on the two-dimensional scene layer to obtain the two-dimensional pictures corresponding to other scene elements; the two-dimensional plane information includes any one of two-dimensional static picture information, two-dimensional animated picture information, and two-dimensional video information;
[0195] Based on the three-dimensional animation corresponding to the target dynamic element and the two-dimensional pictures corresponding to other scene elements, obtain the scene picture of the virtual scene in the current viewport and display it.
[0196] In one embodiment, the scene rendering device is further configured to:
[0197] In response to the static-dynamic switching event for the target dynamic element, remove the target dynamic element from the three-dimensional scene layer and add the target dynamic element to the two-dimensional scene layer;
[0198] Based on the two-dimensional position of the target dynamic element in the current viewport, render the target dynamic element on the two-dimensional scene layer.
[0199] In one embodiment, the static-dynamic switching event for the target dynamic element is generated when the three-dimensional animation corresponding to the target dynamic element in the scene picture finishes playing when the scene elements rendered on the two-dimensional scene layer include dynamic elements. The scene rendering device is further configured to:
[0200] In response to a dynamic-to-static switching event for a target dynamic element, determine a first dynamic element from the dynamic elements rendered on the two-dimensional scene layer for receiving the three-dimensional playback right of the target dynamic element;
[0201] Based on the camera viewing perspective in three-dimensional space, map the two-dimensional position of the first dynamic element in the current viewport to the element placement plane in three-dimensional space to obtain the three-dimensional position corresponding to the first dynamic element;
[0202] Add the first dynamic element to the three-dimensional scene layer, render the first dynamic element on the three-dimensional scene layer based on the three-dimensional position corresponding to the first dynamic element, and remove the first dynamic element from the two-dimensional scene layer.
[0203] In one embodiment, the scene rendering device is further configured to:
[0204] When the first frame of the three-dimensional animation of the first dynamic element is rendered on the three-dimensional scene layer, remove the two-dimensional picture corresponding to the first dynamic element from the two-dimensional scene layer.
[0205] In one embodiment, the scene rendering device is further configured to:
[0206] Based on the first frame in the three-dimensional animation corresponding to the target dynamic element, obtain a two-dimensional static image corresponding to the target dynamic element;
[0207] Based on the two-dimensional position of the target dynamic element in the current viewport, display the two-dimensional static image corresponding to the target dynamic element on the two-dimensional scene layer.
[0208] In one embodiment, the scene rendering device is further configured to:
[0209] In response to a dynamic element addition event for a scene element set, render the newly added dynamic element on the two-dimensional scene layer based on the two-dimensional position of the newly added dynamic element in the current viewport;
[0210] In response to a dynamic-to-static switching event for the newly added dynamic element, based on the camera viewing perspective in three-dimensional space, map the two-dimensional position of the newly added dynamic element in the current viewport to the element placement plane in three-dimensional space to obtain the three-dimensional position corresponding to the newly added dynamic element;
[0211] Add the newly added dynamic element to the three-dimensional scene layer, render the newly added dynamic element on the three-dimensional scene layer based on the three-dimensional position corresponding to the newly added dynamic element, and remove the newly added dynamic element from the two-dimensional scene layer.
[0212] In one embodiment, the scene rendering device is further configured to:
[0213] In response to a dynamic element deletion event for a target dynamic element, remove the target dynamic element from the three-dimensional scene layer;
[0214] Determine a second dynamic element from the dynamic elements rendered in the two-dimensional scene layer for receiving the three-dimensional playback right of the target dynamic element;
[0215] Based on the camera viewing perspective in the three-dimensional space, map the two-dimensional position of the second dynamic element in the current viewport to the element placement plane in the three-dimensional space to obtain the three-dimensional position corresponding to the second dynamic element;
[0216] Add the second dynamic element to the three-dimensional scene layer, render the second dynamic element in the three-dimensional scene layer based on the three-dimensional position corresponding to the second dynamic element, and remove the second dynamic element from the two-dimensional scene layer.
[0217] In one embodiment, the scene rendering device is further configured to:
[0218] In response to a trigger operation on the contact status query entry in the communication application, use the contact dynamic square for displaying the contact status in the communication application as a virtual scene, and enter the step of obtaining the set of scene elements to be displayed in the current viewport of the virtual scene for execution;
[0219] Among them, the set of scene elements to be displayed in the current viewport of the virtual scene is determined based on the set of dynamic elements and the set of static elements corresponding to the contact dynamic square; the set of dynamic elements is obtained by acquiring the target contacts of the currently logged-in account in the communication application and determining based on the target contacts and the virtual roles of the currently logged-in account in the communication application; the set of static elements is determined based on the square background design information.
[0220] For the above scene rendering device, the target dynamic elements of the virtual scene are rendered in the three-dimensional scene layer, and other scene elements are rendered in the two-dimensional scene layer. When displaying the scene picture of the virtual scene, combining three-dimensional rendering and two-dimensional rendering can effectively save computing resources and performance overhead on the basis of ensuring the display effect of the scene picture. Moreover, based on the camera viewing perspective in the three-dimensional space, accurate mapping of the same scene elements in the two-dimensional scene layer and the three-dimensional scene layer is realized, ensuring the alignment of the scene elements in the two-dimensional scene layer and the three-dimensional scene layer, and further ensuring the display effect of the scene picture.
[0221] Each module in the above scene rendering device can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in the processor in the computer device in hardware form or be independent of it, or can be stored in the memory in the computer device in software form, so that the processor can call and execute the operations corresponding to the above modules.
[0222] In one embodiment, a computer device is provided. The computer device can be a terminal, and its internal structure diagram can be as Figure 14As shown in the figure. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface, the display unit, and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (Near Field Communication), or other technologies. The computer program, when executed by the processor, implements a scene rendering method. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covering the display screen, or a button, a trackball, or a touchpad provided on the computer device housing, or an external keyboard, touchpad, or mouse, etc.
[0223] Those skilled in the art can understand that Figure 14 the structure shown in the figure is only a block diagram of some structures related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0224] In one embodiment, a computer device is further provided, including a memory and a processor. A computer program is stored in the memory, and when the processor executes the computer program, the steps in the above method embodiments are implemented.
[0225] In one embodiment, a computer-readable storage medium is provided, storing a computer program, and when the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0226] In one embodiment, a computer program product is provided, and the computer program product includes a computer program. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.
[0227] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.
[0228] Those of ordinary skill in the art can understand that all or part of the processes of implementing the methods in the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in this application can include at least one of non-volatile and volatile memories. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in this application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., and are not limited thereto. The processors involved in the embodiments provided in this application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., and are not limited thereto.
[0229] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope described in this specification.
[0230] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.
Claims
1. A scene rendering method, characterized in that, The method includes: Obtaining a set of scene elements to be displayed in the current viewport of the virtual scene; Determining target dynamic elements from the set of scene elements; Based on the camera viewing angle in three-dimensional space, mapping the two-dimensional position of the target dynamic element in the current viewport to the element placement plane in three-dimensional space to obtain the corresponding three-dimensional position of the target dynamic element; Based on the corresponding three-dimensional position of the target dynamic element, rendering the target dynamic element on the three-dimensional scene layer for three-dimensional rendering, and based on the two-dimensional positions of other scene elements in the current viewport, rendering the other scene elements on the two-dimensional scene layer for two-dimensional rendering, to obtain and display the scene image of the virtual scene in the current viewport.
2. The method according to claim 1, wherein The determining target dynamic elements from the set of scene elements includes: Obtaining the current upper limit of the number of elements played simultaneously on the same screen; When the number of dynamic elements in the set of scene elements is greater than the current upper limit of the number of elements played simultaneously on the same screen, selecting dynamic elements that match the current upper limit of the number of elements played simultaneously on the same screen from the set of scene elements as the target dynamic elements respectively; When the number of dynamic elements in the set of scene elements is less than or equal to the current upper limit of the number of elements played simultaneously on the same screen, taking each dynamic element in the set of scene elements as the target dynamic element respectively.
3. The method according to claim 2, wherein The obtaining method of the current upper limit of the number of elements played simultaneously on the same screen includes at least one of the following: Determining the current upper limit of the number of elements played simultaneously on the same screen based on the current terminal load level; the current upper limit of the number of elements played simultaneously on the same screen is negatively correlated with the current terminal load level, and the current terminal load level is positively correlated with the current terminal load; Determining the current upper limit of the number of elements played simultaneously on the same screen based on the content display size corresponding to the current viewport; The current upper limit of the number of elements played simultaneously on the same screen is negatively correlated with the content display size.
4. The method according to claim 2, wherein The selecting dynamic elements that match the current upper limit of the number of elements played simultaneously on the same screen from the set of scene elements as the target dynamic elements respectively includes: Based on the distance between the two-dimensional position of the dynamic element in the set of scene elements and the center position of the current viewport, respectively determining the selection weight corresponding to each dynamic element in the set of scene elements; the selection weight is negatively correlated with the distance; Based on the selection weights corresponding to each dynamic element respectively, selecting dynamic elements that match the current upper limit of the number of elements played simultaneously on the same screen from the set of scene elements as the target dynamic elements respectively.
5. The method according to claim 1, wherein The mapping the two-dimensional position of the target dynamic element in the current viewport to the element placement plane in three-dimensional space based on the camera viewing angle in three-dimensional space to obtain the corresponding three-dimensional position of the target dynamic element includes: Based on the camera view range in three-dimensional space and the viewport size of the current viewport, determining the viewport position of the current viewport in three-dimensional space; Within the viewport position of the three-dimensional space of the current viewport, starting from the two-dimensional coordinate point of the target dynamic element in the current viewport, a ray is emitted along the camera viewing angle direction in the three-dimensional space, and the three-dimensional coordinates corresponding to the intersection point of the ray and the element placement plane in the three-dimensional space are used as the three-dimensional position corresponding to the target dynamic element.
6. The method according to claim 1, wherein Based on the three-dimensional position corresponding to the target dynamic element, rendering the target dynamic element on the three-dimensional scene layer for three-dimensional rendering, and based on the two-dimensional positions of other scene elements in the scene element set in the current viewport, rendering the other scene elements on the two-dimensional scene layer for two-dimensional rendering, to obtain and display the scene image of the virtual scene in the current viewport, including: Based on the three-dimensional position corresponding to the target dynamic element, rendering the three-dimensional model information of the target dynamic element on the three-dimensional scene layer for three-dimensional rendering, to obtain the three-dimensional animation corresponding to the target dynamic element; Based on the two-dimensional positions of other scene elements in the scene element set in the current viewport, rendering the two-dimensional plane information of the other scene elements on the two-dimensional scene layer, to obtain the two-dimensional images corresponding to the other scene elements; the two-dimensional plane information includes any one of two-dimensional static image information, two-dimensional animated image information, and two-dimensional video information; Based on the three-dimensional animation corresponding to the target dynamic element and the two-dimensional images corresponding to the other scene elements, obtaining and displaying the scene image of the virtual scene in the current viewport.
7. The method according to claim 1, characterized in that, The method further includes: In response to a static / dynamic switching event for the target dynamic element, removing the target dynamic element from the three-dimensional scene layer and adding the target dynamic element to the two-dimensional scene layer; Based on the two-dimensional position of the target dynamic element in the current viewport, rendering the target dynamic element on the two-dimensional scene layer.
8. The method according to claim 7, wherein The static / dynamic switching event for the target dynamic element is generated when the three-dimensional animation corresponding to the target dynamic element in the scene image finishes playing, in the case where the scene elements rendered on the two-dimensional scene layer include dynamic elements; The method further includes: In response to a static / dynamic switching event for the target dynamic element, determining a first dynamic element from the dynamic elements rendered on the two-dimensional scene layer for receiving the three-dimensional playback right of the target dynamic element; Based on the camera viewing angle in the three-dimensional space, mapping the two-dimensional position of the first dynamic element in the current viewport to the element placement plane in the three-dimensional space, to obtain the three-dimensional position corresponding to the first dynamic element; Adding the first dynamic element to the three-dimensional scene layer, based on the three-dimensional position corresponding to the first dynamic element, rendering the first dynamic element on the three-dimensional scene layer, and removing the first dynamic element from the two-dimensional scene layer.
9. The method according to claim 8, characterized in that, The method further includes: When the first frame of the three-dimensional animation of the first dynamic element is rendered on the three-dimensional scene layer, removing the two-dimensional image corresponding to the first dynamic element from the two-dimensional scene layer.
10. The method according to claim 7, characterized in that, Rendering the target dynamic element on the two-dimensional scene layer based on the two-dimensional position of the target dynamic element in the current viewport includes: Obtaining a two-dimensional still image corresponding to the target dynamic element based on the first frame in the three-dimensional animation corresponding to the target dynamic element; Displaying the two-dimensional still image corresponding to the target dynamic element on the two-dimensional scene layer based on the two-dimensional position of the target dynamic element in the current viewport.
11. The method according to claim 1, characterized in that, The method further includes: In response to a dynamic element addition event for the set of scene elements, rendering the newly added dynamic element on the two-dimensional scene layer based on the two-dimensional position of the newly added dynamic element in the current viewport; In response to a static / dynamic switching event for the newly added dynamic element, mapping the two-dimensional position of the newly added dynamic element in the current viewport to an element placement plane in the three-dimensional space based on the camera viewing angle in the three-dimensional space to obtain the three-dimensional position corresponding to the newly added dynamic element; Adding the newly added dynamic element to the three-dimensional scene layer, rendering the newly added dynamic element on the three-dimensional scene layer based on the three-dimensional position corresponding to the newly added dynamic element, and removing the newly added dynamic element from the two-dimensional scene layer.
12. The method according to claim 1, wherein The method further includes: In response to a dynamic element deletion event for the target dynamic element, removing the target dynamic element from the three-dimensional scene layer; Determining a second dynamic element from the dynamic elements rendered on the two-dimensional scene layer for receiving the three-dimensional playback right of the target dynamic element; Mapping the two-dimensional position of the second dynamic element in the current viewport to an element placement plane in the three-dimensional space based on the camera viewing angle in the three-dimensional space to obtain the three-dimensional position corresponding to the second dynamic element; Adding the second dynamic element to the three-dimensional scene layer, rendering the second dynamic element on the three-dimensional scene layer based on the three-dimensional position corresponding to the second dynamic element, and removing the second dynamic element from the two-dimensional scene layer.
13. The method according to any one of claims 1 to 12, characterized in that, The method further includes: In response to a trigger operation on the contact status query entry in the communication application, taking the contact dynamic square for displaying the contact status in the communication application as a virtual scene, and entering the step of obtaining the set of scene elements to be displayed in the current viewport of the virtual scene; Wherein, the set of scene elements to be displayed in the current viewport of the virtual scene is determined based on the set of dynamic elements and the set of static elements corresponding to the contact dynamic square; the set of dynamic elements is obtained by acquiring the target contacts of the current logged-in account in the communication application, and is determined based on the target contacts and the virtual role of the current logged-in account in the communication application; the set of static elements is determined based on the square background design information.
14. A scene rendering device, characterized in that, The apparatus includes: An acquisition module, configured to acquire a set of scene elements to be displayed in the current viewport of a virtual scene; A determination module, configured to determine a target dynamic element from the set of scene elements; A mapping module, configured to map the two-dimensional position of the target dynamic element in the current viewport to an element placement plane in the three-dimensional space based on a camera viewing perspective in the three-dimensional space, so as to obtain a corresponding three-dimensional position of the target dynamic element; A rendering module, configured to render the target dynamic element on a three-dimensional scene layer for three-dimensional rendering based on the three-dimensional position corresponding to the target dynamic element, and render other scene elements on a two-dimensional scene layer for two-dimensional rendering based on the two-dimensional positions of the other scene elements in the current viewport, so as to obtain and display a scene picture of the virtual scene in the current viewport.
15. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 13 are implemented.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 13 are implemented.
17. A computer program product comprising a computer program, characterized in that, When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 13 are implemented.