Scene switching method and scene switching system
By storing and using a 2D renderer to process the view of the 3D renderer during 3D scene switching, replacing and rendering the scene, the memory overflow problem is solved, and the gradient transition effect is achieved, and the switching fluency of mobile devices is improved.
Patent Information
- Application Number
- CN202110260771.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-10
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2041-03-10
AI Technical Summary
During 3D scene switching, the prior art causes memory overflow, resulting in black screen/white screen problems in mobile devices, and huge memory overhead during the transition process.
By detecting scene switching events, store the drawn views on the 3D renderer, and use the 2D renderer to draw and overwrite the 3D renderer, replace the scene view, and render new views in gradient manner, initialize the 3D camera, adjust the rendering style to simulate the lens Close effect.
While reducing memory/visual memory space usage, the gradient transition effect is achieved, avoiding memory overflow problems and improving the fluency of scene switching.
Smart Images

Figure CN113034654B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of rendering technology, and in particular to a scene switching method and a scene switching system. Background Art
[0002] At present, when switching between different 3D scenes, the transition function of the reaction router is used to make the perspective transition from the 3D skybox before switching (the panorama with scene A) to the newly generated 3D skybox space (the panorama with scene B), thereby realizing the switching from scene A to scene B. This method is simple to implement but has huge memory overhead. During the transition period, at least two skybox scenes exist at the same time. In the mobile terminal scenario, most models will have black screen / white screen problems caused by memory overflow. Summary of the invention
[0003] The object of the present invention is to provide a scene switching method and a scene switching system, which can simulate the 3D transition effect of zooming in to gradually change to a new scene while reducing the memory / video memory space occupation.
[0004] In order to achieve the above-mentioned purpose, the first aspect of the present invention provides a scene switching method, which includes: when a triggering event of scene switching regarding a sky box is detected, storing a first view that has been drawn on a 3D renderer, wherein the first view is a view of a first scene captured from a first perspective of a 3D camera in the sky box; drawing the first view through a 2D renderer; covering the 3D renderer with the 2D renderer to continue rendering the first view through the 2D renderer; replacing multiple views of the first scene on the sky box with multiple views of a second scene, and initializing the 3D camera with a second perspective; and adjusting the rendering style of the first view that has been drawn on the 2D renderer to render the second view on the 3D renderer in a gradient manner, wherein the second view is a view of the second scene captured from the second perspective of the 3D camera.
[0005] Preferably, the scene switching method further comprises: establishing a connection between the 3D renderer and a buffer, and correspondingly, storing the drawn first view on the 3D renderer comprises: storing the first view through the buffer.
[0006] Preferably, the scene switching method further includes: establishing a connection between the 2D renderer and the buffer, and accordingly, drawing the first view through the 2D renderer includes: obtaining information about the first view from the buffer through the 2D renderer; and drawing the first view through the 2D renderer based on the information about the first view.
[0007] Preferably, before executing the storing of the drawn first view on the 3D renderer, the scene switching method further comprises: singularizing the skybox, and setting the skybox to be out of control of the reaction router, so as to render the first scene or the second scene through the skybox.
[0008] Preferably, the scene switching method further comprises: detecting a triggering event of the scene switching with respect to the sky box.
[0009] Preferably, the scene switching method further includes: establishing an empty component and a connection between the empty component and a reaction router. Accordingly, the detecting a triggering event of the scene switching of the skybox includes: reading the data to be rendered in the reaction router through the empty component; and when the data to be rendered indicates that a switch is to be made to the second scene, notifying the skybox in an event publishing and subscription manner that the first scene will be switched to the second scene.
[0010] Preferably, while executing the initializing of the 3D camera at the second viewing angle, the scene switching method further comprises: setting the position where the triggering event of the scene switching occurs as the focus of the 3D camera.
[0011] Preferably, adjusting the rendering style of the first view drawn on the 2D renderer includes: simultaneously transforming the position and transparency of the first view drawn on the 2D renderer.
[0012] Preferably, the size of the 2D renderer is greater than or equal to the size of the 3D renderer.
[0013] Through the above technical scheme, the present invention creatively stores the drawn first view on the 3D renderer when a triggering event regarding scene switching of the sky box is detected, and then overlays the 2D renderer on the 3D renderer after drawing the first view through the 2D renderer, then replaces the multiple views of the first scene on the sky box with the multiple views of the second scene, initializes the 3D camera with the second perspective, and finally adjusts the rendering style of the 2D renderer to render the second view on the 3D renderer in a gradient manner, thereby simulating the 3D transition effect of zooming in to gradually transition to a new scene while reducing the memory / video memory space occupied.
[0014] A second aspect of the present invention provides a scene switching system, which includes: a storage device for storing a first view drawn on a 3D renderer when a triggering event for scene switching regarding a sky box is detected, wherein the first view is a view of a first scene captured from a first perspective of a 3D camera in the sky box; a 2D renderer for drawing the first view; an overlay device for overlaying the 3D renderer with the 2D renderer to continue rendering the first view through the 2D renderer; a replacement device for replacing multiple views of the first scene on the sky box with multiple views of a second scene, and initializing the 3D camera with a second perspective; and an adjustment device for adjusting the rendering style of the first view drawn on the 2D renderer to render the second view on the 3D renderer in a gradient manner, wherein the second view is a view of the second scene captured from the second perspective of the 3D camera.
[0015] Preferably, the storage device is a buffer. Accordingly, the scene switching system further comprises: a first establishing device for establishing a connection between the 3D renderer and the buffer.
[0016] Preferably, the scene switching system further comprises: a second establishing device for establishing a connection between the 2D renderer and the buffer, and accordingly, the 2D renderer for drawing the first view comprises: obtaining information about the first view from the buffer; and drawing the first view according to the information about the first view.
[0017] Preferably, the scene switching system further comprises: a singularization device, for singularizing the skybox and setting the skybox to be not controlled by the reaction router, so as to render the first scene or the second scene through the skybox.
[0018] Preferably, the scene switching system further comprises: a detection device, configured to detect a triggering event of the scene switching of the sky box.
[0019] Preferably, the scene switching system also includes: a third establishing device for establishing an empty component and a connection between the empty component and a reaction router, and accordingly, the detection device includes: a reading module for reading the data to be rendered in the reaction router through the empty component; and a notification module for notifying the sky box that it will switch from the first scene to the second scene in an event publishing and subscription manner when the data to be rendered indicates that it is to switch to the second scene.
[0020] Preferably, the scene switching system further comprises: a setting device for setting the position where the triggering event of the scene switching occurs as the focus of the 3D camera.
[0021] Preferably, the adjusting device is used to adjust the rendering style of the first view drawn on the 2D renderer, including: simultaneously transforming the position and transparency of the first view drawn on the 2D renderer.
[0022] Preferably, the size of the 2D renderer is greater than or equal to the size of the 3D renderer.
[0023] For the specific details and benefits of the scene switching system provided by the present invention, please refer to the above description of the scene switching method, which will not be repeated here.
[0024] The third aspect of the present invention further provides a machine-readable storage medium, on which instructions are stored, and the instructions are used to enable a machine to execute the above-mentioned scene switching method.
[0025] The fourth aspect of the present invention also provides an electronic device, which includes: a processor; a memory for storing executable instructions of the processor; the processor is used to read the executable instructions from the memory and execute the instructions to implement the above-mentioned scene switching method.
[0026] Other features and advantages of the present invention will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present invention, but do not constitute a limitation on the embodiments of the present invention. In the accompanying drawings:
[0028] Figure 1 is a flow chart of a scene switching method provided by an embodiment of the present invention; and
[0029] Figure 2 It is a structural diagram of a scene switching system provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0030] The specific implementation of the present invention is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described here is only used to illustrate and explain the present invention, and is not used to limit the present invention.
[0031] Figure 1 FIG. 1 is a flow chart of a 3D scene switching method provided by an embodiment of the present invention. Figure 1As shown, the scene switching method may include steps S101-S105.
[0032] Before executing step S101, the scene switching method may further include: singularizing a skybox, and setting the skybox to be not controlled by a reaction router, so as to render the first scene or the second scene through the skybox.
[0033] In the current 3D scene switching process, the panorama of the first scene (i.e., multiple views / maps about the first scene) is displayed by the first skybox before the switching, and the panorama of the second scene (i.e., multiple views / maps about the second scene) is displayed by the second skybox after the switching, and the connection between the skybox and the reaction router is set, so that when the reaction router detects that the second scene corresponding to the second skybox is to be switched, the reaction router controls the view angle to switch to the second skybox. In other words, the scene switching process is realized by two skyboxes (i.e., the skybox is in a non-singletonized state). On this basis, in order to significantly reduce the memory usage, the skybox and its corresponding drawing components can be singletonized in the present embodiment, and the skybox is set to be out of the control of the reaction router (react-router), so that the view angle will not be switched to another skybox when the react-router detects the rendering data to be switched.
[0034] Before executing step S101, the scene switching method may further include: detecting a triggering event for scene switching of the sky box.
[0035] Specifically, the scene switching method may further include: establishing an empty component and a connection between the empty component and a reaction router. Accordingly, the detecting the triggering event of the scene switching of the skybox may include: reading the data to be rendered in the reaction router through the empty component; and in the case where the data to be rendered indicates that the second scene is to be switched, notifying the skybox that the first scene will be switched to the second scene in an event publishing and subscription manner.
[0036] Add an empty component in react-router, which can read the data in the router (such as data to be rendered, data related to another scene to be switched to). When the data read from the router indicates that the skybox panorama to be rendered has changed, the singleton skybox (i.e., 3D scene component) is notified to switch scenes by event publishing and subscription.
[0037] Step S101 : when a triggering event of scene switching related to a skybox is detected, storing a first view drawn on a 3D renderer.
[0038] The first view is a view of the first scene captured by the first viewing angle of the 3D camera in the sky box. Specifically, the first view is the current view rendered by the 3D renderer before switching: the view of the first scene captured by the current viewing angle of the 3D camera in the sky box.
[0039] In the current scene switching process, since two skyboxes are used to present the scenes before and after the switching respectively, it does not involve the storage and calling of the rendering results. In this embodiment, when a triggering event of scene switching is detected, the current view rendered by the 3D renderer (i.e., the first view before the switching) can be stored so that the current view can be rendered on the 2D (two-dimensional) renderer through step S102.
[0040] Before executing step S101, the scene switching method may further include: establishing a connection between the 3D renderer and a buffer. Accordingly, for step S101, storing the drawn first view on the 3D renderer includes: storing the first view via the buffer.
[0041] Specifically, a data connection is established between a 3D renderer (eg, WebGLRenderer) and a buffer, and a current drawing result before the switching of the 3D renderer is saved in the buffer.
[0042] Step S102: drawing the first view by using a 2D renderer.
[0043] In order to render the first view completely and in equal size on the 2D renderer, the size of the 2D renderer may be set to be greater than or equal to the size of the 3D renderer.
[0044] The 3D renderer may be a 3D canvas, and the 2D renderer may be a 2D canvas.
[0045] Specifically, after a triggering event of switching scenes is detected, the current drawing result of the 3D canvas (ie, the drawn first view) may be drawn on the 2D canvas as a graphic input.
[0046] Before executing step S102, the scene switching method may further include: establishing a connection between the 2D renderer and the buffer. Accordingly, for step S102, drawing the first view by the 2D renderer may include: acquiring information about the first view from the buffer by the 2D renderer; and drawing the first view by the 2D renderer according to the information about the first view.
[0047] Specifically, in this embodiment, in order to call the current view (the drawn first view) drawn by the 3D renderer before switching stored in the buffer, a data connection between the 2D canvas and the buffer can be established. Then, the relevant information of the first view is called through the 2D canvas, and the first view is drawn through the 2D canvas according to the called relevant information of the first view.
[0048] Step S103: Cover the 3D renderer with the 2D renderer to continue rendering the first view through the 2D renderer.
[0049] Specifically, the 2D canvas on which the first view is drawn is overlaid on the 3D canvas, so that the current view of the first scene (ie, the first view before switching) is continuously rendered to the viewer through the 2D canvas.
[0050] Step S104: replace the multiple views of the first scene on the sky box with multiple views of the second scene, and initialize the 3D camera with a second viewing angle.
[0051] The second viewing angle is the same as or different from the first viewing angle.
[0052] Specifically, while continuously rendering the current view of the first scene to the viewer through the 2D canvas, the multiple views of scene A on the sky box are replaced with multiple views of scene B, and the 3D camera is initialized with a new perspective (the new perspective may be the same as or different from the perspective of the 3D camera before the switch), so that the second view on the 3D renderer corresponding to the second perspective can be rendered in a gradient manner in step S105.
[0053] It should be noted that, in the current scene switching process, at least two 3D cameras (i.e., one 3D camera is configured for each skybox) need to be set to achieve the rendering of views of different scenes, while in various embodiments of the present invention, only one 3D camera can be set to achieve the switching between different scenes. Therefore, various embodiments of the present invention can achieve the 3D transition effect of a non-instantiated skybox through simple configuration.
[0054] While executing the initializing of the 3D camera at the second viewing angle, the scene switching method further includes: setting the position where the triggering event of the scene switching occurs as the focus of the 3D camera.
[0055] Specifically, when the viewer clicks on the scene switching component, in response to the triggering event of the scene switching, while initializing the 3D camera with the second perspective, the focus of the 3D camera can be set to the position where the scene switching component is located, so that the 3D camera can use this position as the focus to shoot the view within the switched second perspective, and then render the second view corresponding to the second perspective to the viewer.
[0056] Step S105 : adjusting the rendering style of the first view drawn on the 2D renderer to render the second view on the 3D renderer in a gradient manner.
[0057] The second view may be a view of the second scene captured from the second viewing angle of the 3D camera.
[0058] Regarding step S105 , adjusting the rendering style of the first view drawn on the 2D renderer may include: simultaneously transforming the position and transparency of the first view drawn on the 2D renderer.
[0059] Specifically, after replacing the multiple views on the skybox with the multiple views of the second scene, the position and transparency properties of the rendering style of the 2D canvas are controlled through Cascading Style Sheets (CSS) animation to enlarge and make transparent the first view drawn thereon, so that the new view of the second scene on the 3D canvas covered by it can be rendered through the 2D canvas, that is, simulating a zoom in of the camera to gradually transition to a new 3D perspective, thereby achieving a smooth 3D transition effect while avoiding animation freezes.
[0060] After the scene switch is completed, the 2D renderer (eg, 2D canvas) may be unloaded.
[0061] To summarize, the present invention creatively stores the drawn first view on the 3D renderer when a triggering event regarding scene switching of the sky box is detected, and then overlays the 2D renderer on the 3D renderer after drawing the first view through the 2D renderer, then replaces the multiple views of the first scene on the sky box with multiple views of the second scene, initializes the 3D camera with the second perspective, and finally adjusts the rendering style of the 2D renderer to render the second view on the 3D renderer in a gradient manner, thereby reducing the memory / video memory space occupied while simulating the 3D transition effect of zooming in to gradually transition to a new scene.
[0062] Figure 2 is a structural diagram of a scene switching system provided by an embodiment of the present invention. Figure 2As shown, the scene switching system may include: a storage device 10, for storing a first view drawn on a 3D renderer when a triggering event for scene switching regarding a sky box is detected, wherein the first view is a view of a first scene captured from a first perspective of a 3D camera in the sky box; a 2D renderer 20, for drawing the first view; a covering device 30, for covering the 3D renderer with the 2D renderer to continue rendering the first view through the 2D renderer; a replacement device 40, for replacing a plurality of views of the first scene on the sky box with a plurality of views of a second scene, and initializing the 3D camera with a second perspective; and an adjustment device 50, for adjusting the rendering style of the first view drawn on the 2D renderer to render a second view on the 3D renderer in a gradient manner, wherein the second view is a view of the second scene captured from the second perspective of the 3D camera.
[0063] Preferably, the storage device is a buffer. Accordingly, the scene switching system further comprises: a first establishing device for establishing a connection between the 3D renderer and the buffer.
[0064] Preferably, the scene switching system further comprises: a second establishing device for establishing a connection between the 2D renderer and the buffer, and accordingly, the 2D renderer for drawing the first view comprises: obtaining information about the first view from the buffer; and drawing the first view according to the information about the first view.
[0065] Preferably, the scene switching system further comprises: a singularization device, for singularizing the skybox and setting the skybox to be not controlled by the reaction router, so as to render the first scene or the second scene through the skybox.
[0066] Preferably, the scene switching system further comprises: a detection device, configured to detect a triggering event of the scene switching of the sky box.
[0067] Preferably, the scene switching system also includes: a third establishing device for establishing an empty component and a connection between the empty component and a reaction router, and accordingly, the detection device includes: a reading module for reading the data to be rendered in the reaction router through the empty component; and a notification module for notifying the sky box that it will switch from the first scene to the second scene in an event publishing and subscription manner when the data to be rendered indicates that it is to switch to the second scene.
[0068] Preferably, the scene switching system further comprises: a setting device for setting the position where the triggering event of the scene switching occurs as the focus of the 3D camera.
[0069] Preferably, the adjusting device is used to adjust the rendering style of the first view drawn on the 2D renderer, including: simultaneously transforming the position and transparency of the first view drawn on the 2D renderer.
[0070] Preferably, the size of the 2D renderer is greater than or equal to the size of the 3D renderer.
[0071] For the specific details and benefits of the scene switching system provided by the present invention, please refer to the above description of the scene switching method, which will not be repeated here.
[0072] An embodiment of the present invention further provides a machine-readable storage medium, on which instructions are stored, and the instructions are used to enable a machine to execute the above-mentioned scene switching method.
[0073] An embodiment of the present invention further provides an electronic device, comprising: a processor; a memory for storing executable instructions of the processor; the processor is configured to read the executable instructions from the memory and execute the instructions to implement the above-mentioned scene switching method.
[0074] The optional implementation modes of the embodiments of the present invention are described in detail above in conjunction with the accompanying drawings. However, the embodiments of the present invention are not limited to the specific details in the above implementation modes. Within the technical concept of the embodiments of the present invention, various simple modifications can be made to the technical scheme of the embodiments of the present invention, and these simple modifications all belong to the protection scope of the embodiments of the present invention.
[0075] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. To avoid unnecessary repetition, the embodiments of the present invention will not further describe various possible combinations.
[0076] Those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including a number of instructions to enable a single-chip microcomputer, a chip or a processor to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0077] In addition, various implementations of the embodiments of the present invention may be arbitrarily combined, and as long as they do not violate the concept of the embodiments of the present invention, they should also be regarded as the contents disclosed in the embodiments of the present invention.
Claims
1. A scene switching method, characterized in that: include: When a triggering event of scene switching about a skybox is detected, storing a first view drawn on a 3D renderer, wherein the first view is a view of a first scene captured from a first viewing angle of a 3D camera in the skybox, wherein storing the first view drawn on the 3D renderer comprises: storing the first view in a buffer; Drawing the first view by a 2D renderer includes: acquiring information about the first view from the buffer by the 2D renderer, and drawing the first view by the 2D renderer according to the information about the first view; Overlaying the 3D renderer with the 2D renderer to continue rendering the first view through the 2D renderer; Replacing the multiple views of the first scene on the skybox with multiple views of a second scene, and initializing the 3D camera with a second viewing angle; and The rendering style of the first view drawn on the 2D renderer is adjusted to render the second view on the 3D renderer in a gradient manner, wherein the second view is a view of the second scene captured from the second viewing angle of the 3D camera.
2. The scene switching method according to claim 1, characterized in that: The scene switching method further includes: establishing a connection between the 3D renderer and the buffer, and establishing a connection between the 2D renderer and the buffer.
3. The scene switching method according to claim 1, characterized in that: Before executing the step of storing the drawn first view on the 3D renderer, the scene switching method further includes: The skybox is instantiated, and the skybox is set to be not controlled by the reaction router, so as to render the first scene or the second scene through the skybox.
4. The scene switching method according to claim 1, characterized in that: The scene switching method further includes: detecting a triggering event of the scene switching related to the sky box.
5. The scene switching method according to claim 4, characterized in that: The scene switching method further comprises: establishing an empty component and a connection between the empty component and a reaction router; The detecting of the triggering event of the scene switching of the skybox comprises: Read the data to be rendered in the reaction router through the empty component; and When the data to be rendered indicates that the scene is to be switched to the second scene, the sky box is notified in an event publishing and subscription manner that the scene is to be switched from the first scene to the second scene.
6. The scene switching method according to claim 1, characterized in that: While executing the initializing the 3D camera with the second viewing angle, the scene switching method further includes: The position where the triggering event of the scene switching occurs is set as the focus of the 3D camera.
7. The scene switching method according to claim 1, characterized in that: The adjusting the rendering style of the first view drawn on the 2D renderer comprises: At the same time, the position and transparency of the first view drawn on the 2D renderer are transformed.
8. The scene switching method according to claim 1, characterized in that: The size of the 2D renderer is greater than or equal to the size of the 3D renderer.
9. A scene switching system, characterized in that: The scene switching system comprises: A storage device, configured to store a first view drawn on a 3D renderer when a triggering event of scene switching with respect to a sky box is detected, wherein the first view is a view with respect to a first scene captured from a first viewing angle of a 3D camera in the sky box; A 2D renderer, used for drawing the first view; An overlay device, configured to overlay the 3D renderer with the 2D renderer, so as to continue rendering the first view through the 2D renderer; A replacing device, configured to replace the multiple views of the first scene on the sky box with multiple views of a second scene, and initialize the 3D camera with a second viewing angle; and an adjusting device, configured to adjust a rendering style of the first view drawn on the 2D renderer, so as to render a second view on the 3D renderer in a gradient manner, wherein the second view is a view of the second scene captured from the second viewing angle of the 3D camera; Wherein, the storage device is a buffer; The 2D renderer, for drawing the first view, comprises: acquiring information about the first view from the buffer; and drawing the first view according to the information about the first view.
10. The scene switching system according to claim 9, characterized in that: The scene switching system further comprises: a first establishing device for establishing a connection between the 3D renderer and a buffer; and a second establishing device for establishing a connection between the 2D renderer and the buffer.
11. The scene switching system according to claim 9, characterized in that: The scene switching system also includes: The singularization device is used to singularize the skybox and set the skybox to be not controlled by the reaction router, so as to render the first scene or the second scene through the skybox.
12. The scene switching system according to claim 9, characterized in that: The scene switching system also includes: A detection device is used to detect a triggering event of the scene switching of the sky box.
13. The scene switching system according to claim 12, characterized in that: The scene switching system also includes: The third establishing means is used to establish the empty component and the connection between the empty component and the reaction router; The detection device comprises: A reading module, used for reading the data to be rendered in the reaction router through the empty component; and A notification module is used to notify the sky box that the first scene will be switched to the second scene in an event publishing and subscription manner when the data to be rendered indicates that the second scene is to be switched.
14. The scene switching system according to claim 9, characterized in that: The scene switching system also includes: The setting device is used to set the position where the triggering event of the scene switching occurs as the focus of the 3D camera.
15. The scene switching system according to claim 9, characterized in that: The adjusting device is used to adjust the rendering style of the first view drawn on the 2D renderer, including: At the same time, the position and transparency of the first view drawn on the 2D renderer are transformed.
16. The scene switching system according to claim 9, characterized in that: The size of the 2D renderer is greater than or equal to the size of the 3D renderer.
17. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores instructions, which are used to enable a machine to execute the scene switching method described in any one of claims 1 to 8.
18. An electronic device, characterized in that: The electronic device comprises: processor; a memory for storing instructions executable by the processor; The processor is used to read the executable instructions from the memory and execute the instructions to implement the scene switching method described in any one of claims 1 to 8.
