[go: up one dir, main page]

CN119068105A - Cascade shadow generation method, device, storage medium and computer equipment - Google Patents

Cascade shadow generation method, device, storage medium and computer equipment Download PDF

Info

Publication number
CN119068105A
CN119068105A CN202411072139.7A CN202411072139A CN119068105A CN 119068105 A CN119068105 A CN 119068105A CN 202411072139 A CN202411072139 A CN 202411072139A CN 119068105 A CN119068105 A CN 119068105A
Authority
CN
China
Prior art keywords
cascade
shadow
light source
view
hierarchy
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202411072139.7A
Other languages
Chinese (zh)
Inventor
刘宇辰
傅鸿鑫
朱灿
张熠坤
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
DeepRoute AI Ltd
Original Assignee
DeepRoute AI Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by DeepRoute AI Ltd filed Critical DeepRoute AI Ltd
Priority to CN202411072139.7A priority Critical patent/CN119068105A/en
Publication of CN119068105A publication Critical patent/CN119068105A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/60Shadow generation
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/60Analysis of geometric attributes
    • G06T7/66Analysis of geometric attributes of image moments or centre of gravity

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Geometry (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Computer Graphics (AREA)
  • Image Generation (AREA)

Abstract

The application discloses a cascade shadow generation method, a cascade shadow generation device, a storage medium and computer equipment. The cascade shadow generation method comprises the steps of dividing a center of a target object to form a plurality of cascade layers along a preset radius, calculating a view cone range of each cascade layer under a light source view angle, and respectively performing scene rendering on each cascade layer from the light source view angle based on the view cone range to generate cascade shadows. By the method, repeated calculation of cascade shadows of repeated division of cascade hierarchy is avoided, cascade shadows can be efficiently, accurately and stably generated, the generated cascade shadows meet the observation requirements of different viewpoints, consumption of calculation resources can be reduced, flexibility and compatibility are achieved, and reality and reliability of corresponding scene simulation are improved.

Description

Cascade shadow generation method and device, storage medium and computer equipment
Technical Field
The present application relates to the field of autopilot simulation technologies, and in particular, to a cascade shadow generating method, apparatus, storage medium, and computer device.
Background
In the simulation test of the automatic driving system, the accurate simulation of the shadow effect of the sensor picture can enable the simulation scene to be more close to the real scene, so that the functions of visual perception, object detection and the like of the automatic driving system can be tested more accurately, effectively and reliably, and the automatic driving system is facilitated to be better suitable for driving scenes in the real world.
In the existing shadow calculation, a camera view cone is segmented into a plurality of levels by adopting cascade shadow mapping (Cascaded Shadow Maps, abbreviated as CSM) to generate a plurality of shadow maps, and each level uses shadow maps with different resolutions to improve the shadow expression effect. However, in an autopilot simulation scenario, a user generally needs to simulate sensor pictures of tens of different camera sensors, while a traditional CSM performs hierarchical division based on a viewing cone of a camera, needs to perform repeated division on different cameras and perform repeated calculation and resource binding on engineering, and the like, so that the autopilot simulation scenario has large calculation power consumption, low calculation efficiency, poor flexibility and generalization, and meanwhile, because the autopilot has higher requirements on the accuracy of the camera sensors, the quality and the speed of shadow generation are also higher, so that the traditional CSM has difficulty in performing shadow mapping calculation on images acquired by the multi-camera sensors in a real-time scenario.
Disclosure of Invention
The application mainly provides a cascade shadow generation method, a cascade shadow generation device, a storage medium and computer equipment, and aims to solve the technical problem of poor flexibility of traditional cascade shadow mapping.
In order to solve the technical problems, the technical scheme adopted by the application is to provide a cascade shadow generation method. The cascade shadow generation method comprises the steps of dividing a center of a target object to form a plurality of cascade layers along a preset radius, calculating a view cone range of each cascade layer under a light source view angle, and respectively performing scene rendering on each cascade layer from the light source view angle based on the view cone range to generate cascade shadows.
In some embodiments, the calculating the view cone range of each cascade level at a light source view angle comprises determining an outsourcing rectangle of each cascade level and taking the outsourcing rectangle as a corner point, calculating a minimum z value and a view cone width surrounding all the corner points from the light source view angle, wherein the minimum z value is a minimum distance value from a light source to the outsourcing rectangle, the view cone width is a width of the outsourcing rectangle at the light source view angle, determining an observation matrix and a projection matrix of the cascade level at the light source view angle based on the minimum z value and the view cone width, and determining the view cone range of each cascade level at the light source view angle based on the observation matrix and the projection matrix.
In some embodiments, the determining a view cone range for each of the cascade layers at the light source viewing angle based on the observation matrix and the projection matrix includes determining view cone position information at the light source viewing angle based on the observation matrix, determining view cone shape information at the light source viewing angle based on the projection matrix, and determining the view cone range based on the view cone position information and the view cone shape information.
In some embodiments, the scene rendering is performed on each cascade layer from the view angle of the light source based on the view cone range to generate cascade shadows, and the method comprises determining a cascade shadow generation range corresponding to each cascade layer based on the view cone range, performing shadow mapping on scenes in the cascade shadow generation range from the view angle of the light source to obtain corresponding shadow maps, and reserving the shadow maps in the corresponding ranges of each cascade layer to obtain the cascade shadows.
In some embodiments, the scene rendering is performed on each cascade layer from the light source view angle based on the view cone range to generate cascade shadows, and the method further comprises determining a cascade layer to be tested based on depth values of pixel points in the cascade shadow coverage range, performing shadow testing on the cascade layer to be tested to determine the blocked degree of each pixel point in the cascade layer to be tested, and performing shadow value adjustment on the cascade shadows of the cascade layer to be tested based on the blocked degree.
In some embodiments, the preset radius is not less than a distance from a viewpoint on the target object to a most distant point of a viewing cone corresponding to the viewpoint.
In some embodiments, the dividing along a predetermined radius forms a plurality of cascaded hierarchies including dividing the predetermined radius based on at least one of a linear division, a logarithmic division, and a weighted mixture division to obtain a plurality of the cascaded hierarchies.
In order to solve the technical problem, the application provides a cascade shadow generating device, which comprises a dividing module, a calculating module and a rendering module, wherein the dividing module is used for dividing a target object center into a plurality of cascade layers along a preset radius, the calculating module is used for calculating the view cone range of each cascade layer under the view angle of a light source, and the rendering module is used for respectively rendering scenes of each cascade layer from the view angle of the light source based on the view cone range so as to generate cascade shadows.
In order to solve the technical problem, the application adopts another technical scheme that a storage medium is provided, and program data is stored on the storage medium, and the method is characterized in that the program data is executed by a processor to realize the steps of the cascade shadow generation method.
In order to solve the technical problem, the application adopts another technical scheme that the computer equipment comprises a processor and a memory which are connected with each other, wherein the memory stores a computer program, and the steps of the cascade shadow generation method are realized when the processor executes the computer program.
The application has the beneficial effects that the application discloses a cascade shadow generation method, a cascade shadow generation device, a storage medium and computer equipment, which are different from the prior art. According to the application, the cascade layers are divided along the radius by taking the center of the target object as the center of the circle, so that the cascade layers and the target object can be bound, and the consistency of each cascade layer in all directions can be maintained, so that the consistency is also provided when the simulation scene of each cascade layer is observed by taking the target object as the center, the viewing cones from different viewpoints can fall in the range of cascade layer rendering, the sharing of cascade shadows among different viewpoints is realized, and the flexibility and generalization are realized. When the geometric position of the target object is not changed or has small change, the cascade hierarchy is not required to be divided again and the cascade shadow is not required to be regenerated, and additional adjustment calculation is not required to be carried out on the view point, so that the consumption of corresponding calculation resources is reduced, the jitter of the shadow is avoided, the instantaneity, the high efficiency, the accuracy and the stability of the generation of the cascade shadow are improved, and the effectiveness and the reliability of scene simulation are improved.
Drawings
For a clearer description of embodiments of the application or of solutions in the prior art, the drawings that are necessary for the description of the embodiments or of the prior art will be briefly described, it being apparent that the drawings in the description below are only some embodiments of the application, from which, without the inventive effort, other drawings can be obtained for a person skilled in the art, in which:
Fig. 1 is a schematic diagram of a cascade shadow generated by a conventional cascade shadow generation method.
FIG. 2 is a schematic flow chart of an embodiment of a cascade shadow generation method according to the present application;
FIG. 3 is a schematic diagram of an embodiment of a cascade hierarchy divided by step 10 in the embodiment of FIG. 2;
FIG. 4 is a flow chart of an embodiment of step 20 in the embodiment of FIG. 2;
FIG. 5 is a schematic diagram of an embodiment of the minimum z value in the embodiment of FIG. 4;
FIG. 6 is a schematic view of an embodiment of the cone width of the embodiment of FIG. 4;
FIG. 7 is a flow chart of an embodiment of step 24 in the embodiment of FIG. 4;
FIG. 8 is a flow chart of an embodiment of step 30 in the embodiment of FIG. 2;
FIG. 9 is a schematic flow chart diagram of an alternative embodiment to the embodiment of FIG. 8;
FIG. 10 is a schematic diagram of a cascaded shadow generating apparatus according to an embodiment of the present application;
FIG. 11 is a schematic diagram illustrating the structure of an embodiment of a storage medium according to the present application;
Fig. 12 is a schematic structural diagram of an embodiment of a computer device provided by the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all embodiments of the application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
The terms "first," "second," "third," and the like in embodiments of the present application are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first", "a second", and "a third" may explicitly or implicitly include at least one such feature. In the description of the present application, the meaning of "plurality" means at least two, for example, two, three, etc., unless specifically defined otherwise. Furthermore, the terms "comprise" and "have," as well as any variations thereof, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
Referring to fig. 1, fig. 1 is a schematic diagram of generating cascade shadows by a conventional cascade shadow generation method.
The conventional cascade shadow generation method divides the view cone of the view point into a plurality of cascade layers according to a certain proportion, such as Near, middle and Far layers in fig. 1, each cascade layer corresponds to one sub view cone, each layer covers different depth ranges, relevant shadow maps are calculated according to the view angle of a light source, such as a dashed line frame covering different layers in fig. 1, so that different resolutions are provided for scenes Near and Far, higher resolutions are used for Near layers, detail definition is ensured, lower resolutions are used for Far layers, and calculation cost is reduced, so that influence of unreal factors such as perspective saw teeth on relevant simulation tasks can be reduced.
However, in the conventional cascade shadow generation method, depending on the parameters of the viewpoint, the far-near plane is determined by the parameters of the viewpoint so as to obtain the corresponding cascade hierarchy, for example, in an autopilot simulation scene, a user generally needs to simulate tens of different camera sensors at the same time, and determines the cone of view to perform hierarchy division by the parameters corresponding to the parameters of the different camera sensors, in these cases, the cascade hierarchy corresponding to the different camera sensors generally needs to be repeatedly divided, and repeated calculation and resource binding are performed in engineering, so that the calculation efficiency is extremely low. And because of different viewpoints, the cascade shadows need to be calculated and generated again when the pose of the target object changes or the viewpoint angle changes, cascade shadow sharing among viewpoints cannot be realized, flexibility and compatibility are lacked, and the traditional cascade shadow generating method is difficult to be suitable for simulation tasks with high requirements on real-time performance and accuracy of simulation environments, such as automatic driving simulation, line simulation, real-time visual simulation and the like.
The application provides a cascade shadow generation method, referring to fig. 2, fig. 2 is a flow chart of an embodiment of the cascade shadow generation method provided by the application, and the cascade shadow generation method comprises the following steps:
And 10, dividing the center of the target object as a circle center along a preset radius to form a plurality of cascade layers.
The target object is an object bound with the cascade shadow generated later, and the corresponding cascade shadow can be generated by carrying out region segmentation calculation on the position of the target object. In different simulation environments, the target object can be a host vehicle in an automatic driving simulation environment, a role in a game scene or a core building in building design simulation, and the subsequent cascade shadow generation taking the target object as the center can enable the target object to serve as a focus of vision and interaction, so that corresponding processing and optimization of the target object and the simulation scene close to the target object in the simulation environment are facilitated, and the sense of reality of the simulation environment is improved.
The preset radius is a distance extending outwards from the center of the circle, and can be preset according to the visual range of the viewpoint of the target object, the fineness requirement of the simulation environment, the requirement of related simulation tasks, the availability of computing resources and the like. Dividing the preset radius along the preset radius, namely segmenting the preset radius, wherein the areas formed by different segments around the circle center correspond to different cascading layers.
Referring to fig. 3, fig. 3 is a schematic structural diagram of an embodiment of a cascade hierarchy, and the cascade hierarchy is divided into three sections along a preset radius by taking the center of a target Object (Object) as a center, so as to obtain three cascade hierarchies Near, middle and Far, which are the cascade hierarchies closest to the target Object, the cascade hierarchies with the distance value being the Middle, and the cascade hierarchies at the farthest part. In fig. 3, the rounded isosceles trapezoid is a plane indication that a visual range of a certain view point on a target object corresponds to a viewing cone, and a preset radius corresponding to a cascade hierarchy in the scheme needs to cover the visual range of any view point on the target object, so that all view points can be calculated by using the same cascade hierarchy and a corresponding cascade shadow map, the shadow map does not need to be generated from view point to view point, and the corresponding calculation efficiency is improved.
It should be noted that, fig. 3 is only illustrative, and may be 2 cascade levels, 4 cascade levels or more, the preset radius may be a length value of hundred meters, a length value of kilometers, a length value of ten kilometers or a length value of hundred kilometers, and specific segments of the preset radius may be equidistant segments or non-equidistant segments, so long as the segments of the cascade levels with the target object as the center are all understandably within the protection scope of the scheme.
Optionally, the preset radius is not smaller than the distance from the viewpoint on the target object to the furthest point of the viewing cone corresponding to the viewpoint.
The viewpoint on the target object corresponds to the task requirement of the target object, and specifically can be a camera device on the host vehicle in an automatic driving simulation environment, a visual range of a role in a game scene, or an observation position of a user in building design simulation, and the like, and the furthest point of the viewing cone is the furthest point from the viewpoint and can be observed. By ensuring that the preset radius is not smaller than the distance from the viewpoint to the furthest point of the viewing cone, objects or scenes in all visible ranges can be properly divided into corresponding cascade hierarchies in the simulation environment from the viewpoint of the target object, so that the comprehensiveness and accuracy of shadow generation are ensured, the viewpoints have corresponding shadow coverage from different angles of the center of the target object, and cascade shadow sharing is realized among different viewpoints without carrying out parameter adjustment and calculation on the viewpoints one by one.
Optionally, the dividing along the preset radius forms a plurality of cascade hierarchies, including dividing the preset radius based on one of a linear division, a logarithmic division and a weighted mixed division to obtain a plurality of cascade hierarchies.
The linear division is a way of dividing the cascade hierarchy in an average way, for example, the peripheral area is divided into several areas of 0-100m, 100-200m, 200-300m and the like by taking the center of the target object as the center, the logarithmic division is used for dividing the rendering area of the cascade shadow by taking the distance between the far plane and the near plane as compared with the logarithmic value of the area where the cascade shadow is located, for example, the peripheral area is divided into several areas of 0-9m, 9-30m, 30-300m and the like by taking the center of the target object as the center, the weighted mixed division is used for carrying out weighted average on the linear division and the calculated division distance, the specific weight is selected according to specific tasks, for example, the distance of the linear division is weighted to be 2, the distance of the logarithmic division is weighted to be 1, the area range is obtained after the weighted mixed division to be 0-70m,70-143m,143-300m, the numerical value in the example is calculated by rounding, and the corresponding value can be determined in other rounding manners, such as rounding up, rounding down, rounding up and effective numerical retention and the like. The linear division is simple in calculation and uniform in viewing cone, but the visual effect is rough due to the fact that resolution is too low in the near part, the shadow fineness of the near part can be guaranteed to the greatest extent through the logarithmic division, and the shadow fineness of the far part is too rough due to the fact that the area is too large, and therefore the cascade hierarchy is obtained by means of weighted mixed division preferentially.
Through the determination mode of the cascade hierarchy, the cascade hierarchy and the cascade shadow generated subsequently can be bound with the target object, so that the generation of the subsequent cascade shadow is more attached to the actual position and the gesture of the target object, and the sense of reality and the dynamic effect of the shadow are enhanced. Under the division mode of the cascade hierarchy, different division hierarchies in the simulation environment are seen by any view point of a target object to have consistency in all directions, and the subsequent cascade shadows can be shared among different view points as long as the coverage of the view cones of all view points is achieved, so that continuity and consistency of the subsequently generated shadows under different view angles are improved, generation logic of the cascade shadows is simplified, repeated cascade hierarchy division and subsequently repeated cascade shadow generation are avoided, efficiency of the subsequent cascade shadow generation is facilitated, consumption of calculation resources is reduced, jitter of the shadows is avoided, instantaneity, high efficiency, accuracy and stability of the cascade shadow generation are improved, and effectiveness and reliability of scene simulation are improved.
And step 20, calculating the view cone range of each cascade layer under the view angle of the light source.
The cone of view at the viewing angle of a light source is the area of space that the light source is capable of illuminating and casting shadows. The light source can be sun, street lamp or indoor lamplight, and the position, direction and intensity of the light source determine the path and range of light propagation. The area required to be covered by the cascade shadows generated later can be determined through the view cone range, all view cone ranges corresponding to all view points on the target object can be ensured to be covered by the generated cascade shadows, the shadow of the environment seen by the view points can be determined through shadow mapping by the view cone ranges of all view points, and the authenticity and reliability of the corresponding simulation environment are improved.
Alternatively, referring to fig. 4, calculating the view cone range of each cascade level at the light source viewing angle may be performed as follows:
and 21, determining the outsourcing rectangles of each cascade level, and taking the outsourcing rectangles as corner points.
Step 22, calculating the minimum z value and the viewing cone width surrounding all the corner points from the light source view angle.
And step 23, determining an observation matrix and a projection matrix of the cascade hierarchy under the view angle of the light source based on the minimum z value and the view cone width.
Step 24, determining the view cone range of each cascade layer under the view angle of the light source based on the observation matrix and the projection matrix.
The outsourcing rectangle of each cascade level refers to a rectangle which can contain the cascade level and has the smallest area, wherein the outsourcing rectangle is also centrosymmetric because the cascade level is a centrosymmetric circle, and the center of the outsourcing rectangle coincides with the center of the cascade level. The method is characterized in that the method adopts the outsourcing rectangle with two adjacent sides respectively parallel or perpendicular to the moving advancing direction of the target object to carry out subsequent processing, the directionality of the outsourcing rectangle can be determined without additional calculation, the minimum area is ensured, and the uniqueness of the outsourcing rectangle can also be ensured. And taking four vertexes or more points on the edges of the outsourcing rectangle as corner points, and performing subsequent calculation.
The outsourcing rectangle can specifically refer to two cases illustrated in fig. 5 or fig. 6 under the two-dimensional view angle and the three-dimensional view angle, in the examples of fig. 5 and fig. 6, only the outsourcing rectangle of the nearest cascade level Near is made, in the process of executing the above steps, the outsourcing rectangle needs to be determined by other cascade levels, and since the determination of the outsourcing rectangle of each cascade level is similar to the cascade level Near, the description is omitted here.
The minimum z value is the minimum distance value from the light source to the outsourcing rectangle, referring to fig. 5, the minimum z value determines the initial depth of the view cone under the view angle of the light source, the distance between the corresponding cascade layer and the light source can be determined, and then whether the pixel points in the cascade layer are blocked can be judged based on the minimum z value. The width of the viewing cone is the width of the viewing cone covering all the corner points of the outsourcing rectangle under the light source viewing angle, and referring to fig. 6, the width of the viewing cone determines the width degree of the viewing cone under the light source viewing angle, and the scope of shadows which can be generated by cascading layers under the light source condition can be covered. The minimum z value and the view cone width can be determined according to the position, the orientation and the division condition of the cascade hierarchy of the light source.
It should be noted that the outer rectangle, the light source, and the corresponding minimum z value and the viewing cone width in fig. 5 and 6 are exemplary, and may be specifically obtained based on the relationship between different outer rectangles and the light source, for example, the light source may be directly above or obliquely above the outer rectangle, above the extension range of the outer rectangle, or above the extension range of the outer rectangle, where the viewing cone width obtained when the light source is directly above or obliquely above the outer rectangle is equal to the outer rectangle, and the minimum z value is the distance between the light source and the perpendicular line or the midline of the outer rectangle.
Based on the minimum z-value and the viewing cone width, a corresponding viewing Matrix (View Matrix) and projection Matrix (Projection Matrix) are obtained. Wherein the viewing matrix is used to define a transformation from the world coordinate system to a viewing coordinate system with the light source as a viewpoint, the viewing matrix typically contains the position, orientation and possibly rotation and scaling information of the light source. Under the light source visual angle, the observation matrix converts the light source into a visual point, and determines how to observe each level of the hierarchy and the outsourcing rectangle of the hierarchy when the light starts from the light source. The projection matrix then defines how three-dimensional points in the viewing coordinate system are mapped onto a two-dimensional plane, forming a projection of the view cone under the viewing angle of the light source.
In shadow mapping, by adjusting the viewing matrix, it is ensured that the viewing angle of the light source is correctly directed and the details of each cascade level are captured. The projection matrix can project the scene under the view angle of the light source onto a depth buffer area or a texture map, and then judges whether the object in the scene is in shadow or not through the depth buffer area or the texture map, the projection matrix determines which three-dimensional points can be cut off, which points can be contained on a final two-dimensional plane, and the points are represented by corresponding depth values, so that all details in the view cone range can be accurately mapped and reserved.
The obtained observation matrix determines the position of the viewing cone, the projection matrix determines the shape of the viewing cone, and six planes of the viewing cone corresponding to each cascade level, namely an upper plane, a lower plane, a left plane and a right plane formed by connecting the far plane and the near plane of the viewing cone, can be extracted according to the observation matrix and the projection matrix, so that the space region corresponding to the viewing cone can be determined, and the viewing cone range of each cascade level under the view angle of the light source can be accurately determined.
Alternatively, referring to fig. 7, determining the view cone range of each cascade level at the light source viewing angle based on the observation matrix and the projection matrix may be performed as follows:
Step 241, determining cone position information under the view angle of the light source based on the observation matrix.
Step 242, determining cone-of-view information at the viewing angle of the light source based on the projection matrix.
Step 243, determining the view cone range based on the view cone position information and the view cone shape information.
The viewing matrix relates to the position, orientation and possibly rotation information of the light source in the world coordinate system, by integrating this information into the viewing matrix, the central position of the viewing cone at the viewing angle of the light source and its orientation can be accurately calculated, so that the projection direction and extent of the shadow can be subsequently determined. The projection matrix includes the width and height of the field of view and the distance between the far and near planes of the viewing cone, which together determine the shape of the viewing cone. Therefore, the viewing cone position information can be obtained based on the observation matrix, the viewing cone shape information can be determined based on the projection matrix, and the viewing cone range can be determined according to the viewing cone position information and the viewing cone shape information.
By the method for calculating the view cone range, the obtained view cone range not only comprises all areas needing to be covered by the shadow, but also ensures that the generation of the shadow can accurately reflect the position, the direction, the intensity and other information of the light source, so that the range corresponding to all the view points on the target object in the subsequent shadow generation process can be effectively covered, and the reality and the reliability of the simulation environment are improved.
And 30, respectively performing scene rendering on each cascade hierarchy from the light source view angle based on the view cone range so as to generate cascade shadows.
The view cone range determines the area to be rendered, and only objects in the view cone range can perform corresponding shadow rendering so as to improve the rendering efficiency. Scene rendering from the light source perspective, namely simulating a real shadow effect on objects in the scene according to the information such as the position, the direction, the intensity and the like of the light source. The specific rendering mode can be Shadow Mapping (Shadow Mapping) rendering, or Shadow rendering technology based on screen space Shadow rendering technology (SCREEN SPACE Shadows) or Shadow rendering technology based on ray tracing (RAY TRACING), and the like, and rendering is performed according to specific task requirements and parameter indexes, so that cascading shadows capable of reflecting the simulation environment more truly and reliably are obtained.
Optionally, referring to fig. 8, based on the view cone range, scene rendering is performed on each cascade hierarchy from the light source perspective to generate cascade shadows, which may be performed as follows:
and step 31, determining cascade shadow coverage ranges corresponding to all cascade layers based on the view cone range.
And step 32, performing shadow mapping rendering on the scene in the cascade shadow generation range from the light source view angle to obtain the corresponding cascade shadow.
After the view cone range is obtained, the range which can be irradiated by the light source can be determined based on the view cone range, so that the corresponding cascade shadow coverage can be set, objects and the periphery of the objects in all the view cone range can be covered by the cascade shadow coverage, the subsequent rendering process is optimized, and the generated shadow map can be applicable to different parts of multiple viewpoints or scenes. If the shadow mapping obtained through calculation can cover the area corresponding to all view cones, the method means that the cascade shadows correspondingly generated at the cascade hierarchy can be applicable to the current cascade shadows to determine the corresponding simulation scene no matter where the cascade shadows are observed from the target object.
After the shadow coverage is obtained, corresponding shadow mapping rendering can be performed. Shadow map rendering relies on shadow mapping technology, shadow map is achieved by pre-calculating depth information of a scene under a light source view angle and storing the information in one or more shadow maps, when each frame is rendered, each pixel in the scene is projected from the view point view angle back to the light source view angle and compared with a depth value in the shadow map, if the depth value corresponding to the pixel position of the projected back light source view angle is greater than or equal to the depth value of the same position in the shadow map, the point is indicated to be between the time limit of the light source and the object of the scene, namely, the point is blocked by the object, and therefore the point is rendered into a shadow area, otherwise, if the depth value is smaller than the value in the shadow map, the point is indicated to be not blocked and should be normally displayed.
By respectively performing scene rendering on each level of hierarchy and applying the view cone range limitation, a series of cascade shadows with different levels of detail and coverage areas can be obtained, the shadows jointly form a shadow effect in the scene, and the quality and efficiency of shadow generation can be remarkably improved.
Optionally, referring to fig. 9, based on the view cone range, scene rendering is performed on each cascade hierarchy from the light source perspective to generate cascade shadows, and further including:
and 33, determining the cascade hierarchy to be tested based on the depth value of each pixel point in the cascade shadow coverage range.
And step 34, performing shadow test on the cascade hierarchy to be tested to determine the shielding degree of each pixel point in the cascade hierarchy to be tested.
And 35, adjusting the shadow value of the cascade shadow of the cascade hierarchy to be tested based on the shielded degree.
In the process of generating the cascade shadow, in order to further improve the reality and detail of the shadow, and in the rendering process, shadow tests can be simultaneously carried out on the cascade layers to obtain finer shadow effects corresponding to the cascade layers.
In this process, since the subsequent shadow test requires a certain amount of computing resources and there is a high precision requirement for the different simulation tasks, which is usually a part of the relevant area in the scene, it is usually not necessary to perform the entire shadow mapping. Therefore, a part of cascade hierarchy can be determined to be the cascade hierarchy to be tested to carry out corresponding shadow test. The smaller the cascade hierarchy rendering range is, the higher the definition is, and the more accurate the precision calculation is, so that the cascade hierarchy to be tested generally selects the smallest cascade hierarchy, i.e. the cascade hierarchy closest to the target object, for example, the cascade hierarchy Near in fig. 3, and the subsequent shadow test and the shadow value adjustment on the smallest cascade hierarchy can generally meet the requirements of the simulation tasks such as common autopilot simulation, game scene simulation, architectural design simulation and the like.
After the cascade hierarchy to be detected is determined, shadow test can be carried out on the hierarchy to be detected, namely, the depth value of each pixel point seen from the current viewpoint view angle is compared with the depth value of each pixel point in the cascade shadow coverage range from the light source, whether the corresponding point is blocked or not is judged, and the blocked degree of the corresponding point can be judged according to the surrounding pixel points, so that the shadow value of each pixel point can be regulated based on the blocked degree, and the accuracy and the authenticity of the cascade hierarchy for carrying out the shadow test are higher.
After the shielding degree of each pixel point is determined, the rendering of the cascade shadow can be finely adjusted according to the information. Specifically, for a pixel that is fully occluded, its shadow value may be set to a maximum, typically black, to indicate that these areas are fully in shadow, while for a pixel that is partially occluded, the shadow value may be reduced according to the extent to which it is occluded, to achieve a softening effect of the shadow. The processing mode not only improves the sense of reality of the shadow, but also enables the fusion of the shadow and the surrounding environment to be more natural.
By implementing the steps, cascading shadows with rich details and high realism can be generated. The shadows not only cover all objects in the view cone range, but also are accurately rendered and adjusted according to the position, the direction and the intensity of the light source and the shape and the position of the objects, so that cascading shadows are generated more accurately and truly, and the effectiveness and the reliability of scene simulation are improved.
Referring to fig. 10, fig. 10 is a schematic structural diagram of an embodiment of a cascade shadow generating apparatus according to the present application.
The cascade shadow generating device 40 comprises a dividing module 41 for dividing the center of a target object into a plurality of cascade layers along a preset radius, a calculating module 42 for calculating the view cone range of each cascade layer under the light source view angle, and a rendering module 43 for respectively rendering scenes of each cascade layer from the light source view angle based on the view cone range to generate cascade shadows.
Optionally, the preset radius is not smaller than the distance from the viewpoint on the target object to the furthest point of the viewing cone corresponding to the viewpoint.
Optionally, the dividing along the preset radius forms a plurality of cascade hierarchies, including dividing the preset radius based on one of a linear division, a logarithmic division and a weighted mixed division to obtain a plurality of cascade hierarchies.
Optionally, the calculation module 42 is specifically further configured to determine an outer rectangle of each cascade level, and use the outer rectangle as a corner point, calculate a minimum z value and a view cone width surrounding all corner points from the light source perspective, determine an observation matrix and a projection matrix of each cascade level at the light source perspective based on the minimum z value and the view cone width, and determine a view cone range of each cascade level at the light source perspective based on the observation matrix and the projection matrix.
Optionally, the calculation module 42 is specifically further configured to determine cone position information at the light source viewing angle based on the observation matrix, determine cone shape information at the light source viewing angle based on the projection matrix, and determine cone range based on the cone position information and the cone shape information.
Optionally, the rendering module 43 is specifically further configured to determine a cascade shadow coverage range corresponding to each cascade level based on the view cone range, and perform shadow mapping rendering on a scene in the cascade shadow generation range from the light source perspective, so as to obtain a corresponding cascade shadow.
Optionally, the rendering module 43 is specifically further configured to determine a cascade hierarchy to be tested based on depth values of pixels within a coverage range of the cascade shadow, perform a shadow test on the cascade hierarchy to be tested to determine a blocked degree of each pixel in the cascade hierarchy to be tested, and perform shadow value adjustment on the cascade shadow of the cascade hierarchy to be tested based on the blocked degree.
Since the embodiments of the device portion correspond to the embodiments of the method described above, the description and corresponding beneficial effects of the cascade shadow generating device 40 provided in the embodiment of the present invention may refer to the embodiments of the cascade shadow generating method described above, and this embodiment is not repeated herein.
Referring to fig. 11, fig. 11 is a schematic structural diagram of a storage medium according to an embodiment of the present application.
The storage medium 50 stores program data 51, which program data 51, when executed by a processor, implements a cascade shadow generation method as described in fig. 2 to 9.
The program data 51 is stored in a storage medium 50 and includes instructions for causing a network device (which may be a router, personal computer, server, etc.) or processor to perform all or part of the steps of the method according to various embodiments of the application.
Alternatively, the storage medium 50 may be a usb disk, a removable hard disk, a read-only memory (ROM), a random-access memory (RAM), a magnetic disk, or an optical disk, or other various media that can store the program data 51.
Referring to fig. 12, fig. 12 is a schematic structural diagram of a computer device according to an embodiment of the present application.
The computer device 60 comprises a processor 62 and a memory 61 connected to each other, the memory 61 storing a computer program which, when executed by the processor 62, implements a cascade shadow generation method as described in fig. 2 to 9. The memory 61 may include the storage medium 50, or may be other separately developed memory.
The application discloses a cascade shadow generation method, a cascade shadow generation device, a storage medium and computer equipment, which are different from the prior art. The cascade layers are divided along the radius by taking the center of the target object as the center of the circle, so that the cascade layers and the target object can be bound, and the consistency of each cascade layer in all directions can be maintained, so that the consistency is also realized when the simulation scene of each cascade layer is observed by taking the target object as the center, the viewing cones from different viewpoints can fall in the range of the cascade layer rendering, the sharing of cascade shadows among different viewpoints is realized, and the flexibility and generalization are realized. When the geometric position of the target object is not changed or has small change, the cascade hierarchy is not required to be divided again and the cascade shadow is not required to be regenerated, and additional adjustment calculation is not required to be carried out on the view point, so that the consumption of corresponding calculation resources is reduced, the jitter of the shadow is avoided, the instantaneity, the high efficiency, the accuracy and the stability of the generation of the cascade shadow are improved, and the effectiveness and the reliability of scene simulation are improved.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for cascade shadow generation apparatus embodiments, storage media, and computer device embodiments, since they are substantially similar to cascade shadow generation method embodiments, the description is relatively simple, and reference is made to the description of cascade shadow generation method embodiments in part.
The application is operational with numerous general purpose or special purpose computing system environments or configurations. Such as a personal computer, a server computer, a hand-held or portable device, a tablet device, a multiprocessor system, a microprocessor-based system, a set top box, a programmable consumer electronics, a network PC, a minicomputer, a mainframe computer, a distributed computing environment that includes any of the above systems or devices, and the like.
In the embodiments provided in the present application, it should be understood that the disclosed method, apparatus, storage medium, and computer device may be implemented in other manners. For example, the above-described device embodiments are merely illustrative, e.g., the division of the modules or units is merely a logical functional division, and there may be additional divisions when actually implemented, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted, or not performed.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The foregoing description is only illustrative of the present application and is not intended to limit the scope of the application, and all equivalent structures or equivalent processes or direct or indirect application in other related technical fields are included in the scope of the present application.

Claims (10)

1. A cascade shadow generation method, characterized in that the cascade shadow generation method comprises:
dividing the center of the target object as a circle center along a preset radius to form a plurality of cascade layers;
Calculating the view cone range of each cascade layer under the view angle of the light source;
And respectively performing scene rendering on each cascade hierarchy from the light source view angle based on the view cone range so as to generate cascade shadows.
2. The cascade shadow generation method of claim 1, wherein the calculating a view cone range for each of the cascade layers at a light source viewing angle comprises:
Determining an outsourcing rectangle of each cascade layer, and taking the outsourcing rectangle as a corner point;
Calculating a minimum z value and a view cone width surrounding all the angular points from the light source view angle, wherein the minimum z value is a minimum distance value from the light source to the outer packing rectangle, and the view cone width is a width of the outer packing rectangle under the light source view angle;
Determining an observation matrix and a projection matrix of the cascade hierarchy under the light source view angle based on the minimum z value and the cone width;
The view cone range of each cascade hierarchy at the light source viewing angle is determined based on the observation matrix and the projection matrix.
3. The cascade shadow generation method of claim 2, wherein the determining a view cone range for each of the cascade layers at the light source viewing angle based on the observation matrix and the projection matrix comprises:
determining cone position information under the light source visual angle based on the observation matrix;
determining cone-of-view information at the light source viewing angle based on the projection matrix;
the view cone range is determined based on the view cone position information and the view cone shape information.
4. The cascade shadow generation method according to claim 1, wherein the scene rendering is performed on each of the cascade layers from the light source perspective based on the view cone range to generate cascade shadows, respectively, comprising:
Determining cascade shadow coverage corresponding to each cascade hierarchy based on the view cone range;
And performing shadow mapping rendering on the scene in the cascade shadow generation range from the light source view angle to obtain the corresponding cascade shadow.
5. The cascade shadow generation method of claim 4, wherein the scene rendering is performed on each of the cascade hierarchies from the light source perspective based on the view cone range to generate cascade shadows, further comprising:
Determining a cascading hierarchy to be detected based on the depth value of each pixel point in the cascading shadow coverage area;
Shadow testing is conducted on the cascade hierarchy to be tested to determine the shielding degree of each pixel point in the cascade hierarchy to be tested;
and adjusting the shadow value of the cascade shadow of the cascade hierarchy to be tested based on the blocked degree.
6. The cascade shadow generation method according to claim 1, wherein the preset radius is not smaller than a distance from a viewpoint on the target object to a most distant point of a viewing cone corresponding to the viewpoint.
7. The cascade shadow generation method of claim 1, wherein the dividing along a preset radius forms a plurality of cascade hierarchies, comprising:
and dividing the preset radius based on one division mode of linear division, logarithmic division and weighted mixed division to obtain a plurality of cascade layers.
8. A cascading shadow generating apparatus, characterized in that the cascading shadow generating apparatus comprises:
the dividing module is used for dividing the center of the target object as a circle center along a preset radius to form a plurality of cascade layers;
The computing module is used for computing the view cone range of each cascade layer under the light source visual angle;
and the rendering module is used for respectively performing scene rendering on each cascade hierarchy from the light source view angle based on the view cone range so as to generate cascade shadows.
9. A storage medium having stored thereon program data, which when executed by a processor, implements the steps of the cascade shadow generation method of any of claims 1 to 7.
10. A computer device comprising a processor and a memory connected to each other, the memory storing a computer program, the processor implementing the steps of the cascade shadow generation method of any of claims 1 to 7 when executing the computer program.
CN202411072139.7A 2024-08-06 2024-08-06 Cascade shadow generation method, device, storage medium and computer equipment Pending CN119068105A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202411072139.7A CN119068105A (en) 2024-08-06 2024-08-06 Cascade shadow generation method, device, storage medium and computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202411072139.7A CN119068105A (en) 2024-08-06 2024-08-06 Cascade shadow generation method, device, storage medium and computer equipment

Publications (1)

Publication Number Publication Date
CN119068105A true CN119068105A (en) 2024-12-03

Family

ID=93631045

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202411072139.7A Pending CN119068105A (en) 2024-08-06 2024-08-06 Cascade shadow generation method, device, storage medium and computer equipment

Country Status (1)

Country Link
CN (1) CN119068105A (en)

Similar Documents

Publication Publication Date Title
US8243073B2 (en) Tree insertion depth adjustment based on view frustum and distance culling
JP5476138B2 (en) A method for updating acceleration data structures for ray tracing between frames based on changing field of view
US8619078B2 (en) Parallelized ray tracing
US8692825B2 (en) Parallelized streaming accelerated data structure generation
US7136081B2 (en) System and method of line sampling object scene information
US10699467B2 (en) Computer-graphics based on hierarchical ray casting
US10529117B2 (en) Systems and methods for rendering optical distortion effects
CN111968215A (en) Volume light rendering method and device, electronic equipment and storage medium
CN111968216A (en) Volume cloud shadow rendering method and device, electronic equipment and storage medium
US9208610B2 (en) Alternate scene representations for optimizing rendering of computer graphics
US10553012B2 (en) Systems and methods for rendering foveated effects
US20230230311A1 (en) Rendering Method and Apparatus, and Device
US10861218B2 (en) Methods and systems for volumetric reconstruction based on a confidence field
KR102537529B1 (en) Ray tracing apparatus and method
US8106906B1 (en) Optical system effects for computer graphics
KR20140000170A (en) Method for estimating the quantity of light received by a participating media, and corresponding device
CN117876572B (en) Illumination rendering method, device, equipment and storage medium
US20230090732A1 (en) System and method for real-time ray tracing in a 3d environment
CA2866589A1 (en) Method for representing a participating media in a scene and corresponding device
WO2025055518A1 (en) Virtual screen generation method and apparatus, electronic device, computer readable storage medium, and computer program product
WO2025044423A1 (en) Virtual-terrain rendering method and apparatus, and device, storage medium and program product
CN119068105A (en) Cascade shadow generation method, device, storage medium and computer equipment
CN117333598A (en) A 3D model rendering system and method based on digital scenes
JP2002526843A (en) Energy propagation modeling device
CN117368869B (en) Visualization method, device, equipment and medium for radar three-dimensional power range

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination