Model rendering method and apparatus, storage medium, and electronic device
By acquiring terrain height maps and calculating shadow information maps at multiple time points in the CSM cascaded shadow mapping technology, the problem of insufficient shadow accuracy at ultra-long viewing distances is solved, and more accurate shadow rendering effects are achieved, especially the shadow rendering effects of distant terrain and vegetation are clearer.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NETEASE (HANGZHOU) NETWORK CO LTD
- Filing Date
- 2022-10-18
- Publication Date
- 2026-06-05
AI Technical Summary
The existing CSM cascaded shadow mapping technology is not accurate enough when rendering terrain shadows at ultra-long view distances, which causes distant scene models to not receive shadow information and results in incorrect rendering effects, especially in the case of vegetation shining in backlit areas of the terrain.
By collecting terrain height maps of the target scene model, calculating terrain shadow information at multiple times and baking terrain shadow information maps at multiple times, and using interpolation to calculate shadow rendering data at the current rendering time, including terrain shadow boundary height, range and ray length, the limitations of shadow rendering accuracy and distance are solved.
It improves the accuracy of shadow rendering, avoids the problem of shadow rendering being too bright at ultra-long viewing distances, and ensures the accuracy of shadow rendering effects, especially the shadow rendering effect of distant terrain and vegetation is clearer.
Smart Images

Figure CN115591235B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer texture rendering, specifically to a model rendering method, a shadow rendering device, a storage medium, and an electronic device. Background Technology
[0002] Current games generally use CSM (Cascade Shadow Map) technology when rendering terrain shadows. Cascade shadow mapping uses a layered shadow map technique to achieve shadows in large scenes. The shadow map for nearby objects has high precision but a smaller coverage area, while the shadow map for distant objects has lower precision assigned to each object but a wider coverage area.
[0003] However, CSM shadow technology is limited by accuracy and distance, and it is insufficient when rendering terrain shadows at extremely long view distances. At the same time, the vegetation scattering calculation does not receive information from the backlit areas of the terrain, resulting in the problem of vegetation shining in the backlit areas of the terrain.
[0004] It should be noted that the information disclosed in the background section above is only used to enhance the understanding of the background of this disclosure, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention
[0005] The purpose of this disclosure is to provide a model rendering method, shadow rendering device, storage medium, and electronic device, aiming to solve the problem of incorrect rendering effects caused by insufficient model shadow accuracy at ultra-long viewing distances.
[0006] Other features and advantages of this disclosure will become apparent from the following detailed description, or may be learned in part by practice of this disclosure.
[0007] According to one aspect of the present disclosure, a model rendering method is provided, comprising: acquiring a terrain height map of a target scene model; calculating terrain shadow information at multiple time points based on the terrain height map to bake a terrain shadow information map at multiple time points; wherein the terrain shadow information includes terrain shadow boundary height, terrain shadow range, and terrain shadow ray length; reading the current rendering time and extracting two terrain shadow maps at adjacent time points corresponding to the current rendering time; performing interpolation calculation based on the extracted two terrain shadow maps at adjacent time points to obtain shadow rendering data of the target scene model at the current rendering time for rendering the target scene model.
[0008] According to some embodiments of this disclosure, based on the foregoing scheme, the step of calculating terrain shadow information based on the terrain height map to bake a terrain shadow information map at multiple times includes: calculating terrain shadow information based on the height information of each pixel in the terrain height map at a certain time; baking the terrain shadow information to generate the terrain shadow information map corresponding to that time based on the terrain shadow information; and traversing the terrain height map at each time to obtain the terrain shadow information map corresponding to each time.
[0009] According to some embodiments of this disclosure, based on the foregoing scheme, the step of calculating terrain shadow information based on the height information of each pixel in the terrain height map at a certain moment includes: determining the starting row of pixels in the terrain height map based on the solar ray; scanning each column of pixels row by row with the starting row as the starting position, and determining the x-axis of each pixel based on the angle of the solar ray and the height information of each pixel. i,j The corresponding shadow boundary points s i,j Where i and j are the coordinate values in the planar coordinate system, and i and j are integers; according to each of the aforementioned shadow boundary points s i,j The terrain shadow information is obtained.
[0010] According to some embodiments of this disclosure, based on the foregoing scheme, the step of scanning each column of pixels row by row with the starting row as the starting position is performed to determine the x-axis of each pixel based on the angle of the solar rays and the height information of each pixel. i,j The corresponding shadow boundary points s i,j This includes: for a single pixel x ij Get pixel x i-1,j The corresponding solar ray at that location; based on pixel x i-1,j The corresponding solar ray determines the pixel x. ij The initial shadow boundary point at the location, and based on pixel x ij Height information determines height point h i,j At elevation point h i,j When the height exceeds the height of the initial shadow boundary point, the height point h is... i,j As pixel x ij The corresponding shadow boundary point s i,j And based on the angle of the solar rays and the altitude point h i,j Update the solar rays; or at altitude point h i,j When the height does not exceed the height of the initial shadow boundary point, the initial shadow boundary point is taken as pixel x. ij The corresponding shadow boundary point s i,j .
[0011] According to some embodiments of this disclosure, based on the foregoing scheme, the step of determining the shadow boundary points s...i,j Obtaining the terrain shadow information includes: based on each of the shadow boundary points s i,j The height of the terrain shadow boundary line is obtained from the height information; based on each shadow boundary point s i,j The location information is used to obtain the terrain shadow range; and based on each shadow boundary point s i,j The length of the terrain shadow ray is calculated by connecting the solar rays.
[0012] According to some embodiments of this disclosure, based on the foregoing scheme, baking the terrain shadow information map at that moment based on the terrain shadow information includes: mapping the height of the terrain shadow boundary line in the terrain shadow information map in a first manner and storing it in the first color channel of the terrain shadow information map; storing the terrain shadow range in the terrain shadow information map in the second color channel of the terrain shadow information map; and mapping the length of the terrain shadow ray in the terrain shadow information map in a second manner and storing it in the third color channel of the terrain shadow information map.
[0013] According to some embodiments of this disclosure, based on the foregoing scheme, the method further includes: determining the plurality of times, wherein determining the plurality of times includes: configuring a sampling time interval; and determining the plurality of times according to a linear sampling period or a custom sampling period.
[0014] According to a second aspect of the present disclosure, a shadow rendering apparatus is provided, comprising: an acquisition module for acquiring a terrain height map of a target scene model; a baking module for calculating terrain shadow information at multiple times based on the terrain height map to bake a terrain shadow information map at multiple times; wherein the terrain shadow information includes terrain shadow boundary height, terrain shadow range, and terrain shadow ray length; a reading module for reading the current rendering time and extracting two terrain shadow maps at adjacent times corresponding to the current rendering time; and a rendering module for performing interpolation calculations based on the extracted two terrain shadow maps at adjacent times to obtain shadow rendering data of the target scene model at the current rendering time for rendering the target scene model.
[0015] According to a third aspect of the present disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the shadow rendering method as described in the above embodiments.
[0016] According to a fourth aspect of the present disclosure, an electronic device is provided, characterized in that it includes: one or more processors; and a storage device for storing one or more programs, which, when executed by the one or more processors, cause the one or more processors to implement the shadow rendering method as described in the above embodiments.
[0017] The exemplary embodiments disclosed herein may have some or all of the following beneficial effects:
[0018] In some embodiments of this disclosure, terrain shadow information, including the height of the terrain shadow boundary, the range of the terrain shadow, and the length of the terrain shadow ray, is calculated using the terrain height map of the model. This allows for the pre-baking of multiple terrain shadow information maps at different times. Consequently, during shadow rendering, two terrain shadow maps at adjacent times can be extracted and interpolated based on the current rendering time to obtain accurate shadow rendering data. Compared to traditional CSM cascaded shadow mapping technology, this method is not limited by the accuracy and distance of shadow rendering, avoids the problem of shadow rendering being too bright at ultra-long viewing distances, and improves the shadow rendering effect.
[0019] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0020] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure. It is obvious that the drawings described below are merely some embodiments of this disclosure, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort. In the drawings:
[0021] Figure 1 This diagram illustrates the rendering effect of a CSM shadow technique in the prior art.
[0022] Figure 2 This diagram illustrates the rendering effect of another CSM shadow technique in the prior art.
[0023] Figure 3 The illustration shows a flowchart of a model rendering method according to an exemplary embodiment of the present disclosure;
[0024] Figure 4 This schematically illustrates a terrain elevation map in an exemplary embodiment of the present disclosure;
[0025] Figure 5 A topographic map is schematically illustrated in an exemplary embodiment of this disclosure;
[0026] Figure 6 This schematically illustrates a line-by-line scan of a terrain elevation map in an exemplary embodiment of the present disclosure;
[0027] Figure 7 This schematically illustrates a topographic map scanned line by line in an exemplary embodiment of the present disclosure;
[0028] Figure 8 This schematic diagram illustrates a method for determining shadow boundary points in an exemplary embodiment of the present disclosure.
[0029] Figure 9 This schematic diagram illustrates the R-channel information of a terrain shadow map in an exemplary embodiment of the present disclosure;
[0030] Figure 10 This schematic diagram illustrates the G-channel information of a terrain shadow information map in an exemplary embodiment of the present disclosure;
[0031] Figure 11 This schematic diagram illustrates the B-channel information of a terrain shadow map in an exemplary embodiment of the present disclosure;
[0032] Figure 12 This schematic diagram illustrates a shadow information atlas obtained by a linear sampling period in an exemplary embodiment of the present disclosure.
[0033] Figure 13 This schematic diagram illustrates a shadow information atlas obtained by a custom sampling period in an exemplary embodiment of the present disclosure.
[0034] Figure 14 This schematic diagram illustrates the original terrain effect of a target scene model in an exemplary embodiment of the present disclosure;
[0035] Figure 15 This schematic diagram illustrates the effect of terrain shadow range in a sampled terrain shadow information map according to an exemplary embodiment of the present disclosure;
[0036] Figure 16 This schematic diagram illustrates the effect of the height of the terrain shadow boundary line in a sampled terrain shadow information map according to an exemplary embodiment of the present disclosure;
[0037] Figure 17 This schematic diagram illustrates the shadow rendering effect of an unsampled terrain shadow infographic in an exemplary embodiment of the present disclosure.
[0038] Figure 18 This schematic diagram illustrates the shadow rendering effect of a sampled terrain shadow information map in an exemplary embodiment of the present disclosure;
[0039] Figure 19This schematic diagram illustrates the shadow rendering effect of another unsampled terrain shadow infographic in an exemplary embodiment of the present disclosure;
[0040] Figure 20 This schematic diagram illustrates the shadow rendering effect of another sampled terrain shadow information map in an exemplary embodiment of the present disclosure;
[0041] Figure 21 This schematic diagram illustrates the composition of a model rendering apparatus according to an exemplary embodiment of the present disclosure;
[0042] Figure 22 This schematic diagram illustrates a computer-readable storage medium according to an exemplary embodiment of the present disclosure;
[0043] Figure 23 The schematic diagram illustrates the structure of a computer system of an electronic device according to an exemplary embodiment of the present disclosure. Detailed Implementation
[0044] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this disclosure will be more thorough and complete, and will fully convey the concept of the exemplary embodiments to those skilled in the art.
[0045] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this disclosure. However, those skilled in the art will recognize that the technical solutions of this disclosure can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this disclosure.
[0046] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.
[0047] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.
[0048] Existing games generally use CSM (Cascade Shadow Map) technology when rendering terrain shadows. The principle of CSM is to use layered shadow map technology to achieve shadows in a large scene. The shadow map in the near area has high precision and small coverage, while the shadow map in the far area is assigned to each object with low precision but wide coverage.
[0049] Therefore, due to limitations in accuracy and distance, CSM shadow technology is insufficient when rendering terrain shadows at extremely long view distances. Simultaneously, the vegetation scattering calculation fails to capture information from the backlit areas of the terrain, resulting in vegetation appearing bright in these areas.
[0050] Figure 1 This illustration schematically depicts the rendering effect of a CSM shadow technique in the prior art. (Reference) Figure 1 As shown, the closer an area is to the screen, the more obvious the shadow rendering result is. The farther an area is from the screen, the more the rendered shadow gradually disappears. In fact, the farthest cylinder has no shadow effect after rendering.
[0051] Figure 2 This illustration schematically shows the rendering effect of another CSM shadow technique in the prior art. (Reference) Figure 2 As shown, the vegetation on the distant, backlit terrain is outside the range of the cascaded shadow map and therefore does not cast shadows, resulting in a glowing effect that does not match reality.
[0052] Therefore, in order to address the problems existing in the prior art and solve the problem that insufficient shadow accuracy in ultra-long-distance rendering leads to the inability of distant scene models to receive shadow information and result in incorrect rendering effects, this disclosure provides a model rendering method that uses baking to record terrain shadow-related information and calculates this terrain shadow information map in real time, converting it into the information required for terrain shadow rendering for shadow rendering.
[0053] The implementation details of the technical solutions of the embodiments of this disclosure are described in detail below.
[0054] Figure 3 This illustration schematically shows a flowchart of a model rendering method according to an exemplary embodiment of the present disclosure. Figure 3 As shown, the model rendering method includes steps S1 to S4:
[0055] Step S1: Collect the terrain height map of the target scene model;
[0056] Step S2: Calculate terrain shadow information at multiple times based on the terrain height map to bake terrain shadow information maps at multiple times; wherein, the terrain shadow information includes the height of the terrain shadow boundary line, the terrain shadow range, and the length of the terrain shadow ray;
[0057] Step S3: Read the current rendering time and extract two terrain shadow maps at adjacent times corresponding to the current rendering time;
[0058] Step S4: Perform interpolation calculations based on two terrain shadow maps extracted at adjacent time points to obtain shadow rendering data of the target scene model at the current rendering time for rendering the target scene model.
[0059] The following will describe in more detail each step of the model rendering method in this example embodiment, with reference to the accompanying drawings and embodiments.
[0060] In step S1, a terrain height map of the target scene model is acquired;
[0061] Specifically, a terrain heightmap is used to store the height information of the terrain in a target scene model. Typically, the height of a terrain element is stored with a pixel precision of 1m or 0.5m. Taking the common game engine UE4 (Unreal Engine 4) as an example, its terrain rendering information can be stored as a 2D grayscale image. The position of each pixel in the grayscale image represents the position of each corresponding terrain element, and the grayscale information of each pixel represents the height information of that corresponding terrain element. We know that grayscale information ranges only from 0 to 1, but UE4, through algorithmic mapping, can make it represent terrain height information from -256m to 256m.
[0062] Figure 4 A terrain elevation map is schematically shown in an exemplary embodiment of this disclosure, with reference to... Figure 4 As shown, the whiter the color in the terrain elevation map, the higher the corresponding terrain; the darker the color in the terrain elevation map, the lower the corresponding terrain.
[0063] Figure 5 This illustration schematically depicts a topographic map in an exemplary embodiment of the present disclosure. Figure 5 According to Figure 4 The topographic map is generated from the elevation information in the topographic elevation map, for reference. Figure 5 As shown, the topographic map provides a very intuitive understanding of the terrain's elevation information.
[0064] In step S2, terrain shadow information at multiple times is calculated based on the terrain height map to bake terrain shadow information maps at multiple times; wherein, the terrain shadow information includes the height of the terrain shadow boundary line, the terrain shadow range, and the length of the terrain shadow ray.
[0065] Specifically, because the angle of illumination varies at different times, the shadows cast on the same terrain will also differ throughout the day. Therefore, in order to pre-bake terrain shadow maps for multiple times, it is necessary to calculate terrain shadow information for multiple times.
[0066] In one embodiment of this disclosure, the method further includes: determining the plurality of times, wherein determining the plurality of times includes: configuring a sampling time interval; and determining the plurality of times according to a linear sampling period or a custom sampling period.
[0067] The sampling time interval refers to the time during which shadows need to be rendered. Taking model rendering in a game scene as an example, if the game needs to render shadows from 6:00 to 18:00, then the sampling time interval is from 6:00 to 18:00, which means calculating the terrain shadow information at different times within the time interval of 6:00 to 18:00. If the game needs to render shadows 24 hours a day, then the sampling time interval is from 0:00 to 24:00, which means calculating the terrain shadow information at different times throughout the day.
[0068] After determining the sampling time interval, a sampling period needs to be established to identify specific times within that interval, thus baking the terrain shadow map. There are two baking methods: one is linear time baking. For example, a linear sampling period is configured, and sampling and calculation are performed according to this period, such as sampling one terrain shadow map per hour between 6 AM and 6 PM; the other is custom time baking, which considers the significant changes in ground shadows during sunrise and sunset, and therefore bakes more terrain shadow information maps during these times.
[0069] In one embodiment of this disclosure, step S2, which calculates terrain shadow information based on the terrain height map to bake a terrain shadow information map at multiple time points, includes:
[0070] Step 1: Calculate the terrain shadow information based on the height information of each pixel in the terrain height map at a certain moment;
[0071] Step 2: Baking the terrain shadow information map corresponding to that moment based on the terrain shadow information;
[0072] Step 3: Iterate through the terrain elevation maps at each time point to obtain the terrain shadow information map corresponding to each time point.
[0073] Specifically, in step one, calculating terrain shadow information based on the height information of each pixel in the terrain height map at a certain moment includes: determining the starting row of pixels in the terrain height map based on the solar ray; scanning each column of pixels row by row with the starting row as the starting position, to determine the x-axis of each pixel based on the angle of the solar ray and the height information of each pixel. i,j The corresponding shadow boundary points s i,j Where i and j are the coordinate values in the planar coordinate system, and i and j are integers; according to each of the aforementioned shadow boundary points s i,j The terrain shadow information is obtained.
[0074] First, the starting row of pixels in the terrain height map is determined based on the sun's rays. Since lighting is taken into account during model rendering, the first row of land parcels illuminated by the sun is determined based on the angle of sunlight, and the first row of pixels corresponding to these parcels in the terrain height map is used as the starting row.
[0075] Then, starting from the initial row, each column of pixels is scanned row by row to determine the shadow boundary point. Figure 6 This schematic diagram illustrates a line-by-line scan of a terrain elevation map in an exemplary embodiment of the present disclosure. Figure 7 This schematically illustrates a line-by-line scan of a topographic map according to an exemplary embodiment of the present disclosure. Figure 7 According to Figure 6 The terrain map is generated from the elevation information in the terrain elevation map, and is scanned line by line from the left side of the texture to the right.
[0076] refer to Figure 6 and Figure 7 As shown, the terrain height map includes multiple pixels x. i,j If the sunlight starts shining from the left, then the left side of the texture is the starting row, and the texture moves to the right in a total of i rows. The bottom of the texture is the starting column, and the texture moves upward in a total of j columns.
[0077] In one embodiment of this disclosure, the process involves scanning each column of pixels row by row, starting from the initial row, to determine the x-axis of each pixel based on the angle of the solar rays and the height information of each pixel. i,j The corresponding shadow boundary points s i,j This includes: for a single pixel x ij Get pixel x i-1,j The corresponding solar ray at that location; based on pixel x i-1,j The corresponding solar ray determines the pixel x. ij The initial shadow boundary point at the location, and based on pixel x ij Height information determines height point h i,j At elevation point hi,j When the height exceeds the height of the initial shadow boundary point, the height point h is... i,j As pixel x ij The corresponding shadow boundary point s i,j And based on the angle of the solar rays and the altitude point h i,j Update the solar rays; or at altitude point h i,j When the height does not exceed the height of the initial shadow boundary point, the initial shadow boundary point is taken as pixel x. ij The corresponding shadow boundary point s i,j .
[0078] Next, taking the j-th column pixel as an example, the shadow boundary point s is determined by scanning row by row. i,j A detailed explanation is provided with reference to the accompanying drawings.
[0079] Figure 8 This diagram schematically illustrates a method for determining shadow boundary points according to an exemplary embodiment of this disclosure. (Reference) Figure 8 As shown, for pixel x in the starting row 1,j Since there are no pixels in the previous row, the angle and height point h of the sun ray are used. 1,j Determine the solar ray R1 and the altitude point h. 1,j As pixel x 1,j The corresponding shadow boundary point s 1,j .
[0080] For pixel x in row 2 and column j 2,j On the one hand, get the previous row x 1,j The corresponding solar ray R1 is used to determine the initial shadow boundary point s'. 2,j On the other hand, the height point h is determined based on the height information of this pixel. 2,j ,refer to Figure 8 As shown, due to s' 2,j Higher than h 2,j , then s' 2,j As pixel x 2,j The corresponding shadow boundary point s 2,j .
[0081] The shadow boundary points corresponding to the pixels in the 3rd and 4th rows and the jth column are calculated in a similar way to those in the 2nd row and the jth column. The initial shadow boundary point is used as the final shadow boundary point, and the solar ray R1 also moves forward by two diagonal sides.
[0082] For pixel x in row 5 and column j 5,j ,from Figure 8 It can be intuitively seen that the initial shadow boundary point s' determined by the solar ray R1 is... 5,jIt must be lower than the height point h corresponding to that pixel. 5,j This means that the terrain is not illuminated by the sun, therefore the elevation point h is... 5,j As pixel x 5,j The corresponding shadow boundary point s 5,j At the same time, since the solar rays used to determine whether a terrain is illuminated must begin again from the highest point of the terrain, it is also necessary to consider the angle and altitude h of the solar rays. 5,j Determine the solar ray R2.
[0083] For pixel x in row 6 and column j 6,j The solar rays used for this determination are x 5,j The corresponding solar ray R2, the rest of the process is similar to before.
[0084] Based on the above method, the shadow boundary points corresponding to the pixels in the j-th column can be obtained by analogy. Then, by traversing all columns, the x-th pixel can be obtained. i,j The corresponding shadow boundary points s i,j .
[0085] Finally, based on each of the described shadow boundary points s i,j The terrain shadow information is obtained. Specifically, the terrain shadow information includes the height of the terrain shadow boundary line, the range of the terrain shadow, and the length of the terrain shadow ray.
[0086] Specifically, according to each of the aforementioned shadow boundary points s i,j The height of the terrain shadow boundary line is obtained from the height information; based on each shadow boundary point s i,j The location information is used to obtain the terrain shadow range; and based on each shadow boundary point s i,j The length of the terrain shadow ray is calculated by connecting the solar rays.
[0087] In step two, the terrain shadow information map corresponding to that moment is baked out based on the terrain shadow information.
[0088] In simple terms, baking a texture involves storing terrain shadow information in a texture map, which is then applied to the surface of an object as a normal texture. Therefore, the terrain shadow boundary height, terrain shadow extent, and terrain shadow ray length are stored in the three color channels of the terrain shadow information map, respectively.
[0089] In one embodiment of this disclosure, baking the terrain shadow information map at that moment based on the terrain shadow information includes: mapping the height of the terrain shadow boundary line in the terrain shadow information map in a first manner and storing it in the first color channel of the terrain shadow information map; storing the terrain shadow range in the terrain shadow information map in the second color channel of the terrain shadow information map; and mapping the length of the terrain shadow ray in the terrain shadow information map in a second manner and storing it in the third color channel of the terrain shadow information map.
[0090] Specifically, the height of the terrain shadow boundary line can be stored in the R channel, the terrain shadow range in the G channel, and the terrain shadow ray length in the B channel.
[0091] Because grayscale maps and previous terrain height maps share the same limitation—they can only store values within the range of 0 to 1—terrain shadow information is also remapped here. The terrain shadow boundary height, from -256m to 256m, is mapped to a range of 0 to 1; the terrain shadow range is either black or white and does not require remapping. Considering the overall texture pixel size of 2048×2048, the terrain shadow ray length, from 0m to 2048m, is mapped to a range of 0 to 1.
[0092] Figures 9 to 11 The terrain shadow information map is displayed in three color channels. Figure 9 This schematic diagram illustrates the R-channel information of a terrain shadow map in an exemplary embodiment of the present disclosure; Figure 10 This schematic diagram illustrates the G-channel information of a terrain shadow information map in an exemplary embodiment of the present disclosure; Figure 11 This schematically illustrates a B-channel information diagram of a terrain shadow information map in an exemplary embodiment of the present disclosure.
[0093] Step 3: Iterate through the terrain elevation maps at each time point to obtain the terrain shadow information map corresponding to each time point.
[0094] Specifically, steps one and two only calculate the terrain shadow data at a single moment to obtain the terrain shadow map at that moment. The calculation and sampling are performed at multiple moments to obtain the terrain shadow information map corresponding to each moment, and then baked into a large atlas.
[0095] Figure 12 This schematically illustrates a shadow information atlas obtained through a linear sampling period in an exemplary embodiment of this disclosure. One image is sampled per hour from 6 AM to 6 PM, resulting in 13 shadow information images. These images are then stitched together in an S-shape, starting from the rightmost image in the first row (with the first three images empty). Figure 12 The shadow infographic.
[0096] Figure 13 This schematically illustrates a shadow information atlas obtained through a custom sampling period in an exemplary embodiment of this disclosure. Taking sunrise and sunset into account, more terrain shadow information maps are baked at sunrise and sunset times, resulting in a total of 15 shadow information maps. These are then stitched together in an S-shape, starting from the rightmost image in the first row (the first image is empty), to obtain the atlas. Figure 12 The shadow infographic.
[0097] In step S3, the current rendering time is read, and two terrain shadow maps at adjacent times corresponding to the current rendering time are extracted.
[0098] Specifically, when it is necessary to render the target scene model, the current rendering time is obtained. The current rendering time is the time of day in which the target scene model is located, and then the shadow rendering data at that time is calculated. The shadow rendering data actually corresponds to the terrain shadow information corresponding to the sunlight at that time.
[0099] Since an atlas consisting of terrain shadow rendering maps corresponding to multiple time points has been pre-baked through steps S1 and S2, the atlas can be considered similar to the engine's terrain height. Figure 1 This sampling method yields two terrain shadow maps at adjacent times corresponding to the current rendering time. For example, if the current rendering time is 15:30, then two terrain shadow maps at 15:30 and 16:00, adjacent to 15:30, can be extracted.
[0100] Step S4: Perform interpolation calculations based on two terrain shadow maps extracted at adjacent time points to obtain shadow rendering data of the target scene model at the current rendering time for rendering the target scene model.
[0101] Specifically, the terrain shadow map stores terrain shadow information. The terrain shadow information corresponding to the current rendering time is calculated through interpolation and used as shadow rendering data. Finally, the shadow rendering data is visualized and rendered.
[0102] During model rendering, the terrain shadow boundary height in the terrain shadow information is remapped from -256m to 256m. By comparing the terrain shadow boundary height with the object's height, it is determined whether the object is hidden in the terrain shadow. The terrain shadow ray length can be used to calculate soft shadows. The longer the ray length, the farther the ray is from its origin, and this part should be blurred to create a soft shadow effect.
[0103] Figure 14 This schematic diagram illustrates the original terrain effect of a target scene model in an exemplary embodiment of the present disclosure; Figure 15This schematic diagram illustrates the effect of terrain shadow range in a sampled terrain shadow information map according to an exemplary embodiment of the present disclosure; Figure 16 This schematic diagram illustrates the effect of the height of the terrain shadow boundary line in a sampled terrain shadow information map according to an exemplary embodiment of the present disclosure.
[0104] The model rendering method disclosed herein can solve the problems of light leakage in vegetation in backlit areas of terrain, light leakage in volumetric fog, and lack of shadows in distant terrain. By sampling the terrain shadow information map, it can be converted into shadow rendering data in the scene, thereby solving the problem of rendering errors of distant objects.
[0105] For example, Figure 17 This schematic diagram illustrates the shadow rendering effect of an unsampled terrain shadow infographic in an exemplary embodiment of the present disclosure. Figure 18 This illustration schematically depicts the shadow rendering effect of a sampled terrain shadow infographic in an exemplary embodiment of this disclosure. (Reference) Figure 17 and Figure 18 The comparison clearly shows Figure 17 The unshown shadow in Figure 18 As shown in the image, the model's shadows are more precise, resulting in better rendering.
[0106] For example, Figure 19 This schematic diagram illustrates the shadow rendering effect of another unsampled terrain shadow infographic in an exemplary embodiment of the present disclosure. Figure 20 This schematically illustrates the shadow rendering effect of another sampled terrain shadow infographic in an exemplary embodiment of this disclosure. (Reference) Figure 19 and Figure 20 In comparison, the shadow rendering effect of the sampled terrain shadow information map is less affected by fog light and can clearly render the shadow of the mountain. Compared with ordinary model rendering methods, its rendering effect is better.
[0107] Figure 21 This schematic diagram illustrates the composition of a model rendering apparatus according to an exemplary embodiment of the present disclosure, such as... Figure 21 As shown, the model rendering device 2100 may include an acquisition module 2101, a baking module 2102, a reading module 2103, and a rendering module 2104. Wherein:
[0108] The acquisition module 2101 is used to acquire the terrain height map of the target scene model;
[0109] Baking module 2102 is used to calculate terrain shadow information at multiple times based on the terrain height map to bake terrain shadow information maps at multiple times; wherein, the terrain shadow information includes the height of the terrain shadow boundary line, the terrain shadow range, and the length of the terrain shadow ray;
[0110] The reading module 2103 is used to read the current rendering time and extract two terrain shadow maps at adjacent times corresponding to the current rendering time;
[0111] The rendering module 2104 is used to perform interpolation calculations based on two terrain shadow maps extracted at adjacent time points to obtain shadow rendering data of the target scene model at the current rendering time for rendering the target scene model.
[0112] According to an exemplary embodiment of the present disclosure, the baking module 2102 includes a calculation unit, a baking unit, and a traversal unit. The calculation unit is used to calculate terrain shadow information based on the height information of each pixel in the terrain height map at a certain time. The baking unit is used to bake out the terrain shadow information map corresponding to that time based on the terrain shadow information. The traversal unit is used to traverse the terrain height map at each time to obtain the terrain shadow information map corresponding to each time.
[0113] According to an exemplary embodiment of this disclosure, the computing unit is further configured to determine the starting row of pixels in the terrain height map based on solar rays; and to scan each column of pixels row by row, starting from the starting row, to determine the x-axis of each pixel based on the angle of the solar rays and the height information of each pixel. i,j The corresponding shadow boundary points s i,j Where i and j are the coordinate values in the planar coordinate system, and i and j are integers; according to each of the aforementioned shadow boundary points s i,j The terrain shadow information is obtained.
[0114] According to an exemplary embodiment of this disclosure, the computing unit is further configured to calculate a pixel x ij Get pixel x i-1,j The corresponding solar ray at that location; based on pixel x i-1,j The corresponding solar ray determines the pixel x. ij The initial shadow boundary point at the location, and based on pixel x ij Height information determines height point h i,j At elevation point h i,j When the height exceeds the height of the initial shadow boundary point, the height point h is... i,j As pixel x ij The corresponding shadow boundary point s i,j And based on the angle of the solar rays and the altitude point h i,j Update the solar rays; or at altitude point h i,j When the height does not exceed the height of the initial shadow boundary point, the initial shadow boundary point is taken as pixel x. ij The corresponding shadow boundary point si,j .
[0115] According to an exemplary embodiment of this disclosure, the calculation unit is further configured to calculate based on each of the shadow boundary points s i,j The height of the terrain shadow boundary line is obtained from the height information; based on each shadow boundary point s i,j The location information is used to obtain the terrain shadow range; and based on each shadow boundary point s i,j The length of the terrain shadow ray is calculated by connecting the solar rays.
[0116] According to an exemplary embodiment of this disclosure, the baking unit is further configured to map the height of the terrain shadow boundary line in the terrain shadow information map in a first manner and store it in a first color channel of the terrain shadow information map; store the terrain shadow range in the terrain shadow information map in a second color channel of the terrain shadow information map; and map the length of the terrain shadow ray in the terrain shadow information map in a second manner and store it in a third color channel of the terrain shadow information map.
[0117] According to an exemplary embodiment of the present disclosure, the model rendering apparatus 2100 further includes a time unit for configuring a sampling time interval and determining the plurality of times according to a linear sampling period or a custom sampling period.
[0118] The specific details of each module in the aforementioned model rendering device 2100 have been described in detail in the corresponding model rendering method, so they will not be repeated here.
[0119] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0120] In an exemplary embodiment of this disclosure, a storage medium capable of implementing the above-described method is also provided. Figure 22 This schematic diagram illustrates a computer-readable storage medium according to an exemplary embodiment of the present disclosure, such as... Figure 22As shown, a program product 2200 for implementing the above-described method according to an embodiment of the present disclosure is described. This product may employ a portable compact disc read-only memory (CD-ROM) and include program code, and may run on a terminal device, such as a mobile phone. However, the program product of the present disclosure is not limited thereto. In this document, the readable storage medium may be any tangible medium containing or storing a program that may be used by or in conjunction with an instruction execution system, apparatus, or device.
[0121] In an exemplary embodiment of this disclosure, an electronic device capable of implementing the above-described method is also provided. Figure 23 The schematic diagram illustrates the structure of a computer system of an electronic device according to an exemplary embodiment of the present disclosure.
[0122] It should be noted that, Figure 23 The computer system 2300 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments disclosed herein.
[0123] like Figure 23 As shown, the computer system 2300 includes a Central Processing Unit (CPU) 2301, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 2302 or programs loaded from storage section 2308 into Random Access Memory (RAM) 2303. The RAM 2303 also stores various programs and data required for system operation. The CPU 2301, ROM 2302, and RAM 2303 are interconnected via a bus 2304. An Input / Output (I / O) interface 2305 is also connected to the bus 2304.
[0124] The following components are connected to I / O interface 2305: an input section 2306 including a keyboard, mouse, etc.; an output section 2307 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and speakers, etc.; a storage section 2308 including a hard disk, etc.; and a communication section 2309 including a network interface card such as a LAN (Local Area Network) card, modem, etc. The communication section 2309 performs communication processing via a network such as the Internet. A drive 2310 is also connected to I / O interface 2305 as needed. Removable media 2311, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 2310 as needed so that computer programs read from them can be installed into storage section 2308 as needed.
[0125] In particular, according to embodiments of this disclosure, the processes described below with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 2309, and / or installed from removable medium 2311. When the computer program is executed by central processing unit (CPU) 2301, it performs various functions defined in the system of this disclosure.
[0126] It should be noted that the computer-readable medium shown in the embodiments of this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, etc., or any suitable combination thereof.
[0127] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this disclosure. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0128] The units described in the embodiments of this disclosure can be implemented in software or hardware, and the described units can also be located in a processor. The names of these units do not necessarily limit the unit itself.
[0129] In another aspect, this disclosure also provides a computer-readable medium, which may be included in the electronic device described in the above embodiments; or it may exist independently and not assembled into the electronic device. The computer-readable medium carries one or more programs that, when executed by the electronic device, cause the electronic device to perform the methods described in the above embodiments.
[0130] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to embodiments of this disclosure, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.
[0131] From the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the method according to the embodiments of this disclosure.
[0132] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein.
[0133] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A model rendering method, characterized in that, include: Collect terrain height maps of the target scene model; The starting row of pixels in the terrain elevation map is determined based on the solar rays at a certain moment; each column of pixels is scanned row by row starting from the starting row to determine the position of each pixel based on the angle of the solar rays and the height information of each pixel. x i,j The corresponding shadow boundaries s i,j ;in, i, j These are the coordinate values in the plane coordinate system. i, j The value is an integer; based on each of the described shaded boundary points. s i,j Obtain terrain shadow information; Based on the terrain shadow information, a terrain shadow information map corresponding to that moment is baked out; The terrain height map at each time point is traversed to obtain terrain shadow information maps corresponding to multiple time points; wherein, the terrain shadow information includes the height of the terrain shadow boundary line, the terrain shadow range, and the length of the terrain shadow ray; Read the current rendering time and extract two terrain shadow maps at adjacent times corresponding to the current rendering time; Interpolation calculations are performed based on two terrain shadow maps extracted at adjacent time points to obtain shadow rendering data of the target scene model at the current rendering time for rendering the target scene model.
2. The model rendering method according to claim 1, characterized in that, The process involves scanning each column of pixels row by row, starting from the initial row, to determine the position of each pixel based on the angle of the solar rays and the height information of each pixel. x i,j The corresponding shadow boundaries s i,j ,include: For a single pixel x ij Get pixels x i-1,j The corresponding solar rays at that location; Based on pixels x i-1,j The corresponding solar ray determines the pixel point. x ij The initial shadow boundary point at the location, and pixel-based... x ij Determine the altitude point based on altitude information h i,j ; At the altitude point h i,j When the height exceeds the height of the initial shadow boundary point, the height point will be... h i,j As pixels x ij Corresponding shadow boundary point s i,j And based on the angle of the solar rays and the altitude point h i,j Update the solar rays; or At the altitude point h i,j When the height does not exceed the height of the initial shadow boundary point, the initial shadow boundary point is taken as a pixel. x ij Corresponding shadow boundary point s i,j .
3. The model rendering method according to claim 1, characterized in that, According to each of the aforementioned shadow boundary points s i,j Obtaining the terrain shadow information includes: According to the aforementioned shadow boundary points s i,j The height of the terrain shadow boundary line is obtained from the height information; According to the aforementioned shadow boundary points s i,j The location information is used to obtain the terrain shadow range; and Based on each of the aforementioned shadow boundary points s i,j The length of the terrain shadow ray is calculated by connecting the solar rays.
4. The model rendering method according to claim 3, characterized in that, The process of baking the terrain shadow information map at that moment based on the terrain shadow information includes: The height of the terrain shadow boundary line in the terrain shadow information map is mapped in a first manner and then stored in the first color channel of the terrain shadow information map; The terrain shadow range in the terrain shadow information map is stored in the second color channel of the terrain shadow information map; and The terrain shadow ray length in the terrain shadow information map is mapped in a second manner and then stored in the third color channel of the terrain shadow information map.
5. The model rendering method according to claim 1, characterized in that, The method further includes: determining the plurality of times, wherein determining the plurality of times includes: Configure the sampling time interval; The multiple times are determined according to a linear sampling period or a custom sampling period.
6. A shadow rendering apparatus, characterized in that, include: The acquisition module is used to acquire terrain height maps of the target scene model; The baking module is used to determine the starting row of pixels in the terrain height map based on the solar rays at a certain moment; and to scan each column of pixels row by row starting from the starting row, so as to determine each pixel according to the angle of the solar rays and the height information of each pixel. x i,j The corresponding shadow boundaries s i,j ;in, i, j These are the coordinate values in the plane coordinate system. i, j The value is an integer; based on each of the described shaded boundary points. s i,j Obtain terrain shadow information; bake the terrain shadow information map corresponding to the current time based on the terrain shadow information; traverse the terrain height map at each time to obtain terrain shadow information maps corresponding to multiple times; wherein, the terrain shadow information includes the height of the terrain shadow boundary line, the terrain shadow range, and the length of the terrain shadow ray; The reading module is used to read the current rendering time and extract two terrain shadow maps at adjacent times corresponding to the current rendering time; The rendering module is used to perform interpolation calculations based on two terrain shadow maps extracted at adjacent time points to obtain shadow rendering data of the target scene model at the current rendering time for rendering the target scene model.
7. A computer-readable storage medium having a computer program stored thereon, the program being executed by a processor to implement the model rendering method as described in any one of claims 1 to 5.
8. An electronic device, characterized in that, include: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the model rendering method as described in any one of claims 1 to 5.