Model rendering method and device, non-volatile storage medium and terminal device
By directly determining and rendering the reflection color of the virtual plane on the graphical user interface, the problem of difficulty in balancing accuracy and cost overhead when rendering light reflections in real time is solved, and the rendering efficiency and user experience are improved.
Patent Information
- Application Number
- CN202210676311.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-15
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2042-06-15
AI Technical Summary
In the prior art, when rendering light reflections in real time, the rendering accuracy and cost overhead are difficult to balance, affecting the user's gaming experience.
By obtaining the model data of the target model in the virtual scene, determining the spatial data of the points located below and above the virtual plane on the target model, and determining the reflection color of the virtual plane based on the color information of these spatial data, directly rendering on the graphical user interface, avoiding repeated sampling to determine the reflection position.
Improve rendering efficiency, ensure high rendering effect, and improve user's gaming experience.
Smart Images

Figure CN115120973B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision, and in particular to a model rendering method and apparatus, a non-volatile storage medium, and a terminal device. Background Art
[0002] Currently, most gaming applications utilize real-time rendering to present game scenes and enhance user interaction. In games, the quality of light reflection, such as the clarity of houses reflected in water or the speed at which houses are reflected from different angles as the camera rotates, can significantly impact the quality of a game. While light reflection technology has matured with the rapid development of the gaming industry, achieving exquisite real-time rendering of game reflections remains costly and expensive, impacting the user experience.
[0003] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0004] Embodiments of the present invention provide a model rendering method and apparatus, a non-volatile storage medium, and a terminal device, to at least solve the technical problem in the prior art of the difficulty in balancing rendering accuracy and cost overhead when rendering light reflections in real time.
[0005] According to one embodiment of the present invention, a model rendering method is provided, which provides a graphical user interface through a terminal device, and the content displayed by the graphical user interface includes at least: a virtual scene. The method includes: obtaining model data of a target model in the virtual scene, wherein part of a sub-model of the target model is located below a virtual plane, and the virtual plane is used to present a reflection effect; based on the model data, determining first spatial data of a first point on the target model, wherein the first point is a point on the sub-model of the target model located below the virtual plane; based on the first spatial data, determining second spatial data of a second point on the target model, wherein the second point is a point on the sub-model of the target model located above the virtual plane; based on color information corresponding to the second spatial data, determining the reflection color of the virtual plane; and rendering the virtual plane according to the reflection color.
[0006] Optionally, based on the model data, determining the first spatial data of the first point on the target model includes: determining the original spatial data of the virtual camera in the virtual scene, and the target spatial data from the virtual camera to the lower left corner of the far clipping plane; determining the first position data of the first point in the graphical user interface; determining the first spatial data based on the original spatial data, the target spatial data, the first position data and the original depth data in the model data.
[0007] Optionally, based on the original spatial data, target spatial data, first position data and original depth data in the model data, determining the first spatial data includes: mapping the original depth data to a graphical user interface to obtain target depth data; obtaining the product of the target depth data and the first spatial component in the target spatial data to obtain a first product; obtaining the product of the second spatial component in the target spatial data and the first coordinate component in the target position coordinates to obtain a second product; obtaining the product of the third spatial component in the target spatial data and the second coordinate component in the target position coordinates to obtain a third product; obtaining the sum of the original spatial data, the first product, the second product and the third product to obtain the first spatial data.
[0008] Optionally, determining the second spatial data of the second point on the target model based on the first spatial data includes: acquiring third spatial data of the virtual plane; and determining the second spatial data based on the first spatial data and the third spatial data.
[0009] Optionally, determining the reflection color of the virtual plane based on the color information corresponding to the second spatial data includes: mapping the second spatial data to a graphical user interface to obtain second position data; and acquiring color information corresponding to the second position data to obtain the reflection color.
[0010] Optionally, mapping the second spatial data to a graphical user interface to obtain the second position data includes: obtaining the camera position of a virtual camera in the virtual scene, a first distance from the virtual camera to a far clipping plane, a second distance from the virtual camera to a near clipping plane, and a field of view angle; determining a projection matrix based on the camera position, the first distance, the second distance, and the field of view angle; and obtaining the product of the second spatial data and the projection matrix to obtain the second position data.
[0011] Optionally, before obtaining the model data of the target model in the virtual scene, the method also includes: determining first terrain data of the target model above the virtual plane, and second terrain data of the target model below the virtual plane; in response to the difference between the first terrain data and the second terrain data being less than a preset threshold, obtaining the model data of the target model in the virtual scene.
[0012] According to one embodiment of the present invention, a model rendering device is also provided, which provides a graphical user interface through a terminal device, and the content displayed by the graphical user interface includes at least: a virtual scene. The device includes: a data acquisition module, used to obtain model data of a target model in the virtual scene, wherein part of the sub-model of the target model is located below the virtual plane, and the virtual plane is used to present a reflection effect; a first data determination module, used to determine first spatial data of a first point on the target model based on the model data, wherein the first point is a point on the sub-model of the target model located below the virtual plane; a second data determination module, used to determine second spatial data of a second point on the target model based on the first spatial data, wherein the second point is a point on the sub-model of the target model located above the virtual plane; a color determination module, used to determine the reflection color of the virtual plane based on color information corresponding to the second spatial data; and a rendering module, used to render the virtual plane according to the reflection color.
[0013] Optionally, the first data determination module includes: a first data determination unit, used to determine the original spatial data of the virtual camera in the virtual scene, and the target spatial data from the virtual camera to the lower left corner of the far clipping plane; a second data determination unit, used to determine the first position data of the first point in the graphical user interface; and a third data determination unit, used to determine the first spatial data based on the original spatial data, the target spatial data, the first position data and the original depth data in the model data.
[0014] Optionally, the third data determination unit is also used to: map the original depth data to a graphical user interface to obtain target depth data; obtain the product of the target depth data and the first spatial component in the target spatial data to obtain a first product; obtain the product of the second spatial component in the target spatial data and the first coordinate component in the target position coordinates to obtain a second product; obtain the product of the third spatial component in the target spatial data and the second coordinate component in the target position coordinates to obtain a third product; obtain the sum of the original spatial data, the first product, the second product and the third product to obtain the first spatial data.
[0015] Optionally, the second data determination module includes: a data acquisition unit, configured to acquire third spatial data of the virtual plane; and a fourth data determination unit, configured to determine the second spatial data based on the first spatial data and the third spatial data.
[0016] Optionally, the color determination module includes: a mapping unit, configured to map the second spatial data to a graphical user interface to obtain second position data; and a color acquisition unit, configured to acquire color information corresponding to the second position data to obtain a reflected color.
[0017] Optionally, the mapping unit is also used to: obtain the camera position of the virtual camera in the virtual scene, the first distance from the virtual camera to the far clipping plane, the second distance from the virtual camera to the near clipping plane, and the field of view angle; determine the projection matrix based on the camera position, the first distance, the second distance and the field of view angle; obtain the product of the second spatial data and the projection matrix to obtain the second position data.
[0018] Optionally, the device also includes: a terrain acquisition module, used to determine first terrain data of the target model above the virtual plane, and second terrain data of the target model below the virtual plane; the data acquisition module is also used to acquire model data of the target model in the virtual scene in response to the difference between the first terrain data and the second terrain data being less than a preset threshold.
[0019] According to one embodiment of the present invention, a non-volatile storage medium is further provided, including a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute any one of the above-mentioned model rendering methods.
[0020] According to one embodiment of the present invention, a terminal device is further provided, comprising: a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute any one of the above-mentioned model rendering methods.
[0021] In at least some embodiments of the present invention, model data of a target model in a virtual scene is obtained; first spatial data of a first point on the target model is determined based on the model data; second spatial data of a second point on the target model is determined based on the first spatial data; and a reflection color of a virtual plane is determined based on color information corresponding to the second spatial data; and the virtual plane is rendered according to the reflection color. The method includes mapping the first spatial data to a graphical user interface to determine the position as the reflection position, mapping the second spatial data to the graphical user interface to determine the position as the reflected position, and then directly determining the color corresponding to the position as the reflection color and rendering it at the reflection position. This method eliminates the need for repeated sampling of the second spatial data to determine whether the second spatial data corresponds to a target model based on the reflection position. This method avoids the high cost associated with repeatedly sampling model data to determine the reflection position in the prior art, improves the efficiency of rendering the virtual plane, and uses the color in the user interface to render the virtual plane, ensuring a high rendering effect, providing users with a good visual experience, and enhancing the user's gaming experience. This method also solves the technical problem in the prior art of balancing rendering accuracy and cost when rendering light reflections in real time. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0023] Figure 1 This is a schematic diagram of a screen space reflection principle in the prior art;
[0024] Figure 2 is a block diagram of the hardware structure of a mobile terminal according to a model rendering method according to an embodiment of the present invention;
[0025] Figure 3 is a flowchart of a model rendering method according to an embodiment of the present invention;
[0026] Figure 4 is a schematic diagram illustrating a method of determining spatial coordinates according to an embodiment of the present invention;
[0027] Figure 5 is a structural block diagram of a model rendering device according to an embodiment of the present invention;
[0028] Figure 6 is a schematic diagram of an electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0029] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only 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 ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0030] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0031] First, the technical names or technical terms that appear in the embodiments of the present invention are explained as follows:
[0032] RT: Render Target, specifically a piece of memory on the GPU (Graphics Processing Unit) used to record the image cache of rendering results.
[0033] Depth Buffer: Depth buffer, which saves the RT (the distance from the scene elements to the screen) of the depth information of the 3D scene rendered to the screen.
[0034] Sampling: Obtaining data from various RTs for calculations, etc. Sampling generates read and write operations (IO) on the CPU or GPU, resulting in bandwidth and power consumption.
[0035] Bandwidth: It is an important indicator for performance evaluation. During the rendering process, bandwidth refers to the number of times (data volume) the Depth Buffer and Color Buffer are read and written, which increases power consumption and heat generation of the phone.
[0036] Screen Space Reflection (SSR) uses the depth buffer and color buffer to simulate the reflected color of a certain position on the screen. It requires repeatedly reading the depth buffer to calculate the corresponding reflection position of a position on the screen.
[0037] Ray tracing reflection: A virtual ray is emitted from the virtual camera, and the surface touched by the ray and the direction of the bounce are calculated in the 3D scene. The final color obtained is the reflection result.
[0038] Reflection Probe: An image component placed in a 3D scene that takes a direction as input and returns the color in that direction. It can be used to describe the scene around a location and simulate reflections, but with very low accuracy.
[0039] Real-time rendering primarily involves drawing 3D scene data onto a 2D image. This image typically resides in a block of memory on the GPU. After rendering is complete, the engine copies the image data from memory to the monitor for display.
[0040] Screen space technology: In general rendering technology, different 2D images can be obtained by modifying the scene data in 3D space. However, for some complex effects and optimizations, screen space technology is required. In addition to drawing the color of the 2D image, this technology also needs to draw a 2D depth image (depth map), surface orientation information image (normal map), material information (material metalness, roughness), etc. Using this series of 2D information can produce more complex effects. This type of algorithm relies on repeatedly sampling various 2D information for calculation, thereby reducing dependence on the complexity of the 3D scene.
[0041] Projection matrix: A matrix that projects a point in 3D space into 2D image space.
[0042] Common types of light reflection include: mirror reflection, environmental reflection, light reflection, etc. In order to give users a good gaming experience in the game, relevant technicians have successively proposed a variety of light reflection technologies, such as reflection probes, mirror rendering, ray tracing, screen space reflection (Screen Space Reflection, referred to as SSR), etc.
[0043] Among them, the reflection probe technology selects a simple color in a fixed image as the reflection result based on the direction of a point on the surface of the reflecting object. Although the technical implementation is simple in operation and has low equipment requirements, it has poor flexibility and low reflection accuracy.
[0044] Mirror rendering can re-render the scene model above the mirror underwater based on the position of the reflection plane, allowing users to see exquisite mirror reflection results. However, the cost of re-rendering the scene model is too high and the equipment requirements are high. If the user does not prepare a powerful gaming device, it is difficult to have a good gaming experience.
[0045] Ray tracing is an advanced real-time rendering technology that can accurately calculate the reflection, refraction, and scattering of all light in the game scene. It is not limited to the rendering of flat game scenes. However, it has very high performance requirements for the device, and general high-performance devices cannot run ray tracing well.
[0046] The screen-space reflection algorithm is a post-processing technique based on screen space. It uses a depth buffer and a color buffer to simulate the reflected color at a specific location on the screen. It is independent of scene complexity and fixed cost, and offers excellent rendering results. It is widely used across various gaming devices, including mobile devices, desktops, and consoles.
[0047] Figure 1 This is a schematic diagram of a screen space reflection principle in the prior art, such as Figure 1As shown, A represents a virtual camera, which can refer to a viewing lens used to obtain the user's perspective. The image obtained by the virtual camera can be considered as the image that the user can observe from the display screen; B represents a reflected object, which can refer to various game models in the game scene, such as islands, ships, etc.; C represents a reflecting plane, which can refer to a plane used to reflect the reflected object, such as a water surface, a mirror, etc.; n represents the reflected point; m represents the reflecting point; D represents the normal of the reflecting screen at the reflecting point; α represents the incident angle and the reflection angle.
[0048] The principle of the screen space reflection algorithm is similar to the human eye observing the reflected objects in the reflection plane. It uses the virtual camera to calculate the reflection direction according to the normal and position information of the water surface, and moves along the reflection direction multiple times to search for the presence of the reflected object. Figure 1 The system determines whether point n exists based on the positions of A, m, and D in the image. If no point n is found, the virtual camera's perspective is moved to a new position and searched again, that is, point m is moved, and then re-searches whether point n exists based on A and the new point m. However, each time the reflection position is changed, the system needs to resample the depth information and normal information, read the Depth Buffer to calculate the two-dimensional spatial position corresponding to the reflection position on the device display, and make a judgment on whether the search is completed. Such a large number of repeated sampling and judgments will largely lead to excessive bandwidth utilization of the device GPU, resulting in a decrease in device performance.
[0049] In order to improve the gaming experience of players, according to one embodiment of the present invention, an embodiment of a model rendering method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0050] The method embodiment can be executed on a mobile terminal, a computer terminal, or a similar computing device. Taking running on a mobile terminal as an example, the mobile terminal can be a smartphone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, a game console, or other terminal devices. Figure 2 FIG. 1 is a block diagram of the hardware structure of a mobile terminal according to an embodiment of the present invention showing a model rendering method. Figure 2 As shown, the mobile terminal may include one or more ( Figure 2Only one is shown in the figure) processor 202 (the processor 202 may include but is not limited to a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP) chip, a microprocessor (MCU), a field-programmable logic device (FPGA), a neural network processor (NPU), a tensor processing unit (TPU), an artificial intelligence (AI) type processor, etc.) and a memory 204 for storing data. Optionally, the mobile terminal may further include a transmission device 206 for communication functions, an input and output device 208, and a display device 210. It will be understood by those skilled in the art that Figure 2 The structure shown is only for illustration and does not limit the structure of the mobile terminal. Figure 2 More or fewer components than shown, or with Figure 2 Different configurations shown.
[0051] The memory 204 can be used to store computer programs, for example, software programs and modules of application software, such as the computer program corresponding to the model rendering method in the embodiment of the present invention. The processor 202 executes various functional applications and data processing by running the computer program stored in the memory 204, that is, realizes the above-mentioned model rendering method. The memory 204 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 204 may further include a memory remotely located relative to the processor 202, and these remote memories can be connected to the mobile terminal via a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0052] Transmission device 206 is used to receive or transmit data via a network. A specific example of the aforementioned network may include a wireless network provided by the mobile terminal's communications provider. In one embodiment, transmission device 206 includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, transmission device 206 may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0053] Inputs to the input / output devices 208 can come from a variety of human interface devices (HIDs). Examples include keyboards and mice, game controllers, and other specialized game controllers (e.g., steering wheels, fishing rods, dance mats, remote controls, etc.). Some HIDs provide not only input but also output, such as force feedback and vibration on game controllers and audio output on controllers.
[0054] The display device 210 may be, for example, a head-up display (HUD), a touch-screen liquid crystal display (LCD), and a touch display (also referred to as a "touch screen" or "touch display"). The LCD may enable a user to interact with the user interface of the mobile terminal. In some embodiments, the mobile terminal may have a graphical user interface (GUI), and the user may interact with the GUI by finger contacts and / or gestures on the touch-sensitive surface. The human-computer interaction functions herein may optionally include the following interactions: creating web pages, drawing, word processing, making electronic documents, games, video conferencing, instant messaging, sending and receiving emails, call interfaces, playing digital videos, playing digital music, and / or web browsing, etc. The executable instructions for executing the above-mentioned human-computer interaction functions are configured / stored in a computer program product or readable storage medium executable by one or more processors.
[0055] The model rendering method in one embodiment of the present disclosure can be run on a local terminal device or a server. When the model rendering method 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.
[0056] In an optional embodiment, 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 gaming method based on cloud computing. In the cloud game operation mode, the operating body of the game program and the main body of the game screen presentation are separated. The storage and operation of the model rendering method are completed on the cloud game server. The role of the client device is to receive and send data and present the game screen. For example, the client device can be a display device with data transmission function close to the user side, such as a mobile terminal, TV, computer, PDA, etc.; but the cloud game server in the cloud is responsible for information processing. When playing the game, the player operates the client device to send operation instructions to the cloud game server. The cloud game server runs the game according to the operation instructions, 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.
[0057] In an optional embodiment, taking a game as an example, a local terminal device stores a game program and is used to present the game screen. The local terminal device is used to interact with the player through a graphical user interface, that is, conventionally downloading and installing the game program through an electronic device and running it. The local terminal device can provide the graphical user interface to the player in a variety of ways, for example, it can be rendered and displayed on the terminal's display screen, or provided to the player through holographic projection. For example, the local terminal device may include a display screen and a processor, the display screen is used to present the graphical user interface, the graphical user interface includes the game screen, and the processor is used to run the game, generate the graphical user interface, and control the display of the graphical user interface on the display screen.
[0058] In a possible implementation, an embodiment of the present invention provides a model rendering method that provides a graphical user interface through a terminal device, wherein the terminal device can be the local terminal device mentioned above or the client device in the cloud interaction system mentioned above. Figure 3 is a flow chart of a model rendering method according to an embodiment of the present invention, wherein the method proposes providing a graphical user interface through a terminal device, wherein the content displayed by the graphical user interface includes at least: a virtual scene, such as Figure 3 As shown, the method includes the following steps:
[0059] Step S302: Acquire model data of the target model in the virtual scene.
[0060] Part of the sub-model of the target model is located below the virtual plane, and the virtual plane is used to present the reflection effect.
[0061] The above-mentioned virtual scene can be a 3D game scene with light reflection; the above-mentioned target model can be a 3D model that will be reflected, such as an iceberg, an island, etc.; the above-mentioned virtual plane can be a plane used for light reflection, such as a water surface, a mirror, etc.; the above-mentioned model data can be the RT data of the target model in the virtual scene, including but not limited to the normal data, depth data, color data, etc. of the target model in the virtual scene.
[0062] The aforementioned virtual scene may be content displayed in a graphical user interface presented to a user via a terminal device, such as a game image viewed by a user on a mobile phone screen or computer display. The aforementioned target model may intersect with the aforementioned virtual plane, i.e., the target model may be divided into two parts by the virtual plane. For ease of understanding, the virtual plane is set as a horizontal plane, with one portion of the target model above the virtual plane and the other portion below the virtual plane. In this case, if the virtual camera is above the virtual plane, the portion of the model above the virtual plane is reflected; if the virtual camera is below the virtual plane, the portion of the model below the virtual plane is reflected.
[0063] It should be noted that the model rendering methods corresponding to the above two situations are the same. For ease of understanding, the model rendering method shown in this article is when the virtual camera is located above the virtual plane.
[0064] In an optional embodiment, after determining the virtual scene that needs to be rendered in real time, model data of the target model reflected in the scene can be obtained.
[0065] Step S304: determining first spatial data of a first point on the target model based on the model data.
[0066] The first point is a point on the sub-model below the virtual plane on the target model.
[0067] The first point may be a point on the model portion located below the virtual plane; and the first spatial data may be the 3D world coordinates of the first point in the virtual scene.
[0068] In an optional embodiment, after the model data of the target model is acquired, any point on the model portion below the virtual plane and the first spatial data corresponding to the point may be determined first.
[0069] Step S306: Determine second spatial data of a second point on the target model based on the first spatial data.
[0070] The second point is a point on the sub-model above the virtual plane on the target model.
[0071] The second point may be a point on the model portion located above the virtual plane; and the second spatial data may be the 3D world coordinates of the second point in the virtual scene.
[0072] It's important to note that the second point isn't an arbitrary point, but rather a point symmetrical to the first point about the virtual plane axis. That is, the 3D world coordinates of the second point can be determined based on the 3D world coordinates of the first point and the coordinates of the virtual plane. Since the position of the virtual plane in the game scene generally doesn't change, to improve the efficiency of determining the second spatial data, the virtual plane can be set to a plane with a vertical coordinate of 0. In other words, after acquiring the first spatial data, the second spatial data of the second point can be quickly acquired based on the first spatial data.
[0073] Step S308 : determining the reflection color of the virtual plane based on the color information corresponding to the second spatial data.
[0074] The color information may be color data of a point corresponding to the second spatial data in a virtual scene, and the reflection color may be the color of a reflection point in a virtual plane displayed in a graphical user interface.
[0075] In an optional embodiment, after the second spatial data is acquired, the reflection color can be determined based on the correspondence between the second spatial data and the corresponding reflection point on the virtual plane. The specific determination method is described below.
[0076] Step S310: Rendering the virtual plane according to the reflection color.
[0077] In an optional embodiment, after the reflection color is determined, the color of the reflection point corresponding to the second point on the virtual plane can be immediately rendered according to the reflection color. When all the reflection colors are determined and rendered on the virtual plane, the image formed is the reflection image, and the user can view the reflection image through the virtual camera.
[0078] In at least some embodiments of the present invention, model data of a target model in a virtual scene is obtained; first spatial data of a first point on the target model is determined based on the model data; second spatial data of a second point on the target model is determined based on the first spatial data; and a reflection color of a virtual plane is determined based on color information corresponding to the second spatial data; and the virtual plane is rendered according to the reflection color. The method includes mapping the first spatial data to a graphical user interface to determine the position as the reflection position, mapping the second spatial data to the graphical user interface to determine the position as the reflected position, and then directly determining the color corresponding to the position as the reflection color and rendering it at the reflection position. This method eliminates the need for repeated sampling of the second spatial data to determine whether the second spatial data corresponds to a target model based on the reflection position. This method avoids the high cost associated with repeatedly sampling model data to determine the reflection position in the prior art, improves the efficiency of rendering the virtual plane, and uses the color in the user interface to render the virtual plane, ensuring a high rendering effect, providing users with a good visual experience, and enhancing the user's gaming experience. This method also solves the technical problem in the prior art of balancing rendering accuracy and cost when rendering light reflections in real time.
[0079] In the above embodiment of the present invention, determining the first spatial data of the first point on the target model based on the model data includes: determining the original spatial data of the virtual camera in the virtual scene, and the target spatial data from the virtual camera to the lower left corner of the far clipping plane; determining the first position data of the first point in the graphical user interface; and determining the first spatial data based on the original spatial data, the target spatial data, the first position data, and the original depth data in the model data.
[0080] The above-mentioned original spatial data can be the 3D world coordinates of the virtual camera, represented by CameraPosition. The method for obtaining CameraPosition can refer to relevant literature and will not be repeated here. The above-mentioned target spatial data can be the X, Y, and Z vector components of the camera space from the virtual camera to the lower left corner of the far clipping plane. The above-mentioned first position data can be the position coordinates of the corresponding pixel point in the 2D image mapped to the above-mentioned first point, represented by Texture[u][v]. The above-mentioned original depth data can be the distance between the target model and the virtual camera.
[0081] It should be noted that, since the virtual camera, the first point and the corresponding reflection point on the virtual plane are on the same straight line, the above-mentioned first position data may also refer to the position coordinates of the reflection point.
[0082] In an optional embodiment, after obtaining the above-mentioned original spatial data, target spatial data, first position data, and original depth data, the 3D world coordinates corresponding to the first point can be calculated based on the preset calculation formula of the first spatial data. The calculation formula of the above-mentioned first space is generally used for the 3D world coordinates of the above-mentioned first point. The specific calculation method is shown below.
[0083] In the above embodiment of the present invention, determining the first spatial data based on the original spatial data, target spatial data, first position data and original depth data in the model data includes: mapping the original depth data to a graphical user interface to obtain target depth data; obtaining the product of the target depth data and the first spatial component in the target spatial data to obtain a first product; obtaining the product of the second spatial component in the target spatial data and the first coordinate component in the target position coordinates to obtain a second product; obtaining the product of the third spatial component in the target spatial data and the second coordinate component in the target position coordinates to obtain a third product; obtaining the sum of the original spatial data, the first product, the second product and the third product to obtain the first spatial data.
[0084] The above-mentioned first spatial component can be the above-mentioned vector component Z; the above-mentioned second spatial component can be the above-mentioned vector component X; the above-mentioned first coordinate component can be the horizontal coordinate u of the above-mentioned first point mapped to the corresponding pixel point in the 2D image; the above-mentioned third spatial component can be the above-mentioned vector component Y; the above-mentioned second coordinate component generally refers to the vertical coordinate v of the above-mentioned first point mapped to the corresponding pixel point in the 2D image.
[0085] The first product may be the vertical coordinate value z corresponding to the first spatial data; the second product may be the horizontal coordinate value x corresponding to the first spatial data; and the third product may be the vertical coordinate value y corresponding to the first spatial data.
[0086] Since the process of displaying a graphical user interface to a user using a virtual camera is equivalent to the process of mapping a 3D virtual scene to a 2D image, the target depth data may be a mapping result of the original depth data in the 2D image.
[0087] In an optional embodiment, the mapping of the target model data from the 3D virtual scene to the graphical user interface is completed through the GPU rasterization process. That is to say, the RT data such as the depth data, color data, normal data, etc. of the target model in the 3D virtual scene can be obtained by performing mapping steps such as depth testing, lighting calculation, and coordinate transformation on the point. In order to distinguish the above different types of data, each type of data can be represented in a 2D image in the form of RGBA (Red-Green-Blue-Alpha, color space) data. The specific representation method and mapping data relationship can be referred to in relevant literature and will not be repeated here. Optionally, the color of the depth data image after mapping can be used to determine the distance between the target model and the virtual camera. White represents a farther distance and black represents a closer distance.
[0088] That is to say, the above-mentioned target depth data can be determined by the original depth data and the first position data according to the mapping step, and can be represented by DepthTexture[u][v], which represents the depth data of the target model at the first position coordinate Texture[u][v].
[0089] After the target depth data is determined, first spatial data, ie, the 3D world coordinates of the first point relative to the virtual camera, may be determined based on the target depth data, the target spatial data, the first position data, and the original spatial data.
[0090] The calculation formula of the vertical coordinate value z of the first spatial data is:
[0091] z=DepthTexture[u][v]×Z+CameraPosition(z);
[0092] The calculation formula of the abscissa value x of the first spatial data is:
[0093] x=u*X+CameraPosition(x);
[0094] The calculation formula of the vertical coordinate value y of the first spatial data is:
[0095] y = v*Y + CameraPosition(y);
[0096] The final calculation formula for the first spatial data WorldPosition is:
[0097] WorldPosition=DepthTexture[u][v]*(Z)+u*X+v*Y+CameraPosition.
[0098] It should be noted that the different letters, phrases, etc. used above are only used as abbreviations to facilitate viewing the formulas. For example, CameraPosition represents the 3D world coordinates of the virtual camera, which itself has no special meaning and is not specifically limited.
[0099] In the above embodiment of the present invention, determining the second spatial data of the second point on the target model based on the first spatial data includes: acquiring third spatial data of the virtual plane; and determining the second spatial data based on the first spatial data and the third spatial data.
[0100] The third spatial data may be the 3D world coordinates of the virtual plane. For example, the virtual plane may be a horizontal plane with a vertical coordinate value of 0.
[0101] Figure 4 is a schematic diagram showing a spatial coordinate determination according to an embodiment of the present invention. Figure 4 With the above Figure 3 Similar, but different, Figure 4 The midpoint o is the first point mentioned above, and point n is the second point mentioned above, i.e., the reflected point. When the virtual camera A uses the data of the reflected point m on the virtual plane C, it can directly obtain the data of point o on the target model B. Based on the principle of light reflection and the principle of triangle symmetry, it can be determined that point n and point o are symmetrical about the virtual plane C. In other words, the vertical distance from the first point o to the virtual plane can be directly obtained, and then the second spatial coordinate corresponding to the second point n can be directly determined based on the vertical distance and the third spatial data.
[0102] For example, if the first spatial data corresponding to the first point o is (3, 5, -8), and the virtual plane C is a horizontal plane with a vertical coordinate value of 0, then the second spatial data corresponding to the second point n can be directly determined to be (3, 5, 8).
[0103] In the above embodiment of the present invention, determining the reflected color of the virtual plane based on the color information corresponding to the second spatial data includes: mapping the second spatial data to a graphical user interface to obtain second position data; and obtaining the color information corresponding to the second position data to obtain the reflected color.
[0104] In an optional embodiment, after obtaining the second spatial data, the second spatial data can be mapped to a pixel point in the graphical user interface according to the projection matrix, similar to the aforementioned implementation scheme of determining the first position data based on the first spatial data. The color corresponding to the pixel point is the reflection color.
[0105] Using the color displayed in the graphical user interface as the reflection color instead of the color of the target model corresponding to the second point can effectively avoid the problem of incorrectly determined reflection color when the second point is blocked by the target model.
[0106] In the above embodiment of the present invention, mapping the second spatial data to the graphical user interface to obtain the second position data includes: obtaining the camera position of the virtual camera in the virtual scene, a first distance from the virtual camera to the far clipping plane, a second distance from the virtual camera to the near clipping plane, and a field of view angle; determining a projection matrix based on the camera position, the first distance, the second distance, and the field of view angle; and obtaining the product of the second spatial data and the projection matrix to obtain the second position data.
[0107] In an optional embodiment, the projection matrix P is as follows:
[0108]
[0109] Among them, f represents the distance from the virtual camera to the far clipping plane; c represents the distance from the virtual camera to the near clipping plane; t represents the length of the graphical user interface; r represents the width of the graphical user interface.
[0110] After the projection matrix is determined, the second spatial data W can be directly multiplied by the projection matrix P to obtain its corresponding second position data H, where H=PW, ie, the coordinates of the pixel point in the graphical user interface.
[0111] In the above embodiment of the present invention, before obtaining the model data of the target model in the virtual scene, the method further includes: determining first terrain data of the target model above the virtual plane, and second terrain data of the target model below the virtual plane; in response to the difference between the first terrain data and the second terrain data being less than a preset threshold, obtaining the model data of the target model in the virtual scene.
[0112] The first terrain data may be the terrain of the target model portion above the virtual plane and close to the virtual plane, such as the iceberg portion above the water surface; the second terrain data may be the terrain of the target model portion below the virtual plane and close to the virtual plane, such as the iceberg portion below the water surface.
[0113] It should be noted that, in order to improve the efficiency of light reflection in the rendering model, the target model shown in this article can be a model with consistent terrain above and below the virtual plane and little deformation tendency, such as an iceberg, a beach, an island, etc. For this type of target model, a smaller difference threshold H and a larger difference threshold I can be set. Optionally, after determining the first terrain data and the second terrain data, the difference value between the first terrain data and the second terrain data is determined. If the difference value is less than H, it is determined that the model can be directly rendered using the above method to obtain model data; if the difference value is greater than H but less than I, the target model can be adjusted in the game, and after the adjustment is completed, the model data of the model can be obtained for rendering; if the difference value is greater than I, other rendering methods can be selected to render the model, such as using a screen space reflection algorithm.
[0114] By setting different rendering methods for different models, the accuracy of model rendering can be better improved, giving users a better gaming experience.
[0115] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods of various embodiments of the present invention.
[0116] In this embodiment, a model rendering device is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments. The details that have been described will not be repeated here. As used below, the terms "unit" and "module" can refer to a combination of software and / or hardware that implements a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation using hardware, or a combination of software and hardware, is also possible and contemplated.
[0117] Figure 5: This is a structural block diagram of a model rendering device according to an embodiment of the present invention. The device uses a terminal device to provide a graphical user interface, and the content displayed by the graphical user interface includes at least: a virtual scene. The device includes: a data acquisition module 502, used to obtain model data of a target model in the virtual scene, wherein part of a sub-model of the target model is located below a virtual plane, and the virtual plane is used to present a reflection effect; a first data determination module 504, used to determine first spatial data of a first point on the target model based on the model data, wherein the first point is a point on the sub-model of the target model located below the virtual plane; a second data determination module 506, used to determine second spatial data of a second point on the target model based on the first spatial data, wherein the second point is a point on the sub-model of the target model located above the virtual plane; a color determination module 508, used to determine the reflection color of the virtual plane based on color information corresponding to the second spatial data; and a rendering module 510, used to render the virtual plane according to the reflection color.
[0118] Optionally, the first data determination module 504 includes: a first determination unit, for determining the original spatial data of the virtual camera in the virtual scene, and the target spatial data from the virtual camera to the lower left corner of the far clipping plane; a second determination unit, for determining the first position data of the first point in the graphical user interface; and a third determination unit, for determining the first spatial data based on the original spatial data, the target spatial data, the first position data and the original depth data in the model data.
[0119] Optionally, the third determination unit includes: a target depth data determination subunit, used to map the original depth data to a graphical user interface to obtain target depth data; a first acquisition subunit, used to obtain the product of the target depth data and the first spatial component in the target spatial data to obtain a first product; a second acquisition subunit, used to obtain the product of the second spatial component in the target spatial data and the first coordinate component in the target position coordinates to obtain a second product; a third acquisition subunit, used to obtain the product of the third spatial component in the target spatial data and the second coordinate component in the target position coordinates to obtain a third product; and a first data determination subunit, used to obtain the sum of the original spatial data, the first product, the second product and the third product to obtain the first spatial data.
[0120] Optionally, the second data determining module 506 includes: a first acquiring unit, configured to acquire third spatial data of the virtual plane; and a fourth determining unit, configured to determine the second spatial data based on the first spatial data and the third spatial data.
[0121] Optionally, the color determination module 508 includes: a fifth determination unit, configured to map the second spatial data to a graphical user interface to obtain second position data; and a second acquisition unit, configured to acquire color information corresponding to the second position data to obtain a reflection color.
[0122] Optionally, the second acquisition unit includes: a fourth acquisition sub-unit, used to obtain the camera position of the virtual camera in the virtual scene, the first distance from the virtual camera to the far clipping plane, the second distance from the virtual camera to the near clipping plane, and the field of view angle; a projection matrix determination unit, used to determine the projection matrix based on the camera position, the first distance, the second distance and the field of view angle; a fifth acquisition sub-unit, used to obtain the product of the second spatial data and the projection matrix to obtain the second position data.
[0123] Optionally, the device also includes: a terrain data determination module, used to determine first terrain data of the target model above the virtual plane, and second terrain data of the target model below the virtual plane; a model data determination module, used to obtain model data of the target model in the virtual scene in response to the difference between the first terrain data and the second terrain data being less than a preset threshold.
[0124] It should be noted that the above-mentioned units and modules can be implemented through software or hardware. For the latter, it can be implemented in the following ways, but not limited to this: the above-mentioned units and modules are all located in the same processor; or the above-mentioned units and modules are located in different processors in any combination.
[0125] An embodiment of the present invention further provides a non-volatile storage medium, in which a computer program is stored. The computer program is configured to execute the steps of any one of the above method embodiments when running.
[0126] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.
[0127] Optionally, in this embodiment, the non-volatile storage medium may be configured to store a computer program for executing the following steps:
[0128] S31, obtaining model data of a target model in a virtual scene;
[0129] S32, determining first spatial data of a first point on the target model based on the model data;
[0130] S33, determining second spatial data of a second point on the target model based on the first spatial data;
[0131] S34, determining a reflection color of the virtual plane based on color information corresponding to the second spatial data;
[0132] S35: Rendering the virtual plane according to the reflection color.
[0133] Optionally, the above-mentioned non-volatile storage medium is also configured to store program code for performing the following steps: based on the model data, determining the first spatial data of the first point on the target model includes: determining the original spatial data of the virtual camera in the virtual scene, and the target spatial data from the virtual camera to the lower left corner of the far clipping plane; determining the first position data of the first point in the graphical user interface; determining the first spatial data based on the original spatial data, the target spatial data, the first position data and the original depth data in the model data.
[0134] Optionally, the above-mentioned non-volatile storage medium is also configured to store program code for performing the following steps: based on the original spatial data, target spatial data, first position data and original depth data in the model data, determining the first spatial data includes: mapping the original depth data to a graphical user interface to obtain target depth data; obtaining the product of the target depth data and the first spatial component in the target spatial data to obtain a first product; obtaining the product of the second spatial component in the target spatial data and the first coordinate component in the target position coordinates to obtain a second product; obtaining the product of the third spatial component in the target spatial data and the second coordinate component in the target position coordinates to obtain a third product; obtaining the sum of the original spatial data, the first product, the second product and the third product to obtain the first spatial data.
[0135] Optionally, the above-mentioned non-volatile storage medium is also configured to store program code for performing the following steps: based on the first spatial data, determining the second spatial data of the second point on the target model includes: obtaining the third spatial data of the virtual plane; based on the first spatial data and the third spatial data, determining the second spatial data.
[0136] Optionally, the above-mentioned non-volatile storage medium is also configured to store program code for performing the following steps: determining the reflection color of the virtual plane based on the color information corresponding to the second spatial data includes: mapping the second spatial data to a graphical user interface to obtain second position data; obtaining the color information corresponding to the second position data to obtain the reflection color.
[0137] Optionally, the above-mentioned non-volatile storage medium is also configured to store program code for executing the following steps: mapping the second spatial data to a graphical user interface to obtain the second position data, including: obtaining the camera position of the virtual camera in the virtual scene, the first distance from the virtual camera to the far clipping plane, the second distance from the virtual camera to the near clipping plane, and the field of view angle; determining the projection matrix based on the camera position, the first distance, the second distance and the field of view angle; obtaining the product of the second spatial data and the projection matrix to obtain the second position data.
[0138] Optionally, the above-mentioned non-volatile storage medium is also configured to store program code for executing the following steps: before obtaining the model data of the target model in the virtual scene, the method also includes: determining first terrain data of the target model above the virtual plane, and second terrain data of the target model below the virtual plane; in response to the difference between the first terrain data and the second terrain data being less than a preset threshold, obtaining the model data of the target model in the virtual scene.
[0139] Optionally, in this embodiment, the above-mentioned non-volatile storage medium may include but is not limited to: a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and other media that can store computer programs.
[0140] In at least some embodiments of the present invention, model data of a target model in a virtual scene is obtained; first spatial data of a first point on the target model is determined based on the model data; second spatial data of a second point on the target model is determined based on the first spatial data; and a reflection color of a virtual plane is determined based on color information corresponding to the second spatial data; and the virtual plane is rendered according to the reflection color. The method includes mapping the first spatial data to a graphical user interface to determine the position as the reflection position, mapping the second spatial data to the graphical user interface to determine the position as the reflected position, and then directly determining the color corresponding to the position as the reflection color and rendering it at the reflection position. This method eliminates the need for repeated sampling of the second spatial data to determine whether the second spatial data corresponds to a target model based on the reflection position. This method avoids the high cost associated with repeatedly sampling model data to determine the reflection position in the prior art, improves the efficiency of rendering the virtual plane, and uses the color in the user interface to render the virtual plane, ensuring a high rendering effect, providing users with a good visual experience, and enhancing the user's gaming experience. This method also solves the technical problem in the prior art of balancing rendering accuracy and cost when rendering light reflections in real time.
[0141] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present invention can be embodied in the form of a software product, which can be stored in a computer-readable storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present invention.
[0142] In the exemplary embodiments of the present application, a computer-readable storage medium stores a program product capable of implementing the above-described method of the present embodiment. In some possible implementations, various aspects of the present embodiment may also be implemented in the form of a program product, which includes program code. When the program product is executed on a terminal device, the program code is used to cause the terminal device to execute the steps according to various exemplary embodiments of the present invention described in the "Exemplary Method" section above.
[0143] According to an embodiment of the present invention, a program product for implementing the above method can be a portable compact disc read-only memory (CD-ROM) and include program code, and can be run on a terminal device, such as a personal computer. However, the program product of the embodiment of the present invention is not limited thereto. In the embodiment of the present invention, the computer-readable storage medium can be any tangible medium containing or storing a program, and the program can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0144] The program product may be implemented in any combination of one or more computer-readable media. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination thereof. More specific examples (non-exhaustive) of computer-readable storage media include: an electrical connection having one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0145] It should be noted that the program code contained in the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to wireless, wired, optical cable, RF, etc., or any appropriate combination of the above.
[0146] An embodiment of the present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the above method embodiments.
[0147] Optionally, the electronic device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor, and the input / output device is connected to the processor.
[0148] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:
[0149] S41, obtaining model data of a target model in a virtual scene;
[0150] S42, determining first spatial data of a first point on the target model based on the model data;
[0151] S43, determining second spatial data of a second point on the target model based on the first spatial data;
[0152] S44, determining a reflection color of the virtual plane based on color information corresponding to the second spatial data;
[0153] S45, rendering the virtual plane according to the reflection color.
[0154] Optionally, the above-mentioned non-volatile storage medium is also configured to store program code for performing the following steps: based on the model data, determining the first spatial data of the first point on the target model includes: determining the original spatial data of the virtual camera in the virtual scene, and the target spatial data from the virtual camera to the lower left corner of the far clipping plane; determining the first position data of the first point in the graphical user interface; determining the first spatial data based on the original spatial data, the target spatial data, the first position data and the original depth data in the model data.
[0155] Optionally, the above-mentioned non-volatile storage medium is also configured to store program code for performing the following steps: based on the original spatial data, target spatial data, first position data and original depth data in the model data, determining the first spatial data includes: mapping the original depth data to a graphical user interface to obtain target depth data; obtaining the product of the target depth data and the first spatial component in the target spatial data to obtain a first product; obtaining the product of the second spatial component in the target spatial data and the first coordinate component in the target position coordinates to obtain a second product; obtaining the product of the third spatial component in the target spatial data and the second coordinate component in the target position coordinates to obtain a third product; obtaining the sum of the original spatial data, the first product, the second product and the third product to obtain the first spatial data.
[0156] Optionally, the above-mentioned non-volatile storage medium is also configured to store program code for performing the following steps: based on the first spatial data, determining the second spatial data of the second point on the target model includes: obtaining the third spatial data of the virtual plane; based on the first spatial data and the third spatial data, determining the second spatial data.
[0157] Optionally, the above-mentioned non-volatile storage medium is also configured to store program code for performing the following steps: determining the reflection color of the virtual plane based on the color information corresponding to the second spatial data includes: mapping the second spatial data to a graphical user interface to obtain second position data; obtaining the color information corresponding to the second position data to obtain the reflection color.
[0158] Optionally, the above-mentioned non-volatile storage medium is also configured to store program code for executing the following steps: mapping the second spatial data to a graphical user interface to obtain the second position data including: obtaining the camera position of the virtual camera in the virtual scene, the first distance from the virtual camera to the far clipping plane, the second distance from the virtual camera to the near clipping plane, and the field of view angle; determining the projection matrix based on the camera position, the first distance, the second distance and the field of view angle; obtaining the product of the second spatial data and the projection matrix to obtain the second position data.
[0159] Optionally, the above-mentioned non-volatile storage medium is also configured to store program code for executing the following steps: before obtaining the model data of the target model in the virtual scene, the method also includes: determining first terrain data of the target model above the virtual plane, and second terrain data of the target model below the virtual plane; in response to the difference between the first terrain data and the second terrain data being less than a preset threshold, obtaining the model data of the target model in the virtual scene.
[0160] In at least some embodiments of the present invention, model data of a target model in a virtual scene is obtained; first spatial data of a first point on the target model is determined based on the model data; second spatial data of a second point on the target model is determined based on the first spatial data; and a reflection color of a virtual plane is determined based on color information corresponding to the second spatial data; and the virtual plane is rendered according to the reflection color. The method includes mapping the first spatial data to a graphical user interface to determine the position as the reflection position, mapping the second spatial data to the graphical user interface to determine the position as the reflected position, and then directly determining the color corresponding to the position as the reflection color and rendering it at the reflection position. This method eliminates the need for repeated sampling of the second spatial data to determine whether the second spatial data corresponds to a target model based on the reflection position. This method avoids the high cost associated with repeatedly sampling model data to determine the reflection position in the prior art, improves the efficiency of rendering the virtual plane, and uses the color in the user interface to render the virtual plane, ensuring a high rendering effect, providing users with a good visual experience, and enhancing the user's gaming experience. This method also solves the technical problem in the prior art of balancing rendering accuracy and cost when rendering light reflections in real time.
[0161] Figure 6 FIG is a schematic diagram of an electronic device according to an embodiment of the present invention. Figure 6 As shown, the electronic device 600 is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0162] like Figure 6As shown, electronic device 600 is implemented as a general-purpose computing device. Components of electronic device 600 may include, but are not limited to, at least one processor 610, at least one memory 620, a bus 630 connecting various system components (including memory 620 and processor 610), and a display 640.
[0163] The memory 620 stores program codes, which can be executed by the processor 610 , so that the processor 610 executes the steps according to various exemplary embodiments of the present invention described in the method section of the embodiment of the present application.
[0164] The memory 620 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 6201 and / or a cache memory unit 6202, and may further include a read-only memory unit (ROM) 6203, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory.
[0165] In some examples, the memory 620 may also include a program / utility 6204 having a set (at least one) of program modules 6205. Such program modules 6205 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data. Each or some combination of these examples may include an implementation of a network environment. The memory 620 may further include a memory remotely located relative to the processor 610. These remote memories may be connected to the electronic device 600 via a network. Examples of the aforementioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0166] Bus 630 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a local bus to processor 610, or a bus using any of a variety of bus architectures.
[0167] The display 640 may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the electronic device 600 .
[0168] Optionally, the electronic device 600 may also communicate with one or more external devices 700 (e.g., a keyboard, a pointing device, a Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 600, and / or any device that enables the electronic device 600 to communicate with one or more other computing devices (e.g., a router, a modem, etc.). Such communication may be performed through an input / output (I / O) interface 650. Furthermore, the electronic device 600 may also communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network, such as the Internet) through a network adapter 660. Figure 6 As shown, the network adapter 660 communicates with other modules of the electronic device 600 via the bus 630. Figure 6 Not shown, other hardware and / or software modules may be used in conjunction with electronic device 600, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0169] The electronic device 600 may further include: a keyboard, a cursor control device (such as a mouse), an input / output interface (I / O interface), a network interface, a power supply and / or a camera.
[0170] It can be understood by those skilled in the art that Figure 6 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 6 More or fewer components than shown, or with Figure 1 The memory 620 can be used to store computer programs and corresponding data, such as the computer programs and corresponding data corresponding to the model rendering method and apparatus, non-volatile storage medium, and terminal device method in the embodiments of the present invention. The processor 610 executes the computer programs stored in the memory 620 to perform various functional applications and data processing, thereby implementing the above-mentioned model rendering method and apparatus, non-volatile storage medium, and terminal device method.
[0171] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0172] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only exemplary. For example, the division of units can be a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0173] Units described as separate components may or may not be physically separate, and components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple units. Some or all of the units may be selected to achieve the purpose of the present embodiment according to actual needs.
[0174] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0175] If the integrated unit 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 all or 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 and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to execute all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk, etc. Various media that can store program codes.
[0176] The above are only preferred embodiments of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A model rendering method, characterized in that: A graphical user interface is provided by a terminal device, wherein the content displayed by the graphical user interface includes at least a virtual scene, and the method includes: Acquiring model data of a target model in the virtual scene, wherein a portion of a sub-model of the target model is located below a virtual plane, and the virtual plane is used to present a reflection effect; determining first spatial data of a first point on the target model based on the model data, wherein the first point is a point on a submodel of the target model located below the virtual plane, and the virtual plane intersects the target model; determining, based on the first spatial data, second spatial data of a second point on the target model, wherein the second point is a point on a submodel of the target model located above the virtual plane, and the second point is symmetrical to the first point about the virtual plane axis; determining a reflection color of the virtual plane based on color information corresponding to the second spatial data; Rendering the virtual plane according to the reflection color; Before obtaining the model data of the target model in the virtual scene, the method further includes: determining first terrain data of the target model above the virtual plane, and second terrain data of the target model below the virtual plane; and in response to a difference between the first terrain data and the second terrain data being less than a preset threshold, obtaining the model data of the target model in the virtual scene.
2. The method according to claim 1, characterized in that Determining first spatial data of a first point on the target model based on the model data includes: Determining original spatial data of a virtual camera in the virtual scene and target spatial data from the virtual camera to the lower left corner of a far clipping plane; determining first position data of the first point in the graphical user interface; The first spatial data is determined based on the original spatial data, the target spatial data, the first position data, and original depth data in the model data.
3. The method according to claim 2, characterized in that Determining the first spatial data based on the original spatial data, the target spatial data, the first position data, and original depth data in the model data includes: Mapping the original depth data to the graphical user interface to obtain target depth data; Acquire a product of the target depth data and a first spatial component in the target spatial data to obtain a first product; Obtaining a product of a second spatial component in the target spatial data and a first coordinate component in the target position coordinates to obtain a second product, wherein the target position coordinates are used to represent pixel coordinates of the first point in the graphical user interface; Obtaining a product of a third spatial component in the target spatial data and a second coordinate component in the target position coordinates to obtain a third product; The sum of the original spatial data, the first product, the second product, and the third product is acquired to obtain the first spatial data.
4. The method according to claim 1, wherein Determining second spatial data of a second point on the target model based on the first spatial data includes: Acquiring third space data of the virtual plane; The second spatial data is determined based on the first spatial data and the third spatial data.
5. The method according to claim 1, wherein Determining the reflection color of the virtual plane based on the color information corresponding to the second spatial data includes: mapping the second spatial data to a graphical user interface to obtain second position data; Color information corresponding to the second position data is obtained to obtain the reflected color.
6. The method according to claim 5, characterized in that Mapping the second spatial data to a graphical user interface to obtain second position data includes: Obtaining a camera position of a virtual camera in the virtual scene, a first distance from the virtual camera to a far clipping plane, a second distance from the virtual camera to a near clipping plane, and a field of view angle; Determining a projection matrix based on the camera position, the first distance, the second distance, and the field of view angle; The product of the second spatial data and the projection matrix is obtained to obtain the second position data.
7. A model rendering device, characterized in that: A graphical user interface is provided by a terminal device, wherein the content displayed by the graphical user interface includes at least a virtual scene, and the apparatus includes: a data acquisition module, configured to acquire model data of a target model in the virtual scene, wherein a portion of a sub-model of the target model is located below a virtual plane, and the virtual plane is configured to present a reflection effect; a first data determining module, configured to determine first spatial data of a first point on the target model based on the model data, wherein the first point is a point on a submodel of the target model located below the virtual plane, and the virtual plane intersects the target model; a second data determining module, configured to determine second spatial data of a second point on the target model based on the first spatial data, wherein the second point is a point on a submodel of the target model located above the virtual plane, and the second point is symmetrical to the first point about the virtual plane axis; a color determination module, configured to determine a reflection color of the virtual plane based on color information corresponding to the second spatial data; a rendering module, configured to render the virtual plane according to the reflection color; The device also includes: a terrain data determination module, configured to determine first terrain data of the target model above the virtual plane, and second terrain data of the target model below the virtual plane; and a model data determination module, configured to obtain model data of the target model in the virtual scene in response to a difference between the first terrain data and the second terrain data being less than a preset threshold.
8. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the model rendering method according to any one of claims 1 to 6.
9. A terminal device, characterized in that: include: A memory and a processor, wherein the memory stores a computer program, and the processor is configured to run the computer program to execute the model rendering method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Virtual content display method and device, terminal equipment and storage medium
CN111563966A