Shadow rendering method, game file packaging method and corresponding apparatus

By segmenting the game scene and using a shadow height map with video compression encoding, the problem of excessively large shadow rendering data in mobile games is solved, enabling high-quality real-time shadow effects to be rendered on low-performance devices.

CN114119854BActive Publication Date: 2025-10-24BEIJING ZITIAO NETWORK TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202111433293.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-29
Publication Date
2025-10-24
Estimated Expiration
2041-11-29

AI Technical Summary

Technical Problem

When porting open-world games from PC to mobile, the amount of data for shadow rendering was too large, resulting in severe lag. This was especially true for games with a Time of Observation (TOD) system, where the direction of light changes over time, requiring frequent switching of baked shadow data, which resulted in an unacceptable amount of data.

Method used

The game scene is divided into blocks, and the shadow height map of each terrain block at different time periods is pre-baked and video compressed and encoded to generate video data. During rendering, only the video frames of the target time period are extracted for shadow rendering, and redundant information from adjacent time periods is used for video compression to reduce the amount of data.

Benefits of technology

It enables the rendering of real-time shadow effects that change over time on low-performance mobile devices, while controlling the amount of data to avoid lag, and is suitable for mobile, PC and web games.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114119854B_ABST
    Figure CN114119854B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a shadow rendering method, a game file packaging method and corresponding devices, wherein the shadow rendering method comprises: determining a target period corresponding to an in-game time, obtaining video data corresponding to each target terrain block in a first field of view range of a camera in a game scene from a game file; extracting a video frame corresponding to the target period from the video data to obtain a shadow height map of the target terrain block in the target period; sampling a sampling value corresponding to each to-be-rendered terrain point from the shadow height map of the target period, and rendering a shadow of the to-be-rendered terrain point according to the sampling value. The present disclosure utilizes the characteristic that the shadow changes over time, and video compression encoding is performed on the shadow height map through a video compression encoding technology, so that a higher compression ratio can be obtained, and the data amount is greatly reduced.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of games, in particular to a shadow rendering method, a game file packaging method and corresponding devices. BACKGROUND

[0002] Shadows are quite important visual elements in game pictures, and the stereoscopic effect observed by human eyes largely depends on shadows. The mainstream shadow algorithm at present is Shadow Map algorithm, the main process of which is that a depth map is first rendered from the light source direction, and then when rendering the camera perspective, the occlusion relationship is obtained by comparing the depth value of the screen pixel in the light source coordinate system with the corresponding value in the depth map, so as to render the shadow. In the process of porting large world games to mobile terminals, this will bring considerable overhead. Therefore, a scheme of pre-baking depth data for real-time rendering during game running is generated.

[0003] However, such large world games often have a TOD (Time of Day) system, and the light direction will change over time, so data of different time periods needs to be baked. In order to reduce the sense of lag during time period switching, the granularity of the time period must be very small, which will lead to a hundred-fold increase in baked data, and in addition to the scale of the large world itself, the data volume is almost unacceptable. SUMMARY

[0004] This summary is provided to introduce a selection of concepts, which are further described below in the detailed description. This summary is not intended to identify key or essential features of the claimed subject matter, nor is it intended to be used to limit the scope of the claimed subject matter.

[0005] In a first aspect, the present disclosure provides a shadow rendering method, comprising:

[0006] determining a target time period corresponding to a time in a game, and obtaining video data corresponding to each target terrain block located within a first field of view range of a camera in a game scene from a game file; wherein the video data is obtained by video compression encoding all shadow height maps of the target terrain block at different time periods, and each sampling value corresponding to each terrain point on the target terrain block is stored in the shadow height map;

[0007] extracting a video frame corresponding to the target time period from the video data to obtain a shadow height map of the target terrain block at the target time period;

[0008] sampling a sampling value corresponding to each to-be-rendered terrain point from the shadow height map of the target time period, and rendering a shadow of the to-be-rendered terrain point according to the sampling value.

[0009] In a second aspect, the present disclosure provides a game file packaging method, comprising:

[0010] chunking a terrain in a game scene to obtain a plurality of terrain chunks;

[0011] According to the light source position corresponding to each time period, the highest height of each terrain point on each terrain chunk in the vertical direction of the time period in the shadow is calculated respectively, and the shadow height map corresponding to each time period of each terrain chunk is obtained;

[0012] Video compression encoding is performed on all shadow height maps of each terrain chunk in different time periods respectively, and the video data corresponding to each terrain chunk is obtained;

[0013] The video data corresponding to each terrain chunk is packaged into a game file.

[0014] In a third aspect, the present disclosure provides a shadow rendering device, comprising:

[0015] A video acquisition module is configured to determine a target time period corresponding to an in-game time, and acquire video data corresponding to each target terrain chunk located within a first field of view range of a camera in a game scene from a game file; wherein the video data is obtained by video compression encoding all shadow height maps of the target terrain chunk in different time periods, and the shadow height map stores a sampling value corresponding to each terrain point on the target terrain chunk;

[0016] A video decoding module is configured to extract a video frame corresponding to the target time period from the video data, and obtain a shadow height map of the target terrain chunk in the target time period;

[0017] A shadow rendering module is configured to sample a sampling value corresponding to each to-be-rendered terrain point from the shadow height map of the target time period, and render a shadow of the to-be-rendered terrain point according to the sampling value.

[0018] In a fourth aspect, the present disclosure provides a game file packaging device, comprising:

[0019] A terrain chunking module is configured to chunk a terrain in a game scene to obtain a plurality of terrain chunks;

[0020] A height map calculation module is configured to calculate the highest height of each terrain point on each terrain chunk in the vertical direction of each time period in the shadow according to the light source position corresponding to each time period, and obtain the shadow height map corresponding to each time period of each terrain chunk;

[0021] A video encoding module is configured to perform video compression encoding on all shadow height maps of each terrain chunk in different time periods respectively, and obtain the video data corresponding to each terrain chunk;

[0022] a video packaging module, configured to package the video data corresponding to each terrain block into the game file.

[0023] In a fifth aspect, the present disclosure provides a computer readable storage medium, having stored thereon a computer program, which, when executed by a processing apparatus, implements the steps of the method according to the first aspect or the second aspect.

[0024] In a sixth aspect, the present disclosure provides an electronic device, comprising:

[0025] a storage device having stored thereon a computer program;

[0026] a processing apparatus configured to execute the computer program in the storage device to implement the steps of the method according to the first aspect or the second aspect.

[0027] In the above technical solution, by dividing the game scene into blocks, pre-baking and video compression encoding the shadow height maps of each terrain block in different time periods, and encoding all the shadow height maps of each terrain block into video data, when rendering, only the video frame corresponding to the target time period needs to be extracted from the video data, and the shadow height map of the terrain block in the target time period can be obtained, and then the shadow of each terrain point to be rendered on the terrain block is rendered using the obtained shadow height map. The above process can render real-time shadows in the game picture that change over time. At the same time, the shadow height map data is pre-baked, and the data is video compression encoded using the redundant information between adjacent time periods, so that the data volume is not very large, and the method can be well applied to low-performance mobile devices.

[0028] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF DRAWINGS

[0029] The above and other features, advantages, and aspects of embodiments of the present disclosure will become more apparent by describing in detail the following specific embodiments thereof with reference to the attached drawings. The same or similar elements are denoted by the same or similar reference numerals throughout the drawings. It is to be understood that the drawings are schematic, and the original and elements are not necessarily drawn in proportion. In the drawings:

[0030] Figure 1 is a flowchart of a game file packaging method provided by an embodiment of the present disclosure;

[0031] Figure 2 is a detailed flowchart of step S120 in an embodiment of the present disclosure;

[0032] Figure 3 is a schematic diagram of searching for the highest height in the shadow in a preset height range in an embodiment of the present disclosure;

[0033] Figure 4is a flowchart of a shadow rendering method provided by an embodiment of the present disclosure;

[0034] Figure 5 is a detailed flowchart of step S230 in an embodiment of the present disclosure;

[0035] Figure 6 is a detailed flowchart of step S233 in an embodiment of the present disclosure;

[0036] Figure 7 is a function curve diagram of a preset interpolation function in an embodiment of the present disclosure;

[0037] Figure 8 is a block diagram of a shadow rendering device provided by an embodiment of the present disclosure;

[0038] Figure 9 is a block diagram of a game file packaging device provided by an embodiment of the present disclosure;

[0039] Figure 10 is a block diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0040] Embodiments of the present disclosure will be described in more detail by referring to the drawings. Although certain embodiments of the present disclosure are shown in the drawings, it is understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments set forth herein, but rather the embodiments are provided to more completely understand the present disclosure. It is understood that the drawings and embodiments of the present disclosure are for exemplary purposes only and are not intended to limit the scope of the present disclosure.

[0041] It should be understood that each step described in the method embodiments of the present disclosure can be executed in different orders and / or in parallel. In addition, the method embodiments can include additional steps and / or omit the execution of the steps shown. The scope of the present disclosure is not limited in this respect.

[0042] The term “comprising” and variations thereof as used herein are open-ended, that is, “including but not limited to”. The term “based on” is “based, at least in part, on”. The term “one embodiment” means “at least one embodiment”; the term “another embodiment” means “at least one additional embodiment”; the term “some embodiments” means “at least some embodiments”. Related definitions of other terms will be given in the description below.

[0043] It should be noted that the concepts of “first”, “second”, etc. mentioned in the present disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0044] It should be noted that the modification of "one", "multiple" mentioned in the present disclosure is illustrative but not restrictive, and those skilled in the art should understand that unless the context clearly indicates otherwise, it should be understood as "one or more".

[0045] The names of the messages or information exchanged between the plurality of devices in the embodiments of the present disclosure are only for illustrative purposes, and are not intended to limit the scope of the messages or information.

[0046] The traditional shadow map algorithm includes the following processes: 1) taking a light source as a viewpoint, drawing the entire game scene from the perspective of the light source, and saving the minimum depth value from the light source to the scene to obtain a depth map; 2) returning to the view with the camera as the viewpoint, drawing the scene from the perspective of the camera, and performing shadow judgment during drawing, that is, judging whether a certain pixel is in the shadow of the scene, if the pixel is not in the shadow, it is normally drawn, otherwise it is drawn as a shadow. To determine whether a certain point in the scene is in the shadow, the depth map obtained previously is used. For a certain point in the scene, first convert it to the space of the light source perspective to obtain the depth value of the point in the light source perspective, then compare it with the minimum depth value corresponding to the point in the shadow map, if the depth value of the point is greater than the corresponding minimum depth value, it means that the point is occluded, that is, the point is in the shadow, otherwise it means that the point is not in the shadow. Through the above judgment, the judgment result of "in the shadow" and "not in the shadow" of each point in the scene can be obtained, so as to render the shadow or not render the shadow.

[0047] In the case of a static scene, the step of calculating the shadow map can be used as a pre-computation part, that is, the depth map data used for shadow judgment is pre-baked for real-time rendering.

[0048] Such pre-baking scheme is basically for static lighting, such as the position of the light source (sun or moon) does not change, while for mobile terminal big world games with TOD system, there is a 24-hour time change in the game scene, and the light direction will change over time. In such a dynamic scene, the occlusion relationship in the scene will change with the change of light, and the pre-baked depth map data will no longer be used. Therefore, if such a pre-baking scheme is applied to such games, it is necessary to bake depth map data at different time periods, and in order to reduce the sense of lag during time period switching, the granularity of the time period must be very small, which will result in a hundred-fold increase in baked data, plus the size of the big world itself, the data volume is almost unacceptable.

[0049] To solve the above technical problems, the embodiment of the present disclosure provides a baking shadow scheme, including a game file packaging method and a shadow rendering method. When packaging the game file, the terrain of the game scene is divided into blocks, the shadow height map of each terrain block at different time periods is pre-baked and video compression encoded, and all the shadow height maps of each terrain block are encoded into video data. When performing shadow rendering, only the video frame corresponding to the current target time period needs to be extracted from the video data to obtain the shadow height map of the terrain block at the target time period, and then the shadow of each to-be-rendered terrain point on the terrain block can be rendered using the obtained shadow height map.

[0050] The embodiment of the present disclosure can realize real-time shadow rendering of game pictures changing over time on one hand, and on the other hand, the shadow height map data is pre-baked, and the data is video compression encoded using the redundant information between adjacent time periods, so that the data volume is not very large, and the scheme can be well applied to low-performance mobile terminal devices, and finally good shadow effect can be achieved. It should be noted that the scheme is particularly suitable for mobile terminal games, but it is also applicable to PC and web games.

[0051] Figure 1 A flowchart of a game file packaging method of the embodiment of the present disclosure is shown, which can be executed by an electronic device of a game maker. Please refer to Figure 1 The method includes the following steps:

[0052] S110, the terrain in the game scene is divided into blocks to obtain a plurality of terrain blocks.

[0053] S120, according to the light source position of each time period, the highest height of each terrain point on each terrain block in the vertical direction of the time period is calculated respectively to obtain the corresponding shadow height map of each terrain block at each time period.

[0054] Each terrain block corresponds to a shadow height map at each time period, which is obtained according to the highest height of each terrain point on the terrain block in the vertical direction of the time period, and the sampling value corresponding to each terrain point on the terrain block is stored in the shadow height map. For example, a day set by the TOD system is divided into multiple time periods, the highest height of each terrain point on each terrain block in the vertical direction of the corresponding time period in the game scene is calculated according to the light source position of each time period, and the corresponding shadow height map of each terrain block at the time period is obtained according to the highest height corresponding to each terrain point on the terrain block. For example, a day set by the TOD system is divided into 512 time periods, and 512 shadow height maps are obtained for each terrain block.

[0055] In one embodiment, after the highest height corresponding to each terrain point on the terrain block is calculated, a shadow height map corresponding to the terrain block is obtained according to the highest height, and each pixel in the shadow height map directly stores the value of the highest height of the corresponding terrain point, i.e., the sampling value is the highest height. For example, the game scene is divided into terrain blocks according to a unit of 512m*512m, each terrain block corresponds to a terrain of 512m*512m in the game scene, and there are 512*512 terrain points on the terrain block, each terrain point corresponds to a terrain of 1m*1m in the game scene. Meanwhile, the shadow height map is also represented by a 512*512 resolution map, and one pixel on the shadow height map corresponds to the highest height of a 1m*1m terrain point in the vertical direction in the period.

[0056] In yet another embodiment, after the highest height corresponding to each terrain point on the terrain block in the period is calculated, an ESM (Exponential Shadow Maps) operation is performed on the highest height, and a shadow height map corresponding to the terrain block is obtained according to the ESM operation result of each terrain point. Each pixel in the shadow height map stores the value of the ESM operation result of the highest height of the corresponding terrain point. The specific implementation of this embodiment is described below.

[0057] S130, respectively, video compression encoding is performed on all shadow height maps of each terrain block in different periods to obtain video data corresponding to each terrain block.

[0058] After the shadow height maps of each terrain block in each period are calculated, a plurality of shadow height maps in time sequence of each terrain block are obtained. Since the plurality of shadow height maps can be understood as a sequence of continuous images in time, and the moving speed of the shadow itself is very small and the shape changes slowly, there is a lot of redundant information between the shadow height maps of adjacent periods. By using the above characteristics, video compression encoding is performed on the plurality of shadow height maps corresponding to each terrain block, so that the plurality of shadow height maps are encoded into video data in the order of time change. Since the similarity between two adjacent frames in time in the plurality of shadow height maps is very high, by reducing part of the redundant information in the two adjacent shadow height maps, a compression ratio close to 1:500 can be achieved, greatly reducing the data amount. After video compression encoding, the file size of the obtained video data is only equivalent to that of one shadow height map.

[0059] Considering the quality of the game picture, in step S120, video compression encoding of 8 bits or more, such as 8 bits, 10 bits or 16 bits, is performed on the plurality of shadow height maps corresponding to each terrain block. In a specific embodiment, the x265 codec can be used for video compression encoding and decoding.

[0060] S140, pack the video data corresponding to each terrain block into the game file.

[0061] For example, the TOD system sets one day into 512 time periods, respectively calculates the shadow height map of each terrain block in each time period, obtains 512 shadow height maps corresponding to each terrain block, video compression encodes the 512 shadow height maps corresponding to each terrain block, encodes the 512 shadow height maps into one video data, and then packs the video data corresponding to all terrain blocks in the game scene into the game file. When the user (game player) downloads and installs the game file on the electronic device, and runs the game on the electronic device, the electronic device will render the shadow on the terrain block in the game picture according to the video data of each terrain block in the game file.

[0062] It is worth noting that the traditional shadow map algorithm bakes a depth map, which is obtained by rendering the scene from the direction of the light source. Since there is a certain inclination angle between the light source direction and the ground, the depth map is not necessarily the projection of the terrain directly above, and one pixel on the depth map may correspond to a larger area on the terrain, especially when the light source direction is more inclined, a larger area on the terrain in the distance will correspond to one pixel on the depth map, which will result in insufficient resolution of the shadow, thereby causing obvious sawtooth or defects when drawing the shadow.

[0063] In the embodiments of the present disclosure, the height map is baked, and each pixel in the height map stores the highest height of the corresponding terrain point in the vertical direction or a value further operated on the highest height. Obviously, the height map is the projection of the terrain block directly above, and can be completely one-to-one corresponding to the terrain block. If the size of one terrain point on the terrain block is 1m*1m, one pixel in the height map must correspond to a 1m*1m area of the terrain point on the terrain block. For the scene with severe light inclination such as morning or evening, the rendered shadow effect will be better than that of the traditional shadow map algorithm.

[0064] In an optional embodiment, Figure 2 A detailed flowchart of obtaining the shadow height map in step S120 in this embodiment is shown. Figure 2 Taking the calculation of the shadow height map of a certain terrain block as an example, step S120 includes:

[0065] S121, according to the light source position corresponding to each time period, respectively calculates the highest height of each terrain point on the terrain block in the vertical direction in the corresponding time period, and obtains an original height map.

[0066] According to the light source position of each time period, the highest height of each terrain point on the terrain block in the vertical direction of the corresponding time period in the shadow is calculated respectively, and the original height map is obtained according to the corresponding highest height of each terrain point.

[0067] It can be understood that in the game scene, the height of the terrain is limited, and the highest position is generally about 1000-2000m. In the process of calculating the highest height of each terrain point in the vertical direction of the corresponding time period in the shadow, each terrain point on the terrain block is traversed, and the height in the shadow is searched in the preset height range in the vertical direction of each terrain point according to the light source position of the time period, so as to obtain the corresponding highest height of each terrain point on the terrain block. Figure 3 A schematic diagram of searching the highest height in the shadow in the preset height range is shown. As an example, the highest height in the shadow is searched step by step upwards in the preset height range of 0-2000m in the vertical direction of the terrain point. It is assumed that there is a building nearby. In the process of step-by-step upward search, it is determined that the range of 0-50m in the vertical direction of the terrain point is blocked by the building, that is, in the shadow, and the height above is not in the shadow. Therefore, it can be determined that the highest height of the terrain point in the shadow is 50m.

[0068] It can be understood that the smaller the granularity of the time period division is, the position of the light source in the time period and the shadow generated on the terrain can be considered as unchanged, so the light source position at the starting time (or any time in the middle) of the time period can be taken as the light source position of the time period.

[0069] S122, the first exponential operation is performed on each highest height in the original height map respectively to convert the highest height to an exponential height, and an intermediate height map is obtained.

[0070] The first exponential operation is the first exponential function in the ESM algorithm.

[0071] The first exponential function is e c · h ; c is a constant coefficient, h is the highest height corresponding to the terrain point, and e c · h is the exponential height obtained by performing the first exponential operation on the highest height h. The intermediate height map stores the exponential height e c · h of each terrain point on the terrain block.

[0072] It should be noted that after obtaining the original height map, since the accuracy of the original height map is 1m*1m, which is equivalent to each pixel in the original height map corresponding to 1m*1m on the terrain block, if the traditional shadow map algorithm is used, the shadow judgment result obtained is only two results of "in shadow" and "not in shadow", and the finally rendered shadow will have a serious sawtooth feeling. In order to eliminate the sawtooth feeling of the shadow, the ESM algorithm is used to realize the soft shadow, so that the edge of the finally rendered shadow has a gradual change from the half shadow to the shadow, and the obtained edge is a soft transition, instead of a jagged shape.

[0073] S123, filtering the intermediate height map corresponding to each time period to obtain a shadow height map corresponding to each time period of the terrain block.

[0074] It can be understood that after filtering the exponential height in the intermediate height map, the first shadow attenuation calculated based on the filtered result in the subsequent process will further blur on the basis of the original soft shadow, so as to make the rendered shadow edge more soft and increase the reality of the shadow.

[0075] For example, a 4*4 size Gaussian kernel is used to perform Gaussian filtering on the intermediate height map.

[0076] In an embodiment, considering that the exponential height e c h may be a very large value, and when the exponential height in the intermediate height map is Gaussian filtered, the exponential heights in the 4*4 size range on the intermediate height map are weighted and averaged. In the case where the exponential height is already a large number, the weighted average may produce a larger number, which may cause the filtered value to exceed the range of floating point representation, resulting in floating point overflow. Therefore, the embodiment of the present disclosure proposes to convert the exponential height to logarithmic space to avoid the case of floating point overflow.

[0077] Hereinafter, taking filtering of an exponential height e in the intermediate height map as an example for description. If the exponential height is filtered according to the conventional Gaussian filtering method, the exponential height and the N exponential heights around it are weighted and averaged according to the following filtering formula w·f(h0):

[0078]

[0079] wherein, e0 is the exponential height currently filtered in the intermediate height map, e1 is the first exponential height among the other exponential heights participating in the current filtering, ​w0 is the filter weight corresponding to the current exponential height of the current filtering, w1 is the filter weight corresponding to the first exponential height, w2 is the filter weight corresponding to the second exponential height, and wN is the filter weight corresponding to the Nth exponential height. N w0 is the filter weight corresponding to the current exponential height of the current filtering, w1 is the filter weight corresponding to the first exponential height, w2 is the filter weight corresponding to the second exponential height, and wN is the filter weight corresponding to the Nth exponential height.

[0080] For example, assuming N = 2, the exponential height is filtered with the surrounding two exponential heights and .

[0081] Then w·f(h0) is equal to:

[0082]

[0083] In the embodiments of the present disclosure, according to the logarithmic basic property e lnp = p, the above formula can be transformed into:

[0084]

[0085] Further, the above example of filtering according to three exponential heights is extended to the case of filtering according to multiple exponential heights, and then:

[0086]

[0087] wherein, is the exponential height of the current filtering in the intermediate height map, N is the number of other exponential heights participating in the current filtering, is the ith exponential height of the N other exponential heights, c is a constant coefficient, w0 is the filter weight corresponding to the current exponential height of the current filtering, w1 is the filter weight corresponding to the first exponential height, w2 is the filter weight corresponding to the second exponential height, and wN is the filter weight corresponding to the Nth exponential height. i is the filter weight corresponding to the ith exponential height.

[0088] Therefore, in the process of filtering the intermediate height map in step S123, each exponential height in the intermediate height map is filtered as follows w·f(h0):

[0089]

[0090] Let According to the filtering result of each exponential height, a shadow height map is obtained, which stores the sampling value of each terrain point on the terrain block, and the sampling value is the exponential term u obtained by filtering the exponential height of the terrain point.

[0091] In the above process, when filtering, the superposition operation of multiple exponents is changed into an extraction of a common large multiplier factor The superposition of the exponential results is converted to logarithmic space, and the final shadow height map stores the logarithmic operation of the exponential term u, so the sampling value stored in the shadow height map will not exceed the range of floating-point representation, avoiding floating-point overflow.

[0092] Figure 4 A flowchart of a shadow rendering method provided by an embodiment of the present disclosure is shown, which can be executed by an electronic device of a user (a game player). Please refer to Figure 4 The method includes the following steps:

[0093] S210, determining a target period corresponding to the in-game time, and obtaining video data corresponding to each target terrain block located in the first field of view range of the camera in the game scene from the game file.

[0094] The electronic device of the user obtains and installs the game file (from the network or from the memory), and runs the corresponding game on the electronic device. When the game is running, a period corresponding to the current in-game time (denoted as a target period) is determined, and video data corresponding to each terrain block (denoted as a target terrain block) located in the first field of view range of the camera in the game scene is obtained from the game file. The video data is obtained by video compression encoding all shadow height maps of the target terrain block at different periods, and each shadow height map stores a sampling value of each terrain point on the corresponding target terrain block.

[0095] S220, extracting a video frame corresponding to the target period from each obtained video data to obtain a shadow height map of each target terrain block at the target period.

[0096] After obtaining the video data corresponding to each terrain block in the first field of view range of the camera, the shadow height map corresponding to the target period is decoded from each video data to obtain the shadow height map of each target terrain block at the target period.

[0097] S230, sampling a sampling value corresponding to each to-be-rendered terrain point from the shadow height map at the target period, and rendering a shadow of the to-be-rendered terrain point according to the sampling value.

[0098] In an optional embodiment, Figure 5 A detailed flowchart of the above step S230 is shown, as shown in Figure 5 Step S230 includes:

[0099] S231, copying the shadow height map of each target terrain block located in the first field of view range at the target period to a sampling height map.

[0100] When the game screen is rendered for the first time, the shadow height map of each target terrain block in the first field of view range is copied to the sampling height map respectively, and the sampling height map is the projection directly above each target terrain block in the first field of view range, that is, the shadow height map of the lower-left terrain block in the first field of view range corresponds to the lower-left position on the sampling height map. For example, each target terrain block corresponds to a 512m*512m terrain in the game scene, and the shadow height map of 512*512 pixels is used to represent the target terrain block.

[0101] For example, the sampling height map is an image of 2048*2048 pixels, and 4*4 shadow height maps of 512*512 pixels can be copied to the sampling height map.

[0102] When the camera movement is detected, for example, the camera moves 512m upwards, the eliminated terrain block (that is, the terrain block that disappears in the first field of view range) and the newly appeared terrain block (that is, the terrain block that newly appears in the first field of view range) will be generated with the camera movement. The conventional method of updating the sampling height map is to delete the shadow height map of the eliminated terrain block from the sampling height map, and then copy the data on the sampling height map row by row downwards, such as copying the pixels originally in the 513th row to the 1st row, copying the pixels originally in the 514th row to the 2nd row, and copying the pixels originally in the 515th row to the 3rd row. After copying row by row, the shadow height map of the newly appeared terrain block is copied to the topmost position vacated in the sampling height map.

[0103] In this way, the effective content of the actual copying is only the data of the newly appeared terrain block in the first field of view range, and the copying of the pixels of several rows is wasted. In order to avoid unnecessary copying operations, in the embodiment of the present disclosure, after the eliminated terrain block and the newly appeared terrain block in the first field of view range generated with the camera movement are determined, the shadow height map corresponding to the eliminated terrain block in the sampling height map is deleted, the shadow height map corresponding to the remaining terrain block in the sampling height map is kept unchanged, and the shadow height map corresponding to the newly appeared terrain block is copied to the position corresponding to the shadow height map of the eliminated terrain block.

[0104] In this way, when the game character in the game walks forward or in any direction, the camera moves with the game character, and the sampling height map may only update part of the pixel data each time, without copying the entire sampling height map, thereby maximizing the reuse of the previously copied data, minimizing the update of the sampling height map each time, and reducing the operation pressure of the mobile terminal device.

[0105] S232, determine the sampling position of each to-be-rendered terrain point on the sampling height map.

[0106] The sampling position can be used to determine which pixel on the sampling height map the sampling value corresponding to the to-be-rendered terrain point is located on, so that the sampling value corresponding to the to-be-rendered terrain point can be sampled from the sampling height map.

[0107] S233, sampling a sampling value at a corresponding position on the sampling height map according to the sampling position, and rendering a corresponding shadow according to the sampling value corresponding to each to-be-rendered terrain point.

[0108] In an embodiment, a pixel on the shadow height map directly stores the highest height of a corresponding terrain point on the target terrain block in the vertical direction of the target time period in the shadow, and then the highest height stored by the pixel at the corresponding position on the sampling height map can be sampled according to the sampling position, and a corresponding shadow can be rendered according to the highest height.

[0109] In another embodiment, each pixel on the shadow height map stores an exponential term u obtained by sequentially performing a first exponential operation and a filtering operation on the highest height of a corresponding terrain point on the target terrain block, and then a sampling value u stored by a pixel at a corresponding position on the sampling height map can be sampled according to the sampling position, and a corresponding shadow can be rendered according to the sampling value u. In this embodiment, the specific generation method of the shadow height map is described in the steps S121-S123 of the foregoing embodiment.

[0110] In this embodiment, Figure 6 A detailed flowchart of step S233 is shown in FIG. 6. Figure 6 As shown in FIG. 6, step S233 includes:

[0111] S2331, obtaining a sampling value at a corresponding position on the sampling height map according to the sampling position corresponding to the to-be-rendered terrain point, and calculating a first target exponential height according to the sampling value.

[0112] First, a sampling value at a corresponding position on the sampling height map is obtained according to the sampling position corresponding to the to-be-rendered terrain point Then, a filtering result is restored according to the sampling value w·f(h0) is the first target exponential height.

[0113] S2332, obtaining a world height of the to-be-rendered terrain point in the game scene.

[0114] S2333, performing a second exponential operation on the world height to obtain a second target exponential height.

[0115] The second exponential operation is a second exponential function in the ESM algorithm.

[0116] The second exponential function is e- c · d; c is a constant coefficient, d is the world height of the terrain point to be rendered in the game scene, e- c d is a second target exponential height calculated according to the world height d of the terrain point to be rendered.

[0117] S2334, multiplying the first target exponential height and the second target exponential height to obtain the first shadow attenuation corresponding to the terrain point to be rendered.

[0118] S2334, multiplying the first target exponential height and the second target exponential height to obtain the first shadow attenuation corresponding to the terrain point to be rendered.

[0119]

[0120] Wherein, the first shadow attenuation represents the degree of the terrain point to be rendered being in the shadow at this time.

[0121] S2335, rendering the shadow of the terrain point to be rendered according to the first shadow attenuation.

[0122] Wherein, in step S2335, the original shading information of the terrain point to be rendered is calculated according to the light source position of the target period and the material information of the terrain point to be rendered, then the shadow shading information is obtained according to the first shadow attenuation and the original shading information, and finally the shadow of the terrain point to be rendered is rendered according to the shadow shading information.

[0123] In an embodiment, the original shading information of the terrain point to be rendered is first calculated, and then the first shadow attenuation is applied to the original shading information, so that the corresponding degree of darkening is performed according to the first shadow attenuation on the basis of the original shading, to obtain the shadow shading information, and finally the color of the obtained shadow shading information is rendered on the terrain point to be rendered, to obtain the corresponding shadow.

[0124] In still another embodiment, the shadow rendering method in the embodiment of the present disclosure can be combined with the shadow map algorithm at the same time, so the method further includes: obtaining a shadow depth map in a second field of view range of the camera through the shadow map algorithm; sampling the shadow depth value corresponding to the terrain point to be rendered from the shadow depth map; and calculating the second shadow attenuation corresponding to the terrain point to be rendered according to the shadow depth value.

[0125] It should be noted that the second field of view range is located within the first field of view range.

[0126] ​For example, the first field of view range is a 1Km*1Km range formed with the camera as the center, and the second field of view range is a 200m*200m range formed with the camera as the center.

[0127] Therefore, the step of obtaining the shadow coloring information according to the first shadow attenuation and the original coloring information includes: determining the weight information corresponding to the to-be-rendered terrain point according to a preset interpolation function; performing weighted calculation on the first shadow attenuation and the second shadow attenuation according to the weight information to obtain a target shadow attenuation; and applying the target shadow attenuation to the original coloring information to obtain the shadow coloring information.

[0128] It can be understood that in the embodiments of the present disclosure, the shadow height map stores height information of a terrain point in a shadow, but in some special scenarios, this height information is not completely physically correct, and in order to avoid shadow calculation errors, a shadow map algorithm is used for complementation. The shadow map algorithm is to determine the degree of a terrain point in a shadow according to the minimum depth value of the light source view angle and render the shadow by using a soft shadow algorithm, so that the second shadow attenuation of the to-be-rendered terrain point is obtained. Then, linear interpolation is performed on the first shadow attenuation and the second shadow attenuation as the actual shadow attenuation to render the final shadow effect.

[0129] In the embodiments of the present disclosure, the preset interpolation function is constructed as:

[0130] If x is less than min, the first weight is returned as 0;

[0131] If x is greater than max, the first weight is returned as 1;

[0132] If x is in [min, max], the first weight is returned as a value greater than 0 and less than 1;

[0133] Wherein, x is the distance between the to-be-rendered terrain point and the camera in the length direction, and min

[0134] In the embodiments of the present disclosure, the first weight is determined according to the position of the to-be-rendered terrain point and the preset interpolation function, and then the second weight is calculated according to the first weight. The first weight is the weight corresponding to the first shadow attenuation, and the second weight is the weight corresponding to the second shadow attenuation.

[0135] It should be noted that in the embodiment of the present disclosure, the method further comprises: configuring the sampling mode of the shadow depth map as: when the position sampled from the shadow depth map is out of the second field of view range represented by the shadow depth map, sampling from the position closest to the sampled position. In the embodiment, the range represented by the shadow depth map is 200m*200m, and when the position of the terrain point to be rendered is out of the range of 200m*200m, the minimum depth value of the outermost circle of the shadow depth map will be sampled.

[0136] For example, the first field of view range is a 1Km*1Km range centered on the camera (i.e. a rectangular range of 1Km*1Km around the game character), and the second field of view range is a 200m*200m range centered on the camera (i.e. a rectangular range of 200m*200m around the game character). Figure 7 The function curve diagram of the preset interpolation function in this exemplary embodiment is shown, wherein the X-axis represents the value of x, and the vertical axis represents the value of the first weight. As shown in the figure, Figure 7 When x<180m, the first weight of the first shadow attenuation is 0, and the second weight of the second shadow attenuation is 1. In terms of effect, the entire 180m*180m range is the shadow effect of the shadow map algorithm. When x∈[180,200], the first shadow attenuation and the second shadow attenuation are linearly interpolated. In terms of effect, the range from 180m*180m to 200m*200m is a smooth superposition of the shadow map algorithm and the baked shadow provided by the embodiment of the present disclosure, forming a transition zone. When x∈(200,1000], the first weight of the first shadow attenuation is 1, and the second weight of the second shadow attenuation is 0. In terms of effect, the range from 200m*200m to 1Km*1Km is the shadow effect of the baked shadow in the embodiment of the present disclosure.

[0137] It can be understood that by adjusting the preset interpolation function, the value of the first weight and the second weight can be controlled, as well as the range of the transition zone between the two shadow effects.

[0138] In addition, Figure 7 The function curve diagram shown is only one example and does not represent a limitation on the preset interpolation function. For example, the curve part of x∈[min,max] in the preset interpolation function can also be in other forms, such as a straight line.

[0139] In an example, a high tower is arranged in a game scene, the high tower is in a shape of large at top and small at bottom, in the process of calculating the highest height of each terrain point in the vertical direction which is in the shadow, the height of each terrain point in the vertical direction which is in the shadow is searched based on the highest position of the high tower in a preset height range of the vertical direction of each terrain point, but the lower half of the high tower can be only a very thin stone column, in the real situation, light will pass through the lower half of the high tower and irradiate on the terrain point, but according to the shadow height map, it is wrongly considered that the terrain point is in the shadow, so the baking shadow provided by the embodiment of the present disclosure cannot achieve the completely correct effect for this kind of special scene. By linearly interpolating the first shadow attenuation of the baking shadow and the second shadow attenuation of the shadow map algorithm, the above shortcomings can be made up.

[0140] In this way, for the terrain close to the light source (such as x < 180m), even if it is wrongly considered that the terrain point is in the shadow according to the shadow height map in the embodiment of the present disclosure, but from the perspective of the light source, light will irradiate on the terrain point after passing through the lower part of the high tower, so according to the shadow depth map, it is determined that the terrain point is not in the shadow. Since the second weight obtained according to the preset interpolation function is 1 at this time, the rendered shadow effect is that the terrain point is not in the shadow, and the rendered effect is consistent with the real light irradiation, thereby enhancing the correctness and reliability of the shadow effect of the embodiment of the present disclosure. For the terrain far away from the light source (such as x > 200m), the small flaw can be ignored in the whole picture and will not affect the picture. Therefore, the baking shadow provided by the embodiment of the present disclosure can be mainly used to render the middle and far view shadow.

[0141] In addition, when the shadow map algorithm is used, the larger the field of view range of the shadow depth map is, the higher the accuracy requirement of the shadow depth map is, and the greater the performance consumption will be, so the shadow depth map is limited in a small range (such as the second field of view range of 200m*200m) to render the shadow of the close view, and the shadow of a farther range is rendered according to the baking shadow with lower performance consumption, thereby making up for the deficiency of the baking shadow for the close view and reducing the performance consumption of the shadow map algorithm.

[0142] In summary, the embodiment of the present disclosure applies the offline baking technology to the TOD large world game of the mobile terminal, and good shadow effect can be obtained on the low-performance device, and meanwhile, by using the characteristic that the shadow changes over time, the video compression and coding technology is introduced, a compression ratio of up to 1:500 or more can be obtained, the data amount is greatly reduced, and it becomes possible to apply the offline baking to the mobile terminal large-scale open world game.

[0143] The embodiment of the present disclosure also provides a shadow rendering device, please refer to Figure 8 The shadow rendering device 300 comprises:

[0144] The video acquisition module 310 is configured to determine a target period corresponding to the in-game time, and acquire video data corresponding to each target terrain block in the game scene within the first field of view of the camera from a game file; wherein the video data is obtained by video compression encoding of all shadow height maps of the target terrain block at different periods, and each terrain point on the target terrain block corresponds to a sampling value stored in the shadow height map.

[0145] The video decoding module 320 is configured to extract a video frame corresponding to the target period from the video data, and obtain a shadow height map of the target terrain block at the target period.

[0146] The shadow rendering module 330 is configured to sample a sampling value corresponding to each to-be-rendered terrain point from the shadow height map of the target period, and render a shadow of the to-be-rendered terrain point according to the sampling value.

[0147] Optionally, the shadow rendering module 330 comprises:

[0148] The copying sub-module is configured to copy the shadow height map of each target terrain block within the first field of view at the target period to a sampling height map.

[0149] The position determination sub-module is configured to determine a sampling position of each to-be-rendered terrain point on the sampling height map.

[0150] The shadow rendering sub-module is configured to sample a sampling value at a corresponding position from the sampling height map according to the sampling position, and render a corresponding shadow according to the sampling value corresponding to each to-be-rendered terrain point.

[0151] Optionally, the shadow rendering sub-module comprises:

[0152] The first target exponential height acquisition unit is configured to acquire a sampling value at a corresponding position from the sampling height map according to the sampling position corresponding to the to-be-rendered terrain point, and calculate a first target exponential height according to the sampling value.

[0153] The second target exponential height acquisition unit is configured to acquire a world height of the to-be-rendered terrain point in the game scene, and perform a second exponential operation on the world height to obtain a second target exponential height.

[0154] The first shadow attenuation calculation unit is configured to multiply the first target exponential height and the second target exponential height to obtain a first shadow attenuation corresponding to the to-be-rendered terrain point.

[0155] The shadow rendering unit is configured to render a shadow of the to-be-rendered terrain point according to the first shadow attenuation.

[0156] Optionally, the shadow rendering unit is configured to:

[0157] calculate original shading information of the terrain point to be rendered according to the light source position of the target time period and material information of the terrain point to be rendered;

[0158] obtain shadow shading information according to the first shadow attenuation and the original shading information;

[0159] render a shadow of the terrain point to be rendered according to the shadow shading information.

[0160] Optionally, the device further comprises a second shadow attenuation calculation module configured to: obtain a shadow depth map in a second field of view range of the camera by a shadow map algorithm; wherein the second field of view range is located within the first field of view range; sample a shadow depth value corresponding to the terrain point to be rendered from the shadow depth map; and calculate a second shadow attenuation corresponding to the terrain point to be rendered according to the shadow depth value. The shadow rendering unit is configured to:

[0161] determine weight information corresponding to the terrain point to be rendered according to a preset interpolation function;

[0162] perform weighted calculation on the first shadow attenuation and the second shadow attenuation according to the weight information to obtain a target shadow attenuation;

[0163] apply the target shadow attenuation to the original shading information to obtain the shadow shading information.

[0164] Optionally, the first field of view range is a range with a length of M and a width of N formed with the camera as a center, the second field of view range is a range with a length of M' and a width of N' formed with the camera as a center, and M' < M and N' < N; and the preset interpolation function is constructed as:

[0165] if x is less than min, return a first weight value of 0;

[0166] if x is greater than max, return a first weight value of 1;

[0167] if x is in [min, max], return a first weight value greater than 0 and less than 1;

[0168] wherein x is a distance between the terrain point to be rendered and the camera in the length direction, and min < M' < M' < max < M; or x is a distance between the terrain point to be rendered and the camera in the width direction, and min < N' < N' < max < N.

[0169] The shadow rendering unit is configured to determine a first weight according to the position of the terrain point to be rendered and the preset interpolation function, and calculate a second weight according to the first weight, wherein the first weight is a weight corresponding to the first shadow attenuation, and the second weight is a weight corresponding to the second shadow attenuation.

[0170] Optionally, the copying sub-module is configured to:

[0171] When the camera movement is detected, determine the eliminated terrain block and the newly emerged terrain block in the first field of view range generated by the camera movement;

[0172] Delete the shadow height map corresponding to the eliminated terrain block in the sampling height map, keep the shadow height map corresponding to the remaining terrain block in the sampling height map unchanged, and copy the shadow height map corresponding to the newly emerged terrain block to the position corresponding to the shadow height map of the eliminated terrain block.

[0173] It can be understood that the implementation principle and the technical effects of the shadow rendering device in the embodiment have been introduced in the foregoing method embodiment, and for brief description, the parts not mentioned in the shadow rendering device can be referred to the corresponding description in the shadow rendering method.

[0174] The disclosure embodiment also provides a game file packaging device, please refer to Figure 9 The game file packaging device 400 comprises:

[0175] The terrain block module 410 is configured to block the terrain in the game scene to obtain a plurality of terrain blocks;

[0176] The height map calculation module 420 is configured to calculate the highest height of each terrain point on each terrain block in the vertical direction of each time period according to the light source position corresponding to each time period, to obtain the shadow height map corresponding to each time period of each terrain block;

[0177] The video encoding module 430 is configured to perform video compression encoding on all shadow height maps of each terrain block in different time periods respectively, to obtain the video data corresponding to each terrain block;

[0178] The video packaging module 440 is configured to package the video data corresponding to each terrain block into the game file.

[0179] Optionally, the height map calculation module 420 comprises:

[0180] an original height map calculation unit, configured to calculate, based on the light source position corresponding to each time period, the highest height of each terrain point on the terrain block in the vertical direction of the shadow during the time period, to obtain an original height map corresponding to each terrain block, wherein the original height map stores the highest height of each terrain point on the terrain block;

[0181] an intermediate height map calculation unit, configured to perform a first exponential operation on each maximum height in the original height map to convert the maximum height into an exponential height, thereby obtaining an intermediate height map, wherein the intermediate height map stores the exponential height of each terrain point on the terrain block;

[0182] The filtering unit is configured to filter the intermediate height map corresponding to each time period to obtain a shadow height map corresponding to the terrain block in each time period.

[0183] Optionally, the filtering unit is used to:

[0184] The following filtering operation w·f(h0) is performed on each index height in the intermediate height map:

[0185]

[0186]

[0187] in, is the index height of the current filter in the intermediate height map, N is the number of other index heights participating in the current filter, is the i-th index height among N other index heights, c is the constant coefficient, w0 is the filter weight corresponding to the current filtered index height, w i is the filter weight corresponding to the i-th index height;

[0188] A shadow height map is obtained according to the filtering result of each exponential height, and the shadow height map stores an exponential item u obtained by filtering the exponential height of each terrain point on the terrain block.

[0189] Optionally, the height map calculation module 420 is used to:

[0190] For each terrain block, each terrain point on the terrain block is traversed, and according to the light source position in the time period, the height in the shadow is searched within a preset height range in the vertical direction of the terrain point to obtain the highest height corresponding to each terrain point on the terrain block in the time period.

[0191] It can be understood that the game file packaging device in this embodiment, its implementation principle and the technical effects produced have been introduced in the aforementioned method embodiment. For the sake of brief description, the parts not mentioned in the game file packaging device can refer to the corresponding description in the game file packaging method.

[0192] The embodiment of the present disclosure further provides a computer readable storage medium, which has stored thereon a computer program, and the program is executed by a processing device to implement the steps of the shadow rendering method or the game file packaging method.

[0193] The embodiment of the present disclosure further provides an electronic device, comprising:

[0194] a storage device having stored thereon a computer program;

[0195] a processing device configured to execute the computer program in the storage device to implement the steps of the shadow rendering method or the game file packaging method.

[0196] Reference will be made to the following description Figure 10 , which shows a structural schematic diagram of an electronic device (for example, an electronic device of a game maker or an electronic device of a user) 500 suitable for implementing the embodiment of the present disclosure. The terminal device in the embodiment of the present disclosure can include, but is not limited to, a mobile terminal such as a mobile phone, a notebook computer, a digital broadcast receiver, a PDA (Personal Digital Assistant), a PAD (Tablet Personal Computer), a PMP (Portable Multimedia Player), a vehicle terminal (for example, a vehicle navigation terminal), and the like, and a fixed terminal such as a digital TV, a desktop computer, and the like. Figure 10 The electronic device shown is only an example, and should not bring any limitation to the functions and use range of the embodiment of the present disclosure.

[0197] As shown in Figure 10 , the electronic device 500 can include a processing device (for example, a central processing unit, a graphic processing unit, and the like) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 to a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the electronic device 500 are also stored. The processing device 501, the ROM 502, and the RAM 503 are connected to each other through a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0198] Generally, the following devices can be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, and the like; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, and the like; a storage device 508 including, for example, a magnetic tape, a hard disk, and the like; and a communication device 509. The communication device 509 can allow the electronic device 500 to communicate with other devices to exchange data wirelessly or by wire. Although Figure 10Electronic device 500 is shown with various means, but it is understood that not all of the shown means need be implemented or present. More or less means can alternatively be implemented or present.

[0199] In particular, in accordance with embodiments of the present disclosure, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program comprising program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication means 509, or installed from storage means 508, or installed from ROM 502. When the computer program is executed by processing means 501, the above-mentioned functions defined in the methods of the embodiments of the present disclosure are performed.

[0200] It should be noted that the computer-readable medium described above in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable storage medium, for example, can be, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or apparatus, or any suitable combination thereof. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, the computer-readable storage medium can be any tangible medium that contains or stores a program used by or in connection with an instruction execution system, apparatus, or device. In the present disclosure, the computer-readable signal medium can include a data signal propagated in baseband or propagated as a carrier wave in a propagated data signal, in which the computer-readable program code is carried. Such a propagated data signal can take a variety of forms, including but not limited to electro-magnetic, optical, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium that is not a computer-readable storage medium and that can be used to carry or store program code used by or in connection with an instruction execution system, apparatus, or device. Program code contained in the computer-readable medium can be transmitted using any suitable medium, including but not limited to wire, cable, optical fiber, RF (radio frequency), etc., or any suitable combination thereof.

[0201] In some embodiments, the electronic device of the game developer and the server, the electronic device of the user and the server can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with digital data communication (e.g., communication network) of any form or medium, so as to publish game files to the server or download game files from the server. Examples of communication networks include local area networks ("LAN"), wide area networks ("WAN"), Internet networks (e.g., the Internet), and peer-to-peer networks (e.g., ad hoc peer-to-peer networks), as well as any currently known or future developed networks.

[0202] The computer readable medium described above can be included in the electronic device described above; or can exist separately and not be assembled into the electronic device.

[0203] The computer readable medium described above carries one or more programs, when the one or more programs are executed by the electronic device, the electronic device determines a target period corresponding to the in-game time, obtains video data corresponding to each target terrain block in the first field of view of the camera in the game scene from the game file; wherein the video data is obtained by video compression encoding all shadow height maps of the target terrain block at different periods, and the shadow height map stores a sampling value corresponding to each terrain point on the target terrain block; extract a video frame corresponding to the target period from the video data to obtain a shadow height map of the target terrain block at the target period; sample a sampling value corresponding to each to-be-rendered terrain point from the shadow height map at the target period, and render a shadow of the to-be-rendered terrain point according to the sampling value.

[0204] Alternatively, the computer readable medium described above carries one or more programs, when the one or more programs are executed by the electronic device, the electronic device: divides the terrain in the game scene into blocks to obtain a plurality of terrain blocks; according to the light source position corresponding to each period, respectively calculates the highest height of each terrain point on each terrain block in the vertical direction of the period to obtain the shadow height map corresponding to each period of each terrain block; respectively video compression encode all shadow height maps of each terrain block at different periods to obtain video data corresponding to each terrain block; and pack the video data corresponding to each terrain block into the game file.

[0205] Computer program code for carrying out operations of the present disclosure can be written in any one or more programming languages, including object oriented programming languages such as Java, Smalltalk, C++, as well as conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0206] The flow diagrams and the block diagrams in the drawings are illustrations of architectures, functionalities, and operations of possible implementations of systems, methods, and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flow diagrams or block diagrams can represent a module, a segment, or a portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that in some alternative implementations, the functions noted in the blocks can occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently or the blocks may

[0207] The modules involved in the embodiments of the present disclosure can be implemented in the form of software or in the form of hardware. Among them, the name of the module does not constitute a limitation to the module itself in some cases. For example, the video decoding module can also be described as "a module that extracts a video frame corresponding to a target period from video data to obtain a shadow height map of a target terrain block in the target period".

[0208] The functions described above in the specification can be performed at least in part by one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Program-specific Integrated Circuits (ASICs), Program-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.

[0209] In the context of this disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium will include one or more lines of electrical connections, portable computer disks, hard disk drives, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or Flash memory), optical fibers, portable compact disc read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0210] According to one or more embodiments of the present disclosure, example 1 provides a shadow rendering method, comprising:

[0211] determining a target period corresponding to an in-game time, obtaining video data corresponding to each target terrain block in a first field of view range of a camera in a game scene from a game file; wherein the video data is obtained by video compression encoding all shadow height maps of the target terrain block at different periods, and each terrain point on the target terrain block corresponds to a sampling value stored in the shadow height map;

[0212] extracting a video frame corresponding to the target period from the video data to obtain a shadow height map of the target terrain block at the target period;

[0213] sampling a sampling value corresponding to each to-be-rendered terrain point from the shadow height map at the target period, and rendering a shadow of the to-be-rendered terrain point according to the sampling value.

[0214] According to one or more embodiments of the present disclosure, example 2 provides the method of example 1, wherein the sampling a sampling value corresponding to each to-be-rendered terrain point from the shadow height map at the target period, and rendering a shadow of the to-be-rendered terrain point according to the sampling value, comprises:

[0215] copying the shadow height map of each target terrain block in the first field of view range at the target period to a sampling height map;

[0216] determining a sampling position of each to-be-rendered terrain point on the sampling height map;

[0217] sampling a sampling value at a corresponding position from the sampling height map according to the sampling position, and rendering a corresponding shadow according to the sampling value corresponding to each to-be-rendered terrain point.

[0218] According to one or more embodiments of the present disclosure, example 3 provides the method of example 2, wherein the sampling a sampling value of a corresponding position from the sampling height map according to the sampling position and rendering a shadow corresponding to each to-be-rendered terrain point according to a sampling value corresponding to the to-be-rendered terrain point comprises:

[0219] According to the sampling position corresponding to the to-be-rendered terrain point, a sampling value at a corresponding position in the sampling height map is obtained, and a first target exponential height is calculated according to the sampling value;

[0220] A world height of the to-be-rendered terrain point in the game scene is obtained;

[0221] The world height is subjected to a second exponential operation to obtain a second target exponential height;

[0222] The first target exponential height is multiplied by the second target exponential height to obtain a first shadow attenuation corresponding to the to-be-rendered terrain point;

[0223] The shadow of the to-be-rendered terrain point is rendered according to the first shadow attenuation.

[0224] According to one or more embodiments of the present disclosure, example 4 provides the method of example 3, wherein the rendering a shadow of the to-be-rendered terrain point according to the first shadow attenuation comprises:

[0225] According to the light source position of the target period and the material information of the to-be-rendered terrain point, original shading information of the to-be-rendered terrain point is calculated;

[0226] According to the first shadow attenuation and the original shading information, shadow shading information is obtained;

[0227] The shadow of the to-be-rendered terrain point is rendered according to the shadow shading information.

[0228] According to one or more embodiments of the present disclosure, example 5 provides the method of example 4, further comprising:

[0229] A shadow depth map in a second field of view range of the camera is obtained by a shadow map algorithm; wherein the second field of view range is located within the first field of view range;

[0230] A shadow depth value corresponding to the to-be-rendered terrain point is sampled from the shadow depth map;

[0231] A second shadow attenuation corresponding to the to-be-rendered terrain point is calculated according to the shadow depth value;

[0232] The obtaining shadow shading information according to the first shadow attenuation and the original shading information comprises:

[0233] determine weight information corresponding to the to-be-rendered terrain point according to a preset interpolation function;

[0234] perform weighted calculation on the first shadow attenuation and the second shadow attenuation according to the weight information, to obtain a target shadow attenuation;

[0235] apply the target shadow attenuation to the original shading information, to obtain the shadow shading information.

[0236] According to one or more embodiments of the present disclosure, example 6 provides the method of example 5, the first field of view range is a range of length M and width N formed with the camera as the center, the second field of view range is a range of length M' and width N' formed with the camera as the center, and M' < M and N' < N; the preset interpolation function is constructed as:

[0237] if x is less than min, return the first weight as 0;

[0238] if x is greater than max, return the first weight as 1;

[0239] if x ∈ [min, max], return the first weight as a value greater than 0 and less than 1;

[0240] wherein x is the distance between the to-be-rendered terrain point and the camera in the length direction, and min < M' and M' < max < M; or x is the distance between the to-be-rendered terrain point and the camera in the width direction, and min < N' and N' < max < N;

[0241] The determining the weight information corresponding to the to-be-rendered terrain point according to the preset interpolation function comprises:

[0242] determining a first weight according to the position of the to-be-rendered terrain point and the preset interpolation function;

[0243] calculating a second weight according to the first weight; wherein the first weight is the weight corresponding to the first shadow attenuation, and the second weight is the weight corresponding to the second shadow attenuation.

[0244] According to one or more embodiments of the present disclosure, example 7 provides the method of example 5, further comprising:

[0245] configuring the sampling mode of the shadow depth map as: when the position sampled from the shadow depth map exceeds the second field of view range represented by the shadow depth map, sampling from the position closest to the sampled position.

[0246] According to one or more embodiments of the present disclosure, example 8 provides the method of example 2, the copying of the shadow height map of each target terrain block located in the first field of view range to the sampling height map in the target time period comprises:

[0247] When the camera movement is detected, determine the eliminated terrain blocks and the newly emerged terrain blocks in the first field of view range generated by the camera movement;

[0248] Delete the shadow height map corresponding to the eliminated terrain block in the sampling height map, keep the shadow height map corresponding to the remaining terrain block in the sampling height map unchanged, and copy the shadow height map corresponding to the newly emerged terrain block to the position corresponding to the shadow height map of the eliminated terrain block.

[0249] According to one or more embodiments of the present disclosure, example 9 provides a game file packaging method, comprising:

[0250] The terrain in the game scene is divided into blocks to obtain a plurality of terrain blocks;

[0251] According to the light source position corresponding to each time period, the highest height of each terrain point on each terrain block in the vertical direction of the time period in the shadow is calculated respectively to obtain the shadow height map corresponding to each time period of each terrain block;

[0252] Video compression encoding is performed on all shadow height maps of each terrain block in different time periods respectively to obtain the video data corresponding to each terrain block;

[0253] The video data corresponding to each terrain block is packaged into a game file.

[0254] According to one or more embodiments of the present disclosure, example 10 provides the method of example 9, the method of calculating the highest height of each terrain point on each terrain block in the vertical direction of the time period in the shadow according to the light source position corresponding to each time period to obtain the shadow height map corresponding to each time period of each terrain block comprises:

[0255] For each terrain block, the following operations are performed respectively:

[0256] According to the light source position corresponding to each time period, the highest height of each terrain point on the terrain block in the vertical direction of the time period in the shadow is calculated respectively to obtain the original height map corresponding to each terrain block, and the original height map stores the highest height of each terrain point on the terrain block;

[0257] The first exponential operation is performed on each highest height in the original height map respectively to convert the highest height to an exponential height to obtain an intermediate height map, and the intermediate height map stores the exponential height of each terrain point on the terrain block.

[0258] filtering the intermediate height map corresponding to each time period to obtain a shadow height map of the terrain block corresponding to each time period.

[0259] According to one or more embodiments of the present disclosure, example 11 provides the method of example 10, and the filtering the intermediate height map corresponding to each time period to obtain a shadow height map of the terrain block corresponding to each time period, comprises:

[0260] filtering each exponential height in the intermediate height map as follows: w·f(h0)

[0261]

[0262]

[0263] wherein, is the exponential height currently filtered in the intermediate height map, N is the number of other exponential heights participating in the current filtering, is the i-th exponential height in the N other exponential heights, c is a constant coefficient, w0 is the filtering weight corresponding to the exponential height currently filtered, w i is the filtering weight corresponding to the i-th exponential height;

[0264] obtaining a shadow height map according to the filtering result of each exponential height, the shadow height map storing the exponential term u obtained by filtering the exponential height of each terrain point on the terrain block.

[0265] According to one or more embodiments of the present disclosure, example 12 provides the method of any one of examples 9 to 11, and the calculating the highest height in the vertical direction of the time period in the shadow of each terrain point on each terrain block according to the light source position corresponding to each time period, comprises:

[0266] for each terrain block, traversing each terrain point on the terrain block, searching for the height in the shadow in the preset height range in the vertical direction of the terrain point according to the light source position of the time period, to obtain the highest height corresponding to the time period of each terrain point on the terrain block.

[0267] According to one or more embodiments of the present disclosure, example 13 provides a shadow rendering device, comprising:

[0268] a video acquisition module configured to determine a target time period corresponding to an in-game time, and acquire video data corresponding to each target terrain block within a first field of view of a camera in a game scene from a game file, wherein the video data is obtained by video compression encoding of all shadow height maps of the target terrain block at different time periods, and each terrain point on the target terrain block has a sampling value stored in the shadow height map;

[0269] a video decoding module configured to extract a video frame corresponding to the target time period from the video data, and obtain a shadow height map of the target terrain block at the target time period;

[0270] a shadow rendering module configured to sample a sampling value corresponding to each terrain point to be rendered from the shadow height map of the target time period, and render a shadow of the terrain point to be rendered according to the sampling value.

[0271] According to one or more embodiments of the present disclosure, example 14 provides a game file packaging apparatus, comprising:

[0272] a terrain partitioning module configured to partition a terrain in a game scene to obtain a plurality of terrain blocks;

[0273] a height map calculation module configured to calculate a highest height of each terrain point on each terrain block in a vertical direction of each time period in a shadow according to a light source position corresponding to the time period, and obtain a shadow height map corresponding to each time period for each terrain block;

[0274] a video encoding module configured to video compression encode all shadow height maps of each terrain block at different time periods respectively, and obtain video data corresponding to each terrain block;

[0275] a video packaging module configured to package the video data corresponding to each terrain block into a game file.

[0276] According to one or more embodiments of the present disclosure, example 15 provides a computer readable storage medium having a computer program stored thereon, wherein the program is executed by a processing apparatus to implement the method of any one of examples 1-12.

[0277] According to one or more embodiments of the present disclosure, example 16 provides an electronic device, comprising:

[0278] a storage device having a computer program stored thereon;

[0279] a processing apparatus configured to execute the computer program in the storage device to implement the method of any one of examples 1-12.

[0280] The above description merely illustrates the preferred embodiment of the disclosure and a principle of applied technologies. It should be understood by those skilled in the art that the disclosed range of the disclosure is not limited to the technical solutions formed by the specific combinations of the technical features described above, and should also cover other technical solutions formed by the combinations of the technical features described above or their equivalent features without departing from the disclosed concept. For example, the technical solutions formed by the mutual replacement of the above-described features and the technical features with similar functions disclosed in the disclosure (but not limited to) can be formed.

[0281] Furthermore, although operations are depicted in a particular, sequential order, this should not be understood as requiring or implying that the operations are performed in the order illustrated or sequentially. In certain circumstances, multitasking and parallel processing can be advantageous. Likewise, although specific implementation details are contained in the above discussion, these should not be construed as limiting the scope of the disclosure. Certain features described in the context of separate embodiments can also be implemented together in a single embodiment. Conversely, various features described in the context of a single embodiment can also be implemented separately or in any suitable subcombination. It should be appreciated, as well, that the detailed description has not made reference to the drawing by using a detailed description of the fabrication of the devices and methods described above. Such methods and devices are well known to those skilled in the art, and it is believed the interested person can with the benefit of the detailed description provided herewith apply the fabricating knowledge to these devices and methods.

[0282] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims. With respect to the devices in the above-described embodiments, in which various modules perform operations, the specific manner in which the operations are performed by the modules has been described in detail in the embodiments related to the methods, and will not be described in detail here.

Claims

1. A method of shadow rendering, characterized by, The method comprises: determining a target period corresponding to in-game time, and obtaining video data corresponding to each target terrain block in a first field of view range of a camera in a game scene from a game file; wherein the video data is obtained by video compression encoding all shadow height maps of the target terrain block at different periods, and each terrain point on the target terrain block corresponds to a sampling value stored in the shadow height map; extracting a video frame corresponding to the target period from the video data to obtain a shadow height map of the target terrain block at the target period; copying the shadow height map of each target terrain block in the first field of view range to a sampling height map at the target period; determining a sampling position of each terrain point to be rendered on the sampling height map; obtaining a sampling value at a corresponding position in the sampling height map according to the sampling position corresponding to the terrain point to be rendered, and calculating a first target exponential height according to the sampling value; obtaining a world height of the terrain point to be rendered in the game scene; performing a second exponential operation on the world height to obtain a second target exponential height; multiplying the first target exponential height and the second target exponential height to obtain a first shadow attenuation corresponding to the terrain point to be rendered; rendering a shadow of the terrain point to be rendered according to the first shadow attenuation.

2. The method of claim 1, wherein, The rendering of the shadow of the terrain point to be rendered according to the first shadow attenuation comprises: calculating original shading information of the terrain point to be rendered according to a light source position of the target period and material information of the terrain point to be rendered; obtaining shadow shading information according to the first shadow attenuation and the original shading information; rendering the shadow of the terrain point to be rendered according to the shadow shading information.

3. The method of claim 2, wherein, The method further comprises: obtaining a shadow depth map in a second field of view range of the camera by a shadow map algorithm; wherein the second field of view range is within the first field of view range; sampling a shadow depth value corresponding to the terrain point to be rendered from the shadow depth map; calculating a second shadow attenuation corresponding to the terrain point to be rendered according to the shadow depth value; The obtaining of the shadow shading information according to the first shadow attenuation and the original shading information comprises: determining weight information corresponding to the terrain point to be rendered according to a preset interpolation function; performing weighted calculation on the first shadow attenuation and the second shadow attenuation according to the weight information to obtain target shadow attenuation; applying the target shadow attenuation to the original shading information to obtain the shadow shading information.

4. The method of claim 3, wherein, The first field of view range is a range with a length of M and a width of N formed with the camera as the center, the second field of view range is a range with a length of M' and a width of N' formed with the camera as the center, and M' < M and N' < N; and the preset interpolation function is constructed as follows: if x is less than min, return a first weight value of 0; if x is greater than max, return a first weight value of 1; if x∈[min, max], return a first weight value greater than 0 and less than 1. Wherein, x is the distance between the terrain point to be rendered and the camera in the length direction, and min The method further comprises: According to the position of the terrain point to be rendered and the preset interpolation function, a first weight value is determined; According to the first weight value, a second weight value is calculated; wherein, the first weight value is the weight value corresponding to the first shadow attenuation, and the second weight value is the weight value corresponding to the second shadow attenuation.

5. The method according to claim 3, characterized in that The method further comprises: The sampling mode of the shadow depth map is configured as: when the position sampled from the shadow depth map exceeds the second field of view range represented by the shadow depth map, sampling is performed from the position closest to the sampled position.

6. The method of claim 1, wherein, The method further comprises: When the camera moves, the eliminated terrain block and the newly appeared terrain block in the first field of view range generated by the movement of the camera are determined; The shadow height map corresponding to the eliminated terrain block in the sampling height map is deleted, the shadow height map corresponding to the remaining terrain block in the sampling height map is kept unchanged, and the shadow height map corresponding to the newly appeared terrain block is copied to the position corresponding to the shadow height map of the eliminated terrain block.

7. A game file packaging method characterized by, The method further comprises: The terrain in the game scene is divided into blocks to obtain a plurality of terrain blocks; According to the position of the light source corresponding to each period, the highest height of each terrain point on each terrain block in the vertical direction of the period is calculated respectively to obtain the shadow height map corresponding to each terrain block in each period; All shadow height maps of each terrain block in different periods are video compression encoded respectively to obtain the video data corresponding to each terrain block; The video data corresponding to each terrain block is packaged into a game file; The game file is used to: determine a target period corresponding to a time in the game, and obtain the video data corresponding to each target terrain block in the first field of view range of the camera in the game scene from the game file; From the video data, a video frame corresponding to the target period is extracted to obtain the shadow height map of the target terrain block in the target period, and the sampling value corresponding to each terrain point on the target terrain block is stored in the shadow height map; The shadow height map of each target terrain block in the target period located in the first field of view range is copied to a sampling height map; The sampling position of each terrain point to be rendered on the sampling height map is determined; According to the sampling position corresponding to the terrain point to be rendered, the sampling value at the corresponding position in the sampling height map is obtained, and a first target exponential height is calculated according to the sampling value; The world height of the terrain point to be rendered in the game scene is obtained; The world height is subjected to a second exponential operation to obtain a second target exponential height; Multiplying the first target index height by the second target index height to obtain a first shadow attenuation corresponding to the terrain point to be rendered; The shadow of the terrain point to be rendered is rendered according to the first shadow attenuation.

8. The method of claim 7, wherein, The step of calculating the highest height of each terrain point on each terrain block in the shadow in the vertical direction of the time period according to the light source position corresponding to each time period, and obtaining the shadow height map corresponding to each terrain block in each time period, includes: For each terrain block, perform the following operations: Calculating the highest height of each terrain point on the terrain block in the shadow in the vertical direction of the time period according to the light source position corresponding to each time period, and obtaining an original height map corresponding to each terrain block, wherein the original height map stores the highest height of each terrain point on the terrain block; Performing a first exponential operation on each maximum height in the original height map to convert the maximum height into an exponential height, thereby obtaining an intermediate height map, wherein the intermediate height map stores the exponential height of each terrain point on the terrain block; The intermediate height map corresponding to each time period is filtered to obtain a shadow height map corresponding to the terrain block in each time period.

9. The method of claim 8, wherein, The filtering of the intermediate height map corresponding to each time period to obtain the shadow height map corresponding to each time period of the terrain block includes: filtering each exponential height in the intermediate height map as follows : ; ; wherein, is the currently filtered exponent height in the intermediate height map, N is the number of other exponent heights participating in the current filtering, is the i-th exponent height among the N other exponent heights, c is a constant coefficient, w0is the filtering weight corresponding to the currently filtered exponent height, w i is the filtering weight corresponding to the i-th exponent height; A shadow height map is obtained from the filtered results for each index height, the shadow height map storing the index term resulting from filtering the index height for each terrain point on the terrain patch u .

10. The method according to any one of claims 7 to 9, characterized in that, The step of calculating the highest height of each terrain point on each terrain block in the shadow in the vertical direction of each time period according to the light source position corresponding to each time period includes: For each terrain block, each terrain point on the terrain block is traversed, and according to the light source position in the time period, the height in the shadow is searched within a preset height range in the vertical direction of the terrain point to obtain the highest height corresponding to each terrain point on the terrain block in the time period.

11. A shadow rendering apparatus, characterized by comprising: include: A video acquisition module is configured to determine a target time period corresponding to in-game time and obtain, from the game file, video data corresponding to each target terrain block within the first field of view of the camera in the game scene; wherein the video data is obtained by performing video compression encoding on all shadow height maps of the target terrain block at different time periods, wherein the shadow height maps store sampling values ​​corresponding to each terrain point on the target terrain block; a video decoding module, configured to extract a video frame corresponding to the target time period from the video data, and obtain a shadow height map of the target terrain block during the target time period; A shadow rendering module is used to sample a sampling value corresponding to each terrain point to be rendered from the shadow height map of the target time period, and render the shadow of the terrain point to be rendered according to the sampling value; The shadow rendering module includes: A copy submodule, configured to copy the shadow height map of each target terrain block within the first field of view during the target time period to a sampling height map; A position determination submodule, configured to determine a sampling position of each terrain point to be rendered on the sampling height map; The first target exponent height acquisition unit is configured to acquire a sampling value at a corresponding position in the sampling height map according to a sampling position corresponding to the to-be-rendered terrain point, and calculate a first target exponent height according to the sampling value. The second target exponent height acquisition unit is configured to acquire a world height of the to-be-rendered terrain point in the game scene, and perform second exponent operation on the world height to obtain a second target exponent height. The first shadow attenuation calculation unit is configured to multiply the first target exponent height and the second target exponent height to obtain a first shadow attenuation corresponding to the to-be-rendered terrain point. The shadow rendering unit is configured to render a shadow of the to-be-rendered terrain point according to the first shadow attenuation.

12. A game file packaging apparatus characterized by comprising: The terrain partitioning module is configured to partition a terrain in a game scene to obtain a plurality of terrain blocks. The height map calculation module is configured to calculate a highest height of each terrain point on each terrain block in a vertical direction of each time period to obtain a shadow height map corresponding to each terrain block in each time period according to a light source position corresponding to each time period. The video encoding module is configured to perform video compression encoding on all shadow height maps of each terrain block in different time periods to obtain video data corresponding to each terrain block. The video packaging module is configured to package the video data corresponding to each terrain block into a game file. The game file is configured to determine a target time period corresponding to a time in a game, acquire video data corresponding to each target terrain block located within a first field of view of a camera in a game scene from the game file. Extract a video frame corresponding to the target time period from the video data to obtain a shadow height map of the target terrain block in the target time period, the shadow height map storing sampling values corresponding to each terrain point on the target terrain block. Copy the shadow height map of each target terrain block located within the first field of view in the target time period to a sampling height map. Determine a sampling position of each to-be-rendered terrain point on the sampling height map. Acquire a sampling value at a corresponding position in the sampling height map according to a sampling position corresponding to the to-be-rendered terrain point, and calculate a first target exponent height according to the sampling value. Acquire a world height of the to-be-rendered terrain point in the game scene. Perform second exponent operation on the world height to obtain a second target exponent height. Multiply the first target exponent height and the second target exponent height to obtain a first shadow attenuation corresponding to the to-be-rendered terrain point. Render a shadow of the to-be-rendered terrain point according to the first shadow attenuation. The program is executed by the processing device to implement the steps of the method of any one of claims 1-6 or any one of claims 7-10.

13. A computer readable storage medium having stored thereon a computer program, characterized in that The storage device has a computer program stored thereon.

14. An electronic device, comprising: The processing device is configured to execute the computer program in the storage device to implement the steps of the method of any one of claims 1-6 or any one of claims 7-10. ​ ​

Citation Information

Patent Citations

  • Method for displaying real-time shadow in virtual reality

    CN106355631A

  • Image rendering method and device and storage medium

    CN108830923A

  • Method, apparatus and device for processing tomographic images, and storage medium

    CN108924556A

  • Shadow map generation method and device

    CN111724313A