Shadow generation method, image rendering method, graphics processing unit, and system

By determining the intersection of light and shadow light in image rendering and calculating the shadow intensity, the problem of difficulty in obtaining a soft shadow effect in the existing technology is solved, and real shadow rendering under low resource consumption is achieved.

WO2024198201A1PCT designated stage expired Publication Date: 2024-10-03XIANGDIXIAN COMPUTING TECH (CHONGQING) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2023/113251
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-03-28
Filing Date
2023-08-16
Publication Date
2024-10-03

AI Technical Summary

Technical Problem

It is difficult to obtain realistic soft shadow effects without using a large amount of hardware and software resources with existing technologies.

Method used

By determining the intersection point of the initial light and shadow light in the three-dimensional scene of the image to be rendered, calculating the distance between the intersection point and the light source to match the shadow intensity, the shadow generation method is implemented, and then the brightness of the pixels is adjusted during the image rendering process to obtain Soft shadow effect.

Benefits of technology

Without introducing a ray tracing system, a realistic soft shadow effect is achieved, reducing the consumption of hardware and software resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2023113251_03102024_PF_FP_ABST
    Figure CN2023113251_03102024_PF_FP_ABST
Patent Text Reader

Abstract

The present invention provides a shadow generation method, an image rendering method, a graphics processing unit, and a system. The shadow generation method comprises: in a three-dimensional scene of an image to be rendered, determining an initial light ray emitted from a target pixel point of said image, determining whether the initial light ray hits an opaque object or not, and if yes, determining an intersection point of the initial light ray and a first opaque object hit by the initial light ray as a first intersection point; for a light source in the three-dimensional scene, determining whether a shadow light ray which takes the first intersection point as a starting point and points to the light source hits an opaque object or not; and if yes, determining an intersection point of the shadow light ray and a first opaque space object hit by the shadow light ray as a second intersection point, and calculating the distance between the first intersection point and the second intersection point so as to match shadow intensity of the first intersection point under the light source according to the distance. A real soft shadow effect is obtained to a certain extent, without using a large number of hardware and software resources.
Need to check novelty before this filing date? Find Prior Art

Description

Shadow generation method, image rendering method, graphics processor and system

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

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

[0003] The present application relates to the technical field of graphics processors, and in particular to a shadow generation method, an image rendering method, a graphics processor, and a system. Background Art

[0004] Ray tracing is a new technology in the image rendering process of the Graphics Processing Unit (GPU), which is used to make the rendered images produce more realistic light and shadow effects. The ray tracing system can complete the shadow calculation very well, but the entire ray tracing system requires a lot of hardware and software resources, and the implementation difficulty and complexity are very high. In the GPU rendering pipeline without ray tracing, the current shadow calculation is mainly done by converting the perspective to the direction of the light source, calculating the depth of all objects, judging the shadow of the object based on the depth, and then converting the perspective back to the normal rendering perspective. However, this method of calculating the shadow of each pixel based on the depth, so the shadows obtained are all hard shadows. Even if the shadow edges are filtered, it is still difficult to obtain a true soft shadow effect. In other words, it is currently difficult to obtain a true soft shadow effect without using a lot of hardware and software resources.

[0005] Summary of the Invention

[0006] The purpose of the present disclosure is to provide a shadow generation method, an image rendering method, a graphics processor and a system, which solve the technical problem in the prior art that it is difficult to obtain a realistic soft shadow effect without using a large amount of hardware and software resources.

[0007] According to one aspect of the present disclosure, a shadow generation method is provided, comprising:

[0008] In a three-dimensional scene of an image to be rendered, determining an initial ray emitted from a target pixel point of the image to be rendered, and determining whether the initial ray hits an opaque object. If so, determining an intersection point between the initial ray and the first opaque object hit by the initial ray as a first intersection point;

[0009] For a light source in a 3D scene, determine whether a shadow ray directed toward the light source, starting from a first intersection point, hits an opaque object. If so, determine the intersection point of the shadow ray with the first opaque spatial object hit by the shadow ray as the second intersection point, and calculate the distance between the first intersection point and the second intersection point to match the shadow intensity of the first intersection point under the light source based on the distance.

[0010] The shadow intensity of the target pixel is determined according to the shadow intensity of the first intersection point under the light source.

[0011] In some embodiments, in the above shadow generation method, the shadow intensity of the first intersection under the light source is negatively correlated with the distance between the first intersection and the second intersection.

[0012] In some embodiments, in the above shadow generation method, determining the shadow intensity of the target pixel point according to the shadow intensity of the first intersection point under the light source includes the following steps:

[0013] The shadow intensity of the first intersection point under each light source is superimposed to obtain the shadow intensity of the target pixel point.

[0014] In some embodiments, in the shadow-based generation method, determining whether the initial light hits an opaque object, and if so, determining the intersection of the initial light and the first opaque object hit by the initial light as the first intersection point includes the following steps:

[0015] According to the ray equation of the initial ray, the initial ray is intersected with each opaque object in the 3D scene to determine whether the initial ray hits the opaque object. If so, the intersection point and the 3D coordinates of the first opaque object hit by the initial ray are determined, and this intersection point is used as the first intersection point.

[0016] For a light source in a three-dimensional scene, determining whether a shadow ray directed toward the light source with a first intersection point as its starting point hits an opaque object; if so, determining the intersection point of the shadow ray with the first opaque spatial object hit by the shadow ray as a second intersection point, including the following steps:

[0017] For a light source in the three-dimensional scene, determining a ray equation of a shadow ray starting from the first intersection point and pointing to the light source based on the three-dimensional coordinates of the first intersection point and the three-dimensional coordinates of the light source;

[0018] According to the light equation of the shadow ray, the intersection calculation between the shadow ray and each opaque object in the three-dimensional scene is performed to determine whether the shadow ray hits the opaque object. If so, the intersection point and three-dimensional coordinates of the shadow ray and the first opaque spatial object it hits are determined, and the intersection point is used as the second intersection point.

[0019] In some embodiments, the shadow-based generation method described above, for a light source in a three-dimensional scene, determines, based on the three-dimensional coordinates of the first intersection point and the three-dimensional coordinates of the light source, a ray equation for a shadow ray starting from the first intersection point and pointing toward the light source, including the following steps:

[0020] For a light source in a three-dimensional scene, the equation of the shadow ray starting from the first intersection point and pointing to the light source is: X=X1+mt, Y=Y1+nt, Z=Z1+pt;

[0021] Where (X1, Y1, Z1) are the three-dimensional coordinates of the first intersection point, m, n, and p are the direction vectors of the shadow ray on the X-axis, Y-axis, and Z-axis respectively, t is the distance of the ray, and (X, Y, Z) are the three-dimensional coordinates of the point on the shadow ray at a distance t from the ray;

[0022] According to the three-dimensional coordinates of the light source (X0, Y0, Z0), the distance t between the first intersection point and the light source is:

[0023] Substitute the three-dimensional coordinates of the light source (X0, Y0, Z0) and the light distance t between the first intersection point and the light source into the light equation of the shadow light, and obtain the direction vectors m, n, and p of the shadow light on the X-axis, Y-axis, and Z-axis respectively: m = (X0–X1) / t, n = (Y0–Y1) / t, p = (Z0–Z1) / t, thereby solving the light equation of the shadow light.

[0024] In some embodiments, in the above shadow-based generation method, the ray equation of the shadow ray is: X=X1+mt, Y=Y1+nt, Z=Z1+pt; wherein (X1, Y1, Z1) are the three-dimensional coordinates of the first intersection point, m, n, and p are the direction vectors of the shadow ray on the X-axis, Y-axis, and Z-axis, respectively, t is the ray distance, and (X, Y, Z) are the three-dimensional coordinates of the point on the shadow ray at the ray distance t;

[0025] The distance D between the first intersection point and the second intersection point can be calculated using any of the following formulas: D = |X2–X1| / m; D = |Y2–Y1| / n; D = |Z2–Z1| / p;

[0026] Among them, (X1, Y1, Z1) are the three-dimensional coordinates of the first intersection point, and (X2, Y2, Z2) are the three-dimensional coordinates of the second intersection point.

[0027] In some embodiments, in the shadow-based generation method, determining the intersection point of the initial light ray and the first opaque object it hits and its three-dimensional coordinates includes the following steps:

[0028] In the process of calculating the intersection of the initial light ray and each opaque object in the three-dimensional scene, determining the intersection points and three-dimensional coordinates of each intersecting opaque object of the initial light ray;

[0029] According to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the intersection points of the initial light ray and each intersecting opaque object, the intersection point with the smallest distance from the target pixel point is determined as the intersection point of the initial light ray and the first opaque object hit by the initial light ray;

[0030] Determining the intersection point of a shadow ray with the first opaque space object it hits and its 3D coordinates involves the following steps:

[0031] In the process of calculating the intersection of the shadow ray and each opaque object in the three-dimensional scene, determining the intersection point and the three-dimensional coordinates of each intersecting opaque object of the shadow ray;

[0032] According to the three-dimensional coordinates of the first intersection point and the three-dimensional coordinates of the intersection points of the shadow ray and each intersecting opaque object, the intersection point with the shortest distance from the first intersection point among the intersection points of the shadow ray and each intersecting opaque object is determined as the intersection point of the shadow ray and the first opaque spatial object it hits.

[0033] In some embodiments, in the above shadow generation method, the distance D between the first intersection point and the second intersection point is calculated as follows:

[0034] Among them, (X1, Y1, Z1) are the three-dimensional coordinates of the first intersection point, and (X2, Y2, Z2) are the three-dimensional coordinates of the second intersection point.

[0035] In some embodiments, the shadow-based generation method further includes:

[0036] Perform denoising on the shadow intensity of the target pixel.

[0037] In some embodiments, in the above shadow-based generation method, the number of initial light rays emitted from a pixel point of the image to be rendered is less than or equal to a preset threshold.

[0038] In some embodiments, in the above shadow-based generation method, the light source is a point light source, a line light source, or a surface light source.

[0039] In some embodiments, in the shadow-based generation method, the number of shadow rays starting from a first intersection point and pointing to a light source is 1.

[0040] According to another aspect of the present disclosure, there is provided an image rendering method, comprising:

[0041] Obtaining the shadow intensity of each pixel in the image to be rendered by the shadow generation method of any of the above embodiments;

[0042] The color of each pixel in the image to be rendered is calculated through the rendering pipeline; the color of each pixel includes chroma and brightness;

[0043] According to the shadow intensity of each pixel, the brightness of each pixel is adjusted to obtain the final color of each pixel.

[0044] According to another aspect of the present disclosure, a graphics processor is provided, comprising:

[0045] A shadow generation module, configured to implement the shadow generation method of any of the above embodiments to obtain the shadow intensity of each pixel in the image to be rendered;

[0046] A rendering module is configured to calculate the color of each pixel of the image to be rendered through a rendering pipeline; the color of each pixel includes chroma and brightness;

[0047] The adjustment module is configured to adjust the brightness of each pixel according to the shadow intensity of each pixel to obtain the final color of each pixel.

[0048] According to another aspect of the present disclosure, a graphics processing system is provided, comprising the graphics processor according to any one of the above embodiments.

[0049] According to another aspect of the present disclosure, an electronic component is provided, comprising the graphics processing system according to any one of the above embodiments.

[0050] According to another aspect of the present disclosure, an electronic device is provided, comprising the electronic component of any one of the above embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] FIG1 is a schematic diagram of a flow chart of a shadow generation method provided by an embodiment of the present disclosure;

[0052] FIG2 is a schematic diagram of the intersection of a shadow ray and an object in a three-dimensional scene provided by one embodiment of the present disclosure;

[0053] FIG3 is a schematic diagram of the intersection of an initial light ray and an object in a three-dimensional scene provided by one embodiment of the present disclosure;

[0054] FIG4 is a schematic diagram of the intersection of shadow light corresponding to a line light source and an object in a three-dimensional scene provided by an embodiment of the present disclosure;

[0055] FIG5 is a schematic diagram of a flow chart of an image rendering method provided by an embodiment of the present disclosure;

[0056] FIG6 is another schematic diagram of a flow chart of an image rendering method provided by an embodiment of the present disclosure;

[0057] FIG7 is a schematic diagram of the structure of a graphics processor provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0058] Before introducing the embodiments of the present disclosure, it should be noted that:

[0059] Some embodiments of the present disclosure are described as processing flows. Although the various operation steps of the flow may be given sequential step numbers, the operation steps therein may be implemented in parallel, concurrently, or simultaneously.

[0060] In the embodiments of the present disclosure, the terms "first", "second", etc. may be used to describe various features, but these features should not be limited by these terms. These terms are used only to distinguish one feature from another.

[0061] The term “and / or” may be used in embodiments of the present disclosure. “And / or” includes any and all combinations of one or more of the listed associated features.

[0062] It should be understood that when describing the connection relationship or communication relationship between two components, unless it is explicitly stated that the two components are directly connected or directly communicating, the connection or communication between the two components can be understood as direct connection or communication, or as indirect connection or communication through an intermediate component.

[0063] In order to make the technical solutions and advantages of the embodiments of the present disclosure more clearly understood, the exemplary embodiments of the present disclosure are further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, and are not an exhaustive list of all the embodiments. It should be noted that the embodiments and features in the embodiments of the present disclosure can be combined with each other unless they conflict.

[0064] The purpose of the present disclosure is to provide a shadow generation method, an image rendering method, a graphics processor and a system. The shadow generation method includes: in a three-dimensional scene of an image to be rendered, determining an initial light ray emitted from a target pixel point of the image to be rendered, and judging whether the initial light ray hits an opaque object. If so, determining the intersection of the initial light ray and the first opaque object hit by the initial light ray as a first intersection point; for a light source in the three-dimensional scene, judging whether a shadow light ray starting from the first intersection point and pointing to the light source hits an opaque object; if so, determining the intersection of the shadow light ray and the first opaque spatial object hit by the initial light ray as a second intersection point, and calculating the distance between the first intersection point and the second intersection point to match the shadow intensity of the first intersection point under the light source according to the distance; and determining the shadow intensity of the target pixel point according to the shadow intensity of the first intersection point under the light source.

[0065] This solution doesn't involve a ray tracing system. Instead, it calculates the distance between the intersection of the light emitted by the pixel and the scene (the first intersection) and the light source obstruction to directly match the corresponding shadow intensity, ultimately achieving a certain degree of soft shadow effect. In other words, without using a lot of hardware and software resources, a realistic soft shadow effect is achieved to a certain extent.

[0066] An embodiment of the present disclosure provides a shadow generation method, as shown in FIG1 , comprising:

[0067] Step S110: In the three-dimensional scene of the image to be rendered, determining an initial ray emitted from a target pixel point of the image to be rendered, and determining whether the initial ray hits an opaque object. If so, determining an intersection point between the initial ray and the first opaque object hit by the initial ray as a first intersection point;

[0068] Step S120: For a light source in the three-dimensional scene, determine whether a shadow ray starting from a first intersection point and directed toward the light source hits an opaque object; if so, determine the intersection point of the shadow ray and the first opaque spatial object hit by the shadow ray as the second intersection point, and calculate the distance between the first intersection point and the second intersection point to match the shadow intensity of the first intersection point under the light source based on the distance;

[0069] Step S130: determining the shadow intensity of the target pixel point according to the shadow intensity of the first intersection point under the light source.

[0070] It can be understood that the first opaque object hit by the initial ray is the nearest unobstructed object seen by the human eye when looking at the target pixel (under the perspective corresponding to the initial ray) or captured by the camera when photographing the target pixel (under the perspective corresponding to the initial ray). The intersection point (first intersection) between the initial ray and the first opaque object it hits can be understood as the point seen by the human eye when looking at the target pixel or captured by the camera when photographing the target pixel (also the intersection point of the initial ray and the 3D scene). Therefore, the shadow intensity of the target pixel can be derived from the shadow intensity of the intersection point (first intersection) between the initial ray and the first opaque object it hits. Whether the first intersection point is in the shadow area of ​​the light source depends on whether there is an obstruction between the first intersection point and the light source (that is, whether the shadow ray starting from the first intersection point and directed towards the light source hits an opaque object). When the first intersection point is in the shadow area of ​​the light source, the shadow intensity of the first intersection point under the light source is determined by the obstruction distance (the distance between the first intersection point and the second intersection point). Different occlusion distances (the distance between the first intersection point and the second intersection point) can be matched to obtain different shadow intensities, thereby obtaining a certain degree of soft shadow effect.

[0071] In the above steps, the steps of light generation and shadow intensity matching are implemented by software, and the other steps are implemented by hardware.

[0072] The three-dimensional scene of the image to be rendered refers to a scene containing a three-dimensional model of the image to be rendered, such as a game scene, an animation scene, etc. The three-dimensional scene includes all geometric objects such as light sources, obstructions, and scene objects.

[0073] In some embodiments, the shadow intensity of the first intersection under the light source is negatively correlated with the distance between the first intersection and the second intersection.

[0074] That is to say, the matching rule of the shadow intensity of the first intersection under the light source is: the smaller the distance between the first intersection and the second intersection, the greater the shadow intensity of the first intersection under the corresponding light source; the greater the distance between the first intersection and the second intersection, the smaller the shadow intensity of the first intersection under the corresponding light source.

[0075] It can be understood that the distance between the first intersection and the second intersection indicates the degree of obstruction of the first intersection by the opaque object (obstruction). The smaller the distance, the greater the degree of obstruction of the first intersection by the opaque object (obstruction), and the greater the shadow intensity. The larger the distance, the smaller the degree of obstruction of the first intersection by the opaque object (obstruction), and the smaller the shadow intensity.

[0076] The specific correlation (e.g., correlation coefficient) between the shadow intensity of the first intersection under the light source and the distance between the first intersection and the second intersection can be set as needed. The initial correlation between the shadow intensity and the occlusion distance (the distance between the first intersection and the second intersection) can be set by software. In step S120, the corresponding shadow intensity is obtained based on the matching of the initial correlation. After the final rendering result of the image to be rendered is obtained by combining the shadow intensity with the rendering pipeline, the software can also continuously debug the correlation between the shadow intensity and the occlusion distance (the distance between the first intersection and the second intersection) based on the rendering result, so that the shadow effect in the final rendering result continuously approaches the real soft shadow effect.

[0077] In step S120 , when the shadow light starting from the first intersection point and directed toward a light source does not hit the opaque object, it is determined that the first intersection point is not in the shadow area of ​​the light source, that is, the shadow intensity under the light source is 0.

[0078] As shown in Figure 2, points A, B, and C are the intersection points of the initial light rays emitted by the three pixel points and the first opaque spatial object they hit. That is, points A, B, and C are the three first intersection points corresponding to the three pixel points. Among them, the shadow light from point A to the light source does not hit the opaque object (that is, there is no obstruction between point A and the light source), and the shadow light from points B and C to the light source both hit the opaque object (that is, there is an obstruction between points B and C and the light source), so points B and C are shadows. Among them, since the distance from point C to the first opaque spatial object it hits is longer, the shadow of point C is lighter, and the distance from point B to the first opaque spatial object it hits is shorter, so the shadow of point B is darker.

[0079] In some embodiments, in step S110, determining whether the initial light hits an opaque object, and if so, determining the intersection of the initial light and the first opaque object hit by the initial light as the first intersection point includes the following steps:

[0080] According to the ray equation of the initial ray, the initial ray is intersected with each opaque object in the 3D scene to determine whether the initial ray hits the opaque object. If so, the intersection point and the 3D coordinates of the first opaque object hit by the initial ray are determined, and this intersection point is used as the first intersection point.

[0081] In step S120, for a light source in a three-dimensional scene, it is determined whether a shadow ray starting from a first intersection point and directed toward the light source hits an opaque object; if so, the intersection point of the shadow ray and the first opaque spatial object hit by the shadow ray is determined as the second intersection point, including the following steps:

[0082] For a light source in the three-dimensional scene, determining a ray equation of a shadow ray starting from the first intersection point and pointing to the light source based on the three-dimensional coordinates of the first intersection point and the three-dimensional coordinates of the light source;

[0083] According to the light equation of the shadow ray, the intersection calculation between the shadow ray and each opaque object in the three-dimensional scene is performed to determine whether the shadow ray hits the opaque object. If so, the intersection point and three-dimensional coordinates of the shadow ray and the first opaque spatial object it hits are determined, and the intersection point is used as the second intersection point.

[0084] It can be understood that if a ray intersects a geometric object, it is considered that the ray hits the geometric object.

[0085] The ray equation of the initial ray emitted from the target pixel of the image to be rendered is determined when the initial ray is generated, while the spatial geometric equations of each opaque object in the 3D scene are determined when the 3D scene is constructed. Therefore, based on the ray equation of the initial ray and the spatial geometric equations of each opaque object, the initial ray can be intersected with each opaque object in the 3D scene to determine whether the initial ray hits the opaque object. The initial ray can also be intersected with the primitives that make up the opaque object (such as a triangle) to determine whether the initial ray hits the opaque object. Specifically, the intersection calculation can use an intersection algorithm such as Monte Carlo. For example, when calculating the intersection of the initial ray and the triangle primitive, the intersection point of the ray and the plane containing the triangle primitive is usually calculated first, and then a determination is made whether the intersection point is on the triangle primitive. If it is on the triangle primitive, it indicates that the intersection is indeed achieved. Therefore, during the intersection calculation, the intersection points and their 3D coordinates of each intersecting opaque object are also obtained.

[0086] Similarly, when determining whether a shadow ray originating from the first intersection point and directed toward a light source hits an opaque object, the ray equation for the shadow ray originating from the first intersection point and directed toward the light source is first determined. Then, based on the ray equation for the shadow ray, an intersection calculation is performed between the shadow ray and each opaque object in the 3D scene to determine whether the shadow ray hits the opaque object. During this intersection calculation, the intersection points and 3D coordinates of each intersecting opaque object are also obtained.

[0087] In some embodiments, in the scenario described above where the intersection calculation is used to determine whether a shadow ray intersects an opaque object, for a light source in a three-dimensional scene, determining a ray equation for a shadow ray starting from the first intersection point and pointing toward the light source based on the three-dimensional coordinates of the first intersection point and the three-dimensional coordinates of the light source includes the following steps:

[0088] For a light source in a three-dimensional scene, the equation of the shadow ray starting from the first intersection point and pointing to the light source is: X=X1+mt, Y=Y1+nt, Z=Z1+pt;

[0089] Where (X1, Y1, Z1) are the three-dimensional coordinates of the first intersection point, m, n, and p are the direction vectors of the shadow ray on the X-axis, Y-axis, and Z-axis respectively, t is the distance of the ray, and (X, Y, Z) are the three-dimensional coordinates of the point on the shadow ray at a distance t from the ray;

[0090] According to the three-dimensional coordinates of the light source (X0, Y0, Z0), the distance t between the first intersection point and the light source is:

[0091] Substitute the three-dimensional coordinates of the light source (X0, Y0, Z0) and the light distance t between the first intersection point and the light source into the light equation of the shadow light, and obtain the direction vectors m, n, and p of the shadow light on the X-axis, Y-axis, and Z-axis respectively: m = (X0–X1) / t, n = (Y0–Y1) / t, p = (Z0–Z1) / t, thereby solving the light equation of the shadow light.

[0092] The three-dimensional coordinates of each light source in the three-dimensional scene are determined when the three-dimensional scene is constructed.

[0093] The above-mentioned shadow ray solving process can be understood as follows: since the above-mentioned light source and the first intersection point are both on the shadow ray, the light distance between the two is first calculated through the three-dimensional coordinates of the light source and the first intersection point, and then the three-dimensional coordinates of the light source and the first intersection point, as well as the light distance between the two are substituted into the light equation of the shadow ray, that is, the direction vectors m, n and p of the shadow ray on the X-axis, Y-axis and Z-axis are solved, thereby solving the light equation of the shadow ray.

[0094] After the shadow ray equation is solved, in step S120 , the distance between the first intersection point and the second intersection point can be calculated using any of the following formulas: D = |X2–X1| / m; D = |Y2–Y1| / n; D = |Z2–Z1| / p;

[0095] Among them, (X1, Y1, Z1) are the three-dimensional coordinates of the first intersection point, and (X2, Y2, Z2) are the three-dimensional coordinates of the second intersection point.

[0096] In addition, the distance between the first and second intersection points can be calculated directly according to the following formula instead of the light equation of the shadow light:

[0097] In some embodiments, in the scenario described above where the intersection calculation is used to determine whether the initial ray or the shadow ray intersects with an opaque object, determining the intersection point between the initial ray and the first opaque object hit by the initial ray and its three-dimensional coordinates includes the following steps:

[0098] In the process of calculating the intersection of the initial light ray and each opaque object in the three-dimensional scene, determining the intersection points and three-dimensional coordinates of each intersecting opaque object of the initial light ray;

[0099] According to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the intersection points of the initial light ray and each intersecting opaque object, the intersection point with the smallest distance from the target pixel point is determined as the intersection point of the initial light ray and the first opaque object hit by the initial light ray;

[0100] Determining the intersection point of a shadow ray with the first opaque space object it hits and its 3D coordinates involves the following steps:

[0101] In the process of calculating the intersection of the shadow ray and each opaque object in the three-dimensional scene, determining the intersection point and the three-dimensional coordinates of each intersecting opaque object of the shadow ray;

[0102] According to the three-dimensional coordinates of the first intersection point and the three-dimensional coordinates of the intersection points of the shadow ray and each intersecting opaque object, the intersection point with the shortest distance from the first intersection point among the intersection points of the shadow ray and each intersecting opaque object is determined as the intersection point of the shadow ray and the first opaque spatial object it hits.

[0103] Among the intersection points between the initial ray and each intersecting opaque object, the point with the smallest distance from the target pixel is determined. This can be understood as the first collision point between the initial ray and the opaque object in the 3D scene. This collision point is what the human eye sees when looking at the target pixel, or what a camera captures when photographing the target pixel (it is also the first intersection point between the initial ray and the 3D scene). The shadow intensity of this collision point directly reflects the shadow intensity of the target pixel. Therefore, the first collision point between the initial ray and the opaque object in the 3D scene is selected as the first intersection point to generate the shadow, as shown in Figure 3.

[0104] In some embodiments, the distance D between the intersection of the initial light and each intersecting opaque object and the target pixel is i The calculation formula is: Among them, (X p ,Y p ,Z p ) is the three-dimensional coordinate of the target pixel, (X i ,Y i ,Z i ) are the three-dimensional coordinates of the intersection points of the initial light ray and each opaque object it intersects.

[0105] Furthermore, the intersection point with the smallest distance from the first intersection point among the intersection points of the shadow ray and each intersecting opaque object can be understood as the first collision point between the shadow ray and the opaque object in the 3D scene. The distance between this collision point and the first intersection point can truly reflect the degree of occlusion of the first intersection point by the occluding object (opaque object). The smaller the distance, the greater the degree of occlusion. Therefore, the first collision point between the shadow ray and the opaque object in the 3D scene is selected as the second intersection point, and the distance between the second intersection point and the first intersection point is calculated to match the shadow intensity of the first intersection point.

[0106] In some embodiments, the distance D between the intersection point of the shadow ray and each opaque object intersected and the first intersection point is j The calculation formula is: Among them, (X1, Y1, Z1) is the three-dimensional coordinates of the first intersection point, (X j ,Y j ,Z j ) are the three-dimensional coordinates of the intersection points of the shadow ray and each opaque object it intersects.

[0107] In the above shadow generation method, regardless of the number of initial rays emitted from a pixel in the image to be rendered, a soft shadow effect can be achieved to a certain extent. However, the greater the number of initial rays emitted from a pixel, the more computing resources are required. Therefore, to further avoid the need for a large amount of computing resources, in some embodiments, the number of initial rays emitted from a pixel in the image to be rendered is less than or equal to a preset threshold. In other words, the number of initial rays emitted from a pixel in the image to be rendered can be limited.

[0108] The more initial rays emitted from a pixel, the better the resulting shadow effect. Therefore, in some usage scenarios, the number of initial rays emitted from a pixel can be set based on the actual computing resource capabilities and the desired shadow effect.

[0109] In some embodiments, the preset threshold may be 1, that is, the number of initial rays emitted from a pixel point of the image to be rendered is 1.

[0110] In a scenario where a pixel point (target pixel point) of the image to be rendered emits an initial ray, in order to make the initial ray emitted by a pixel point intersect with opaque objects as much as possible, the initial ray corresponding to the pixel point can be emitted toward the area where spatial objects are densely populated, so that each pixel point can obtain the corresponding shadow intensity as much as possible.

[0111] In some embodiments, the preset threshold may be greater than 1, that is, the number of initial light rays emitted from a pixel point of the image to be rendered may be greater than 1.

[0112] Among them, when multiple initial light rays emitted from a pixel point (target pixel point) of the image to be rendered hit an opaque object, different first intersection points are obtained. According to step S120, the shadow intensities of these first intersection points under a light source are obtained respectively. The shadow intensities of these first intersection points under the light source are superimposed to obtain the shadow intensity of the pixel point (target pixel point).

[0113] It should be noted that the direction of the initial light emitted from a pixel point (target pixel point) can be arbitrary (random), and can be selected not according to the observation point or the position (viewing angle) of the camera, but can also be selected according to the observation point or the position (viewing angle) of the camera. For example, in a scenario where a pixel point (target pixel point) of the image to be rendered emits an initial light ray, the initial light rays corresponding to each pixel point in the image to be rendered can also be rays starting from a specified observation point and pointing to these pixel points respectively. If a pixel point (target pixel point) of the image to be rendered can emit two initial light rays, then two observation points can be specified, and so on.

[0114] In some embodiments, for a scene with multiple light sources in a three-dimensional scene, the shadow intensity of the first intersection under each light source can be obtained for each light source in the three-dimensional scene by the method in step S120.

[0115] Correspondingly, step S130 includes the following steps:

[0116] The shadow intensity of the first intersection point under each light source is superimposed to obtain the shadow intensity of the target pixel point.

[0117] The shadow intensities of the first intersection point under each light source may be superimposed by directly adding them together, or by multiplying the shadow intensities of the first intersection point under each light source by corresponding weights according to the contribution of each light source and then summing them up.

[0118] In a three-dimensional scene with multiple light sources, when multiple initial light rays emitted from a pixel point (target pixel point) of the image to be rendered hit an opaque object, different first intersection points are obtained. For different light sources, the shadow intensity of each first intersection point under each light source is obtained respectively according to step S120, and then for a first intersection point, the shadow intensities of the first intersection point under each light source are superimposed to obtain the total shadow intensity of the first intersection point under all light sources, and then the total shadow intensities of each first intersection point corresponding to the pixel point (target pixel point) are superimposed to obtain the shadow intensity of the pixel point (target pixel point).

[0119] In some embodiments, the shadow intensity of the target pixel obtained in the above step S130 may contain noise. In order to further optimize the soft shadow effect, the above method further includes: performing denoising processing on the shadow intensity of the target pixel.

[0120] A specific denoising process may be to perform denoising filtering using a filter kernel.

[0121] In some embodiments, the light source is a point light source, a line light source, or a surface light source.

[0122] When the light source is a line light source or a surface light source, in the step of determining the light equation of the shadow light, the three-dimensional coordinates of the light source used refer to the three-dimensional coordinates of any point or specified point on the light source.

[0123] In some embodiments, when the light source is a line light source or a surface light source, there can be multiple shadow rays starting from a first intersection point and pointing to a light source (line light source or surface light source), that is, a first intersection point can emit shadow rays to different points of a light source (line light source or surface light source), and the multiple shadow rays obtained correspond to different second intersection points. The distances between these second intersection points and the first intersection point are calculated, and multiple shadow intensities are matched to obtain them. The multiple shadow intensities can be superimposed to finally obtain the shadow intensity of the first intersection point.

[0124] In some embodiments, in order to further reduce computing resources and avoid wasting software and hardware resources, when the light source is a line light source or a surface light source, a shadow ray starting from a first intersection point and pointing to a light source (line light source or surface light source) is one, that is, a first intersection point emits a shadow ray to a light source (line light source or surface light source), and at most one second intersection point is obtained.

[0125] For example, Figure 4 shows a schematic diagram of the intersection of the shadow light corresponding to the line light source and the objects in the three-dimensional scene. Assume that the two ends of the line light source are points P and Q. If the first intersection point is located in the ABCD plane, in a scene where a first intersection point sends a shadow ray to the line light source, the emitted shadow ray only needs to reach between PQ. Therefore, the directions of the shadow rays randomly emitted by each first intersection point on the ABCD plane may be different, and each shadow ray may also hit an opaque object.

[0126] As can be seen in Figure 4, on the ABCD plane, any shadow ray emitted from the first intersection point on segment BC to the linear light source will be blocked by the opaque object. Therefore, segment BC is deeply shadowed. As mentioned earlier, the shadow intensity can be calculated based on the distance from the first intersection point to the second intersection point (the occluder intersection point). Because the distance from the first intersection point to the opaque object (occluder) on all BC segments is similar, the shadow noise corresponding to the first intersection point on the BC segment is not noticeable, so the denoising filter can use a smaller and smoother filter kernel.

[0127] When any shadow ray is emitted from the first intersection of segments AB and CD to a line light source, it may directly reach the light source or be blocked by an opaque object. Therefore, the shadow intensity of the first intersection may be 0 (appearing as a bright spot) or non-zero (appearing as a shadow). For the first intersection of segments AB and CD, because bright spots or shadows are randomly generated, the rendering result looks like noise. After denoising filtering, a shadow of a certain intensity is ultimately generated. Because the bright spots and shadows are mixed together, the final result is a soft shadow.

[0128] The first intersection point is located on the left side of point A and the right side of point D. Since the shadow light emitted to the linear light source is not blocked by opaque objects, the rendering result is a bright spot.

[0129] Overall, the shadow generation method described above achieves a transition and brightness change from dark to light and finally to bright areas under line light sources, which is closer to the real effect. The same principle applies to area light sources and will not be further explained here.

[0130] After the shadow intensity of each pixel on the to-be-rendered image is generated, the shadow intensity of each pixel may be written into a video memory. In subsequent rendering steps, the shadow intensity of each pixel may be read out from the video memory as needed.

[0131] Based on the same inventive concept, as shown in FIG5 , an embodiment of the present disclosure further provides an image rendering method, including:

[0132] Step S210: obtaining the shadow intensity of each pixel in the image to be rendered by the shadow generation method of any of the above embodiments;

[0133] Step S220: Calculate the color of each pixel in the image to be rendered through the rendering pipeline; the color of each pixel includes chroma and brightness;

[0134] Step S230: adjusting the brightness of each pixel according to the shadow intensity of each pixel to obtain the final color of each pixel.

[0135] The rendering pipeline for calculating the color of each pixel in the image to be rendered includes the traditional vertex shading stage, the rasterization stage, and the fragment shading stage.

[0136] The shadow intensity of each pixel in the image to be rendered is obtained by the shadow generation method of any of the above embodiments and stored in the video memory. After the color of each pixel in the image to be rendered is calculated through the rendering pipeline, the shadow data (the shadow intensity of each pixel) is read from the video memory and superimposed on the color of each pixel to adjust the brightness of each pixel to obtain the final color of each pixel, which is then written back to the video memory.

[0137] In the process of superimposing the shadow intensity and color of each pixel point, the greater the shadow intensity of a pixel point, the lower the brightness of the pixel point, and the smaller the shadow intensity of a pixel point, the higher the brightness of the pixel point.

[0138] In some embodiments, as shown in Figure 6, the overall process of the above-mentioned image rendering method is: the software generates an initial light (with a pixel as the starting point); the hardware calculates the intersection of the initial light and the first opaque object it hits as the first intersection, determines the light equation of the shadow light with the first intersection as the starting point and pointing to a light source, determines the intersection of the shadow light and the first opaque object it hits as the second intersection (shadow position point), calculates the distance between the first intersection and the second intersection, as the distance at which the shadow light is blocked by the opaque object; the hardware feeds back the distance to the software, and the software matches the shadow intensity of the first intersection according to the distance, obtains the shadow intensity of the pixel point and writes it into the video memory; the hardware calculates the color of each pixel in the image to be rendered through the rendering pipeline, and reads the shadow data (the shadow intensity of each pixel point) from the video memory, superimposes it on the color of each pixel point to adjust the brightness of each pixel point, obtains the final color of each pixel point, and writes the final rendering color back to the video memory.

[0139] The video memory may be a frame buffer.

[0140] Based on the same inventive concept, an embodiment of the present disclosure further provides a graphics processor 300, as shown in FIG7 , including:

[0141] The shadow generation module 310 is configured to implement the shadow generation method of any of the above embodiments to obtain the shadow intensity of each pixel in the image to be rendered;

[0142] The rendering module 320 is configured to calculate the color of each pixel in the image to be rendered through the rendering pipeline; the color of each pixel includes chroma and brightness;

[0143] The adjustment module 330 is configured to adjust the brightness of each pixel according to the shadow intensity of each pixel to obtain the final color of each pixel.

[0144] The specific implementation process of each module of the above-mentioned graphics processor can refer to the shadow generation method of any of the above-mentioned embodiments or the image rendering method of any of the above-mentioned embodiments, and will not be repeated here.

[0145] Based on the same inventive concept, an embodiment of the present disclosure further provides a graphics processing system, comprising a graphics processor according to any of the above embodiments.

[0146] The graphics processing system can be a die (tube core), or a SOC (System on Chip) with multiple dies interconnected, or other organizational forms.

[0147] Based on the same inventive concept, an embodiment of the present disclosure further provides an electronic component, which includes the graphics processing system in any of the above embodiments.

[0148] In some usage scenarios, the electronic component is in the form of a graphics card or a CPU motherboard.

[0149] Based on the same inventive concept, embodiments of the present disclosure further provide an electronic device comprising the aforementioned electronic components. In some usage scenarios, the electronic device is a portable electronic device, such as a smartphone, tablet computer, or VR device; in other usage scenarios, the electronic device is a personal computer, game console, or the like.

[0150] Although the preferred embodiments of the present disclosure have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present disclosure.

[0151] Obviously, those skilled in the art may make various changes and modifications to the present disclosure without departing from the spirit and scope of the present disclosure. Thus, if these modifications and variations of the present disclosure fall within the scope of the claims of the present disclosure and their equivalents, the present disclosure is intended to include these modifications and variations.

Claims

1. A shadow generation method, comprising: In a three-dimensional scene of an image to be rendered, determining an initial light ray emitted from a target pixel point of the image to be rendered, and determining whether the initial light ray hits an opaque object, and if so, determining an intersection point between the initial light ray and the first opaque object hit by the initial light ray as a first intersection point; For a light source in the three-dimensional scene, determining whether a shadow ray starting from the first intersection point and pointing to the light source hits an opaque object; If yes, determine the intersection point of the shadow ray and the first opaque spatial object it hits as the second intersection point, and calculate the distance between the first intersection point and the second intersection point to match the shadow intensity of the first intersection point under the light source according to the distance; The shadow intensity of the target pixel point is determined according to the shadow intensity of the first intersection point under the light source. 2 . The method according to claim 1 , wherein the shadow intensity of the first intersection under the light source is negatively correlated with the distance between the first intersection and the second intersection.

3. The method according to claim 1, determining the shadow intensity of the target pixel point according to the shadow intensity of the first intersection point under the light source, comprising the following steps: The shadow intensity of the first intersection point under each light source is superimposed to obtain the shadow intensity of the target pixel point.

4. The method according to claim 1, determining whether the initial light hits an opaque object, and if so, determining the intersection of the initial light and the first opaque object hit by the initial light as the first intersection, comprising the following steps: According to the light equation of the initial light, the initial light is intersected with each opaque object in the three-dimensional scene to determine whether the initial light hits an opaque object, and if so, the intersection point and the three-dimensional coordinates of the first opaque object hit by the initial light are determined, and the intersection point is used as the first intersection point; For a light source in the three-dimensional scene, determining whether a shadow ray starting from the first intersection point and pointing to the light source hits an opaque object; If yes, then determining the intersection point of the shadow ray and the first opaque spatial object it hits as the second intersection point comprises the following steps: For a light source in the three-dimensional scene, determining a light equation of a shadow light starting from the first intersection point and pointing to the light source according to the three-dimensional coordinates of the first intersection point and the three-dimensional coordinates of the light source; According to the light equation of the shadow ray, the intersection calculation of the shadow ray and each opaque object in the three-dimensional scene is performed to determine whether the shadow ray hits an opaque object. If so, the intersection point of the shadow ray and the first opaque spatial object hit by the shadow ray and its three-dimensional coordinates are determined, and the intersection point is used as the second intersection point.

5. The method according to claim 4, for a light source in the three-dimensional scene, determining a light equation of a shadow light starting from the first intersection point and pointing to the light source according to the three-dimensional coordinates of the first intersection point and the three-dimensional coordinates of the light source, comprising the following steps: For a light source in the three-dimensional scene, the light equation of the shadow light starting from the first intersection and pointing to the light source is: X=X1+mt, Y=Y1+nt, Z=Z1+pt; Wherein, (X1, Y1, Z1) are the three-dimensional coordinates of the first intersection point, m, n and p are the direction vectors of the shadow light on the X-axis, Y-axis and Z-axis respectively, t is the light distance, and (X, Y, Z) are the three-dimensional coordinates of the point on the shadow light with a light distance of t; According to the three-dimensional coordinates (X0, Y0, Z0) of the light source, the light distance t between the first intersection point and the light source is obtained as: Substitute the three-dimensional coordinates (X0, Y0, Z0) of the light source and the light distance t between the first intersection point and the light source into the light equation of the shadow light, and obtain the direction vectors m, n and p of the shadow light on the X-axis, Y-axis and Z-axis respectively: m = (X0-X1) / t, n = (Y0-Y1) / t, p = (Z0-Z1) / t, thereby solving the light equation of the shadow light.

6. The method according to claim 4, wherein the light equation of the shadow light is: X=X1+mt, Y=Y1+nt, Z=Z1+pt; wherein, (X1, Y1, Z1) are the three-dimensional coordinates of the first intersection point, m, n and p are the direction vectors of the shadow light on the X-axis, Y-axis and Z-axis respectively, t is the light distance, and (X, Y, Z) are the three-dimensional coordinates of the point on the shadow light with the light distance t; The distance D between the first intersection point and the second intersection point is calculated using any one of the following formulas: D = |X2–X1| / m; D = |Y2–Y1| / n; D = |Z2–Z1| / p; Among them, (X2, Y2, Z2) are the three-dimensional coordinates of the second intersection point.

7. The method according to claim 4, determining the intersection point of the initial light ray with the first opaque object hit by the initial light ray and its three-dimensional coordinates, comprising the following steps: In the process of performing intersection calculation on the initial light and each opaque object in the three-dimensional scene, determining the intersection points and three-dimensional coordinates of each intersecting opaque object between the initial light and the intersecting opaque object; According to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the intersection points of the initial light ray and each of the intersecting opaque objects, determine the intersection point with the shortest distance from the target pixel point among the intersection points of the initial light ray and each of the intersecting opaque objects, as the intersection point of the initial light ray and the first opaque object hit by the initial light ray; Determining the intersection point of the shadow ray with the first opaque spatial object hit by the shadow ray and its three-dimensional coordinates, comprising the following steps: In the process of calculating the intersection of the shadow ray and each opaque object in the three-dimensional scene, determining the intersection points and the three-dimensional coordinates of the intersection points between the shadow ray and each opaque object; According to the three-dimensional coordinates of the first intersection point and the three-dimensional coordinates of the intersection points of the shadow ray and each intersecting opaque object, determine the intersection point with the shortest distance from the first intersection point among the intersection points of the shadow ray and each intersecting opaque object as the intersection point of the shadow ray and the first opaque spatial object it hits.

8. According to the method of claim 1, the distance D between the first intersection point and the second intersection point is calculated as follows: in, (X1, Y1, Z1) are the three-dimensional coordinates of the first intersection, and (X2, Y2, Z2) are the three-dimensional coordinates of the second intersection.

9. The method according to claim 1, further comprising: The shadow intensity of the target pixel is denoised.

10. According to the method of claim 1, the number of initial light rays emitted from a pixel point of the image to be rendered is less than or equal to a preset threshold. The method according to claim 1 , wherein the light source is a point light source, a line light source or a surface light source. 12 . The method according to claim 1 , wherein the number of shadow rays starting from the first intersection point and pointing to a light source is 1.

13. An image rendering method, comprising: Obtaining the shadow intensity of each pixel in the image to be rendered by the method described in any one of claims 1 to 12; Calculate the color of each pixel in the image to be rendered through a rendering pipeline; The color of each pixel includes chromaticity and brightness; According to the shadow intensity of each pixel, the brightness of each pixel is adjusted to obtain the final color of each pixel.

14. A graphics processor, comprising: A shadow generation module, configured to implement the method according to any one of claims 1 to 12 to obtain the shadow intensity of each pixel in the image to be rendered; A rendering module, configured to calculate the color of each pixel in the image to be rendered through a rendering pipeline; The color of each pixel includes chromaticity and brightness; The adjustment module is configured to adjust the brightness of each pixel according to the shadow intensity of each pixel to obtain the final color of each pixel.

15. A graphics processing system, comprising the graphics processor according to claim 14.

16. An electronic component, wherein: Includes the graphics processing system described in claim 15.

17. An electronic device, wherein: The electronic component comprising claim 16.

Citation Information

Patent Citations

  • Shadow effect rendering method and device, storage medium and electronic device

    CN113313806A

  • Rendering method and device, computer equipment and storage medium

    CN114549719A

  • Sphere rendering method and device, electronic equipment and readable storage medium

    CN114820913A

  • Performance of ray-traced shadow creation within a scene

    US20210027520A1