Soft shadow algorithm with contact hardening effect for mobile GPU

By downsampling the shadow map and using the base spline filtering algorithm, the problem of shadow rendering delay and numerical accuracy in the existing technology is solved, and an efficient and low-latency shadow rendering effect is achieved, which is significantly improved especially in the mobile GPU environment. frame rate.

CN118696350APending Publication Date: 2024-09-24HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202280091722.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2022-04-29
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

The existing technology has the problem that the sampling operation consumes a large amount of GPU memory bandwidth and rendering delay when rendering shadow images, especially when using larger filtering kernel algorithms based on PCF and PCSS, and the numerical accuracy and calculation cost are high, resulting in shadow effects Not realistic enough.

Method used

The shadow map downsampled image is generated by downsampling the shadow map image, and combined with the basic spline filtering algorithm to reduce the number of sampling points and reduce the computational load. A 4-tap bicubic basic spline filtering algorithm is used to replace the Gaussian blur filter kernel, reducing GPU memory bandwidth required for texture sampling.

Benefits of technology

It achieves more realistic shadow effects, reduces computing load and rendering delay, improves the efficiency and quality of shadow rendering, and significantly improves the frame rate especially in mobile GPU environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118696350A
    Figure CN118696350A
Patent Text Reader

Abstract

An image processing apparatus (900) for generating a shadow effect is described. The apparatus (900) includes one or more processors (901) and a memory (902), where the memory (902) stores data defining program code in a non-transitory manner, the program code being executable by the one or more processors (901) that, when executed by the one or more processors (901), transmits the data to the one or more processors (901) to the one or more processors (901). The image processing apparatus (900) is caused to perform the following operations: acquiring an input scene (701); generating a shadow map image (702) from the input scene (701) by down-sampling the shadow map image (702) to generate one or more shadow map down-sampled images (703, 704); an output shadow effect image (705) is generated from two or more images selected from (a) the shadow map image (702) and (b) the one or more shadow map downsampled images (703, 704). An output shadow effect image (705) is generated from two or more images selected from (a) the shadow map image (702) and (b) the one or more shadow map downsampled images (703, 704), the shadows in the output shadow effect image (705) may be caused to be a combination of shadows in two or more images selected from (a) the shadow map image (702) and (b) the one or more shadow map downsampled images (703, 704). In this way, the shadow in the output shadow effect image (705) may be more vivid.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to an image processing apparatus and method for generating shadow effects, for example for video games. Background Art

[0002] Shadows can be the result of a lack of light due to occlusion. Objects are in shadow when light from a light source is blocked from reaching them. Shadows can help illuminate scenes feel realistic, making it easier for viewers to see the spatial relationships between objects. Shadows can also give scenes and objects a sense of depth. Rendering shadows can be very important for video games. This is because shadows not only add to the realism of the rendered image, but also show the distance and position of objects to the viewer.

[0003] One of the fundamental problems in computer graphics is how to generate accurate soft shadows from area light sources. Soft shadows can provide valuable clues about the relationships between objects. Shadows can be sharper when objects are touching or close to each other, and more blurred or softer when objects are farther apart.

[0004] Shadow rendering can be a basic but important feature for many applications. Applications such as video games may require shadow rendering to be very efficient. Ideally, it would take less than 10ms per frame to render.

[0005] However, rendering high-quality soft shadows using filtering algorithms (e.g., using percentage closer filtering (PCF)) can be very expensive and demanding, especially for modern mobile GPUs, as these algorithms involve large kernel sizes and a large number of texture sampling taps.

[0006] The first method of rendering shadow images is shadow mapping and percentage closer filtering (PCF).

[0007] Figure 1 An exemplary depth map of shadows is schematically shown 100. Light source 101 may be blocked by occluder 102. Shadow 103 may be formed behind occluder 102. Occluder 102 may be at a distance Z 104 from light source 101. Shadow 103 may be at a distance d 105 from light source 101.

[0008] The principle of shadow mapping is to render the scene from the perspective of the light source 101, all parts visible from the perspective of the light source 101 are illuminated, and all parts that are not visible are in shadow 103. Therefore, shadow mapping may consist of two steps. First, in the first step, the depth map 101 is rendered. Figure 1An exemplary depth map for shadows is shown schematically. Next, in a second step, the scene is rendered as normal and the resulting depth map is used to calculate whether a fragment is in shadow.

[0009] Since the depth map 100 may have a fixed resolution, the depth of each texel may frequently span more than one fragment. As a result, multiple fragments sample the same depth value from the depth map and arrive at the same shadow conclusion. This may result in jagged, blocky edges for the shadow.

[0010] Based on shadow maps [Williams, 1978], percentage closer filtering (PCF) [Reeves et al., 1987] attempts to solve these jagged edge problems by using some filter functions that produce softer shadows, making the shadows look less angular or harsh. The principle is to sample the depth map multiple times, each time with slightly different texture coordinates. Each individual sample can be checked to see if it is in shadow. Then, all the sub-results can be combined and averaged to get a soft-looking shadow.

[0011] Figure 2 An exemplary N×N texture pixel of a depth map is shown in a schematic diagram. An exemplary implementation of PCF may be to simply sample 201 the surrounding N×N texture pixels of the depth map 200 and average the comparison results, such as Figure 2 shown.

[0012] Figure 3A and Figure 3B An exemplary shadow effect image is shown. Figure 3A An exemplary hard shadow image 300 is shown. Figure 3B An exemplary soft shadow image 302 is shown. Many modern games can be developed using Unreal and Unity engines, which often use 3x3 bilinear PCF filtering. This can be done by fetching 9 texture samples in a 3×3 grid of adjacent areas using 9 texture fetch instructions, and then performing a 3×3 triangle bilinear weighted calculation on these 9 samples in the fragment shader to obtain a smooth filtered shadow. The shadow 301 in the hard shadow image is shown in FIG. Figure 3A In contrast, Figure 3B The shadow 303 using PCF filtering has smoother edges.

[0013] While PCF can be very good quality, achieving such high quality may require a lot of samples. As with standard texture filtering, surfaces with shallow angles may require huge anisotropic filtering areas. With PCF, it may not be possible to use pre-filtered mipmaps to speed up the process. This is because a depth comparison is required for each sample. Therefore, in the worst case, each individual texture pixel in the shadow map may need to be sampled and compared in order to calculate the light attenuation for a single framebuffer pixel. Unsurprisingly, this process can be slow. When using PCF to implement edge softening, the situation can become even worse. This is because this approach can be equivalent to setting a lower limit on the size of the filtering area, and therefore a lower limit on the cost of pixel shading.

[0014] Another disadvantage of PCF is that it may only support a fixed-size penumbra. This may be due to the use of a uniform filter kernel for all pixels, which results in no contact hardening effect.

[0015] The second method of rendering shadow images is percentage closer softshadow (PCSS).

[0016] While the original PCF method may only deal with uniform filter kernels that produce shadows with fixed-size penumbras, a variant called PCSS has been proposed to render soft shadows with variable-size penumbras. This is also called contact hardening shadows. Contact hardening shadows are a graphics effect that more accurately simulates real-life shadow effects. As the object casting the shadow gets closer to the surface being cast by the shadow, the shadow may become sharper. As the object gets farther away, the shadow will become blurrier.

[0017] Figure 4A , Figure 4B and Figure 4C An exemplary shadow effect image is shown. Figure 4A An exemplary shadow effect image 400 generated using a 1 percent closer filtering (PCF) tap kernel is shown. Figure 4B An exemplary shadow effect image 401 generated using a 9×9 PCF tap kernel is shown. Figure 4C An exemplary shadow effect image 402 generated using a percentage closer soft shadow (PCSS) kernel is shown. The shadow effect image 402 generated using the percentage closer soft shadow (PCSS) kernel shows blurrier shadows than the PCF kernel.

[0018] The PCSS method can include the following three key steps.

[0019] First, the average occlusion depth of the current pixel is calculated by averaging all depth values ​​within the initial filter kernel that are less than the depth of the current pixel.

[0020] Second, the average blocker depth is used to calculate the penumbra size. Note that PCSS assumes that blockers / receivers are all flat and parallel. Using this assumption, the penumbra can be easily calculated from similar triangles, as Figure 5 shown. Figure 5 An exemplary depth map of a shadow is schematically shown. Light source 501 may be blocked by obstruction 502. Shadow 503 may be formed behind obstruction 502.

[0021] Third, a loop is performed using PCF on all sample points in the penumbra 504 to perform shadow comparisons and sum the visibility to obtain soft shadows. Since the implementation of PCSS may only result in shader modifications, it may be easy to integrate into existing rendering systems.

[0022] However, PCSS can achieve visually reasonable quality and real-time performance, but only for very small area lights. For large area lights, the performance of PCSS may be affected due to the larger PCF filter kernel required.

[0023] A key point of PCSS is that these steps are based on brute force point sampling of the depth map. When the area light size becomes large, many sampling points (e.g., 30×30) are required to avoid banding artifacts.

[0024] Increasing the kernel size of PCF may increase the softness of shadows, but for large kernels, many texture samples will be involved. Therefore, this may consume a lot of memory bandwidth and affect rendering performance.

[0025] A third method for rendering shadow images is a variance shadow map based on a summed-area table (SAT).

[0026] Based on PCSS, more efficient pre-filtering methods have been proposed, such as SAT-based variance shadow map (SAVSM). This method can support pre-filtering based on the single-tailed version of Chebyshev's inequality and requires much less texture memory.

[0027] The algorithm is similar to that of the standard shadow map, except that instead of simply writing the depth to the shadow map, the depth and the depth squared are written to a two-component variance shadow map. By filtering a region, the two moments M1 and M2 of the depth distribution in that region can be recovered. From this, the mean and variance of the distribution can be calculated. Using the variance, the Chebyshev inequality (as shown in Equations 1 and 2) can be used to calculate an upper bound on the probability that a surface currently in shadow (at depth t) is occluded.

[0028] E(x)=x,σ 2 =E(x 2 )-E(x) 2 (1)

[0029]

[0030] Specifically, for a single occluder and a single receiver, there may be a small neighborhood within which they are locally flat, so the probability computed in this area may be a good approximation of the true probability. As shown in Figure 4, PCSS may require the use of large filter kernels for pixels with large penumbras, which may be expensive. However, as shown in Equation 3, this algorithm requires compute shaders to compute SAT, which is very expensive because every single pixel needs to be integrated over a large image area.

[0031]

[0032] In addition, it is well known that SAT may suffer from numerical precision loss for large filter kernels. Specifically, in order to obtain stable shadow quality, SAT generation uses a 32-bit integer format. However, in the contact shadow area, where the blocker and the receiver are placed very close, the precision of integer SAT may still be insufficient and may introduce small errors.

[0033] Additionally, SAT is a fast box filter that uses the same weights for all texels within the kernel. This can produce blocky effects for soft shadows.

[0034] In summary, the prior art mainly includes the following defects:

[0035] A large number of sampling operations consumes a lot of GPU memory bandwidth and may increase rendering latency. This can be seen in larger filter kernel algorithms based on PCF and PCSS.

[0036] · Found numerical precision issues in the SAT-based variance shadow map algorithm and the high cost of the compute shaders used by SAT generation.

[0037] • Prior art systems typically use a box filter that has the same weight for all texels within a kernel, which can produce unwanted soft shadow blocking artifacts.

[0038] It is necessary to develop a device and method for solving the above problems. Summary of the invention

[0039] According to a first aspect, an image processing device for generating a shadow effect is provided. The device includes one or more processors and a memory, wherein the memory stores data defining a program code in a non-transient manner, the program code being executable by the one or more processors, and the program code, when executed by the one or more processors, causes the image processing device to perform the following operations: obtain an input scene; generate a shadow map image from the input scene; generate one or more shadow map downsampled images by downsampling the shadow map image; generate an output shadow effect image based on two or more images selected from (a) the shadow map image and (b) the one or more shadow map downsampled images.

[0040] Generating an output shadow effect image based on two or more images selected from (a) the shadow map image and (b) one or more shadow map downsampled images can make the shadows in the output shadow effect image a combination of shadows in the two or more images selected from (a) the shadow map image and (b) one or more shadow map downsampled images. In this way, the shadows in the output shadow effect image can be more realistic.

[0041] In some implementations, the apparatus may be configured to generate the output shadow effect image by sampling the two or more images selected from (a) the shadow map image and (b) the one or more shadow map downsampled images.

[0042] By sampling two or more images to generate an output shadow effect image, the apparatus is able to check whether a pixel is in the shadow of an object.

[0043] In some implementations, the apparatus may be configured to generate the output shadow effect image by performing linear interpolation between samples in the two or more images selected from (a) the shadow map image and (b) the one or more shadow map downsampled images.

[0044] The output shadow effect image is generated by performing linear interpolation between samples in the two or more images, which can be generated by combining or averaging the two or more images.

[0045] In some implementations, the apparatus may be configured to generate other shadow map downsampled images by downsampling the shadow map downsampled image.

[0046] In some implementations, the apparatus may be configured to generate the output shadow effect image based on the shadow map downsampled image and the other shadow map downsampled images.

[0047] In some implementations, the apparatus may be configured to generate the one or more shadow map downsampled images as at least a portion of a map.

[0048] By generating other shadow map downsampled images, the above-mentioned apparatus can provide other levels of downsampling, thereby providing a larger range of levels to combine to form softer shadows.

[0049] In some implementations, the device can be used to generate the shadow map image from the input scene in the following manner, wherein the input scene includes one or more objects and one or more light sources: calculating a blocking area of ​​the input scene, wherein the one or more light sources are blocked by the one or more objects within the blocking area; estimating an average blocking depth; and calculating a penumbra size based on the blocking area and the average blocking depth.

[0050] The size and location of the shadow can be determined by calculating the occlusion area, estimating the occlusion depth, and calculating the penumbra size to generate a shadow map image.

[0051] According to a second aspect, a computer-implemented method for generating a shadow effect is provided. The method comprises: obtaining an input scene; generating a shadow map image from the input scene; generating one or more shadow map downsampled images by downsampling the shadow map image; and generating an output shadow effect image based on two or more images selected from (a) the shadow map image and (b) the one or more shadow map downsampled images.

[0052] Generating an output shadow effect image based on two or more images selected from (a) the shadow map image and (b) one or more shadow map downsampled images can make the shadows in the output shadow effect image a combination of shadows in the two or more images selected from (a) the shadow map image and (b) one or more shadow map downsampled images. In this way, the shadows in the output shadow effect image can be more realistic.

[0053] According to a third aspect, an image processing device for generating a shadow effect is provided. The device comprises one or more processors and a memory, wherein the memory stores data defining a program code in a non-transient manner, the program code being executable by the one or more processors, and the program code, when executed by the one or more processors, causes the image processing device to perform the following operations: acquiring an input scene; generating a shadow map image from the input scene; generating a filtered shadow map image from the shadow map image by a basis spline filtering algorithm; and generating an output shadow effect image based on the filtered shadow map image.

[0054] By generating an output shadow effect image based on the filtered shadow map image, the number of sampling points can be reduced, which can reduce the computational load, power consumption and rendering delay.

[0055] In some implementations, the apparatus may be configured to filter the shadow map image using a 4-tap bicubic spline filtering algorithm.

[0056] Using a 4-tap bicubic spline filtering algorithm, realistic shadow effects can be provided while reducing the number of sampling points.

[0057] In some implementations, the apparatus may be configured to generate the output shadow effect image from the filtered shadow map image by estimating the probability that a pixel is blocked within a neighboring region.

[0058] The output shadow effect image is generated by estimating the probability that a pixel is blocked in the neighboring area, and the size and location of the shadow can be estimated.

[0059] According to a fourth aspect, a computer-implemented method for generating a shadow effect is provided. The method comprises: obtaining an input scene; generating a shadow map image from the input scene; generating a filtered shadow map image from the shadow map image by a basis spline filtering algorithm; and generating an output shadow effect image based on the filtered shadow map image.

[0060] By generating an output shadow effect image based on the filtered shadow map image, the number of sampling points can be reduced, which can reduce the computational load, power consumption and rendering delay.

[0061] According to a fifth aspect, an image processing device for generating a shadow effect is provided. The device includes one or more processors and a memory, wherein the memory stores data defining a program code in a non-transient manner, the program code being executable by the one or more processors, and the program code, when executed by the one or more processors, causes the image processing device to perform the following operations: acquiring an input scene; generating a shadow map image from the input scene; generating one or more shadow map downsampled images by downsampling the shadow map image; generating a filtered shadow map image from the shadow map image by a base spline filtering algorithm; generating a filtered shadow map downsampled image from each of the one or more shadow map downsampled images by a base spline filtering algorithm; generating an output shadow effect image based on two or more images selected from (a) the filtered shadow map image and (b) the one or more filtered shadow map downsampled images.

[0062] Combining downsampling with the basis spline filtering algorithm can make the output shadow effect image more realistic, while also reducing the number of sampling points, thereby reducing the computational load.

[0063] According to a sixth aspect, a computer-implemented method for generating a shadow effect is provided. The method comprises: obtaining an input scene; generating a shadow map image from the input scene; generating one or more shadow map downsampled images by downsampling the shadow map image;

[0064] Generate a filtered shadow map image from the shadow map image by using a base spline filtering algorithm; generate a filtered shadow map down-sampled image from each of the one or more shadow map down-sampled images by using a base spline filtering algorithm; and generate an output shadow effect image based on two or more images selected from (a) the filtered shadow map image and (b) the one or more filtered shadow map down-sampled images.

[0065] Combining downsampling with the basis spline filtering algorithm can make the output shadow effect image more realistic, while also reducing the number of sampling points, thereby reducing the computational load.

[0066] According to a seventh aspect, there is provided a computing device for performing the method described herein.

[0067] In some implementations, the computing device may include a graphics processing unit and a main memory, and the computing device is used to: on the graphics processing unit: obtain the input scene; generate the shadow map image; generate the filtered shadow map image and / or the downsampled shadow map image;

[0068] Generate the output down-sampled image; on the main memory: obtain the output down-sampled image from the graphics processing unit; output the output down-sampled image.

[0069] In some implementations, the computing device may be configured such that the graphics processing unit includes: a rendering channel for acquiring the input scene and generating the shadow map image; a first sub-channel for generating the filtered shadow map image and / or the downsampled shadow map image; and a second sub-channel for generating the output downsampled image.

[0070] Configuring a computing device to perform a large amount of processing in a GPU rather than in main memory can reduce the computational load in the main memory of the computing device.

[0071] According to an eighth aspect, there is provided a mobile communication device comprising the computing apparatus described herein.

[0072] According to a ninth aspect, there is provided a computer program comprising executable instructions which, when executed by a computer, cause the computer to perform the method described herein. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] The present invention is described below by way of examples in conjunction with the accompanying drawings. In the accompanying drawings:

[0074] Figure 1 An exemplary depth map of a shadow is schematically shown.

[0075] Figure 2 An exemplary NxN texel of a depth map is schematically shown.

[0076] Figure 3A and Figure 3B An exemplary shadow effect image is shown, where Figure 3A An exemplary hard shadow image is shown, Figure 3B An exemplary soft shadow image is shown.

[0077] Figure 4A , Figure 4B and Figure 4C An exemplary shadow effect image is shown, where Figure 4A An exemplary shadow effect image generated using a 1 percent closer filtering (PCF) tap kernel is shown. Figure 4B shows an exemplary shadow effect image generated using a 9×9 PCF tap kernel, Figure 4C An exemplary shadow effect image generated using a percentage closer soft shadow (PCSS) kernel is shown.

[0078] Figure 5 An exemplary depth map of a shadow is schematically shown.

[0079] Figure 6 The stages of a first exemplary embodiment of an image processing device for generating a shadow effect are schematically shown.

[0080] Figure 7 An example of a first computer-implemented method for generating shadow effects is shown.

[0081] Figure 8 An example of an apparatus for performing the methods described herein is shown.

[0082] Fig. 9 The stages of a second exemplary embodiment of an image processing device for generating a shadow effect are shown schematically.

[0083] Fig. 10A An exemplary comparison between a Gaussian filter kernel and a bicubic B-spline filter kernel is shown graphically, Fig. 10B An exemplary weighted sum distribution for a cubic B-spline filtering algorithm is graphically shown, Fig. 10C An exemplary texture pixel area is shown schematically.

[0084] Fig.11 An example of a second computer-implemented method for generating shadow effects is shown.

[0085] Fig.12 The stages of a second exemplary embodiment of an image processing device for generating a shadow effect are shown schematically.

[0086] Fig.13 An exemplary depth map of a shadow is schematically shown.

[0087] Fig.14 An example of a third computer-implemented method for generating shadow effects is shown.

[0088] Fig.15 An exemplary computing device for performing the methods described herein is schematically shown.

[0089] Fig.16A and Fig. 16B An output image of an apparatus for generating a shadow effect is shown.

[0090] Fig.17A and Fig. 17B An output image of a device for generating a shadow effect compared to the prior art is shown, wherein: Fig.17A The output image of the prior art is shown, Fig. 17BAn output image of an apparatus for generating a shadow effect is shown.

[0091] Fig.18A and Fig.18B An output image of a device for generating a shadow effect compared to the prior art is shown, wherein: Fig.18A The output image of the prior art is shown, Fig.18B An output image of an apparatus for generating a shadow effect is shown.

[0092] Fig.19A and Fig.19B An output image of a device for generating a shadow effect compared to the prior art is shown, wherein: Fig.19A The output image of the prior art is shown, Fig.19B An output image of an apparatus for generating a shadow effect is shown.

[0093] Fig. 20A and Fig. 20B An output image of a device for generating a shadow effect compared to the prior art is shown. Fig. 20A The output image of the prior art is shown, Fig. 20B An output image of an apparatus for generating a shadow effect is shown.

[0094] Fig.21A The PCF shadow effect transition area is shown. Fig.21B The PCT shading effect transition region is shown. DETAILED DESCRIPTION

[0095] Apparatus and methods described herein relate to generating shadow effects on an input scene.

[0096] Embodiments of the present invention can solve one or more of the above-mentioned problems by generating an output shadow effect image based on two or more images selected from (a) a shadow map image and (b) one or more shadow map downsampled images. In this way, the shadows in the output shadow effect image can be a combination of shadows in two or more images selected from (a) a shadow map image and (b) one or more shadow map downsampled images. In this way, the shadows in the output shadow effect image can be more realistic.

[0097] In addition, the embodiments of the present invention can also solve one or more of the above-mentioned problems by generating an output shadow effect image according to the filtered shadow map image, which can reduce the number of sampling points, thus reducing the calculation load, power consumption and rendering delay.

[0098] Inspired by the problems found in the prior art, the purpose of the above device may be to introduce a new soft shadow algorithm to achieve real-time, high-quality, low-memory-cost soft shadow rendering for mobile GPUs.

[0099] Optimization goals may include reducing the number of sampling points used for soft shadow filtering using an easily computable filter kernel with a similar kernel shape to the Gaussian blur filter kernel.

[0100] It has been found that the shapes of Gaussian blur filter kernels and cubic B-spline filter kernels may be similar. However, the B-spline filter algorithm may be easier to calculate than the Gaussian blur algorithm. In this way, the above device can use the GPU characteristics of the hardware bilinear texture filter and use the cubic B-spline filter kernel instead of the Gaussian blur filter kernel to obtain a very similar blur result, which may be smoother than the box filter.

[0101] Therefore, in the new algorithm, it is proposed to use this cubic B-spline filter kernel to replace all the filter kernels previously used in the shading step of the soft shadow algorithm.

[0102] Figure 6 A schematic diagram shows a stage 700 of a first exemplary embodiment of an image processing device 900 for generating a shadow effect.

[0103] The purpose of apparatus 900 may be to render a scene from the perspective of a light source, where all parts visible from the perspective of the light source are illuminated, while all parts that are not visible must be in shadow.

[0104] The apparatus 900 may be used to obtain the input scene 701. In other words, the apparatus 900 may be used to generate or receive the input scene.

[0105] The input scene 701 may be an input image. The input scene 701 may include one or more objects. The input scene 701 may include one or more light sources. The apparatus 900 may be used to generate or render a shadow, which is formed on the other side of the object relative to the light source.

[0106] The input scene 701 may include a 3D mesh scene representation. The 3D mesh scene representation may include light source information. For example, the light source information may include the position and orientation of the light source relative to the object. In this way, there may be enough information to generate the position and orientation of the shadow.

[0107] The apparatus 900 may be used to generate a shadow map image 702 from an input scene 701. In other words, a scene representation including light source information in the input scene 701 may be used to generate the shadow map image 702.

[0108] The apparatus 900 may be used to generate a shadow map image 702 from an input scene 701 by writing depth and depth squared into a two-component variance shadow map having two channels (rather than simply writing depth into the shadow map). Specifically, the Vulkan format VK_FORMAT_R16G16_UNORM may be used. The shadow map may include two channels.

[0109] The generation of the shadow map image 702 is described in detail in Fig.13 . Fig.13 An exemplary depth map of a shadow is schematically shown.

[0110] To generate the shadow map image 702, the apparatus 900 may be configured to calculate an occlusion region 1403 of the input scene 701. Within the occlusion region, one or more light sources 1401 may be occluded by one or more objects 1402. The size of the occlusion region 1403 may depend on the size of the light source 1401, the distance of the occlusion region 1403 of the receiver from the light source 1402, and the distance of the occlusion object 1402 between the light source 1401 and the occlusion region 1403. The occlusion region 1403 may be calculated by intersecting the shadow map plane with the viewing cone formed by P 1403 and the light source 1401.

[0111] To generate the shadow map image 702, the apparatus 900 may be used to estimate the average occlusion depth. Based on the occlusion area 1403, the average depth value may be sampled from the texture of the map. This may be achieved using a custom high-order filtering algorithm. The average occlusion depth may be estimated based on a heuristic formula.

[0112] To generate the shadow map image 702, the apparatus 900 may be used to calculate the penumbra size 1404 based on the blockage area 1403 and the average blockage depth. After the average blockage depth is generated, the penumbra size may be estimated based on the size of the light source 1401 and the distance of the blocker / receiver from the light source 1401. This may be done using Fig.13 and a similar triangle as shown in Equation 4.

[0113]

[0114] In some implementations, after generating the shadow map image 702, the apparatus 900 can be optimized by removing the expensive SAT calculation stage in the prior art for pre-filtering purposes. Instead, the map can be applied to each level from bottom to top, such as Figure 7 shown and described herein.

[0115] The apparatus 900 may be used to generate one or more shadow map downsampled images 703, 704 by downsampling the shadow map image 702. The apparatus may be used to generate one shadow map downsampled image 703 from the shadow map image 702. Alternatively, the apparatus may be used to generate more than one (e.g., two) shadow map downsampled images 703, 704 from the shadow map image 703.

[0116] like Figure 7 As shown, the apparatus 900 can be used to generate another shadow map downsampled image 704 from the shadow map downsampled image 703. In this way, two shadow map downsampled images 703 and 704 can be generated, and the other shadow map downsampled image 704 includes other levels of downsampling. Figure 7 As shown, the pixel area of ​​the other shadow map downsampled image 704 is smaller than the pixel area of ​​the shadow map downsampled image 703. This step can be repeated to generate more other shadow map downsampled images 704 including other levels of downsampling. Figure 7 In the example shown, the output texture size is successively reduced by a factor of two along the width and height dimensions at each downsampling step. It has been found that the last downsampling step produces a texture of the smallest size that can produce realistic shadows.

[0117] The apparatus 900 may be used to generate one or more shadow map downsampled images 703, 704 as at least part of a map. In other words, different levels of downsampling in the shadow map image 702, the shadow map downsampled image 703, and the other shadow map downsampled images 704 may provide different map levels. Such map levels of shadow map textures may be used for pre-filtering. It has been found that downsampling of four bottom pyramid levels may provide sufficient levels in test scenes.

[0118] For each visible scene point P, according to a fixed filter kernel size wi (given by the user according to the light source size), the corresponding mip level can be calculated, for which the projected area of ​​each pixel in the shadow map space is the same as the kernel size wi. This area can be the penumbra size used for shadow filtering. The soft shadow value of this penumbra kernel can be estimated by sampling the shadow map to this level. Filtering can use the default bilinear or trilinear filtering. Alternatively, filtering can use a custom high-order filtering algorithm described in this article.

[0119] The apparatus 900 may be used to generate an output shadow effect image 705. Specifically, the apparatus 900 may be used to generate the output shadow effect image 705 based on two or more images selected from (a) the shadow map image 702 and (b) one or more shadow map downsampled images 703, 704. In other words, the two or more images selected from (a) the shadow map image 702 and (b) one or more shadow map downsampled images 703, 704 may be used to generate the output shadow effect image 705.

[0120] The apparatus 900 may generate an output shadow effect image 705 using two images of (a) the shadow map image 702 and (b) one or more shadow map downsampled images 703, 704. In other words, the apparatus 900 may generate an output shadow effect image 705 using the shadow map image 702 and one of the shadow map downsampled images 703, 704. Alternatively, the apparatus 900 may generate an output shadow effect image 705 using two images of the shadow map downsampled images 703, 704. For example, the apparatus may generate an output shadow effect image 705 using the shadow map downsampled image 703 and other shadow map downsampled images 704. In the best case, the apparatus 900 may use two images including different downsampled levels or map levels. In this way, the output shadow effect image 705 may be generated by combining or averaging images of different downsampled levels or map levels. In this way, the shadow may be more realistic.

[0121] Alternatively, the apparatus 900 may use two or more of (a) the shadow map image 702 and (b) the one or more shadow map downsampled images 703, 704 to generate an output shadow effect image 705. In this example, the output shadow effect image 705 may be generated by combining or averaging the two or more images.

[0122] The apparatus 900 may be used to sample a shadow map image 702 and one or more shadow map downsampled images 703 , 704 .

[0123] The apparatus 900 may be used to obtain samples in the shadow map image 702 and one or more shadow map downsampled images 703, 704, and perform linear interpolation between the samples. The linear interpolation may be used to generate an output shadow effect image 705. Using linear interpolation, the output shadow effect image 705 may be generated by combining or averaging samples in two or more images.

[0124] In this way, each upper pixel can provide the average value of the lower pixels. Similar to the double filtering algorithm, Figure 7 The series of downsampling iterative steps shown can provide a summing effect for each down-level pixel.

[0125] Increasing the number of downsampling levels can increase the blurriness of the shadows in the output shadow effect image. However, increasing the number of downsampling levels also increases the computational load. At four downsampling levels, a balance was found between realistic shadows and computational load.

[0126] The apparatus 900 may output the calculated shading factor for each pixel (in the floating point range [0, 1]). The shading factor may be used in the lighting calculations to output the final color of each pixel in the shading effect image 705.

[0127] The main parameters of device 900 may include: (i) for PC platform, the resolution of the shadow map buffer can be set to 1024×1024 without MSAA; for mobile platform, the resolution of the shadow map buffer is set to 512×512, but with 4x MSAA; (ii) the number of downsampling steps used to generate the texture layer level, which controls the range and softness of soft shadows. It has been found that 4 is a suitable level for all tested scenes.

[0128] Figure 7 An example of a method 800 for generating a shadow effect is summarized. At step 801, the method 800 includes: obtaining an input scene. At step 802, the method 800 includes: generating a shadow map image from the input scene. At step 803, the method 800 includes: generating one or more shadow map downsampled images by downsampling the shadow map image. At step 804, the method 800 includes: generating an output shadow effect image based on two or more images selected from (a) the shadow map image and (b) the one or more shadow map downsampled images.

[0129] Figure 8 An example of an apparatus 900 for implementing methods 800, 1200, and 1500 is shown in a schematic diagram. The apparatus 900 can be implemented on an electronic device such as a laptop, a tablet, a smart phone, or a TV. Specifically, the apparatus 900 can be implemented using Vulkan, OpenGL, or other application programming interfaces (Application Programming Interface, API), and can be used on PCs and mobile devices.

[0130] The apparatus 900 includes a processor 901, which is used to process a data set in the manner described herein. For example, the processor 901 can be implemented as a computer program running on a programmable device such as a central processing unit (CPU). The apparatus 900 includes a memory 902, which is used to communicate with the processor 901. The memory 902 can be a non-volatile memory. The processor 901 can also include a cache ( Figure 8), the cache may be used to temporarily store data in the memory 902. The apparatus may include one or more processors and one or more memories. The memory may store data executable by the processor. The processor may be used to operate according to a computer program stored in a machine-readable storage medium in a non-transient manner. The computer program may store instructions to cause the processor to perform its method in the manner described herein.

[0131] Fig. 9 Phase 1000 of a second exemplary embodiment of an image processing device 900 for generating a shadow effect is schematically shown.

[0132] The apparatus 900 provided in the second embodiment may be used to obtain the input scene 701 , as described herein in conjunction with the first exemplary embodiment.

[0133] The apparatus 900 provided in the second embodiment may be used to generate a shadow map image 702 from an input scene 701 , as described herein in conjunction with the first exemplary embodiment.

[0134] The apparatus 900 provided in the second embodiment may be used to not generate one or more shadow downsampled images 703, 704. Instead, the apparatus 900 may be used to generate a filtered shadow map image 1001 from the shadow map image 702. However, features of the first and second embodiments of the apparatus 900 may be used interchangeably.

[0135] The device 900 can be used to generate a filtered shadow map image 1001 through a bilinear filter or a trilinear filter. However, in the best case, the device 900 can be used to generate a filtered shadow map image 1001 through a base spline filtering algorithm 1101. Specifically, the base spline filtering algorithm 1101 can be a 4-tap bicubic base spline filtering algorithm. The base spline filtering algorithm 1101 can produce more realistic and less blocky artifacts in the output shadow effect image 705. This is because the base spline filtering algorithm 1101 can remove the square pixel simulation results used in the bilinear filter or the trilinear filter. The base spline filtering algorithm 1101 can provide high-order filtering, eliminating the blocky effects produced by the bilinear filter or the trilinear filter.

[0136] Fig. 10A An exemplary comparison 1100 between a Gaussian filter kernel 1101 and a bicubic B-spline filter kernel 1102 is shown graphically. It has been found that the shapes of the Gaussian blur filter kernel 1102 and the cubic B-spline filter kernel 1101 are very similar. In addition, both the Gaussian blur filter kernel 1102 and the cubic B-spline filter kernel 1101 can produce smooth filtering results, such as Fig. 10A shown. Fig. 10A The similarity of the shapes of the two filter kernels in 1D is shown.

[0137] The B-spline filter algorithm 1101 may be easier to calculate than the Gaussian blur algorithm 1102. In other words, the computational power required by the B-spline filter algorithm 1101 is much lower than that of the Gaussian blur algorithm 1102. The apparatus 900 can utilize the GPU characteristics of the hardware bilinear texture filter and use a cubic B-spline filter kernel instead of a high-cost Gaussian blur filter kernel to obtain a similar blur effect at a lower cost.

[0138] The bicubic B-spline filter 1101 can be introduced into the shadow filtering algorithm of the apparatus 900. This can reduce the number of sampling points and achieve a smooth transition from a hard shadow area to a soft shadow area.

[0139] Fig. 10B An exemplary weighted sum distribution 1103 of a cubic B-spline filtering algorithm 1104 is graphically shown. A filter known in image processing is generally referred to as a cubic B-spline filter. When the filter is applied in both the x-direction and the y-direction, the filter is referred to as a bicubic B-spline filter. A cubic B-spline is a cubic filter kernel with cubic polynomial weights, such as Fig. 10B shown. Fig. 10B A weighted sum based filtering algorithm is also shown.

[0140] exist Fig. 10B In the example, the y value of the function is the relative weight to be assigned to texels that are far from the center of a given texture sampling coordinate x. Since the weight value is zero, texels that are more than two texels away from the center may be essentially ignored. However, texels located at the center are given the highest weight. In particular, for this particular cubic B-spline filter, all weights are positive, that is, greater than zero.

[0141] In 1D, the cubic filtering algorithm can be expressed as Equation 5.

[0142] f(x)=w0(x)f i-1 +w1(x)f i +w2(x)f i+1 +w3(x)f i+2 (5)

[0143] In Equation 5, f i The values ​​of neighboring texture pixels indexed at the 4 taps of the integer sampling position can be multiplied by the corresponding cubic polynomial weights wi(x) of the convolution kernel. The weighted sum is the final result of the filtering.

[0144] General 1D cubic interpolation is a method to estimate a specific function value f(x) at any continuous sampling point x by computing the weighted sum of 4 taps of known function values ​​f(i-1), f(i), f(i+1) and f(i+2) at 4 integer grid locations (from i-1 to i+2), where x=i+α, α and i are the integer and fractional parts of x respectively, α∈[0,1), i.e., α∈[0,1), i∈Z.

[0145] The formula for calculating the B-spline weight using a third-order polynomial is shown in Equation 6.

[0146]

[0147] In Equation 6, the four weights are determined by the fraction α of the current sample coordinate x.

[0148] Bicubic filtering is a 2D extension of 1D cubic filtering and is used to interpolate data points on a 2D regular grid. The 2D interpolation function is a separable extension of the 1D interpolation function. 2D interpolation can be achieved by performing two ID interpolations for each coordinate direction. Therefore, d can be input into the above formula to obtain the filter weights along the X direction and the Y direction.

[0149] Fig. 10C An exemplary texture pixel region 1105 is shown schematically. A bicubic filter in 2D requires filtering a 4×4 texture pixel region, 16 texture fetches, and a third-order weighted filter calculation in the X and Y directions within a 4×4 local neighborhood, which involves 32 multiplication operations for a single pixel shading, as shown in FIG. Fig. 10C The filter samples a 4×4 grid of texels around the target UV coordinate 1106 .

[0150] Fortunately, this method can be simplified by taking advantage of the GPU hardware bilinear sampling feature, which only requires 4 texture fetches to achieve the same filtering effect for a 4×4 texel area. This effectively combines 16 sampling taps into only 4.

[0151] This is achieved by carefully adjusting the sampling coordinates. For 1D cubic filtering, in order to combine 4 taps into 2, the above device must combine the first pair of taps into linear taps and the second pair of taps into other linear taps. Therefore, instead of combining the first pair of taps into the second pair of taps into the third pair of taps, the sampling coordinates are adjusted. i and f i+1 Perform two texture lookups at a*f and use common values ​​a and b i +b*f i+1Instead of performing a linear combination, a single texture lookup is performed at i+b / (a+b), and the result is then multiplied by (a+b). Specifically, a 2:1 reduction becomes a 4:1 reduction in 2D, effectively reducing 16 taps in 2D to 4. This is achieved according to Equations 7 to 9.

[0152]

[0153] Using this 4-tap bicubic B-spline filter kernel instead of bilinear sampling may only require 4 texture fetches within the pixel neighborhood to approximate the weighted sum of the sample points in the sampling step. This can reduce the GPU memory bandwidth required for texture sampling.

[0154] The apparatus 900 may be used to generate the output shadow effect image 705. Specifically, the apparatus 900 may be used to generate the output shadow effect image 705 according to the filtered shadow map image 1001. In other words, the filtered shadow map image 1001 may be used to generate the output shadow effect image 705.

[0155] Filtering a fixed area can provide two moments M1 and M2 of the depth distribution in the area. Based on these two moments, the mean and variance of the distribution can be calculated by Equations 10 and 11. Using the variance, Chebyshev's inequality can be used to calculate the upper limit of the probability that the current shadow surface is occluded, which can be used as the final shadow factor for the pixel shadow.

[0156] E(x)=x,σ 2 =E(x 2 )-E(x) 2 (10)

[0157]

[0158] In other words, the apparatus 900 may be used to generate the output shadow effect image 705 from the filtered shadow map image by estimating the probability that a pixel is blocked in a neighboring region.

[0159] Fig.11 An example of a method 1200 for generating a shadow effect is outlined. At step 1201, the method 1200 includes: obtaining an input scene. At step 1202, the method 1200 includes: generating a shadow map image from the input scene. At step 1203, the method 1200 includes: generating a filtered shadow map image from the shadow map image by a basis spline filtering algorithm. At step 1204, the method 1200 includes: generating an output shadow effect image based on the filtered shadow map image.

[0160] Fig.12Phase 1300 of a third exemplary embodiment of an image processing device 900 for generating a shadow effect is schematically shown.

[0161] The apparatus 900 provided in the third embodiment may be used to obtain the input scene 701 , as described herein in conjunction with the first exemplary embodiment and the second exemplary embodiment.

[0162] When shading each pixel in the eye view, the apparatus 900 should return a floating point value indicating the amount of shading for each shadow point P 1403. The apparatus 900 provided in the third embodiment can be used to generate a shadow map image 702 from an input scene 701, as described herein in conjunction with the first exemplary embodiment and the second exemplary embodiment.

[0163] The apparatus 900 provided in the second embodiment may be used to generate one or more shadow downsampled images 703, 704, as described herein in conjunction with the first embodiment. The apparatus 900 provided in the third embodiment may be used to generate a filtered shadow image 1001 from the shadow image 702, as described herein in conjunction with the second embodiment. In other words, the features of the first embodiment and the second embodiment of the apparatus 900 may be combined and / or used interchangeably.

[0164] Combining maps of different levels may result in pixels and being located only in square areas. This may result in a blocky filtering effect in the final shading. Therefore, the apparatus 900 provided in the third embodiment can reduce the blocking filtering effect by adopting a high-order filtering algorithm.

[0165] After generating the two-pass shadow map and building a map on it, for each visible scene point P 1403, an initial occlusion search area A is calculated by intersecting the shadow map plane with the viewing cone formed by P 1403 and the light source 1401. Based on the area size A, the average depth value zAvg in A is sampled from the map texture using a custom high-order filtering algorithm, as described herein. The average occlusion depth can be estimated based on a heuristic formula. After obtaining the average occlusion depth, the actual penumbra kernel wp can be calculated. Finally, the soft shadow value of the penumbra kernel wp can be directly evaluated, as described in conjunction with the second embodiment of the device 900, however, since floating-point map levels are used, the device 900 can be used to sample two or more map levels instead of one map level.

[0166] The apparatus 900 may be used to generate a filtered shadow map downsampled image 1301, 1302 from each of the one or more shadow map downsampled images 703, 704. In other words, Fig.12As shown, if the device 900 has generated two shadow map downsampled images 703, 704, one shadow map downsampled image 703 and one other shadow map downsampled image 704, the device 900 can be used to generate two corresponding filtered shadow map downsampled images 1301, 1302, one filtered shadow map downsampled image 1301 and one other filtered shadow map downsampled image 1302.

[0167] The apparatus 900 may be used to generate one or more filtered shadow map downsampled images 1301, 1302 from each of the one or more shadow map downsampled images 703, 704 by means of a basis spline filtering algorithm 1101. The apparatus 900 may be used to generate one or more filtered shadow map downsampled images 1301, 1302 by means of the same basis spline filtering algorithm 1101 in the same manner as described herein for the filtered shadow map image 1001.

[0168] The apparatus 900 may also be used to generate a filtered shadow map image 1001 from the shadow map image 702. In this way, the apparatus 900 may generate a filtered image for each level in the hierarchy of tiles.

[0169] like Fig.12 As shown, the filtered shadow map downsampled images 1301 , 1302 may include the same mapping levels as the corresponding shadow map downsampled images 703 , 704 .

[0170] The high-order bicubic filtering in the base spline filtering algorithm 1101 can be applied to each map layer level. The device 900 can be used to perform soft shadow filtering by sampling from the map texture. Specifically, the device 900 can use a kernel size proportional to the penumbra size for high-order bicubic filtering, and calculate the penumbra size of each pixel according to Equation 4, as described herein in conjunction with the first embodiment of the device. The soft shadow factor value of the penumbra kernel can be evaluated by a high-order filtering algorithm in the same manner as the second embodiment of the device 900, however, the device 900 can be used to sample two map layers instead of just one map layer level. Since the floating-point penumbra size is known, it corresponds to a level with a fractional part between two adjacent levels (N-1 and N), so the device 900 can be used to calculate the final shadow factor by performing linear interpolation based on the fractional distance between the two adjacent levels. The final shadow factor can be calculated according to Equation 12.

[0171] Shadow_factor=(1-fractional)*Shadow_factor N-1 +(fractional)*Shadow_factor N (12)

[0172] The result of this calculation can provide soft shadows, which appear smooth and achieve a smooth transition from hard shadows to soft shadows.

[0173] The apparatus 900 may be used to generate an output shadow effect image 705. Specifically, the apparatus 900 may be used to generate the output shadow effect image 705 based on two or more images selected from (a) the filtered shadow map image 1001 and (b) one or more filtered shadow map downsampled images 1301, 1302. In other words, the two or more images selected from (a) the filtered shadow map image 1001 and (b) one or more filtered shadow map downsampled images 1301, 1302 may be used to generate the output shadow effect image 705.

[0174] The device 900 may use two images of (a) the filtered shadow map image 1001 and (b) one or more filtered shadow map downsampled images 1301, 1302 to generate the output shadow effect image 705. In other words, the device 900 may use the filtered shadow map image 1001 and one filtered shadow map downsampled image 1301, 1302 to generate the output shadow effect image 705. Alternatively, the device 900 may use two images of the filtered shadow map downsampled images 1301, 1302 to generate the output shadow effect image 705. For example, the device may use the filtered shadow map downsampled image 1301 and other filtered shadow map downsampled images 1302, 1302 to generate the output shadow effect image 705. In the best case, the device 900 may use two images including different downsampled levels or texture levels. In this way, the output shadow effect image 705 may be generated by combining or averaging images of different downsampled levels or texture levels. In this way, the shadows may be more realistic.

[0175] Alternatively, the apparatus 900 may use two or more of (a) the filtered shadow map image 1001 and (b) the one or more filtered shadow map downsampled images 1301, 1302 to generate the output shadow effect image 705. In this example, the output shadow effect image 705 may be generated by combining or averaging the two or more images.

[0176] Fig.14An example of a method 1500 for generating a shadow effect is outlined. At step 1501, the method 1500 includes: obtaining an input scene. At step 1502, the method 1500 includes: generating a shadow map image from the input scene. At step 1503, the method 1500 includes: generating one or more shadow map downsampled images by downsampling the shadow map image. At step 1504, the method 1500 includes: generating a filtered shadow map image from the shadow map image by a basis spline filtering algorithm. At step 1505, the method 1500 includes: generating a filtered shadow map downsampled image from each of the one or more shadow map downsampled images by a basis spline filtering algorithm. At step 1506, the method 1500 includes: generating an output shadow effect image based on two or more images selected from (a) the filtered shadow map image and (b) the one or more filtered shadow map downsampled images.

[0177] Fig.15 An exemplary computing device 1600 for performing the methods described herein is schematically illustrated.

[0178] Mobile graphics processing units (GPUs) typically use a design approach, often called tile-based rendering, to minimize the amount of power-hungry external memory accesses required during rendering. The Vulkan API can provide an explicit subpass mechanism to fetch framebuffer attachments in on-chip tile memory, a special feature of tile-based GPUs that can be used to explicitly implement fast access to on-chip memory.

[0179] The computing device 1600 can explicitly use this functionality by utilizing on-chip tile memory on the GPU to save memory bandwidth when building the first two map levels for the shadow map texture. Specifically, the computing device 1600 can use two subpasses 1604, 1605 within a single rendering pass 1602 to generate a shadow map texture and build a map level on it, such as Fig.15 shown.

[0180] Specifically, computing device 1600 may include a graphics processing unit (GPU) 1601. GPU 1601 may include a rendering pass 1602, and rendering pass 1602 may also include a transient attachment. GPU 1601 may include a first subpass 1604, and first subpass 1604 may also include 4x depth 1608. GPU 1601 may include a second subpass 1605, and second subpass 1605 may also include 1x color 1609.

[0181] Computing device 1600 may include main memory 1606. Main memory 1606 may include color write back 1610.

[0182] The computing device 1600 may be used to obtain an input scene 701. Specifically, a rendering pass 1602 of the GPU 1601 may be used to obtain the input scene 701, as described herein.

[0183] Computing device 1600 may be used to generate shadow map image 702. Specifically, rendering pass 1602 of GPU 1601 may be used to generate shadow map image 702, as described herein.

[0184] The computing device 1600 may be used to generate filtered shadow map images 1001, 1301, 1302 and / or downsampled shadow map images 703, 704, 1301, 1302. Specifically, the first subpass 1604 of the GPU 1601 may be used to generate filtered shadow map images 1001, 1301, 1302 and / or downsampled shadow map images 703, 704, 1301, 1302, as described herein.

[0185] In the first subpass 1604, the computing device 1600 may rasterize the entire scene triangle from the perspective of the light source into a depth buffer with 4x MSAA enabled. Specifically, the first subpass 1604 may not require any color render targets.

[0186] Computing device 1600 may be used to generate output downsampled image 705. Specifically, the second subpass of GPU 1601 may be used to generate output downsampled image 705, as described herein.

[0187] In the second subchannel 1604, the computing device 1600 may perform a custom parsing operation through a pixel shader that reads 4 MSAA depth samples of the current pixel and calculates the average depth and depth squared, and then writes them into a two-component variance shadow map in the VK_FORMAT_R16G16_UNORM format. Here, the computing device 1600 may use a subchannel that reads the MSAA texture through an input attachment. Therefore, the MSAA texture may only reside in the on-chip tile memory and may not need to enter the system memory. In this way, the memory bandwidth for storing and reading this texture can be saved. For a 512×512 depth texture with 4x MSAA, when rendering each frame, it is found that the read and write bandwidth saved is 1024×1024×4×2=8MB.

[0188] In order for the computing device 1600 to work properly, the first subpass 1601 that renders to the MSAA texture must specify the MSAA texture through pColorAttachments and use VK_ATTACHMENT_STORE_OP_DONT_CARE as the storage operation. The second subpass 1605 that performs the custom resolve operation needs to specify the MSAA texture through pInputAttachments and specify the resolve target through pColorAttachments. The second subpass 1605 then needs to render a full-screen quad using a shader that uses the subpassInputMS resource to read the MSAA data. In addition, the application needs to specify the dependency between the two subpasses 1604 and 1605 and the dependency flag VK_DEPENDENCY_BY_REGION_BIT, which indicates the stage / access mask (similar to a pipeline barrier). In this way, the driver should have enough information to arrange (for example) to run on a tiled GPU 1601. MSAA content may never leave the tile memory, but is resolved per tile, and the resolution results are written to the main memory.

[0189] When accessing the shadow map texture at rendering time, computing device 1600 can access the resolved texture as the base level while accessing all upper levels for shadow factor filtering. The original 4x MSAA texture may not be accessible. Testing has shown that this approach works well.

[0190] The computing device 1600 may be used to output the output downsampled image 705. Specifically, the main memory 1606 may be used to obtain the output downsampled image 705 from the GPU 1601 and output the output downsampled image 705.

[0191] The mobile communication device may be configured to include the computing means 1600. The mobile communication device may be a personal computer, a laptop computer, a smartphone, or a similar mobile communication device.

[0192] The proposed algorithm can be implemented on PC and Android devices using a graphics API (e.g., DirectX, Vulkan, or OpenGL).

[0193] For testing purposes, the algorithm was implemented on a prototype app using Vulkan so that the source code could be cross-platform compiled on PC (Windows) and mobile phone (Android) platforms.

[0194] For uniform filter kernel size, the performance is compared with the state-of-the-art PCF algorithm. For variable filter kernel size per pixel, the performance is compared with the traditional PCSS algorithm.

[0195] The algorithm was tested on a mobile phone. The algorithm was implemented on a Huawei P30 Pro phone with a rendering resolution of 2340×1080p, using a 512×512 shadow depth texture, and 4x MSAA enabled. The frame rate results in FPS are shown in Table 1.

[0196] Table 1

[0197]

[0198] Fig.17A and Fig. 17B Shown is an output image of a device for generating shadow effects compared to the prior art when tested on a Huawei P30 Pro. Fig.17A The output image of the prior art is shown. Fig. 17B An output image of an apparatus for generating a shadow effect is shown.

[0199] The algorithm was tested on a laptop. The algorithm was implemented on a Huawei MateBook laptop equipped with an Intel integrated GPU, rendering at a resolution of 1920×1080p, using a 1024×1024 shadow depth texture, and no MSAA. The frame rate results in FPS are shown in Table 2.

[0200] Table 2

[0201]

[0202] Fig.18A and Fig.18B An output image of a device for generating shadow effects compared to the prior art when tested on a Huawei MateBook laptop is shown. Fig.18A The output image of the prior art is shown. Fig.18B An output image of an apparatus for generating a shadow effect is shown.

[0203] Fig.19A and Fig.19B Other output images of the apparatus for generating shadow effects compared to the prior art are shown when tested on a Huawei MateBook laptop. Fig.19A The output image of the prior art is shown. Fig.19B An output image of an apparatus for generating a shadow effect is shown.

[0204] Fig. 20A and Fig. 20B Other output images of the apparatus for generating shadow effects compared to the prior art are shown when tested on a Huawei MateBook laptop. Fig. 20A The output image of the prior art is shown. Fig. 20BAn output image of an apparatus for generating a shadow effect is shown.

[0205] It can be clearly seen from the performance table of the test results that the proposed image processing device is much faster than the prior art PCF and PCSS. The speed-up factor may reach about 10 times.

[0206] With PCF, since a depth comparison needs to be done for every sample, it is not possible to use a pre-filtered texture map to speed up the process. Therefore, in the worst case, the device must sample and compare every individual texture pixel within an N×N sized neighboring area of ​​the shadow map to calculate the light attenuation for each single pixel. Unsurprisingly, this process can be very slow with a complexity of O(N×N). The situation becomes even worse if PCF is used to implement edge softening and a large filter kernel size N is used, as this approach is equivalent to setting a lower limit on the size of the filter area, and therefore the cost of pixel shading.

[0207] The same is true for PCSS, because for a particular pixel, once the filter kernel size N is found, if N is large, then the same type of expensive PCF filtering operation is performed on the NxN size neighboring area. PCSS only performs well when N is very small. Therefore, in the entire frame, some pixels may perform well, while other pixels may not perform well. This also explains why PCSS is usually faster than PCF in testing.

[0208] In the proposed algorithm, runtime shadow filtering is simple and of fixed cost. Each pixel is shaded by simply sampling a 4-tap bicubic B-spline kernel, involving only 4 texel sampling operations of fixed cost for uniform filtering. This is in contrast to the N×N sampling operations in the PCF algorithm. This is why the proposed algorithm may still have a better speedup factor than both PCF and PCSS when N is large.

[0209] Fig.21A The PCF shadow effect transition region is shown. Fig.21B The PCT shading effect transition region is shown.

[0210] It can also be seen from the test images shown above that the proposed algorithm can produce better quality output images compared to PCF and PCSS. This is because PCF usually performs box filtering in an NxN area 2200, such as Fig.21A This usually results in blocky features in the shadow transition areas of the output image.

[0211] The proposed algorithm uses a bicubic B-spline filter kernel, whose shape is very similar to a disk-shaped Gaussian filter kernel. As a result, the output image is very smooth, more like a Gaussian blur, including the transition area from hard to soft shadows.

[0212] Applicants hereby disclose separately each individual feature described herein and any combination of two or more such features. With the common knowledge of those skilled in the art, such features or combinations can be implemented as a whole according to this specification, without considering whether such features or combinations of features can solve any problem disclosed herein; and without limiting the scope of the claims. Applicants point out that various aspects of the present invention may include any such individual features or combinations of features. In view of the above description, it will be obvious to those skilled in the art that various modifications can be made within the scope of the present invention.

Claims

1. An image processing device (900) for generating a shadow effect, characterized in that: The apparatus (900) comprises one or more processors (901) and a memory (902), wherein the memory (902) stores data defining a program code in a non-transitory manner, the program code being executable by the one or more processors (901), and when the program code is executed by the one or more processors (901), causing the image processing apparatus (900) to perform the following operations: Get Input Scene (701); generating a shadow map image (702) from the input scene (701); generating one or more shadow map downsampled images (703, 704) by downsampling the shadow map image (702); An output shadow effect image (705) is generated based on two or more images selected from (a) the shadow map image (702) and (b) the one or more shadow map downsampled images (703, 704).

2. The device (900) according to claim 1, characterized in that The apparatus (900) is used to generate the output shadow effect image (705) by sampling the two or more images selected from (a) the shadow map image (702) and (b) the one or more shadow map downsampled images (703, 704).

3. The device (900) according to claim 2, characterized in that The apparatus (900) is configured to generate the output shadow effect image (705) by performing linear interpolation between samples in the two or more images selected from (a) the shadow map image (702) and (b) the one or more shadow map downsampled images (703, 704).

4. The device (900) according to any one of the preceding claims, characterized in that The apparatus (900) is used to generate other shadow map downsampled images (704) by downsampling the shadow map downsampled image (703).

5. The device (900) according to claim 4, characterized in that The device (900) is used to generate the output shadow effect image (705) according to the shadow map down-sampled image (703) and the other shadow map down-sampled images (704).

6. The device (900) according to any one of the preceding claims, characterized in that The apparatus (900) is used to generate the one or more shadow map downsampled images (703, 704) as at least a part of a map.

7. The device (900) according to any one of the preceding claims, characterized in that The apparatus (900) is used to generate the shadow map image (702) from the input scene (701) by: Calculating a blocking area (1403) of the input scene (701), wherein the one or more light sources (1401) are blocked by the one or more objects (1402) within the blocking area (1403); Estimate the average blocking depth; The penumbra size (1404) is calculated based on the blocking area (1403) and the average blocking depth.

8. A computer-implemented method (800) for generating a shadow effect, characterized in that: The method (800) comprises: Get Input Scene (801); generating a shadow map image from the input scene (802); generating one or more shadow map downsampled images by downsampling the shadow map image (803); An output shadow effect image is generated based on two or more images selected from (a) the shadow map image and (b) the one or more shadow map downsampled images (804).

9. An image processing device (900) for generating a shadow effect, characterized in that: The apparatus (900) comprises one or more processors (901) and a memory (902), wherein the memory (902) stores data defining a program code in a non-transitory manner, the program code being executable by the one or more processors (901), and when the program code is executed by the one or more processors (901), causing the image processing apparatus (900) to perform the following operations: Get Input Scene (701); generating a shadow map image (702) from the input scene (701); generating a filtered shadow map image (1001) from the shadow map image (702) by a basis spline filtering algorithm (1101); An output shadow effect image (705) is generated based on the filtered shadow map image (1001).

10. The device (900) according to claim 9, characterized in that The device (900) is used to filter the shadow map image (702) by using a 4-tap bicubic spline filtering algorithm (1101).

11. The device (900) according to claim 9 or 10, characterized in that The apparatus (900) is used to generate the output shadow effect image (705) from the filtered shadow map image (1001) by estimating the probability of a pixel being blocked in an adjacent region.

12. A computer-implemented method (1200) for generating a shadow effect, characterized in that: The method (1200) comprises: Get Input Scene (1201); generating a shadow map image from the input scene (1202); Generating a filtered shadow map image from the shadow map image by a basis spline filtering algorithm (1203); An output shadow effect image is generated based on the filtered shadow map image (1204).

13. An image processing device (900) for generating a shadow effect, characterized in that: The apparatus (900) comprises one or more processors (901) and a memory (902), wherein the memory (902) stores data defining a program code in a non-transitory manner, the program code being executable by the one or more processors (901), and when the program code is executed by the one or more processors (901), causing the image processing apparatus (900) to perform the following operations: Get Input Scene (701); generating a shadow map image (702) from the input scene (701); generating one or more shadow map downsampled images (703, 704) by downsampling the shadow map image (702); generating a filtered shadow map image (1001) from the shadow map image (702) by a basis spline filtering algorithm (1101); Generating a filtered shadow map downsampled image (1301, 1302) from each of the one or more shadow map downsampled images (703, 704) by a basis spline filtering algorithm (1101); An output shadow effect image (705) is generated based on two or more images selected from (a) the filtered shadow map image (1001) and (b) the one or more filtered shadow map downsampled images (1301, 1302).

14. A computer-implemented method (1500) for generating a shadow effect, characterized in that: The method (1500) comprises: GetInputScene(1501); generating a shadow map image from said input scene (1502); generating one or more shadow map downsampled images by downsampling the shadow map image (1503); generating a filtered shadow map image from the shadow map image by a basis spline filtering algorithm (1504); generating a filtered shadow map downsampled image from each of the one or more shadow map downsampled images by a basis spline filtering algorithm (1505); An output shadow effect image is generated based on two or more images selected from (a) the filtered shadow map image and (b) the one or more filtered shadow map downsampled images (1506).

15. A computing device (1600), characterized in that: For carrying out the method according to any one of claims 8, 12 and 14.

16. The computing device (1600) according to claim 15, characterized in that The computing device comprises a graphics processing unit (1601) and a main memory (1606), wherein the computing device (1600) is used to: On the graphics processing unit (1601): Obtain the input scene (701); generating the shadow map image (702); Generating the filtered shadow map image (1001, 1301, 1302) and / or the downsampled shadow map image (703, 704, 1301, 1302); generating the output downsampled image (705); On the main memory (1606): Obtaining the output downsampled image (705) from the graphics processing unit (1601); The output downsampled image is output (705).

17. The computing device (1600) according to claim 15 or 16, characterized in that The graphics processing unit (1601) comprises: A rendering pass (1602) for acquiring the input scene (701) and generating the shadow map image (702); A first subchannel (1604) for generating the filtered shadow map image (1001, 1301, 1302) and / or the downsampled shadow map image (703, 704, 1301, 1302); The second subchannel (1605) is used to generate the output downsampled image (705).

18. A mobile communication device, characterized in that: Comprising a computing device (160) according to any one of claims 15 to 17.

19. A computer program comprising executable instructions, characterized in that When the instructions are executed by a computer, the computer is caused to perform the method according to any one of claims 8, 12 and 14.