Method and apparatus for rendering scene on basis of ray tracing
By comprehensively considering the occlusion point set of multiple shading points and optimizing the calculation process in ray tracing rendering, the problem of insufficient rendering performance on mobile devices is solved, achieving high-quality and efficient rendering effects to meet the needs of different users.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- HUAWEI TECH CO LTD
- Filing Date
- 2025-11-05
- Publication Date
- 2026-07-30
AI Technical Summary
Ray tracing rendering is computationally intensive on mobile devices, and the number of intersection calculations is limited, resulting in insufficient rendering performance and difficulty in achieving real-time, high-quality rendering effects.
By determining the first set of occlusion points in the scene data and comprehensively considering the occlusion point sets of other shading points, the ray tracing rendering method is optimized, the environmental awareness of each shading point is improved, shared storage units and mapping relationships are used to optimize the calculation, and ray tracing is used to accelerate the structure and occlusion relationship-assisted structure optimization rendering process.
Without increasing computational overhead, it significantly improves the quality and realism of rendered images, provides flexible rendering settings to adapt to different needs and scenarios, and improves computational efficiency and stability.
Smart Images

Figure CN2025132626_30072026_PF_FP_ABST
Abstract
Description
Methods and apparatus for rendering scenes based on ray tracing
[0001] This application claims priority to Chinese Patent Application No. 202510125169.8, filed on January 24, 2025, entitled “Method and Apparatus for Rendering Scenes Based on Ray Tracing”, the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of media technology, and in particular to methods and apparatus for rendering scenes based on ray tracing. Background Technology
[0003] Ray tracing is an advanced technique originating from geometric optics. By simulating the interaction between light and the surface of an object, and based on the material properties of the object's surface, it calculates specular reflection, diffuse reflection, or refraction according to the laws of physics, enabling precise tracking of the path of light. This allows it to realistically simulate the imaging process of objects in the real world as seen by a camera or human eye, thus producing rendering effects that approach "photorealistic" quality.
[0004] Ray tracing technology obtains environmental information about shaded points by emitting rays and calculating their intersections with the scene, and then calculates the lighting effects for those points. However, intersection calculation in ray tracing is a computationally intensive process, and the number of intersection calculations is one of the key metrics for measuring ray tracing performance overhead. Especially on mobile devices, due to physical limitations such as size and power consumption, their ray tracing capabilities are less than those of desktop devices. To achieve real-time ray tracing effects, the number of intersection calculations that can be performed in each rendering process is strictly limited. Summary of the Invention
[0005] This application provides a method and apparatus for rendering scenes based on ray tracing, used to improve the quality of rendered images. To achieve the above objective, this application adopts the following technical solution:
[0006] In a first aspect, embodiments of this application provide a method for rendering a scene based on ray tracing. The method includes: determining a first set of occlusion points corresponding to a first shading point in scene data; obtaining a second set of occlusion points; and shading the first shading point according to the second set of occlusion points and the scene data. The second set of occlusion points includes the first set of occlusion points and occlusion points corresponding to one or more shading points in the scene other than the first shading point.
[0007] This application proposes a ray tracing-based scene rendering scheme. When processing each shading point, not only are its own occlusion points considered, but also the occlusion points of other shading points in the same scene. This comprehensive consideration significantly improves each shading point's perception of its surrounding environment without increasing the computational overhead of intersection calculations. This enhanced perception significantly improves the quality of the rendered image, resulting in a richer and more realistic visual experience for the user.
[0008] In some implementations, the above methods are encapsulated as a first application programming interface (API) for ray tracing rendering.
[0009] In real-world rendering scenarios, users typically have specific requirements for the quality and accuracy of the rendered images. To meet these requirements, this application proposes a rendering method that can be encapsulated in an application programming interface (API). In this way, users can decide whether to enable the rendering method provided by this application based on their specific needs. If users wish to improve the quality of the rendered images and enhance visual effects, they can choose to enable the rendering method provided by this application. Conversely, if users prioritize the accuracy of the rendered images and wish to maintain the accuracy and realism of the images, they can choose not to enable the rendering method provided by this application. This design allows users to flexibly adjust rendering settings when using the application to achieve the best visual experience.
[0010] In some implementations, the second set of occlusion points is obtained based on a first identifier, which is used to indicate whether the second set of occlusion points is obtained.
[0011] In some implementations, the first application programming interface described above includes the first identifier.
[0012] Understandably, using the second set of occluded points to color the shading points significantly improves the quality of the rendered image, resulting in a more delicate and realistic visual effect. To enhance the flexibility of the solution, a first flag can be set in the application programming interface of this method. This flag allows users to choose whether to use the second set of occluded points for rendering based on their needs and preferences. In this way, users can flexibly adjust the rendering settings to achieve their desired visual effects, whether pursuing ultimate image quality or ensuring rendering accuracy.
[0013] In some implementations, a second set of occlusion points is obtained based on a second identifier, wherein the second identifier is used to indicate sharing mode information, and the sharing mode information includes one or more mode information.
[0014] In some implementations, the first application programming interface described above includes the second identifier.
[0015] Understandably, different sharing modes have their own focuses, designed with different needs and scenarios in mind. For example, some sharing modes may prioritize improving the quality of rendered images, aiming to provide users with a more detailed and realistic visual experience. Others may emphasize ease of use and implementation, making it easier for applications to integrate and use these rendering technologies. Therefore, when designing the application programming interface (API) for rendering methods, a second identifier can be considered. This identifier allows users to choose the sharing mode that best suits their needs and preferences. In this way, users can flexibly adjust rendering settings and choose the most suitable rendering strategy based on different use cases and goals. This not only provides users with a more personalized rendering experience but also ensures that while pursuing high-quality rendering effects, ease of use and efficiency are not sacrificed too much.
[0016] In some implementations, the information about the occlusion point includes at least one of the following: the location of the occlusion point, the normal direction, or the sampling probability.
[0017] Understandably, the rendering process involves the use of various data, including the location information of occluded points, normal directions, and sampling probabilities. Therefore, in a rendered scene, when the same occluded point is used to shade multiple shading points, it is essential to ensure that these shading points can share access to critical data such as the occluded point's location, normal direction, and sampling probabilities. This ensures that each shading point can correctly utilize this information for shading, guaranteeing the consistency and accuracy of the rendering results.
[0018] In some implementations, the above method further includes: obtaining occlusion points corresponding to one or more color points other than the first color point based on the first pixel point corresponding to the first color point.
[0019] In some implementations, obtaining the occlusion point corresponding to one or more color points other than the first color point based on the first pixel point corresponding to the first color point specifically includes: determining the color points corresponding to one or more second pixels within a preset range from the first pixel point based on the first pixel point; and obtaining the occlusion point corresponding to the determined color point.
[0020] By pre-setting the sharing range, the computational complexity of obtaining occlusion points corresponding to one or more occluded points other than the first occluded point can be significantly reduced, thereby improving overall computational efficiency. This method optimizes the computation process, avoiding repetitive and unnecessary computational steps, enabling faster and more efficient achievement of expected results when processing large amounts of data.
[0021] In some implementations, obtaining the occlusion point corresponding to one or more color points other than the first color point based on the first pixel point corresponding to the first color point specifically includes: obtaining the occlusion point corresponding to one or more color points other than the first color point based on the first pixel point and the mapping relationship, wherein the mapping relationship is used to characterize the mapping relationship between the first pixel point and the pixel points corresponding to one or more color points other than the first color point.
[0022] Understandably, by introducing mapping relationships, the computational complexity required to obtain the occlusion points corresponding to one or more shading points other than the first shading point can be further reduced. This is because the mapping relationships are pre-established, and can be directly used to quickly find the shading points of other pixels associated with the first pixel and their corresponding occlusion points. This method not only improves computational efficiency but also optimizes resource utilization, enabling high performance and stability when handling complex scenes and large amounts of data. Furthermore, the introduction of mapping relationships makes the algorithm more flexible and scalable, adapting to changes in different scenarios and requirements.
[0023] In some implementations, the mapping relationship includes the grouping information of the first pixel, and the first pixel and the pixels corresponding to one or more color points other than the first color point are in the same group. Obtaining the occlusion point corresponding to one or more color points other than the first color point according to the first pixel and the mapping relationship specifically includes: obtaining the occlusion point corresponding to one or more color points other than the first color point according to the first pixel and the grouping information.
[0024] Introducing grouping information significantly reduces the computational complexity required to obtain the occlusion points corresponding to one or more occluded points other than the first occluded point. This is because grouping information categorizes pixels with similar characteristics together, allowing for the rapid identification of other occluded points associated with the first pixel. This approach not only improves computational efficiency but also optimizes resource utilization, maintaining high performance and stability when handling complex scenes and large amounts of data. Furthermore, the introduction of grouping information makes the algorithm more flexible and scalable, adapting to changes in different scenarios and requirements.
[0025] In some implementations, the occlusion points corresponding to one or more of the aforementioned shading points, other than the first shading point, are obtained through a shared memory unit.
[0026] Understandably, since each computational unit can access the shared memory unit, the occlusion points of all shaded points can be stored in the shared memory unit. In this way, when each computational unit processes a shaded point, it can access this shared memory unit to obtain the occlusion points shared by other computational units. Using these shared occlusion points, the computational unit can perform more precise and detailed processing on the first shaded point, thereby significantly improving the overall quality of the rendered image.
[0027] In some implementations, the above method further includes: obtaining a shared set of occlusion points, which is obtained based on the occlusion points corresponding to multiple shading points in the above scene; and obtaining the second set of occlusion points from the shared set of occlusion points according to the first shading point.
[0028] Understandably, obtaining occlusion points through a shared set of occlusion points significantly improves the rendering quality of the entire image by finding more suitable and accurate occlusion points for each shading point. This technique not only enhances the depth and three-dimensionality of the image but also creates richer and more delicate details, resulting in a final rendering effect that more closely resembles the visual experience of the real world.
[0029] In some implementations, the above-mentioned determination of the first occlusion point set corresponding to the first shading point in the scene data of the above scene based on the ray tracing algorithm specifically includes: obtaining the ray tracing direction of the first shading point; and obtaining the first occlusion point set according to the ray tracing direction.
[0030] Understandably, ray tracing technology can accurately determine the occlusion points of specific shaded points. This method is relatively low-cost to implement while still maintaining high accuracy.
[0031] In some implementations, obtaining the ray tracing direction of the first shading point specifically includes: obtaining a random number; and obtaining the ray tracing direction based on the random number.
[0032] Understandably, using random numbers to determine the direction of ray tracing is a widely accepted technique, favored in the field of ray tracing due to its relatively low implementation cost.
[0033] In some implementations, obtaining the ray tracing direction of the first shading point specifically includes: obtaining the ray tracing direction based on different light sources.
[0034] It is understood that the method provided in this application has a wide range of applications; it is not limited to a specific type of light source and can adapt to various different light source scenarios. By adopting the method provided in this application, the quality of rendered images can be effectively improved, enabling them to achieve satisfactory visual effects in different application scenarios.
[0035] In some implementations, the ray tracing direction of the first shading point is obtained, and a noise map is obtained; based on the noise map, the ray tracing direction is obtained.
[0036] Understandably, compared to using random numbers for ray tracing, using noise maps significantly reduces low-frequency noise in the rendered image, resulting in a rendering effect that is more consistent with human visual perception. This method effectively reduces noise and irregular textures in the image, making the rendered image smoother and more natural. Furthermore, the use of noise maps can improve rendering efficiency because it reduces the number of ray tracing calculations required, thus speeding up the entire rendering process. The application of this technique not only improves image quality but also optimizes rendering speed, resulting in a more satisfying final visual effect.
[0037] In some implementations, obtaining the first set of occlusion points based on the aforementioned ray tracing direction specifically includes: constructing a ray tracing acceleration structure (bounding volume hierarchy, BVH) based on the aforementioned scene data; and obtaining the first set of occlusion points based on the aforementioned ray tracing acceleration structure, the aforementioned ray tracing direction, and the position of the aforementioned first shading point.
[0038] As is understandable, BVH, or Ray Tracing Accelerator Structure, is a data structure specifically designed to optimize geometry manipulation. It is particularly important in computer graphics, especially in collision detection and ray tracing, where it demonstrates superior performance. By organizing complex geometric objects into a hierarchical bounding volume structure, BVH effectively reduces unnecessary computation, significantly improving processing efficiency. This data structure constructs a tree-like structure where each node represents a bounding volume, with these bounding volumes layered around the internal geometric objects. In collision detection, BVH can quickly eliminate geometry that cannot collide, performing more detailed detection only on objects that may intersect. In ray tracing, BVH accelerates the calculation of ray interactions with objects in the scene because it can quickly determine which objects the ray intersects with, thus performing further ray scattering and reflection calculations only on these objects. Therefore, using BVH during rendering can significantly improve the quality of the rendered image, resulting in a more realistic and efficient final image.
[0039] In some implementations, the above-mentioned coloring of the first occluded point based on the second occlusion point set and the scene data specifically includes: performing an occlusion test on the second occlusion point set according to an occlusion relationship auxiliary structure to obtain a third occlusion point set, wherein the occlusion relationship auxiliary structure is used to record the probability that the occlusion point of the occluded point in each scene block of the above scene passes the occlusion test, and the third occlusion set includes the occlusion points in the second occlusion point set that pass the occlusion test; and coloring the first occluded point based on the third occlusion point set and the scene data.
[0040] Understandably, when using occlusion points for shading, if the occlusion point is not the first occlusion point on the ray tracing direction of the first shading point, it may introduce some error into the rendering result. To eliminate this potential error, occlusion tests should be performed on the acquired occlusion points to determine whether to use them. This method can effectively improve the accuracy of the rendering results.
[0041] In some implementations, the initial illumination value of the first shading point can also be obtained, and the first shading point can be shaded based on the initial illumination value of the first shading point, the aforementioned third occlusion point set, and the aforementioned scene data. The initial illumination value of the first shading point refers to the illumination intensity of the shading point when there is no occlusion.
[0042] In some implementations, the above method further includes updating the above occlusion relationship auxiliary structure based on the results of the above occlusion test.
[0043] Understandably, by constructing and updating the occlusion relationship auxiliary structure, the number of occlusion points in the second occlusion point set that require occlusion testing can be determined more accurately. This significantly reduces unnecessary occlusion testing, thereby improving the efficiency of ray tracing rendering. In practical applications, the second occlusion point set typically contains a large number of occlusion points. Performing occlusion testing on every single occlusion point would consume significant computational resources and time. By utilizing the occlusion relationship auxiliary structure, only a subset of the occlusion points in the second occlusion point set needs to be tested, reducing the required computation, optimizing the rendering process, and improving overall rendering performance.
[0044] In some implementations, the above-mentioned coloring of the first color point based on the second occlusion point set and the above-mentioned scene data specifically includes: coloring the first color point based on the initial illumination value of the first color point, the second occlusion point set, and the above-mentioned scene data.
[0045] The initial illumination value of the first shading point refers to the illumination intensity of the shading point when there is no occlusion.
[0046] Understandably, by analyzing occlusion points, the amount of lighting lost by the shading point due to occlusion can be calculated. This process requires precise analysis of the relative positions and orientations of objects in the scene. Subsequently, by combining the initial lighting and the lighting loss due to occlusion, the actual lighting value of the shading point can be obtained. This actual lighting value comprehensively considers both direct illumination and indirect reflection from the light source, thereby ensuring the realism and accuracy of the rendering effect.
[0047] Secondly, embodiments of this application provide an apparatus for rendering a scene based on ray tracing. The apparatus may be a rendering device (i.e., a device with rendering capabilities), a module applied to a rendering device (such as a processor, chip, or chip system), or a logic node, logic module, or software that can implement all or part of the functions of the rendering device. The apparatus includes: a determining unit, an acquiring unit, and a shading unit.
[0048] The determining unit is used to determine the set of first occlusion points corresponding to the first shading point in the scene data of the above scene.
[0049] The acquisition unit is used to acquire a second set of occlusion points, which includes the first set of occlusion points and occlusion points corresponding to one or more shading points in the scene other than the first shading point.
[0050] A coloring unit is used to color the first coloring point according to the second occlusion point set and the scene data mentioned above.
[0051] In some implementations, the aforementioned apparatus may execute a first aspect encapsulated as a first application programming interface for ray tracing rendering.
[0052] In some implementations, the acquisition unit is specifically used to: acquire the second set of occlusion points based on the first identifier, wherein the first identifier is used to indicate whether to acquire the second set of occlusion points.
[0053] In some implementations, the aforementioned first application programming interface includes a first identifier.
[0054] In some implementations, the acquisition unit is specifically used to: acquire the second set of occlusion points based on the second identifier, wherein the second identifier is used to indicate sharing mode information, and the sharing mode information includes one or more mode information.
[0055] In some implementations, the first application programming interface described above includes a second identifier.
[0056] In some implementations, the information about the occlusion point includes at least one of the following: the location of the occlusion point, the normal direction, or the sampling probability.
[0057] In some implementations, the acquisition unit is further configured to: acquire occlusion points corresponding to one or more color points other than the first color point based on the first pixel point corresponding to the first color point.
[0058] In some implementations, the acquisition unit is specifically used to: determine, based on the first pixel, one or more second pixels within a preset range from the first pixel, corresponding to their respective coloring points; and acquire the occlusion points corresponding to the determined coloring points.
[0059] In some implementations, the acquisition unit is specifically used to: acquire the occlusion points corresponding to one or more color points other than the first color point according to the first pixel point and the mapping relationship, wherein the mapping relationship is used to characterize the mapping relationship between the first pixel point and the pixel points corresponding to one or more color points other than the first color point.
[0060] In some implementations, the mapping relationship includes the grouping information of the first pixel, and the first pixel and the pixels corresponding to one or more color points other than the first color point are in the same group. The acquisition unit is specifically used to: acquire the occlusion points corresponding to one or more color points other than the first color point according to the first pixel and the grouping information.
[0061] In some implementations, the occlusion points corresponding to one or more of the aforementioned shading points, other than the first shading point, are obtained through a shared memory unit.
[0062] In some implementations, the aforementioned acquisition unit is further configured to: acquire a shared set of occlusion points, the shared set of occlusion points being obtained based on the occlusion points corresponding to multiple shading points in the aforementioned scene; and acquire the aforementioned second set of occlusion points from the shared set of occlusion points based on the aforementioned first shading point.
[0063] In some implementations, the aforementioned determining unit is specifically used to: obtain the ray tracing direction of the aforementioned first shading point; and obtain the aforementioned first occlusion point set based on the aforementioned ray tracing direction.
[0064] In some implementations, the aforementioned determining unit is specifically used to: obtain a random number; and obtain the aforementioned ray tracing direction based on the random number.
[0065] In some implementations, the aforementioned determining unit is specifically used to: obtain the aforementioned ray tracing direction based on the type of light source.
[0066] In some implementations, the aforementioned determining unit is specifically used to: obtain a noise map; and obtain the aforementioned ray tracing direction based on the noise map.
[0067] In some implementations, the aforementioned determining unit is specifically used to: construct a ray tracing acceleration structure based on the aforementioned scene data; and obtain the aforementioned first occlusion point set based on the aforementioned ray tracing acceleration structure, the aforementioned ray tracing direction, and the aforementioned position of the first shading point.
[0068] In some implementations, the aforementioned coloring unit is specifically used to: perform occlusion testing on the aforementioned second occlusion point set according to the occlusion relationship auxiliary structure to obtain a third occlusion point set, wherein the aforementioned occlusion relationship auxiliary structure is used to record the probability that the occlusion point of the coloring point in each scene block of the aforementioned scene passes the occlusion test, and the aforementioned third occlusion set includes the occlusion points in the aforementioned second occlusion point set that pass the occlusion test; and color the aforementioned first coloring point according to the aforementioned third occlusion point set and the aforementioned scene data.
[0069] In some implementations, the aforementioned coloring unit is also used to update the aforementioned occlusion relationship auxiliary structure based on the results of the aforementioned occlusion test.
[0070] In some implementations, the shading unit is specifically used to: shade the first shading point according to the initial illumination value of the first shading point, the second occlusion point set, and the scene data.
[0071] In some implementations, the shading unit is specifically used to: shade the first shading point according to the initial illumination value of the first shading point, the third occlusion point set, and the scene data.
[0072] Thirdly, embodiments of this application also provide an apparatus for rendering a scene based on ray tracing, the apparatus comprising: at least one processor, which, when the at least one processor executes program code or instructions, implements the method in the first aspect or any possible implementation thereof.
[0073] In some implementations, the device may also include at least one memory for storing the program code or instructions.
[0074] Fourthly, embodiments of this application also provide a chip, including: an input interface, an output interface, at least one processor, and a memory. The at least one processor is used to execute code in the memory, and when the at least one processor executes the code, the chip is used to implement the method described in the first aspect or any possible implementation thereof.
[0075] In some implementations, the aforementioned chip can also be an integrated circuit.
[0076] Fifthly, embodiments of this application also provide a computer-readable storage medium for storing a computer program, the computer program including methods for implementing the first aspect above or any possible implementation thereof.
[0077] In some implementations, the computer-readable storage medium is a non-transitory computer-readable storage medium.
[0078] Sixthly, embodiments of this application also provide a computer program product containing instructions that, when run on a computer, cause the computer to implement the method described in the first aspect or any possible implementation thereof.
[0079] Seventhly, embodiments of this application also provide an apparatus for rendering a scene based on ray tracing, the apparatus including a processing circuit. The processing circuit is used to implement the method in the first aspect or any possible implementation thereof.
[0080] Eighthly, embodiments of this application also provide a computer program containing instructions that, when run on a computer, cause the computer to implement the method described in the first aspect or any possible implementation thereof.
[0081] The apparatus, computer storage medium, computer program, computer program product, and chip for rendering scenes based on ray tracing provided in this embodiment are all used to execute the method for rendering scenes based on ray tracing provided above. Therefore, the beneficial effects that can be achieved can be referred to the beneficial effects in the method for rendering scenes based on ray tracing provided above, and will not be repeated here. Attached Figure Description
[0082] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0083] Figure 1 is a flowchart illustrating the rendering process using ray technology provided in an embodiment of this application.
[0084] Figure 2 is a structural example diagram of an electronic device provided in an embodiment of this application;
[0085] Figure 3a is a rendering system framework diagram provided in an embodiment of this application;
[0086] Figure 3b is a rendering system framework diagram provided in an embodiment of this application;
[0087] Figure 4 is a flowchart illustrating a method for rendering a scene based on ray tracing, as provided in an embodiment of this application.
[0088] Figure 5 is a flowchart illustrating another method for rendering a scene based on ray tracing provided in an embodiment of this application;
[0089] Figure 6 is a flowchart illustrating another method for rendering a scene based on ray tracing provided in an embodiment of this application;
[0090] Figure 7 is a flowchart illustrating another method for rendering a scene based on ray tracing provided in an embodiment of this application;
[0091] Figure 8 is a schematic diagram of the light source provided in an embodiment of this application;
[0092] Figure 9 is a flowchart illustrating another method for rendering a scene based on ray tracing provided in an embodiment of this application;
[0093] Figure 10 is a rendering effect diagram provided by an embodiment of this application;
[0094] Figure 11 is another rendering effect diagram provided by an embodiment of this application;
[0095] Figure 12 is a schematic diagram of a data structure provided in an embodiment of this application;
[0096] Figure 13 is a schematic diagram of another data structure provided in an embodiment of this application;
[0097] Figure 14 is a schematic diagram of a hemispherical space provided in an embodiment of this application;
[0098] Figure 15 is a flowchart illustrating another method for rendering a scene based on ray tracing provided in an embodiment of this application;
[0099] Figure 16 is a flowchart illustrating another method for rendering a scene based on ray tracing provided in an embodiment of this application;
[0100] Figure 17 is a schematic diagram of a shared occlusion point provided in an embodiment of this application;
[0101] Figure 18 is another rendering effect diagram provided by an embodiment of this application;
[0102] Figure 19 is a flowchart illustrating another method for rendering a scene based on ray tracing provided in an embodiment of this application;
[0103] Figure 20 is a schematic diagram of the structure of a device provided in an embodiment of this application;
[0104] Figure 21 is a schematic diagram of the structure of a chip provided in an embodiment of this application;
[0105] Figure 22 is a schematic diagram of the structure of another electronic device provided in an embodiment of this application. Detailed Implementation
[0106] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of the embodiments of this application.
[0107] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0108] The terms "first" and "second," etc., in the specification and drawings of the embodiments of this application are used to distinguish different objects or to distinguish different treatments of the same object, rather than to describe a specific order of objects.
[0109] Furthermore, the terms "comprising" and "having," and any variations thereof, used in the description of the embodiments of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the steps or units listed, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or devices.
[0110] It should be noted that in the description of the embodiments of this application, the words "exemplarily" or "for example" are used to indicate examples, illustrations, or explanations. Any embodiment or design scheme described as "exemplarily" or "for example" in the embodiments of this application should not be construed as being more preferred or advantageous than other embodiments or design schemes. Specifically, the use of the words "exemplarily" or "for example" is intended to present the relevant concepts in a specific manner.
[0111] Next, the technical terms and concepts involved in the embodiments of this application will be explained and interpreted in detail.
[0112] Ray tracing is a rendering technique that generates images by simulating the propagation and interaction of light. It delivers highly realistic visual effects because it considers the physical behavior of light in the real world, including phenomena such as reflection, refraction, scattering, and shadows. During rendering, ray tracing algorithms emit light rays from a virtual camera, which intersect with objects in the scene, and calculate the final color and brightness of the light rays based on the material properties of the objects. Due to its computationally intensive nature, ray tracing typically requires high-performance computing resources, but with advancements in hardware technology, real-time ray tracing is becoming increasingly feasible in game and film production.
[0113] Rendering refers to the process of converting objects in a 3D scene into a 2D image. In this process, computer programs calculate the geometry, position, material properties, and the position and characteristics of light sources for each object in the scene, then simulate how light is reflected, refracted, or absorbed on these objects. Rendering techniques can be broadly categorized into rasterization and ray tracing. Rasterization is a commonly used technique in real-time graphics processing; it quickly generates images by converting 3D models into pixel arrays, but it may not be able to accurately simulate complex lighting effects. Ray tracing, on the other hand, generates more realistic images by simulating the physical behavior of light, although it is computationally more expensive.
[0114] Shading point: During rendering, each pixel will have a corresponding surface point in three-dimensional space. The value of the pixel is the light emitted from the surface point towards the camera. This point is called the shading point.
[0115] Intersection: The core operation of ray tracing. Given the origin and direction of a ray, and a representation of the scene, the intersection operation returns the nearest intersection point between the ray and the scene.
[0116] Blue noise: High-frequency noise has a greater distribution of noise, and using blue noise for rendering can produce a more visually appealing result.
[0117] Light source: Provides illumination to objects in the scene.
[0118] Occlusion point: A point on the surface of another object that prevents light from reaching the shading point.
[0119] The Open Graphics Library (OpenGL) is a cross-language, cross-platform application programming interface (API) for rendering 2D and 3D vector graphics. It consists of numerous functions and commands that allow developers to create complex graphics effects on different hardware and operating systems. OpenGL is widely used in computer graphics, particularly in game development, virtual reality, and scientific visualization systems.
[0120] Vulkan, a graphics application programming interface (API), is an advanced graphics and computing API that provides high-performance, efficient graphics rendering and computing capabilities across platforms. Vulkan aims to provide more direct hardware control and reduce driver overhead, allowing developers to fully leverage the computing power of modern multi-core processors. It supports multiple operating systems, providing developers with a unified way to create complex graphics applications and games.
[0121] Embedded Graphics Library (EGL): This is a graphics processing library widely used in embedded systems. It provides developers with a rich set of API interfaces for rendering and displaying graphics on embedded devices.
[0122] Single Instruction Multiple Threads (SIMT) is an advanced computer processing technique that allows a single instruction to control the execution of multiple threads simultaneously. This technique plays a crucial role in improving processor performance, especially in multi-core processors, where it can significantly enhance program efficiency and processing speed.
[0123] Ray tracing technology: It obtains environmental information of shaded points by emitting rays and calculating their intersections with the scene, and calculates the lighting effects of the shaded points accordingly.
[0124] The following is a brief description of the rendering process using ray tracing. As shown in (1) and (2) of Figure 1, the goal of the rendering task is to draw an image on the screen from a given camera viewpoint. This image contains multiple pixels, so it is necessary to calculate the color of each pixel in the image. The specific process of rendering using ray tracing is as follows: As shown in (3) of Figure 1, each pixel can find its corresponding shading point by performing an intersection procedure in the scene based on the ray formed by itself and the camera (this step can also be implemented by rasterization). Then, the illumination of each shading point is calculated by the ray tracing algorithm, and the illumination is used as the color of the corresponding pixel (the outgoing color in (4) of Figure 1). Specifically, as shown in (5) of Figure 1, the visible surface around each shading point is found by ray intersection, and the illumination of the shading point is calculated based on the illumination of the visible surface.
[0125] However, intersection calculations in ray tracing are a computationally intensive process, and the number of intersection calculations is one of the key metrics for measuring ray tracing performance overhead. Especially on mobile devices, due to physical limitations such as size and power consumption, their ray tracing capabilities are less than those of desktop devices. To achieve real-time ray tracing effects, the number of intersection calculations that can be performed in each rendering process is strictly limited.
[0126] Therefore, this application proposes a ray tracing-based rendering scheme to improve the quality of the rendered image without increasing the computational overhead of intersection calculation.
[0127] The solutions provided in this application can be applied to various devices with rendering capabilities. For example, they can be applied to various terminal electronic devices such as mobile phones, personal computers (PCs), tablets, wearable devices, in-vehicle devices, augmented reality (AR) and virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, and personal digital assistants (PDAs). For example, they can also be applied to server-side devices such as servers and cloud servers. This application does not limit the specific type of electronic device.
[0128] For example, FIG2 is a schematic diagram of the structure of an electronic device 100 provided in an embodiment of this application. The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headphone jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0129] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0130] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0131] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0132] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0133] The I2C interface is a bidirectional synchronous serial bus. The processor 110 can couple with the touch sensor 180K through the I2C interface, enabling communication between the processor 110 and the touch sensor 180K via the I2C bus interface, thus realizing the touch function of the electronic device 100. The MIPI interface can be used to connect the processor 110 with peripheral devices such as the display screen 194 and the camera 193. The MIPI interface includes a camera serial interface (CSI) and a display serial interface (DSI). In some embodiments, the processor 110 and the camera 193 communicate through the CSI interface to realize the shooting function of the electronic device 100. The processor 110 and the display screen 194 communicate through the DSI interface to realize the display function of the electronic device 100.
[0134] It is understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a structural limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may also employ different interface connection methods or combinations of multiple interface connection methods as described in the above embodiments.
[0135] The charging management module 140 receives charging input from a charger, which can be either a wireless or wired charger. The power management module 141 connects to the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, providing power to the processor 110, internal memory 121, external memory, display 194, camera 193, and wireless communication module 160, etc.
[0136] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0137] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Miniled LED, a MicroLED, a Micro-OLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1.
[0138] The electronic device 100 can perform shooting functions through an ISP, camera 193, touch sensor, video codec, GPU, display screen 194, and application processor, etc. For example, the shooting process described in the embodiments of this application.
[0139] The ISP (Image Signal Processor) is used to process data fed back from the camera 193. For example, when taking a picture, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, and the camera's photosensitive element transmits this electrical signal to the ISP for processing, transforming it into an image visible to the naked eye. The ISP can also perform algorithmic optimization of image noise, brightness, and skin tone. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.
[0140] Camera 193 is used to capture still images or videos. An object is projected onto a photosensitive element by generating an optical image through the lens. The photosensitive element can be a charge-coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, which is then transmitted to an ISP for conversion into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into a standard RGB, YUV, or other format image signal. It should be understood that the description of the embodiments in this application uses an RGB format image as an example, and the image format is not limited in this application. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.
[0141] Digital signal processors (DSPs) are used to process digital signals. Besides digital image signals, they can also process other digital signals. For example, when electronic device 100 selects a frequency, the DSP can perform Fourier transforms on the frequency energy.
[0142] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. Thus, electronic device 100 can play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0143] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The internal memory 121 can be used to store computer executable program code, including instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area.
[0144] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0145] A pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. A gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100. A barometric pressure sensor 180C is used to measure barometric pressure. A magnetic sensor 180D includes a Hall effect sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip cover. An accelerometer 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). A distance sensor 180F is used to measure distance. The electronic device 100 can measure distance using infrared or laser. In some embodiments, during a shooting scene, the electronic device 100 can use the distance sensor 180F to measure distance for fast focusing. A proximity sensor 180G may include, for example, a light-emitting diode (LED) and a photodetector, such as a photodiode. An ambient light sensor 180L is used to sense ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the sensed ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking a picture. A fingerprint sensor 180H is used to collect fingerprints. Electronic device 100 can utilize the collected fingerprint characteristics to achieve fingerprint unlocking, application access lock, fingerprint photography, fingerprint answering of calls, etc. Temperature sensor 180J is used to detect temperature. Touch sensor 180K, also known as a "touch panel," can be placed on display screen 194. The touch sensor 180K and display screen 194 together form a touchscreen, also known as a "touch screen." Touch sensor 180K is used to detect touch operations applied to or near it. Bone conduction sensor 180M can acquire vibration signals. Audio module 170 can analyze the vibration signals of the acoustic vibration bone blocks acquired by the bone conduction sensor 180M to extract voice signals and realize voice functions.
[0146] Buttons 190 include a power button, volume buttons, etc. Buttons 190 can be mechanical buttons or touch buttons. Electronic device 100 can receive button inputs and generate key signal inputs related to user settings and function control of electronic device 100. Motor 191 can generate vibration alerts. Motor 191 can be used for incoming call vibration alerts or for touch vibration feedback. For example, touch operations applied to different applications (such as taking photos, playing audio, etc.) can correspond to different vibration feedback effects. Touch operations applied to different areas of the display screen 194 can also correspond to different vibration feedback effects from motor 191. Indicator 192 can be an indicator light, used to indicate charging status, battery level changes, or to indicate messages, missed calls, notifications, etc. SIM card interface 195 is used to connect a SIM card.
[0147] The software system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses a layered architecture system as an example to exemplify the software structure of electronic device 100.
[0148] The aforementioned systems can be Harmony OS, Android, Windows, iOS, or other operating systems.
[0149] Figure 3a is a rendering system framework diagram provided in an embodiment of this application. As shown in Figure 3a, the rendering system framework includes software and hardware, with the hardware including CPU, GPU, DDR, etc. This rendering system framework can be deployed on various devices with rendering capabilities, such as the electronic device shown in Figure 2, or server-side devices such as servers and cloud servers. It can also be deployed in a system composed of terminal electronic devices and server-side devices. This application does not specifically limit its deployment in this regard.
[0150] It should be understood that the hardware and software shown in Figure 3a are merely examples. In other embodiments, other types of software or hardware may be used. For example, DDR in Figure 3a may be used as video memory. In other embodiments, video memory may also be implemented by synchronous dynamic random access memory (SDRAM) or other types of memory.
[0151] The software encompasses applications (APPs), rendering engines, and rendering frameworks.
[0152] The applications include various types such as game applications, video applications, instant messaging applications, and photo applications.
[0153] A rendering engine may contain one or more engines, such as Unity 3D, Unreal Engine, etc.
[0154] The rendering framework integrates various graphics libraries, such as the Open Graphics Library (OpenGL), the Vulkan graphics application programming interface, or the Embedded Graphics Library (EGL).
[0155] This application provides a method for rendering scenes based on ray tracing. This method can be incorporated into code within a driver, library, or software or hardware, or it can utilize an API (such as OpenGL, Vulkan, or EGL) that encapsulates the functionality. For example, an API can be used to encapsulate a method for rendering scenes based on ray tracing. Typically, APIs can be implemented or encapsulated within the GPU's video driver, providing acceptable performance for rendering requests, although these solutions can be implemented using various general-purpose and processor-specific methods.
[0156] Figure 3b is another rendering system framework diagram provided in an embodiment of this application. As shown in Figure 3a, the rendering system framework includes an application, a driver, and hardware. This system framework can be deployed on various devices with rendering capabilities, such as the electronic device shown in Figure 2, or server-side devices such as servers and cloud servers. It can also be deployed in a system composed of terminal electronic devices and server-side devices. This application does not specifically limit it in this regard.
[0157] Applications include system applications (such as Harmony OS applications, Android system applications, Windows system applications, or iOS system applications), rendering engine applications (such as Unity 3D or Unreal), or upper-layer applications (such as game applications, video applications, instant messaging applications, camera applications, etc.).
[0158] The driver can support rendering frameworks such as OpenGL, Vulkan, and EGL.
[0159] The hardware includes CPU, GPU, DDR, and other hardware.
[0160] The driver can expose the rendering framework API for applications to call.
[0161] Applications can render by calling the rendering framework API.
[0162] For example, system applications can call the Vulkan API to perform rendering.
[0163] In some implementations, this method can be encapsulated as a first application programming interface for ray tracing rendering scenes.
[0164] The following is a detailed description of the solution provided in the embodiments of this application, which can be executed by the aforementioned rendering-capable device (hereinafter referred to as the rendering device).
[0165] Figure 4 illustrates a method for rendering a scene based on ray tracing provided in an embodiment of this application. As shown in Figure 4, the method includes:
[0166] S401. Determine the set of first occlusion points corresponding to the first shading point in the scene data of the scene.
[0167] The aforementioned scene refers to a virtual 3D environment containing various objects, light sources, and cameras. In this scene, ray tracing algorithms are used to simulate the process of light rays originating from light sources, passing through objects in the scene, undergoing reflection and refraction, and finally reaching the camera. This process accurately calculates the color and brightness of each pixel, thereby generating highly realistic rendered images.
[0168] Scene data may include shading point information for one or more shading points. Shading point information may include one or more of the following: the shading point's position, the shading point's normal, and the shading point's pixel position. In some embodiments, scene data may also include light source information, which may include one or more of the following: light source type (including light source size and shape description), light source intensity, and light source texture. The first shading point is any one of the one or more shading points in the scene described above. In some embodiments, scene data may also include object information, which may include one or more of the following: object type (including object size and shape description), object position, object texture, and object material.
[0169] In some implementations, S401 can be encapsulated as a second application programming interface (API) for ray tracing rendering. For example, the second API can be an OpenGL, Vulkan, or EGL API. That is, the second API is used to determine a first set of occlusion points corresponding to at least one shading point in the scene based on a ray tracing algorithm.
[0170] For example, the second application programming interface (API) is used to determine the set of first occlusion points corresponding to a first shading point in the scene data of the scene based on a ray tracing algorithm. Exemplarily, when the second API includes input, the input to the second API can be one or more of scene data, the first shading point, multiple first shading points, etc.
[0171] For example, when the second application programming interface includes an output, the output of the second application programming interface may be a set of first occlusion points corresponding to the first shading point, or a set of first occlusion points corresponding to multiple first shading points respectively.
[0172] As shown in Figure 5, in some implementations, the specific implementation of S401 may include S501 and S502.
[0173] S501, Obtain the ray tracing direction of the first shading point.
[0174] For example, obtaining the ray tracing direction of the first shading point can be achieved in various ways.
[0175] As shown in Figure 6, in some implementations, the above S501 may specifically include S601 and S602.
[0176] S601, Get a random number.
[0177] In some implementations, random numbers can be generated using computer programs. For example, random number generation algorithms can be used to generate random numbers.
[0178] In some implementations, random numbers can be generated using a noise graph, as shown in Figure 7. Specifically, S701 can include S701 and S702.
[0179] S701, Obtain the noise map.
[0180] For example, the noise map can be a blue noise map. It is understood that the blue noise map conforms to the rules of blue noise, and therefore can produce a visually superior rendering.
[0181] S702. Obtain random numbers based on the noise graph.
[0182] The noise map is represented as a two-dimensional array, where each element is a floating-point number between 0 and 1.
[0183] The specific implementation method for obtaining random numbers based on the noise diagram can be any implementation method that can be conceived by those skilled in the art, and the embodiments of this application do not limit this.
[0184] For example, random numbers can be obtained by sampling the noise map based on the pixel position of the first colored point.
[0185] A noise map is a two-dimensional array where each number is a floating-point number between 0 and 1. By sampling directly from this two-dimensional array based on the pixel position, you get random numbers.
[0186] In some implementations, random numbers are obtained based on the noise graph, specifically including: obtaining a third identifier; and obtaining random numbers based on the noise graph when the third identifier indicates that random numbers are generated using the noise graph.
[0187] The third identifier is used to indicate whether a noise graph is used to generate random numbers.
[0188] For example, the third identifier can take the values 0 and 1. A value of 0 indicates that the noise graph is not used to generate random numbers, while a value of 1 indicates that the noise graph is used to generate random numbers.
[0189] For example, the default value for the third identifier can be 0.
[0190] The values for the third identifier described above are for illustrative purposes only. Other enumerated values are also possible, or they can indicate other methods of generating random numbers. For example, the third identifier is used to indicate the method of generating random numbers (it should be understood that another identifier can also be used to indicate the method of generating random numbers), such as a value of 0 indicating that random numbers are generated using a random number generation algorithm, a value of 1 indicating that random numbers are generated using a noise graph, and so on.
[0191] In some implementations, the second application programming interface may include a third identifier.
[0192] For example, the rendering device can execute the second application programming interface and, if the third identifier indicates the use of a noise graph, execute the above-described S701 and S702 to obtain random numbers from the noise graph.
[0193] Understandably, compared to using random numbers for ray tracing, using noise maps significantly reduces low-frequency noise in the rendered image, resulting in a rendering effect that is more consistent with human visual perception. This method effectively reduces noise and irregular textures in the image, making the rendered image smoother and more natural. Furthermore, the use of noise maps can improve rendering efficiency because it reduces the number of ray tracing calculations required, thus speeding up the entire rendering process. The application of this technique not only improves image quality but also optimizes rendering speed, resulting in a more satisfying final visual effect.
[0194] S602. Obtain the ray tracing direction based on the random number.
[0195] For example, random numbers can be obtained using random number generation techniques or noise maps provided in conventional computer programs. Then, based on these random numbers, random sampling directions can be formed within a hemispherical space centered on the normal direction of the first shading point, and the randomly sampled directions can be used as the ray tracing direction of the first shading point. Alternatively, random numbers can be sampled from the surface of the light source, and the light source point can be connected to the first shading point, with the direction of the connecting line serving as the ray tracing direction of the first shading point. Higher sampling probabilities can also be assigned to specific regions within the hemispherical space, thereby sampling within the hemispherical space of the shading point to obtain the ray tracing direction. Furthermore, various sampling methods can be combined and used in combination to obtain the ray tracing direction.
[0196] In some implementations, obtaining the ray tracing direction based on a random number can specifically be done by obtaining the ray tracing direction based on a random number and the light source type.
[0197] As shown in Figure 8, the above light source types can include Ray Tracing Ambient Occlusion (RTAO), ambient light sources, surface light sources, and irregular surface light sources.
[0198] For example, when the light source type is RTAO, the direction can be randomly sampled in a hemispherical space centered on the normal direction of the first shading point based on a random number, and the randomly sampled direction can be used as the ray tracing direction of the first shading point. Alternatively, the light source surface can be sampled according to a random number, and the light source point can be connected to the first shading point, with the direction of the connecting line used as the ray tracing direction of the first shading point.
[0199] For example, when the light source is an ambient light source, the direction can be randomly sampled in a hemispherical space centered on the normal direction of the first shading point, and the randomly sampled direction can be used as the ray tracing direction of the first shading point.
[0200] For example, when the light source is a surface light source or an irregular surface light source, random numbers can be sampled on the surface of the light source, and the light source point can be connected to the first shading point, with the direction of the connection line serving as the direction of ray tracing for the first shading point.
[0201] It is understood that the method provided in this application has a wide range of applications; it is not limited to a specific type of light source and can adapt to various different light source scenarios. By adopting the method provided in this application, the quality of rendered images can be effectively improved, enabling them to achieve satisfactory visual effects in different application scenarios.
[0202] In some implementations, obtaining the ray tracing direction based on the random number and the light source type specifically includes: obtaining the fourth identifier; and obtaining the ray tracing direction based on the random number and the light source type indicated by the fourth identifier.
[0203] The fourth identifier is used to indicate the type of light source.
[0204] For example, the fourth identifier can be 1, 2, 3 and 4, where a value of 1 indicates RTAO, a value of 2 indicates ambient light, a value of 3 indicates surface light, and a value of 4 indicates irregular surface light.
[0205] For example, the default value for the third identifier can be 1.
[0206] The values for the fourth identifier mentioned above are for illustrative purposes only. Other enumerated values are also possible, or other methods can be used to indicate the light source type. For example, the fourth identifier is used to indicate the light source type (it should be understood that another identifier can also be used to indicate the light source type), such as a value of 4 indicating RTAO, a value of 3 indicating ambient light, a value of 2 indicating surface light, a value of 1 indicating irregular surface light, and so on.
[0207] In some implementations, the second application programming interface includes a fourth identifier.
[0208] For example, the rendering device can call the second application programming interface and obtain the ray tracing direction based on the light source type indicated by the fourth identifier and a random number.
[0209] S502. Obtain the first set of occlusion points based on the ray tracing direction.
[0210] For example, in some implementations, an intersection calculation can be performed based on the position of the first shading point and the ray tracing direction to obtain a first set of occlusion points.
[0211] Understandably, by performing the intersection calculation, the occlusion point of the shaded point can be accurately determined based on its position and the ray tracing direction. This method is relatively low in cost while still maintaining high accuracy.
[0212] For example, in some implementations, as shown in Figure 9, the first set of occlusion points is obtained according to the ray tracing direction, which may specifically include S901 and S902.
[0213] S901, Constructing a ray tracing acceleration structure based on scene data.
[0214] For example, light source and object information from scene data can be used to construct ray tracing acceleration structures.
[0215] S902. Obtain the first occlusion point set based on the ray tracing acceleration structure, the ray tracing direction, and the position of the first shading point.
[0216] For example, after obtaining the ray tracing direction of the first shading point, a ray can be constructed based on the position of the first shading point and the ray tracing direction, and the ray can interact with the ray tracing acceleration structure to perform intersection calculations to determine the occlusion points, thereby obtaining the set of the first occlusion points.
[0217] As is understandable, BVH, or Ray Tracing Accelerator Structure, is a data structure specifically designed to optimize geometry manipulation. It is particularly important in computer graphics, especially in collision detection and ray tracing, where it demonstrates superior performance. By organizing complex geometric objects into a hierarchical bounding volume structure, BVH effectively reduces unnecessary computation, significantly improving processing efficiency. This data structure constructs a tree-like structure where each node represents a bounding volume, with these bounding volumes layered around the internal geometric objects. In collision detection, BVH can quickly eliminate geometry that cannot collide, performing more detailed detection only on objects that may intersect. In ray tracing, BVH accelerates the calculation of ray interactions with objects in the scene because it can quickly determine which objects the ray intersects with, thus performing further ray scattering and reflection calculations only on these objects. Therefore, using BVH during rendering can significantly improve the quality of the rendered image, resulting in a more realistic and efficient final image.
[0218] In some implementations, obtaining the first set of occlusion points based on the ray tracing direction may specifically include: obtaining a fifth identifier, and if the fifth identifier indicates the use of a ray tracing acceleration structure, executing S901 and S902 to obtain the first set of occlusion points.
[0219] The fifth identifier is used to indicate whether a ray tracing acceleration structure is used.
[0220] For example, the fifth identifier can take the values 0 and 1. A value of 0 indicates that ray tracing acceleration is not used, and a value of 1 indicates that ray tracing acceleration is used.
[0221] For example, the default value for the fifth identifier can be 0.
[0222] The values for the fifth flag described above are for illustrative purposes only. Other enumerated values are also possible, or other methods can be used to indicate whether a ray tracing acceleration structure is used. For example, the fifth flag is used to indicate whether a ray tracing acceleration structure is used (it should be understood that another flag can also be used to indicate whether a ray tracing acceleration structure is used), such as a value of 0 indicating the use of a ray tracing acceleration structure, a value of 1 indicating the disuse of a ray tracing acceleration structure, and so on.
[0223] In some implementations, the second application programming interface may include a fifth identifier.
[0224] For example, the rendering device can execute the second application programming interface and, when the fifth identifier indicates the use of a ray tracing acceleration structure, execute S901 and S902, namely, constructing a ray tracing acceleration structure based on scene data; and then obtain a first set of occlusion points according to the ray tracing acceleration structure, the ray tracing direction, and the position of the first shading point.
[0225] For example, the rendering device can execute the second application programming interface and, if the fifth identifier indicates that ray tracing acceleration is not used, can skip S901 and S902 and obtain the first occlusion point set in another way. For instance, it can perform an intersection calculation based on the position of the first shading point and the ray tracing direction to obtain the first occlusion point set.
[0226] S402, Obtain the second set of occlusion points.
[0227] The second set of occlusion points includes the first set of occlusion points and the occlusion points corresponding to one or more shading points in the scene other than the first shading point.
[0228] In some implementations, obtaining the second set of occlusion points specifically includes: obtaining a first identifier, and obtaining the second set of occlusion points if the first identifier indicates that the second set of occlusion points is to be used.
[0229] The first identifier mentioned above is used to indicate whether the second set of occlusion points is used.
[0230] For example, the first identifier can take the values 0 and 1. A value of 0 indicates that the second occlusion point set is not used, and a value of 1 indicates that the second occlusion point set is used.
[0231] For example, the default value of the first identifier can be 0.
[0232] The values for the first identifier described above are for illustrative purposes only. Other enumerated values are also possible, or other methods can be used to indicate whether the second occlusion point set is used. For example, the first identifier is used to indicate whether the second occlusion point set is used (it should be understood that another identifier can also be used to indicate whether the second occlusion point set is used). For example, a value of 0 indicates the use of the first occlusion point set, and a value of 1 indicates the use of the second occlusion point set.
[0233] In some implementations, the aforementioned first application programming interface includes a first identifier.
[0234] For example, the rendering device may execute a first application programming interface and, if a first identifier indicates the use of a second set of occlusion points, execute S402, i.e., obtain the second set of occlusion points.
[0235] Understandably, using the second set of occluded points to color the shading points significantly improves the quality of the rendered image, resulting in a more delicate and realistic visual effect. To enhance the flexibility of the approach, a first flag can be set in the method's application programming interface (API). This flag allows users to choose whether to use the second set of occluded points for rendering based on their needs and preferences. In this way, users can flexibly adjust rendering settings to achieve their desired visual effects, whether pursuing ultimate image quality or ensuring rendering accuracy.
[0236] In some implementations, obtaining the second set of occlusion points specifically includes: obtaining a second identifier, and obtaining the second set of occlusion points when the second identifier indicates shared light source point pattern information.
[0237] The second identifier is used to indicate sharing mode information, which includes one or more mode information. For example, the sharing mode information may include shared occlusion point mode information and shared light source point mode information.
[0238] For example, the second identifier can take the values 0, 1, and 2. A value of 0 indicates that the shared mode information is not used, a value of 1 indicates that the shared occlusion point mode information is used, and a value of 2 indicates that the shared light source point mode information is used.
[0239] The values for the second identifier described above are for illustrative purposes only. Other enumerated values are also possible, or other methods can be used to share the mode information. For example, the second identifier is used to share mode information (it should be understood that another identifier can also be used to indicate shared mode information). For instance, a value of 0 indicates sharing the light source point mode information, a value of 1 indicates not using shared mode information, and a value of 2 indicates sharing the occlusion point mode information.
[0240] For example, the rendering device can execute a first application programming interface and, if the second identifier indicates shared information about occlusion points, execute S402, i.e., obtain a second set of occlusion points.
[0241] For example, the rendering device can execute the first application programming interface and, if the second flag is 1, execute S402, that is, obtain the second set of occlusion points.
[0242] For example, the rendering device can execute a first application programming interface and, with the second identifier indicating shared light source information, obtain a set of shared light sources.
[0243] The shared light source point set includes light source points corresponding to one or more shading points in the above scene, excluding the first shading point mentioned above.
[0244] For example, the rendering device may execute a first application programming interface and, if a second identifier indicates that mode information is not shared, not acquire a second set of occlusion points and a shared set of light sources.
[0245] In some implementations, S402 can be encapsulated as a third application programming interface (API). This third API can be an OpenGL, Vulkan, or EGL API. For example, the third API can be an OpenGL, Vulkan, or EGL API. That is, the third API is used to obtain the second set of occlusion points.
[0246] For example, when the third application programming interface includes input, the input of the third application programming interface can be one or more of the pixel position of the first shading point, the position of the first shading point, or the normal of the first shading point.
[0247] For example, when the third application programming interface includes output, the output of the third application programming interface can be a second set of occlusion points or a shared set of occlusion points. The shared set of occlusion points can include a first set of occlusion points and a second set of occlusion points.
[0248] In some implementations, obtaining the second occlusion point set can specifically be done by obtaining the second occlusion point set based on the pixel position of the first color point.
[0249] In some implementations, obtaining the second occlusion point set specifically includes: obtaining occlusion points corresponding to one or more shading points other than the first shading point in the above scene; and combining the obtained occlusion points corresponding to one or more shading points other than the first shading point in the above scene with the first occlusion point set to form the second occlusion point set.
[0250] For example, the occlusion points corresponding to one or more occlusion points other than the first occlusion point in the above scenario can be merged with the first occlusion point set to form a second occlusion point set.
[0251] For example, the occlusion points corresponding to one or more shading points other than the first shading point in the above scene can be deduplicated according to the first occlusion point set. Then, the occlusion points corresponding to one or more shading points other than the first shading point in the above scene after deduplication can be merged with the first occlusion point set to form a second occlusion point set.
[0252] In some implementations, obtaining the occlusion points corresponding to one or more shading points other than the first shading point in the above scene specifically includes: obtaining the occlusion points corresponding to one or more shading points other than the first shading point in the scene based on the first pixel point corresponding to the first shading point.
[0253] In some implementations, obtaining the occlusion point corresponding to one or more shading points in the scene other than the first shading point based on the first pixel point corresponding to the first shading point specifically includes: determining the shading points corresponding to one or more second pixels within a preset range from the first pixel point based on the first pixel point; and obtaining the occlusion point corresponding to the determined shading point.
[0254] The preset range of the first pixel can be a region set based on the first pixel.
[0255] For example, a region (rectangular region, circular region, elliptical region, cross region, triangular region or other shaped region) is set as the preset range of the first pixel point, and the coloring points corresponding to one or more second pixels within the preset range of the first pixel point are respectively obtained; the occlusion points corresponding to the determined coloring points are obtained.
[0256] As shown in Figure 10, the matrix area formed by the dashed lines in the figure is the preset range of the first pixel point set with the first pixel point as the center. In the figure, the black pixels are the first pixels, the gray pixels are the pixels within the preset range of the first pixels, i.e., the second pixels, and the white pixels are the pixels outside the preset range of the first pixels. The coloring points corresponding to one or more second pixels within the matrix area in the figure are determined; the occlusion points corresponding to the determined coloring points are obtained.
[0257] Understandably, by pre-setting the sharing range, the computational complexity of obtaining the occlusion points corresponding to one or more occluded points other than the first occluded point can be significantly reduced, thereby improving overall computational efficiency. This method, by optimizing the computation process, avoids repetitive and unnecessary computational steps, enabling faster and more efficient achievement of the expected results when processing large amounts of data.
[0258] In some implementations, determining the color points corresponding to one or more second pixels within a preset range of the first pixel based on the first pixel, and obtaining the occlusion points corresponding to the determined color points, specifically includes: when the sixth identifier indicates the use of a preset range, determining the color points corresponding to one or more second pixels within the preset range of the first pixel based on the first pixel, and obtaining the occlusion points corresponding to the determined color points.
[0259] The sixth identifier is used to indicate whether a preset range is used.
[0260] For example, the sixth identifier can take the values 0 and 1. A value of 0 indicates that the preset range is not used, and a value of 1 indicates that the preset range is used.
[0261] For example, the default value for the sixth identifier can be 0.
[0262] The values for the sixth identifier described above are for illustrative purposes only. Other enumerated values are also possible, or other methods can be used to indicate whether a preset range is used. For example, the sixth identifier is used to indicate whether a preset range is used (it should be understood that another identifier can also be used to indicate whether a preset range is used), such as a value of 0 indicating the use of a preset range, a value of 1 indicating the non-use of a preset range, and so on.
[0263] In some implementations, the second application programming interface may include a sixth identifier.
[0264] For example, the rendering device can execute a second application programming interface and, when indicated by a sixth identifier to use a preset range, determine, based on the first pixel, the shading points corresponding to one or more second pixels within the preset range of the first pixel; and obtain the occlusion points corresponding to the determined shading points.
[0265] In some implementations, obtaining the occlusion points corresponding to one or more shading points other than the first shading point in the scene based on the first pixel point corresponding to the first shading point specifically includes: obtaining the occlusion points corresponding to one or more shading points other than the first shading point based on the first pixel point and the mapping relationship.
[0266] The above mapping relationship is used to characterize the mapping relationship between the first pixel and the pixel corresponding to one or more color points other than the first color point.
[0267] For example, one or more second pixels other than the first pixel can be randomly selected from the scene, a mapping relationship between the first pixel and one or more second pixels can be established, and the occlusion points corresponding to one or more shading points other than the first shading point can be obtained based on the first pixel and the mapping relationship.
[0268] As shown in Figure 11, the black pixels in the figure are the first pixels corresponding to the first coloring point, the gray pixels in the figure are the randomly selected second pixels, and the white pixels in the figure are the pixels that were not randomly selected. A mapping relationship between the first pixel and one or more second pixels can be established. Based on the first pixel and the mapping relationship, the occlusion points corresponding to the coloring points of one or more second pixels can be obtained.
[0269] Figures 10 and 11 show the rendered images corresponding to a preset range and the rendered images corresponding to randomly selected pixels. Referring to Figures 10 and 11, the image rendered using randomly selected pixels shows a significant improvement in detail compared to the image rendered using a preset range. This difference is because the pixels selected randomly are more dispersed, allowing for the use of a larger area of occlusion points for coloring. This processing method effectively enhances the visual expressiveness of the rendering effect, resulting in a more delicate and refined image.
[0270] Understandably, by introducing mapping relationships, the computational complexity required to obtain the occlusion points corresponding to one or more shading points other than the first shading point can be further reduced. This is because the mapping relationships are pre-established, and other shading points associated with the first pixel and their corresponding occlusion points can be quickly found directly using these relationships. This method not only improves computational efficiency but also optimizes resource utilization, enabling high performance and stability when handling complex scenes and large amounts of data. Furthermore, the introduction of mapping relationships makes the algorithm more flexible and scalable, adapting to changes in different scenarios and requirements.
[0271] In some implementations, obtaining the occlusion points corresponding to one or more color points other than the first color point based on the first pixel and the mapping relationship specifically includes: obtaining a seventh identifier; and, when the seventh identifier indicates the use of the mapping relationship, obtaining the occlusion points corresponding to one or more color points other than the first color point based on the first pixel and the mapping relationship.
[0272] The seventh identifier is used to indicate whether a mapping relationship is used.
[0273] For example, the seventh identifier can take the values 0 and 1. A value of 0 indicates that no mapping relationship is used, and a value of 1 indicates that a mapping relationship is used.
[0274] For example, the default value for the seventh identifier can be 0.
[0275] The values for the seventh identifier described above are for illustrative purposes only. Other enumerated values are also possible, or other methods can be used to indicate whether a mapping relationship is used. For example, the seventh identifier is used to indicate whether a mapping relationship is used (it should be understood that another identifier can also be used to indicate whether a mapping relationship is used), such as a value of 0 indicating that a mapping relationship is used, a value of 1 indicating that a mapping relationship is not used, and so on.
[0276] In some implementations, the second application programming interface may include a seventh identifier.
[0277] For example, the rendering device can execute a second application programming interface and, when the seventh identifier indicates the use of a mapping relationship, obtain occlusion points corresponding to one or more shading points other than the first shading point based on the first pixel point and the mapping relationship.
[0278] In some implementations, the mapping relationship includes the grouping information of the first pixel, and the first pixel and the pixels corresponding to one or more color points other than the first color point are in the same group. Obtaining the occlusion point corresponding to one or more color points other than the first color point according to the first pixel and the mapping relationship specifically includes: obtaining the occlusion point corresponding to one or more color points other than the first color point according to the first pixel and the grouping information.
[0279] For example, based on the grouping information of the first pixel, find one or more pixels in the same pixel group, and obtain the occlusion points of the shading points corresponding to one or more pixels in the same pixel group.
[0280] Understandably, introducing grouping information can significantly reduce the computational complexity required to obtain the occlusion points corresponding to one or more chromatic points other than the first chromatic point. This is because grouping information categorizes pixels with similar characteristics together, allowing for the rapid identification of other chromatic points associated with the first pixel and their corresponding occlusion points. This method not only improves computational efficiency but also optimizes resource utilization, maintaining high performance and stability when handling complex scenes and large amounts of data. Furthermore, the introduction of grouping information makes the algorithm more flexible and scalable, adapting to changes in different scenarios and requirements.
[0281] In some implementations, the occlusion points corresponding to one or more of the aforementioned shading points, other than the first shading point, are obtained through a shared memory unit.
[0282] For example, the shared storage unit can be queried to obtain the occlusion points corresponding to one or more occlusion points other than the first occlusion point mentioned above.
[0283] In this context, a shared storage unit can be a storage unit that is accessed by one or more computing units. A shared storage unit can be a multi-level cache (such as an L1-level cache or an L2-level cache), a register file, or shared memory.
[0284] For example, the computing unit corresponding to the first shaded point can access shared memory to obtain information about occlusion points corresponding to one or more shaded points other than the first shaded point.
[0285] The information about the occluded point may include at least one of its location, normal direction, or sampling probability. The sampling probability of the occluded point refers to the random sampling direction of the occluded point within the aforementioned hemispherical space.
[0286] Understandably, since each computational unit can access the shared memory unit, the occlusion points of all shaded points can be stored in this shared memory unit. In this way, when each computational unit processes the first shaded point, it can access this shared memory unit to obtain the occlusion points shared by other computational units. Using these shared occlusion points, the computational units can perform more precise and detailed processing on the first shaded point, thereby significantly improving the overall quality of the rendered image.
[0287] Specifically, in practice, sharing occlusion points involves the flow of these points between local computing units. Many graphics hardware devices, such as GPUs, are designed with the ability to quickly share information between local computing units, such as the SIMT architecture. In the embodiments of this application, the information transmission operation of occlusion points can be implemented using the SIMT architecture.
[0288] It is understood that by utilizing the fast sharing mechanism of local computing units within the hardware to transmit occlusion points, this process can significantly reduce the bandwidth overhead problem faced by the solution provided in this application embodiment during runtime, and effectively reduce the latency of data transmission, thereby further improving the overall performance of the program.
[0289] In some implementations, the GPU can execute multiple threads in parallel, and these threads can share data. For example, each thread can execute a point shading process. A thread executing a point shading process can obtain occlusion points generated by other threads executing point shading processes. For instance, a thread executing a point shading process can write the occlusion point corresponding to the corresponding shading point into the aforementioned shared memory unit.
[0290] For example, threads performing the coloring process of colored points can achieve inter-thread sharing of occlusion points through the subgroup feature in Vulkan.
[0291] For example, thread 1 can implement the coloring process for shading point 1, and thread 2 can implement the coloring process for shading point 2. Thread 1 can obtain the occlusion points generated during the coloring process of shading point 2 by thread 2.
[0292] In some implementations, obtaining the second set of occlusion points specifically includes: obtaining a shared set of occlusion points; and obtaining the second set of occlusion points from the shared set of occlusion points based on the first colored point.
[0293] The shared set of occlusion points is obtained based on the occlusion points corresponding to multiple shading points in the scene.
[0294] In some implementations, the shared set of occlusion points includes multiple shading points in the scene and the occlusion points corresponding to those shading points.
[0295] In some implementations, the shared set of occlusion points can have a specific data structure that provides the ability to query or access the occlusion points corresponding to the colored points.
[0296] In some implementations, the data structure of the shared set of occlusion points can be a tree structure, such as a binary tree, ternary tree, or multi-branch tree. For example, a binary tree structure is shown in Figure 12. The nodes in the figure correspond to a shading point in the scene or a shading point and its corresponding occlusion point.
[0297] In other implementations, the data structure for the shared set of occlusion points can be a grouped structure. For example, multiple occluded points with adjacent pixel positions can be grouped together according to their pixel positions. For instance, as shown in Figure 13, a solid box represents a occluded point, a black box and its surrounding eight gray boxes (each gray box representing a occluded point) form a small group, and the four dashed boxes in the upper left corner (each dashed box representing a small group) form a large group.
[0298] For example, the grouping structure described above can be a single-layer grouping structure or a multi-layer grouping structure. For instance, a two-layer grouping structure, a three-layer grouping structure, a four-layer grouping structure, or a more than one-layer grouping structure.
[0299] In some implementations, obtaining the shared set of occlusion points specifically includes: constructing a shared set of occlusion points based on multiple shading points in the scene. Here, the multiple first shading points include first shading points.
[0300] In some implementations, obtaining the second occlusion point set from the shared set of occlusion points based on the first shading point specifically includes:
[0301] For example, inputting the color point information of the first color point into the occlusion point sharing set can yield the second occlusion point set.
[0302] In some implementations, as shown in Figure 12, the second occlusion point set may include all occlusion points within a certain distance of the first shading point. This shared occlusion point set is used to quickly remove occlusion points that are far from the first shading point. The shared occlusion point set may store spatial information, such as bounding boxes, for quick removal in intermediate nodes or large groups. For example, the second occlusion point set can be obtained based on the aforementioned spatial information.
[0303] S403. Based on the second set of occlusion points and the scene data of the scene, color the first color point.
[0304] In some implementations, S403 can be encapsulated as a fourth application programming interface (API) for ray tracing rendering. For example, the fourth API could be an OpenGL, Vulkan, or EGL API. That is, the fourth API can be used to shade the first shading point based on a second set of occlusion points and scene data of the scene.
[0305] For example, when the fourth application programming interface includes inputs, the inputs to the fourth application programming interface may be one or more of the following: a first set of occlusion points, a second set of occlusion points, scene data of the scene, the initial illumination value of the first shading point, and an occlusion relationship auxiliary structure.
[0306] For example, if the fourth application programming interface includes an output, the output of the fourth application programming interface may be the illumination value of the first shading point.
[0307] In some implementations, the first shading point is shaded based on the second occlusion point set and the scene data. Specifically, the first shading point is shaded according to the initial illumination value of the first shading point, the second occlusion point set, and the scene data.
[0308] The initial illumination value of the first shading point refers to the illumination intensity of the shading point when there is no occlusion.
[0309] In some implementations, the above-mentioned coloring of the first shading point based on the initial illumination value of the first shading point, the second occlusion point set, and scene data specifically includes: obtaining an eighth identifier; and, when the eighth identifier indicates the use of the initial illumination value, coloring the first shading point based on the initial illumination value of the first shading point, the second occlusion point set, and scene data.
[0310] The eighth indicator is used to indicate whether the initial illumination value is used.
[0311] For example, the eighth identifier can take the values 0 and 1. A value of 0 indicates that the initial illumination value is not used, and a value of 1 indicates that the initial illumination value is used.
[0312] For example, the default value for the eighth identifier can be 0.
[0313] The values for the eighth flag described above are for illustrative purposes only. Other enumerated values are also possible, or other methods can be used to indicate whether the initial lighting value is used. For example, the eighth flag is used to indicate whether the initial lighting value is used (it should be understood that another flag can also be used to indicate whether the initial lighting value is used), such as a value of 0 indicating the use of the initial lighting value, a value of 1 indicating the non-use of the initial lighting value, and so on.
[0314] In some implementations, the fourth application programming interface may include an eighth identifier.
[0315] For example, the rendering device can execute a fourth application programming interface and, when the eighth identifier indicates the use of the initial illumination value of the first shading point, shade the first shading point according to the initial illumination value of the first shading point, the second occlusion point set, and the scene data.
[0316] As shown in Figure 14, for a shading point illuminated by RTAO, its initial illumination value can be obtained by first forming a hemispherical space centered on the normal direction of the shading point. Within this hemispherical space, directions are randomly sampled, with different directions having different sampling probabilities. Integrating over the hemispherical space yields the integral formula corresponding to the illumination value of the shading point: AO(x)=∫V(x,θ,r)cosθdθ
[0317] In the case of no obstruction (i.e., V(x,θ,r)=1 always holds true), the integral ∫V(x,θ,r)cos(n,θ)dθ over the hemispherical space has a value equal to 1. Therefore, the initial illumination value of the shading point under RTAO illumination is 1.
[0318] For a shading point illuminated by an ambient light source, its initial illumination value can be obtained by integration, or by randomly sampling or pre-setting one or more points on the light source, and then using these light source points and the illumination formula to calculate the illumination value of the first shading point.
[0319] For a colored point illuminated by a surface light source, its initial illumination value can also be obtained through integration.
[0320] For a colored point illuminated by an irregular surface light source, its initial illumination value can be obtained by randomly sampling or by selecting one or more points on the light source in a pre-defined manner, and then calculating the initial illumination value of the first colored point based on these light source points and the illumination formula.
[0321] Understandably, by analyzing occlusion points, the amount of lighting lost by the shading point due to occlusion can be calculated. This process requires precise analysis of the relative positions and orientations of objects in the scene. Subsequently, by combining the initial lighting and the lighting loss due to occlusion, the actual lighting value of the shading point can be obtained. This actual lighting value comprehensively considers both direct illumination from the light source and occlusion caused by scene geometry, thus ensuring the realism and accuracy of the rendering effect.
[0322] In some implementations, the amount of illumination lost by the first shading point due to occlusion can also be determined. The difference between the initial illumination value of the first shading point and the amount of illumination lost due to occlusion is used as the output illumination value of the first shading point, i.e., the illumination value obtained after shading.
[0323] The specific implementation method for determining the illumination value lost by the first colored point due to the occlusion point can be any implementation method that can be conceived by those skilled in the art, and the embodiments of this application do not limit it.
[0324] For example, for each occluded point in the second occluded point set, the random sampling direction of the hemispherical space corresponding to the first shading point and the sampling direction probability corresponding to each occluded point can be found. Based on the random sampling direction corresponding to each occluded point in the second occluded point set, the illumination correction value of each occluded point in the second occluded point set can be determined. Based on the sampling direction probability corresponding to each occluded point in the second occluded point set and the illumination correction value of each occluded point in the second occluded point set, the occlusion illumination value of each occluded point in the second occluded point set can be determined. Based on the occlusion illumination value of each occluded point in the second occluded point set, the illumination value lost by the first shading point due to the occlusion point can be obtained.
[0325] The light loss of the first shading point due to occlusion can be obtained by the average or weighted average of the occlusion light values of all occluded points in the second set of occluded points.
[0326] The shading value at the shading point can satisfy: B = f / p
[0327] B is the occlusion illumination value of the occluded point, f is the illumination value correction value of the occluded point, and p is the sampling direction probability corresponding to the occluded point.
[0328] As shown in Figure 15, in some implementations, the above S403 may include S1501 and S1502.
[0329] S1501. Perform occlusion testing on the second set of occlusion points to obtain the third set of occlusion points.
[0330] The third set of occlusion points includes the occlusion points in the second set of occlusion points that passed the occlusion test.
[0331] For example, an occlusion test can be performed on the second set of occlusion points to obtain the third set of occlusion points based on the occlusion relationship auxiliary structure.
[0332] The aforementioned occlusion relationship auxiliary structure includes the probability that the occlusion point of the shading point in each scene block of the above scene passes the occlusion test.
[0333] For example, a scene consists of four scene blocks, with the first shading point located in scene block 2. Based on the occlusion relationship auxiliary structure, the probability of an occluded point in scene block 2 passing the occlusion test is 70%. Therefore, this auxiliary structure can be used to select 30% of the occluded points in the second occlusion point set for occlusion testing to obtain the third occlusion point set.
[0334] In the case where the third set of occlusion points is obtained by performing occlusion tests on the second set of occlusion points based on the occlusion relationship auxiliary structure, the third set of occlusion points includes the occlusion points in the second set of occlusion points that have passed the occlusion test and the occlusion points that have not undergone the occlusion test.
[0335] In some implementations, the above-mentioned method of performing occlusion testing on the second set of occlusion points to obtain the third set of occlusion points based on the occlusion relationship auxiliary structure specifically includes: obtaining the ninth identifier; and, when the ninth identifier indicates the use of the occlusion relationship auxiliary structure, performing occlusion testing on the second set of occlusion points to obtain the third set of occlusion points based on the occlusion relationship auxiliary structure.
[0336] The ninth identifier is used to indicate whether an occlusion relationship auxiliary structure is used for occlusion testing.
[0337] For example, the ninth identifier can take the values 0 and 1. A value of 0 indicates that the occlusion relationship auxiliary structure is not used for occlusion testing, while a value of 1 indicates that the occlusion relationship auxiliary structure is used for occlusion testing.
[0338] For example, the default value for the ninth identifier can be 0.
[0339] The values for the ninth flag described above are for illustrative purposes only. Other enumerated values are also possible, or other methods can be used to indicate whether to use the occlusion relationship auxiliary structure for occlusion testing. For example, the ninth flag is used to indicate whether to use the occlusion relationship auxiliary structure for occlusion testing (it should be understood that another flag can also be used to indicate whether to use the occlusion relationship auxiliary structure for occlusion testing), such as a value of 0 indicating that the occlusion relationship auxiliary structure is used for occlusion testing, a value of 1 indicating that the occlusion relationship auxiliary structure is not used for occlusion testing, and so on.
[0340] In some implementations, the fourth application programming interface may include the ninth identifier.
[0341] For example, the rendering device can execute a fourth application programming interface and, when the ninth identifier indicates the use of an occlusion relationship auxiliary structure, perform an occlusion test on the second set of occlusion points to obtain a third set of occlusion points based on the occlusion relationship auxiliary structure.
[0342] S1502. Based on the third occlusion point set and the scene data of the scene, color the first color point.
[0343] Understandably, when using occlusion points for shading, if the occlusion point is not the first occlusion point on the ray tracing direction of the first shading point, it may introduce some error into the rendering result. To eliminate this potential error, occlusion tests should be performed on the acquired occlusion points to determine whether to use them. This method can effectively improve the accuracy of the rendering results.
[0344] For example, the first shading point is shading based on the initial illumination value of the first shading point, the third occlusion point set, and the scene data of the scene.
[0345] As shown in Figure 16, in some implementations, the above S403 may include S1501, S1502 and S1503.
[0346] S1503. Update the occlusion relationship auxiliary structure based on the occlusion test results.
[0347] For example, suppose a scene consists of four scene blocks, with the first shading point located in scene block 2. Before the occlusion relationship auxiliary structure is updated, the probability of an occluded point in scene block 2 passing the occlusion test, as recorded by the auxiliary structure, is 70%. Performing an occlusion test on the aforementioned second set of occluded points shows that the probability of occluded points in the second set of occluded points of the first shading point passing the occlusion test is 80%. Based on this occlusion test result, the probability of an occluded point in scene block 2 passing the occlusion test, as recorded by the auxiliary structure, can be adjusted from 70% to 80%.
[0348] In some implementations, when the third occlusion point set is obtained by performing occlusion testing on the second occlusion point set based on the occlusion relationship auxiliary structure, the probability of passing the occlusion test in the occlusion test result is obtained based on the actual number of occlusion points that are tested and the actual number of occlusion points that pass the occlusion test.
[0349] For example, the second set of occlusion points includes 100 occlusion points. Based on the occlusion relationship auxiliary structure, 30 occlusion points are selected for occlusion testing. Among these 30 occlusion points, 24 occlusion points pass the occlusion test. Therefore, the probability of passing the occlusion test in the occlusion test results is 80%.
[0350] In some implementations, the initial probability of a shading point in each scene block of the aforementioned occlusion relationship auxiliary structure passing the occlusion test can be 0 or a random number.
[0351] Understandably, by constructing and updating the occlusion relationship auxiliary structure, the proportion of occlusion points in the second occlusion point set that require occlusion testing can be determined more accurately. This significantly reduces unnecessary occlusion testing, thereby improving the efficiency of ray tracing rendering. In practical applications, the second occlusion point set typically contains a large number of occlusion points. Performing occlusion testing on every single occlusion point would consume significant computational resources and time. By utilizing the occlusion relationship auxiliary structure, it can be assumed that a portion of the occlusion points in the second occlusion point set have passed the occlusion test, while another portion has failed. In this way, only those occlusion points that have failed the test need to be tested, reducing the required computation, optimizing the rendering process, and improving overall rendering performance.
[0352] In some implementations, updating the occlusion relationship auxiliary structure based on the occlusion test results specifically includes: obtaining the tenth identifier; and updating the occlusion relationship auxiliary structure based on the occlusion test results when the tenth identifier indicates that the occlusion test results should be used to update the occlusion relationship auxiliary structure.
[0353] The tenth identifier is used to indicate whether the occlusion relationship auxiliary structure is updated using the results of the occlusion test.
[0354] For example, the tenth identifier can take the values 0 and 1. A value of 0 indicates that the occlusion relationship auxiliary structure is not updated using the results of the occlusion test, while a value of 1 indicates that the occlusion relationship auxiliary structure is updated using the results of the occlusion test.
[0355] For example, the tenth identifier can have a default value of 0.
[0356] The values for the tenth flag described above are for illustrative purposes only. Other enumerated values are also possible, or other methods can be used to indicate whether the occlusion test results are used to update the occlusion relationship auxiliary structure. For example, the tenth flag is used to indicate whether the occlusion test results are used to update the occlusion relationship auxiliary structure (it should be understood that another flag can also be used to indicate whether the occlusion test results are used to update the occlusion relationship auxiliary structure). For example, a value of 0 indicates that the occlusion test results are used to update the occlusion relationship auxiliary structure, a value of 1 indicates that the occlusion test results are not used to update the occlusion relationship auxiliary structure, and so on.
[0357] In some implementations, the fourth application programming interface may include the tenth identifier.
[0358] For example, the rendering device can execute the fourth application programming interface and, if the tenth identifier indicates that the occlusion relationship auxiliary structure should be updated, update the occlusion relationship auxiliary structure based on the results of the occlusion test.
[0359] The solution provided in this application, when processing each shading point, not only considers the occlusion points of that point itself, but also integrates the occlusion points of other shading points in the same scene. Through this comprehensive consideration, the perception ability of each shading point to its surrounding environment can be significantly improved without increasing the computational overhead of intersection calculations. This improved perception ability results in a significant improvement in the quality of the rendered image, thereby bringing users a richer and more realistic visual experience.
[0360] In some implementations, the application programming interfaces involved in the embodiments of this application can be combined with each other.
[0361] For example, the first application programming interface (API) can be combined with the second API, so that the combined API has the capabilities of both the first and second APIs.
[0362] For example, a second application programming interface (API) can be combined with a third API, so that the combined API has the capabilities of both the second and third APIs.
[0363] For example, the third application programming interface can be combined with the fourth application programming interface to give the combined application programming interface the capabilities of both the second and third application programming interfaces.
[0364] In some implementations, multiple application programming interfaces in this application embodiment may include the same identifier.
[0365] For example, both the first application programming interface and the third application programming interface include a third identifier.
[0366] For example, both the first and fourth application programming interfaces include an eighth identifier.
[0367] Through the above steps S401 to S403, and in conjunction with Figure 17, it can be seen that the embodiments of this application, when processing each shading point, not only consider the occlusion points of that point itself, but also integrate the occlusion points of other shading points in the same scene. This comprehensive consideration significantly improves the perception ability of each shading point of its surrounding environment without increasing the computational overhead of intersection calculations. This enhanced perception ability significantly improves the quality of the rendered image, thereby providing users with a richer and more realistic visual experience.
[0368] Figure 18 illustrates a technical solution related to an embodiment of this application and a rendering provided by that embodiment. A comparison clearly shows that the rendering provided by this embodiment produces less noise in visual effects compared to renderings in the prior art, thereby significantly improving the overall quality of the rendering result.
[0369] The following describes an apparatus for performing the above-described method of rendering a scene based on ray tracing.
[0370] It is understood that, in order to achieve the above-mentioned functions, a device for rendering scenes based on ray tracing includes hardware and / or software modules that perform the respective functions. Based on the algorithmic steps of the examples described in the embodiments disclosed herein, the embodiments of this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in conjunction with the embodiments, but such implementation should not be considered beyond the scope of the embodiments of this application.
[0371] This application embodiment can divide the device for rendering scenes based on ray tracing into functional modules according to the above method example. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware. It should be noted that the module division in this embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.
[0372] Figure 19 illustrates another method for rendering a scene based on ray tracing provided in an embodiment of this application. As shown in Figure 19, the method includes:
[0373] S1901. Determine the set of first occlusion points corresponding to the first shading point in the scene data of the scene.
[0374] S1902, Obtain the fourth set of occlusion points.
[0375] The fourth set of occlusion points includes occlusion points corresponding to one or more shading points in the above scene, excluding the first shading point.
[0376] S1903. Based on the first occlusion point set, the fourth occlusion point set, and the scene data, color the first color point.
[0377] It is understandable that the fourth set of occlusion points includes the occlusion points corresponding to one or more shading points in the above scene, excluding the first shading point mentioned above.
[0378] In some implementations, the second occlusion point set can be obtained from the first occlusion point set and the fourth occlusion point set.
[0379] The specific implementation methods of S1901 to S1903 above can be referred to the relevant content in S401 to S403 above, and will not be repeated here.
[0380] Figure 20 illustrates a possible configuration of the ray tracing-based rendering scene device described in the above embodiments, where each functional module is divided according to its corresponding function. This device can be a rendering device (i.e., a device with rendering capabilities), a module applied to the rendering device (e.g., a processor, chip, or chip system), or a logic node, logic module, or software capable of implementing all or part of the rendering device's functions. As shown in Figure 20, the ray tracing-based rendering scene device 2000 may include: a determining unit 2001, an acquiring unit 2002, and a shading unit 2003.
[0381] The determining unit 2001 is used to determine the set of first occlusion points corresponding to the first shading point in the scene data of the above scene based on the ray tracing algorithm.
[0382] The acquisition unit 2002 is used to acquire a second set of occlusion points, which includes the first set of occlusion points and occlusion points corresponding to one or more shading points in the scene other than the first shading point.
[0383] The shading unit 2003 is used to shade the first shading point according to the second occlusion point set and the above scene data.
[0384] In some implementations, the aforementioned device is encapsulated as a first application programming interface for ray tracing rendering.
[0385] In some implementations, the first application programming interface includes a first identifier, which is used to indicate whether to acquire the second set of occlusion points. The acquisition unit 2002 is specifically used to acquire the second set of occlusion points according to the first identifier.
[0386] In some implementations, the first application programming interface includes a second identifier, which is used to indicate sharing mode information, including one or more mode information. The acquisition unit 2002 is specifically used to: acquire the second set of occlusion points according to the second identifier.
[0387] In some implementations, the information about the occlusion point includes at least one of the following: the location of the occlusion point, the normal direction, or the sampling probability.
[0388] In some implementations, the acquisition unit 2002 is further configured to: acquire the occlusion point corresponding to one or more color points other than the first color point based on the first pixel point corresponding to the first color point.
[0389] In some implementations, the acquisition unit 2002 is specifically used to: determine, based on the first pixel, one or more second pixels within a preset range of the first pixel, corresponding to their respective coloring points; and acquire the occlusion points corresponding to the determined coloring points.
[0390] In some implementations, the acquisition unit 2002 is specifically used to: acquire the occlusion points corresponding to one or more color points other than the first color point according to the first pixel point and the mapping relationship, wherein the mapping relationship is used to characterize the mapping relationship between the first pixel point and one or more color points other than the first color point.
[0391] In some implementations, the mapping relationship includes the grouping information of the first pixel, and the first pixel and one or more color points other than the first color point are in the same group. The acquisition unit 2002 is specifically used to: acquire the occlusion point corresponding to one or more color points other than the first color point according to the first pixel and the grouping information.
[0392] In some implementations, the occlusion points corresponding to one or more of the aforementioned shading points, other than the first shading point, are obtained through a shared memory unit.
[0393] In some implementations, the acquisition unit 2002 is further configured to: acquire a shared set of occlusion points, the shared set of occlusion points being obtained based on the occlusion points corresponding to multiple shading points in the above scene; and acquire the second set of occlusion points from the shared set of occlusion points according to the first shading point.
[0394] In some implementations, the determining unit 2001 is specifically used to: obtain the ray tracing direction of the first shading point; and obtain the first occlusion point set based on the ray tracing direction.
[0395] In some implementations, the aforementioned determining unit 2001 is specifically used to: obtain a random number; and obtain the aforementioned ray tracing direction based on the random number.
[0396] In some implementations, the determining unit 2001 is specifically used to: obtain the ray tracing direction according to the type of light source.
[0397] In some implementations, the aforementioned determining unit 2001 is specifically used to: obtain a noise map; and obtain the aforementioned ray tracing direction based on the noise map.
[0398] In some implementations, the determining unit 2001 is specifically used to: construct a ray tracing acceleration structure based on the scene data; and obtain the first occlusion point set according to the ray tracing acceleration structure, the ray tracing direction, and the position of the first shading point.
[0399] In some implementations, the shading unit 2003 is specifically used to: perform occlusion testing on the second occlusion point set according to the occlusion relationship auxiliary structure to obtain a third occlusion point set, wherein the occlusion relationship auxiliary structure is used to record the probability that the occlusion point of the shading point in the scene block of each scene passes the occlusion test, and the third occlusion set includes the occlusion points in the second occlusion point set that pass the occlusion test; and shading the first shading point according to the third occlusion point set and the scene data.
[0400] In some implementations, the aforementioned coloring unit 2003 is also used to update the aforementioned occlusion relationship auxiliary structure based on the results of the aforementioned occlusion test.
[0401] In some implementations, the shading unit 2003 is specifically used to: shade the first shading point according to the initial illumination value of the first shading point, the second occlusion point set, and the scene data.
[0402] This application also provides a chip, which can be the chip of the aforementioned ray tracing-based scene rendering device. Figure 21 shows a schematic diagram of the structure of a chip 2200. The chip 2200 includes one or more processors 2201 and interface circuits 2202.
[0403] For example, chip 2200 can be a GPU.
[0404] Optionally, the chip 2200 may also include a bus 2203.
[0405] Processor 2201 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above-described method for rendering scenes based on ray tracing can be completed through integrated logic circuits in the hardware of processor 2201 or through software instructions.
[0406] Optionally, the processor 2201 described above can be a general-purpose processor, a digital signal processing (DSP) processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the various methods and steps disclosed in the embodiments of this application. The general-purpose processor can be a microprocessor or any conventional processor, etc.
[0407] The interface circuit 2202 can be used to send or receive data, instructions or information. The processor 2201 can use the data, instructions or other information received by the interface circuit 2202 to process the data, instructions or other information, and can send the processed information out through the interface circuit 2202.
[0408] Optionally, the chip may also include memory, which may include read-only memory and random access memory, providing operation instructions and data to the processor. A portion of the memory may also include non-volatile random access memory (NVRAM).
[0409] Optionally, the memory stores executable software modules or data structures, and the processor can execute corresponding operations by calling the operation instructions stored in the memory (which may be stored in the operating system).
[0410] Optionally, the chip can be used in the ray tracing-based scene rendering apparatus or the ray tracing-based scene rendering apparatus involved in the embodiments of this application. Optionally, the interface circuit 2202 can be used to output the execution result of the processor 2201. For the methods of ray tracing-based scene rendering provided by one or more embodiments of the present application, please refer to the foregoing embodiments, which will not be repeated here.
[0411] It should be noted that the functions of the processor 2201 and the interface circuit 2202 can be implemented through hardware design, software design, or a combination of hardware and software; no restrictions are imposed here.
[0412] Figure 22 is a schematic diagram of an electronic device provided in an embodiment of this application. The electronic device can be a device for rendering scenes based on ray tracing, or a chip or functional module in a device for rendering scenes based on ray tracing. As shown in Figure 22, the electronic device 2200 includes a processor 2201, a transceiver 2202, and a communication line 2203.
[0413] The processor 2201 is used to execute any step of the method for rendering a scene based on ray tracing provided in the embodiments of this application. In the process of executing any step of the method for rendering a scene based on ray tracing provided in the embodiments of this application, the transceiver 2202 and the communication line 2203 may be called to complete the corresponding operation.
[0414] Furthermore, the electronic device 2200 may also include a memory 2204. The processor 2201, the memory 2204, and the transceiver 2202 can be connected via a communication line 2203.
[0415] The processor 2201 can be a processor, a general-purpose processor, a network processor (NP), a digital signal processor (DSP), a microprocessor, a microcontroller, a programmable logic device (PLD), or any combination thereof. The processor 2201 can also be other devices with processing capabilities, such as circuits, devices, or software modules, without limitation.
[0416] Transceiver 2202 is used to communicate with other devices or other communication networks, such as Ethernet, radio access network (RAN), wireless local area network (WLAN), etc. Transceiver 2202 can be a module, circuit, transceiver, or any device capable of enabling communication.
[0417] The transceiver 2202 is mainly used for sending and receiving commands and information, and may include a transmitter and a receiver to send and receive commands and information, respectively; operations other than sending and receiving commands and information are implemented by the processor.
[0418] Communication line 2203 is used to transmit information between the components included in electronic device 2200.
[0419] In one design, the processor can be viewed as a logic circuit, and the transceiver as an interface circuit.
[0420] The memory 2204 is used to store instructions. These instructions can be computer programs.
[0421] The memory 2204 can be volatile memory or non-volatile memory, or it can include both. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM). Memory 2204 can also be a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed discs, laser discs, optical discs, digital universal discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices. It should be noted that the memory in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0422] It should be noted that the memory 2204 can exist independently of the processor 2201, or it can be integrated with the processor 2201. The memory 2204 can be used to store instructions, program code, or some data, etc. The memory 2204 can be located inside or outside the electronic device 2200, without limitation. The processor 2201 is used to execute the instructions stored in the memory 2204 to implement the method provided in the above embodiments of this application.
[0423] In one example, processor 2201 may include one or more processor cores, such as processor core 0 and processor core 1 in Figure 22.
[0424] As an optional implementation, the electronic device 2200 may include multiple processors, for example, in addition to processor 2201 in FIG22, it may also include processor 2207.
[0425] As an optional implementation, the electronic device 2200 also includes an output device 2205 and an input device 2206. For example, the input device 2206 is a device such as a keyboard, mouse, microphone, or joystick, and the output device 2205 is a device such as a display screen or speaker.
[0426] It should be noted that the electronic device 2200 can be a chip system or a device with a similar structure to that shown in Figure 22. The chip system can be composed of chips or include chips and other discrete components. Actions, terms, etc., involved in the various embodiments of this application can be referenced interchangeably without limitation. The message names or parameter names in the messages used for interaction between devices in the embodiments of this application are merely examples; other names can be used in specific implementations without limitation. Furthermore, the composition structure shown in Figure 22 does not constitute a limitation on the electronic device 2200. In addition to the components shown in Figure 22, the electronic device 2200 may include more or fewer components than those shown in Figure 22, or combine certain components, or have different component arrangements.
[0427] The processor and transceiver described in this application can be implemented on integrated circuits (ICs), analog ICs, radio frequency integrated circuits, mixed-signal ICs, application-specific integrated circuits (ASICs), printed circuit boards (PCBs), electronic devices, etc. The processor and transceiver can also be manufactured using various IC process technologies, such as complementary metal oxide semiconductors (CMOS), n-metal-oxide-semiconductor (NMOS), p-type metal oxide semiconductors (PMOS), bipolar junction transistors (BJTs), bipolar CMOS (BiCMOS), silicon germanium (SiGe), gallium arsenide (GaAs), etc.
[0428] This application also provides an apparatus for rendering a scene based on ray tracing. The apparatus includes at least one processor, which, when executing program code or instructions, implements the aforementioned method steps to achieve the method for rendering a scene based on ray tracing in the above embodiments.
[0429] Optionally, the device may further include at least one memory for storing the program code or instructions.
[0430] This application also provides a computer storage medium storing computer instructions. When the computer instructions are run on a device for rendering a scene based on ray tracing, the device for rendering a scene based on ray tracing executes the aforementioned related method steps to implement the method for rendering a scene based on ray tracing in the above embodiments.
[0431] This application also provides a computer program product that, when run on a computer, causes the computer to perform the aforementioned steps to implement the ray tracing-based scene rendering method described in the above embodiments.
[0432] This application also provides an apparatus for rendering a scene based on ray tracing. This apparatus may specifically be a chip, integrated circuit, component, or module. Specifically, the apparatus may include a connected processor and a memory for storing instructions, or the apparatus may include at least one processor for fetching instructions from external memory. When the apparatus is running, the processor can execute instructions to cause the chip to perform the methods for rendering scenes based on ray tracing as described in the above method embodiments.
[0433] It should be understood that in various embodiments of this application, the sequence number of each process does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of this application.
[0434] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this application.
[0435] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0436] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of the units described above is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0437] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0438] In addition, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0439] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of this application, essentially, or the parts that contribute to the prior art, or parts of the technical solutions, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0440] The above description is merely a specific implementation of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the embodiments of this application should be included within the protection scope of the embodiments of this application. Therefore, the protection scope of the embodiments of this application should be determined by the protection scope of the claims.
Claims
1. A method for rendering a scene based on ray tracing, characterized in that, The method includes: Determine the set of first occlusion points corresponding to the first shading point in the scene data of the scene; Obtain a second set of occlusion points, the second set of occlusion points including the first set of occlusion points and occlusion points corresponding to one or more shading points in the scene other than the first shading point; The first shading point is shading based on the second set of occlusion points and the scene data.
2. The method according to claim 1, characterized in that, The method is encapsulated as a first application programming interface for ray tracing rendering.
3. The method according to claim 2, characterized in that, The process of obtaining the second set of occlusion points includes: Based on the first identifier, the second set of occlusion points is obtained, wherein the first identifier is used to indicate whether the second set of occlusion points is obtained.
4. The method according to claim 2 or 3, characterized in that, The acquisition of the second set of occlusion points includes: Based on the second identifier, the second set of occlusion points is obtained. The second identifier is used to indicate sharing mode information, which includes one or more mode information.
5. The method according to any one of claims 1 to 4, characterized in that, The method further includes: Obtain the occlusion points corresponding to one or more occlusion points other than the first occlusion point based on the first pixel point corresponding to the first occlusion point.
6. The method according to claim 5, characterized in that, The step of obtaining the occlusion points corresponding to one or more color points other than the first color point based on the first pixel point corresponding to the first color point includes: Based on the first pixel, determine the color points corresponding to one or more second pixels within a preset range from the first pixel; Obtain the occlusion point corresponding to the determined color point.
7. The method according to claim 5, characterized in that, The step of obtaining the occlusion points corresponding to one or more color points other than the first color point based on the first pixel point corresponding to the first color point includes: Obstruction points corresponding to one or more color points other than the first color point are obtained based on the first pixel point and the mapping relationship. The mapping relationship is used to characterize the mapping relationship between the first pixel point and the pixel points corresponding to one or more color points other than the first color point.
8. The method according to claim 7, characterized in that, The mapping relationship includes grouping information of the first pixel, wherein the first pixel and the pixels corresponding to one or more color points other than the first color point are in the same group. Obtaining the occlusion points corresponding to the one or more color points other than the first color point based on the first pixel and the mapping relationship includes: Obstruction points corresponding to one or more color points other than the first color point are obtained based on the first pixel and the grouping information.
9. The method according to any one of claims 1 to 8, characterized in that, The occlusion points corresponding to one or more occlusion points other than the first occlusion point are obtained through a shared storage unit. The occlusion points corresponding to one or more occlusion points other than the first occlusion point stored in the shared storage unit are written by the thread that occludes the one or more occlusion points.
10. The method according to any one of claims 1 to 5, characterized in that, The method for obtaining the second set of occlusion points includes: Obtain a shared set of occlusion points, which is obtained based on the occlusion points corresponding to multiple shading points in the scene; The second occlusion point set is obtained from the shared set of occlusion points based on the first shading point.
11. The method according to any one of claims 1 to 10, characterized in that, The step of determining the set of first occlusion points corresponding to the first shading point in the scene data based on the ray tracing algorithm includes: Obtain the ray tracing direction of the first shading point; The first set of occlusion points is obtained based on the ray tracing direction.
12. The method according to claim 11, characterized in that, The step of obtaining the ray tracing direction of the first shading point includes: Obtain at least one of the following: random number, light source type, and noise graph; The ray tracing direction is obtained based on at least one of the acquired random number, the light source type, and the noise map.
13. The method according to any one of claims 1 to 12, characterized in that, The step of coloring the first color point according to the second occlusion point set and the scene data includes: The first shading point is shading based on its initial illumination value, the second set of occlusion points, and the scene data.
14. The method according to claim 13, characterized in that, The step of coloring the first shading point based on its initial illumination value, the second set of occlusion points, and the scene data includes: According to the occlusion relationship auxiliary structure, an occlusion test is performed on the second occlusion point set to obtain a third occlusion point set. The occlusion relationship auxiliary structure includes the probability that the occlusion point of the shading point in each scene block of the scene passes the occlusion test. The third occlusion set includes the occlusion points in the second occlusion point set that pass the occlusion test. The first shading point is shading based on its initial illumination value, the third set of occlusion points, and the scene data.
15. The method according to claim 14, characterized in that, The method further includes: The occlusion relationship auxiliary structure is updated based on the results of the occlusion test.
16. A device for rendering scenes based on ray tracing, characterized in that, include: Determine the cell, acquire the cell, and color the cell; The determining unit is used to determine the first occlusion point set corresponding to the first shading point in the scene data of the scene; The acquisition unit is used to acquire a second set of occlusion points, the second set of occlusion points including the first set of occlusion points and occlusion points corresponding to one or more shading points in the scene other than the first shading point; The coloring unit is used to color the first coloring point according to the second occlusion point set and the scene data.
17. The apparatus according to claim 16, characterized in that, The acquisition unit is specifically used for: Based on the first identifier, the second set of occlusion points is obtained, wherein the first identifier is used to indicate whether the second set of occlusion points is obtained.
18. The apparatus according to claim 16 or 17, characterized in that, The acquisition unit is specifically used for: Based on the second identifier, the second set of occlusion points is obtained. The second identifier is used to indicate sharing mode information, which includes one or more mode information.
19. The apparatus according to any one of claims 16 to 18, characterized in that, The acquisition unit is used for: Obtain the occlusion points corresponding to one or more occlusion points other than the first occlusion point based on the first pixel point corresponding to the first occlusion point.
20. The apparatus according to claim 19, characterized in that, The acquisition unit is specifically used for: Based on the first pixel, determine the color points corresponding to one or more second pixels within a preset range from the first pixel; Obtain the occlusion point corresponding to the determined color point.
21. The apparatus according to claim 19, characterized in that, The acquisition unit is specifically used for: Obstruction points corresponding to one or more color points other than the first color point are obtained based on the first pixel point and the mapping relationship. The mapping relationship is used to characterize the mapping relationship between the first pixel point and the pixel points corresponding to one or more color points other than the first color point.
22. The apparatus according to claim 21, characterized in that, The mapping relationship includes grouping information for the first pixel, wherein the first pixel and the pixels corresponding to one or more color points other than the first color point are in the same group, and the acquisition unit is specifically used for: Obstruction points corresponding to one or more color points other than the first color point are obtained based on the first pixel and the grouping information.
23. The apparatus according to any one of claims 16 to 22, characterized in that, The occlusion points corresponding to one or more occlusion points other than the first occlusion point are obtained through a shared storage unit. The occlusion points corresponding to one or more occlusion points other than the first occlusion point stored in the shared storage unit are written by the thread that occludes the one or more occlusion points.
24. The apparatus according to any one of claims 16 to 18, characterized in that, The acquisition unit is used for: Obtain a shared set of occlusion points, which is obtained based on the occlusion points corresponding to multiple shading points in the scene; The second occlusion point set is obtained from the shared set of occlusion points based on the first shading point.
25. The apparatus according to any one of claims 16 to 24, characterized in that, The determining unit is specifically used for: Obtain the ray tracing direction of the first shading point; The first set of occlusion points is obtained based on the ray tracing direction.
26. The apparatus according to claim 25, characterized in that, The determining unit is specifically used for: Obtain at least one of the following: random number, light source type, and noise graph; The ray tracing direction is obtained based on at least one of the random number, the light source type, and the noise map.
27. The apparatus according to any one of claims 16 to 26, characterized in that, The coloring unit is specifically used for: The first shading point is shading based on its initial illumination value, the second set of occlusion points, and the scene data.
28. The apparatus according to claim 27, characterized in that, The coloring unit is specifically used for: According to the occlusion relationship auxiliary structure, an occlusion test is performed on the second occlusion point set to obtain a third occlusion point set. The occlusion relationship auxiliary structure is used to record the probability that the occlusion point of the shading point in the scene block of each scene passes the occlusion test. The third occlusion set includes the occlusion points in the second occlusion point set that pass the occlusion test. The first shading point is shading based on its initial illumination value, the third set of occlusion points, and the scene data.
29. The apparatus according to claim 28, characterized in that, The coloring unit is also used for: The occlusion relationship auxiliary structure is updated based on the results of the occlusion test.
30. A device for rendering scenes based on ray tracing, characterized in that, It includes processing circuitry for performing the method according to any one of claims 1 to 15.
31. A device for rendering scenes based on ray tracing, characterized in that, The device includes at least one processor and a memory, wherein the at least one processor executes a program or instructions stored in the memory to cause the ray-tracing-based scene rendering apparatus to implement the method of any one of claims 1 to 15.
32. A computer-readable storage medium, characterized in that, Used to store a computer program that, when the computer program is run on a computer or processor, causes the computer or processor to implement the method of any one of claims 1 to 15.
33. A computer program product, characterized in that, The computer program product includes instructions that, when executed on a computer or processor, cause the computer or processor to perform the method of any one of claims 1 to 15.