WO2021253640A1 - 阴影数据确定方法、装置、设备和可读介质 - Google Patents

阴影数据确定方法、装置、设备和可读介质 Download PDF

Info

Publication number
WO2021253640A1
WO2021253640A1 PCT/CN2020/112540 CN2020112540W WO2021253640A1 WO 2021253640 A1 WO2021253640 A1 WO 2021253640A1 CN 2020112540 W CN2020112540 W CN 2020112540W WO 2021253640 A1 WO2021253640 A1 WO 2021253640A1
Authority
WO
WIPO (PCT)
Prior art keywords
image area
shadow
shadow data
objects
range
Prior art date
Application number
PCT/CN2020/112540
Other languages
English (en)
French (fr)
Inventor
马蛟
张旭辉
Original Assignee
完美世界(北京)软件科技发展有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 完美世界(北京)软件科技发展有限公司 filed Critical 完美世界(北京)软件科技发展有限公司
Publication of WO2021253640A1 publication Critical patent/WO2021253640A1/zh

Links

Images

Classifications

    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/50Controlling the output signals based on the game progress
    • A63F13/52Controlling the output signals based on the game progress involving aspects of the displayed game scene
    • AHUMAN NECESSITIES
    • A63SPORTS; GAMES; AMUSEMENTS
    • A63FCARD, BOARD, OR ROULETTE GAMES; INDOOR GAMES USING SMALL MOVING PLAYING BODIES; VIDEO GAMES; GAMES NOT OTHERWISE PROVIDED FOR
    • A63F13/00Video games, i.e. games using an electronically generated display having two or more dimensions
    • A63F13/55Controlling game characters or game objects based on the game progress
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T15/003D [Three Dimensional] image rendering
    • G06T15/50Lighting effects
    • G06T15/60Shadow generation

Definitions

  • the present invention relates to the technical field of data processing, and in particular to a method, device, equipment and readable medium for determining shadow data.
  • the shadow map of each object contained in the game environment of the object controlled by the player will be drawn in real time, so that each object in the game environment has a shadow , Making the game experience more realistic.
  • the calculation overhead of drawing the shadow map of each object contained in the game environment in real time is relatively high, and it is easy to appear stalls during the execution of the game.
  • the embodiments of the present invention provide a method, a device, a device, and a storage medium for determining shadow data, which are used to reduce calculation overhead and improve game execution efficiency.
  • an embodiment of the present invention provides a method for determining shadow data, the method including:
  • the respective shadow data corresponding to the objects contained in the respective image area ranges are calculated.
  • an embodiment of the present invention provides an apparatus for determining shadow data, including:
  • the determining module is configured to determine the current corresponding position of the target object in the shadow map to be drawn when it is detected that the target object moves out of the corresponding target range in the shadow map to be drawn;
  • the determining module is configured to determine the multiple image area ranges in the shadow map to be drawn and the hierarchical relationship between the image area ranges based on the current corresponding position of the target object in the shadow map to be drawn;
  • the update module is configured to determine the shadow data update time interval corresponding to the respective image area ranges based on the respective levels corresponding to the respective image area ranges;
  • the calculation module is configured to calculate the respective shadow data corresponding to each object contained in each image area based on the update time interval of the shadow data corresponding to the respective image area ranges.
  • an embodiment of the present invention provides an electronic device including a processor and a memory.
  • the memory stores at least one instruction, at least one program, code set or instruction set, the at least one instruction, at least one program,
  • the code set or instruction set is loaded and executed by the processor to implement the shadow data determination method in the first aspect.
  • an embodiment of the present invention provides a computer-readable medium on which at least one instruction, at least one program, code set or instruction set is stored, the at least one instruction, at least one program, code set or instruction set It is loaded and executed by the processor to realize the shadow data determination method in the first aspect.
  • the corresponding position of the target object in the shadow map to be drawn can be determined, so that based on the location of the target object, multiple image area ranges can be divided in the shadow map to be drawn.
  • the shadow data update time interval corresponding to the current image area range can be determined according to the levels corresponding to the different image area ranges, so that different image area ranges are set with different shadow data updates.
  • the time interval avoids that the entire shadow map to be drawn is updated with the same shadow data update frequency. According to the specific conditions of different image areas, set the respective shadow data update time intervals, which can realize real-time shadows, and the game experience is more realistic.
  • the present invention can reduce the performance overhead required to realize real-time shadows, improve the operating efficiency of game applications, and reduce the storage space for storing shadow data.
  • FIG. 1 is a schematic flowchart of a method for determining shadow data according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram of a principle of Shadowmap provided by an embodiment of the present invention.
  • FIG. 3 is a schematic diagram of an inner image area range provided by an embodiment of the present invention.
  • FIG. 4 is a schematic diagram of multiple image area ranges provided by an embodiment of the present invention.
  • FIG. 5 is a schematic diagram of multiple image area ranges in a 3D scene according to an embodiment of the present invention.
  • FIG. 6 is a schematic diagram of shadow data storage provided by an embodiment of the present invention.
  • FIG. 7 is a schematic diagram of a result of drawing a shadow on a target object in an inner image area provided by an embodiment of the present invention.
  • FIG. 8 is a schematic diagram of another shadow data storage provided by an embodiment of the present invention.
  • FIG. 9 is a schematic diagram of a process of dynamically generating shadow data of an inner image area range provided by an embodiment of the present invention.
  • FIG. 10 is a schematic diagram of a process of generating shadow data according to an embodiment of the present invention.
  • FIG. 11 is a schematic flowchart of judging the intersection relationship between an object and a frustum according to an embodiment of the present invention.
  • FIG. 12 is a schematic diagram of an exemplary AABB and OBB bounding box provided by an embodiment of the present invention.
  • FIG. 13 is a schematic diagram of a situation of comparing computing resources required for calculating one animation frame with computing resources required for solving multiple animation frames according to an embodiment of the present invention
  • FIG. 14 is a schematic diagram of another process of generating shadow data according to an embodiment of the present invention.
  • FIG. 15 is a schematic diagram of a result of blur processing provided by an embodiment of the present invention.
  • 16 is a schematic structural diagram of a device for determining shadow data according to an embodiment of the present invention.
  • FIG. 17 is a schematic structural diagram of an electronic device provided by an embodiment of the present invention.
  • the words “if” and “if” as used herein can be interpreted as “when” or “when” or “in response to determination” or “in response to detection”.
  • the phrase “if determined” or “if detected (statement or event)” can be interpreted as “when determined” or “in response to determination” or “when detected (statement or event) )” or “in response to detection (statement or event)”.
  • FIG. 1 is a flowchart of a method for determining shadow data according to an embodiment of the present invention. As shown in FIG. 1, the method includes the following steps:
  • the target object may be an agent of the user, such as a simulated person.
  • Shadowmap In order to obtain the shadows of the target object and surrounding objects, we can assume that a light source is set in the game environment, analyze what kind of shadows will be generated when the light source illuminates the target object and each object in the game environment, and generate shadow data according to the analysis results ( Shadowmap).
  • Shadowmap production As shown in Figure 2, it is a schematic diagram of the principle of Shadowmap.
  • the sun-shaped icon represents the location of the light source
  • the box-shaped icon represents an object.
  • the surface of the object facing the light source is bright and behind the surface of the object facing away from the light source.
  • the space will form a shaded area.
  • the game environment around the target object to be manipulated can be determined first, and objects such as houses, trees, etc. required for the game can be set in the game environment. Assuming that the map in the game environment can be divided by grids, then the target grid area where the target object is currently located can be determined. Assuming that there is currently a blank shadow map to be drawn, you can add the shadow of the target object or object at the corresponding position above.
  • the shadow map to be drawn has the same size as the map in the game environment and is divided by the same grid, then The target grid area at the corresponding position in the shadow map to be drawn can be found through the target grid area of the target object in the map.
  • Then divide the groups of grids around the target grid area into multiple image area ranges, and determine the hierarchical relationship between these image area ranges.
  • the image area closest to the target grid area belongs to the inner image area, and the image area farthest from the target grid area belongs to the outer image area.
  • three image area ranges are set in the shadow map to be drawn as an example, based on the target grid area, multiple image area ranges in the shadow map to be drawn and the range between each image area are determined
  • the process of the hierarchical relationship can be realized as follows: With the target grid area as the center, three nine-square grid areas are determined. Among them, the grid size of the three nine-square grid areas is different, and the area with the smallest grid size among the three nine-square grid areas is taken as Inner image area range, the area with the largest grid size among the three nine-square grid areas is regarded as the outer image area range, and the three nine-square grid areas except for the inner image area range and the outer image area range are regarded as the middle image area range .
  • FIGS. 3 and 4 For ease of understanding, take FIGS. 3 and 4 as examples to illustrate the process of determining the range of multiple image regions.
  • the target grid area where the game character is located is the center.
  • the target grid area is surrounded by 8 grid areas around it.
  • the target grid area and the 8 grid areas around it form a nine-square grid area.
  • the Jiugongge area is the divided inner image area range.
  • this time expand the size of the middle grid of the Jiugong grid to obtain a Jiugong grid that is larger than the Jiugong grid of the inner image area.
  • This larger Jiugong grid can be used as the middle image area.
  • This larger Jiugong grid can be used as the outer layer. The extent of the image area. It can be seen that the target grid area is taken as the center, and multiple image areas of different levels are determined by outward diffusion.
  • the display result of the divided multiple image regions in the 3D scene can also be shown in Fig. 5. It can be seen from the figure that there are three Jiugong grids centered on the player.
  • the Jiugong grid on the innermost layer is the range of the above-mentioned inner image area
  • the Jiugong grid on the middle layer is the range of the above-mentioned middle image area
  • the Jiugong grid on the outermost layer is the above-mentioned image area.
  • the extent of the outer image area is the extent of the outer image area.
  • the size of the image area can be adjusted by adjusting the size interface corresponding to the inner image area, the middle image area, and the outer image area.
  • the technician can adjust the size of the image area based on experience and observation results of the animation model. For example, the technician can observe whether the calculated shadow data has obvious jaggies when displayed on the screen under a certain size, or whether the fineness of the shadow data display can be accepted, etc. When adjusted to a satisfactory size, the size of the current image area range can be used as the final result.
  • a Texture2DArray object can be created to store the shadow data of the three image regions. As shown in Figure 6, Slice0 in the Texture2DArray object can store the shadow data of the inner image area, Slice1 can store the shadow data of the middle image area, and Slice2 can store the shadow data of the outer image area. .
  • a corresponding shadow data update time interval can be set for each image area range.
  • the shadow data update time interval corresponding to the inner image area range can be set to be smaller than the shadow data update time interval corresponding to the middle image area range, and the shadow data update time interval corresponding to the middle image area range is smaller than the outer image area range.
  • the shadow data update interval corresponding to the layer image area range can be set to be smaller than the shadow data update time interval corresponding to the middle image area range, and the shadow data update time interval corresponding to the middle image area range is smaller than the outer image area range.
  • the shadow data update time interval corresponding to the inner image area range is set to 1
  • the shadow data update time interval corresponding to the middle image area range is set to 2
  • the shadow data update time corresponding to the outer image area range is set to 3.
  • the objects closest to the target object and the shadow of the target object itself can be updated in real time, and for those objects that are far away from the target object that the user does not pay much attention to, it can be separated for a period of time Update their shadows once. Furthermore, the number of objects that need to be updated as a whole can be reduced, computing overhead can be saved, the operating efficiency of game applications can be improved, and the storage space for storing shadow data can be reduced at the same time.
  • the shadow data update time interval corresponding to each image area range can be determined based on the level corresponding to each image area range. For example, for the inner image area range, suppose there are the target object, house A and house B in the inner image area range, the last time the shadow of the target object, house A and house B is calculated is 15'21", 15'21” After a time interval of 1” has elapsed, the shadows of the target object, house A and house B can be calculated again (provided that the target object has not moved out of the nine-square grid area where the shadow was calculated last time). It should be noted that the update time In addition to the specific duration, the interval can also be expressed by the number of frames, such as calculating the shadow of the object in the image area every several animation frames.
  • the target object in the inner image area there may be other objects, and some of these objects may be dynamic, such as cars and animals, and some may be static, such as houses, Trees, etc., can classify these objects.
  • some of these objects may be dynamic, such as cars and animals, and some may be static, such as houses, Trees, etc.
  • the time difference between the current time and the previous shadow data update time reaches the shadow data update time interval corresponding to the inner image area, only the shadows of objects belonging to the target object type are updated, and for those For objects in the inner image area except for objects belonging to the target object type, when the shadow update time corresponding to the object of other object type meets the preset condition, the shadow of the object of other object type is recalculated.
  • the objects of the target object type mentioned above can be dynamic objects, or more important objects that need to be carefully portrayed.
  • the process of recalculating the shadows of objects of other object types can be implemented as follows: If the current time and the previous shadow of objects of other object types are When the time difference between the calculation moments reaches the preset time interval, the shadows of objects of other object types are recalculated.
  • a Texture2DArray object and CurlnnerRT can be created to store the shadow data of the three image regions.
  • the shadow data of the inner image area can be stored in the Slice0 of the Texture2DArray object. Specifically, it can be dynamically calculated shadows of objects of the target object type and other object types in the inner image area. Data. In Slice1, you can store the shadow data in the middle image area, and in Slice2 you can store the shadow data in the outer image area. Among them, the dynamically calculated shadow data of objects of the target object type and objects of other object types within the range of the inner image area can be merged and stored in CurlnnerRT.
  • Frame0 (Frame represents a video frame), generate Inner (Inner represents the shadow data of the target object type and other object type objects in the inner image area), and the generated Inner result Save to CurlnnerRT.
  • Frame1 generate Dynamic (Dynamic represents the shadow data of the target object type in the inner image area), and then perform the min or max operation on the generated Dynamic result and the content saved in CurlnnerRT, and then pass the min or max operation The result is saved to Slice0.
  • the processing of Frame 2, 3, 4 is the same as Frame1.
  • Frame5 generate Inner, and save the generated Inner result to CurlnnerRT.
  • the dynamically calculated shadow data of the target object type and other object type objects in the inner image area can be merged and stored in Slice0.
  • the results stored in Slice0 can be used directly to reduce the number of samples. .
  • the main process of generating shadow data includes: calculating the light space orthogonal projection (VP) matrix; calculating the intersecting relationship between the object and the viewing cone; declaring Render Texture; SetRenderTarget; ClearRenderTarget; Set the VP matrix to the Shader; Commandbuffer.DrawRender (objects that intersect the frustum); Graphics.Execute Commandbuffer; pass the generated RT to the Shader; pass the generated RT to the Shader again; sample_Shadowmap to calculate the shadow.
  • VP light space orthogonal projection
  • the frustum refers to the range of a cone visible to the camera in the scene. It is composed of 6 faces up, down, left, right, near and far. The scene inside the frustum is visible, and vice versa is not visible.
  • the calculation process of the VP matrix can mainly include: obtaining the directional light Forward direction; given the up vector (0,1,0); based on the directional light Forward direction and the up vector, performing multiple cross-multiplications, Obtain the reference axis vector of the light space; determine the light space reference axis matrix; determine the coordinates of the light in the world space; determine the displacement matrix; multiply the light space reference axis matrix and the displacement matrix to obtain the light space matrix, which can be obtained by ⁇ matrix_V ⁇ function implementation; get the 8 vertices of the bounding box of the world space; convert to the light space based on the 8 vertices of the bounding box of the world space and the light space matrix; find the maximum and minimum coordinates; calculate the frustum by parameters Realization of widht, height, near, far; determine the light space orthogonal projection matrix, which can be realized by the (matrix_P) function; multiply the light space matrix and the light space orthogonal projection matrix to get
  • the intersection relationship between the object and the viewing cone can be calculated based on the VP matrix.
  • the distance between it and the target object is not equal, some are closer to the target object, and some are far away from the target object. Objects that are closer to the target object may fall in the inner image area, objects that are slightly farther away may fall in the middle image area, and objects farther away may fall in the outer image area.
  • each image area range corresponds to a frustum
  • an object falls into a certain viewing frustum, then it can be considered that the certain object belongs to the range of the image area corresponding to the falling viewing frustum.
  • the judgment can be made in the order of the Inner viewing frustum, Middle viewing frustum, and Outer viewing frustum.
  • the process of calculating the shadow data corresponding to each object contained in each image area range can be implemented as follows: Determine the scene where the target object is located Included objects; for any of all objects, determine the affiliation of any object with each image area; determine the objects that belong to each image area based on the affiliation of all objects with each image area; For any image area range in each image area range, if the time difference between the current time and the time when the shadow data is updated last time reaches the corresponding shadow data update time interval, calculate the shadow data corresponding to the object belonging to any image area range .
  • the frustum corresponding to each image area range can be determined, and further, the process of determining the intersection relationship between any object and each image area range can be implemented as follows: determining that any object corresponds to each image area range respectively The intersection relationship between the viewing cones; based on the intersection relationship, determine the subordination relationship between any object and the range of each image area.
  • intersection relationship includes a complete inclusion relationship, a partial intersection relationship, and an exclusion relationship.
  • the partial intersection relationship is the relationship between the boundary of the object and the viewing cone.
  • any frustum completely contains any object in order to reduce the number of objects that need to be rendered, it can be set if any frustum completely contains any object, then it is determined that any object belongs to the image area range corresponding to any frustum. In other words, if any object is completely contained in the Inner frustum, it will not be rendered to the shadowmap corresponding to the middle image area and the outer image area. If any object is completely contained in the middle frustum, Then it is not rendered to the Shadowmap corresponding to the outer image area.
  • the judging process mainly includes: constructing the displacement matrix and rotation matrix of the Render; setting the Pos and EulerAngle of the Render to 0; recording Render.Bound The 8 mass points of Render.Bound are multiplied by the displacement matrix and rotation matrix of Render with the 8 mass points of Render.Bound to obtain 8 vertices of the compact bounding box.
  • the viewing frustum can be a rectangular parallelepiped, for example, an AABB or OBB bounding box, and the object can also be surrounded by a rectangular parallelepiped with a maximum range, and the rectangular parallelepiped can also be an AABB or OBB bounding box, for example.
  • a schematic of AABB and OBB bounding boxes can be seen in Figure 12.
  • an animation Frame disassembly is processed into multiple animation frames, so that the computing resources that need to be consumed in a short period of time can be dispersed into a longer period of time, and the computing resources that need to be consumed per unit of time are reduced.
  • the process of calculating the shadow data corresponding to each object contained in each image area range can be implemented as follows: Each object; according to the preset number, all objects are divided into multiple object sets; if the time difference between the current time and the time of the previous update of the shadow data reaches the corresponding shadow data update time interval, each object is generated in batches The shadow data of the objects in the collection, each batch generates the shadow data of all the objects in the object collection; all the shadow data are merged.
  • the process of generating shadow data in the case of disassembling an animation frame into multiple animation frames as shown in Figure 14 is similar to the process of directly processing an animation frame to generate shadow data as shown in Figure 10.
  • the main difference between them is that in the process of generating shadow data when an animation frame is disassembled into multiple animation frames, some steps need to be executed multiple times, and the steps that need to be executed multiple times are outlined by a dotted frame in Figure 14.
  • the steps to be executed multiple times include: SetRenderTarget; setting the VP matrix to the Shader; Commandbuffer.DrawRender; Graphics.Execute Commandbuffer.
  • the 5-frame operation process includes:
  • Frame 1 Calculate and render objects 1-1000 and generate them in the target Shadowmap.
  • Frame 2 Calculate and render the 1001-2000th objects, and superimpose the result on the target Shadowmap where the result of frame 1 is saved.
  • Frame 3 Calculate and render the 2001-3000 objects, and superimpose the results into the target Shadowmap where the results of frames 1-2 are saved.
  • Frame 4 Calculate and render 3001-4000 objects, and superimpose the results into the target Shadowmap that saves the results of frames 1-3.
  • Frame 5 Calculate and render 4001-5000 objects, and superimpose the results on the target Shadowmap where the results of frames 1-4 are saved.
  • the shadow data Before generating the shadow data corresponding to each object contained in each image area, the shadow data is stored in the off-screen space; after the shadow data is generated, the shadow data is blurred, and the blurred shadow The data is transferred from the off-screen space to the on-screen space to display the blurred shadow data.
  • the rendering result can be generated in advance and saved as off-screen without affecting the picture displayed on the current screen.
  • the image that can be displayed on the screen is on-screen, so when you need to display the off-screen image on the screen, you can transfer the off-screen image to the on-screen, so that the image can be displayed on the screen.
  • the obtained shadow image can also be de-aliased through soft shadow technology to obtain a better effect.
  • the rendering process can also be optimized through the Gizmos auxiliary debugging tool.
  • Gizmos is a visual debugging or auxiliary tool for scene views. It can be implemented in two ways, including OnDrawGizmo or OnDrawGizmosSelected methods.
  • the corresponding position of the target object in the shadow map to be drawn can be determined, so that based on the location of the target object, multiple image area ranges can be divided in the shadow map to be drawn.
  • the shadow data update time interval corresponding to the current image area range can be determined according to the levels corresponding to the different image area ranges, so that different image area ranges are set with different shadow data updates.
  • the time interval avoids that the entire shadow map to be drawn is updated with the same shadow data update frequency. Setting the respective shadow data update time intervals according to the specific conditions of different image areas can reduce the number of objects that need to update shadows, save computational overhead, improve the operating efficiency of game applications, and reduce the amount of shadow data storage. storage.
  • shadow data determining device of one or more embodiments of the present invention will be described in detail. Those skilled in the art can understand that all of these shadow data determining devices can be configured by using commercially available hardware components through the steps taught in this scheme.
  • FIG. 16 is a schematic structural diagram of a device for determining shadow data according to an embodiment of the present invention. As shown in FIG. 16, the device includes: a determination module 11, an update module 12, and a calculation module 13.
  • the determining module 11 is configured to determine the current corresponding position of the target object in the shadow map to be drawn when it is detected that the target object moves out of the corresponding target range in the shadow map to be drawn;
  • the determining module 11 is configured to determine the multiple image area ranges in the shadow map to be drawn and the hierarchical relationship between the image area ranges based on the current corresponding position of the target object in the shadow map to be drawn;
  • the update module 12 is configured to determine the shadow data update time interval corresponding to the respective image area ranges based on the respective levels corresponding to the respective image area ranges;
  • the calculation module 13 is configured to calculate the respective shadow data corresponding to each object contained in the respective image area based on the update time interval of the respective shadow data corresponding to the respective image area ranges.
  • the determining module 11 is set to:
  • a plurality of image area ranges in the shadow map to be drawn and a hierarchical relationship between the image area ranges are determined.
  • three image area ranges are set in the shadow map to be drawn, and the determining module 11 is set to:
  • the second layer peripheral grid area surrounding the first layer peripheral grid area is determined as the outer image area range.
  • the shadow data update time interval corresponding to the inner image area range is less than the shadow data update time interval corresponding to the middle image area range, and the shadow data update time interval corresponding to the middle image area range is less than the outer image area range.
  • the shadow data update interval corresponding to the layer image area range is less than the shadow data update time interval corresponding to the inner image area range.
  • calculation module 13 is set to:
  • the shadow data of the object of the target object type is generated
  • the shadow data of the object of the target object type is merged with the shadow data of the object of the other object type.
  • calculation module 13 is set to:
  • the determining module 11 is further configured to:
  • intersection relationship Determining an intersection relationship between any of the objects and the viewing cones corresponding to the respective image area ranges, where the intersection relationship includes a complete inclusion relationship, a partial intersection relationship, and an exclusion relationship;
  • the determining module 11 is set to:
  • any viewing frustum completely includes the any object, it is determined that the any object belongs to the image area range corresponding to the any viewing frustum.
  • calculation module 13 is set to:
  • Shadow data If the time difference between the current time and the time of the previous update of the shadow data reaches the corresponding shadow data update time interval, the shadow data of each object in the object set is generated in batches, and each batch is generated for all objects in the object set. Shadow data;
  • the device shown in FIG. 16 can execute the method for determining shadow data provided in the embodiments shown in FIG. 1 to FIG.
  • the structure of the apparatus for determining shadow data shown in FIG. 16 may be implemented as an electronic device.
  • the electronic device may include a processor 91 and a memory 92.
  • executable code is stored on the memory 92, and when the executable code is executed by the processor 91, the processor 91 can at least implement the functions provided in the embodiments shown in FIGS. 1 to 15 above.
  • the method of determining the shadow data may be implemented as an electronic device.
  • the electronic device may include a processor 91 and a memory 92.
  • executable code is stored on the memory 92, and when the executable code is executed by the processor 91, the processor 91 can at least implement the functions provided in the embodiments shown in FIGS. 1 to 15 above. The method of determining the shadow data.
  • the electronic device may also include a communication interface 93 for communicating with other devices.
  • the systems, methods, and devices of the embodiments of the present invention can be implemented as pure software (for example, a software program written in Java), or as pure hardware (for example, a dedicated ASIC chip or FPGA chip) as required. It can also be implemented as a system that combines software and hardware (for example, a firmware system storing fixed codes or a system with general-purpose memory and a processor).
  • Another aspect of the present invention is a computer-readable medium on which computer-readable instructions are stored, and when the instructions are executed, the method of each embodiment of the present invention can be implemented.

Landscapes

  • Engineering & Computer Science (AREA)
  • Multimedia (AREA)
  • Human Computer Interaction (AREA)
  • Computer Graphics (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Processing Or Creating Images (AREA)

Abstract

一种阴影数据确定方法、装置、设备和可读介质,该方法包括:当检测到目标对象移动出待绘制阴影图中对应的目标范围时,确定目标对象当前在待绘制阴影图中对应的位置(101);基于目标对象当前在待绘制阴影图中对应的位置,确定待绘制阴影图中的多个图像区域范围以及各图像区域范围之间的层级关系(102);基于各图像区域范围分别对应的层级,确定各图像区域范围分别对应的阴影数据更新时间间隔(103);基于各图像区域范围分别对应的阴影数据更新时间间隔,计算各图像区域范围内包含的各物体分别对应的阴影数据。通过该方法,能够提高游戏应用程序的运行效率,同时还能减少用于存储阴影数据的存储空间。

Description

阴影数据确定方法、装置、设备和可读介质
本申请要求于2020年6月18日提交的申请号为202010562137.1、发明名称为“阴影数据确定方法、装置、设备和可读介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本发明涉及数据处理技术领域,尤其涉及一种阴影数据确定方法、装置、设备和可读介质。
背景技术
为了使得游戏体验更加逼真,在通过游戏应用程序进行游戏的过程中,会实时绘制玩家所操控的对象所处游戏环境中包含的各物体的阴影图,这样游戏环境中的各物体就有了影子,使得游戏体验更加逼真。
由于游戏环境比较复杂,经常性的游戏环境中所包含的物体繁多,导致实时绘制游戏环境中包含的各物体的阴影图的计算开销较大,容易在游戏执行的过程中出现卡顿等现象。
发明内容
本发明实施例提供一种阴影数据确定方法、装置、设备和存储介质,用以降低计算开销,提高游戏执行效率。
第一方面,本发明实施例提供一种阴影数据确定方法,该方法包括:
当检测到目标对象移动出待绘制阴影图中对应的目标范围时,确定所述目标对象当前在所述待绘制阴影图中对应的位置;
基于所述目标对象当前在待绘制阴影图中对应的位置,确定所述待绘制阴影图中的多个图像区域范围以及各图像区域范围之间的层级关系;
基于所述各图像区域范围分别对应的层级,确定所述各图像区域范围分别对应的阴影数据更新时间间隔;
基于所述各图像区域范围分别对应的阴影数据更新时间间隔,计算所述各图像区域范围内包含的各物体分别对应的阴影数据。
第二方面,本发明实施例提供一种阴影数据确定装置,包括:
确定模块,设置为当检测到目标对象移动出待绘制阴影图中对应的目标范围时,确定所述目标对象当前在所述待绘制阴影图中对应的位置;
所述确定模块,设置为基于所述目标对象当前在待绘制阴影图中对应的位置,确定所述待绘制阴影图中的多个图像区域范围以及各图像区域范围之间的层级关系;
更新模块,设置为基于所述各图像区域范围分别对应的层级,确定所述各图像区域范围分别对应的阴影数据更新时间间隔;
计算模块,设置为基于所述各图像区域范围分别对应的阴影数据更新时间间隔,计算所述各图像区域范围内包含的各物体分别对应的阴影数据。
第三方面,本发明实施例提供一种电子设备,包括处理器和存储器,所述存储器中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、至少一段程序、代码集或指令集由所述处理器加载并执行以实现第一方面中的阴影数据确定方法。
第四方面,本发明实施例提供了一种计算机可读介质,其上存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、至少一段程序、代码集或指令集由处理器加载并执行以实现第一方面中的阴影数据确定方法。
通过本发明实施例提供的方法,可以确定目标对象在待绘制阴影图中对应的位置,这样可以基于目标对象所在位置,在待绘制阴影图中划分出多个图像区域范围。针对不同的图像区域范围对应有不同的层级,可以按照不同图像区域范围对应的层级,来确定当前的图像区域范围对应的阴影数据更新时间间隔,这样不同的图像区域范围设置有不同的阴影数据更新时间间隔,避免了整个待绘制阴影图都使用同一阴影数据更新频率进行更新。针对不同的图像区域范围 的具体情况设置各自的阴影数据更新时间间隔,可以实现实时阴影,游戏体验更加逼真,同时还可以降低实现实时阴影所需要的性能开销,能够降低需要更新阴影的物体的数量,节约计算开销,提高游戏应用程序的运行效率,同时还能减少用于存储阴影数据的存储空间。解决了更新阴影数据所需较大的计算开销的问题,采用本发明能够实现降低实现实时阴影所需要的性能开销,提高游戏应用程序的运行效率且减少用于存储阴影数据的存储空间的效果。
附图说明
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作一简单地介绍,显而易见地,下面描述中的附图是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种阴影数据确定方法的流程图示意图;
图2为本发明实施例提供的一种Shadowmap原理的示意图;
图3为本发明实施例提供的一种内层图像区域范围示意图;
图4为本发明实施例提供的一种多个图像区域范围的示意图;
图5为本发明实施例提供的一种多个图像区域范围在3D场景下的示意图;
图6为本发明实施例提供的一种阴影数据存储示意图;
图7为本发明实施例提供的一种对内层图像区域范围中目标对象绘制阴影的结果示意图;
图8为本发明实施例提供的另一种阴影数据存储示意图;
图9为本发明实施例提供的一种动态生成内层图像区域范围的阴影数据的流程示意图;
图10为本发明实施例提供的一种阴影数据生成的流程示意图;
图11为本发明实施例提供的一种判断物体和视锥体的相交关系的流程示意图;
图12为本发明实施例提供的一种示例性的AABB和OBB包围盒的示意图;
图13为本发明实施例提供的一种对比计算一个动画帧所需的计算资源与解为多个动画帧所需的计算资源的情况的示意图;
图14为本发明实施例提供的另一种阴影数据生成的流程示意图;
图15为本发明实施例提供的一种模糊处理的结果示意图;
图16为本发明实施例提供的一种阴影数据确定装置的结构示意图;
图17为本发明实施例提供的一种电子设备的结构示意图。
具体实施方式
为使本发明实施例的目的、技术方案和优点更加清楚,下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。
在本发明实施例中使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本发明。在本发明实施例和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义,“多种”一般包含至少两种。
取决于语境,如在此所使用的词语“如果”、“若”可以被解释成为“在……时”或“当……时”或“响应于确定”或“响应于检测”。类似地,取决于语境,短语“如果确定”或“如果检测(陈述的条件或事件)”可以被解释成为“当确定时”或“响应于确定”或“当检测(陈述的条件或事件)时”或“响应于检测(陈述的条件或事件)”。
另外,下述各方法实施例中的步骤时序仅为一种举例,而非严格限定。
图1为本发明实施例提供的一种阴影数据确定方法的流程图,如图1所示,该方法包括如下步骤:
101、当检测到目标对象移动出待绘制阴影图中对应的目标范围时,确定目标对象当前在待绘制阴影图中对应的位置。
102、基于目标对象当前在待绘制阴影图中对应的位置,确定待绘制阴影图中的多个图像区域范围以及各图像区域范围之间的层级关系。
103、基于各图像区域范围分别对应的层级,确定各图像区域范围分别对应的阴影数据更新时间间隔。
104、基于各图像区域范围分别对应的层级,确定各图像区域范围分别对应的阴影数据更新时间间隔。
实际应用中,在作为玩家的用户使用游戏应用程序的过程中,需要根据用户对目标对象的控制操作,逐帧渲染用于在显示器上显示的游戏画面。其中,目标对象可以是用户的代理,例如是模拟人物等。为了使得游戏的体验更加的逼真,除了根据用户对目标对象的操控绘制出目标对象在游戏环境中移动的情形之外,还可以绘制在目标对象移动的过程中目标对象的影子的变化情况,以及目标对象周围的一些物体的阴影。
为了得到目标对象以及周围物体的阴影,可以假设在游戏环境中设置一光源,分析当该光源照射到游戏环境中的目标对象以及各物体时,会产生怎样的阴影,根据分析结果生成阴影数据(Shadowmap)。
下面大致介绍一些Shadowmap制作原理的内容。如图2所示,是Shadowmap原理的示意图。在图中,太阳形状的图标表示为光源所在位置,方框形状的图标表示一个物体,假设从光源位置出发散发方向光,那么正对光源的物体表面是明亮的,背对光源的物体表面后面的空间会形成一个阴影区域。对于计算机来说,可以计算光源到物体上的像素以及空间中的像素的深度,如果在一条光线上的物体上的某一像素的深度大于空间中的像素的深度,那么该空间中的像素就是有阴影的。
在用户进行游戏的过程中,对于当前时刻来说,首先可以确定操控的目标对象周围的游戏环境,在游戏环境中可以设置游戏所需的房子、树等物体。假设游戏环境中的地图可以通过网格切分,那么则可以确定目标对象当前所在的目标网格区域。假设当前有一张空白的待绘制阴影图,可以在上面相应的位置上添加目标对象或者物体的阴影,该待绘制阴影图与游戏环境中的地图大小一 致,且通过同样的网格切分,那么能够通过目标对象在地图中的目标网格区域找到待绘制阴影图中对应位置上的目标网格区域。然后将目标网格区域周围的几组网格划分为多个图像区域范围,并确定这些图像区域范围之间的层级关系。距离目标网格区域最近的图像区域范围属于内层图像区域范围,距离目标网格区域最远的图像区域范围属于外层图像区域范围。
可选地,在本发明实施例中以待绘制阴影图中设置有三个图像区域范围为例,基于目标网格区域,确定待绘制阴影图中的多个图像区域范围以及各图像区域范围之间的层级关系的过程具体可以实现为:以目标网格区域为中心,确定三个九宫格区域,其中,三个九宫格区域中宫格尺寸各不相同,三个九宫格区域中宫格尺寸最小的区域作为内层图像区域范围,三个九宫格区域中宫格尺寸最大的区域作为外层图像区域范围,三个九宫格区域中除内层图像区域范围以及外层图像区域范围之外的区域作为中层图像区域范围。
为了便于理解,以图3和图4为例来说明确定多个图像区域范围的过程。在图中,以游戏人物所在的目标网格区域为中心,目标网格区域被其周围的8个网格区域所包围,目标网格区域和其周围的8个网格区域形成九宫格区域,假设该九宫格区域为划分出的内层图像区域范围。
然后仍以游戏人物所在的目标网格区域为中心,这次扩大九宫格中宫格的尺寸,得到一个比内层图像区域范围的九宫格更大的九宫格,该更大的九宫格可以作为中层图像区域范围。再然后,还可以以游戏人物所在的目标网格区域为中心,继续将九宫格中宫格的尺寸扩大,得到一个比中层图像区域范围的九宫格更大的九宫格,该更大的九宫格可以作为外层图像区域范围。可见,以目标网格区域作为中心,向外扩散确定不同层级的多个图像区域范围。划分得到的多个图像区域范围在3D场景下的展示结果还可以见图5所示。由图可见,以玩家为中心共有三个九宫格,最里面一层的九宫格即为上述内层图像区域范围,中间一层的九宫格即为上述中层图像区域范围,最外面一层的九宫格即为上述外层图像区域范围。
在实际应用中,可以通过用于调节内层图像区域范围、中层图像区域范围 以及外层图像区域范围分别对应的尺寸界面来调节图像区域范围的大小。在本发明实施例中,技术人员可以凭借经验和对动画模型的观察结果来调整图像区域范围的大小。例如,技术人员可以观察在某一特定尺寸下,所计算出的阴影数据在显示在屏幕上时是否存在明显的锯齿,或者阴影数据显示的精细程度是否能够被接受等。在调整到满意的大小时,当前的图像区域范围的大小即可作为最终结果。
在一种可能的实现方式中,可以创建Texture2DArray对象来存储三个图像区域范围的阴影数据。如图6所示,在Texture2DArray对象中的Slice0中可以存储内层图像区域范围的阴影数据,在Slice1中可以存储中层图像区域范围的阴影数据,在Slice2中可以存储外层图像区域范围的阴影数据。
在划分好多个图像区域范围并确定好它们之间的层级关系之后,对于每个图像区域范围可以设置对应的阴影数据更新时间间隔。
对于整个游戏环境中的目标对象以及各物体来说,无需在每帧游戏画面中都实时计算它们的阴影,因为用户对有些距离目标对象较远的物体的关注度并不高,同时有些物体如房子、树等它们是静态的,它们的阴影也是不变的,因此无需在每帧游戏画面中都计算一次这些静物的阴影。
基于此,在本发明实施例中,可以设置内层图像区域范围对应的阴影数据更新时间间隔小于中层图像区域范围对应的阴影数据更新时间间隔,中层图像区域范围对应的阴影数据更新时间间隔小于外层图像区域范围对应的阴影数据更新时间间隔。
举例来说,可以将内层图像区域范围对应的阴影数据更新时间间隔设置为1,将中层图像区域范围对应的阴影数据更新时间间隔设置为2,将外层图像区域范围对应的阴影数据更新时间间隔设置为3。
通过这样的阴影数据更新时间间隔设置方式,使得与目标对象最近的物体以及目标对象本身的阴影能够得到实时的更新,而对于用户不太关注的那些距离目标对象较远的物体,可以隔一段时间更新一次它们的阴影。进而,整体上可以降低需要更新阴影的物体的数量,节约计算开销,提高游戏应用程序的运 行效率,同时还能减少用于存储阴影数据的存储空间。
在设置好各图像区域范围分别对应的阴影数据更新时间间隔之后,可以基于各图像区域范围分别对应的层级,确定各图像区域范围分别对应的阴影数据更新时间间隔。例如,对于内层图像区域范围来说,假设内层图像区域范围中有目标对象、房子A和房子B,上一次计算目标对象、房子A和房子B的阴影的时刻为15'21”,在15'21”经过时间间隔1”之后,可以再次计算目标对象、房子A和房子B的阴影(前提是目标对象未移动出上一次计算阴影时所在的九宫格区域)。需要说明的是,更新时间间隔除了可以是具体的时长之外,也可以通过帧数表示,比如隔几个动画帧计算一次图像区域范围内物体的阴影。
可以理解的是,除了在达到任一图像区域范围对应的阴影数据更新时间时,可以重新计算该任一图像区域范围内物体的阴影之外,还可以在检测到目标对象移动出当前所在的内层九宫格区域时,触发执行重新计算阴影数据的过程。一种对内层图像区域范围中目标对象绘制阴影的结果的示例可见图7所示。
可选地,由于内层图像区域范围中除了目标对象之外,还可能存在其他的物体,而这些物体有的可能是动态的,比如车子、动物,有的则可能是静态的,比如房子、树等,可以对这些物体进行分类。根据分类结果,在当前时间与前一次进行阴影数据更新时间之间的时间差达到内层图像区域范围对应的阴影数据更新时间间隔时,只对属于目标物体类型的物体的阴影进行更新,而对于那些内层图像区域范围中除了属于目标物体类型的物体之外的物体,在其他物体类型的物体对应的阴影更新时间满足预设条件时,再重新计算其他物体类型的物体的阴影。
上述目标物体类型的物体可以是动态类型的物体,或者比较重要的需要仔细刻画的物体等。
可选地,在其他物体类型的物体对应的阴影更新时间满足预设条件时,重新计算其他物体类型的物体的阴影的过程可以实现为:若当前时刻与前一次对其他物体类型的物体的阴影进行计算的时刻之间的时间差达到预设时间间隔时,则重新计算其他物体类型的物体的阴影。
若当前时刻与前一次对其他物体类型的物体的阴影进行计算的时刻之间的时间差未达到预设时间间隔时,那么就无需重新计算其他物体类型的物体的阴影。
在一种可能的实现方式中,可以创建Texture2DArray对象以及CurlnnerRT来存储三个图像区域范围的阴影数据。如图8所示,在Texture2DArray对象中的Slice0中可以存储内层图像区域范围的阴影数据,具体可以是动态计算出的内层图像区域范围内目标物体类型的物体以及其他物体类型的物体的阴影数据,在Slice1中可以存储中层图像区域范围的阴影数据,在Slice2中可以存储外层图像区域范围的阴影数据。其中,可以将动态计算的内层图像区域范围内目标物体类型的物体以及其他物体类型的物体的阴影数据合并存储到CurlnnerRT中。
例如,如图9所示,在Frame0(Frame表示视频帧)中,生成Inner(Inner表示内层图像区域范围内目标物体类型的物体以及其他物体类型的物体的阴影数据),将生成的Inner结果保存到CurlnnerRT中。在Frame1中,生成Dynamic(Dynamic表示内层图像区域范围内目标物体类型的物体的阴影数据),然后将生成的Dynamic结果与CurlnnerRT中保存的内容进行min或者max操作,再将经过min或者max操作的结果保存到Slice0。Frame2、3、4的处理同Frame1。在Frame5中,生成Inner,将生成的Inner结果保存到CurlnnerRT中。
通过这样的方式,可以使得不必对静态或者不重要的那些物体频繁的进行阴影的更新处理,进而可以减少需要计算阴影的物体的数量,从而能够节约计算开销,提高游戏应用程序的运行效率,同时还能减少用于存储阴影数据的存储空间。
此外,可以将动态计算的内层图像区域范围内目标物体类型的物体以及其他物体类型的物体的阴影数据合并存储到Slice0中,在渲染游戏环境时,直接使用Slice0中存储的结果,减少采样次数。
上面介绍了对多个图像区域范围中的某一图像区域范围内的物体的阴影进行更新的时间或者条件,下面将介绍在达到那样的时间或者条件时,具体可以 如何生成某一图像区域范围内的物体的阴影数据的过程。
如图10所示,概况来说,生成阴影数据的主要过程包括:计算灯光空间正交投影(英文简写为VP)矩阵;计算物体和视锥体的相交关系;声明Render Texture;SetRenderTarget;ClearRenderTarget;设置VP矩阵给Shader;Commandbuffer.DrawRender(和视锥体相交的物体);Graphics.Execute Commandbuffer;把生成的RT传给Shader;再次把生成的RT传给Shader;采样_Shadowmap计算阴影。
其中,视锥体(frustum),是指场景中摄像机的可见的一个锥体范围。它有上、下、左、右、近、远,共6个面组成。在视锥体内的景物可见,反之则不可见。
首先介绍VP矩阵的计算过程,VP矩阵的计算过程主要可以包括:获取方向光Forward方向;给定up向量(0,1,0);基于方向光Forward方向和up向量,进行多次叉乘,得到灯光空间的基准轴向量;确定灯光空间基准轴矩阵;确定灯光在世界空间中的坐标;确定位移矩阵;将灯光空间基准轴矩阵和位移矩阵进行相乘,得到灯光空间矩阵,可以通过{matrix_V}函数实现;获取世界空间的包围盒的8个顶点;基于世界空间的包围盒的8个顶点和灯光空间矩阵,转换到灯光空间;求出最大最小坐标;计算视锥体,可以通过参数widht,height,near,far实现;确定灯光空间正交投影矩阵,可以通过(matrix_P)函数实现;将灯光空间矩阵与灯光空间正交投影矩阵进行相乘,得到灯光空间正交投影矩阵的最终结果,可以通过(matrix_VP)函数实现。
在获得VP矩阵之后,可以基于VP矩阵,计算物体和视锥体的相交关系。需要说明的是,对于游戏环境中的每个物体来说,它与目标对象之间的距离不等,有的离目标对象比较近,有的则离目标对象比较远。离目标对象比较近的那些物体可能会落在内层图像区域范围,稍远一些的物体可能会落在中层图像区域范围,再远一些的物体可能会落在外层图像区域范围。假设每个图像区域范围都对应有一个视锥体,那么则有内层图像区域范围对应的Inner视锥体、中层图像区域范围对应的Middle视锥体以及外层图像区域范围对应的Outer视 锥体。进而,如果某一物体落入某一视锥体,那么就可以认为该某一物体属于该落入的视锥体对应的图像区域范围。在判断某一物体落入哪个视锥体时,可以以Inner视锥体、Middle视锥体以及Outer视锥体的顺序依次进行判断。
基于上述分析,可选地,基于各图像区域范围分别对应的阴影数据更新时间间隔,计算各图像区域范围内包含的各物体分别对应的阴影数据的过程可以实现为:确定目标对象所在的场景中包含的各物体;对于所有物体中的任一物体,确定任一物体分别与各图像区域范围的从属关系;基于所有物体分别与各图像区域范围的从属关系,确定属于各图像区域范围的物体;对于各图像区域范围中的任一图像区域范围,若当前时间与前一次更新阴影数据时间之间的时间差达到对应的阴影数据更新时间间隔时,计算属于任一图像区域范围的物体对应的阴影数据。
可选地,还可以确定各图像区域范围分别对应的视锥体,进而,确定任一物体分别与各图像区域范围的相交关系的过程可以实现为:确定任一物体与各图像区域范围分别对应的视锥体之间的相交关系;基于相交关系,确定任一物体分别与各图像区域范围的从属关系。
在实际应用中,可以判断任一物体与各图像区域范围分别对应的视锥体之间的相交关系,相交关系包括完全包含关系、部分相交关系和不包含关系。其中,部分相交关系是物体边界与视锥体有交叉情况的关系。
在本发明实施例中,为了减少需要渲染的物体的数量,可以设定若任一视锥体完全包含任一物体,则确定任一物体属于任一视锥体对应的图像区域范围。换句话说,如果任一物体完全包含在Inner视锥体中,则不将其渲染到中层图像区域范围以及外层图像区域范围对应的Shadowmap,如果任一物体完全包含在Middle视锥体中,则不将其渲染到外层图像区域范围对应的Shadowmap。
下面将介绍具体判断物体和视锥体的相交关系的过程,如图11所示,判断过程主要包括:构建Render的位移矩阵和旋转矩阵;将Render的Pos和EulerAngle设置为0;记录Render.Bound的8个质点;将Render的位移矩阵和旋转矩阵与Render.Bound的8个质点相乘,得到紧凑包围盒的8个顶点。获 取灯光空间矩阵(matrix_VP);将紧凑包围盒的8个顶点与灯光空间矩阵相乘,得到灯光空间的8个坐标;找出最大和最小坐标;获取视锥体信息(widht,height,near,far);将找出的最大和最小坐标与视锥体信息进行比较,得出Render和视锥体的相交关系。
在上述过程中,视锥体可以是一个长方体,例如可以是AABB或OBB包围盒,物体也可以通过一个最大范围的长方体包围住,该长方体例如也可以是AABB或OBB包围盒。AABB和OBB包围盒的一种示意可见图12所示。
在Commandbuffer.DrawRender的过程中,可以在灯光位置放置一个Camera的物体,然后设置Camera.depthTextureMode为DepthTextureMode.Depth,在计算好VP矩阵之后,设置Camera的参数,包括ratio、widht,height,near,far等。然后设置一个RT给Camera的TargetBuffer或targetTexture对象,设置globalMaximumLOD为-1,确保不渲染任何物体。最后调用Camera.Render方法,此时可以调用Lightmode=Shadowcaster的pass,渲染结果则可以保存到RT上,最终得到Shadowmap。
可以理解的是,生成阴影数据的过程所消耗的计算量较大,对处理器造成的压力较大,为了减轻处理器在计算阴影数据过程中短时间内需要消耗的计算资源,可以将一个动画帧拆解为多个动画帧进行处理,这样可以将短时间内需要消耗的计算资源分散到较长时长内,进而单位时长所需消耗的计算资源降低。
基于此,可选地,基于各图像区域范围分别对应的阴影数据更新时间间隔,计算各图像区域范围内包含的各物体分别对应的阴影数据的过程可以实现为:确定目标对象所在的场景中包含的各物体;按照预设数量,将所有物体划分为多个物体集合;若当前时间与前一次更新阴影数据时间之间的时间差达到对应的阴影数据更新时间间隔时,分批次生成每个物体集合中的物体的阴影数据,每个批次生成一个物体集合中所有物体的阴影数据;将所有阴影数据进行合并。
在实际应用中,直接计算一个动画帧所需的计算资源与解为多个动画帧所需的计算资源的情况对比可见图13所示。值得注意的是,由于将一个动画帧拆解为多个动画帧进行处理,在得到拆解后的每个动画帧对应的阴影数据之后, 还需将多个阴影数据进行合并,这样合并所得结果与直接对一个动画帧进行处理所得结果是一致的。
如图14所示的在将一个动画帧拆解为多个动画帧的情况下生成阴影数据的过程,与图10所示的直接对一个动画帧进行处理以生成阴影数据的过程类似,它们之间的主要区别是在将一个动画帧拆解为多个动画帧的情况下生成阴影数据的过程中,有些步骤需要多次执行,需要多次执行的步骤在图14中通过虚线框框出,需要多次执行的步骤包括:SetRenderTarget;设置VP矩阵给Shader;Commandbuffer.DrawRender;Graphics.Execute Commandbuffer。
为了便于理解将一个动画帧拆解为多个动画帧的情况下生成阴影数据的过程,以一个具体的生成阴影数据的过程为例进行说明。假设当前有一个游戏场景需要渲染,在该游戏场景中假设共有5000个物体,现在需要生成这5000个物体对应的Shadowmap,那么可以拆解成5帧来完成5000个物体对应的Shadowmap的计算,这5帧的操作过程包括:
第1帧:对第1-1000个物体进行计算和渲染,生成到目标Shadowmap中。
第2帧:对第1001-2000个物体进行计算和渲染,将结果叠加到保存有第1帧结果的目标Shadowmap中。
第3帧:对2001-3000个物体进行计算和渲染,将结果叠加到保存有第1-2帧结果的目标Shadowmap中。
第4帧:对3001-4000个物体进行计算和渲染,将结果叠加到保存有第1-3帧结果的目标Shadowmap中。
第5帧:对4001-5000个物体进行计算和渲染,将结果叠加到保存有第1-4帧结果的目标Shadowmap中。
值得注意的是,图14中需要多次执行的步骤可以用于实现上述将结果叠加到前一帧结果的目的。
下面介绍离屏RT(RenderTexture)的过程。在生成各图像区域范围内包含的各物体分别对应的阴影数据之前,将阴影数据存储到离屏空间中;在生成阴影数据之后,对阴影数据进行模糊(Blur)处理,将模糊处理后的阴影数据从 离屏空间转存到在屏空间,以对模糊处理后的阴影数据进行展示。
上述模糊处理的效果可见图15所示。
在进行初始化时,可以设置给Shader,且可以只设置一次。在生成Shadowmap时,可以将RenderTarget设置为OffScreenRT。然后在Shadowmap生成结束之后,可以对OffScreenRT进行模糊(Blur)或者其他处理。最后可以把OffScreenRT设置给OnScreenRT。
可以把渲染结果保存到一个图像中,如果该图像是离屏的,那么该图像不会被显示到屏幕上。这样做,无论如何修改该图像,都不会影响当前屏幕所展示的画面,同时在实际应用中,可以预先生成渲染结果并保存为离屏,不会影响当前屏幕显示的画面。能够显示在屏幕上的图像为在屏,因此当需要将离屏的图像展示在屏幕上时,可以将离屏的图像传到在屏,这样图像就可以在屏幕中进行展示了。
为了取得更好的渲染效果,还可以对得到的阴影图像通过软阴影技术,进行去锯齿处理,以获得更佳的效果。进一步地,还可以通过Gizmos辅助调试工具优化渲染过程。Gizmos是场景视图的可视化调试或辅助工具,可以通过两种方式实现,包括OnDrawGizmo或者OnDrawGizmosSelected方法。
通过本发明实施例提供的方法,可以确定目标对象在待绘制阴影图中对应的位置,这样可以基于目标对象所在位置,在待绘制阴影图中划分出多个图像区域范围。针对不同的图像区域范围对应有不同的层级,可以按照不同图像区域范围对应的层级,来确定当前的图像区域范围对应的阴影数据更新时间间隔,这样不同的图像区域范围设置有不同的阴影数据更新时间间隔,避免了整个待绘制阴影图都使用同一阴影数据更新频率进行更新。针对不同的图像区域范围的具体情况设置各自的阴影数据更新时间间隔,能够降低需要更新阴影的物体的数量,节约计算开销,提高游戏应用程序的运行效率,同时还能减少用于存储阴影数据的存储空间。
以下将详细描述本发明的一个或多个实施例的阴影数据确定装置。本领域技术人员可以理解,这些阴影数据确定装置均可使用市售的硬件组件通过本方 案所教导的步骤进行配置来构成。
图16为本发明实施例提供的一种阴影数据确定装置的结构示意图,如图16所示,该装置包括:确定模块11、更新模块12、计算模块13。
确定模块11,设置为当检测到目标对象移动出待绘制阴影图中对应的目标范围时,确定所述目标对象当前在所述待绘制阴影图中对应的位置;
所述确定模块11,设置为基于所述目标对象当前在待绘制阴影图中对应的位置,确定所述待绘制阴影图中的多个图像区域范围以及各图像区域范围之间的层级关系;
更新模块12,设置为基于所述各图像区域范围分别对应的层级,确定所述各图像区域范围分别对应的阴影数据更新时间间隔;
计算模块13,设置为基于所述各图像区域范围分别对应的阴影数据更新时间间隔,计算所述各图像区域范围内包含的各物体分别对应的阴影数据。
可选地,所述确定模块11,设置为:
获取所述待绘制阴影图对应的网格区域;
在所述网格区域中,确定所述目标对象当前所在的目标网格区域;
基于所述目标网格区域,确定所述待绘制阴影图中的多个图像区域范围以及各图像区域范围之间的层级关系。
可选地,所述待绘制阴影图中设置有三个图像区域范围,所述确定模块11,设置为:
确定以所述目标网格区域为中心的九宫格区域,作为内层图像区域范围;
确定包围所述九宫格区域的第一层外围网格区域,作为中层图像区域范围;
确定包围所述第一层外围网格区域的第二层外围网格区域,作为外层图像区域范围。
可选地,所述内层图像区域范围对应的阴影数据更新时间间隔小于所述中层图像区域范围对应的阴影数据更新时间间隔,所述中层图像区域范围对应的阴影数据更新时间间隔小于所述外层图像区域范围对应的阴影数据更新时间间隔。
可选地,所述计算模块13,设置为:
若当前的图像区域范围为所述内层图像区域范围,则确定所述内层图像区域范围中的各物体,所述物体包括所述目标对象;
确定所述各物体分别对应的物体类型;
若当前时间与前一次更新阴影数据时间之间的时间差达到所述内层图像区域范围对应的阴影数据更新时间间隔时,生成目标物体类型的物体的阴影数据;
获取其他物体类型的物体的阴影数据,所述其他物体类型的物体为所述各物体中除所述目标物体类型的物体之外的物体;
将所述目标物体类型的物体的阴影数据与所述其他物体类型的物体的阴影数据进行合并。
可选地,所述计算模块13,设置为:
确定所述目标对象所在的场景中包含的各物体;
对于所有物体中的任一物体,确定所述任一物体分别与所述各图像区域范围的从属关系;
基于所有物体分别与所述各图像区域范围的从属关系,确定属于所述各图像区域范围的物体;
对于所述各图像区域范围中的任一图像区域范围,若当前时间与前一次更新阴影数据时间之间的时间差达到对应的阴影数据更新时间间隔时,获取属于所述任一图像区域范围的物体对应的阴影数据。
可选地,所述确定模块11,还设置为:
确定所述各图像区域范围分别对应的视锥体;
确定所述任一物体与所述各图像区域范围分别对应的视锥体之间的相交关系,所述相交关系包括完全包含关系、部分相交关系和不包含关系;
基于所述相交关系,确定所述任一物体分别与所述各图像区域范围的从属关系。
可选地,所述确定模块11,设置为:
若任一视锥体完全包含所述任一物体,则确定所述任一物体属于所述任一 视锥体对应的图像区域范围。
可选地,所述计算模块13,设置为:
确定所述目标对象所在的场景中包含的各物体;
按照预设数量,将所有物体划分为多个物体集合;
若当前时间与前一次更新阴影数据时间之间的时间差达到对应的阴影数据更新时间间隔时,分批次生成每个物体集合中的物体的阴影数据,每个批次生成一个物体集合中所有物体的阴影数据;
将所有阴影数据进行合并。
图16所示装置可以执行前述图1至图15所示实施例中提供的阴影数据确定方法,详细的执行过程和技术效果参见前述实施例中的描述,在此不再赘述。
在一个可能的设计中,上述图16所示阴影数据确定装置的结构可实现为一电子设备,如图17所示,该电子设备可以包括:处理器91、存储器92。其中,所述存储器92上存储有可执行代码,当所述可执行代码被所述处理器91执行时,使所述处理器91至少可以实现如前述图1至图15所示实施例中提供的阴影数据确定方法。
可选地,该电子设备中还可以包括通信接口93,用于与其他设备进行通信。
根据需要,本发明各实施例的系统、方法和装置可以实现为纯粹的软件(例如用Java来编写的软件程序),也可以根据需要实现为纯粹的硬件(例如专用ASIC芯片或FPGA芯片),还可以实现为结合了软件和硬件的系统(例如存储有固定代码的固件系统或者带有通用存储器和处理器的系统)。
本发明的另一个方面是一种计算机可读介质,其上存储有计算机可读指令,所述指令被执行时可实施本发明各实施例的方法。
以上已经描述了本发明的各实施例,上述说明是示例性的,并非穷尽性的,并且也不限于所公开的各实施例。在不偏离所说明的各实施例的范围和精神的情况下,对于本技术领域的普通技术人员来说许多修改和变更都是显而易见的。要求保护的主题的范围仅由所附的权利要求进行限定。

Claims (14)

  1. 一种阴影数据确定方法,其特征在于,包括:
    当检测到目标对象移动出待绘制阴影图中对应的目标范围时,确定所述目标对象当前在所述待绘制阴影图中对应的位置;
    基于所述目标对象当前在待绘制阴影图中对应的位置,确定所述待绘制阴影图中的多个图像区域范围以及各图像区域范围之间的层级关系;
    基于所述各图像区域范围分别对应的层级,确定所述各图像区域范围分别对应的阴影数据更新时间间隔;
    基于所述各图像区域范围分别对应的阴影数据更新时间间隔,计算所述各图像区域范围内包含的各物体分别对应的阴影数据。
  2. 根据权利要求1所述的方法,其特征在于,所述基于所述目标对象当前在待绘制阴影图中对应的位置,确定所述待绘制阴影图中的多个图像区域范围以及各图像区域范围之间的层级关系,包括:
    获取所述待绘制阴影图对应的网格区域;
    在所述网格区域中,确定所述目标对象当前所在的目标网格区域;
    基于所述目标网格区域,确定所述待绘制阴影图中的多个图像区域范围以及各图像区域范围之间的层级关系。
  3. 根据权利要求2所述的方法,其特征在于,所述待绘制阴影图中设置有三个图像区域范围,所述基于所述目标网格区域,确定所述待绘制阴影图中的多个图像区域范围以及各图像区域范围之间的层级关系,包括:
    以所述目标网格区域为中心,确定三个九宫格区域,其中,所述三个九宫格区域中宫格尺寸各不相同,所述三个九宫格区域中宫格尺寸最小的区域作为内层图像区域范围,所述三个九宫格区域中宫格尺寸最大的区域作为外层图像区域范围,所述三个九宫格区域中除所述内层图像区域范围以及所述外层图像区域范围之外的区域作为中层图像区域范围。
  4. 根据权利要求3所述的方法,其特征在于,所述内层图像区域范围对应 的阴影数据更新时间间隔小于所述中层图像区域范围对应的阴影数据更新时间间隔,所述中层图像区域范围对应的阴影数据更新时间间隔小于所述外层图像区域范围对应的阴影数据更新时间间隔。
  5. 根据权利要求3所述的方法,其特征在于,所述基于所述各图像区域范围分别对应的阴影数据更新时间间隔,计算所述各图像区域范围内包含的各物体分别对应的阴影数据,包括:
    若当前的图像区域范围为所述内层图像区域范围,则确定所述内层图像区域范围中的各物体,所述物体包括所述目标对象;
    确定所述各物体分别对应的物体类型;
    若当前时间与前一次更新阴影数据时间之间的时间差达到所述内层图像区域范围对应的阴影数据更新时间间隔时,生成目标物体类型的物体的阴影数据;
    获取其他物体类型的物体的阴影数据,所述其他物体类型的物体为所述各物体中除所述目标物体类型的物体之外的物体;
    将所述目标物体类型的物体的阴影数据与所述其他物体类型的物体的阴影数据进行合并。
  6. 根据权利要求1所述的方法,其特征在于,所述基于所述各图像区域范围分别对应的阴影数据更新时间间隔,计算所述各图像区域范围内包含的各物体分别对应的阴影数据,包括:
    确定所述目标对象所在的场景中包含的各物体;
    对于所有物体中的任一物体,确定所述任一物体分别与所述各图像区域范围的从属关系;
    基于所有物体分别与所述各图像区域范围的从属关系,确定属于所述各图像区域范围的物体;
    对于所述各图像区域范围中的任一图像区域范围,若当前时间与前一次更新阴影数据时间之间的时间差达到对应的阴影数据更新时间间隔时,获取属于所述任一图像区域范围的物体对应的阴影数据。
  7. 根据权利要求6所述的方法,其特征在于,所述方法还包括:
    确定所述各图像区域范围分别对应的视锥体;
    所述确定所述任一物体分别与所述各图像区域范围的从属关系,包括:
    确定所述任一物体与所述各图像区域范围分别对应的视锥体之间的相交关系,所述相交关系包括完全包含关系、部分相交关系和不包含关系;
    基于所述相交关系,确定所述任一物体分别与所述各图像区域范围的从属关系。
  8. 根据权利要求7所述的方法,其特征在于,所述基于所述相交关系,确定所述任一物体分别与所述各图像区域范围的从属关系,包括:
    若任一视锥体完全包含所述任一物体,则确定所述任一物体属于所述任一视锥体对应的图像区域范围。
  9. 根据权利要求7所述的方法,其特征在于,所述方法还包括:
    若所述任一物体完全包含在内层图像区域范围对应的视锥体中,则不将所述任一物体对应的阴影数据渲染到中层阴影图像或者外层阴影图像中;
    若所述任一物体完全包含在中层图像区域范围对应的视锥体中,则不将所述任一物体对应的阴影数据渲染到所述外层阴影图像中。
  10. 根据权利要求1所述的方法,其特征在于,所述基于所述各图像区域范围分别对应的阴影数据更新时间间隔,计算所述各图像区域范围内包含的各物体分别对应的阴影数据,包括:
    确定所述目标对象所在的场景中包含的各物体;
    按照预设数量,将所有物体划分为多个物体集合;
    若当前时间与前一次更新阴影数据时间之间的时间差达到对应的阴影数据更新时间间隔时,分批次生成每个物体集合中的物体的阴影数据,每个批次生成一个物体集合中所有物体的阴影数据;
    将所有阴影数据进行合并。
  11. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    在生成所述各图像区域范围内包含的各物体分别对应的阴影数据之前,将所述阴影数据存储到离屏空间中;
    在生成所述阴影数据之后,对所述阴影数据进行模糊处理,将模糊处理后的阴影数据从所述离屏空间转存到在屏空间,以对所述模糊处理后的阴影数据进行展示。
  12. 一种阴影数据确定装置,其特征在于,包括:
    确定模块,设置为当检测到目标对象移动出待绘制阴影图中对应的目标范围时,确定所述目标对象当前在所述待绘制阴影图中对应的位置;
    所述确定模块,设置为基于所述目标对象当前在待绘制阴影图中对应的位置,确定所述待绘制阴影图中的多个图像区域范围以及各图像区域范围之间的层级关系;
    更新模块,设置为基于所述各图像区域范围分别对应的层级,确定所述各图像区域范围分别对应的阴影数据更新时间间隔;
    计算模块,设置为基于所述各图像区域范围分别对应的阴影数据更新时间间隔,计算所述各图像区域范围内包含的各物体分别对应的阴影数据。
  13. 一种电子设备,其特征在于,包括处理器和存储器,所述存储器中存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、至少一段程序、代码集或指令集由所述处理器加载并执行以实现根据权利要求1-11任一项所述的方法。
  14. 一种计算机可读介质,其特征在于,其上存储有至少一条指令、至少一段程序、代码集或指令集,所述至少一条指令、至少一段程序、代码集或指令集由处理器加载并执行以实现根据权利要求1-11任一项所述的方法。
PCT/CN2020/112540 2020-06-18 2020-08-31 阴影数据确定方法、装置、设备和可读介质 WO2021253640A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202010562137.1A CN111790150B (zh) 2020-06-18 2020-06-18 阴影数据确定方法、装置、设备和可读介质
CN202010562137.1 2020-06-18

Publications (1)

Publication Number Publication Date
WO2021253640A1 true WO2021253640A1 (zh) 2021-12-23

Family

ID=72804193

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/112540 WO2021253640A1 (zh) 2020-06-18 2020-08-31 阴影数据确定方法、装置、设备和可读介质

Country Status (2)

Country Link
CN (2) CN113509721B (zh)
WO (1) WO2021253640A1 (zh)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112396683A (zh) * 2020-11-30 2021-02-23 腾讯科技(深圳)有限公司 虚拟场景的阴影渲染方法、装置、设备及存储介质
CN113018856A (zh) * 2021-03-30 2021-06-25 网易(杭州)网络有限公司 图像处理方法、装置、电子设备及存储介质
CN114627221B (zh) * 2021-12-08 2023-11-10 北京蓝亚盒子科技有限公司 一种场景渲染方法、装置及运行器、可读存储介质
CN116483359B (zh) * 2023-04-25 2024-03-12 重庆赛力斯凤凰智创科技有限公司 一种新拟态绘制方法、装置、电子设备及可读存储介质

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014167466A1 (en) * 2013-04-09 2014-10-16 Koninklijke Philips N.V. Layered two-dimensional projection generation and display
CN105912234A (zh) * 2016-04-06 2016-08-31 腾讯科技(深圳)有限公司 虚拟场景的交互方法和装置
CN106355631A (zh) * 2016-08-30 2017-01-25 北京像素软件科技股份有限公司 虚拟现实中实时阴影的显示方法
CN109493406A (zh) * 2018-11-02 2019-03-19 四川大学 快速百分比靠近软阴影绘制方法
CN111105491A (zh) * 2019-11-25 2020-05-05 腾讯科技(深圳)有限公司 场景渲染方法、装置、计算机可读存储介质和计算机设备

Family Cites Families (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101393651A (zh) * 2008-11-07 2009-03-25 北京航空航天大学 一种视野驱动的实时阴影方法
CN102509332B (zh) * 2011-10-19 2014-05-07 清华大学 流体模拟渲染方法及装置
CN102768765B (zh) * 2012-06-25 2015-07-15 南京安讯网络服务有限公司 实时点光源软阴影渲染方法
CN107194890B (zh) * 2017-05-18 2020-07-28 上海兆芯集成电路有限公司 使用多分辨率改善图像质量的方法及装置
EP3635515A1 (en) * 2017-06-09 2020-04-15 Sony Interactive Entertainment Inc. Optimized shadows and adaptive mesh skinning in a foveated rendering system
CN107274476B (zh) * 2017-08-16 2020-12-18 城市生活(北京)资讯有限公司 一种阴影图的生成方法及装置

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014167466A1 (en) * 2013-04-09 2014-10-16 Koninklijke Philips N.V. Layered two-dimensional projection generation and display
CN105912234A (zh) * 2016-04-06 2016-08-31 腾讯科技(深圳)有限公司 虚拟场景的交互方法和装置
CN106355631A (zh) * 2016-08-30 2017-01-25 北京像素软件科技股份有限公司 虚拟现实中实时阴影的显示方法
CN109493406A (zh) * 2018-11-02 2019-03-19 四川大学 快速百分比靠近软阴影绘制方法
CN111105491A (zh) * 2019-11-25 2020-05-05 腾讯科技(深圳)有限公司 场景渲染方法、装置、计算机可读存储介质和计算机设备

Also Published As

Publication number Publication date
CN113509721B (zh) 2023-10-13
CN111790150B (zh) 2021-05-28
CN111790150A (zh) 2020-10-20
CN113509721A (zh) 2021-10-19

Similar Documents

Publication Publication Date Title
WO2021253640A1 (zh) 阴影数据确定方法、装置、设备和可读介质
US11748840B2 (en) Method for efficient re-rendering objects to vary viewports and under varying rendering and rasterization parameters
US9652880B2 (en) 2D animation from a 3D mesh
US20230053462A1 (en) Image rendering method and apparatus, device, medium, and computer program product
JP6636163B2 (ja) 画像表示方法、成形そり幕を生成する方法、および頭部装着ディスプレイデバイス
WO2022110903A1 (zh) 全景视频渲染方法及系统
CN111080766B (zh) 一种基于WebGL的GPU加速海量目标高效渲染方法
CN105487848B (zh) 一种3d应用的显示刷新方法及系统
WO2017198104A1 (zh) 一种粒子系统的处理方法及装置
WO2021228031A1 (zh) 渲染方法、设备以及系统
CN112215932B (zh) 粒子动画处理方法、装置、存储介质及计算机设备
JP2015018294A (ja) 画像処理プログラム、画像処理装置、画像処理システムおよび画像処理方法
CN114529658A (zh) 一种图形渲染方法及其相关设备
CN110276823B (zh) 基于光线追踪且实时可交互的集成成像生成方法及系统
CN113706504A (zh) 一种残影处理方法、装置、存储介质及电子设备
WO2023202254A1 (zh) 图像渲染方法、装置、电子设备、计算机可读存储介质及计算机程序产品
CN115970275A (zh) 虚拟对象的投影处理方法、装置、存储介质与电子设备
WO2022022260A1 (zh) 图像风格迁移方法及其装置
WO2022047136A1 (en) Shader core instruction to invoke depth culling
CN115705668A (zh) 一种视图绘制的方法、装置及存储介质
KR20230013099A (ko) 실시간 깊이 맵을 사용한 지오메트리 인식 증강 현실 효과
CN112465692A (zh) 图像处理方法、装置、设备及存储介质
CN110335335A (zh) 用于球面投影的均匀密度立方体贴图渲染
CN117173378B (zh) 基于CAVE环境的WebVR全景数据展现方法、装置、设备及介质
WO2024103756A1 (zh) 一种三维模型的显示方法、装置、电子设备及存储介质

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 20940650

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20940650

Country of ref document: EP

Kind code of ref document: A1