Method, device and system for realizing portal effect in virtual scene
By acquiring the camera images of the portal and destination gate, calculating their positions and creating replicas, processing the occluded parts, and recursively displaying the images, the screen flickering problem of the portal effect in the virtual scene is solved, and the real transmission of objects and the smooth transmission of physical effects are achieved.
Patent Information
- Application Number
- CN202211103897.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-09
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2042-09-09
AI Technical Summary
The portal effect in existing virtual scenes cannot achieve the real teleportation and physical effects of objects, resulting in flickering screen images and partial appearance of objects on the other side of the door.
By obtaining images from the cameras of the portal and destination gate, their positions and screen space are calculated, it is determined whether the game model has passed through the portal and a copy is created. The occluded part of the game model is processed using a surface shader, and the destination gate image is recursively displayed to achieve real teleportation and physical effects of the object.
There is no obvious display effect disharmony during the object transmission process, achieving a smooth portal effect, suitable for low-performance devices.
Smart Images

Figure CN116310017B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of virtual display and enhanced display development, and in particular to a method, device and system for realizing a portal effect in a virtual scene. Background Art
[0002] Most of the portal effects in current games are just delicate pictures or the display effects cannot fully meet common sense. For example, the picture of the destination door in another area displayed in the portal cannot be completely stitched together with the portal frame, the screen will flicker when the game model itself passes through the door, and part of the object will appear on the other side of the door when it turns through the door.
[0003] Therefore, how to design a method for realizing the portal effect of the real transmission of objects and physical effects in a virtual scene is still a technical problem to be solved in this field. Summary of the Invention
[0004] In view of this, the present invention proposes a method, device and system for realizing a portal effect in a virtual scene, so as to realize a portal effect with real teleportation of objects and physical effects in the virtual scene.
[0005] A first aspect of the present invention provides a method for achieving a portal effect in a virtual scene, comprising the following steps:
[0006] Build a virtual scene, obtain images from the cameras belonging to the transmission gate and the destination gate, fit the images to the gate entrance plane, and calculate the positions of the cameras belonging to the transmission gate and the destination gate and the screen space of the corresponding entrance plane;
[0007] When the game model passes through the portal to the destination portal, determine whether the game model has passed through the portal and calculate the position of the game model after the portal is transferred;
[0008] Create a replica of the game model. When more than half of the game model's position passes through the portal, swap the position of the replica with the position of the game model to achieve teleportation of the game model.
[0009] Using the surface shader attached to the player model mesh, the game model's copy is deleted after the game model completely leaves the portal area;
[0010] The transmission image acquired by the destination gate camera in the destination gate entrance plane is recursively displayed on the transmission gate entrance plane according to the set recursion times.
[0011] Furthermore, the steps of acquiring images from cameras belonging to the transmission gate and the destination gate, aligning the images with the gate entrance plane, and calculating the positions of the cameras belonging to the transmission gate and the destination gate and the screen space of the corresponding entrance plane include:
[0012] Create a portal camera, a destination portal camera, a portal entrance plane, and a destination portal entrance plane, and display the image captured by the camera belonging to the other portal;
[0013] According to the positions of the portal, the game model, and the game model's camera, the position of the camera to which the destination portal belongs is calculated;
[0014] Calculate the position of the camera to which the portal belongs based on the position of the destination gate, the game model, and the game model's camera;
[0015] Get the screen position of the destination portal entrance plane and calculate the screen space displayed on the portal entrance plane;
[0016] Get the screen position of the portal entrance plane and calculate the screen space displayed on the destination portal entrance plane.
[0017] Furthermore, the determining whether the game model has passed through the portal and calculating the position of the game model after the portal is transferred includes:
[0018] Calculate the angle between the portal and the forward vector of the game model;
[0019] Determine whether the angle is greater than 90. If the angle is greater than 90, it means that the game model has passed through the portal entrance plane at the current moment;
[0020] The position of the game model after transmission is calculated based on the transmission portal, the game model and the position of the game model before transmission.
[0021] Furthermore, the step of establishing a replica of the game model and, when more than half of the position of the game model has passed the transmission gate, exchanging the position of the replica of the game model with the position of the game model to achieve transmission of the game model comprises:
[0022] Stretch the mesh where the portal entrance plane is located into a cuboid to give it thickness;
[0023] Modify the shader of the portal entrance plane;
[0024] Create a replica of the game model. When the center point of the game model crosses the entrance plane of the portal, the positions of the replica and the game model are swapped to achieve teleportation.
[0025] Use shaders to cull portals and destination doors that obscure the player model mesh.
[0026] Furthermore, using a surface shader mounted on the player model mesh to completely delete the game model copy after the game model completely leaves the portal area includes:
[0027] Determine whether the player model mesh crosses the portal entrance plane, and remove the part of the model that crosses the portal entrance plane;
[0028] The relative position of the portal entrance plane to the player model mesh is detected and passed as an offset to the surface shader on the clone player model mesh and the player model mesh, so that the part of the player model mesh that is culled and the part of the clone player model mesh that is displayed are the same.
[0029] Furthermore, before the step of recursively displaying the transmission image acquired by the destination door camera in the destination door entrance plane on the transmission door entrance plane according to the set recursive times, the step further includes:
[0030] Filters objects that are too close to the portal camera and the destination portal camera.
[0031] Furthermore, the step of filtering objects that are too close to the transmission gate camera and the destination gate camera includes:
[0032] Determine which side of the portal the player is on based on the dot product of the portal entrance plane and the vector of the game model relative to the portal entrance plane;
[0033] Calculate the normal vector of the portal entrance plane using the portal camera's screen space matrix;
[0034] The screen space distance of the portal camera is obtained by multiplying the screen space position of the portal camera by the normal vector of the portal entrance plane.
[0035] A custom projection matrix consisting of the portal entrance plane's normal vector and the portal camera's screen-space distance is applied to align the portal camera's near clip plane with the portal entrance plane's surface.
[0036] Furthermore, the step of infinitely recursively displaying the transmission image acquired by the destination gate camera in the destination gate entrance plane on the transmission gate entrance plane includes:
[0037] Calculate the position of the game model relative to the target door entrance plane;
[0038] Recursively calculate the position of the next game model relative to the target gate entrance plane in the recursive loop using the number of times the loop is realized;
[0039] The images of the transmission gate entrance plane displayed at the position of each destination gate entrance plane are extracted and superimposed.
[0040] A second aspect of the present invention provides a device for realizing a portal effect in a virtual scene, specifically comprising:
[0041] The scene building module is used to build the virtual scene, obtain the images of the cameras belonging to the transmission gate and the destination gate, fit the images to the gate entrance plane, and calculate the positions of the cameras belonging to the transmission gate and the destination gate and the screen space of the corresponding entrance plane;
[0042] The game model position calculation module is used to determine whether the game model has passed through the transmission gate and calculate the position of the game model after transmission when the game model passes through the transmission gate to the destination gate;
[0043] The player teleportation module is used to create a replica of the game model. When the position of the game model exceeds half of the teleportation gate, the position of the replica of the game model and the position of the game model are swapped to realize the teleportation of the game model.
[0044] A game model duplicate deletion module, configured to use a surface shader attached to the player model mesh to delete the game model duplicate after the game model completely leaves the portal area;
[0045] The image acquisition module is used to recursively display the transmission image acquired by the destination door camera in the destination door entrance plane on the transmission door entrance plane according to the set recursion times.
[0046] A third aspect of the present invention provides a system for realizing a portal effect in a virtual scene, the system comprising: a memory for storing a computer program; and a processor for implementing the steps of the method for realizing a portal effect in a virtual scene as described above when executing the computer program.
[0047] The method, device and system for realizing the portal effect in the above-mentioned virtual scene can be observed at all angles and when the object is being transported, without any obvious display effect being inconsistent, and can realize a smooth portal effect on lower-performance devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] For purposes of illustration and not limitation, the present invention will now be described with reference to preferred embodiments thereof, particularly with reference to the accompanying drawings, in which:
[0049] Figure 1 This is a flow chart of a method for achieving a portal effect in a virtual scene provided by one embodiment of the present invention;
[0050] Figure 2 It is a screen space diagram of the portal entrance plane and the destination portal entrance plane;
[0051] Figure 3 This is a schematic diagram of the model mesh of the replica and the player body;
[0052] Figure 4 This is a schematic diagram of the restored effect;
[0053] Figure 5 It is a recursive calculation of the position of the next player body relative to the target gate entrance plane in the recursive loop;
[0054] Figure 6 It is a superimposed effect diagram of the image of the portal entrance plane displayed at the location of each destination portal entrance plane;
[0055] Figure 7 2 is a schematic diagram of a system for realizing a portal effect in a virtual scene provided by another embodiment of the present invention. DETAILED DESCRIPTION
[0056] In order to more clearly understand the above-mentioned objects, features and advantages of the present invention, the present invention is described in detail below with reference to the accompanying drawings and specific embodiments. It should be noted that the embodiments of the present invention and the features therein can be combined with each other without conflict.
[0057] The following description sets forth numerous specific details to facilitate a thorough understanding of the present invention. The embodiments described are merely some, not all, of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are intended to fall within the scope of protection of the present invention.
[0058] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present invention. The terms used in this specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention.
[0059] Figure 1 This is a flowchart of a method for implementing a portal effect in a virtual scene, provided by one embodiment of the present invention. Taking the virtual scene as a game screen (Unity Engine) as an example, where the game model can be multiple teleportation models, the method for implementing a portal effect in a virtual scene, proposed in this application, is described in detail below, using the player as an example.
[0060] See also Figure 1 The specific implementation steps of the method for realizing the portal effect in the virtual scene include:
[0061] S100, build a virtual scene, obtain images from the cameras of the transmission gate P1 and the destination gate P2 respectively, calculate the camera positions of the transmission gate P1 and the destination gate P2, and display them on the entrance plane of the corresponding portal.
[0062] First, build a virtual scene and obtain images from the cameras belonging to the transmission gate P1 and the destination gate P2, so that the images are completely aligned with the entrance and exit planes P1Screen and P2Screen.
[0063] In this embodiment, the specific implementation of step S100 is as follows:
[0064] S101, create a portal camera P1Cam, a destination door camera P2Cam and two planes P1Screen and P2Screen in the game screen (Unity Engine) to serve as the entrance and exit of the transmission, and display the picture taken by the camera belonging to the other door.
[0065] S102, calculate the position of the camera belonging to the destination gate P2 through the positions of the portal P1, the player body and the player body camera PlayerCam.
[0066] The calculation method for the position of the camera belonging to the destination gate P2 is:
[0067] p2CamPos=(p1Pos.Matrix*p2Pos.Matrix*playerCamPos.Matrix).GetColumn
[0068] Among them, p2CamPos is the position of the destination door camera; p1Pos.Matrix is the portal matrix; p2Pos.Matrix is the destination door matrix; playerCamPos.Matrix is the player's camera matrix; Matrix4x4.GetColumn is often used in the matrix to obtain the position.
[0069] S103, calculate the position of the camera to which the portal P1 belongs through the positions of the destination portal P2, the player body and the player body camera PlayerCam.
[0070] The calculation method for the position of the camera to which portal P1 belongs is:
[0071] p1CamPos=(p2Pos.Matrix*p1Pos.Matrix*playerCamPos.Matrix).GetColumn
[0072] Among them, p1CamPos is the portal camera position; p2Pos.Matrix is the destination portal matrix; p1Pos.Matrix is the portal matrix; playerCamPos.Matrix is the player's camera matrix.
[0073] S104, obtaining the screen position of uv of the destination portal entrance plane P2Screen, dividing the screen position of uv of the destination portal entrance plane P2Screen by the w component to calculate the screen space uv displayed on the transmission portal entrance plane P1Screen.
[0074] Among them, the w component represents the depth of the current point from the screen. Usually, the three values xyz are used to represent the position of an object in three-dimensional space.
[0075] S105 , obtaining the screen position of the uv of the portal entrance plane P1Screen, and dividing the screen position of the uv of the portal entrance plane P1Screen by the w component to calculate the screen space uv displayed on the destination portal entrance plane P2Screen.
[0076] The screen space of the portal entrance plane P1Screen and the screen space of the destination portal entrance plane P2Screen are as follows Figure 2 shown.
[0077] S200, when the player body passes through the teleportation gate to the destination gate, determine whether the player body passes through the teleportation gate and calculate the position of the player body after the teleportation.
[0078] In this embodiment, the specific implementation of step S200 is as follows:
[0079] S210, when the player body passes through the portal to the destination portal, the angle θ between the portal P1 and the forward vector of the player body Player is calculated.
[0080] S220, determining whether the angle θ is greater than 90. If it is greater than 90, it indicates that the player has passed through the portal entrance plane P1Screen at this moment (frame).
[0081] S230, calculating the position of the player body Player after the transmission through the transmission portal P1, the player body and the position of the player body before the transmission.
[0082] In this embodiment, the method for calculating the position of the player after teleportation is:
[0083] playerAfterPos=(p1Pos.Matrix*p2Pos.Matrix*playerBeforPos.Matrix).GetColumn
[0084] Among them, playerAfterPos is the position of the player body after teleportation; p1Pos.Matrix is the teleportation gate matrix; p2Pos.Matrix is the destination gate matrix; playerBeforPos.Matrix is the position of the player body before teleportation.
[0085] S300, creating a player clone. When the player's main body position exceeds half of the teleportation gate, the player's clone position and the player's main body position are swapped to achieve the player's main body teleportation.
[0086] In order to avoid screen flickering at the moment of transmission, the part of the player model mesh PlayerMesh that is blocked by the transmission portal P1 and the destination portal P2 is removed.
[0087] In this embodiment, the specific implementation of step S300 is as follows:
[0088] S310, stretching the grid where the portal entrance plane P1Screen is located into a cuboid so that it has thickness.
[0089] S320, modify the shader of the portal entrance plane P1Screen and turn off occlusion culling (CullOff) to avoid flashing when passing through the portal.
[0090] S330, creating a copy of the player's body, namely the player's clone. When more than half of the player's body has passed the portal, the positions of the player's clone and the player's body are swapped to achieve teleportation.
[0091] Copy the player body Player who is crossing the portal entrance plane P1Screen to the corresponding position in the destination portal entrance plane P2Screen. The player copy is ClonePlayer. When the center point of the player body Player crosses the portal entrance plane P1Screen, the positions of the player copy ClonePlayer and the player body Player are swapped to achieve the teleportation effect.
[0092] S340, using a shader to cull the portion of the player model mesh that is blocked by the portal and the destination door.
[0093] S400, using the surface shader mounted on the player model mesh to delete the player copy after the player body completely leaves the portal area.
[0094] In this embodiment, the specific implementation of step S400 is as follows:
[0095] S410, determining whether the player model mesh crosses the portal entrance plane P1Screen, and removing the part of the model that crosses the portal entrance plane P1Screen.
[0096] In this embodiment, the angle θ is obtained to determine which part of the player model mesh PlayerMesh needs to be discarded, that is, the dot product is used to calculate which part of the player model mesh PlayerMesh crosses the portal entrance plane P1Screen. If it crosses the portal entrance plane P1Screen, this part of the player model mesh PlayerMesh is discarded so that it cannot be displayed on the portal entrance plane P1Screen.
[0097] S420, detect the relative position of the portal entrance plane P1Screen in the player model mesh PlayerMesh, and pass it as an offset to the surface shader SurfShader on the clone player model mesh ClonePlayerMesh and the player model mesh PlayerMesh.
[0098] In this embodiment, the relative position of the portal entrance plane P1Screen in the player model mesh PlayerMesh is detected and passed as an offset to the surface shader SurfShader on the clone player model mesh ClonePlayerMesh and the player model mesh PlayerMesh, so that the part of the player model mesh PlayerMesh that is culled is the same as the part displayed by the clone player model mesh ClonePlayerMesh. The effect is as follows: Figure 3 shown.
[0099] S500: Filter objects that are too close to the transmission gate camera P1Cam and the destination gate camera P2Cam.
[0100] When the content captured by the destination camera P2Cam is displayed on the portal entrance plane P1Screen, if an object is too close to the camera, it will ruin the visual experience. Therefore, objects that are too close to the portal camera P1Cam and the destination camera P2Cam must be filtered out.
[0101] In this embodiment, vectors are used to calculate which side of the portal the object is on during transmission and the progress of the transmission.
[0102] In this embodiment, the specific implementation of step S500 is as follows:
[0103] S510, judging which side of the portal the player is on based on the dot product of the portal entrance plane P1Screen and the vector of the player body Player relative to the portal entrance plane P1Screen.
[0104] S520 , using the screen space matrix of the portal camera P1Cam, calculate the normal vector P1ScreenNormal of the portal entrance plane P1Screen.
[0105] S530 , obtain the screen space distance P1CamSpaceDst of the portal camera P1Cam by performing a dot product between the screen space position of the portal camera P1Cam and the normal vector P1ScreenNormal of the portal entrance plane P1Screen.
[0106] S540, in UnityEngine, use CalculateObliqueMatrix to process the custom projection matrix composed of the normal vector P1ScreenNormal of the portal entrance plane P1Screen and the screen space distance P1CamSpaceDst of the portal camera P1Cam, so as to align the near clip plane of the portal camera P1Cam with the surface of the portal entrance plane P1Screen. The effect is as follows: Figure 4 shown.
[0107] S600: Recursively display the transmitted image captured by the destination gate camera in the destination gate entrance plane on the transmission gate entrance plane according to the set number of recursions. Specifically, when transmission gate P1 and destination gate P2 face each other, the transmitted image captured by the destination gate camera P2Cam in the destination gate entrance plane P2Screen will be infinitely recursively displayed on the transmission gate entrance plane P1Screen.
[0108] In this embodiment, the specific implementation of step S600 is as follows:
[0109] S610, calculating the position of the player Player relative to the target door entrance plane P2Screen.
[0110] S620, using the number of loops RLimit, recursively calculates the position tempPlayerPos of the next player body player relative to the target door entrance plane P2Screen in the recursive loop, and the effect is as follows: Figure 5 shown.
[0111] In this embodiment, the number of recursive displays is set according to the user's hardware rendering capability.
[0112] S630, extract the transmission images displayed by the transmission gate camera P1Cam on the position tempPlayerPos of each destination gate entrance plane P2Screen from far to near and superimpose them, the effect is as follows Figure 6 shown.
[0113] The above-mentioned method for realizing the portal effect in the virtual scene can be observed at all angles and when the object is being transported, without any obvious display effect being inconsistent, and a smooth portal effect can be realized on lower-performance devices.
[0114] Corresponding to the above method embodiment, see Figure 7 , Figure 7 This is a schematic diagram of a system for implementing a portal effect in a virtual scene according to another embodiment of the present invention. The system 100 may include:
[0115] Memory 101, used for storing computer programs;
[0116] The processor 102 may implement the following steps when executing the computer program stored in the memory 101:
[0117] Build a virtual scene, obtain images from the cameras belonging to the portal and destination gate, calculate the positions of the cameras belonging to the portal and destination gate and the screen space of the corresponding entrance plane; determine whether the player body has passed through the portal, and calculate the position of the player body after the teleportation; remove the parts of the player model mesh that are blocked by the portal and destination gate; filter objects that are too close to the portal camera and destination gate camera; recursively display the teleported image obtained by the destination gate camera in the destination gate entrance plane on the portal entrance plane according to the set number of recursions.
[0118] The above specific embodiments do not limit the scope of protection of the present invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may occur depending on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention are intended to be included within the scope of protection of the present invention.
Claims
1. A method for realizing a portal effect in a virtual scene, characterized in that: The steps include: Build a virtual scene, obtain images from the cameras belonging to the transmission gate and the destination gate, fit the images to the gate entrance plane, and calculate the positions of the cameras belonging to the transmission gate and the destination gate and the screen space of the corresponding entrance plane; When the game model passes through the portal to the destination portal, determine whether the game model has passed through the portal and calculate the position of the game model after the portal is transferred; Create a replica of the game model. When more than half of the game model's position passes through the portal, swap the position of the replica with the position of the game model to achieve teleportation of the game model. Using the surface shader attached to the player model mesh, the game model's copy is deleted after the game model completely leaves the portal area; Recursively displaying the transmission image acquired by the destination gate camera in the destination gate entrance plane on the transmission gate entrance plane according to the set recursion times; Using the surface shader attached to the player model mesh to delete the game model copy after the game model completely leaves the portal area includes: Determine whether the player model mesh crosses the portal entrance plane, and remove the part of the model that crosses the portal entrance plane; Detect the relative position of the portal entrance plane in the player model mesh and pass it as an offset to the surface shader on the clone player model mesh and the player model mesh, so that the part of the player model mesh that is culled is the same as the part displayed by the clone player model mesh; Before the step of recursively displaying the transmission image acquired by the destination door camera in the destination door entrance plane on the transmission door entrance plane according to the set recursive number of times, the step further includes: Filter objects that are too close to the portal camera and the destination portal camera; The step of filtering objects that are too close to the transmission gate camera and the destination gate camera includes: Determine which side of the portal the player is on based on the dot product of the portal entrance plane and the vector of the game model relative to the portal entrance plane; Calculate the normal vector of the portal entrance plane using the portal camera's screen space matrix; The screen space distance of the portal camera is obtained by multiplying the screen space position of the portal camera by the normal vector of the portal entrance plane. A custom projection matrix consisting of the portal entrance plane's normal vector and the portal camera's screen-space distance is applied to align the portal camera's near clip plane with the portal entrance plane's surface.
2. The method for realizing a portal effect in a virtual scene according to claim 1, characterized in that: The steps of obtaining images from cameras belonging to the transmission gate and the destination gate, aligning the images with the gate entrance plane, and calculating the positions of the cameras belonging to the transmission gate and the destination gate and the screen space of the corresponding entrance plane include: Create a portal camera, a destination portal camera, a portal entrance plane, and a destination portal entrance plane, and display the image captured by the camera belonging to the other portal; According to the positions of the portal, the game model, and the game model's camera, the position of the camera to which the destination portal belongs is calculated; Calculate the position of the camera to which the portal belongs based on the position of the destination gate, the game model, and the game model's camera; Get the screen position of the destination portal entrance plane and calculate the screen space displayed on the portal entrance plane; Get the screen position of the portal entrance plane and calculate the screen space displayed on the destination portal entrance plane.
3. The method for realizing a portal effect in a virtual scene according to claim 1, wherein: The determining whether the game model has passed through the portal and calculating the position of the game model after the portal is transferred includes: Calculate the angle between the portal and the forward vector of the game model; Determine whether the angle is greater than 90. If the angle is greater than 90, it means that the game model has passed through the portal entrance plane at the current moment; The position of the game model after transmission is calculated based on the transmission portal, the game model and the position of the game model before transmission.
4. The method for realizing a portal effect in a virtual scene according to claim 1, wherein: The step of establishing a replica of the game model and, when more than half of the position of the game model has passed the teleportation gate, swapping the position of the replica of the game model with the position of the game model to achieve teleportation of the game model comprises: Stretch the mesh where the portal entrance plane is located into a cuboid to give it thickness; Modify the shader of the portal entrance plane; Create a replica of the game model. When the center point of the game model crosses the entrance plane of the portal, the positions of the replica and the game model are swapped to achieve teleportation. Use shaders to cull portals and destination doors that obscure the player model mesh.
5. The method for realizing a portal effect in a virtual scene according to claim 1, characterized in that: The step of infinitely recursively displaying the transmission image acquired by the destination gate camera in the destination gate entrance plane on the transmission gate entrance plane comprises: Calculate the position of the game model relative to the target door entrance plane; Recursively calculate the position of the next game model relative to the target gate entrance plane in the recursive loop using the number of times the loop is realized; The images of the transmission gate entrance plane displayed at the position of each destination gate entrance plane are extracted and superimposed.
6. A device for realizing a portal effect in a virtual scene, characterized in that: include: The scene building module is used to build the virtual scene, obtain the images of the cameras belonging to the transmission gate and the destination gate, fit the images to the gate entrance plane, and calculate the positions of the cameras belonging to the transmission gate and the destination gate and the screen space of the corresponding entrance plane; The game model position calculation module is used to determine whether the game model has passed through the transmission gate and calculate the position of the game model after transmission when the game model passes through the transmission gate to the destination gate; The player teleportation module is used to create a replica of the game model. When the position of the game model exceeds half of the teleportation gate, the position of the replica of the game model and the position of the game model are swapped to realize the teleportation of the game model. A game model duplicate deletion module, configured to use a surface shader attached to the player model mesh to delete the game model duplicate after the game model completely leaves the portal area; An image acquisition module, configured to recursively display the transmission image acquired by the destination gate camera in the destination gate entrance plane on the transmission gate entrance plane according to a set number of recursions; Using the surface shader attached to the player model mesh to delete the game model copy after the game model completely leaves the portal area includes: Determine whether the player model mesh crosses the portal entrance plane, and remove the part of the model that crosses the portal entrance plane; Detect the relative position of the portal entrance plane in the player model mesh and pass it as an offset to the surface shader on the clone player model mesh and the player model mesh, so that the part of the player model mesh that is culled is the same as the part displayed by the clone player model mesh; Before the step of recursively displaying the transmission image acquired by the destination door camera in the destination door entrance plane on the transmission door entrance plane according to the set recursive number of times, the step further includes: Filter objects that are too close to the portal camera and the destination portal camera; The step of filtering objects that are too close to the transmission gate camera and the destination gate camera includes: Determine which side of the portal the player is on based on the dot product of the portal entrance plane and the vector of the game model relative to the portal entrance plane; Calculate the normal vector of the portal entrance plane using the portal camera's screen space matrix; The screen space distance of the portal camera is obtained by multiplying the screen space position of the portal camera by the normal vector of the portal entrance plane. A custom projection matrix consisting of the portal entrance plane's normal vector and the portal camera's screen-space distance is applied to align the portal camera's near clip plane with the portal entrance plane's surface.
7. A system for realizing a portal effect in a virtual scene, characterized in that: include: memory for storing computer programs; A processor, configured to implement the steps of the method for realizing a portal effect in a virtual scene as claimed in any one of claims 1 to 5 when executing the computer program.
Citation Information
Patent Citations
Virtual scene conversion method and device, terminal equipment and storage medium
CN110163976A
Image data processing method and device, storage medium and computer equipment
CN112891940A