Ray tracing method and apparatus, computer device, storage medium, and computer program product

By performing ray tracing on the full-view depth information map of virtual scenes, the problem that ray tracing cannot be expanded off-screen in the existing technology is solved, achieving higher accuracy and efficiency, and improving the global lighting effect of ray tracing results .

WO2024212683A9PCT designated stage expired Publication Date: 2024-12-05TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2024/075049
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-04-13
Filing Date
2024-01-31
Publication Date
2024-12-05

AI Technical Summary

Technical Problem

Existing ray tracing methods cannot accurately track light outside the screen because the lack of depth information outside the screen space leads to inaccurate ray tracing results.

Method used

By obtaining the information map of the full viewing depth information of the virtual scene, projecting the tracking rays onto the information map, ray tracing along the travel path, depth information considerations are achieved inside and outside the screen, and ray tracing is expanded outside the screen.

Benefits of technology

It significantly improves the chance of light hitting an effective surface, improves the accuracy and efficiency of ray tracing, and enhances the global lighting effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024075049_05122024_PF_FP_ABST
    Figure CN2024075049_05122024_PF_FP_ABST
Patent Text Reader

Abstract

The present application discloses a ray tracing method and apparatus, a computer device, a storage medium, and a computer program product. The method comprises: acquiring an information map of a virtual scene, wherein full-view depth information of the virtual scene is recorded in the information map, and the full-view depth information comprises a depth value of each virtual object in the virtual scene; in the virtual scene and on the basis of a reference point, generating a tracing ray used for ray tracing, wherein the reference point is a position where the virtual object having a ray tracing requirement is located in the virtual scene; projecting the tracing ray from the virtual scene to the information map to obtain a travel path of the tracing ray on the information map; and on the information map, performing ray tracing along the travel path to obtain a ray tracing result.
Need to check novelty before this filing date? Find Prior Art

Description

Ray tracing method, device, computer equipment, storage medium and computer program product

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application is based on the Chinese patent application with application number 202310393666.7 and application date April 13, 2023, and claims the priority of the Chinese patent application. The entire content of the Chinese patent application is hereby introduced into this application as a reference. Technical Field

[0003] The present application relates to the field of computer technology, and relates to, but is not limited to, a ray tracing method, apparatus, computer equipment, storage medium, and computer program product. Background Art

[0004] With the development of computer graphics technology, ray tracing technology has been widely used in games, animations, film and television dramas and other products. The so-called ray tracing technology is a rendering algorithm in computer graphics. The specific behavior of ray tracing technology refers to projecting light through a certain point to the scene and tracing the light to determine whether the light intersects with an object in the scene.

[0005] In related technologies, the commonly used real-time ray tracing method is the screen space ray tracing method, which aims to simulate the ray tracing process by ray stepping in the screen space. Specifically, it emits several rays from each pixel in the screen space, and then ray steps each ray based on the depth information in the screen space, and then tests the intersection state of each ray to achieve the purpose of ray tracing.

[0006] However, when performing ray tracing, the methods in the related art only obtain depth information within the current screen space and cannot obtain depth information outside the screen. Therefore, if a ray travels to an area outside the screen, it cannot be traced further, resulting in the ray tracing result for that ray being directly considered as not hitting a valid surface. Therefore, the ray tracing methods in the related art cannot produce accurate ray tracing results and have significant limitations.

[0007] Summary of the Invention

[0008] Embodiments of the present application provide a ray tracing method, apparatus, computer device, storage medium, and computer program product, which can improve the accuracy of ray tracing.

[0009] An embodiment of the present application provides a ray tracing method, which includes: obtaining an information map of a virtual scene, wherein the information map records full-view depth information of the virtual scene, and the full-view depth information includes the depth value of each virtual object in the virtual scene; in the virtual scene, generating a tracing ray for ray tracing based on a reference point; the reference point is the position of a virtual object for which ray tracing is required in the virtual scene; projecting the tracing ray from the virtual scene to the information map to obtain a travel path of the tracing ray on the information map; and performing ray tracing along the travel path on the information map to obtain a ray tracing result.

[0010] An embodiment of the present application provides a ray tracing device, which includes: an acquisition unit, configured to acquire an information map of a virtual scene, wherein the information map records full-view depth information of the virtual scene, and the full-view depth information includes depth values ​​of each virtual object in the virtual scene; a processing unit, configured to generate tracing rays for ray tracing based on a reference point in the virtual scene; the reference point is the position of a virtual object for which ray tracing is required in the virtual scene; the processing unit is further configured to project the tracing rays from the virtual scene to the information map to obtain a travel path of the tracing rays on the information map; the processing unit is further configured to perform ray tracing along the travel path on the information map to obtain a ray tracing result.

[0011] An embodiment of the present application provides a computer device, which includes an input interface and an output interface, and further includes: a processor and a computer storage medium; wherein the processor is suitable for implementing one or more instructions, and the computer storage medium stores one or more instructions, and the one or more instructions are suitable for being loaded by the processor and executing the above-mentioned ray tracing method.

[0012] An embodiment of the present application provides a computer storage medium storing one or more instructions, wherein the one or more instructions are suitable for being loaded by a processor and executing the above-mentioned ray tracing method.

[0013] An embodiment of the present application provides a computer program product, which includes a computer program; when the computer program is executed by a processor, the above-mentioned ray tracing method is implemented.

[0014] The embodiment of the present application obtains an information map that records the full-view depth information of the virtual scene, and projects the tracing rays used for ray tracing in the virtual scene from the virtual scene to the information map, thereby obtaining the travel path of the tracing rays on the information map, and then performing ray tracing along the travel path on the information map. In this way, during the ray tracing process, the depth information inside and outside the screen space can be considered at the same time. That is to say, the embodiment of the present application performs ray tracing on the information map that records the full-view depth information, thereby extending ray tracing from inside the screen space to outside the screen space. This can greatly increase the probability of light hitting the effective surface, thereby improving the accuracy of ray tracing, and thus significantly improving the global illumination effect achieved based on the ray tracing results. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0016] FIG1a is a schematic diagram of a ray tracing method jointly executed by a terminal and a server according to an embodiment of the present application;

[0017] FIG1b is a schematic diagram of another ray tracing method jointly executed by a terminal and a server provided in an embodiment of the present application;

[0018] FIG2 is a schematic flow chart of a ray tracing method provided in an embodiment of the present application;

[0019] FIG3a is a schematic diagram of generating discrete surface elements in a virtual scene according to an embodiment of the present application;

[0020] FIG3 b is a schematic diagram of generating tracing rays in a virtual scene provided by an embodiment of the present application;

[0021] FIG3 c is a schematic diagram of an octahedral mapping provided in an embodiment of the present application;

[0022] FIG3 d is a schematic diagram of obtaining a path of a tracing ray on an information map according to an embodiment of the present application;

[0023] FIG4 is a flow chart of a ray tracing method provided in another embodiment of the present application;

[0024] FIG5a is a schematic diagram of a viewing cone of a camera provided in an embodiment of the present application;

[0025] FIG5 b is a schematic diagram of obtaining an information map provided by an embodiment of the present application;

[0026] FIG5c is a schematic diagram of marking step points provided in an embodiment of the present application;

[0027] FIG6 is a schematic structural diagram of a ray tracing device provided in an embodiment of the present application;

[0028] FIG7 is a schematic structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0029] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application.

[0030] The embodiments of this application are based on computer vision (CV) and computer graphics technologies within artificial intelligence (AI) technology, and propose a method for ray tracing based on full-view depth information of a virtual scene. AI technology refers to theories, methods, techniques, and application systems that use digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to achieve optimal results. In other words, AI is a comprehensive technology within computer science; it primarily develops new intelligent machines that can react in a manner similar to human intelligence by understanding the essence of intelligence, enabling intelligent machines to possess multiple functions such as perception, reasoning, and decision-making. Computer vision within AI is the science of making machines "see." Specifically, it refers to the use of cameras and computers to replace the human eye in identifying, tracking, and measuring targets, and further performing image processing to transform computer processing into images more suitable for human observation or transmission to instruments for detection. Computer graphics technology in AI technology is a science that uses mathematical algorithms to convert two-dimensional or three-dimensional graphics into raster form for computer displays; simply put, the main research content of computer graphics is to study how to represent graphics in computers, as well as the relevant principles and algorithms for using computers to calculate, process and display graphics.

[0031] In the embodiments of the present application, a virtual scene can be understood as a scene that can be displayed on a device screen. For example, the virtual scene can be a scene obtained by simulating a scene in the real world, such as a scene obtained by simulating an autonomous driving scene or a scenic spot scene in the real world; or the virtual scene can be a semi-simulated and semi-fictional scene, such as a scene in which fictional characters are superimposed on a simulated world corresponding to the real world; or the virtual scene can be a purely fictional scene, such as a scene from a game, a TV series, or a movie, etc.

[0032] The virtual scene may include at least one virtual object. The virtual object may be a static object element in the virtual scene, such as virtual grass, virtual buildings, etc.; or, the virtual object may be an movable object in the virtual scene, such as a virtual character in a game scene, a virtual animal in a game scene, etc. It should be understood that each virtual object in the virtual scene may be a static object element, or may be an movable object, or may include both static object elements and movable objects, without limitation. The virtual scene may also include a camera, which is a component for presenting a view of the virtual scene from at least one viewing angle. The embodiment of the present application does not limit the position of the camera in the virtual scene. For example, the camera may be located at the position of a virtual object in the virtual scene, or at any position in the virtual scene other than the position of each virtual object, etc.

[0033] A full view refers to the full view (i.e., a 360° view) of a virtual scene from any object (such as a user or a camera). The full view may include viewpoints from multiple view directions. The multiple view directions mentioned here can be set based on empirical values ​​or actual needs. For example, assuming that the virtual scene is built based on a three-dimensional Cartesian coordinate system, which is a coordinate system that can define the position of an object in three-dimensional space and is composed of three coordinate axes: the X-axis (horizontal axis), the Y-axis (vertical axis), and the Z-axis (vertical axis), then the multiple view directions may include: the positive direction of each coordinate axis in the three-dimensional Cartesian coordinate system (i.e., the direction indicated by the arrow of the coordinate axis), and the negative direction of each coordinate axis (i.e., the direction opposite to the direction indicated by the arrow of the coordinate axis). Since the full view can view all virtual objects in the virtual scene, the full view depth information may include the depth value of each virtual object in the virtual scene; wherein the depth value of any virtual object refers to the distance value between the corresponding virtual object and the camera. It should be understood that the distance value between the same virtual object and the camera remains unchanged regardless of the view angle, so the depth value of the same virtual object is the same under different view angles in the full view. During the ray tracing process, the depth value of any virtual object can be used to determine whether there is a virtual object where the light reaches, thereby obtaining the ray tracing result.

[0034] Based on the above definition, the following describes the principle behind the method for performing ray tracing based on full-view depth information of a virtual scene, as proposed in an embodiment of the present application. The general principles of this method are as follows: First, an information map of the virtual scene is obtained, and tracing rays for ray tracing are generated based on the positions of virtual objects in the virtual scene that require ray tracing. Next, the tracing rays are projected from the virtual scene onto the information map to obtain the path of the tracing rays on the information map. Ray tracing can then be performed along this path on the information map. Because the information map records the full-view depth information of the virtual scene, and the full-view depth information includes the depth values ​​of all virtual objects in the virtual scene, that is, the full-view depth information includes the depth values ​​of virtual objects displayed on the screen as well as the depth values ​​of virtual objects not displayed on the screen (i.e., the depth values ​​of virtual objects outside the screen); therefore, by performing ray tracing on the information map that records the full-view depth information, the embodiment of the present application can simultaneously perform ray tracing based on the depth values ​​of virtual objects on the screen and the depth values ​​of virtual objects outside the screen, thereby extending ray tracing to outside the screen, thereby overcoming the limitation of traditional ray tracing methods that cannot effectively trace rays outside the screen space due to the lack of depth information outside the screen space. This can significantly increase the probability of light rays hitting valid surfaces and improve the accuracy of ray tracing. Moreover, because the information map can be a two-dimensional (2D) map, it can be seen that the entire ray tracing process of the embodiment of the present application can be completed on a single 2D map, which can greatly improve the efficiency of ray tracing.

[0035] During implementation, the aforementioned method can be performed by a single computer device, which can be a terminal or a server. Alternatively, the aforementioned method can be performed jointly by a terminal and a server. For example, the terminal can be responsible for acquiring an information map, generating tracing rays, and determining the path of the tracing rays on the information map. The path and the information map can then be sent to the server, causing the server to perform ray tracing along the path on the information map, as shown in Figure 1a. Alternatively, the server can be responsible for acquiring an information map and generating tracing rays, and then sending the information map and tracing rays to the terminal, causing the terminal to project the tracing rays to obtain the path of the tracing rays on the information map and perform ray tracing along the path on the information map, as shown in Figure 1b. Alternatively, the server and the terminal can each acquire an information map, with the server performing a series of operations to obtain the path of the tracing rays on the information map and sending the path to the terminal, causing the terminal to perform ray tracing along the path sent by the server on the information map it generated, and so on.

[0036] The terminals mentioned above may include, but are not limited to, smartphones, computers (such as tablets, laptops, and desktop computers), smart wearable devices (such as smart watches and smart glasses), smart voice interaction devices, smart home appliances (such as smart TVs), in-vehicle terminals, or aircraft. Servers may be standalone physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. Furthermore, terminals and servers may be located outside or within a blockchain network, without limitation. A blockchain network is a network composed of a peer-to-peer (P2P) network and a blockchain. Blockchain refers to a novel application model for computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. It is essentially a decentralized database, a series of data blocks (or blocks) generated using cryptographic methods. When any device among the terminal and the server is located in the blockchain network or has a communication connection with the blockchain network, any device can upload its internal data to the blockchain of the blockchain network for storage to prevent the internal data of the computer device from being tampered with, thereby improving the security of the internal data.

[0037] Based on the above description, the embodiment of the present application proposes a ray tracing method. The ray tracing method can be executed by the computer device (terminal or server) mentioned above, or it can be executed by the terminal and the server together; for ease of explanation, the following description will take the computer device executing the ray tracing method as an example. Referring to Figure 2, the ray tracing method may include the following steps S201 to S204:

[0038] S201 , obtaining an information map of a virtual scene, wherein the information map records full-view depth information of the virtual scene.

[0039] In one implementation, as can be seen from the foregoing, the full perspective of the virtual scene includes perspectives under multiple perspective directions, where the full perspective refers to the full perspective of any object (such as a user or a camera) viewing the virtual scene, that is, a 360° perspective. Multiple perspective directions can be set according to empirical values ​​or actual needs. For example, if the virtual scene is built based on a three-dimensional Cartesian coordinate system, then the multiple perspective directions may include: the positive direction of each coordinate axis in the three-dimensional Cartesian coordinate system, and the negative direction of each coordinate axis.

[0040] The full-view depth information includes the depth values ​​of all virtual objects in the virtual scene, as all virtual objects can be viewed. The depth value of any virtual object refers to the distance between the object and the camera. The distance between the same virtual object and the camera remains constant regardless of the viewing angle, resulting in the same depth value for the same virtual object from different viewing angles within the full-view depth information.

[0041] In some embodiments, when acquiring an information map of a virtual scene, the computer device may collect depth information of the virtual scene in each viewing direction, thereby constructing an information map of the virtual scene based on the collected depth information. For example, step S201 may be implemented as follows: First, an initial three-dimensional map of the virtual scene may be acquired. The initial three-dimensional map is an image used to record scene views of the virtual scene in each viewing direction. The initial three-dimensional map may include multiple faces, where each face represents a scene view of the virtual scene in a viewing direction, and different faces correspond to different viewing directions. In other words, the number of faces involved in the initial three-dimensional map is the same as the number of viewing directions involved in the virtual scene. When the virtual scene involves six viewing directions (such as the positive and negative directions of the X-axis, Y-axis, and Z-axis mentioned above), the initial three-dimensional map may be a cube map composed of six faces, and the six faces of the cube map represent the scene views seen when viewing the virtual scene along the positive and negative directions of the X-axis, Y-axis, and Z-axis, respectively. Secondly, the depth information of the virtual scene in each viewing direction can be obtained. Any depth information includes: the depth value of each virtual object in the scene view in the corresponding viewing direction; it should be understood that if there is a scene view in a certain viewing direction that does not include a virtual object, the depth information in this viewing direction is empty. Then, the depth value in each depth information obtained can be recorded in the pixel points in the corresponding surface of the initial three-dimensional map to obtain the target three-dimensional map; and each pixel point in the target three-dimensional map can be mapped to a two-dimensional blank map to obtain an information map of the virtual scene, wherein the two-dimensional blank map refers to a two-dimensional map that does not contain any information. It can be seen that the information map obtained by this embodiment directly records the full-view depth information of the virtual scene (i.e., the depth value of each virtual object), which can effectively improve the search efficiency when searching for the depth value of any virtual object in the information map.

[0042] In another implementation, a computer device can also construct an information map of a virtual scene using discrete surface elements. The so-called discrete surface elements refer to planar shapes with direction and size (such as ellipses, circles, etc.). Step S201 can be implemented as follows: First, multiple discrete surface elements can be generated in the virtual scene, with at least one discrete surface element attached to the surface of each virtual object in the virtual scene. For example, a schematic diagram of generating discrete surface elements in the virtual scene can be shown in Figure 3a, where the left image in Figure 3a is a scene view of the virtual scene, and the right image in Figure 3a is the generated discrete surface elements. Second, the distance value between each discrete surface element and the camera can be obtained as the depth value of the corresponding discrete surface element in the virtual scene. The distance value between any discrete surface element and the camera can be obtained by calculating the Euclidean distance based on the world space coordinates of any discrete surface element and the world space coordinates of the camera to obtain the distance value between the corresponding discrete surface element and the camera. The so-called world space coordinates refer to coordinates in the world space coordinate system, which can also be called an absolute coordinate system and does not change with viewing angle or other factors. After obtaining the depth value of each discrete surface element in the virtual scene, the computer device can use the depth value of each discrete surface element in the virtual scene to construct an information map of the virtual scene. For example, the computer device can obtain a two-dimensional map template, which includes multiple pixels, each pixel is used to store a depth value; according to the direction vector between each discrete surface element and the camera, the pixel corresponding to each discrete surface element in the map template is searched, and then the depth value of each discrete surface element in the virtual scene is stored in the corresponding pixel to obtain the information map of the virtual scene. It can be seen that the information map obtained by this embodiment is to record the depth information of the full perspective of the virtual scene by recording the depth value of the discrete surface elements attached to the surface of each virtual object; compared with the method of obtaining the information map by collecting the depth information under each viewing direction, this embodiment can simplify the construction process of the information map and improve the efficiency of obtaining the information map.

[0043] S202 : In a virtual scene, generating a tracing ray for ray tracing based on a reference point.

[0044] During step S202, the computer device may invoke an image processing engine to generate a tracing ray based on a reference point in the virtual scene. The so-called tracing ray can be understood as a virtual ray (i.e., a ray that does not exist in the virtual scene). The computer device may invoke the image processing engine to determine a tracing ray emission direction based on business needs, or randomly determine a tracing ray emission direction; then, the computer device invokes the image processing engine to generate a tracing ray for ray tracing in the emission direction based on a reference point in the virtual scene.

[0045] In the embodiment of the present application, the reference point refers to the position of a virtual object in a virtual scene that has a ray tracing requirement. The virtual object that has a ray tracing requirement can be any virtual object among multiple virtual objects in the virtual scene. In actual applications, the virtual object in the virtual scene that has a ray tracing requirement can be set according to business needs, that is, the existence of a ray tracing requirement can be determined by a preset setting. For example, as shown in Figure 3b, if the business needs indicate that the lighting information of the virtual character 31 in Figure 3b needs to be collected, it can be set that the virtual character 31 has a ray tracing requirement, so that when the computer device executes step S202, the position of the virtual character 31 in the virtual scene is determined as the reference point, and then the tracing ray 32 in Figure 3b is generated based on the reference point. Alternatively, the computer device can also randomly select a virtual object from the virtual scene as the virtual object that has a ray tracing requirement, that is, the existence of a ray tracing requirement can be determined by randomly selecting in the virtual scene, so that when the computer device executes step S202, the position of the randomly selected virtual character in the virtual scene is determined as the reference point.

[0046] In some embodiments, the virtual object focused on in the current virtual scene can also be determined as a virtual object with ray tracing requirements. For example, for a 1v1 game, the two player characters (i.e., virtual objects) currently participating in the game are the currently focused virtual objects. Therefore, these two player characters can be directly determined as virtual objects with ray tracing requirements.

[0047] In some embodiments, the virtual object closest to the camera in the current virtual scene can also be determined as the virtual object requiring ray tracing. That is, if there are multiple virtual objects in the virtual scene, for the current default camera (i.e., the camera that generates the image of the virtual scene, which can also be understood as the camera that captures the image forming the current virtual scene), the virtual object closest to the camera is the virtual object requiring ray tracing. In this way, since the depth value between the camera and each virtual object can be determined when the virtual scene information map is obtained in S201 above, the distance between each virtual object and the camera can be determined, thereby quickly determining the virtual object requiring ray tracing.

[0048] S203: Project the tracing ray from the virtual scene to the information map to obtain a travel path of the tracing ray on the information map.

[0049] Since the virtual scene is in three-dimensional space, research has shown that when a ray in three-dimensional space is mapped to a two-dimensional image using octahedral mapping, it will be divided into multiple continuous line segments (up to four line segments), each of which is distributed on an independent face of the octahedron, and the starting point of any line segment on the two-dimensional image is the two-dimensional projection of the intersection of the ray in three-dimensional space and the three axis planes of the corresponding coordinate system; therefore, based on this principle, when the tracing ray in the virtual scene is projected onto a two-dimensional information map using octahedral mapping, multiple continuous line segments can be obtained, and these continuous line segments can be used as the path of the tracing ray on the information map. In an embodiment of the present application, octahedral mapping is a spherical parameterized mapping method, the principle of which is to map spherical parameters to an octahedron, and then further map them to a parameter mapping method on a two-dimensional image, as shown in Figure 3c.

[0050] Based on this, when the computer device executes step S203, it can project the starting point of the tracing ray to the information map through an octahedron mapping operation to obtain a first projection point. In addition, the three-dimensional space coordinate system corresponding to the virtual scene is determined, and the intersection between the tracing ray and at least one axial plane in the three-dimensional space coordinate system is projected to the information map through an octahedron mapping operation to obtain at least one second projection point. In addition, the path end point can be determined on the tracing ray according to a preset tracing path threshold (or called the maximum tracing path, whose unit is a length unit), and the path end point can be projected to the information map through an octahedron mapping operation to obtain a third projection point. Then, the first projection point, at least one second projection point, and the third projection point can be connected in sequence to obtain the path of the tracing ray on the information map. For example, assuming that the number of second projection points is three, and the first projection point is identified by label 33, the second projection points are identified by label 34, and the third projection point is identified by label 35, the path of the tracing ray on the information map can be obtained as shown in Figure 3d; wherein, the first projection point is the starting point S of the path, and the third projection point is the end point E of the path.

[0051] In some embodiments, the implementation method of a computer device projecting any point onto an information map through an octahedral mapping operation may be: first, a direction vector between any point and a camera may be obtained, where the direction of the direction vector is the direction in which the camera points to any point; second, each vector element in the direction vector may be normalized so that the modulus of the normalized direction vector is 1, so that the normalized direction vector can be used to represent the position of any point on a sphere constructed with the camera as the center; then, a preset conversion method may be used to convert the normalized direction vector into two-dimensional coordinates, and the converted two-dimensional coordinates are the coordinates of the projection point of the any point on the information map.

[0052] During the implementation process, the normalized direction vector (the direction vector may be a three-dimensional direction vector) may be obtained first, and then the normalized direction vector may be converted using a preset conversion method to obtain a two-dimensional coordinate. The preset conversion method may be implemented by calling a conversion function, the input of which is the normalized direction vector, and the output is a two-dimensional coordinate. During the conversion process, the conversion function may determine the corresponding two-dimensional coordinate by determining the value of the normalized direction vector in the three-dimensional direction (the aforementioned X-axis, Y-axis, and Z-axis).

[0053] In an embodiment of the present application, it can be determined whether the x component of the normalized direction vector in the X-axis direction is greater than 0. If so, the x component of the two-dimensional coordinate takes a value of 1, otherwise it takes a value of -1; and it can be determined whether the y component of the normalized direction vector in the Y-axis direction is greater than 0. If so, the y component of the two-dimensional coordinate takes a value of 1, otherwise it takes a value of -1.

[0054] For example, if the value of the normalized direction vector in the X-axis direction is greater than 0, and the value of the normalized direction vector on the Y-axis is also greater than 0, then the output two-dimensional coordinate can be determined to be (1, 1); if the value of the normalized direction vector in the X-axis direction is greater than 0, and the value of the normalized direction vector on the Y-axis is less than or equal to 0, then the output two-dimensional coordinate can be determined to be (1, -1); if the value of the normalized direction vector in the X-axis direction is less than or equal to 0, and the value of the normalized direction vector on the Y-axis is greater than 0, then the output two-dimensional coordinate can be determined to be (-1, 1); if the value of the normalized direction vector in the X-axis direction is less than or equal to 0, and the value of the normalized direction vector on the Y-axis is also less than or equal to 0, then the output two-dimensional coordinate can be determined to be (-1, -1).

[0055] In some embodiments, if the value of the normalized direction vector in the Z-axis direction is greater than 0, the final two-dimensional coordinate is determined to be the two-dimensional coordinate determined based on the value in the X-axis direction and the value in the Y-axis direction; if the value of the normalized direction vector in the Z-axis direction is less than or equal to 0, the two-dimensional coordinate determined based on the value in the X-axis direction and the value in the Y-axis direction is corrected. The positive and negative correction here can refer to correcting a positive value to a negative value and a negative value to a positive value. For example, if the two-dimensional coordinate determined based on the value in the X-axis direction and the value in the Y-axis direction is (1, 1), and the value of the normalized direction vector in the Z-axis direction is less than or equal to 0, the two-dimensional coordinate after the positive and negative correction is (-1, -1), that is, the two-dimensional coordinate finally output is (-1, -1).

[0056] S204: Perform ray tracing along the travel path on the information map to obtain a ray tracing result.

[0057] As can be seen from the above description, the information map includes multiple pixels, each pixel stores a depth value, and a virtual object in the virtual scene corresponds to at least one pixel in the information map. If the information map directly records the depth values ​​of each virtual object in the virtual scene, then one virtual object corresponds to one pixel; if the information map records the depth values ​​of each virtual object in the virtual scene by recording the depth values ​​of discrete surface elements attached to the surface of each virtual object, then the number of pixels corresponding to a virtual object is the same as the number of discrete surface elements involved in the virtual object. Based on this, when executing step S204, the computer device can determine whether the light hits the valid surface based on the depth values ​​stored in the pixels in the information map, thereby obtaining the ray tracing result.

[0058] Here, a valid surface refers to the surface of any virtual object in the virtual scene; that is, the meaning of a ray hitting a valid surface can be understood as: the ray (i.e., the traced ray) hits the surface of a virtual object. It can be understood that determining whether a ray hits a valid surface essentially depends on whether a virtual object exists where the ray passes; if so, it indicates that the ray will hit the surface of the virtual object. Because when a virtual object exists at a certain location in the virtual scene, the depth value at that location will be less than or equal to the depth value stored at the pixel corresponding to that location on the information map. Therefore, the computer device can determine whether the ray hits a valid surface by determining the relationship between the depth value stored at the pixel in the information map and the true depth value of that pixel (i.e., the depth value of the pixel's mapping point in the virtual scene). If the depth value stored at the pixel is greater than or equal to the pixel's true depth value, it indicates that a virtual object exists at the pixel's mapping point in the virtual scene, indicating that the ray can hit a valid surface. Otherwise, it indicates that the ray did not hit a valid surface. Using this embodiment to determine whether a ray hits a valid surface, it is not necessary to consider the position of the camera, which can improve the efficiency of ray tracing and the accuracy of ray tracing results. Furthermore, considering that when the information map is obtained as mentioned above, there may be certain factors that cause the depth value stored in the information map to have a certain error, then in order to improve the fault tolerance of ray tracing, the computer device can also determine whether the light hits the valid surface by judging whether the difference between the depth value stored in the pixel point and the actual depth value is less than or equal to a preset difference threshold; if the difference is less than or equal to the difference threshold, it indicates that there is a virtual object at the mapping point of the pixel point in the virtual scene, thereby indicating that the light can hit the valid surface; otherwise, it indicates that the light does not hit the valid surface.

[0059] Alternatively, as can be seen from the foregoing, the embodiment of the present application does not limit the position of the camera in the virtual scene. It can be located at the position of a virtual object in the virtual scene, or at any position in the virtual scene other than the position of each virtual object, etc. Since the depth value of any virtual object refers to the distance value between the corresponding virtual object and the camera, and when the camera is located at any position other than the position of each virtual object, the distance value between each virtual object and the camera must be a valid value (i.e., a value that is not zero), it can be seen that the depth value of each virtual object recorded by the information map in this case must be a valid value; then in this case, the computer device can determine whether the light hits the valid surface by determining whether the depth value stored in the pixel point in the information map is a valid value. If the depth value stored in the pixel point is a valid value, it indicates that there is a virtual object at the mapping point of the pixel point in the virtual scene, thereby indicating that the light can hit the valid surface; otherwise, it indicates that the light does not hit the valid surface.

[0060] The embodiment of the present application obtains an information map that records the full-view depth information of the virtual scene, and projects the tracing rays used for ray tracing in the virtual scene from the virtual scene to the information map, thereby obtaining the travel path of the tracing rays on the information map, and then tracing the rays along the travel path on the information map. This method can solve the limitation of traditional ray tracing methods that cannot perform effective ray tracing outside the screen space due to the lack of depth information outside the screen space. In other words, the embodiment of the present application can extend ray tracing to outside the screen by performing ray tracing on the information map that records the full-view depth information, which can greatly increase the probability of light hitting the effective surface, thereby improving the accuracy of ray tracing. Moreover, since the information map can be a two-dimensional map, it can be seen that the entire ray tracing process of the embodiment of the present application can be completed on a two-dimensional map, which can greatly improve the efficiency of ray tracing.

[0061] Based on the method embodiment shown in FIG2 above, the embodiment of the present application also proposes a ray tracing method. In the embodiment of the present application, the ray tracing method is mainly described by taking a computer device executing the ray tracing method as an example; and the embodiment of the present application chooses to use the spherical depth information obtained by performing a depth test based on a certain camera point on all virtual objects in the virtual scene, and then mapping it through an octahedron. The resulting two-dimensional information map will be used as a representation of the full-view depth information. As shown in FIG4, the ray tracing method may include the following steps S401 to S407:

[0062] S401, obtaining an initial three-dimensional map of the virtual scene.

[0063] Here, the initial three-dimensional map includes multiple faces, one face represents a scene view of the virtual scene in a viewing direction, and different faces correspond to different viewing directions.

[0064] S402: Acquire depth information of the virtual scene in each viewing direction, where any depth information includes: a depth value of each virtual object in the scene view in the corresponding viewing direction.

[0065] Since the scene views of the virtual scene in various viewing directions are obtained by capturing the camera, the computer device can collect the depth information of the virtual scene in various viewing directions based on the camera. In the process of executing step S402, the computer device can first traverse the various viewing directions involved in the full viewing angle of the virtual scene, and control the camera to face the currently traversed viewing direction to perform cone clipping on the virtual objects in the virtual scene. The so-called cone clipping refers to the process of determining whether the virtual object falls into (i.e., is located in) the cone of the camera. If any virtual object falls into the cone of the camera, then any virtual object is clipped by the cone. Otherwise, any virtual object is not clipped by the cone. Among them, the cone mentioned here refers to the cone space visible to the camera, which looks like a pyramid with the top cut off. As shown in Figure 5a, it is a schematic diagram of the cone of a camera provided in an embodiment of the present application, wherein the cone of the camera 501 is composed of a near clipping plane 502, a far clipping plane 503 and four cone planes 504. The near clipping plane 502 is a surface set to prevent the virtual object from being too close to the camera and being invisible. The far clipping plane 503 is a surface set to prevent the virtual object from being too far away from the camera and being invisible. The four viewing cone surfaces 504 are surfaces formed by four lines diverging from the camera 501 and tangent to the two clipping planes.

[0066] Then, a depth test can be performed on each virtual object clipped by the viewing frustum to obtain depth information of the virtual scene in the currently traversed viewing direction. The computer device can poll each virtual object clipped by the viewing frustum; calculate the distance value between the currently polled virtual object and the camera based on the position coordinates of the currently polled virtual object and the position coordinates of the camera; and add the calculated distance value as the depth value of the currently polled virtual object to the depth information of the virtual scene in the currently traversed viewing direction. The position coordinates of the virtual object and the camera mentioned here can be world space coordinates or the coordinates of the virtual object and the camera in the scene coordinate system of the virtual scene (i.e., a coordinate system established by a certain point in the virtual scene), without limitation. The computer device can also calculate the Euclidean distance based on the two position coordinates to obtain a distance value; that is, the computer device can calculate the Euclidean distance between the currently polled virtual object and the camera based on the position coordinates of the currently polled virtual object and the position coordinates of the camera to obtain the corresponding distance value.

[0067] That is to say, in the embodiment of the present application, it is possible to choose to use the spherical depth information obtained by depth testing all virtual objects in the virtual scene based on a certain camera, and then use the two-dimensional information map obtained after octahedron mapping as a representation of the full-view depth information of the virtual scene.

[0068] Here, a method for obtaining this two-dimensional information map is provided: First, a cube map of the scene's full-view depth information is constructed as follows. The X+ axis (i.e., the positive direction of the X axis) can be selected, and the current camera orientation is set to the X+ axis direction. Then, a frustum clipping operation is performed on all virtual objects in the entire scene in the camera direction. If a virtual object passes the frustum clipping, a depth test is performed on it. The depth map of all virtual objects within the frustum is recorded on the corresponding face of the X+ cube map. Finally, the above operations are performed sequentially for the remaining five directions (X-axis, Y+ axis, Y-axis, Z+ axis, and Z-axis). Finally, a cube map recording the full-view depth information of the virtual scene is obtained. After obtaining the cube map of the virtual scene's full-view depth information, an octahedral mapping operation can be performed on each pixel in the cube map to obtain a two-dimensional map recording the full-view depth information of the virtual scene.

[0069] It should be understood that when the camera is controlled to face the currently traversed viewing angle and the virtual objects in the virtual scene are clipped with the view frustum, if no virtual objects pass through the view frustum clipping, that is, all virtual objects do not fall into the camera's view frustum, then the depth information of the virtual scene in the currently traversed viewing angle is empty.

[0070] S403 : Record the depth values ​​in each piece of depth information obtained into the pixel points in the corresponding surface of the initial three-dimensional map to obtain the target three-dimensional map.

[0071] In an embodiment of the present application, a computer device may poll each viewing direction and traverse each depth value in the depth information under the currently polled viewing direction to determine the virtual object to which the currently traversed depth value belongs; search for the pixel corresponding to the determined virtual object in the surface corresponding to the currently polled viewing direction in the initial three-dimensional map; then store the currently traversed depth value in the found pixel, and continue traversing until all depth values ​​in the depth information under the currently polled viewing direction have been traversed. Then, the computer device continues to poll other viewing directions until all viewing directions have been polled and all depth values ​​in the depth information under each viewing direction have been traversed, thereby obtaining the target three-dimensional map.

[0072] S404: Map each pixel point in the target three-dimensional map to a two-dimensional blank map to obtain an information map of the virtual scene.

[0073] In an embodiment of the present application, an information map of the virtual scene is obtained by mapping each pixel point in the target three-dimensional map to a two-dimensional blank map, so as to record the full-view depth information of the virtual scene through the two-dimensional information map, so that when ray tracing is subsequently performed on the information map through steps S405 to S407, the entire ray tracing process can be completed on a two-dimensional image, thereby improving the efficiency of ray tracing.

[0074] In an embodiment of the present application, for any pixel in the target three-dimensional map, the position point corresponding to the pixel in the virtual scene can be determined, and then the position point is projected onto a two-dimensional blank map through an octahedral mapping operation to obtain the projection point corresponding to the position point, and the pixel is recorded at the projection point. The method of projecting the position point through the octahedral mapping operation is similar to the description of step S203 in the method embodiment shown in Figure 2, and will not be repeated here. In addition, the position point corresponding to any pixel in the virtual scene refers to: the position of the object represented by any pixel in the virtual scene; for example, if the object represented by any pixel is the eye of a virtual object, then the position point corresponding to any pixel in the virtual scene is the position of the eye of the virtual object. Exemplarily, the information map obtained by mapping each pixel in the target three-dimensional map can be shown in Figure 5b; it should be understood that the left figure in Figure 5b does not fully show the target three-dimensional map, and only exemplarily shows a portion of the surface of the target three-dimensional map.

[0075] S405 , in the virtual scene, generating tracing rays for ray tracing based on the reference point.

[0076] S406 : Projecting the tracing ray from the virtual scene to the information map to obtain a travel path of the tracing ray on the information map.

[0077] It should be noted that the implementation of steps S405 to S406 can refer to the implementation of steps S202 to S203 in the method embodiment shown in Figure 2 above, and will not be repeated here. In addition, the embodiment of the present application does not limit the execution order of steps S405 and steps S401 to S404. In other words, the computer device may first execute steps S401 to S404, and then execute step S405; or, execute step S405 first, and then execute steps S401 to S404; or, the computer device may also execute steps S401 to S404 and step S405 simultaneously, etc.

[0078] S407: Perform ray tracing along the travel path on the information map to obtain a ray tracing result.

[0079] In one implementation of step S407, the computer device may perform the following steps: first, select a pixel point on the travel path as the current step point. Then, search the information map for the depth value stored at the current step point and use this depth value as the reference depth value for the current step point. Then, map the current step point to the virtual scene to obtain a mapping point, and determine the true depth value of the current step point based on the position of the mapping point in the virtual scene. Finally, generate a ray tracing result based on the reference depth value of the current step point and the true depth value of the current step point.

[0080] In an embodiment of the present application, when selecting a pixel point on a travel path as a current step point, the computer device may first determine multiple step points on the information map according to a preset step length, thereby determining the current step point by selecting the step point, where the step length refers to the distance between two adjacent landing points during travel. In this case, the implementation method for selecting a pixel point on the travel path as the current step point may be: dividing the travel path into multiple tracking segments according to the preset step length, and marking the end point of each tracking segment as a step point; stepping to each of the marked step points in turn, and determining the step point currently stepped to as the current step point. For example, see FIG5c: assuming that the travel path is divided into three tracking segments (segments represented by dotted lines in FIG5c) according to the preset step length: segment SA, segment AB, and segment BE; then, a five-pointed star pattern may be used to mark the end point A of segment SA, the end point B of segment AB, and the end point E of segment BE as step points. This implementation method can improve the efficiency of stepping by first determining multiple step points and then performing the stepping operation, thereby improving the efficiency of selecting the current step point.

[0081] Alternatively, the computer device can directly step on the information map to determine the current step point in real time. In this case, a pixel point on the path can be selected as the current step point by first determining the step length corresponding to the step operation to be executed, performing a step operation on the path according to the determined step length, and determining the pixel point reached after the step operation as the current step point. This eliminates the need to determine multiple step points in advance, thus saving processing resources. By determining the current step point in real time, this embodiment eliminates the need to pre-identify each step point, thus saving processing resources. It should be noted that in this embodiment, the step lengths corresponding to step operations executed at different times can be the same or different, and this is not limited to this. For example, each time the computer device executes a step operation, it can obtain a preset step length as the step length corresponding to the current step operation. In this case, the step lengths of step operations executed at different times are the same. Alternatively, the computer device can randomly generate a step length. In this case, the step lengths of step operations executed at different times can be different, thereby increasing the diversity and authenticity of the step process.

[0082] When mapping the current step point to the virtual scene to obtain the mapping point, and determining the true depth value of the current step point based on the position of the mapping point in the virtual scene, the computer device can first reversely map the current step point to the octahedron according to the principle of the octahedron mapping operation mentioned above, then map it to the sphere centered on the camera, and finally map it to the virtual scene to obtain the mapping point; then, when determining the true depth value of the current step point based on the position of the mapping point in the virtual scene, the computer device can calculate the distance value between the mapping point and the camera based on the position of the mapping point in the virtual scene and the position of the camera in the virtual scene; and determine the calculated distance value as the true depth value of the current step point.

[0083] When generating a ray tracing result based on the reference depth value of the current step point and the real depth value of the current step point, the computer device can determine whether the reference depth value of the current step point is greater than or equal to the real depth value of the current step point. If the reference depth value of the current step point is greater than or equal to the real depth value of the current step point, it indicates that there is a virtual object at the mapping point corresponding to the current step point in the virtual space, so the stepping can be ended at this time, and a ray tracing result indicating that the light hits a valid surface is generated. If the reference depth value of the current step point is less than the real depth value of the current step point, it indicates that there is no virtual object at the mapping point corresponding to the current step point in the virtual space, so the stepping can continue until it steps to a specified pixel point, and a ray tracing result indicating that the light did not hit a valid surface is generated. The specified pixel point mentioned here can be a pre-set pixel point, or it can be a pixel point that is a target distance away from the starting point of the tracing path. The target distance can be randomly generated or pre-set, and there is no limitation on this.

[0084] Alternatively, the computer device may calculate the difference between the reference depth value at the current step point and the actual depth value at the current step point, and determine whether the calculated difference is less than or equal to a difference threshold. If the calculated difference is less than or equal to the difference threshold, stepping is terminated and a ray tracing result is generated indicating that the ray hits a valid surface. If the calculated difference is greater than the difference threshold, stepping is continued until a specified pixel is reached, and a ray tracing result is generated indicating that the ray did not hit a valid surface.

[0085] In another implementation of step S407, the computer device may perform the following steps: first, select a pixel point on the travel path as the current step point. Furthermore, search the information map for the depth value stored at the current step point as the reference depth value of the current step point. Then, determine whether the reference depth value of the current step point is a valid value. Finally, if the reference depth value of the current step point is a valid value (i.e., a value not zero), then stepping is terminated, and a ray tracing result is generated to indicate that the ray hits a valid surface. If the reference depth value of the current step point is an invalid value (i.e., a zero value), then stepping is continued until the specified pixel point is reached, and a ray tracing result is generated to indicate that the ray did not hit a valid surface. It should be understood that this implementation may be performed when the camera is not located at the position of each virtual object in the virtual scene; and the implementation method of selecting a pixel point on the travel path as the current step point can be found in the above description and will not be repeated here.

[0086] The embodiment of the present application obtains an information map that records the full-view depth information of the virtual scene, and projects the tracing rays used for ray tracing in the virtual scene from the virtual scene to the information map, thereby obtaining the travel path of the tracing rays on the information map, and then tracing the rays along the travel path on the information map. This method can solve the limitation of traditional ray tracing methods that cannot perform effective ray tracing outside the screen space due to the lack of depth information outside the screen space. In other words, the embodiment of the present application can extend ray tracing to outside the screen by performing ray tracing on the information map that records the full-view depth information, which can greatly increase the probability of light hitting the effective surface, thereby improving the accuracy of ray tracing. Moreover, since the information map can be a two-dimensional map, it can be seen that the entire ray tracing process of the embodiment of the present application can be completed on a two-dimensional map, which can greatly improve the efficiency of ray tracing.

[0087] In practical applications, the ray tracing method shown in Figures 2 and 4 can be applied to various virtual scenes, such as game scenes, scenes in film and television dramas, etc. For example, taking the virtual scene as a game scene as an example, the application process of the ray tracing method may include the following two parts:

[0088] The first part is to represent the full-view depth information of the game scene. This part can use the spherical depth information obtained by performing a depth test on all virtual objects in the game scene based on a certain camera point, and then use the octahedron mapping to obtain a 2D information map as the representation of the full-view depth information of the game scene. Among them, one method of obtaining the 2D information map can be as follows:

[0089] First, the target cube map (i.e., target three-dimensional map) of the scene's full-view depth information can be constructed through the following steps: first, select the X+ axis and set the camera's current orientation to the X+ axis direction; then, control the camera to perform frustum clipping on all virtual objects in the game scene in the current orientation; if the virtual object passes the frustum clipping, perform a depth test on it, so that the depth values ​​obtained after the depth test of all virtual objects in the frustum are recorded on the surface corresponding to the X+ axis in the initial cube map (i.e., initial three-dimensional map); and, perform the above operations on the remaining five viewing directions (X-axis, Y+ axis, Y-axis, Z+ axis, Z-axis) in sequence, and finally obtain a target cube map that records the full-scene depth information of the game scene.

[0090] After obtaining the target Cube map that records the full-view depth information of the game scene, an octahedron mapping operation can be performed on each pixel on the target Cube map to obtain a 2D information map that records the full-view depth information of the game scene.

[0091] The second part is ray tracing based on full-view depth information. In this part, the path of light in the 3D Cartesian coordinate system can be reprojected onto a 2D information map using an octahedron mapping algorithm. This allows ray tracing to be performed across the entire viewing angle (both inside and outside the screen) on a single 2D information map. Exemplarily, an implementation method of this part can be as follows: first, based on the position of the virtual object that has ray tracing requirements in the game scene, a tracing ray is generated, and a maximum tracing path is set for the tracing ray; then, the tracing ray is projected onto a two-dimensional information map to obtain a maximum of four continuous line segments, which constitute the travel path of the tracing ray on the information map; then, the travel path is divided into a number of tracing line segments in sequence according to a preset step size, and corresponding step points are obtained; finally, each step point is stepped into in sequence, and the reference depth value of the current step point on the information map of the current step is compared with the real depth value of the current step point in the game scene. If the reference depth value of the current step point is greater than or equal to the real depth value, the step is returned to success, and a ray tracing result is generated to indicate that the ray hits the valid surface; if the reference depth value of the current step point is less than the real depth value, the step is continued until the maximum tracing path is reached, and the step is returned to failure, and a ray tracing result is generated to indicate that the ray does not hit the valid surface.

[0092] The embodiment of the present application is based on a segmented ray tracing method based on an information map that records full-view depth information obtained after octahedral mapping. Compared with the traditional screen-space ray tracing method, the ray tracing can be extended outside the screen, thereby greatly increasing the hit probability of the ray and significantly improving the accuracy of the ray tracing. In this way, a more accurate ray tracing result can be obtained, so that the game screen rendered based on the ray tracing result is more realistic. For example, when the ray tracing result is used to indicate that the ray successfully hits the valid surface, the game screen can more realistically present the refraction and reflection effects of the light. At the same time, all ray tracing processes are completed on a two-dimensional information map, which can greatly improve the efficiency of tracing. This can shorten the time required for ray tracing, thereby shortening the rendering time of the game screen, avoiding the phenomenon of game screen freezes, and improving the smoothness and stability of game operation.

[0093] Based on the description of the above-mentioned ray tracing method embodiment, the embodiment of the present application further discloses a ray tracing device; the ray tracing device can be a computer program (including program code) running on a computer device, and the ray tracing device can execute each step in the method flow shown in Figure 2 or Figure 4. Referring to Figure 6, the ray tracing device 600 can run the following units: an acquisition unit 601, configured to acquire an information map of a virtual scene, wherein the information map records the full-view depth information of the virtual scene, and the full-view depth information includes the depth value of each virtual object in the virtual scene; a processing unit 602, configured to generate a tracing ray for ray tracing based on a reference point in the virtual scene; the reference point is the position of the virtual object for which ray tracing is required in the virtual scene; the processing unit 602 is further configured to project the tracing ray from the virtual scene to the information map to obtain a path of the tracing ray on the information map; the processing unit 602 is further configured to perform ray tracing along the path on the information map to obtain a ray tracing result.

[0094] In some embodiments, each pixel stores a depth value, and a preset correspondence exists between a virtual object in the virtual scene and at least one pixel in the information map; the processing unit 602 is further configured to: select a pixel on the travel path as a current step point; determine the depth value stored in the current step point found in the information map as a reference depth value of the current step point; map the current step point to the virtual scene to obtain a mapping point, and determine the true depth value of the current step point according to the position of the mapping point in the virtual scene; and generate a ray tracing result according to the reference depth value of the current step point and the true depth value of the current step point.

[0095] In some embodiments, the virtual scene also includes a camera, and the depth value of any virtual object refers to the distance value between the corresponding virtual object and the camera; the processing unit 602 is further configured to: determine the distance value between the mapping point and the camera based on the position of the mapping point in the virtual scene and the position of the camera in the virtual scene; and determine the distance value between the mapping point and the camera as the true depth value of the current step point.

[0096] In some embodiments, the processing unit 602 is further configured to: if the reference depth value of the current step point is greater than or equal to the real depth value of the current step point, end the stepping and generate a ray tracing result indicating that the light hits a valid surface, where the valid surface refers to the surface of any virtual object; if the reference depth value of the current step point is less than the real depth value of the current step point, continue stepping until stepping to a specified pixel point, and generate a ray tracing result indicating that the light did not hit a valid surface.

[0097] In some embodiments, the processing unit 602 is further configured to: calculate the difference between the reference depth value and the true depth value; if the difference is less than or equal to a difference threshold, end the stepping and generate a ray tracing result indicating that the light hits a valid surface, where the valid surface refers to the surface of any virtual object; if the difference is greater than the difference threshold, continue stepping until stepping to a specified pixel point, and generate a ray tracing result indicating that the light does not hit a valid surface.

[0098] In some embodiments, the information map includes multiple pixels, each pixel stores a depth value, and a virtual object in the virtual scene has a preset correspondence with at least one pixel in the information map; the processing unit 602 is further configured to: select a pixel on the travel path as the current step point; determine the depth value stored in the current step point found in the information map as the reference depth value of the current step point; if the reference depth value of the current step point is a valid value, end the stepping, and generate a ray tracing result indicating that the light hits a valid surface, the valid surface refers to the surface of any virtual object; if the reference depth value of the current step point is an invalid value, continue stepping until stepping to a specified pixel point, and generate a ray tracing result indicating that the light did not hit a valid surface.

[0099] In some embodiments, the processing unit 602 is further configured to: determine the step length corresponding to the step operation currently to be performed; perform a step operation on the travel path according to the step length, and determine the pixel point reached after performing the step operation as the current step point.

[0100] In some embodiments, the processing unit 602 is further configured to: divide the travel path into multiple tracking line segments according to a preset step length, and identify the end point of each tracking line segment as a step point; step to each identified step point in turn, and determine the step point currently stepped to as the current step point.

[0101] In some embodiments, the full perspective of the virtual scene includes perspectives under multiple viewing directions; the acquisition unit 601 is further configured to: obtain an initial three-dimensional map of the virtual scene, the initial three-dimensional map includes multiple faces, one face represents a scene view of the virtual scene under a viewing direction, and different faces correspond to different viewing directions; obtain depth information of the virtual scene under each viewing direction, the depth information under any viewing direction includes: the depth value of each virtual object in the scene view under the corresponding viewing direction; record the depth value in each depth information obtained into the pixel point in the corresponding face of the initial three-dimensional map to obtain a target three-dimensional map; map each pixel point in the target three-dimensional map to a two-dimensional blank map to obtain an information map of the virtual scene.

[0102] In some embodiments, the scene views of the virtual scene in various viewing directions are obtained by shooting with a camera; the acquisition unit 601 is further configured to: traverse various viewing directions involved in the full viewing angle of the virtual scene; control the camera to face the currently traversed viewing direction, and perform a viewing cone cropping on the virtual objects in the virtual scene; wherein, if any virtual object falls into the viewing cone of the camera, it is determined that the corresponding virtual object passes through the viewing cone cropping; perform a depth test on each virtual object cropped through the viewing cone to obtain the depth information of the virtual scene in the currently traversed viewing direction.

[0103] In some embodiments, the acquisition unit 601 is further configured to: poll each virtual object clipped by the viewing cone; calculate the distance value between the currently polled virtual object and the camera based on the position coordinates of the currently polled virtual object and the position coordinates of the camera; and use the calculated distance value as the depth value of the currently polled virtual object, and add it to the depth information of the virtual scene in the currently traversed viewing direction.

[0104] In some embodiments, the acquisition unit 601 is further configured to: generate multiple discrete surface elements in the virtual scene, where the discrete surface elements are planar figures with direction and size, and each virtual object in the virtual scene has at least one discrete surface element attached to its surface; obtain the distance value between each discrete surface element and the camera in the virtual scene, and determine the distance value as the depth value of the corresponding discrete surface element in the virtual scene; and use the depth value of each discrete surface element in the virtual scene to construct an information map of the virtual scene.

[0105] In some embodiments, the processing unit 602 is further configured to: project the starting point of the tracing ray to the information map through an octahedron mapping operation to obtain a first projection point; determine the three-dimensional space coordinate system corresponding to the virtual scene; project the intersection between the tracing ray and at least one axial plane in the three-dimensional space coordinate system to the information map through an octahedron mapping operation to obtain at least one second projection point; determine the path end point on the tracing ray according to a preset tracing path threshold; project the path end point to the information map through an octahedron mapping operation to obtain a third projection point; and sequentially connect the first projection point, the at least one second projection point, and the third projection point to obtain the travel path of the tracing ray on the information map.

[0106] According to another embodiment of the present application, the various units in the ray tracing device shown in Figure 6 can be individually or all combined into one or several other units to form, or one (or some) of the units can be further divided into multiple functionally smaller units to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above-mentioned units are divided based on logical functions. In actual applications, the functions of one unit can also be implemented by multiple units, or the functions of multiple units can be implemented by one unit. In other embodiments of the present application, other units can also be included based on the ray tracing device. In actual applications, these functions can also be implemented with the assistance of other units, and can be implemented by the collaboration of multiple units.

[0107] According to another embodiment of the present application, a ray tracing device as shown in FIG6 can be constructed, and the ray tracing method of the embodiment of the present application can be implemented by running a computer program (including program code) capable of executing the steps involved in the corresponding method as shown in FIG2 or FIG4 on a general-purpose computing device such as a computer, which includes a central processing unit (CPU), a random access memory (RAM), a read-only memory (ROM), and other processing elements and storage elements. The computer program can be recorded on a computer storage medium, for example, and loaded into the above-mentioned computing device through the computer storage medium and run therein.

[0108] The embodiment of the present application obtains an information map that records the full-view depth information of the virtual scene, and projects the tracing rays used for ray tracing in the virtual scene from the virtual scene to the information map, thereby obtaining the travel path of the tracing rays on the information map, and then tracing the rays along the travel path on the information map. This method can solve the limitation of traditional ray tracing methods that cannot perform effective ray tracing outside the screen space due to the lack of depth information outside the screen space. In other words, the embodiment of the present application can extend ray tracing to outside the screen by performing ray tracing on the information map that records the full-view depth information. This can greatly increase the probability of light hitting the effective surface, thereby improving the accuracy of ray tracing, and significantly improving the global illumination effect achieved based on the ray tracing results. In addition, since the information map can be a two-dimensional map, it can be seen that the entire ray tracing process of the embodiment of the present application can be completed on a two-dimensional map, which can greatly improve the efficiency of ray tracing.

[0109] Based on the description of the above method embodiment and the device embodiment, the embodiment of the present application also provides a computer device. Referring to Figure 7, the computer device 700 includes at least a processor 701, an input interface 702, an output interface 703 and a computer storage medium 704. Among them, the processor 701, the input interface 702, the output interface 703 and the computer storage medium 704 in the computer device can be connected by a bus or other means. The computer storage medium 704 can be stored in the memory of the computer device, and the computer storage medium 704 is used to store a computer program, and the computer program includes program instructions (such as program instructions 1 to program instructions n as shown in Figure 7), and the processor 701 is used to execute the program instructions stored in the computer storage medium 704. The processor 701 (or CPU) is the computing core and control core of the computer device, which is suitable for implementing one or more instructions, such as being suitable for loading and executing one or more instructions to realize the corresponding method flow or corresponding function.

[0110] In one embodiment, the processor 701 described in the embodiment of the present application can be used to perform a series of ray tracing processes, including: obtaining an information map of a virtual scene, wherein the information map records the full-view depth information of the virtual scene, and the full-view depth information includes the depth value of each virtual object in the virtual scene; in the virtual scene, generating tracing rays for ray tracing based on a reference point; the reference point is the position of the virtual object for which ray tracing is required in the virtual scene; projecting the tracing rays from the virtual scene to the information map to obtain the travel path of the tracing rays on the information map; performing ray tracing along the travel path on the information map to obtain ray tracing results, and so on.

[0111] The embodiment of the present application also provides a computer storage medium (Memory), which is a memory device in a computer device for storing programs and data. It is understandable that the computer storage medium here can include both built-in storage media in the computer device and, of course, extended storage media supported by the computer device. The computer storage medium provides a storage space that stores the operating system of the computer device. In addition, one or more instructions suitable for being loaded and executed by the processor 701 are also stored in the storage space. These instructions can be one or more computer programs (including program codes). It should be noted that the computer storage medium here can be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk storage; of course, it can also be at least one computer storage medium located away from the aforementioned processor.

[0112] In one embodiment, one or more instructions stored in a computer storage medium may be loaded and executed by a processor to implement the corresponding steps in the above-mentioned method embodiment shown in Figure 2 or Figure 4; during the implementation process, one or more instructions in the computer storage medium may be loaded by the processor and execute the following steps: obtaining an information map of a virtual scene, wherein the information map records the full-view depth information of the virtual scene, and the full-view depth information includes the depth value of each virtual object in the virtual scene; in the virtual scene, generating a tracing ray for ray tracing based on a reference point; the reference point is the position of a virtual object for which ray tracing is required in the virtual scene; projecting the tracing ray from the virtual scene to the information map to obtain a travel path of the tracing ray on the information map; performing ray tracing along the travel path on the information map to obtain a ray tracing result.

[0113] It should be noted that, according to one aspect of the present application, a computer program product is also provided, which includes a computer program, and the computer program is stored in a computer storage medium. The processor of the computer device reads the computer program from the computer storage medium, and the processor executes the computer program, so that the computer device performs the methods provided in the various optional embodiments of the method embodiments shown in Figures 2 or 4 above. It should be understood that the above disclosure is only a preferred embodiment of the present application, and of course it cannot be used to limit the scope of the rights of the present application. Therefore, equivalent changes made in accordance with the claims of the present application are still within the scope covered by the present application.

Claims

1. A ray tracing method, the method being performed by a computer device, include: Acquire an information map of a virtual scene, wherein the information map records full-view depth information of the virtual scene, and the full-view depth information includes depth values ​​of each virtual object in the virtual scene; In the virtual scene, a tracing ray for ray tracing is generated based on a reference point; the reference point is a position of a virtual object for which ray tracing is required in the virtual scene; Projecting the tracing ray from the virtual scene to the information map to obtain a travel path of the tracing ray on the information map; On the information map, ray tracing is performed along the travel path to obtain a ray tracing result.

2. The method according to claim 1, in, The information map includes a plurality of pixels, each pixel stores a depth value, and a virtual object in the virtual scene has a preset corresponding relationship with at least one pixel in the information map; The step of performing ray tracing along the travel path on the information map to obtain a ray tracing result includes: Selecting a pixel point on the travel path as a current step point; Determine the depth value stored at the current step point found in the information map as the reference depth value of the current step point; Mapping the current step point to the virtual scene to obtain a mapping point, and determining a real depth value of the current step point according to a position of the mapping point in the virtual scene; A ray tracing result is generated according to the reference depth value of the current step point and the real depth value of the current step point.

3. The method according to claim 2, in, The virtual scene also includes a camera, and the depth value of any virtual object refers to the distance value between the corresponding virtual object and the camera; The determining the real depth value of the current step point according to the position of the mapping point in the virtual scene comprises: Determine a distance value between the mapping point and the camera according to the position of the mapping point in the virtual scene and the position of the camera in the virtual scene; The distance value between the mapping point and the camera is determined as the real depth value of the current step point.

4. The method according to claim 2 or 3, in, The generating a ray tracing result according to the reference depth value of the current step point and the real depth value of the current step point comprises: If the reference depth value of the current step point is greater than or equal to the real depth value of the current step point, then the stepping is ended, and a ray tracing result indicating that the ray hits a valid surface is generated, where the valid surface refers to a surface of any virtual object; If the reference depth value of the current step point is less than the real depth value of the current step point, the stepping is continued until the designated pixel point is reached, and a ray tracing result indicating that the ray does not hit a valid surface is generated.

5. The method according to any one of claims 2 to 4, in, The generating a ray tracing result according to the reference depth value of the current step point and the real depth value of the current step point comprises: Calculating a difference between the reference depth value and the true depth value; If the difference is less than or equal to the difference threshold, then the stepping is terminated, and a ray tracing result indicating that the ray hits a valid surface is generated, where the valid surface refers to a surface of any virtual object; If the difference is greater than the difference threshold, continue stepping until stepping to a specified pixel point, and generate a ray tracing result indicating that the ray does not hit a valid surface.

6. The method according to claim 1, in, The information map includes a plurality of pixels, each pixel stores a depth value, and a virtual object in the virtual scene has a preset corresponding relationship with at least one pixel in the information map; The step of performing ray tracing along the travel path on the information map to obtain a ray tracing result includes: Selecting a pixel point on the travel path as a current step point; Determine the depth value stored at the current step point found in the information map as the reference depth value of the current step point; If the reference depth value of the current step point is a valid value, then the stepping is ended, and a ray tracing result indicating that the ray hits a valid surface is generated, where the valid surface refers to a surface of any virtual object; If the reference depth value of the current step point is an invalid value, the stepping continues until the designated pixel point is reached, and a ray tracing result indicating that the ray has not hit a valid surface is generated.

7. The method according to claim 2 or 6, in, The selecting a pixel point on the travel path as the current step point comprises: Determine the step length corresponding to the current step operation to be executed; A stepping operation is performed on the travel path according to the step length, and a pixel point reached after the stepping operation is performed is determined as the current stepping point.

8. The method according to claim 2 or 6, in, The selecting a pixel point on the travel path as the current step point comprises: Dividing the travel path into a plurality of tracking line segments according to a preset step length, and marking the end point of each tracking line segment as a step point; Step to each of the identified step points in sequence, and determine the step point currently stepped to as the current step point.

9. The method according to any one of claims 1 to 8, in, The full viewing angle of the virtual scene includes viewing angles in multiple viewing directions; The step of obtaining the information map of the virtual scene includes: Acquire an initial three-dimensional texture of a virtual scene, wherein the initial three-dimensional texture includes a plurality of faces, wherein one face represents a scene view of the virtual scene in a viewing direction, and different faces correspond to different viewing directions; Acquire depth information of the virtual scene in each viewing direction, where the depth information in any viewing direction includes: depth values ​​of each virtual object in the scene view in the corresponding viewing direction; Recording the depth values ​​in each piece of depth information obtained into the pixel points in the corresponding surface of the initial three-dimensional map to obtain a target three-dimensional map; Each pixel point in the target three-dimensional map is mapped to a two-dimensional blank map to obtain an information map of the virtual scene.

10. The method according to claim 9, in, The scene views of the virtual scene in each viewing direction are obtained by shooting with a camera; and the obtaining of depth information of the virtual scene in each viewing direction includes: Traversing each viewing direction involved in the full viewing angle of the virtual scene; Controlling the camera to face the currently traversed viewing angle direction, and performing frustum clipping on virtual objects in the virtual scene; wherein, if any virtual object falls into the frustum of the camera, it is determined that the corresponding virtual object passes the frustum clipping; A depth test is performed on each virtual object clipped by the viewing cone to obtain depth information of the virtual scene in the current traversal viewing direction.

11. The method according to claim 10, in, The performing of a depth test on each virtual object clipped by the viewing cone to obtain depth information of the virtual scene in the current traversal viewing direction includes: Poll each virtual object clipped by the view frustum; Calculate the distance between the virtual object currently being polled and the camera according to the position coordinates of the virtual object currently being polled and the position coordinates of the camera; The calculated distance value is used as the depth value of the currently polled virtual object, and is added to the depth information of the virtual scene in the currently traversed viewing direction.

12. The method according to any one of claims 1 to 11, in, The step of obtaining the information map of the virtual scene includes: Generate a plurality of discrete surface elements in a virtual scene, wherein the discrete surface element is a plane figure having a direction and a size, and at least one discrete surface element is attached to the surface of each virtual object in the virtual scene; Acquire a distance value between each discrete surface element and a camera in the virtual scene, and determine the distance value as a depth value of the corresponding discrete surface element in the virtual scene; The information map of the virtual scene is constructed by using the depth values ​​of the discrete surface elements in the virtual scene.

13. The method according to any one of claims 1 to 12, in, The step of projecting the tracing ray from the virtual scene to the information map to obtain a path of the tracing ray on the information map includes: Projecting the starting point of the tracing ray onto the information map through an octahedral mapping operation to obtain a first projection point; Determining a three-dimensional space coordinate system corresponding to the virtual scene; Projecting the intersection point between the tracing ray and at least one axial plane in the three-dimensional space coordinate system onto the information map through the octahedral mapping operation to obtain at least one second projection point; Determining a path termination point on the tracing ray according to a preset tracing path threshold; Projecting the path termination point onto the information map through the octahedral mapping operation to obtain a third projection point; The first projection point, the at least one second projection point and the third projection point are sequentially connected to obtain a path of the tracing ray on the information map.

14. A ray tracing device, include: An acquisition unit is configured to acquire an information map of a virtual scene, wherein the information map records full-view depth information of the virtual scene, and the full-view depth information includes depth values ​​of each virtual object in the virtual scene; A processing unit configured to generate a tracing ray for ray tracing based on a reference point in the virtual scene; the reference point is a position of a virtual object for which ray tracing is required in the virtual scene; The processing unit is further configured to project the tracing ray from the virtual scene to the information map to obtain a travel path of the tracing ray on the information map; The processing unit is further configured to perform ray tracing along the travel path on the information map to obtain a ray tracing result.

15. A computer device comprising an input interface, an output interface, a processor and a computer storage medium; in, The processor is suitable for implementing one or more instructions, and the computer storage medium stores one or more instructions, and the one or more instructions are suitable for being loaded by the processor and executing the ray tracing method according to any one of claims 1 to 13.

16. A computer storage medium storing one or more instructions, wherein the one or more instructions are suitable for being loaded by a processor and executing the ray tracing method according to any one of claims 1 to 13.

17. A computer program product, the computer program product comprising a computer program, the computer program being stored in a computer storage medium; When a processor of a computer device reads the computer program from the computer storage medium and executes the computer program, the ray tracing method according to any one of claims 1 to 13 is implemented.