Reflection effect processing method and device, electronic equipment and storage medium
By acquiring and computing the map of the virtual object model from the view perspective of the virtual camera, the problem of high requirements for terminal device resources in the prior art is solved, and more efficient rendering and lower memory consumption are achieved.
Patent Information
- Application Number
- CN202411978621.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-05-23
AI Technical Summary
The prior art requires high resource requirements for terminal devices when rendering reflection effects in virtual scenes, resulting in increased performance and memory overhead.
By determining the view angle of the virtual camera, obtain maps of the pre-established virtual object model, and calculate the target map of the reflection effect based on the relative relationship, avoiding reflection capture and screen space reflection.
Reduces resource requirements for terminal devices when processing reflection results, improves rendering efficiency, and reduces memory consumption.
Smart Images

Figure CN120022596A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer processing technology, and in particular to a reflection effect processing method, device, electronic equipment, storage medium and program product. Background Art
[0002] In some virtual scenes, such as games, there is an effect in which a virtual object model in the rendered virtual scene is reflected by another virtual object model in the virtual scene, such as the reflection effect of the sky being reflected by the water surface.
[0003] In the related art, when rendering the reflection effect between the sky and the water surface, reflection capture (reflection capture) and screen space reflection (SSR) are usually used.
[0004] However, reflection capture and screen space reflections are resource-intensive on the end device. Summary of the invention
[0005] In view of this, an object of the present invention is to provide a method, device, electronic device, storage medium and program product for processing reflection effects, which can reduce the resource requirements of terminal devices when processing reflection results.
[0006] In a first aspect, an embodiment of the present invention provides a method for processing a reflection effect, comprising: determining a first view angle of a virtual camera; obtaining a first target map of the first virtual object model under the first view angle from a pre-established first map of the first virtual object model, the first map being used to render the reflection effect of the first virtual object model; obtaining a second target map of the second virtual object model under the first view angle based on the first target map under the first view angle and a predetermined relative relationship between the first virtual object model and the second virtual object model, the second target map being used to render the reflection effect of the first virtual object model reflected by the second virtual object model, the relative relationship being used to indicate the relative positions of the first virtual object model and the second virtual object model in the same virtual scene.
[0007] In a possible implementation, the method also includes: in response to a switching instruction of the view angle of the virtual camera, switching from the first view angle to the second view angle; obtaining a first target map of the first virtual object model under the second view angle from the first map; and obtaining a second target map of the second virtual object model under the second view angle based on the first target map and the relative relationship under the second view angle.
[0008] In a possible implementation, obtaining a first target map of a first virtual object model under a second view perspective from a first map includes: determining switching information of a virtual camera's view perspective based on a view perspective switching instruction, wherein the switching information includes movement distance information and / or view perspective rotation information, wherein the view perspective rotation information includes view perspective rotation direction information and view perspective rotation angle information; determining an offset cropping range of the first target map based on the switching information, wherein the offset cropping range is used to indicate a view perspective offset of the first target map; and obtaining the first target map under a second view perspective from the first map based on the offset cropping range.
[0009] In one possible implementation, the method is applied to a terminal device, the terminal device includes a display device for displaying a view, and based on switching information, an offset cropping range of a first target map is determined, including: acquiring an aspect ratio of the view and a second map of a pre-established second virtual object model, the second map is used to render a reflection effect of the second virtual object model, and the second map is established based on the view distance of the virtual camera; based on the switching information, the aspect ratio and the second map, the offset cropping range of the first target map is determined.
[0010] In a possible implementation, the method also includes: for each first pixel point in the first target map under the first view angle, determining the sight direction vector between the first pixel point and the virtual camera; obtaining the first normal vector of the first target map; for each first pixel point, based on the sight direction vector and the first normal vector corresponding to the first pixel point, obtaining the first reflection direction vector of the first pixel point; based on the first reflection direction vector corresponding to each first pixel point, texture sampling the first target map to obtain the first texture information corresponding to each first pixel point; based on the first texture information corresponding to each first pixel point, rendering the first virtual object model.
[0011] In a possible implementation, based on the first target map at the first view perspective and a predetermined relative relationship between the first virtual object model and the second virtual object model, a second target map of the second virtual object model at the first view perspective is obtained, including: for each first pixel point in the first target map at the first view perspective, mapping the first pixel point to a second pixel point of the second virtual object model based on the relative relationship; and based on all the second pixels, obtaining the second target map of the second virtual object model at the first view perspective.
[0012] In a possible implementation, the relative relationship includes a model matrix and a projection matrix, the model matrix is used to indicate the model mapping relationship between the first virtual object model and the second virtual object model, and the projection matrix is used to indicate the projection relationship between the pixel points of the first virtual object model and the second virtual object model; for each first pixel point in the first target map under the first view perspective, mapping the first pixel point to the second pixel point of the second virtual object model based on the relative relationship includes: for each first pixel point in the first target map under the first view perspective, mapping the first pixel point to the second pixel point of the second virtual object model based on the model matrix and the projection matrix.
[0013] In a possible implementation, the viewing angle of the virtual camera is variable. Before mapping each first pixel point in the first target map under the first viewing angle to a second pixel point of the second virtual object model based on a model matrix and a projection matrix, it also includes: obtaining a view matrix corresponding to the first viewing angle, the view matrix being used to indicate a mapping relationship between the first viewing angle and the virtual camera; for each first pixel point in the first target map under the first viewing angle, mapping the first pixel point to a second pixel point of the second virtual object model based on the model matrix and the projection matrix, including: for each first pixel point in the first target map under the first viewing angle, mapping the first pixel point to a second pixel point of the second virtual object model based on the view matrix, the model matrix and the projection matrix.
[0014] In a possible implementation, the method also includes: for each second pixel point in the second target map under the first view angle, determining the sight direction vector between the second pixel point and the virtual camera; obtaining the second normal vector of the second target map; for each second pixel point, based on the sight direction vector and the second normal vector corresponding to the second pixel point, obtaining the second reflection direction vector of the second pixel point; sampling the second target map based on the second reflection direction vector corresponding to each second pixel point to obtain the second texture information corresponding to each second pixel point; and rendering the second virtual object model based on the second texture information corresponding to each second pixel point.
[0015] In a second aspect, an embodiment of the present invention provides a device for processing reflection effects, comprising: a perspective determination module, used to determine a first view perspective of a virtual camera; a first acquisition module, used to acquire a first target map of a first virtual object model under the perspective of the first view from a first map of a pre-established first virtual object model, the first map being used to render the reflection effect of the first virtual object model; a second acquisition module, used to acquire a second target map of a second virtual object model under the perspective of the first view based on the first target map under the perspective of the first view and a predetermined relative relationship between the first virtual object model and the second virtual object model, the second target map being used to render the reflection effect of the first virtual object model reflected by the second virtual object model, the relative relationship being used to indicate the relative positions of the first virtual object model and the second virtual object model in the same virtual scene.
[0016] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the processing method of the reflection effect of the first aspect.
[0017] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the processing method for the reflection effect of the first aspect.
[0018] In a fifth aspect, an embodiment of the present invention provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are executed by a computer device, the computer device executes the method for processing the reflection effect of the first aspect.
[0019] The embodiment of the present invention brings the following beneficial effects: by determining the first view angle of the virtual camera; obtaining the first target map of the first virtual object model under the first view angle from the first map of the pre-established first virtual object model, the first map is used to render the reflection effect of the first virtual object model; based on the first target map under the first view angle and the predetermined relative relationship between the first virtual object model and the second virtual object model, obtaining the second target map of the second virtual object model under the first view angle, the second target map is used to render the reflection effect of the first virtual object model reflected by the second virtual object model, thereby, after obtaining the first target map of the first virtual object model, based on the relative relationship between the first virtual object model and the second virtual object model, obtaining the second target map for rendering the reflection effect of the first virtual object model reflected by the second virtual object model, that is, calculating the reflection effect of the first virtual object model reflected by the second virtual object model through the relative relationship and the first target map, without the need for reflection capture and screen space reflection, which can reduce the resource requirements for the terminal device when processing the reflection result.
[0020] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0021] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0023] Figure 1 A processing schematic diagram of a reflection effect provided for related technology;
[0024] Figure 2 A schematic diagram of processing a reflection effect provided by an embodiment of the present invention;
[0025] Figure 3 A schematic flow chart of a method for processing a reflection effect provided by an embodiment of the present invention;
[0026] Figure 4 A schematic diagram of a mapping according to an embodiment of the present invention;
[0027] Figure 5 A schematic diagram of an interface with a reflection effect disclosed in an embodiment of the present invention;
[0028] Figure 6 A schematic diagram of the structure of a reflection effect processing device provided by an embodiment of the present invention;
[0029] Figure 7 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0031] First, the processing of the reflection effect of the sky reflected by the water surface in the related art is described. This embodiment is described by taking the virtual scene as a game virtual scene as an example. The game can be, for example, a strategy game (simulation game, SLG), and the virtual scene can be, for example, an SLG world.
[0032] See also Figure 1 , Figure 1 A schematic diagram of processing a reflection effect provided by the related technology. Figure 1 As shown, the process of processing the reflection effect in the related art includes:
[0033] 1. Reflect the environment background through the sky box. The environment background reflected by the sky box may include but is not limited to the blue sky, white clouds, sun, stars, etc. The sky box is a cube texture used to simulate a vast sky environment. In a game or simulation environment, the sky box is used as a background to provide a closed cube environment containing elements such as the sky and clouds to create an immersive visual effect.
[0034] 2. Reflection capture Actors in the virtual scene, actors can include but are not limited to characters or objects. In the game scene, through reflection capture technology, the reflection information of the surrounding environment can be captured and stored for subsequent generation of reflection effects on the surface of objects.
[0035] 3. Screen Space Reflection: Screen Space Reflection is a technology that calculates reflections in screen space. SSR technology calculates and renders the reflection effect of the object surface by analyzing the relative position relationship between pixels in screen space, thereby achieving realistic mirror reflection.
[0036] 4. Planar reflection: Planar reflection refers to the reflection effect simulated on a plane. In the game scene, planar reflection technology can be used to generate a mirror effect on the horizontal plane (such as the water surface) that is opposite to the surrounding environment, increasing the three-dimensional sense and realism of the scene. Among them, planar reflection is an optional processing method.
[0037] 5. Use a shader with reflection to process water material. A shader is a program used to render graphic effects. A shader with reflection can calculate and render the reflection effect of an object surface, thereby enhancing the realism of the scene. In a game or simulation environment, water material uses specific shaders and textures to simulate the flow, transparency, and reflection of water, thereby enhancing the realism of the scene.
[0038] 6. The mesh that forms the water surface. The water surface refers to the surface of the water in the game. As part of the water body, the water surface can present realistic water waves, ripples and reflection effects by applying water materials and reflection technology, adding a sense of liveliness to the game scene. The mesh is a three-dimensional data structure used to represent the shape of objects in a game or simulation environment. As the basic building block of an object, the shape and size of the mesh will directly affect the presentation of the reflection effect. Developers can optimize the visual effect of the reflection effect by adjusting the shape and size of the mesh.
[0039] Specifically, if you want to achieve a realistic reflection effect on the sky and water surface of the SLG world, you need to use a reflection capture box (box reflection capture), adjust its size and position to cover the entire area. And add a post-process volume (post process volume), and set it to infinite expansion (unbound) to wrap the entire world. In addition, turn on the screen space reflection option at the same time, set the quality (quality), maximum reflection distance (max roughness), reflection intensity (intensity), etc. to achieve a better reflection effect. At the same time, you also need to ensure that there is an appropriate skysphere (skysphere) or skybox (skybox) in the scene, and configure its material so that it can reflect the sky. Adjust the direction and intensity of the main light source to ensure that the lighting reflection effect is realistic. In addition, add an ambient light (ambient light) to the scene to improve the overall lighting quality.
[0040] Reflection capture and screen space reflections can provide accurate reflection effects in large world scenes, but they also bring a lot of performance and memory overhead.
[0041] In terms of performance:
[0042] 1. The reflection capture sphere and reflection capture box capture the ambient lighting information in the scene, which will incur a certain amount of computational overhead during capture.
[0043] 2. SSR calculates reflections in screen space when rendering each frame, which requires a large number of pixel shader calculations and therefore places high demands on GPU performance.
[0044] In terms of memory:
[0045] 1. Reflection capture generates environment maps, which occupy video random access memory (VRAM). Larger capture areas and high-resolution environment maps will increase video memory usage.
[0046] 2. SSR needs to use additional screen space buffers to store intermediate calculation results, which will occupy video memory
[0047] For real-time reflections:
[0048] Because the reflection effect is calculated in real time, the amount of calculation is large and the performance is extremely high. Low-configuration mobile devices (also known as electronic devices or terminal devices) will have obvious frame drops and body heating, and will also accelerate power consumption.
[0049] From the above analysis, we can see that reflection capture and screen space reflection have high requirements on the resources of terminal devices.
[0050] In view of this, embodiments of the present invention provide a method, device, electronic device, storage medium and program product for processing reflection effects, which can reduce the resource requirements of terminal devices when processing reflection results.
[0051] To facilitate understanding of this embodiment, a method for processing a reflection effect disclosed in an embodiment of the present invention is first described in detail.
[0052] See also Figure 2 , Figure 2 A schematic diagram of processing a reflection effect provided by an embodiment of the present invention. Figure 2 As shown, the processing of the reflection effect in this embodiment may not include reflecting and capturing the actors in the virtual scene, screen space reflection and plane reflection. That is to say, the processing of the reflection effect in this embodiment may include reflecting the environmental background through a sky box, processing the water material using a shader with a reflection function, and forming a water surface mesh.
[0053] In one embodiment of the present disclosure, the method for processing the reflection effect can be run on a local terminal device or a server. When the method for processing the reflection effect is run on a server, the method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.
[0054] In an optional implementation, various cloud applications can be run under the cloud interaction system, such as cloud games. Taking cloud games as an example, cloud games refer to a game mode based on cloud computing. In the operation mode of cloud games, the operating body of the game program and the main body of the game screen presentation are separated. The storage and operation of the reflection effect processing method are completed on the cloud game server. The role of the client device is used for receiving and sending data and presenting the game screen. For example, the client device can be an acquisition device with data transmission function close to the user side, such as a mobile terminal, a TV, a computer, a handheld computer, etc.; but the cloud game server in the cloud is used for information processing. When playing the game, the player operates the client device to send an operation instruction to the cloud game server. The cloud game server runs the game according to the operation instruction, encodes and compresses the game screen and other data, and returns it to the client device through the network. Finally, the client device decodes and outputs the game screen.
[0055] In an optional embodiment, taking a game as an example, a local terminal device stores a game program and is used to present a game screen. The local terminal device is used to interact with the player through a graphical user interface, that is, the game program is downloaded and installed and run by an electronic device in a conventional manner. The local terminal device may provide the graphical user interface to the player in a variety of ways, for example, it may be rendered and obtained on the acquisition screen of the terminal, or provided to the player through a holographic projection. For example, the local terminal device may include an acquisition screen and a processor, the acquisition screen is used to present a graphical user interface, the graphical user interface includes a game screen, and the processor is used to run the game, generate a graphical user interface, and control the acquisition of the graphical user interface on the acquisition screen.
[0056] In a possible implementation, an embodiment of the present invention provides a method for processing reflection effects, and provides a graphical user interface through a terminal device, wherein the terminal device may be the local terminal device mentioned above, or may be a client device in the cloud interaction system mentioned above. The graphical user interface may be used to display a view, and the player may observe the SLG world from a certain viewing angle in the view.
[0057] To facilitate understanding of this embodiment, a method for processing a reflection effect disclosed in an embodiment of the present invention is first introduced in detail. Figure 3 As shown, the method for processing the reflection effect provides a graphical user interface through a terminal device, wherein the terminal device can be the local terminal device described above, or can be the client device described above, and the method includes the following steps:
[0058] S310: Determine a first viewing angle of the virtual camera.
[0059] Among them, the virtual camera can be a definition of the way in which the graphic object is visualized in the virtual world. The virtual camera is a picture obtained by real-time calculation by a computer. The perspective of the virtual camera is equivalent to the perspective of the viewer (also known as the user or player). Specifically, by adjusting the perspective and parameters of the virtual camera, the view perspective can be adjusted. In a virtual scene, the user may need to switch to a different perspective to observe the virtual environment. For example, in a game, the user may need to switch to a third-person perspective to better observe the character or scene. The virtual camera can achieve this perspective switching. In addition, the perspective of the virtual camera can also be combined with the user's interactive behavior. For example, when the user moves his head or body, the perspective of the virtual camera will change accordingly, thereby providing a more natural interactive experience. The view perspective refers to the visual image obtained when observing an object or scene from a specific position and direction. In a virtual scene, the view perspective is usually used to describe the position and orientation of the virtual camera, and the resulting visual image.
[0060] S320: Acquire a first target map of the first virtual object model under a first viewing angle from a pre-established first map of the first virtual object model, wherein the first map is used to render a reflection effect of the first virtual object model.
[0061] Among them, mapping, also known as texture mapping, is a process or medium for applying an image or pattern to the surface of a three-dimensional model. The first virtual object model can be a model of one of the virtual objects in the virtual scene. For example, the first virtual object model can be, for example, a sky ball model or a sky box model. The first map is used to render the reflection effect of the first virtual object model, which can be the reflection effect of the environmental background of the first virtual object model at the first virtual object model. In this embodiment, the first target map is part of the first map, which can be understood as the first target map is a subset of the first map. The rendering of this embodiment may include but is not limited to rendering color, lighting, etc., for example, it can be rendered by a fragment shader.
[0062] S330. Based on the first target map under the first view angle and a predetermined relative relationship between the first virtual object model and the second virtual object model, obtain a second target map of the second virtual object model under the first view angle, wherein the second target map is used to render a reflection effect of the first virtual object model being reflected by the second virtual object model.
[0063] The second virtual object model may be a model of another virtual object in the virtual scene. For example, the second virtual object model may be a water surface model. The second target map is used to render the reflection effect of the first virtual object model reflected by the second virtual object model, and may be used to render the imaging of the first virtual object in the second virtual object model. The relative relationship is used to indicate the relative position of the first virtual object model and the second virtual object model in the same virtual scene, that is, through the relative relationship, it can be known what the relative position between the first virtual object model and the second virtual object model is in the virtual scene.
[0064] In this embodiment, the second target map for rendering the reflection effect of the first virtual object model being reflected by the second virtual object model can be obtained through the relative relationship between the first virtual object model and the second virtual object model and the first target map of the first virtual object model under the first view perspective. In other words, the reflection effect of one model being reflected by another model can be achieved through the conversion of the relative relationship.
[0065] It should be understood that the first virtual object model and the second virtual object model in this embodiment are not limited to the sky ball model and the water surface model. As long as one of the virtual object models is reflected by another virtual object model in the same virtual scene, there is no limitation here.
[0066] The technical solution of this embodiment can obtain the second target map for rendering the reflection effect of the first virtual object model reflected by the second virtual object model based on the relative relationship between the first virtual object model and the second virtual object model after obtaining the first target map of the first virtual object model. That is, the reflection effect of the first virtual object model reflected by the second virtual object model is calculated through the relative relationship and the first target map, without the need for reflection capture and screen space reflection, which can reduce the resource requirements on the terminal device when processing the reflection results.
[0067] In a possible implementation, the viewing angle of the virtual camera in this embodiment may be fixed.
[0068] In another possible implementation, the viewing angle of the virtual camera in this embodiment may change. Below, the situation where the viewing angle of the virtual camera changes is described.
[0069] In a possible implementation, the method further includes:
[0070] In response to a switching instruction of the view angle of the virtual camera, switch from the first view angle to the second view angle; obtain a first target map of the first virtual object model under the second view angle from the first map; based on the first target map and the relative relationship under the second view angle, obtain a second target map of the second virtual object model under the second view angle.
[0071] In this embodiment, when the viewing angle changes, the first target map and relative relationship of the first virtual object model under the second viewing angle can be used to obtain the second target map of the second virtual object model under the second viewing angle. That is to say, when the viewing angle changes, the reflection effect can also be processed in the manner of this embodiment. In this way, when the viewing angle is adjusted, the resource requirements for the terminal device when processing the reflection results can be reduced.
[0072] In another possible implementation, if the first view angle is switched to the second view angle, the reflection effect may be processed by using reflection capture and screen space reflection.
[0073] Next, it is described how to obtain the first target map of the first virtual object model under the second viewing angle from the first map after the viewing angle is switched.
[0074] In a possible implementation, obtaining a first target map of a first virtual object model under a second viewing angle from a first map includes:
[0075] Based on the view perspective switching instruction, determine the switching information of the view perspective of the virtual camera, the switching information includes movement distance information and / or view perspective rotation information, the view perspective rotation information includes view perspective rotation direction information and view perspective rotation angle information; based on the switching information, determine the offset cropping range of the first target map, the offset cropping range is used to indicate the view perspective offset of the first target map; based on the offset cropping range, obtain the first target map under the second view perspective from the first map.
[0076] Among them, the view angle switching instruction may be generated by the terminal device detecting a trigger operation acting on the graphical user interface detection. The view angle switching information may be the switching information corresponding to the trigger operation. The view angle offset of the first target map may be the offset direction and offset of the first target map, for example, the first target map is offset to the left by a certain offset, to the right by a certain offset, to the front by a certain offset, to the back by a certain offset, to the top by a certain offset, or to the bottom by a certain offset, which is determined according to the actual situation and is not limited here. The offset may include the offset in the first direction and the offset in the second direction. The first direction may be, for example, the X axis, and the second direction may be, for example, the Y axis. In this embodiment, based on the offset cropping range, the first target map under the second view angle is obtained from the first map, which may be to obtain the map area corresponding to the offset cropping range from the first map, and remove the map area corresponding to the offset cropping range in the first target map under the first view angle, and splice the map area corresponding to the offset cropping range obtained from the first map with the first target map under the first view angle from which the map area is removed, thereby obtaining the first target map under the second view angle.
[0077] The technical solution of this embodiment obtains the offset cropping range, and then obtains the first target map under the perspective of the second view from the first map based on the offset cropping range. In this way, the first target view under the perspective of the second view can be obtained according to the view offset of the first target map, thereby saving the resources required for obtaining the first target view under the perspective of the new view and improving the efficiency of obtaining the first target view under the perspective of the new view.
[0078] In another possible implementation, the first target map under the new viewing angle may be directly acquired from the first map based on the new viewing angle.
[0079] The following embodiment further illustrates how to determine the offset cropping range based on the above embodiment.
[0080] In a possible implementation, the method is applied to a terminal device, the terminal device includes a display device for displaying a view, and based on the switching information, determining an offset clipping range of a first target map includes:
[0081] Obtain the aspect ratio of the view and a second map of a pre-established second virtual object model, where the second map is used to render the reflection effect of the second virtual object model, and the second map is established based on the view distance of the virtual camera; determine the offset clipping range of the first target map based on the switching information, the aspect ratio and the second map.
[0082] See also Figure 4 , Figure 4 FIG. 1 is a schematic diagram of a mapping according to an embodiment of the present invention. Figure 4 As shown, the second map is a plane map, the first map is perpendicular to the second map, and the second map is arranged around the first map. It should be noted that Figure 4 The maps shown are only some examples, not all map examples. The first map can be, for example, a sky map, and the second map can be, for example, a water map. The sky map is also called a reflection map of space. The water map is also called a reflection map of the water surface or a water surface clipping plane (ortho near clip plane).
[0083] The aspect ratio is the ratio of the width to the height of the view, and is used to set the projection matrix to ensure that the rendered image is not distorted due to the different shapes of the view. It affects the aspect ratio of the rendered image. The clipping plane is the position of the near clipping plane defined in the orthographic projection matrix. It determines which objects are too close to the camera to be rendered.
[0084] exist Figure 4 In the sky, the water surface clipping plane is drawn with the camera / view angle as the center and the integer multiple of the view distance as the radius of the circle. The first texture around the camera / view angle is drawn in combination with the skybox. When the camera / view angle is rotating, the sky texture offset clipping range is obtained through the view aspect ratio, the skybox under the view distance and the water surface clipping plane. The same is applied to the calculation of the reflection map of the water surface. Because the water surface is Z-axis mapped, a matrix conversion is required to synchronize the facade sky map with the reflection map of the water surface mapped on the Z axis.
[0085] The following embodiment describes how to use the first target map to render the reflection effect of the first virtual object model based on the above embodiment.
[0086] In a possible implementation, the method of rendering using the first target map may include:
[0087] For each first pixel point in the first target map under the first view angle, determine the sight direction vector between the first pixel point and the virtual camera; obtain the first normal vector of the first target map; for each first pixel point, based on the sight direction vector and the first normal vector corresponding to the first pixel point, obtain the first reflection direction vector of the first pixel point; based on the first reflection direction vector corresponding to each first pixel point, perform texture sampling on the first target map to obtain the first texture information corresponding to each first pixel point; based on the first texture information corresponding to each first pixel point, render the first virtual object model.
[0088] Wherein, each first pixel point can be considered as a vertex. The first normal vector can be predetermined. Based on the sight direction vector corresponding to the first pixel point and the first normal vector, the first reflection direction vector of the first pixel point is obtained, which can be the product of the sight direction vector corresponding to the first pixel point and the first normal vector as the first reflection direction vector. Wherein, texture is defined as a visual feature that reflects the homogeneous phenomenon in the image. It reflects the intrinsic properties shared by the surface of an object, and contains important information about the structural organization arrangement of the surface of the object and their relationship with the surrounding environment. Texture information can be, for example, the color value or texture coordinate of the reflected texture. In this embodiment, the first target map is texture sampled by the first reflection direction vector corresponding to the first pixel point, and the first texture information corresponding to each first pixel point in the first view direction can be obtained, and then the first virtual object model is rendered using the first texture information, so that the reflection effect of the first virtual object model is displayed in the first virtual object model.
[0089] The technical solution of this embodiment can perform texture sampling on the first target map through the first reflection direction vector corresponding to the first pixel point, and obtain the first texture information corresponding to each first pixel point in the first view direction, and then use the first texture information to render the first virtual object model, so as to display the reflection effect of the first virtual object model in the first virtual object model, which can enhance the immersive experience of the virtual scene.
[0090] The following embodiment describes how to obtain a map under a second viewing angle using a map under a first viewing angle based on the above embodiment.
[0091] In a possible implementation, based on the first target map at the first viewing angle and a predetermined relative relationship between the first virtual object model and the second virtual object model, obtaining a second target map of the second virtual object model at the first viewing angle includes:
[0092] For each first pixel point in the first target map under the perspective of the first view, the first pixel point is mapped to a second pixel point of the second virtual object model based on a relative relationship; based on all the second pixels, a second target map of the second virtual object model under the perspective of the first view is obtained.
[0093] Among them, mapping the first pixel point to the second pixel point of the second virtual object model can be understood as mapping the position information of the first pixel point to the second virtual object model, and the pixel information (such as RGB information) of the first pixel point is consistent with the pixel information of the second pixel point. Mapping the first pixel point to the second pixel point of the second virtual object model based on the relative relationship can be the product result of the position information of the first pixel point and the relative relationship.
[0094] In this embodiment, the first pixel is mapped to the second pixel of the second virtual object model according to the relative relationship, so that each second pixel of the second virtual object model under the first view angle can be obtained, that is, the second target map under the first view angle can include the first pixel under the first view angle mapped to the second virtual object model. Optionally, the product between the first pixel and the relative relationship can be used as the second pixel.
[0095] In a possible implementation, the relative relationship includes a model matrix and a projection matrix, the model matrix is used to indicate the model mapping relationship between the first virtual object model and the second virtual object model, and the projection matrix is used to indicate the projection relationship of pixel points between the first virtual object model and the second virtual object model.
[0096] Correspondingly, for each first pixel point in the first target map at the first viewing angle, mapping the first pixel point to a second pixel point of the second virtual object model based on the relative relationship includes:
[0097] For each first pixel point in the first target map at the first viewing angle, the first pixel point is mapped to a second pixel point of the second virtual object model based on the model matrix and the projection matrix.
[0098] Mapping the first pixel point to the second pixel point of the second virtual object model based on the model matrix and the projection matrix may be a product result of the model matrix, the projection matrix and the position information of the first pixel point.
[0099] In this embodiment, the first pixel point is mapped to the second pixel point of the second virtual object model through the model matrix and the projection matrix. That is, the mapping relationship between the models and the projection relationship between the pixels can be taken into account, which can improve the accuracy of setting the first pixel point to the second virtual object model.
[0100] In a possible implementation, the viewing angle of the virtual camera is variable, and before mapping each first pixel point in the first target map at the first viewing angle to a second pixel point of the second virtual object model based on the model matrix and the projection matrix, the method further includes:
[0101] Obtain a view matrix corresponding to the first view perspective, where the view matrix is used to indicate a mapping relationship between the first view perspective and the virtual camera; for each first pixel point in the first target map under the first view perspective, map the first pixel point to a second pixel point of the second virtual object model based on the model matrix and the projection matrix, including: for each first pixel point in the first target map under the first view perspective, map the first pixel point to a second pixel point of the second virtual object model based on the view matrix, the model matrix and the projection matrix.
[0102] In this embodiment, the first pixel point is mapped to the second pixel point of the second virtual object model based on the view matrix, model matrix and projection matrix, which can be the product result of the view matrix, model matrix, projection matrix and the position information of the first pixel point.
[0103] In this embodiment, if the viewing angle of the virtual camera is changeable, the first pixel point is also mapped to the second pixel point of the second virtual object model through the view matrix, so that
[0104] In another possible implementation, the viewing angle is fixed, and the view matrix may not be needed.
[0105] The following embodiment describes how to use the second target map to render the reflection effect of the second virtual object model based on the above embodiment.
[0106] In a possible implementation, the method further includes:
[0107] For each second pixel point in the second target map under the first view angle, determine the sight direction vector between the second pixel point and the virtual camera; obtain the second normal vector of the second target map; for each second pixel point, based on the sight direction vector and the second normal vector corresponding to the second pixel point, obtain the second reflection direction vector of the second pixel point; based on the second reflection direction vector corresponding to each second pixel point, sample the second target map to obtain the second texture information corresponding to each second pixel point; based on the second texture information corresponding to each second pixel point, render the second virtual object model.
[0108] Among them, the second normal vector can be predetermined. Based on the sight direction vector corresponding to the second pixel point and the second normal vector, the second reflection direction vector of the second pixel point is obtained, which can be the product of the sight direction vector corresponding to the first pixel point and the second normal vector as the second reflection direction vector. In this embodiment, the second target map is texture sampled by the second reflection direction vector corresponding to the second pixel point, and the second texture information corresponding to each second pixel point in the first view direction can be obtained, and then the second virtual object model is rendered using the second texture information, so as to display the reflection effect of the first virtual object reflected by the second virtual object model in the second virtual object model.
[0109] The technical solution of this embodiment can perform texture sampling on the second target map through the second reflection direction vector corresponding to the second pixel point, and obtain the second texture information corresponding to each second pixel point in the first view direction, and then use the second texture information to render the second virtual object model, so as to display the reflection effect of the first virtual object model reflected by the second virtual object in the second virtual object model, which can enhance the immersive experience of the virtual scene.
[0110] For ease of understanding, the following embodiments are based on the above embodiments and illustrate the technical solutions of the embodiments of the present invention in combination with program codes.
[0111] / / Use the camera component algorithm to process the view aspect ratio and clipping plane, obtain the sky map range in the picture, and calculate the line of sight and reflection direction. The example code is as follows:
[0112] #CameraComponent
[0113] #AspectRatio
[0114] #OrthoNearClipPlane
[0115] vec3 I=normalize(FragPos-viewPos);
[0116] vec3 R=reflect(I,normalize(Normal)).
[0117] FragPos: represents the world space position of the fragment, that is, the position of the current fragment in the scene. The fragment of this embodiment may refer to the pixel table of the sky map after projection on the display device or the pixel representation of the water map after projection on the display device. viewPos: represents the world space position of the camera (usually the position of the observer). FragPos-viewPos: This operation calculates the vector from the observer (camera) to the current fragment. I is the line of sight direction vector pointing from the camera position to the fragment position, which has been normalized by the normalize function. Normal is the normal vector of the fragment surface, which has also been normalized by the normalize function. R is the reflection direction vector calculated by the reflect function, which is based on the line of sight direction I and the normal vector Normal.
[0118] / / Sampling from cube map to get reflection texture
[0119] vec4 reflection=texture(skybox,R).
[0120] skybox: This is a defined cube map texture sampler that contains a panoramic image of the surrounding environment, usually used to simulate the sky, environment or other panoramic background.
[0121] Texture function: This function retrieves the corresponding color value from the cube map according to the provided texture sampler and texture coordinates (R). For cube maps, texture coordinates are three-dimensional vectors that specify the direction of the sampling point on the cube map. Reflection is the color value sampled from the cube map, which is stored in a vec4 type variable, which contains the color information of the four RGBA channels.
[0122] In this embodiment, the texture function is used to sample from the skybox cubemap along the direction specified by R, thereby obtaining the color value of the reflection texture.
[0123] / / Output the reflection color as fragment color
[0124] FragColor=reflection.
[0125] FragColor is an output variable that is usually used to store the final color value of the fragment. At the end of the fragment shader, the value of this variable is passed to the rendering pipeline to generate the color of the pixel on the screen.
[0126] Among them, FragColor represents the final color of the current fragment, and reflection is the reflection color sampled from the cube map texture. By assigning reflection to FragColor, the reflection color is directly output as the fragment color.
[0127] / / Input variables, vertex position and normal
[0128] layout(location=0)in vec3 aPos;
[0129] layout(location=1)in vec3 aNormal.
[0130] layout(location=0) and layout(location=1): These instructions are used to specify the location (or index) of the vertex attributes in the vertex data. location=0 means aPos is the first vertex attribute, while location=1 means aNormal is the second vertex attribute.
[0131] in vec3 aPos is an input variable that receives the position information of the vertex. It is a three-dimensional vector (vec3) containing the X, Y, and Z coordinates of the vertex in model space (or object space).
[0132] in vec3 aNormal is also an input variable that receives the vertex normal information. It is also a three-dimensional vector (vec3) that contains the direction component of the vertex normal. Normals are often used in lighting calculations to determine the angle between light and the surface.
[0133] In the vertex shader, these input variables are typically used to calculate the transformed vertex positions and normals, as well as to perform lighting calculations, etc.
[0134] / / Uniform variables, model, view and projection matrices
[0135] uniform mat4 model;
[0136] uniform mat4 view;
[0137] uniform mat4 projection.
[0138] Uniform variables are used to pass constant data from the CPU to the GPU. These data remain constant during the execution of the shader program, but can change between different rendering calls. Uniform variables are often used to pass transformation matrices, lighting parameters, material properties, etc.
[0139] Mat4 type: Mat4 is a 4x4 matrix type used to represent linear transformations. It can store and operate vectors in four dimensions. It should be noted that in three-dimensional graphics rendering, only three dimensions are usually used to represent points or vectors in space, and the fourth dimension is usually used for homogeneous coordinates or perspective projection.
[0140] Model matrix: The model matrix is used to transform vertices from model space (or object space) to world space. It contains the object's scaling, rotation, and translation information.
[0141] View matrix: The view matrix is used to transform vertices from world space to observation space (or camera space). It contains the position and orientation information of the camera and is used to simulate the camera's perspective.
[0142] Projection matrix: The projection matrix is used to transform vertices from viewing space to clipping space. It defines the shape and size of the viewing frustum and determines which vertices are inside the viewing frustum (visible) and which vertices are outside the viewing frustum (invisible and will be clipped).
[0143] After matrix conversion, it is applied to the reflection map offset of the water surface. Because the water surface is Z-axis mapped, a matrix conversion is needed to synchronize the facade sky map with the reflection map of the water surface mapped on the Z axis. Next, point-to-point synchronization between the sky and the water surface is achieved to simulate a real reflection effect.
[0144] Sky map matrix conversion mapping:
[0145] / / Convert the two-dimensional vertex position to a three-dimensional position and set it to the value on the Z axis
[0146] vec3 pos3D=vec3(aPos2D,zValue);
[0147] aPos2D is a 2D vector (vec2) that contains the X and Y coordinates of the vertex in 2D space. These coordinates represent screen pixel positions, texture coordinates, or other forms of 2D positions.
[0148] zValue is a scalar value (usually a float) that specifies the Z coordinate of the vertex in 3D space. The specific value of zValue depends on the depth position at which the vertex is placed in 3D space.
[0149] vec3 constructor: vec3 is a three-dimensional vector type that can be constructed by providing three components (X, Y, Z). In this example, a new three-dimensional vector pos3D is constructed using the X and Y components of aPos2D and zValue as the Z component.
[0150] pos3D is a three-dimensional vector (vec3) that contains the position information of the vertex in three-dimensional space. By combining aPos2D and zValue, a two-dimensional vertex can be converted into a three-dimensional vertex with depth information (i.e., Z coordinate).
[0151] / / Pass the transformed 3D position to the fragment shader
[0152] FragPos = pos3D;
[0153] FragPos is an output variable, usually declared at the end of the vertex shader, and used to pass certain data (such as the transformed three-dimensional vertex position) to the fragment shader. In the fragment shader, this data can be received through the corresponding input variables for further processing or calculation.
[0154] / / Pass texture coordinates directly to the fragment shader
[0155] TexCoord = aTexCoord;
[0156] TexCoord is an output variable declared in the vertex shader to pass texture coordinates to the fragment shader. In the fragment shader, you can receive these texture coordinates through the corresponding input variables and use them to sample color or other data from the texture.
[0157] aTexCoord is an input variable, usually obtained from the vertex data passed from the CPU, containing the texture coordinates associated with the current vertex. Texture coordinates are usually used to determine the specific location to sample from the texture, they can be two-dimensional (for 2D textures), three-dimensional (for 3D textures) or other forms, depending on the type of texture used.
[0158] / / Apply the model projection matrix
[0159] gl_Position=projection*view*model*vec4(pos3D,1.0);
[0160] gl_Position is a built-in output variable that stores the position of the vertex in clip space calculated by the vertex shader. This position will be used in subsequent rendering pipeline stages, such as clipping, perspective division, and view transformation.
[0161] projection, view, model: These are the projection matrix, view matrix and model matrix respectively, they are all 4x4 matrices. These matrices are used to transform vertices from model space to clip space.
[0162] pos3D: This is a three-dimensional vector that contains the position information of the vertex in three-dimensional space. In order to multiply it with the 4x4 transformation matrix, we need to convert it into a four-dimensional vector (homogeneous coordinates).
[0163] vec4(pos3D,1.0): This constructor creates a 4D vector whose X, Y, and Z components come from pos3D, and the W component is set to 1.0. In homogeneous coordinates, the W component is often used for perspective projection and transformation normalization.
[0164] Matrix multiplication: projection*view*model, first transform the vertex position from model space to world space (through the model matrix), then transform to observation space (through the view matrix), and finally transform to clip space (through the projection matrix). This process is linear, and because homogeneous coordinates are used, it can handle nonlinear transformations such as perspective projection.
[0165] / / Calculate the fragment position, the model transformation is applied to the vertex position
[0166] FragPos=vec3(model*vec4(aPos,1.0));
[0167] / / Calculate the fragment normal, the model matrix is applied to the vertex normal
[0168] Normal=mat3(transpose(inverse(model)))*aNormal;
[0169] Normal is an output variable used to store the transformed normal vector, which will be passed to the fragment shader.
[0170] inverse(model): This is the inverse of the model matrix. We need to use the inverse matrix when calculating the transformed normal because the normal vector is defined using the tangent space of the surface, which changes when transformed. The inverse matrix is able to "undo" the transformations made to the vertex positions, transforming the normal vector in the correct way.
[0171] transpose(inverse(model)): Since normal vectors are direction vectors, they are not affected by scaling. Therefore, the rotation part of the inverse matrix is usually used to transform the normals. The rotation part of the inverse matrix can be obtained by taking the transpose of its inverse matrix. In the case of an orthogonal matrix, the inverse matrix is equal to the transposed matrix; in the case of a non-orthogonal matrix, the transpose of the inverse matrix gives the correct rotation part, but may contain unnecessary scaling information.
[0172] / / Calculate vertex position and transform to clip space
[0173] gl_Position=projection*view*vec4(FragPos,1.0);
[0174] / / Texture sampling
[0175] vec4 texColor=texture(texture1,TexCoord);
[0176] vec4 texColor is a four-dimensional vector used to store the color value sampled from the texture.
[0177] texture is a built-in function used to sample a color from a specified texture. It accepts two parameters: texture sampler (texture1) and texture coordinates (TexCoord).
[0178] texture1: This is a texture sampler variable that represents the texture to be sampled from. A texture sampler encapsulates texture data and sampling state (such as filtering mode and addressing mode). Texture samplers are usually defined outside of the shader and passed to the shader via uniform variables.
[0179] TexCoord is a 2D or 3D vector (depending on the type of texture) that specifies the location to sample from the texture. For 2D textures, the texture coordinate is usually a 2D vector (vec2) whose components are in the range [0,1] (for unnormalized texture coordinates, the range may be different). For 3D textures, the texture coordinate is a 3D vector (vec3). The texture function directly returns a 4D vector, which is assigned to the texColor variable.
[0180] In the fragment shader, texture sampling is often used to obtain the color of the texture associated with the current fragment. This can be achieved by passing the fragment's UV coordinates (or other types of texture coordinates) to the texture function. This color value can then be used in subsequent rendering calculations, such as combining with the lighting model to generate the final fragment color.
[0181] / / Use the Z-axis information to adjust the color value
[0182] float intensity=FragPos.z*0.1;
[0183] FragColor=texColor*vec4(intensity,intensity,intensity,1.0).
[0184] FragPos.z represents the position of the current fragment on the Z axis, which can be derived from world space or view space after the view transform. FragPos is usually a three-dimensional vector, but in some cases it may also be a four-dimensional homogeneous coordinate passed from the vertex shader.
[0185] intensity is a floating point variable used to store the intensity value calculated based on the Z-axis position. Here, FragPos.z is multiplied by 0.1 to scale the intensity so that it is between 0 and some maximum value (this maximum value depends on the range of FragPos.z).
[0186] vec4(intensity,intensity,intensity,1.0) is a 4D vector whose R, G, and B components are all set to the same intensity value, and the A component (alpha) is set to 1.0, indicating full opacity.
[0187] FragColor is the output variable of the fragment shader, representing the final color value. It is set to the product of the texture color (texColor) and the intensity vector, thus achieving color adjustment based on the Z-axis position.
[0188] It should be noted that calculating the fragment position, applying the model transformation to the vertex position, calculating the fragment normal, applying the model matrix to the vertex normal, and calculating the vertex position and transforming it to the clipping space can be understood as the switching implementation of the view displayed by the display device when the view angle changes.
[0189] In this embodiment, by using the camera calculation component algorithm to calculate the sky map range displayed by the camera, and applying it to the Z-axis water surface reflection map calculation through matrix conversion, the sky and water surface reflection point-to-point synchronization can be achieved with low consumption, and a real reflection effect can be provided in the SLG world scene. Such calculation amount and memory consumption of real-time reflection calculation amount can be reduced, and more room for development can be reserved for other effects.
[0190] For ease of understanding, a schematic diagram of the reflection effect is provided below for illustrative purposes. Figure 5, Figure 5 A schematic diagram of an interface with a reflection effect disclosed in an embodiment of the present invention.
[0191] like Figure 5 In the interface shown in (a), the first virtual object model is, for example, a sky model, and the first target map is used to render the content of the sky model, for example, to render Figure 5 The moon and clouds shown in (a) can show the effect of the moon and clouds in the sky. Figure 5 In the interface shown in (a), the second virtual object model is, for example, a ground model, and the second target map is used to render the content of the ground model, for example, to render Figure 5 The land and water surface shown in (a) in the figure. Since the water surface has reflective properties in real scenes, in order to improve the realism of virtual scenes, it is necessary to reflect the clouds and the moon in the sky on the water surface. The effect of the sky being reflected by the water surface can be achieved by the above-mentioned embodiments, such as adding clouds or the moon to the water surface. The content displayed on the water surface is related to the current viewing angle and is not limited here.
[0192] Then, if Figure 5 The viewing angle of (a) in the figure changes, and it can be shown Figure 5 The interface shown in (b) in FIG. Optional: Figure 5 The viewing angle of the interface shown in (b) can be Figure 5 Based on the perspective of the interface shown in (a), the perspective shifts to the left and moves backwards, then Figure 5 The position of the moon in (b) is compared to Figure 5 The Moon in (a) is more centrally located, and Figure 5 The size of the moon in (b) is compared to Figure 5 The size of the moon in (a) is smaller. At this time, after the viewing angle changes, the effect of the sky being reflected by the water surface can also be achieved by the above embodiment. It should be understood that due to the change in viewing angle, the reflection of the clouds in the sky and the moon by the water surface also changes.
[0193] In a possible implementation, an embodiment of the present invention provides a reflection effect processing device that provides a graphical user interface through a terminal device, wherein the terminal device can be the local terminal device mentioned above, or can be a client device in the cloud interaction system mentioned above.
[0194] like Figure 6 As shown, Figure 6 A schematic diagram of a device for processing reflection effects provided by an embodiment of the present invention. Figure 6 The apparatus shown may include:
[0195] The perspective determination module 610 is used to determine the first view perspective of the virtual camera; the first acquisition module 620 is used to obtain a first target map of the first virtual object model under the first view perspective from a pre-established first map of the first virtual object model, and the first map is used to render the reflection effect of the first virtual object model; the second acquisition module 630 is used to obtain a second target map of the second virtual object model under the first view perspective based on the first target map under the first view perspective and a predetermined relative relationship between the first virtual object model and the second virtual object model, and the second target map is used to render the reflection effect of the first virtual object model reflected by the second virtual object model.
[0196] The reflection effect processing device provided in the embodiment of the present invention has the same technical features as the reflection effect processing method provided in the above embodiment, so it can also solve the same technical problems and achieve the same technical effects.
[0197] This embodiment also provides an electronic device, including a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the above-mentioned processing method for the reflection effect. The electronic device can be a server or a terminal device.
[0198] See also Figure 7 As shown, the electronic device includes a processor 100 and a memory 101. The memory 101 stores computer executable instructions that can be executed by the processor 100. The processor 100 executes the computer executable instructions to implement the above-mentioned processing method for the reflection effect.
[0199] Further, Figure 7 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 100 , the communication interface 103 and the memory 101 are connected via the bus 102 .
[0200] The memory 101 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0201] The processor 100 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 100. The above processor 100 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present invention can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present invention can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101 and completes the steps of the method of the above embodiment in combination with its hardware.
[0202] The processor in the above electronic device can implement the steps in the above reflection effect processing method by executing computer executable instructions.
[0203] This embodiment also provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the processing method for the above-mentioned reflection effect.
[0204] The computer executable instructions stored in the computer readable storage medium can implement the steps in the above reflection effect processing method by executing the computer executable instructions:
[0205] An embodiment of the present invention further provides a computer program product, including a stored program code, wherein the instructions included in the program code can be used to execute the method in the foregoing method embodiment. For specific implementation, please refer to the method embodiment, which will not be described in detail here.
[0206] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0207] In addition, in the description of the embodiments of the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, and it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0208] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. 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, etc. Various media that can store program codes.
[0209] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0210] Finally, it should be noted that the above embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above embodiments, those skilled in the art should understand that any person skilled in the art can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.
Claims
1. A method for processing reflection effect, characterized in that: include: Determine a first view angle of the virtual camera; Acquire, from a pre-established first texture of the first virtual object model, a first target texture of the first virtual object model under the first view angle, wherein the first texture is used to render a reflection effect of the first virtual object model; Based on the first target map under the first view perspective and a predetermined relative relationship between the first virtual object model and the second virtual object model, a second target map of the second virtual object model under the first view perspective is obtained, the second target map is used to render a reflection effect of the first virtual object model reflected by the second virtual object model, and the relative relationship is used to indicate the relative positions of the first virtual object model and the second virtual object model in the same virtual scene.
2. The method according to claim 1, characterized in that The method further comprises: In response to a switching instruction of the view angle of the virtual camera, switching from the first view angle to a second view angle; Acquire, from the first map, the first target map of the first virtual object model at the perspective of the second view; Based on the first target map at the second view angle and the relative relationship, the second target map of the second virtual object model at the second view angle is acquired.
3. The method according to claim 2, characterized in that The acquiring, from the first map, the first target map of the first virtual object model under the second view angle, comprises: Based on the view angle switching instruction, determine the view angle switching information of the virtual camera, wherein the switching information includes movement distance information and / or view angle rotation information, and the view angle rotation information includes view angle rotation direction information and view angle rotation angle information; Based on the switching information, determining an offset clipping range of the first target map, wherein the offset clipping range is used to indicate a viewing angle offset of the first target map; Based on the offset clipping range, the first target map under the second view angle is obtained from the first map.
4. The method according to claim 3, characterized in that The method is applied to a terminal device, the terminal device includes a display device for displaying a view, and the determining of the offset clipping range of the first target map based on the switching information includes: Acquire the aspect ratio of the view and a pre-established second texture of the second virtual object model, where the second texture is used to render a reflection effect of the second virtual object model, and the second texture is established based on the view distance of the virtual camera; An offset cropping range of the first target texture is determined based on the switching information, the aspect ratio, and the second texture.
5. The method according to claim 1, characterized in that The method further comprises: For each first pixel point in the first target map under the first view angle, determining a sight direction vector between the first pixel point and the virtual camera; Obtaining a first normal vector of the first target map; For each first pixel point, based on the sight direction vector corresponding to the first pixel point and the first normal vector, obtain a first reflection direction vector of the first pixel point; Performing texture sampling on the first target map based on the first reflection direction vector corresponding to each of the first pixel points to obtain first texture information corresponding to each of the first pixel points; The first virtual object model is rendered based on the first texture information corresponding to each of the first pixel points.
6. The method according to any one of claims 1 to 5, characterized in that The acquiring, based on the first target map at the first view angle and a predetermined relative relationship between the first virtual object model and the second virtual object model, a second target map of the second virtual object model at the first view angle comprises: For each first pixel point in the first target map at the first view angle, mapping the first pixel point to a second pixel point of the second virtual object model based on the relative relationship; Based on all the second pixel points, a second target map of the second virtual object model under the first view angle is obtained.
7. The method according to claim 6, characterized in that The relative relationship includes a model matrix and a projection matrix, the model matrix is used to indicate a model mapping relationship between the first virtual object model and the second virtual object model, and the projection matrix is used to indicate a projection relationship between pixel points of the first virtual object model and the second virtual object model; The mapping, for each first pixel point in the first target map under the first view angle, to a second pixel point of the second virtual object model based on the relative relationship comprises: For each first pixel point in the first target map at the first view angle, the first pixel point is mapped to a second pixel point of the second virtual object model based on the model matrix and the projection matrix.
8. The method according to claim 7, characterized in that The viewing angle of the virtual camera is variable, and before mapping each first pixel point in the first target map under the first viewing angle to a second pixel point of the second virtual object model based on the model matrix and the projection matrix, the method further includes: Acquire a view matrix corresponding to the first view angle, where the view matrix is used to indicate a mapping relationship between the first view angle and the virtual camera; The mapping, for each first pixel point in the first target map under the first view angle, to a second pixel point of the second virtual object model based on the model matrix and the projection matrix comprises: For each first pixel point in the first target map under the first view angle, the first pixel point is mapped to a second pixel point of the second virtual object model based on the view matrix, the model matrix and the projection matrix.
9. The method according to claim 6, characterized in that The method further comprises: For each second pixel point in the second target map under the first view angle, determine a sight direction vector between the second pixel point and the virtual camera; Obtaining a second normal vector of the second target map; For each second pixel point, based on the sight direction vector and the second normal vector corresponding to the second pixel point, obtain a second reflection direction vector of the second pixel point; Sampling the second target map based on the second reflection direction vector corresponding to each of the second pixel points to obtain second texture information corresponding to each of the second pixel points; The second virtual object model is rendered based on the second texture information corresponding to each of the second pixel points.
10. A device for processing reflection effect, characterized in that: include: A viewing angle determination module, used to determine a first viewing angle of a virtual camera; A first acquisition module, configured to acquire a first target map of the first virtual object model under the first view angle from a pre-established first map of the first virtual object model, wherein the first map is used to render a reflection effect of the first virtual object model; A second acquisition module is used to acquire a second target map of the second virtual object model under the first view perspective based on the first target map under the first view perspective and a predetermined relative relationship between the first virtual object model and the second virtual object model, wherein the second target map is used to render a reflection effect of the first virtual object model being reflected by the second virtual object model, and the relative relationship is used to indicate the relative positions of the first virtual object model and the second virtual object model in the same virtual scene.
11. An electronic device, characterized in that: The invention comprises a processor and a memory, wherein the memory stores computer executable instructions that can be executed by the processor, and the processor executes the computer executable instructions to implement the method for processing the reflection effect according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called and executed by a processor, the computer-executable instructions prompt the processor to implement the method for processing the reflection effect according to any one of claims 1 to 9.
13. A computer program product, characterized in that The computer program product comprises a computer program stored on a computer-readable storage medium, wherein the computer program comprises program instructions. When the program instructions are executed by a computer device, the computer device is caused to execute the method for processing reflection effects according to any one of claims 1 to 9.