Rendering method and rendering system based on cache shader

By introducing cache shaders into the rendering system, cache the calculation results of other shaders, and performing sampling and interpolation, the problem of ray tracing renderers being rendered for a long time in complex scenes is solved, and efficient rendering is achieved.

CN119625099APending Publication Date: 2025-03-14MOJINGTIANHE WUXI DIGITAL IMAGE TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411681432.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-03-14

AI Technical Summary

Technical Problem

The existing ray tracing renderers significantly increase rendering time when working with complex scenes, resulting in inefficiency.

Method used

The rendering method based on cache shaders is adopted to reduce repeated calculations by cached the calculation results of other shaders and sampling and interpolation when needed.

Benefits of technology

It significantly improves rendering efficiency, reduces rendering time, and meets the dual needs of high efficiency and high quality in film and television production.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119625099A_ABST
    Figure CN119625099A_ABST
Patent Text Reader

Abstract

The invention relates to a rendering method and system based on a cache shader, and the method comprises the steps: enabling a subsequent shader to send request information for calling a coloring calculation result, and judging whether the coloring calculation result is located in the cache shader or not; if yes, sampling is carried out from the cache shader, and if not, a front shader is called for sampling, and coloring calculation is carried out again; a re-calculated coloring calculation result is stored in a cache shader; according to the method, the cache shader is arranged, calculation results of other shaders are cached, sampling and interpolation are preferentially carried out on the cache result during final output, the cache result can be directly used in the subsequent rendering process, repeated calculation is not needed, and therefore the rendering efficiency is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to image processing technology, and in particular to a rendering method and a rendering system based on a cache shader. Background Art

[0002] In the field of modern film and television production and visual effects (VFX), the balance between rendering efficiency and effect has always been an important challenge. As the last step in the VFX production process, the efficiency of rendering directly affects the progress and cost of the entire project. In order to ensure the realism and exquisiteness of the final effect, high-precision offline renderers, especially ray tracing renderers, are usually used in film and television production, rather than efficient real-time renderers commonly used in game production. Offline renderers achieve the best visual effects by sampling each pixel multiple times to reduce noise and generate smooth images.

[0003] Ray tracing renderers can realistically reproduce complex optical phenomena such as light and shadow effects, reflection and refraction by simulating the propagation and reflection of light in the scene. However, this high-precision rendering method requires a lot of computing resources. Multiple sampling of each pixel means that the rendering time will increase significantly, especially when the scene complexity is high. For each shader, multiple sampling within the same pixel, its computational complexity directly affects the rendering efficiency. Summary of the invention

[0004] In view of the deficiencies in the prior art, the present invention discloses a rendering method and a rendering system based on a cache shader.

[0005] The technical solution adopted by the present invention is as follows:

[0006] A rendering method based on a cache shader comprises the following steps:

[0007] The subsequent shader sends a request message for calling the shader calculation result, and determines whether the shader calculation result is located in the cache shader;

[0008] If yes, sampling is performed from the cache shader, if no, the preceding shader is called to perform sampling and re-calculate the shading;

[0009] Save the recalculated shading calculation results in the cache shader;

[0010] Its further technical solution is that the sampling method is:

[0011] Determine the pixel points to be sampled;

[0012] Find four integer pixel points around the pixel point to be sampled that are closest to the pixel point to be sampled in a straight line; the integer pixel points are pixel points whose horizontal coordinate values ​​and vertical coordinate values ​​are both integers;

[0013] The integer pixel points are sampled.

[0014] A further technical solution is that the cache shader is a cache structure based on a hash table data structure.

[0015] A further technical solution is to perform interpolation calculation on the sampling result after sampling to obtain a rendering result.

[0016] A further technical solution is that the rendering method is applied to a rendering scene, and if the rendering scene is refreshed, the cache of the cache shader is cleared.

[0017] A further technical solution is that the rendering method further includes a Mipmap processing process.

[0018] A further technical solution is that the Mipmap processing process specifically includes:

[0019] When starting the shader operation, determine whether it is the penetration mode;

[0020] If it is penetration mode, directly call the pre-shader to get the result; if not, determine whether it is Mipmap debug mode;

[0021] If it is Mipmap debug mode, get the Mipmap debug color; if not, determine whether Mipmap is enabled;

[0022] If Mipmap is enabled, after getting the Mipmap level, calculate the Mipmap interpolation, and then calculate the texture interpolation;

[0023] Afterwards, when a subsequent shader requests a shading calculation result, a step is performed to determine whether the shading calculation result is located in the cache shader.

[0024] A rendering system based on a cache shader, used to implement a rendering method based on a cache shader as described in any of the above items, the rendering system includes a shader network; the shader network includes multiple shaders; the subsequent shader calls the shading calculation result of the previous shader and performs shading calculation; the cache shader is located on the operation network between the previous shader and the subsequent shader.

[0025] A further technical solution is that the rendering system further comprises:

[0026] The penetration mode judgment module is used to judge whether it is the penetration mode when starting the shader operation; if it is the penetration mode, the subsequent shader directly calls the previous shader to obtain the result;

[0027] Mipmap debug mode judgment module, used to judge whether it is Mipmap debug mode when the penetration mode judgment module judges it is no; if it is Mipmap debug mode, the subsequent shader obtains Mipmap debug color;

[0028] Enable Mipmap judgment module, used to determine whether to enable Mipmap when the Mipmap debugging mode judgment module determines no;

[0029] A Mipmap interpolation calculation module is used to receive information about enabling the Mipmap judgment module. If Mipmap is enabled, the Mipmap interpolation is calculated after obtaining the Mipmap level. If Mipmap is not enabled, the Mipmap interpolation is calculated after the Mipmap level is set to 0.

[0030] The texture interpolation calculation module is used to calculate texture interpolation.

[0031] The beneficial effects of the embodiments of the present invention are as follows:

[0032] The embodiment of the present invention designs and implements a new shader optimization scheme. The core design idea of ​​the scheme is to set a cache shader, cache the calculation results of other shaders, and give priority to sampling and interpolating the cached results when finally outputting. Specifically, the cache shader can store the output results of other shaders in memory in a similar way to images. This caching mechanism allows the cached results to be used directly in the subsequent rendering process without repeated calculations, thereby greatly improving the rendering efficiency.

[0033] Although the introduction of the cache mechanism requires a certain amount of memory space, the efficiency improvement it brings is significant. In practical applications, relatively accurate rendering output can be generated by interpolating the cached results. This method significantly shortens the rendering time while sacrificing a small amount of memory, making efficient rendering possible. In this way, the overall rendering speed can be improved while ensuring the rendering quality, meeting the dual requirements of high efficiency and high quality in film and television production.

[0034] Embodiments of the present invention are particularly suitable for ray tracing renderers, which can realistically reproduce complex optical phenomena such as light and shadow effects, reflection and refraction by simulating the propagation and reflection of light in a scene. However, this high-precision rendering method requires a large amount of computing resources. Multiple sampling of each pixel means that the rendering time will increase significantly, especially when the scene complexity is high. This is particularly evident. For multiple samplings of each shader within the same pixel, its computational complexity directly affects the rendering efficiency. In this case, the rendering method and system using a cached shader can improve the rendering efficiency while ensuring the rendering quality. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 Schematic diagram of a shader network in an embodiment of the present invention.

[0036] Figure 2 1 is a step diagram of a rendering method based on a cache shader in an embodiment of the present invention.

[0037] Figure 3 This is a step diagram of a rendering method based on a cache shader in a Mipmap processing process in an embodiment of the present invention. DETAILED DESCRIPTION

[0038] The specific implementation of the present invention will be described below in conjunction with the accompanying drawings.

[0039] The embodiment of the present invention relates to a rendering method based on a cache shader, and the rendering method is implemented based on a rendering system. Specifically, the rendering system includes a shader network. Figure 1 FIG. 1 is a schematic diagram of a shader network in an embodiment of the present invention. Figure 1 As shown, the material operation of an object requires an entire shader network to complete. The shader network includes multiple shaders as operation nodes of the shader network. The subsequent shader calls the shading calculation result of the previous shader and performs shading calculation. In the shader network, the subsequent shader refers to the shader that can call other shader results for calculation, and the shader called by the subsequent shader for calculation results is the previous shader. The data call and transmission between the subsequent shader and the previous shader are not single-line, but form a network structure. For example, a subsequent shader can call the calculation results of more than one previous shader, and a previous shader may also be called by more than one subsequent shader. At the same time, the role played by a shader in the calculation network can also be adjusted as needed. When the shader is called by other shaders to calculate the result, it can be a previous shader, and when it needs to call the results of other shaders in the network, it can be a subsequent shader. This is determined according to the transmission direction of the calculation result.

[0040] The input value of the shader is generally the intermediate operation result of the previous shader or the original data to be processed. Usually, this input is the intermediate data from other processing steps for further processing by the current shader.

[0041] The shading calculation results output by the shader include color values, which can be single-channel, RGB or RGBA. The operation of the shader is called on demand, and the operation is not performed on the entire image at one time. Instead, the renderer calls the shader when it needs to calculate the color of a certain point of an object. Only this point is calculated each time, and various parameters required for the operation are passed through the shader global parameters (shaderglobal), such as UV values, screen space xy values ​​or normals.

[0042] The cache shader is located on the computing network between the previous shader and the subsequent shader, and is bridged to the network node between the previous shader and the subsequent shader. The cache shader becomes a cache node, which caches the calculation results of the previous shader.

[0043] Based on the rendering system described above, the rendering method based on cache shader disclosed in this embodiment is: Figure 2 FIG. 1 is a step diagram of a rendering method based on a cache shader in an embodiment of the present invention. Figure 2 As shown, the following steps are included:

[0044] The subsequent shader sends a request message for calling the shader calculation result, and determines whether the shader calculation result is located in the cache shader.

[0045] If yes, then sample from the cache shader, if no, call the previous shader to sample and re-do the shading calculation.

[0046] Save the recomputed shading calculation results in the cache shader.

[0047] Since there is a cache shader bridged between the preceding shader and the subsequent shader, when the subsequent shader requests the shading result of a certain point on a certain object, its operation function is called. At this time, it is first checked whether it can be directly obtained from the existing cache result of the cache shader. If not, the preceding shader is called, and combined with the shading calculation result in the preceding shader, the operation function is re-calculated to obtain the shading calculation result, and saved in the cache shader for the next call.

[0048] The rendering method of this embodiment directly samples from the result of the cache shader when the shader calculation result is stored in the cache shader, without calling the pre-shader for recalculation again.

[0049] In the prior art, the sampling settings for different shaders are global, so even on shaders that do not require very high sampling, repeated calls are required, wasting resources. In the improved technology of this embodiment, such repeated calls are redirected to the cache shader, and directly sampling the output results from the cache shader will greatly increase the computing efficiency.

[0050] Furthermore, the rendering method is applied to the rendering scene, and if the rendering scene is refreshed, the cache of all cache shaders is cleared. In the subsequent calculation process, when a new calculation result is generated, the data is stored in the cache shader again.

[0051] Preferably, when the shader performs sampling calculation, the sampling method includes:

[0052] Determine the pixel to be sampled. For example, the pixel to be sampled is (1.4, 2.5)

[0053] Find the four integer pixels closest to the pixel to be sampled in a straight line around it. Integer pixels are pixels whose horizontal and vertical coordinates are both integers. For the pixel to be sampled (1.4, 2.5), the integer pixels found are (1, 2), (2, 2), (1, 3), and (2, 3).

[0054] Sampling integer pixels. The sampling position to be calculated is converted into the four nearest integer pixels around it for sampling. This sampling method uses the inverse idea of ​​bilinear interpolation to decompose complex calculation problems into simple sampling of neighboring pixels. This method not only reduces the amount of calculation, but also provides smooth sampling results, which is suitable for most rendering requirements.

[0055] Preferably, the cache shader is a cache structure based on a hash table data structure. The cache structure based on the hash table data structure can efficiently store and manage sampled data. Since the UV space usually contains a large number of tiles (in accordance with the UDIM specification), using an array to manage all possible UV positions will result in a waste of memory. Therefore, a hash table is selected as the data structure of the cache. The hash table stores only part of the data that needs to be calculated by encoding the UV. This method not only saves memory, but also improves access efficiency. The value stored in the cache shader can be a single-channel floating point number or a multi-channel RGB or RGBA value, depending on the specific rendering requirements. Through this flexible data storage method, different rendering quality requirements can be met while ensuring reasonable memory usage.

[0056] Preferably, after sampling, the sampling results are interpolated to obtain the rendering result. The purpose of the interpolation stage is to combine the sampling results obtained from the cache shader to obtain the final rendering result. Preferably, a bilinear interpolation calculation method is used, which can smoothly transition pixel values, thereby reducing artifacts and aliasing effects when rendering images. In addition, other types of interpolation methods, such as more accurate bicubic interpolation, can also be used to meet the needs of different application scenarios.

[0057] The present embodiment further includes a Mipmap (multumin parvo, multi-level asymptotic texture technology) processing process. Mipmap is a texture optimization technology widely used in computer graphics, which aims to improve the efficiency and quality of image rendering. The basic idea of ​​Mipmap is to generate a series of pre-processed images of different resolutions for texture images, and dynamically select the appropriate image level according to the distance of texture mapping during the rendering process. This technology can effectively reduce the blur effect and graininess of the texture, while improving rendering performance.

[0058] Figure 3 FIG. 4 is a step diagram of a rendering method based on a cache shader in a Mipmap processing process in an embodiment of the present invention. Figure 3 As shown, specifically, the Mipmap processing process includes the following steps:

[0059] When starting shader operation, determine whether it is pass-through mode. Pass-through mode directly evaluates the input data and ignores the processing effect of the current node. It is used for quick comparison and debugging to check the status of data that has not been processed by the current node.

[0060] If it is penetration mode, the previous shader is called directly to get the result. If not, it is determined whether it is Mipmap debug mode. In Mipmap debug mode, the output shows the Mipmap level used for each pixel. To make the result more intuitive, the displayed value is the ratio of cache resolution to custom resolution, 1 represents full resolution, and close to 0 represents lower resolution. It is used to help debug and verify the selection and use of Mipmap levels, and to analyze the detail level and filtering effect of textures.

[0061] If it is Mipmap debug mode, get the Mipmap debug color. If not, determine whether Mipmap is enabled.

[0062] If Mipmap is enabled, after getting the Mipmap level, calculate the Mipmap interpolation, and then calculate the texture interpolation. When calculating Mipmap interpolation, you can use different Mipmap levels as needed. For example, if it is a simple texture mapping requirement, you can use the closest Mipmap level. Or you can use a linear level to perform linear interpolation between the two closest Mipmap levels to provide a smooth transition effect. When Mipmap is not used, only the highest resolution texture data is used.

[0063] Afterwards, when a subsequent shader requests a shading calculation result, a step is performed to determine whether the shading calculation result is located in a cached shader.

[0064] Applying the rendering method in this embodiment to the Mipmap processing process can make the Mipmap processing process not only used for traditional texture optimization, but also have the effect of adaptively adjusting the cache size and improving the cache hit rate. Since there is a cache shader in the calculation process, the size of the Mipmap cache can be dynamically adjusted according to the usage and demand of the texture. This intelligent adjustment mechanism can optimize memory usage and reduce unnecessary computing overhead while ensuring high-quality rendering. Through reasonable cache management, the system can use memory more efficiently and avoid performance bottlenecks caused by excessive or too small cache. Cache hit rate is an important indicator for measuring the performance of the cache system. In a system using Mipmap technology, the cache hit rate can be improved by optimizing the selection and cache strategy of the Mipmap level. The system will select the most appropriate Mipmap level for storage and access according to the actual needs and usage of the texture, thereby reducing the probability of cache misses and further improving rendering speed and efficiency.

[0065] The rendering system that implements the above Mipmap processing process includes:

[0066] The penetration mode judgment module is used to judge whether it is the penetration mode when starting the shader operation; if it is the penetration mode, the subsequent shader directly calls the previous shader to obtain the result;

[0067] Mipmap debug mode judgment module, used to judge whether it is Mipmap debug mode when the penetration mode judgment module judges it is no; if it is Mipmap debug mode, the subsequent shader obtains Mipmap debug color;

[0068] Enable Mipmap judgment module, used to determine whether to enable Mipmap when the Mipmap debugging mode judgment module determines no;

[0069] A Mipmap interpolation calculation module is used to receive information about enabling the Mipmap judgment module. If Mipmap is enabled, the Mipmap interpolation is calculated after obtaining the Mipmap level. If Mipmap is not enabled, the Mipmap interpolation is calculated after the Mipmap level is set to 0.

[0070] The texture interpolation calculation module is used to calculate texture interpolation.

[0071] The above description is an explanation of the present invention, not a limitation of the present invention. The scope of the present invention is defined in the claims. The present invention may be modified in any form without violating the basic structure of the present invention.

Claims

1. A rendering method based on cache shader, characterized in that: The following steps are involved: The subsequent shader sends a request message for calling the shader calculation result, and determines whether the shader calculation result is located in the cache shader; If yes, sampling is performed from the cache shader, if no, the preceding shader is called to perform sampling and re-calculate the shading; Save the recomputed shading calculation results in the cache shader.

2. The rendering method based on cache shader according to claim 1, characterized in that: The sampling method is: Determine the pixel points to be sampled; Find four integer pixel points around the pixel point to be sampled that are closest to the pixel point to be sampled in a straight line; the integer pixel points are pixel points whose horizontal coordinate values ​​and vertical coordinate values ​​are both integers; The integer pixel points are sampled.

3. The rendering method based on cache shader according to claim 1, characterized in that: The cache shader is a cache structure based on a hash table data structure.

4. The rendering method based on cache shader according to claim 1, characterized in that: After sampling, the sampling results are interpolated to obtain the rendering result.

5. The rendering method based on cache shader according to claim 1, characterized in that: The rendering method is applied to a rendering scene, and if the rendering scene is refreshed, the cache of the cache shader is cleared.

6. The rendering method based on cache shader according to claim 1, characterized in that: The rendering method further includes a Mipmap processing process.

7. The rendering method based on cache shader according to claim 6, characterized in that: The Mipmap processing process specifically includes: When starting the shader operation, determine whether it is the penetration mode; If it is penetration mode, directly call the pre-shader to get the result; if not, determine whether it is Mipmap debug mode; If it is Mipmap debug mode, get the Mipmap debug color; if not, determine whether Mipmap is enabled; If Mipmap is enabled, after getting the Mipmap level, calculate the Mipmap interpolation, and then calculate the texture interpolation; Afterwards, when a subsequent shader requests a shading calculation result, a step is performed to determine whether the shading calculation result is located in the cache shader.

8. A rendering system based on cache shader, characterized in that: Used to implement the cache shader-based rendering method described in any one of claims 1 to 6, the rendering system includes a shader network; the shader network includes multiple shaders; the subsequent shader calls the shading calculation result of the previous shader and performs shading calculation; the cache shader is located on the operation network between the previous shader and the subsequent shader.

9. The cache shader-based rendering system according to claim 8, characterized in that: The rendering system further comprises: The penetration mode judgment module is used to judge whether it is the penetration mode when starting the shader operation; if it is the penetration mode, the subsequent shader directly calls the previous shader to obtain the result; Mipmap debug mode judgment module, used to judge whether it is Mipmap debug mode when the penetration mode judgment module judges it is no; if it is Mipmap debug mode, the subsequent shader obtains Mipmap debug color; Enable Mipmap judgment module, which is used to determine whether to enable Mipmap when the Mipmap debugging mode judgment module determines that it is not; A Mipmap interpolation calculation module is used to receive information about enabling the Mipmap judgment module. If Mipmap is enabled, the Mipmap interpolation is calculated after obtaining the Mipmap level. If Mipmap is not enabled, the Mipmap interpolation is calculated after the Mipmap level is set to 0. The texture interpolation calculation module is used to calculate texture interpolation.