Rendering method and device, equipment and storage medium
Patent Information
- Application Number
- CN202380055175.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2022-08-04
- Filing Date
- 2023-05-22
- Publication Date
- 2025-02-25
AI Technical Summary
Ray tracing technology consumes a large power and low execution efficiency on the mobile terminal, making it difficult to achieve high-quality and realistic rendering effects.
By dynamically adjusting the light emission density based on the visual range of the model to be rendered in the rendered picture and the distance to the camera device, combining the preset weight coefficient and relationship table, determining the light emission density, and ensuring the rendering effect Reduce rendering power consumption and improve rendering efficiency.
On the premise of ensuring the rendering effect, the rendering power consumption is reduced, the rendering efficiency is improved, and the rendering needs are adapted to the rendering needs under different conditions, especially on the mobile terminal, which effectively reduces the ray tracing calculation density.
Smart Images

Figure CN119522444A_ABST
Abstract
Description
Rendering method, device, equipment and storage medium
[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office of China on August 4, 2022, with application number 202210934786.9 and application name “Rendering method, device, equipment and storage medium”, the entire contents of which are incorporated by reference into this application. Technical Field
[0002] The present application relates to the field of image processing technology, and in particular to a rendering method, apparatus, device, and storage medium. Background Art
[0003] With the continuous development of computer graphics, rendering, as one of the most important research topics in computer graphics, has gradually been widely used. Among them, ray tracing technology is the most important technology for achieving high-quality, realistic, and high-quality imagery because it can generate rendering results close to the real world based on real physical laws.
[0004] In the ray tracing process used to render realistic images, ray tracing technology requires tracing every ray in the scene, which has a large computational overhead. It is a heavy-loaded technology on mobile devices, resulting in high power consumption and low execution effect of ray tracing on mobile devices.
[0005] Summary of the Invention
[0006] Embodiments of the present application provide a rendering method, apparatus, device, and storage medium to solve the problems of high power consumption and low execution efficiency in the existing ray tracing process.
[0007] In a first aspect, the present application provides a rendering method, applied to an electronic device, the method comprising: obtaining data to be rendered, the data to be rendered including a model to be rendered; when the model to be rendered satisfies a first condition, performing ray tracing rendering on the model to be rendered based on a first ray emission density; when the model to be rendered satisfies a second condition, performing ray tracing rendering on the model to be rendered based on a second ray emission density; wherein the model to be rendered satisfies the first condition including: the visible range proportion of the model to be rendered in the image to be rendered is the first visible range proportion, and the distance between the model to be rendered and a camera device is the first distance; wherein the model to be rendered satisfies the second condition including: the visible range proportion of the model to be rendered in the image to be rendered is the second visible range proportion, and the distance between the model to be rendered and the camera device is the second distance; the first visible range proportion is different from the second visible range proportion, and / or the first distance is different from the second distance, the image to be rendered is drawn by the camera device based on the data to be rendered during the rendering process, and the camera device is a virtual camera in the electronic device. wherein, when the first condition and the second condition are different, the first ray emission density and the second ray emission density are different.
[0008] In an embodiment of the present application, the light emission density of the model to be rendered is calculated based on the proportion of the visible range of the model to be rendered in the picture to be rendered and the distance between the model to be rendered and the camera device. Moreover, when the proportion of the visible range of the model to be rendered in the picture to be rendered changes and / or the distance between the model to be rendered and the camera device changes, that is, when the conditions satisfied by the model to be rendered change, the light emission density for performing ray tracing rendering can be adaptively adjusted, thereby reducing rendering power consumption and improving rendering efficiency while ensuring the rendering effect.
[0009] In one possible implementation of the first aspect, when the first visible range and the second visible range account for the same proportion, if the first distance is greater than the second distance, then the first ray emission density is less than the second ray emission density. In this way, the ray emission density of the model to be rendered is affected by the distance between the model to be rendered and the camera device. The smaller the distance, the greater the contribution of the model to be rendered to the rendered image, and the corresponding ray tracing calculation density is also greater. This can reduce power consumption during rendering while ensuring image quality.
[0010] In one possible implementation of the first aspect, when the first distance and the second distance are the same, if the first visible range percentage is greater than the second visible range percentage, then the first ray emission density is greater than the second ray emission density. In this way, the ray emission density of the model to be rendered is determined by the visible range percentage of the model to be rendered in the rendered image. A larger visible range percentage indicates a greater contribution of the model to be rendered to the rendered image, and the corresponding ray tracing calculation density also increases. This reduces power consumption during rendering while ensuring image quality.
[0011] In a possible implementation of the first aspect, the method further includes: determining the conditions satisfied by the model to be rendered based on the proportion of the visible range of the model to be rendered in the image to be rendered and the distance between the model to be rendered and the camera device; and determining the light emission density of the model to be rendered based on the conditions satisfied by the model to be rendered; wherein, when the condition is the first condition, the light emission density is the first light emission density; and when the condition is the second condition, the light emission density is the second light emission density. In this possible implementation, the impact of the model to be rendered on the image quality of the image to be rendered is measured based on different factors, and different light emission densities are determined accordingly, which provides a possibility for reducing power consumption while ensuring image quality.
[0012] In a possible implementation of the first aspect, the light emission density of the model to be rendered is determined based on the conditions satisfied by the model to be rendered, including: based on a preset first weight coefficient and a second weight coefficient, weighted summing the proportion of the visible range of the model to be rendered in the picture to be rendered and the distance between the model to be rendered and the camera device to obtain the light emission density coefficient of the model to be rendered; and determining the light emission density of the model to be rendered based on the light emission density coefficient of the model to be rendered and a preset first relationship, the first relationship being used to represent the correspondence between the light emission density coefficient and the light emission density. In actual applications, although the proportion of the visible range of the model to be rendered in the picture to be rendered and the distance between the model to be rendered and the camera device both contribute to the picture to be rendered to a certain extent, the size of their contributions is different. This embodiment can accurately determine the importance of the model to be rendered in the picture to be rendered by setting the first weight coefficient and the second weight coefficient, laying the foundation for determining the accurate light emission density.
[0013] In a possible implementation of the first aspect, ray tracing rendering is performed on the model to be rendered based on the ray emission density, where the ray emission density is the first ray emission density or the second ray emission density, including: performing ray tracing rendering on the model to be rendered based on the ray emission density to obtain a ray tracing rendering result image of the model to be rendered, wherein the ray tracing rendering result image carries hole pixels; and filling the hole pixels in the ray tracing rendering result image with color according to the template value of each pixel of the model to be rendered when the drawing is initiated and the scene semantic image of the model to be rendered, wherein the scene semantic image is used to identify the model to which the pixels belong. In this embodiment, ray tracing rendering is performed based on the determined ray emission density, so that hole pixels will be generated in the picture to be rendered, so the hole pixels in the ray tracing rendering result image also need to be filled with color to obtain an image with complete colors to ensure the rendering effect of the picture to be rendered.
[0014] In a possible implementation of the first aspect, the method of performing ray tracing rendering on the model to be rendered based on the light emission density to obtain a ray tracing rendering result image of the model to be rendered includes: determining the target pixels in the model to be rendered that need to be rendered using ray tracing based on the light emission density and a preset shading pixel arrangement, wherein the shading pixel arrangement is used to indicate pixel position arrangement information for ray tracing rendering; performing ray tracing rendering on the target pixels to obtain color data of the target pixels; and outputting the color data to the location of the target pixels to obtain a ray tracing rendering result image of the model to be rendered. In this embodiment, the preset shading pixel arrangement can be used to determine the pixel positions to be rendered using ray tracing rendering technology, laying the foundation for the subsequent accurate execution of ray tracing rendering.
[0015] In a possible implementation of the first aspect, the color filling of the hole pixels in the ray tracing rendering result image based on the template value of each pixel of the model to be rendered when the rendering is initiated and the scene semantic image of the model to be rendered includes: for any pixel in the ray tracing rendering result image, determining whether the current pixel being sampled is a hole pixel; when the current pixel is a hole pixel, based on the template value of each pixel of the model to be rendered when the rendering is initiated and the scene semantic image, determining a reference pixel with the same template value as the hole pixel on the ray tracing rendering result image, the reference pixel being a pixel with existing color data on the ray tracing rendering result image; and color filling of the hole pixels using the color data of the reference pixel. In this embodiment, by traversing the hole pixels in the ray tracing rendering result image and color filling them, a target rendered image with complete colors can be obtained, laying the foundation for subsequently outputting an image that meets the requirements for image quality.
[0016] In a possible implementation of the first aspect, based on the template value of each pixel of the model to be rendered when drawing is initiated and the scene semantic image, determining a reference pixel having the same template value as the hole pixel on the ray tracing rendering result image includes: obtaining the texture coordinates of the hole pixel and the texture coordinates of the first pixel with existing color data on the ray tracing rendering result image according to the scene semantic image of the model to be rendered; querying the template cache position based on the texture coordinates of the hole pixel and the texture coordinates of the first pixel to determine the template value of the hole pixel and the template value of the first pixel; the template cache position is used to store the template value of each pixel of the model to be rendered when drawing is initiated; when the template value of the hole pixel is consistent with the template value of the first pixel, determining the first pixel as the reference pixel of the hole pixel; when the template value of the hole pixel is inconsistent with the template value of the first pixel, traversing other pixels with existing color data on the ray tracing rendering result image until a reference pixel having the same template value as the hole pixel is determined. In this way, by using pixels on the same model for color filling, the color data of the hollow pixels on the model to be rendered can be made the same as the color data of the pixel positions where ray tracing rendering is performed, thereby ensuring the image quality of the rendered image.
[0017] In one possible implementation of the first aspect, performing ray tracing rendering on the model to be rendered includes: performing ray tracing rendering on the model to be rendered using a bound Vulkan ray tracing acceleration structure. In practical applications, because the Vulkan API can provide lower CPU overhead and more direct GPU control, Vulkan can be applied to mobile ray tracing technology. Ray tracing algorithms are executed on the mobile device based on Vulkan's ray tracing acceleration structure, thereby improving image rendering efficiency.
[0018] In a second aspect, an embodiment of the present application provides a rendering device, which can be an electronic device or a chip or chip system within an electronic device. The rendering device may include a processing module. When the rendering device is an electronic device, the processing module is used to implement a method described in the first aspect or any possible implementation of the first aspect. When the rendering device is an electronic device, the processing module may be a processor. The rendering device may also include a storage module, which may be a memory. The storage module is used to store instructions, and the processing module executes the instructions stored in the storage module to cause the electronic device to implement a method described in the first aspect or any possible implementation of the first aspect. When the rendering device is a chip or chip system within an electronic device, the processing module may be a processor. The processing module executes the instructions stored in the storage module to cause the electronic device to implement a method described in the first aspect or any possible implementation of the first aspect. The storage module may be a storage unit within the chip (e.g., a register, a cache, etc.) or a storage unit within the electronic device located outside the chip (e.g., a read-only memory, a random access memory, etc.).
[0019] Exemplarily, the processing module may include an acquisition unit and a processing unit;
[0020] Correspondingly, the acquiring unit is used to acquire data to be rendered, wherein the picture to be rendered corresponding to the data to be rendered includes a model to be rendered, and the picture to be rendered is drawn by the camera device based on the data to be rendered during the rendering process;
[0021] The processing unit is configured to perform ray tracing rendering on the model to be rendered based on a first ray emission density when the model to be rendered meets a first condition, and to perform ray tracing rendering on the model to be rendered based on a second ray emission density when the model to be rendered meets a second condition;
[0022] The model to be rendered satisfies the first condition, which includes: the visible range proportion of the model to be rendered in the image to be rendered is the first visible range proportion, and the distance between the model to be rendered and the camera device is the first distance;
[0023] The model to be rendered satisfies the second condition, including: the visible range proportion of the model to be rendered in the image to be rendered is the second visible range proportion, and the distance between the model to be rendered and the camera device is the second distance;
[0024] The first visible range ratio is different from the second visible range ratio, and / or the first distance is different from the second distance.
[0025] In a possible implementation, when the first visible range accounts for the same proportion as the second visible range, if the first distance is greater than the second distance, the first light emission density is less than the second light emission density.
[0026] In a possible implementation, when the first distance is the same as the second distance, if the first visible range accounts for a larger proportion than the second visible range, the first light emission density is greater than the second light emission density.
[0027] In a possible implementation, the processing unit is further configured to determine conditions satisfied by the model to be rendered based on a visible range ratio of the model to be rendered in the image to be rendered and a distance between the model to be rendered and the camera device, and determine a light emission density of the model to be rendered based on the conditions satisfied by the model to be rendered;
[0028] When the condition satisfied by the model to be rendered is the first condition, the light emission density is the first light emission density; when the condition satisfied by the model to be rendered is the second condition, the light emission density is the second light emission density.
[0029] In a possible implementation, when determining the light emission density of the model to be rendered based on the conditions satisfied by the model to be rendered, the processing unit is specifically used to perform weighted summation of the visible range proportion of the model to be rendered in the rendered picture and the distance between the model to be rendered and the camera device based on a preset first weight coefficient and a second weight coefficient to obtain the light emission density coefficient of the model to be rendered; and determine the light emission density of the model to be rendered based on the light emission density coefficient of the model to be rendered and a preset first relationship, wherein the first relationship is used to represent the correspondence between the light emission density coefficient and the light emission density.
[0030] In one possible implementation, when ray tracing rendering is performed on the model to be rendered based on the ray emission density, the ray emission density is the first ray emission density or the second ray emission density, and the processing unit is specifically used to perform ray tracing rendering on the model to be rendered based on the ray emission density to obtain a ray tracing rendering result image of the model to be rendered, and the ray tracing rendering result image carries void pixels; the void pixels in the ray tracing rendering result image are filled with color according to the template value of each pixel of the model to be rendered when the drawing is initiated and the scene semantic image of the model to be rendered, and the scene semantic image is used to identify the model to which the pixel belongs.
[0031] In one possible implementation, when ray tracing rendering is performed on the model to be rendered based on the light emission density to obtain the ray tracing rendering result image of the model to be rendered, the processing unit is specifically used to determine the target pixels in the model to be rendered that need to be rendered using ray tracing based on the light emission density and a preset shading pixel arrangement, and the shading pixel arrangement is used to indicate the pixel position arrangement information using ray tracing rendering; perform ray tracing rendering on the target pixels to obtain color data of the target pixels; output the color data to the position where the target pixels are located to obtain the ray tracing rendering result image of the model to be rendered.
[0032] In a possible implementation, when filling the hole pixels in the ray tracing rendering result image with color based on the template values of each pixel of the model to be rendered when the drawing is initiated and the scene semantic image of the model to be rendered, the processing unit is specifically used to determine whether the sampled current pixel is a hole pixel for any pixel in the ray tracing rendering result image; when the current pixel is a hole pixel, based on the template values of each pixel of the model to be rendered when the drawing is initiated and the scene semantic image, determine a reference pixel with the same template value as the hole pixel on the ray tracing rendering result image, the reference pixel being a pixel with existing color data on the ray tracing rendering result image; and use the color data of the reference pixel to fill the hole pixel with color.
[0033] In a possible implementation, when a reference pixel having the same template value as the hole pixel is determined on the ray tracing rendering result image based on the template value of each pixel of the model to be rendered when drawing is initiated and the scene semantic image, the processing unit is specifically used to obtain the texture coordinates of the hole pixel and the texture coordinates of the first pixel with existing color data on the ray tracing rendering result image according to the scene semantic image of the model to be rendered; based on the texture coordinates of the hole pixel and the texture coordinates of the first pixel, query the template cache position to determine the template value of the hole pixel and the template value of the first pixel; the template cache position is used to store the template value of each pixel of the model to be rendered when drawing is initiated; when the template value of the hole pixel is consistent with the template value of the first pixel, determine the first pixel as the reference pixel of the hole pixel; when the template value of the hole pixel is inconsistent with the template value of the first pixel, traverse other pixels with existing color data on the ray tracing rendering result image until a reference pixel having the same template value as the hole pixel is determined.
[0034] In a possible implementation, when performing ray tracing rendering on the model to be rendered, the processing unit is specifically configured to perform ray tracing rendering on the model to be rendered using a bound Vulkan ray tracing acceleration structure.
[0035] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to perform the method described in the first aspect or any possible implementation of the first aspect.
[0036] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program or instruction is stored. When the computer program or instruction is run on a computer, the computer executes the method described in the first aspect or any possible implementation of the first aspect.
[0037] In a fifth aspect, an embodiment of the present application provides a computer program product comprising a computer program, which, when the computer program runs on a computer, enables the computer to execute the method described in the first aspect or any possible implementation of the first aspect.
[0038] In a sixth aspect, the present application provides a chip or chip system, comprising at least one processor and a communication interface, wherein the communication interface and the at least one processor are interconnected via a line, and the at least one processor is configured to execute a computer program or instruction to perform the method described in the first aspect or any possible implementation of the first aspect. The communication interface in the chip may be an input / output interface, a pin, or a circuit.
[0039] In one possible implementation, the chip or chip system described above in this application further includes at least one memory, in which instructions are stored. The memory may be a storage unit within the chip, such as a register, a cache, etc., or a storage unit of the chip (e.g., a read-only memory, a random access memory, etc.).
[0040] It should be understood that the second to sixth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 is a schematic diagram of the principle of ray tracing;
[0042] FIG2 is a schematic diagram of a rendering process provided by an embodiment of the present application;
[0043] FIG3 is a schematic structural diagram of an electronic device;
[0044] FIG4 is a schematic diagram of a flow chart of a rendering method provided in an embodiment of the present application;
[0045] FIG5 is a schematic diagram of a flow chart of another rendering method provided in an embodiment of the present application;
[0046] FIG6 is a schematic diagram showing the principle of performing ray tracing based on the Vulkan ray tracing acceleration structure;
[0047] FIG7 is a schematic diagram showing the principle of filling holes in a ray tracing rendering result image;
[0048] FIG8 is a schematic diagram of a process of updating a model in a picture to be rendered corresponding to data to be rendered;
[0049] FIG9 is a schematic structural diagram of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] To facilitate a clear description of the technical solutions of the embodiments of the present application, some of the terms and technologies involved in the embodiments of the present application are briefly introduced below:
[0051] 1. Rendering: This refers to the process by which software generates an image from a model. A model can be understood as an object, a three-dimensional object or virtual scene in the image to be rendered, strictly defined using language or data structures. It includes information such as geometry, viewpoint, texture, and lighting. In the embodiments of this application, an image is a digital image or a bitmap image.
[0052] 2. Data to be rendered: This includes model data and material data. Model data refers to the coordinate data, position coordinates, normal coordinates, texture coordinates, tangent coordinates, and so on, of each triangle vertex in a model composed of a triangular mesh. If the 3D scene contains animation, the model data also includes animation information. Material data can include specular maps, physical color maps, and albedo maps (the ratio of reflection and refraction on the surface of a material). In other words, material data is stored in the form of maps.
[0053] 3. Camera. In this embodiment, the camera is a virtual camera installed within the electronic device in the graphics rendering scene. This virtual camera can observe the three-dimensional scene from a certain angle and direction, thereby obtaining the appearance of the virtual scene. Typically, the camera is fixed in position within the device, but by changing the angle and direction of the camera, different appearances of the virtual scene can be viewed.
[0054] 4. Ray tracing: Ray tracing, also known as light trace or ray tracing, is a general technique derived from geometric optics. It models the path of light rays by tracing the light rays as they interact with optical surfaces. Ray tracing technology can simulate realistic virtual scenes by tracing each ray emitted by the camera to achieve effects such as reflection, refraction, shadows, or caustics, thereby rendering realistic images.
[0055] 5. Vulkan: It is a programming interface for graphics and computing devices, specifically a cross-platform 2D and 3D graphics application programming interface (API) that aims to provide lower central processing unit (CPU) overhead and more direct graphics processing unit (GPU) control.
[0056] Vulkan is a brand-new API design that can be designed completely in accordance with modern graphics architecture, providing developers with a more sophisticated API. It supports the creation and submission of instructions in parallel with multiple threads, and uses standardized shader bytecode to provide unified graphics and computing functions. With the help of Vulkan, the multi-core and multi-threaded potential of current GPUs can be maximized.
[0057] 6. Levels of Detail (LOD): LOD, also known as the Level of Detail model, is a real-time 3D computer graphics technology. The basic idea is that the less an object contributes to the rendered image, the simpler the representation of that object. Therefore, during the image rendering process, different LODs can be set based on the distance range between the object and the camera. This allows different objects to be displayed with different details, thus avoiding the time and resource consumption caused by rendering relatively insignificant details, reducing hardware load and improving rendering performance.
[0058] Optionally, in a game scene, objects with different levels of detail can be switched for display according to the distance between the camera device and the model (i.e., object), so that nearby objects have rich details and distant objects can ignore many details, thereby reducing the amount of rendering calculations and improving smoothness.
[0059] 7. Other terms
[0060] In the embodiments of this application, terms such as "first" and "second" are used to distinguish between identical or similar items with substantially the same functions and effects. For example, the terms "first chip" and "second chip" are used solely to distinguish between different chips and do not define their order. Those skilled in the art will understand that terms such as "first" and "second" do not define the quantity or execution order, and do not necessarily define differences.
[0061] It should be noted that in the embodiments of this application, words such as "exemplary" or "for example" are used to indicate examples, illustrations, or descriptions. Any embodiment or design described in this application as "exemplary" or "for example" should not be construed as being preferred or advantageous over other embodiments or designs. Rather, the use of words such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0062] In the embodiments of the present application, "at least one" refers to one or more, and "more" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: the existence of A alone, the existence of A and B at the same time, and the existence of B alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, c can be single or multiple.
[0063] With the continuous advancement of computer graphics, rendering, as a key research topic within the field, has been increasingly applied to a variety of fields, including computer and video games, simulations, film and television special effects, and visual design. Improving the realism of rendered images is a key goal in graphics rendering applications, such as gaming, virtual reality (VR) and augmented reality (AR).
[0064] In 3D computer graphics, ray tracing is a rendering technique used to generate images by tracing the path of light on a pixel-by-pixel basis in an image plane and simulating its interactions with virtual objects. This technique can produce a high degree of visual realism, but it comes at a high computational cost. Ray tracing is increasingly used on personal computers (PCs) and consoles, where hardware acceleration is readily available through hardware such as discrete graphics cards. However, due to limitations in mobile computing power, ray tracing suffers from high power consumption and low execution efficiency when applied to mobile devices, making it difficult to implement on mobile devices.
[0065] In response to the above technical issues, the technical solution of this application was conceived as follows: The inventors have discovered in practice that real-time ray tracing has a strong gain effect in improving the realism of rendered images. Currently, it mainly covers shadows, reflections, ambient occlusion, translucent materials, and global illumination. These algorithms require calculating a large number of intersections between ray vectors and three-dimensional scenes. The more rays traced, the more intersections need to be calculated, and the more computing resources and time are consumed. Therefore, the inventors thought that in the process of scene rendering using real-time ray tracing on mobile devices, the amount of calculation can be reduced and efficiency can be optimized by reducing the number of rays emitted by ray tracing and reducing the execution density of the ray tracing algorithm.
[0066] For example, during the three-dimensional scene update process, the degree of simplification of the model to be rendered can be determined by calculating the proportion of the visible range of the model to be rendered in the rendered picture, and then combining the distance between the model to be rendered and the camera device to determine the light emission density coefficient of the model to be rendered. Finally, the light emission density of the model to be rendered is determined in combination with a preset relationship table, thereby determining the impact of the model to be rendered on the image quality of the final rendering result.
[0067] It can be understood that the greater the light emission density of the model to be rendered, the greater the impact of the model to be rendered on the image quality of the final rendering result. At this time, in the rendering process of the model to be rendered, a higher light emission density is used for calculation; the smaller the light emission density of the model to be rendered, the smaller the impact of the model to be rendered on the image quality of the final rendering result. Therefore, in the rendering process of the model to be rendered, a lower light emission density is used for calculation, thereby minimizing the light emission density during ray tracing while maintaining no significant change in the rendering quality, thereby improving the ray tracing calculation performance of the entire scene.
[0068] Furthermore, the inventors found in their research that the Vulkan API can provide lower CPU overhead and more direct GPU control. Therefore, Vulkan can be applied to mobile ray tracing technology, and the ray tracing algorithm can be executed on the mobile terminal based on Vulkan's ray tracing acceleration structure to improve rendering efficiency.
[0069] Based on the above technical conception process, an embodiment of the present application provides a rendering method. For the model to be rendered included in the model data to be rendered, first, based on the rendering pipeline parameters in the material information of the model to be rendered, it is determined whether the model to be rendered is rendered using ray tracing technology. If the model to be rendered is rendered using ray tracing technology, then based on the proportion of the visible range of the model to be rendered in the image to be rendered and the distance between the model to be rendered and the camera device, the light emission density coefficient of the model to be rendered is determined, and then the preset first relationship is queried to determine the light emission density of the model to be rendered. The first relationship is the correspondence between the light emission density coefficient and the light emission density. Then, combined with the template value of the model to be rendered when the drawing is initiated, pixel rendering is performed on the model to be rendered. This technical solution, by calculating the light emission density of the model to be rendered, can reduce rendering power consumption and improve rendering efficiency while ensuring the rendering effect.
[0070] For example, Figure 1 is a schematic diagram of the principle of ray tracing. As shown in Figure 1, the schematic diagram includes a camera device (viewpoint), a virtual image, an object, and a light source.
[0071] The principle of ray tracing is as follows: light emitted from a photographic device passes through the pixel position on the target rendering plane, enters the three-dimensional (3D) scene, and extends all the way to the object. The intersection of the light and the object on the virtual screen is calculated, and then the intersection is colored.
[0072] In practical applications, when passing through a 3D scene, light may be reflected from one object to another (causing reflection), blocked by an object (causing shadow), or pass through a transparent or translucent object (simulating translucency or dielectrics, such as glass or water). Therefore, if the material at the intersection of the light and the object is reflective, it can be traced in the direction of reflection at the intersection, and the shading of the intersection after reflection can be obtained. In other words, the ray tracing method calculates projection and global illumination by tracing the propagation of light in a three-dimensional scene, thereby rendering a two-dimensional image.
[0073] It can be understood that the light source is a virtual light source set in the 3D space, which is used to generate a lighting environment in the 3D space.
[0074] FIG2 is a process diagram of a rendering method provided by an embodiment of the present application. As shown in FIG2 , the process diagram may include the following processes: model loading process 101 , acceleration structure construction process 102 , mesh drawing process 103 , and quadrilateral drawing process 104 .
[0075] The model loading process 101 mainly loads the model in the image to be rendered based on the data to be rendered, determines whether it needs to be rendered using ray tracing technology based on the model's material information, and assigns a unique ID to the model that needs to be rendered using ray tracing technology. The data to be rendered includes the model to be rendered and the material data of the rendering model.
[0076] The acceleration structure construction process 102 is mainly to improve the efficiency of subsequent ray tracing technology rendering by constructing the acceleration structure.
[0077] The network drawing process 103 mainly draws a grid based on the spatial matrix information and model data of the camera device to obtain the image to be rendered. For the model that needs to be rendered using ray tracing technology, the light emission density of the model is determined, and ray tracing technology rendering is performed. For example, the light emission density shown in Figure 2 is 1 / 4, and 1 target pixel can be selected for pixel shading for every 4 pixels.
[0078] In the quad drawing process 104, the result image rendered by the ray tracing technology can be rendered as a whole based on the picture to be rendered, the light emission density of the model and the result determined by the mesh drawing process 103. For example, the empty pixels in the picture to be rendered are filled with color to generate the target rendering picture, and after determining that each model in the target rendering picture is filled with color data, the target rendering image corresponding to the data to be rendered is obtained.
[0079] It is worth noting that the product implementation form of the embodiment of the present application is program code contained in machine learning and deep learning platform software and deployed on an electronic device. The program code of the embodiment of the present application can be stored inside the electronic device. When running, the program code runs in the host memory and / or GPU memory of the electronic device.
[0080] The electronic device of the embodiment of the present application may also be a terminal device in any form. For example, the terminal device may include a handheld device with image processing function, a vehicle-mounted device, etc. For example, some electronic devices include: mobile phones, tablet computers, PDAs, laptop computers, mobile internet devices (MIDs), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in industrial control, wireless terminals in self-driving cars, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, cellular phones, cordless phones, session initiation protocol (SIP) phones, wireless local loop (WLL) stations, personal digital assistants (PDAs), handheld devices with wireless communication capabilities, computing devices or other processing devices connected to wireless modems, in-vehicle devices, wearable devices, terminal devices in 5G networks or future evolved public land mobile communication networks. The terminal equipment in the network (PLMN), etc., is not limited to this in the embodiments of the present application.
[0081] As an example and not a limitation, in the embodiments of the present application, the electronic device may also be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also achieve powerful functions through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include those that are fully functional, large in size, and can achieve complete or partial functions without relying on smartphones, such as smart watches or smart glasses, as well as those that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various smart bracelets and smart jewelry for vital sign monitoring.
[0082] In addition, in the embodiments of the present application, the electronic device can also be a terminal device in the Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network of human-machine interconnection and object-to-object interconnection.
[0083] The electronic devices in the embodiments of the present application may also be referred to as: terminal equipment, user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent or user device, etc.
[0084] In the embodiments of the present application, the electronic device or each network device includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and memory (also known as main memory). The operating system can be any one or more computer operating systems that implement business processing through processes, such as the Linux operating system, the Unix operating system, the Android operating system, the iOS operating system, or the Windows operating system. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.
[0085] In order to better understand the embodiments of the present application, the structure of the electronic device according to the embodiments of the present application is introduced below:
[0086] Figure 3 is a schematic diagram of the structure of an electronic device. As shown in Figure 3, 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, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display 194, and a subscriber identification module (SIM) card interface 195.
[0087] Among them, the sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light 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.
[0088] It should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0089] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. It may also be an application specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gates, transistor logic devices, or discrete hardware components. Among them, different processing units may be independent devices or integrated into one or more processors.
[0090] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0091] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the instruction or data again, it can retrieve it from the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.
[0092] In some embodiments, the processor 110 may include one or more interfaces. The 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.
[0093] It is understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is for illustrative purposes only and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods from those in the above embodiments, or a combination of multiple interface connection methods.
[0094] Electronic device 100 implements display functionality through a GPU, display screen 194, and an application processor. A GPU is a microprocessor for image processing that connects display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.
[0095] Display screen 194 is used to display images, videos, etc. 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 or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLed, a quantum dot light-emitting diode (QLED), a low-temperature polycrystalline oxide (LTPO), etc. In some embodiments, electronic device 100 may include one or N display screens 194, where N is a positive integer greater than one.
[0096] The electronic device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.
[0097] 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 external memory card communicates with the processor 110 via the external memory interface 120 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.
[0098] The internal memory 121 can be used to store computer executable program codes, and the executable program codes include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121 and / or instructions stored in a memory provided in the processor.
[0099] Exemplarily, the electronic device 100 may further include one or more items such as a button 190 , a motor 191 , an indicator 192 , and a SIM card interface 195 (eSIM card).
[0100] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture, etc. In the embodiment of the present application, the Android system with a layered architecture is used as an example to exemplify the software structure of the electronic device 100 .
[0101] The technical solution of the present application is described in detail below through specific embodiments. It should be noted that the following specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0102] For example, FIG4 is a flow chart of a rendering method provided in an embodiment of the present application. The rendering method can be applied to electronic devices. As shown in FIG4, in this embodiment, the rendering method can include the following steps:
[0103] S401: Acquire data to be rendered, where the data to be rendered includes a model to be rendered.
[0104] In practical applications, different scenes correspond to different data to be rendered. By acquiring the data to be rendered for the current scene, the image to be rendered can be determined based on the field of view and orientation of the camera within the device. That is, in this embodiment, the camera is a virtual camera within the electronic device, and the image to be rendered is generated by the camera during the image rendering process based on the data to be rendered.
[0105] It can also be understood that the image to be rendered can be determined based on the field of view and direction of the camera device, that is, for the same data to be rendered, different images to be rendered can be obtained by changing the field of view and / or direction of the camera device.
[0106] In this embodiment, the rendering method can be applied to a scene containing multiple frames of different pictures. The multiple frames of the scene can be rendered and generated in sequence according to the time sequence. Different frames can include different numbers of models to be rendered. The embodiment of the present application is explained by a frame of picture generated based on the data to be rendered and a model to be rendered included in the picture.
[0107] Optionally, the data to be rendered may be obtained by reading local data, or by receiving data sent by other devices. This embodiment does not limit the method of obtaining the data to be rendered.
[0108] S402 : Determine conditions satisfied by the model to be rendered according to the visible range proportion of the model to be rendered in the image to be rendered and the distance between the model to be rendered and the camera device.
[0109] In practical applications, the image quality of the model to be rendered in the picture to be rendered is mainly affected by the proportion of the visible range of the model to be rendered in the picture to be rendered and the distance between the model to be rendered and the camera device. Therefore, before performing ray tracing on the model to be rendered, we can first determine the influence of the proportion of the visible range of the model to be rendered in the picture to be rendered and the distance between the model to be rendered and the camera device on the image quality of the picture to be rendered, that is, the conditions satisfied by the model to be rendered, and then determine the light emission density of the model to be rendered based on the conditions.
[0110] Among them, the greater the proportion of the visible range of the model to be rendered in the rendered picture, the greater the contribution of the model to be rendered to the rendered picture, and the corresponding ray tracing calculation density should also be greater; the smaller the distance between the model to be rendered and the camera device, the greater the contribution of the model to be rendered to the rendered picture, and the corresponding ray tracing calculation density should also be greater.
[0111] For example, in actual applications, if the visible range proportion of the model to be rendered in the picture to be rendered is the first visible range proportion, and the distance between the model to be rendered and the camera device is the first distance, then based on the first visible range proportion and the first distance, the light emission density of the model to be rendered can be calculated to be the first light emission density.
[0112] If the visible range proportion of the model to be rendered in the rendered picture is the second visible range proportion, and the distance between the model to be rendered and the camera device is the second distance, then based on the second visible range proportion and the second distance, the light emission density of the model to be rendered can be calculated as the second light emission density.
[0113] It can be understood that when the first light emission density and the second light emission density are different, at least one of the visible range ratio and distance of the model to be rendered under different conditions is different, that is, the first visible range ratio is different from the second visible range ratio, and / or the first distance is different from the second distance.
[0114] In one embodiment of the present application, since a larger proportion of the visible range of the model to be rendered in the picture to be rendered indicates a greater contribution of the model to be rendered to the picture to be rendered, when the first visible range proportion is the same as the second visible range proportion, if the first distance is greater than the second distance, the first light emission density is less than the second light emission density.
[0115] In another embodiment of the present application, since the smaller the distance between the model to be rendered and the camera device, the greater the contribution of the model to be rendered to the rendered image, therefore, when the first distance and the second distance are the same, if the first visible range accounts for a greater proportion than the second visible range, the first light emission density is greater than the second light emission density.
[0116] In an embodiment of the present application, the light emission density when performing ray tracing rendering can be determined based on the conditions satisfied by the model to be rendered. Specifically, when the model to be rendered satisfies the first condition, S403 is executed; when the model to be rendered satisfies the second condition, S404 is executed.
[0117] S403: Perform ray tracing rendering on the model to be rendered based on the first light emission density.
[0118] In this step, the first ray emission density can be understood as the percentage of pixels in the model to be rendered that are rendered using ray tracing. For example, if the first ray emission density is 1 / 4, then one out of every four pixels is rendered using ray tracing, and the remaining pixels can be rendered using other color filling methods.
[0119] That is, if the model to be rendered meets the first condition, that is, the visible range proportion of the model to be rendered in the picture to be rendered is the first visible range proportion, and the distance between the model to be rendered and the camera device is the first distance, then the light emission density of the model to be rendered can be calculated to be the first light emission density. Accordingly, based on the first light emission density, ray tracing rendering can be performed on the model to be rendered to obtain the scene semantic image and ray tracing rendering result image corresponding to the model to be rendered.
[0120] S404: Perform ray tracing rendering on the model to be rendered based on the second light emission density.
[0121] In this step, the second ray emission density can be understood as the percentage of pixels rendered using ray tracing, among the pixels corresponding to the model to be rendered. For example, assuming the second ray emission density is 3 / 4, three out of every four pixels are rendered using ray tracing, and the remaining pixels can be filled with color using other methods.
[0122] That is, if the model to be rendered meets the second condition, that is, the visible range proportion of the model to be rendered in the picture to be rendered is the second visible range proportion, and the distance between the model to be rendered and the camera device is the second distance, then the light emission density of the model to be rendered can be calculated to be the second light emission density. Accordingly, based on the second light emission density, ray tracing rendering can be performed on the model to be rendered to obtain the scene semantic image and ray tracing rendering result image corresponding to the model to be rendered.
[0123] In an embodiment of the present application, when the first visible range accounts for the same proportion as the second visible range, if the first distance is greater than the second distance, the first light emission density is less than the second light emission density.
[0124] In an embodiment of the present application, the electronic device can generate a target rendering screen after performing ray tracing rendering on the model to be rendered in the rendering screen by executing the technical solution of the present application, and then fill the model to be rendered in the target rendering screen with color, and after rendering and filling the holes of the unrendered model in the target rendering screen, a target rendering image can be generated.
[0125] In an embodiment of the present application, by obtaining data to be rendered, the data to be rendered includes a model to be rendered. When the model to be rendered meets a first condition, ray tracing rendering is performed on the model to be rendered based on a first ray emission density. When the model to be rendered meets a second condition, ray tracing rendering is performed on the model to be rendered based on a second ray emission density. The model to be rendered is located in a picture to be rendered, and the picture to be rendered is drawn by a camera device based on the data to be rendered during the rendering process. That is, when the proportion of the visible range of the model to be rendered in the picture to be rendered changes and / or the distance between the model to be rendered and the camera device changes, the ray emission density of the model to be rendered can be changed, so that the proportion of pixels performing ray tracing can be adaptively adjusted. While ensuring the rendering effect, the rendering power consumption is reduced and the rendering efficiency is improved.
[0126] For example, based on the above embodiment, FIG5 is a flowchart of another rendering method provided by an embodiment of the present application. As shown in FIG5 , in this embodiment, the rendering method may include the following steps:
[0127] S501: Acquire data to be rendered, where the data to be rendered includes a model to be rendered.
[0128] The rendering method of this embodiment can be applied to a scene containing multiple frames of different pictures. The multiple frames of the scene can be rendered and generated in sequence according to the time sequence. Different frames can include different numbers of models to be rendered. The embodiment of the present application is explained with a frame of picture corresponding to the data to be rendered.
[0129] It is understandable that in actual applications, each frame may include one or more models to be rendered. In this embodiment, the frame to be rendered includes models to be rendered for explanation, and the number of models to be rendered is not limited, and can be determined according to the actual scenario.
[0130] Optionally, during the scene update process, for the current scene, the data to be rendered of the current scene may be obtained, and the model to be rendered in the picture to be rendered may be determined based on the model data in the data to be rendered.
[0131] Optionally, this rendering method can be applied to graphics rendering-related applications, such as gaming applications and virtual simulation applications. It is understood that during the download and installation of an application, the relevant data to be rendered in the application will also be downloaded and saved. Accordingly, during the execution of the application, the data to be rendered can be obtained by loading the data related to the application.
[0132] Optionally, during the process of browsing a web page, a data request may be sent to a server, and then the data to be rendered may be obtained by receiving the data sent by the server.
[0133] That is, in actual applications, the data to be rendered can be obtained by reading local data or by receiving data sent by other devices. This embodiment does not limit the method of obtaining the data to be rendered.
[0134] It is understood that in this embodiment, the data to be rendered may include a model in a 3D scene and its attribute information. For example, a model may be a 3D object or virtual scene or object strictly defined using a language or data structure, and may include information such as geometry, viewpoint, texture, and lighting. For example, models of the sky, houses, people, and trees may include such attributes as color, material, length, width, and height.
[0135] S502: Determine whether the model to be rendered is rendered using ray tracing technology. If so, execute S503 to S507; if not, execute S508 and S509.
[0136] During the 3D scene update process, ray tracing has a significant benefit in improving the realism of the rendered image. However, since it requires calculating a large number of intersections between ray vectors and the 3D scene, the more rays traced, the greater the computing resources and time consumed. Therefore, to achieve the desired visual realism and reduce resource consumption, the material information of each model can be used to specify whether the model is rendered using ray tracing technology. Therefore, in this embodiment, the model to be rendered is loaded based on the data to be rendered, but before the model is rendered, it is first determined whether the model to be rendered is rendered using ray tracing technology.
[0137] In actual applications, the data to be rendered also includes the material data of the model to be rendered, which can also be understood as the attribute information of the model. Therefore, whether the model is rendered using ray tracing technology can be determined based on the attribute information of the model. Specifically, there is a model material file in the material information that comes with the model. A rendering pipeline parameter RenderPipeline is set in the model material file. The value of the rendering pipeline parameter RenderPipeline can be RASTER or RAYTRACING. Among them, if the rendering pipeline parameter RenderPipeline = RASTER, it means that the model is rendered using traditional rendering technology, that is, ray tracing technology is not used for rendering; if the rendering pipeline parameter RenderPipeline = RAYTRACING, it indicates that the model is rendered using ray tracing technology.
[0138] Correspondingly, in an embodiment of the present application, after the model to be rendered is loaded based on the data to be rendered, the values of the rendering pipeline parameters of the model to be rendered can be determined by querying the model material file in the material information of the model to be rendered. In this way, it can be determined whether the model to be rendered is rendered using ray tracing technology based on the values of the pipeline parameters to be rendered.
[0139] As an example, if the rendering pipeline parameter RenderPipeline=RASTER of the model to be rendered, it means that the model to be rendered is not rendered using ray tracing technology, and therefore, the solutions S508 and S509 are executed; if the rendering pipeline parameter RenderPipeline=RAYTRACING of the model to be rendered, it indicates that the model to be rendered is rendered using ray tracing technology, and then the solutions S503 to S507 can be executed.
[0140] S503 : Determine a light emission density coefficient of the model to be rendered according to a visible range proportion of the model to be rendered in the image to be rendered and a distance between the model to be rendered and the camera device.
[0141] The visible range of the model to be rendered in the picture to be rendered accounts for a ratio of the bounding sphere information of the model to be rendered (ie, the number of pixels covered by the bounding sphere) to the total number of pixels in the picture to be rendered.
[0142] In this embodiment, the number of pixels covered by the bounding sphere of the model to be rendered can be determined as follows: first, the world space coordinates (X, Y, Z) of the model to be rendered and the vertex data of the model to be rendered are determined based on the data to be rendered; second, based on the bounding sphere formed by the world space coordinates (X, Y, Z) and the vertex data, the coordinates of the center of the bounding sphere and the radius of the bounding sphere of the model to be rendered in three-dimensional space are determined, and then the spatial coordinates (X0, Y0, Z0) and (X1, Y1, Z1) of the two endpoints of any diameter on the bounding sphere are obtained. The spatial coordinates (X0, Y0, Z0) and (X1, Y1, Z1) of the two endpoints are multiplied by the projection matrix of the camera device respectively to obtain the standard device space coordinates (x0, y0, z0) and (x1, y1, z1). By calculating the pixel module length between (x0, y0, z0) and (x1, y1, z1), the radius pixel number R of the bounding sphere on the image to be rendered is obtained, and then the number of pixels 4πRR covered by the bounding sphere of the model to be rendered can be determined.
[0143] The number of pixels of the image to be rendered can be calculated based on the width Width and height Height of the resolution of the image to be rendered. Therefore, in this embodiment, the visible range of the model to be rendered in the image to be rendered accounts for 4πRR / (Width*Height).
[0144] It can be understood that in practical applications, the larger the proportion of the visible range of the model to be rendered in the rendered picture is, the greater the contribution of the model to be rendered to the rendered picture is, and the corresponding ray tracing calculation density should also be greater.
[0145] Optionally, the bounding sphere information of the model to be rendered can also be replaced by the axis-aligned bounding box (AABB) information of the model to be rendered. Specifically, the AABB information of the model to be rendered can be the pixel range information covered by the AABB of the model to be rendered projected onto the screen or the pixel range information covered by the oriented bounding box (OBB) projected onto the screen. This embodiment does not limit it.
[0146] In this embodiment, the distance between the model to be rendered and the camera device can be obtained based on the world space coordinates (X, Y, Z) of the model to be rendered in the space matrix and the world space coordinates (X0, Y0, Z0) of the camera device itself. Specifically, by calculating the vector modulus composed of the world space coordinates (X, Y, Z) of the model to be rendered in the space matrix and the world space coordinates (X0, Y0, Z0) of the camera device itself, the distance between the model to be rendered and the camera device can be obtained.
[0147] In practical applications, the distance between the model to be rendered and the camera device can also be characterized by the level of detail (LOD). LOD is used to describe scenes in video games. Models to be rendered that are closer to the camera device can present more polygons than models to be rendered that are farther away from the camera device. That is, according to the position and importance of the model to be rendered in the picture to be rendered, the resource allocation when rendering the model to be rendered can be determined, and the number of faces and detail of non-important models to be rendered can be reduced, thereby obtaining efficient rendering operations. It can be understood that the lower the LOD, that is, the smaller the distance between the model to be rendered and the camera device, the greater the contribution of the model to be rendered to the picture to be rendered, and the corresponding ray tracing calculation density should also be greater.
[0148] In this embodiment, since the proportion of the visible range of the model to be rendered in the picture to be rendered and the distance between the model to be rendered and the camera device both contribute to the picture to be rendered, if you want to calculate the light emission density coefficient of the model to be rendered, you can query the first weight coefficient and the second weight coefficient preset in the device. According to the first weight coefficient and the second weight coefficient, the distance between the model to be rendered and the camera device and the proportion of the visible range of the model to be rendered in the picture to be rendered are weighted and summed, so as to obtain the emission light density coefficient of the model to be rendered when it is rendered using ray tracing technology.
[0149] The first weight coefficient is the weight coefficient for the distance between the model to be rendered and the camera device, and the second weight coefficient is the weight coefficient for the proportion of the visible range of the model to be rendered in the image to be rendered. The sum of the first weight coefficient and the second weight coefficient is equal to 1. The first weight coefficient and the second weight coefficient are determined based on the importance of the two indicators: the distance between the model to be rendered and the camera device, and the proportion of the visible range of the model to be rendered in the image to be rendered, and are preset in the device.
[0150] In an optional embodiment of the present application, the first weight coefficient can be selected as 0.3, and the second weight coefficient can be selected as 0.7. That is, a weight of 0.7 can be assigned to the indicator of the proportion of the visible range of the model to be rendered in the rendered picture, and a weight of 0.3 can be assigned to the indicator of the distance between the model to be rendered and the camera device, so as to perform a weighted sum of these two indicators and calculate the light emission density coefficient of the model to be rendered.
[0151] S504 : Determine the light emission density of the model to be rendered according to the light emission density coefficient of the model to be rendered and a preset first relationship, where the first relationship is used to represent a corresponding relationship between the light emission density coefficient and the light emission density.
[0152] In this embodiment, the device is pre-installed with a first relationship between the light emission density coefficient and the light emission density of each model when rendering using ray tracing technology. For example, the device is pre-installed with a relationship table representing the light emission density coefficient and the light emission density. After determining the light emission density coefficient to be rendered, the light emission density of the model to be rendered can be determined by querying the relationship table.
[0153] Exemplarily, the light emission density is used to represent the relationship between the pixels of the model and the emitted light. For example, a light emission density of 0.5 means that a light ray is emitted every other pixel, and a light emission density of 0.2 means that a light ray is emitted every three pixels, etc.
[0154] It can be understood that in this embodiment, the light emission density of the model to be rendered can be used as the basis for the model pixel shading frequency in the subsequent fragment shader stage, wherein the model pixel shading frequency is used to refer to shading one out of every several pixels of all pixels of the model to be rendered.
[0155] S505: Using the identifier of the model to be rendered as a template value of each pixel on the model to be rendered when rendering is initiated.
[0156] In this embodiment, the template value of the model to be rendered when the rendering is initiated can be set according to the identifier of the model to be rendered and whether the ray tracing technology is used for rendering.
[0157] In an optional embodiment, if the model to be rendered is rendered using ray tracing technology, the identifier (ID) of the model to be rendered can be bound to the template value of the model to be rendered when the drawing is initiated (drawcall), that is, the template value of each pixel of the model to be rendered when the drawing is initiated (drawcall) is equal to the identifier of the model to be rendered.
[0158] S506 , rendering the model to be rendered using ray tracing technology to obtain a scene semantic image corresponding to the model to be rendered and a ray tracing rendering result image.
[0159] Among them, the scene semantic image is used to identify the model to which the pixel belongs, and the ray tracing rendering result image carries void pixels.
[0160] In this embodiment, when ray tracing is performed on the model to be rendered based on the ray emission density, a ray tracing rendering result image of the model to be rendered can be obtained. The ray tracing rendering result image contains void pixels. The void pixels in the ray tracing rendering result image can then be filled with color based on the template value of each pixel of the model to be rendered when rendering is initiated and the scene semantic image of the model to be rendered. The scene semantic image is used to identify the model to which the pixel belongs.
[0161] It can be understood that in this embodiment, when it is determined that the model to be rendered is rendered using ray tracing technology, the ray tracing algorithm can be executed by calling the bound vulkan ray tracing acceleration structure to output the rendered color data to the RGB three channels of the target pixel.
[0162] For example, Figure 6 is a schematic diagram illustrating the principles of ray tracing based on the Vulkan ray tracing acceleration architecture. In practical applications, assuming that the main body performing ray tracing rendering is a processor, as shown in Figure 6, this schematic diagram may include the processor, the Vulkan ray tracing acceleration architecture, the driver layer, and the application. The processor may include a CPU and / or a GPU.
[0163] In this embodiment, the CPU or GPU in the processor can directly call the vulkan ray tracing acceleration structure to perform ray tracing technology rendering, and the GPU and CPU can also call the vulkan ray tracing acceleration structure to perform ray tracing technology rendering after information exchange. This embodiment does not limit this.
[0164] Optionally, the driver layer is a driver implementation provided for the Vulkan ray tracing acceleration structure based on the GPU architecture, and the application is a program that can call Vulkan to perform graphics or computing work.
[0165] In this embodiment, the processor can determine the target pixel that needs to be colored in the model to be rendered based on the light emission density of the model to be rendered, and then call the Vulkan ray tracing acceleration structure to execute the ray tracing algorithm, and output the color data of the target pixel to the RGB three channels of the target pixel for direct use in the fragment shader stage.
[0166] It can be understood that in the embodiments of the present application, the target pixels that need to be rendered using ray tracing in the model to be rendered can be determined based on the light emission density and the preset shading pixel arrangement, and then ray tracing rendering is performed on the target pixels to obtain the color data of the target pixels, and finally the color data is output to the location of the target pixels to obtain the ray tracing rendering result image of the model to be rendered.
[0167] It is understood that the shading pixel arrangement is used to indicate the pixel position arrangement information for rendering using ray tracing. Accordingly, in this embodiment, when determining the target pixels to be shaded in the model to be rendered based on the light emission density, the shape arrangement of the target pixel positions corresponding to the light emission density can be first determined based on the preset shading pixel arrangement, and then the target pixel positions to be shaded in the model to be rendered can be determined based on the shape arrangement of the target pixel positions.
[0168] For example, referring to Figure 2 above, when the light emission density of the model to be rendered is 0.25, one target pixel is selected from every four pixels for pixel shading. At this time, the target pixel position can be arranged in a "Z" shape, or in other shapes, such as an "=" shape, etc. The embodiment of the present application does not limit the position arrangement and state arrangement of the target pixels, which can be set according to actual needs.
[0169] It can be understood that the target pixel position can be determined based on the "Z"-shaped arrangement, but the specific position of the target pixel in the image to be rendered can be determined according to the settings. For example, in Figure 2, the pixels of the model to be rendered are arranged in 4×4. When the light emission density is 0.25, you can choose to render the pixels at the intersections of the first row and the first column, the first row and the third column, the third row and the first column, the third row and the third column, etc. You can also choose to render the pixels at the intersections of the first row and the second column, the first row and the fourth column, the third row and the second column, the third row and the fourth column, etc. You can also choose to render the pixels at the intersections of the second row and the first column, the second row and the third column, the fourth row and the first column, the fourth row and the third column, etc. Of course, the target pixel can also be determined in this way. This embodiment does not limit it and will not be elaborated here.
[0170] Optionally, in the process of executing the ray tracing algorithm on the model to be rendered based on the bound vulkan ray tracing acceleration structure, for the model to be rendered, based on the determined target pixel position, in the fragment shader stage, it can be calculated whether the currently processed pixel needs normal shading. If normal shading is required, the ray tracing rendering algorithm in the fragment shader is executed, and the color data of the pixel is output to the RGB three channels of the pixel; if normal shading is not required, the operation is abandoned, and the template value of the pixel is output to the template cache location. Therefore, the generated ray tracing technology rendering result only renders part of the pixels of the model to be rendered, so that there are hole pixels in the target rendering screen (i.e., the ray tracing rendering result image) after ray tracing is performed on the model to be rendered. Among them, the template cache location is a special memory area in the graphics rendering framework, which is used to store the template value of each model that is assigned an identifier, and the template value is used to distinguish different models.
[0171] That is to say, in the fragment shader of the model to be rendered, based on the light emission density, the shape arrangement of the target pixel position and the coordinates of the currently processed pixel determined in the above steps, it can be calculated whether the currently processed pixel is used to emit light for the pixel's color information. If so, the color data of the current pixel is calculated and output to the current pixel. If not, exit.
[0172] Accordingly, after the ray tracing rendering in S506, a ray tracing rendering result image (i.e., a color image) with void pixels and a scene semantic image identifying which model the pixels belong to can be output. Therefore, in an embodiment of the present application, the void pixels in the ray tracing rendering result image can also be filled with color based on the scene semantic image, so that the color of the final target rendered image is complete.
[0173] S507 , filling the empty pixels in the ray tracing rendering result image with colors according to the template value of each pixel of the model to be rendered when rendering is initiated and the scene semantic image.
[0174] Optionally, for each pixel in the ray tracing rendering result image, the pixels are filled and rendered in sequence according to the post-processing logic, that is, the color value of each hole pixel in the ray tracing rendering result image is calculated and filled to the target position, thereby generating the final real-time ray tracing technology rendering result.
[0175] For example, Figure 7 is a schematic diagram illustrating the principle of filling holes in a ray tracing rendering result image. As shown in Figure 7, the ray tracing rendering result image generated by S506 is sampled, and for any pixel in the ray tracing rendering result image, a determination is made as to whether the current pixel being sampled is a hole pixel, i.e., whether the current pixel is a pixel for which ray tracing has been performed.
[0176] 7 , in an optional embodiment, if the current pixel is not a hole pixel, that is, the current pixel executes the ray tracing algorithm and has color data, the color data can be directly output to the position of the current pixel.
[0177] As shown in Figure 7, in an optional embodiment, if the current pixel is a hole pixel, that is, the current pixel has not executed the ray tracing algorithm and there is no color data, at this time, the color data of the current pixel can be obtained by executing a preset algorithm, and color filling can be performed based on the color data.
[0178] Specifically, when the current pixel is a hole pixel, first, based on the template value of each pixel of the model to be rendered when the drawing is initiated and the scene semantic image, a reference pixel with the same template value as the hole pixel is determined on the ray tracing rendering result image. The reference pixel is a pixel with color data; then the color data of the reference pixel is used to fill the hole pixel with color.
[0179] Optionally, the specific method of obtaining the color data of the current pixel by executing a preset algorithm, that is, determining the reference pixel of the hole pixel, and rendering accordingly is as follows: according to the scene semantic image of the model to be rendered, obtaining the texture coordinates of the hole pixel and the texture coordinates of the first pixel with existing color data on the ray tracing rendering result image, and then querying the template cache position based on the texture coordinates of the hole pixel and the texture coordinates of the first pixel to determine the template value of the hole pixel and the template value of the first pixel; the template cache position is used to store the template value of each pixel of the model to be rendered when rendering is initiated; and judging whether the template value of the hole pixel is consistent with the template value of the first pixel; If they are consistent, it is determined that the hole pixel and the first pixel belong to the same model. At this time, the first pixel is determined to be the reference pixel of the hole pixel, and the color data of the first pixel can be output to the position of the hole pixel to achieve rendering of the hole pixel; if they are inconsistent, other pixels with existing color data on the ray tracing rendering result image are traversed until a reference pixel with the same template value as the hole pixel is determined, for example, the texture coordinates of the second pixel with existing color data are obtained, and the above judgment process is performed until a pixel with existing color data belonging to the same model is found and used as a reference pixel, thereby achieving color filling of the hole pixel.
[0180] It can be understood that in this embodiment, the first pixel and the second pixel are different.
[0181] S508: Set the template value bound to the model to be rendered when drawing is initiated to 0.
[0182] In an optional embodiment, if the model to be rendered is not rendered using ray tracing technology, the template value of the model to be rendered can be set to 0 when drawing is initiated, that is, the template value bound to the model to be rendered during drawcall is set to 0.
[0183] Optionally, in an embodiment of the present application, if the model to be rendered is not rendered using ray tracing technology, S509 may be executed:
[0184] S509: Perform rasterization rendering on the model to be rendered to obtain a rendering result of the model to be rendered.
[0185] It can be understood that rasterization rendering is actually a kind of ordinary rendering. That is, for the model to be rendered that does not use ray tracing rendering, the model to be rendered can be rendered according to the rasterization rendering method to obtain the color data of the model to be rendered, and then the color data can be rendered into each pixel of the model to be rendered.
[0186] Optionally, after using normal rendering, the template cache position of each pixel of the model to be rendered may be marked as 0 when the rendering is initiated.
[0187] It is understandable that other models in the to-be-rendered picture can be rendered according to the above methods from S501 to S509, which will not be described in detail in this embodiment.
[0188] S510: When it is determined that all pixels of all rendering models in the to-be-rendered picture have color data, output a target rendered image.
[0189] Optionally, through the above steps S501 to S509 , a target rendered image can be obtained.
[0190] The rendering method provided in an embodiment of the present application is for a model to be rendered in a to-be-rendered image corresponding to the to-be-rendered data. When determining that the model to be rendered needs to be rendered using ray tracing technology, the method first determines the light emission density coefficient of the model to be rendered based on the visible range ratio of the model to be rendered in the to-be-rendered image and the distance between the model to be rendered and the camera device. Then, in combination with a preset first relationship, the light emission density of the model to be rendered can be determined, and then the ray tracing technology is executed based on the light emission density to render the model to be rendered. This technical solution can minimize the number of rays emitted by ray tracing while ensuring the rendering effect when the model to be rendered is rendered using ray tracing technology, minimize the computational cost of ray tracing, and improve rendering efficiency.
[0191] Optionally, in an embodiment of the present application, for scenes with dynamic characteristics such as game scenes, the scenes are constantly updated, and during the scene update process, the model leaves the scene and becomes invisible, or enters the scene and becomes visible, so the queue of visible models in the rendering screen will change dynamically. Therefore, it is necessary to reallocate the model identifier according to the visible model queue in the current scene.
[0192] For example, Fig. 8 is a flow chart of updating the model in the scene to be rendered corresponding to the data to be rendered. As shown in Fig. 8, in this embodiment, when the scene is updated, the model identification starts from sequence number 1, ie ID=1.
[0193] Exemplarily, as shown in FIG8 , assuming that the current scene's to-be-rendered picture includes models: model 1, model 2, model 3, ..., model N, then the models can be taken from the to-be-rendered picture in sequence to determine whether the currently taken model is visible.
[0194] As an example, when the model to be retrieved is visible, the current model identification number is assigned to the current model, that is, the identification of the current model is controlled to be equal to the current model identification number (that is, model id = ID). Accordingly, the model identification number is increased by 1 (ID = ID + 1), and the step of retrieving the model from the picture to be rendered is performed.
[0195] As another example, when the model to be retrieved is not visible, the process directly proceeds to the step of retrieving the model from the image to be rendered.
[0196] In an embodiment of the present application, during the process of initiating model drawing, each model is assigned a unique positive integer identifier, which is used as the rendering template value. The template value is output to the template cache while drawing the model color, which can meet the needs of continuous updating of scenes in scenes with dynamic characteristics and improve the realism of the picture.
[0197] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of method. In order to realize the above functions, it includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily appreciate that, in combination with the method steps of each example described in the embodiment disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in a hardware or computer software driven hardware manner depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0198] In the embodiment of the present application, the functional modules of the device for implementing the rendering method can be divided according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical functional division. In actual implementation, there may be other division methods.
[0199] 9 is a schematic diagram of the structure of a chip provided in an embodiment of the present application. As shown in FIG9 , a chip 900 includes one or more (including two) processors 901 , a communication line 902 , a communication interface 903 and a memory 904 .
[0200] The processor 901 is implemented by a GPU, or the processor 901 is implemented by a CPU and a GPU.
[0201] In some embodiments, the memory 904 stores the following elements: executable modules or data structures, or a subset thereof, or an extended set thereof.
[0202] The methods described in the embodiments of the present application can be applied to or implemented by processor 901. Processor 901 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the above method can be completed by hardware integrated logic circuits in processor 901 or by software instructions. Processor 901 can implement or execute the methods, steps, and logic block diagrams related to each process disclosed in the embodiments of the present application.
[0203] The steps of the method disclosed in the embodiments of the present application can be directly implemented as being executed by a hardware decoding processor, or can be implemented by a combination of hardware and software modules in the decoding processor. The software module can be located in a storage medium mature in the art, such as a random access memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable read-only memory (EEPROM). The storage medium is located in the memory 904, and the processor 901 reads the information in the memory 904 and performs the steps of the above method in conjunction with its hardware.
[0204] The processor 901 , the memory 904 , and the communication interface 903 may communicate with each other via a communication line 902 .
[0205] In the above embodiment, the instructions stored in the memory for execution by the processor may be implemented in the form of a computer program product, wherein the computer program product may be pre-written in the memory or downloaded and installed in the memory in the form of software.
[0206] The present application also provides a computer program product including one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center via a wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) method. The computer-readable storage medium can be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrated. For example, the available medium can include magnetic media (e.g., floppy disk, hard disk or tape), optical media (e.g., digital versatile disc (DVD)), or semiconductor media (e.g., solid state disk (SSD)).
[0207] The present application also provides a computer-readable storage medium. The methods described in the above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. If implemented in software, the functions can be stored as one or more instructions or codes on a computer-readable medium or transmitted on a computer-readable medium. Computer-readable media can include computer storage media and communication media, and can also include any medium that can transfer a computer program from one place to another. The storage medium can be any target medium that can be accessed by a computer.
[0208] In one possible implementation, computer-readable media may include RAM, ROM, compact disc read-only memory (CD-ROM) or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium designed to carry or store the desired program code in the form of instructions or data structures and accessible by a computer. Moreover, any connection is appropriately referred to as a computer-readable medium. For example, if a coaxial cable, fiber optic cable, twisted pair, digital subscriber line (DSL) or wireless technologies such as infrared, radio and microwave are used to transmit software from a website, server or other remote source, the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technologies such as infrared, radio and microwave are included in the definition of medium. Disk and optical disk as used herein include optical disk, laser disk, optical disk, digital versatile disk (DVD), floppy disk and Blu-ray disk, where disks generally reproduce data magnetically, while optical disks reproduce data optically using lasers. Combinations of the above should also be included within the scope of computer-readable media.
[0209] The present application embodiment is described with reference to the flow chart and / or block diagram according to the method, device (system) and computer program product of the embodiment of the present application.It should be understood that each flow process and / or box in the flow chart and / or block diagram and the combination of the flow process and / or box in the flow chart and / or block diagram can be realized by computer program instructions.These computer program instructions can be provided to the processing unit of general-purpose computer, special-purpose computer, embedded processing machine or other programmable data processing equipment to produce a machine, so that the instruction executed by the processing unit of computer or other programmable data processing equipment produces the device for realizing the function specified in one flow chart flow chart or multiple flow charts and / or one block or multiple blocks of block diagram.
[0210] The above specific implementation methods further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above are only specific implementation methods of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent replacements, improvements, etc. made on the basis of the technical solutions of the present invention should be included in the scope of protection of the present invention.
Claims
1. A rendering method, applied to an electronic device, characterized in that: The method comprises: Acquire data to be rendered, wherein the data to be rendered includes a model to be rendered; When the model to be rendered meets a first condition, performing ray tracing rendering on the model to be rendered based on a first light emission density; When the model to be rendered meets the second condition, performing ray tracing rendering on the model to be rendered based on the second light emission density; The model to be rendered satisfies the first condition, which includes: the visible range proportion of the model to be rendered in the image to be rendered is the first visible range proportion, and the distance between the model to be rendered and the camera device is the first distance; The model to be rendered satisfies the second condition, including: the visible range proportion of the model to be rendered in the image to be rendered is the second visible range proportion, and the distance between the model to be rendered and the camera device is the second distance; The first visible range ratio is different from the second visible range ratio, and / or the first distance is different from the second distance; The picture to be rendered is drawn by the camera device based on the data to be rendered during the rendering process, and the camera device is a virtual camera in the electronic device.
2. The method according to claim 1, characterized in that When the first visible range accounts for the same proportion as the second visible range, if the first distance is greater than the second distance, the first light emission density is less than the second light emission density.
3. The method according to claim 1, characterized in that When the first distance is the same as the second distance, if the first visible range accounts for a larger proportion than the second visible range, the first light emission density is greater than the second light emission density.
4. The method according to any one of claims 1 to 3, characterized in that The method further comprises: Determining the conditions satisfied by the model to be rendered according to the proportion of the visible range of the model to be rendered in the picture to be rendered and the distance between the model to be rendered and the camera device; Determining the light emission density of the model to be rendered according to the conditions satisfied by the model to be rendered; Wherein, when the condition satisfied by the model to be rendered is the first condition, the light emission density is the first light emission density; When the condition satisfied by the model to be rendered is the second condition, the light emission density is the second light emission density.
5. The method according to claim 4, characterized in that The step of determining the light emission density of the model to be rendered according to the conditions satisfied by the model to be rendered includes: Based on a preset first weight coefficient and a second weight coefficient, a weighted sum is performed on the visible range ratio of the model to be rendered in the image to be rendered and the distance between the model to be rendered and the camera device to obtain a light emission density coefficient of the model to be rendered; The light emission density of the model to be rendered is determined according to the light emission density coefficient of the model to be rendered and a preset first relationship, where the first relationship is used to represent a corresponding relationship between the light emission density coefficient and the light emission density.
6. The method according to any one of claims 1 to 5, characterized in that Performing ray tracing rendering on the to-be-rendered model based on a ray emission density, where the ray emission density is the first ray emission density or the second ray emission density, includes: Performing ray tracing rendering on the model to be rendered based on the light emission density to obtain a ray tracing rendering result image of the model to be rendered, wherein the ray tracing rendering result image carries void pixels; The hole pixels in the ray tracing rendering result image are filled with color according to the template value of each pixel of the model to be rendered when the rendering is initiated and the scene semantic image of the model to be rendered, wherein the scene semantic image is used to identify the model to which the pixel belongs.
7. The method according to claim 6, characterized in that The step of performing ray tracing rendering on the model to be rendered based on the light emission density to obtain a ray tracing rendering result image of the model to be rendered includes: Determining target pixels in the model to be rendered that need to be rendered using ray tracing based on the light emission density and a preset shading pixel arrangement, wherein the shading pixel arrangement is used to indicate pixel position arrangement information for rendering using ray tracing; Performing ray tracing rendering on the target pixel to obtain color data of the target pixel; The color data is output to the location of the target pixel to obtain a ray tracing rendering result image of the model to be rendered.
8. The method according to claim 6, characterized in that Filling the empty pixels in the ray tracing rendering result image with colors according to the template value of each pixel of the to-be-rendered model when rendering is initiated and the scene semantic image of the to-be-rendered model, includes: For any pixel in the ray tracing rendering result image, determine whether the current pixel sampled is a hole pixel; When the current pixel is a hole pixel, based on the template value of each pixel of the to-be-rendered model when rendering is initiated and the scene semantic image, determining a reference pixel having the same template value as the hole pixel on the ray tracing rendering result image, the reference pixel being a pixel having existing color data on the ray tracing rendering result image; The hole pixels are filled with colors using the color data of the reference pixels.
9. The method according to claim 8, characterized in that The determining, based on the template value of each pixel of the to-be-rendered model when rendering is initiated and the scene semantic image, a reference pixel having the same template value as the hole pixel on the ray tracing rendering result image, includes: According to the scene semantic image of the model to be rendered, the texture coordinates of the hole pixel and the texture coordinates of the first pixel with existing color data on the ray tracing rendering result image are obtained; Based on the texture coordinates of the hole pixel and the texture coordinates of the first pixel, querying a template cache position to determine a template value of the hole pixel and a template value of the first pixel; the template cache position is used to store the template value of each pixel of the to-be-rendered model when rendering is initiated; When the template value of the hole pixel is consistent with the template value of the first pixel, determining the first pixel as a reference pixel of the hole pixel; When the template value of the hole pixel is inconsistent with the template value of the first pixel, other pixels with existing color data on the ray tracing rendering result image are traversed until a reference pixel with the same template value as the hole pixel is determined.
10. The method according to any one of claims 1 to 9, characterized in that Performing ray tracing rendering on the model to be rendered includes: Ray tracing rendering is performed on the model to be rendered using the bound Vulkan ray tracing acceleration structure.
11. A rendering device, applied to an electronic device, characterized in that: The device comprises: An acquisition unit, configured to acquire data to be rendered, wherein the data to be rendered includes a model to be rendered; a processing unit, configured to perform ray tracing rendering on the model to be rendered based on a first ray emission density when the model to be rendered meets a first condition, and to perform ray tracing rendering on the model to be rendered based on a second ray emission density when the model to be rendered meets a second condition; The model to be rendered satisfies the first condition, which includes: the visible range proportion of the model to be rendered in the image to be rendered is the first visible range proportion, and the distance between the model to be rendered and the camera device is the first distance; The model to be rendered satisfies the second condition, including: the visible range proportion of the model to be rendered in the image to be rendered is the second visible range proportion, and the distance between the model to be rendered and the camera device is the second distance; The first visible range ratio is different from the second visible range ratio, and / or the first distance is different from the second distance; The picture to be rendered is drawn by the camera device based on the data to be rendered during the rendering process, and the camera device is a virtual camera in the electronic device.
12. An electronic device, characterized in that: include: A memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program to perform the rendering method according to any one of claims 1 to 10.
13. A computer-readable storage medium, characterized in that The computer-readable storage medium stores instructions, and when the instructions are executed, causes a computer to execute the rendering method according to any one of claims 1 to 10.
14. A computer program product, characterized in that The invention comprises a computer program, which, when being executed, enables an electronic device to perform the rendering method according to any one of claims 1 to 10.