Scene picture rendering method and device, equipment, storage medium and program product
By pre-storing the visibility data between scene space units and camera space units, and eliminating invisible scene elements, only elements within the virtual camera's view are rendered, solving the problem of low rendering efficiency in existing technologies and achieving more efficient scene rendering.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- TENCENT TECHNOLOGY (SHENZHEN) CO LTD
- Filing Date
- 2022-09-30
- Publication Date
- 2026-05-19
AI Technical Summary
Existing technologies require real-time calculation of the visibility of scene elements, resulting in low rendering efficiency for game scenes.
By pre-storing visibility data of the visibility relationship between scene space units and camera space units, the visibility of scene elements is determined and rendered, invisible scene elements are removed, and only the remaining elements located within the virtual camera's view are rendered.
It improves the rendering efficiency of scene images, reduces unnecessary rendering overhead, and increases the efficiency of the rendering process.
Smart Images

Figure CN117839202B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of computer and rendering technology, and in particular to a method, apparatus, device, storage medium, and program product for rendering scene images. Background Technology
[0002] In the game's scene space, some scene elements are not visible from certain perspectives because they are obscured by other scene elements.
[0003] In related technologies, during game runtime, the system calculates in real time whether scene elements in the scene space are visible from the current viewpoint, and then renders the scene space based on the real-time calculation results to obtain the scene image.
[0004] In the aforementioned technologies, the rendering efficiency of the scene is low because the visibility of scene elements needs to be calculated in real time. Summary of the Invention
[0005] This application provides a method, apparatus, device, storage medium, and program product for rendering scene images, which can improve the rendering efficiency of scene images. The technical solution is as follows:
[0006] According to one aspect of the embodiments of this application, a method for rendering a scene is provided, the method comprising:
[0007] From the n scene space units contained in the scene space, determine the first scene space unit where the first scene element is located at the first moment, where n is an integer greater than 1;
[0008] Based on pre-stored visibility data, the visibility relationship between the first scene space unit and the first camera space unit in the camera space is determined; wherein, the visibility data includes the visibility relationship between the n scene space units and the m camera space units contained in the camera space, the first camera space unit refers to the camera space unit where the virtual camera is located at the first moment, and m is an integer greater than 1;
[0009] When the visibility relationship between the first scene space unit and the first camera space unit is invisible, the first scene element is removed from each scene element contained in the scene space to obtain the remaining scene elements in the scene space;
[0010] Based on the remaining scene elements in the scene space, the content within the viewpoint of the virtual camera in the scene space is rendered to obtain the scene image at the first moment.
[0011] According to one aspect of the embodiments of this application, a scene rendering apparatus is provided, the apparatus comprising:
[0012] The spatial unit determination module is used to determine the first scene spatial unit where the first scene element is located at the first moment from n scene spatial units contained in the scene space, where n is an integer greater than 1.
[0013] The visibility determination module is used to determine the visibility relationship between the first scene space unit and the first camera space unit in the camera space based on pre-stored visibility data; wherein, the visibility data includes the visibility relationship between the n scene space units and the m camera space units contained in the camera space, the first camera space unit refers to the camera space unit where the virtual camera is located at the first moment, and m is an integer greater than 1;
[0014] The element removal module is used to remove the first scene element from each scene element contained in the scene space when the visibility relationship between the first scene space unit and the first camera space unit is invisible, so as to obtain the remaining scene elements in the scene space.
[0015] The rendering module is used to render the content within the viewpoint of the virtual camera in the scene space based on the remaining scene elements in the scene space, so as to obtain the scene image at the first moment.
[0016] According to one aspect of the embodiments of this application, a computer device is provided, the computer device including a processor and a memory, the memory storing a computer program, the computer program being loaded and executed by the processor to implement the above-described scene rendering method.
[0017] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and the computer program is loaded and executed by a processor to implement the above-described scene rendering method.
[0018] According to one aspect of the embodiments of this application, a computer program product is provided, comprising a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the aforementioned scene rendering method.
[0019] The technical solutions provided in this application embodiment may have the following beneficial effects:
[0020] By pre-storing the visibility relationship between scene space units and camera space units in the form of visibility data, during the actual rendering of the scene, after determining the scene space unit where the scene space element is located and the camera space unit where the virtual camera is located, the visibility relationship between the scene space element and the virtual camera can be determined by querying the visibility data, and the scene can be rendered. This eliminates the need to calculate the visibility of scene elements in real time, improves the efficiency of determining the visibility of scene elements, and thus improves the rendering efficiency of the scene.
[0021] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application. Attached Figure Description
[0022] Figure 1 This is a flowchart of a scene rendering method provided in one embodiment of this application;
[0023] Figure 2 This is a schematic diagram of a scene rendering system provided in one embodiment of this application;
[0024] Figure 3 This is a flowchart of a scene rendering method provided in another embodiment of this application;
[0025] Figure 4 This is a flowchart of a scene rendering method provided in another embodiment of this application;
[0026] Figure 5 This is a flowchart of a scene rendering method provided in another embodiment of this application;
[0027] Figure 6 This is a schematic diagram of a spatial unit provided in one embodiment of this application;
[0028] Figure 7 This is a schematic diagram of a spatial unit provided in one embodiment of this application;
[0029] Figure 8 This is a schematic diagram of a spatial unit provided in one embodiment of this application;
[0030] Figure 9 This is a data fragment of a binary sequence set before clustering, provided in one embodiment of this application;
[0031] Figure 10 This is a data fragment after clustering of a set of binary sequences provided in one embodiment of this application;
[0032] Figure 11 This is a flowchart of a scene rendering method provided in another embodiment of this application;
[0033] Figure 12 This is a block diagram of a scene rendering apparatus provided in one embodiment of this application;
[0034] Figure 13 This is a block diagram of a scene rendering apparatus provided in another embodiment of this application;
[0035] Figure 14 This is a block diagram of a terminal device provided in one embodiment of this application. Detailed Implementation
[0036] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of methods consistent with some aspects of this application as detailed in the appended claims.
[0037] Please refer to Figure 1 The diagram illustrates a flowchart of a scene rendering method provided in one embodiment of this application. The method may include the following steps:
[0038] Step 110: Obtain scene information of the scene space.
[0039] The scene information includes the scene elements contained in the scene space.
[0040] Step 120: Obtain the position and size information of dynamic scene elements in the scene space.
[0041] Step 130: Determine the scene space unit where each dynamic scene element is located based on the position and size information of the dynamic scene elements in the scene space.
[0042] Step 140: Determine the camera space unit where the virtual camera is located.
[0043] Step 150: Based on the pre-stored visibility data, determine the visibility relationship between the scene space unit where each dynamic scene element is located and the camera space unit where the virtual camera is located.
[0044] Step 160: Determine whether the dynamic scene element is visible relative to the camera space unit where the virtual camera is located in the first frame. If yes, proceed to step 170; otherwise, proceed to step 180.
[0045] Step 170: Occlusion culling is performed on dynamic scene elements that are not visible relative to the camera space unit in the first frame of the virtual camera.
[0046] Step 180: Determine if the game has ended. If yes, end the step; otherwise, proceed to step 110.
[0047] Please refer to Figure 2 This illustration shows a schematic diagram of an implementation environment provided in one embodiment of this application, which can be implemented as a scene rendering system. For example... Figure 2 As shown, the system 200 may include: terminal device 11.
[0048] The terminal device 11 has a target application installed and running, such as a client for the target application. Optionally, a user account is logged in on the client. The terminal device is an electronic device with data computing, processing, and storage capabilities. The terminal device can be a smartphone, tablet, PC (Personal Computer), wearable device, etc., and this application embodiment does not limit this. The target application can be a game application, such as a shooting game application, a multiplayer shooting survival game application, a battle royale survival game application, an LBS (Location Based Service) game application, a MOBA (Multiplayer Online Battle Arena) game application, etc., and this application embodiment does not limit this. The target application can also be a social application, a payment application, a video application, a music application, a shopping application, a news application, or any application with scene rendering capabilities. In the method provided in this application embodiment, the executing entity for each step can be the terminal device 11, such as a client running on the terminal device 11.
[0049] In some embodiments, the system 200 further includes a server 12, which establishes a communication connection (such as a network connection) with the terminal device 11. The server 12 is used to provide background services for the target application. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The method steps provided in this application embodiment can also be executed alternately by the terminal device 11 and the server 12, and this application embodiment does not specifically limit this.
[0050] The technical solution of this application will be described and illustrated below through several embodiments.
[0051] Please refer to Figure 3 This document illustrates a flowchart of a method for rendering a scene according to an embodiment of this application. In this embodiment, the method is illustrated using an example of its application in the terminal device described above. The method may include the following steps (310-340):
[0052] Step 310: From the n scene space units contained in the scene space, determine the first scene space unit where the first scene element is located at the first moment, where n is an integer greater than 1.
[0053] In some embodiments, the scene space is a three-dimensional space, referring to the spatial region where scene elements may reside, divided into n three-dimensional scene space units. The scene space may contain only dynamic scene elements, only static scene elements, or both. Dynamic scene elements refer to scene elements whose positions in the scene space are not fixed. For example, dynamic scene elements may appear in the scene space but may not, such as special effects elements or props that only appear after user interaction or task completion. Alternatively, dynamic elements may refer to scene elements whose positions in the scene space can change, such as virtual objects, virtual vehicles, and virtual special effects. Static scene elements refer to scene elements that always exist in the scene space and whose position relative to the scene space does not change, such as virtual buildings, virtual stones, virtual walls, virtual sculptures, and virtual hills.
[0054] In some embodiments, the size and / or shape of different scene space units may be the same or different. That is, the scene space may be uniformly divided into n scene space units with the same shape and size, or it may be divided into n scene space units according to various shape and / or size parameters. The scene space unit may be a cube, a cuboid, or other shapes, and this application embodiment does not specifically limit them.
[0055] In some embodiments, the scene space unit in which the first scene element is located at the first moment is called the first scene space unit. Here, the first moment is after the current moment, or the first moment is the current moment.
[0056] Step 320: Determine the visibility relationship between the first scene space unit and the first camera space unit in the camera space based on the pre-stored visibility data.
[0057] In some embodiments, visibility data includes the visibility relationship between n scene space units and m camera space units contained in the camera space, where the first camera space unit refers to the camera space unit where the virtual camera is located at the first moment, and m is an integer greater than 1.
[0058] In some embodiments, the position of the virtual camera can be changed, and the camera space refers to the spatial area where the virtual camera may be located. In some embodiments, the camera space refers to the camera space corresponding to the aforementioned scene space, that is, the spatial area of the aforementioned scene space that can be observed through the virtual camera. The camera space and the scene space may overlap, that is, there may be overlapping or overlapping camera space units and scene space units. Of course, the camera space and the scene space may also not overlap. The camera space can be divided into m camera space units. Optionally, different camera space units have the same shape and size. The camera space unit where the virtual camera is located at the first moment is called the first camera space unit.
[0059] In some embodiments, the visibility relationships between n scene spatial units and m camera spatial units can be pre-stored as visibility data. Thus, during the actual rendering of the scene, the visibility relationship between a specific scene spatial unit and a specific camera spatial unit can be obtained by directly querying the visibility data; for example, the visibility relationship between the first scene spatial unit and the first camera spatial unit can be determined by querying the visibility data.
[0060] Step 330: When the visibility relationship between the first scene space unit and the first camera space unit is invisible, remove the first scene element from the various scene elements contained in the scene space to obtain the remaining scene elements in the scene space.
[0061] In some embodiments, the visibility relationship between scene space units and camera space units has at least two possibilities: visible and invisible. If the first scene space unit is invisible relative to the first camera space unit, it means that the scene elements contained in the first scene space unit at the first moment are invisible relative to the virtual camera at the first moment; that is, the first scene elements are invisible relative to the virtual camera at the first moment. Therefore, during the rendering of the scene at the first moment, the first scene elements should be occluded and culled, i.e., the first scene elements should not be rendered.
[0062] During game rendering, when observing objects in the scene space from a virtual camera position, if a scene element is within the virtual camera's field of view but is occluded by other opaque scene elements, this occluded scene element is not visible to the virtual camera. However, the computer's rendering pipeline will still render it, incurring unnecessary performance overhead. If these occluded scene elements can be excluded from the rendering queue and not rendered, this is called occlusion culling.
[0063] Step 340: Based on the remaining scene elements in the scene space, render the content within the virtual camera's field of view in the scene space to obtain the scene image at the first moment.
[0064] In some embodiments, the spatial area that the virtual camera can observe is related to the location of the virtual camera (such as the camera space unit in which the virtual camera is located) and the virtual camera's viewpoint. After removing the first scene elements, the content of the remaining scene elements that is within the virtual camera's viewpoint is rendered, while scene elements that are outside the virtual camera's viewpoint are not rendered, thus obtaining the scene image at the first moment.
[0065] In summary, the technical solution provided in this application pre-stores the visibility relationship between scene space units and camera space units in the form of visibility data. During the actual rendering of the scene, after determining the scene space unit where the scene space element is located and the camera space unit where the virtual camera is located, the visibility relationship between the scene space element and the virtual camera can be determined by querying the visibility data, and the scene can be rendered. This eliminates the need to calculate the visibility of scene elements in real time, improves the efficiency of determining the visibility of scene elements, and thus improves the rendering efficiency of the scene.
[0066] In some possible implementations, such as Figure 4 As shown above, Figure 3 Step 310 in the embodiment can be replaced by the following steps (312-316):
[0067] Step 312: Obtain the coordinate and size information of the first scene element at the first moment.
[0068] In some embodiments, the coordinate information of the first scene element includes the coordinates of the first scene element in the coordinate system corresponding to the scene space. In some embodiments, the scene space is a portion of the space in the virtual world, and the virtual world includes multiple scene spaces; the coordinate information of the first scene element may also include the coordinates of the first scene element in the world coordinate system of the virtual world. In some embodiments, the coordinate information of the first scene element may also include the offset value of the first scene element relative to a reference position (such as the center of the scene space or the virtual world, or the starting point of the scene space or the virtual world).
[0069] In some embodiments, the dimensions of different scene elements may not be the same, and the dimensions of the same scene element may also be different at different times. The size information of the first scene element may include the height, width, and length of the first scene element.
[0070] Step 314: Determine the center point of the first scene element based on its coordinate and size information.
[0071] In some embodiments, the coordinates of the center point of the first scene element can be calculated based on the coordinates and dimensions of the first scene element.
[0072] Step 316: From the n scene space units, determine the scene space unit where the center point of the first scene element is located as the first scene space unit.
[0073] In some embodiments, step 316 further includes the following steps:
[0074] 1. Determine the offset of the center point of the first scene element relative to the starting point of the scene space in at least one spatial dimension at the first moment;
[0075] 2. For each spatial dimension in at least one spatial dimension, divide the offset corresponding to the dimension by the size of the scene spatial unit in the dimension to obtain the number of scene units between the starting point and the center point in the spatial dimension.
[0076] 3. Based on the number of scene units between the starting point and the center point in each spatial dimension, determine the first scene spatial unit where the first scene element is located.
[0077] In some embodiments, the number of scene space units separated from the center point and the starting point in each spatial dimension is calculated. For example, if the offset corresponding to a certain dimension (the offset is a number greater than or equal to 0) is divided by the size of the scene space unit in that dimension, the calculated result is 'a'. If 'a' is an integer, then the number of scene space units separated from the center point and the starting point in that spatial dimension is determined to be 'a'; if 'a' is a decimal, then the number of scene space units separated from the center point and the starting point in that spatial dimension is determined to be the integer part of 'a' + 1. For example, if the scene space has three spatial dimensions, namely the X-axis dimension, the Y-axis dimension, and the Z-axis dimension, and the number of scene space units between the starting point and the center point calculated in these three dimensions are x, y, and z, respectively, then the x-th scene space unit along the X-axis, the y-th scene space unit along the Y-axis, and the z-th scene space unit along the Z-axis, calculated from the starting point, is determined as the scene space unit where the first scene element is located, i.e., the first scene space unit.
[0078] In the above implementation, the scene space unit where the scene element is located is determined based on the offset of the center point of the scene element relative to the starting point of the scene space and the size of the scene space unit in each spatial dimension. Therefore, it is not necessary to pre-store the coordinate range corresponding to each scene space unit, thus saving the storage resources required to determine the scene space unit where the scene element is located.
[0079] In some possible implementations, such as Figure 5 As shown above, in the above Figure 3Before step 320 in the embodiment, the following steps (350-380) are also included:
[0080] Step 350: Determine the spatial unit parameter information, the area range of the scene space, and the area range of the camera space.
[0081] The spatial unit parameter information includes the size parameters of the camera spatial unit and the scene spatial unit.
[0082] In some embodiments, during the visibility data determination stage, the area range of the scene space and the area range of the camera space are determined to determine which areas of space should be divided into scene space units and which areas should be divided into camera space units; the size parameters of the camera space units and scene space units are determined by determining the space unit parameter information. In some embodiments, the size parameters of the camera space units and scene space units may be the same or different.
[0083] In some embodiments, the size of a scene space unit is related to at least one of the following: the surface type of the scene space, and the maximum size of scene elements in the scene space.
[0084] In some embodiments, the size of the scene space unit is determined according to the surface type of the scene space. Optionally, the size / volume of the scene space unit in a scene space with relatively open terrain can be larger than the size / volume of the scene space unit in a scene space with denser terrain objects. For example, the size / volume of the scene space unit in a grassland scene space can be larger than the size / volume of the scene space unit in a forest scene space; the size / volume of the scene space unit in a forest scene space can be larger than the size / volume of the scene space unit in a town scene space.
[0085] In some embodiments, the size of a scene space unit is determined according to the largest scene element that may exist in the scene space. Optionally, the largest scene element that may exist in the scene space can be completely placed within a single scene space unit. Optionally, the volume of a scene space unit is greater than or equal to the volume of the largest scene element that may exist in the scene space.
[0086] In some embodiments, the camera space unit is also a three-dimensional space unit, and its shape can be a cuboid, a cube, or other shapes. This application does not specifically limit this.
[0087] Step 360: Based on the spatial unit parameter information, the area range of the scene space, and the area range of the camera space, divide the scene space into n scene space units and the camera space into m camera space units.
[0088] In some embodiments, after determining the area of the scene space, the scene space is divided according to the size parameters of the scene space units to generate n scene space units; after determining the area of the camera space, the camera space is divided according to the size parameters of the camera space units to generate m camera space units.
[0089] like Figure 6 As shown, when the size parameters of the camera space unit and the scene space unit are the same, the division results of the camera space unit and the scene space unit can be the same, that is, the camera space unit 13 and the scene space unit 14 overlap.
[0090] Step 370: Determine the visibility relationship between n scene spatial units and m camera spatial units to obtain visibility data.
[0091] In some embodiments, it is necessary to determine the visibility relationship between each scene spatial unit and each camera spatial unit. That is, it is necessary to determine n×m visibility relationships. Optionally, if a scene spatial unit is not visible relative to a camera spatial unit, the corresponding visibility relationship can be represented by 0; if a scene spatial unit is visible relative to a camera spatial unit, the corresponding visibility relationship can be represented by 1.
[0092] In some embodiments, such as Figure 7 As shown, due to the obstruction of the wall, scene space unit 15 is not visible relative to camera space unit 16; while due to the absence of obstruction from the wall, scene space unit 15 is visible relative to camera space unit 17, scene space unit 21 is visible relative to camera space unit 16, and scene space unit 21 is visible relative to camera space unit 17.
[0093] In some embodiments, such as Figure 8 As shown, the visibility relationship between scene space unit 18 and camera space unit 19 is determined based on the visibility relationship between magnified space unit 20 corresponding to scene space unit 18 and camera space unit 19; wherein, magnified space unit 20 is a space unit with a size larger than scene space unit 18 and containing scene space unit.
[0094] In some embodiments, the side length of the enlarged spatial unit is equal to the sum of the side length of the scene spatial unit and the length of the largest dynamic scene element, where the largest dynamic scene element refers to the largest dynamic scene element in the virtual scene.
[0095] Step 380: Save visibility data.
[0096] In some embodiments, binary sequences are used to represent the visibility relationships between scene spatial units and camera spatial units, with each binary sequence corresponding to one camera spatial unit. Therefore, the visibility data includes m binary sequences, each indicating the visibility relationships between n scene spatial units and the same camera spatial unit. That is, the visibility data is stored according to camera spatial units, with each camera spatial unit corresponding to one binary sequence.
[0097] In some embodiments, the binary sequence includes at least n bits, each bit having a value of either a first value or a second value; wherein the first value indicates that the visibility relationship between the scene space unit and the camera space unit corresponding to the bit is invisible, and the second value indicates that the visibility relationship between the scene space unit and the camera space unit corresponding to the bit is visible. Optionally, the first value is 0 and the second value is 1. The first and second values can also be other values, which can be specifically set by those skilled in the art according to the actual situation, and this application embodiment does not specifically limit them.
[0098] In some embodiments, the visibility data includes m binary sequences, each binary sequence indicating the visibility relationship between n scene spatial units and the same camera spatial unit.
[0099] In some embodiments, step 380 further includes the following steps:
[0100] 1. Based on the Hamming distance between the binary sequences and the central sequence, cluster the m binary sequences to obtain K cluster sets, where K is a positive integer; where the Hamming distance refers to the number of different values of corresponding bits between the binary sequences and the central sequence.
[0101] 2. For each of the K cluster sets, determine the center sequence corresponding to the cluster set based on the binary sequences contained in the cluster set;
[0102] 3. If the center sequence of each cluster set satisfies the stopping clustering condition, for each cluster set, replace each binary sequence contained in the cluster set with the center sequence of the cluster set.
[0103] 4. Save the compressed visibility data.
[0104] The compressed visibility data includes the center sequences corresponding to K cluster sets. For the visibility relationship between multiple camera space units and n scene space units corresponding to the cluster set to which each center sequence belongs, the visibility relationship between the camera space unit and the n scene space units indicated by the center sequence is used as the substitute representation.
[0105] In some embodiments, during the clustering of m binary sequences, it is necessary to calculate the distance between the binary sequence and the corresponding center sequences of K cluster sets, and update the K cluster sets accordingly. In this embodiment, the Hamming distance between each binary sequence in the binary sequence set and the K center sequences is calculated separately, instead of calculating the Euclidean distance between data points in the conventional K-Means clustering algorithm. Assuming the binary sequence and the K center sequences have the same number of bits, the Hamming distance refers to the number of different values at corresponding bits between the binary sequence and the center sequences. For example, two binary sequences of equal length, 11001101 and 01011101, differ only in the first and fourth bits, so their Hamming distance is 2. The fewer different bits between two sequences, the smaller the Hamming distance, and the more similar they are; conversely, the more different bits, the larger the Hamming distance, and the greater the difference between them. If two sequences have no different values at corresponding bits, the Hamming distance is 0, indicating that the two binary sequences are identical.
[0106] For each of the K center sequences, the Hamming distance can be calculated by performing an XOR operation on the corresponding bits of the binary sequence and the center sequence to obtain a binary result sequence. The binary result sequence consists of the XOR values of the XOR operation. If the corresponding bits have the same value, the XOR value is 0; if the corresponding bits have different values, the XOR value is 1. The number of XOR values of 1 in the binary result sequence is determined as the Hamming distance between the binary sequence and the center sequence.
[0107] For example, consider the two equal-length binary sequences 11001101 and 01011101. Performing an XOR operation on each corresponding bit will yield an XOR value for each corresponding bit. If the corresponding bits are the same, the XOR value is 0; if they are different, the XOR value is 1. This results in a binary result sequence of the same length as the two original sequences. The number of 1s in this result sequence gives the Hamming distance between the two sequences. In the example above, the two equal-length binary sequences 11001101 and 01011101 differ only in their first and fourth bits. Therefore, the XOR result is 10010000, which contains two 1s. Thus, the Hamming distance between the binary sequences 11001101 and 01011101 is 2. By using an XOR operation on corresponding bits to calculate the Hamming distance between two binary sequences, the problem of Euclidean distance not being applicable to binary sequence distance calculations in the K-Means clustering algorithm is solved.
[0108] After updating the K cluster sets, the center sequences corresponding to each of the K cluster sets need to be recalculated. In some embodiments, for each of the K cluster sets, the value of the updated center sequence at the i-th bit can be determined based on the value of each bit in the binary sequence contained in the cluster set, where i is a positive integer. The updated center sequence of the cluster set is determined based on the values of each bit in the updated center sequence of the cluster set.
[0109] In some embodiments, a first quantity and a second quantity are determined based on the value of each binary sequence in the i-th bit of the cluster set; wherein the first quantity is the number of binary sequences with a value of 1 in the i-th bit, and the second quantity is the number of binary sequences with a value of 0 in the i-th bit, and i is a positive integer; the value of the center sequence corresponding to the cluster set in the i-th bit is determined based on the relationship between the first quantity and the second quantity; and the center sequence corresponding to the cluster set is obtained based on the values of the center sequence corresponding to the cluster set in each bit.
[0110] In the conventional K-Means clustering algorithm, after each clustering iteration, the average value of each dimension of all data points in each cluster is typically used as the centroid. However, this algorithm is not suitable for cases where the data points are in binary sequence form. Therefore, to adapt to this case, the centroid algorithm is adjusted accordingly. The resulting centroid is not a regular data point, but a binary sequence of the same length as the set of binary sequences. The value of the updated centroid sequence at the i-th bit can be determined based on the distribution of the values at the i-th bit of all binary sequences in the cluster set. Since the binary sequence can only take two values at each bit (0 or 1), the values at the i-th bit of all binary sequences in the cluster set can be separated and categorized: those with a value of 1 are in one category, and those with a value of 0 are in another. Then, the relationship between the number of 1s and 0s is used to determine whether the updated centroid sequence should have a value of 0 or 1 at the i-th bit. Once all the values at each bit of the updated center sequence in the cluster set have been taken, a definite updated center sequence can be obtained, which will become the new center sequence in the cluster set.
[0111] In some embodiments, if the first quantity is greater than or equal to the second quantity, the value of the updated center sequence of the cluster set at the i-th position is determined to be 1; if the first quantity is less than the second quantity, the value of the updated center sequence of the cluster set at the i-th position is determined to be 0; or, if the first quantity is greater than the second quantity, the value of the updated center sequence of the cluster set at the i-th position is determined to be 1; if the first quantity is less than or equal to the second quantity, the value of the updated center sequence of the cluster set at the i-th position is determined to be 0.
[0112] To determine whether the value of the updated center sequence of a cluster set should be 0 or 1 at the i-th position, the value can be the one with the greater number of 0s and 1s. For example, if the number of 1s at the i-th position in all binary sequences in the cluster set is greater than the number of 0s, then the updated center sequence can have a value of 1 at the i-th position; conversely, if the number of 0s at the i-th position is greater than the number of 1s, then the updated center sequence can have a value of 0 at the i-th position. Furthermore, if the number of 1s at the i-th position in all binary sequences in the cluster set is equal to the number of 0s, then the updated center sequence can have either a value of 1 or a value of 0 at the i-th position. The specific setting can be determined by those skilled in the art based on the actual situation, and this application does not impose specific limitations on this. The values 0 and 1 have different meanings in different application scenarios, and according to the conservative strategy of clustering algorithms, the values of 0 and 1 will have a certain bias depending on different application scenarios; there is no fixed standard for these values. For example, if 0 and 1 represent visibility, with 0 indicating invisibility and 1 indicating visibility, then when the number of 1s and 0s in the i-th position are equal, the clustering algorithm will tend to assign a value of 1, representing visibility, which is more in line with practical applications. Suppose we calculate the center sequence for four binary sequences of equal length: 10010100, 11010100, 11011101, and 00010111. The value in the first position of the center sequence should be the value that appears most frequently in the first position of the four binary sequences, i.e., 1. Since the number of 0s and 1s is equal in the second position, it can also be 1. Continuing in this way, the resulting center sequence is 11010101. By taking the value that appears most frequently in the i-th position of all binary sequences in the cluster set as the value in the i-th position of the updated center sequence, the problem that the K-Means clustering algorithm's method for calculating center points is not applicable to calculating center sequences in binary sequence form is solved.
[0113] In some embodiments, after determining the K cluster sets as clustering results of binary sequence sets, the method further includes: for each of the K cluster sets, determining the updated center sequence of the cluster set as the compressed sequence of the cluster set; and replacing each binary sequence contained in the cluster set with the compressed sequence of the cluster set.
[0114] After clustering the binary sequence set using the K-Means clustering algorithm, we can obtain the following: Figure 9The data fragment shown is clustered, where the binary sequences in each cluster have a high degree of similarity at each position. Compressing the clustered binary sequences is achieved by compressing each cluster separately, uniformly compressing the binary sequences in each cluster into the central sequence of that cluster. That is, the updated central sequence of the cluster represents all binary sequences in that cluster. Therefore, the compressed data size is greatly reduced, saving data storage space and making it suitable for situations with large amounts of data in the computer field. Furthermore, using a unified central sequence to represent all binary sequences in the cluster simplifies the data retrieval process by eliminating the need to locate a specific binary sequence within the cluster; data retrieval is more convenient as the central sequence of the cluster is read directly. An example of the compression size implementation can be given: if the storage space occupied by each binary sequence before clustering is X, the storage unit of X can be a bit, byte (B), kilobyte (KB), megabyte (MB), etc. If the total number of entries in a binary sequence is M, where M is an integer greater than 1, then the total storage space occupied by the binary sequences before clustering is X × M. Assuming all binary sequences are divided into K groups according to the clustering results, where K is an integer much smaller than M, then the storage space occupied by the compressed binary sequences after clustering is X × K. Therefore, the data volume of the clustered binary sequences can be compressed to K / M of the original size. For example, assuming the number of clusters K is 100, and the total number of binary sequence entries in the binary sequence set is 10000, then the binary sequence data can be compressed to 1 / 100 of its original size, which is a hundredfold reduction in data compression to save storage space.
[0115] In some embodiments, the compressed visibility data includes K compressed sequences (i.e., center sequences) obtained based on K cluster sets. The visibility relationship between scene spatial units and camera spatial units indicated by each compressed sequence can be used to represent the visibility relationship between all camera spatial units and scene spatial units corresponding to their respective cluster sets.
[0116] However, using a single central sequence to uniformly represent all binary sequences in a cluster will introduce some data bias, which is unavoidable during compression. For example... Figure 10The third cluster set in the data structure has 23 values of 1 and 1 value of 0 in its first position. In this case, the value of the center sequence in the first position must be 1. After compressing the third cluster set, all binary sequences in the third cluster set will be represented by 1 in the first position. This introduces a data bias for the binary sequence that originally had a value of 0 in the first position, resulting in data loss during cluster set compression. Since data bias is inevitable when each cluster set uses a uniform center sequence to represent all binary sequences, the compressed center sequence will also have some data loss. This compression method is actually a lossy compression method. Therefore, while data compression allows for more data storage within the same storage space, it also requires accepting some data loss.
[0117] Therefore, the K cluster sets determined in the above steps are not necessarily the final clustering results. The final clustering result of the binary sequence clustering method provided in this application needs to simultaneously meet two conditions: first, the size of the compressed data needs to be within the preset storage space; second, the data loss generated during the compression process needs to be within the preset loss range. Only clustering results that simultaneously meet both conditions can be considered to have achieved the clustering effect of the clustering method in this application. If the K cluster sets determined in the above steps only meet one of the conditions, such as only meeting the condition that the compressed data size is within the preset storage space, or only meeting the condition that the data loss generated during the compression process is within the preset loss range, or if neither condition is met (i.e., the compressed data size exceeds the preset storage space and the data loss generated during the compression process also exceeds the preset loss range), then it is necessary to adjust the value of K and re-cluster the binary sequence set. Only when the K cluster sets obtained by clustering satisfy both the requirement that the compressed data volume is within the preset storage range and the data loss generated during the compression process is within the preset loss range can the K cluster sets be determined as the final clustering result of the binary sequence set.
[0118] In some embodiments, the scene space is a space in the virtual environment that dynamic scene elements have a probability of reaching. Each binary sequence includes a first sequence segment and a second sequence segment. The first sequence segment indicates the visibility relationship between n scene space units and the same camera space unit, and the second sequence segment indicates the visibility relationship between at least one static scene element in the virtual environment and the same camera space unit. That is, each binary sequence is formed by concatenating the first and second sequence segments. The first sequence segment indicates the visibility relationship between a scene space unit that a dynamic scene element may reach and the corresponding camera space unit; the second sequence segment indicates the visibility relationship between a static scene element in the scene space and the corresponding camera space unit. Optionally, the length of the first sequence segment of each binary sequence segment is the same (i.e., the number of bits is the same); the length of the second sequence segments of different binary sequence segments can be the same or different.
[0119] In the above implementation, visibility data is pre-calculated and saved for use during real-time rendering of the scene. This avoids the resource consumption caused by calculating the visibility of scene elements relative to the virtual camera during the rendering process, thereby reducing the processing resources required to render the scene and improving the rendering efficiency of the scene.
[0120] In some possible implementations, the scene space has k different unit partitioning methods, each corresponding to a different scene element type and different visibility data, where k is an integer greater than 1. The visibility relationship associated with the first scene element is determined based on the first visibility data, which is the visibility data corresponding to the scene element type to which the first scene element belongs.
[0121] In some embodiments, the scene element type includes the size type of the scene element. Multiple scene space unit partitioning methods are pre-stored, and the size types of the scene space units corresponding to different partitioning methods are different.
[0122] In some embodiments, the method further includes: determining the size type of a first scene element; determining the target size of a scene spatial unit for occlusion culling corresponding to the first scene element based on the size type of the first scene element; determining the first scene spatial unit based on the target size; and determining the visibility relationship between the first scene spatial unit and the first camera spatial unit according to the visibility data corresponding to the first scene spatial unit with the target size stored in advance.
[0123] In some embodiments, the scene space units corresponding to different unit partitioning methods have the same shape but different volumes. For example, the scene space units corresponding to different unit partitioning methods are all cubes, but the side lengths of the scene space units are different. Then, for scene elements with a larger size in a certain spatial dimension, the visibility data corresponding to the unit partitioning method with a longer side length can be used to determine their visibility; for scene elements with a smaller size in all spatial dimensions, the visibility data corresponding to the unit partitioning method with a shorter side length can be used to determine their visibility.
[0124] In some embodiments, the shapes of the scene space units corresponding to different unit partitioning methods are different. For example, k different unit partitioning methods include: partitioning the scene space units according to cube shapes and partitioning the scene space units according to cuboid shapes. Then, for scene elements whose sizes are not significantly different across spatial dimensions, their visibility can be determined using the visibility data corresponding to the cube-shaped unit partitioning method; for scene elements whose size differs significantly in one spatial dimension from their sizes in other spatial dimensions, their visibility can be determined using the visibility data corresponding to the cuboid-shaped unit partitioning method.
[0125] In some embodiments, scene space units corresponding to different unit partitioning methods have the same shape and volume but different orientations. For example, different unit partitioning methods may result in scene space units that are cuboids with the same shape and volume, but the spatial dimensions corresponding to the longest (or shortest) side of the scene space units are different. Therefore, for scene space elements with a longer horizontal length but a smaller height, their visibility can be determined using the visibility data corresponding to the unit partitioning method with a longer dimension and smaller height in the spatial dimension parallel to the ground; similarly, for scene space elements with a higher height but smaller dimensions in other spatial dimensions, their visibility can be determined using the visibility data corresponding to the unit partitioning method with a smaller dimension and higher height in the spatial dimension parallel to the ground.
[0126] In the above implementation, by pre-generating and saving multiple different unit division methods and corresponding visibility data, during the actual rendering process, the most suitable unit division method and corresponding visibility data can be selected according to the scene element type (such as size type) of the scene element to determine the visibility relationship of the scene element, thereby improving the adaptability between scene space units and scene elements, and thus improving the display accuracy of scene elements and scene images.
[0127] In some possible implementations, the following steps may also be included after step 340 above:
[0128] 1. From the n scene space units contained in the scene space, determine the second scene space unit in which the second scene element is located at the second time; wherein, the second time is after the first time, and the second scene element is a scene element that exists in the scene space at the second time.
[0129] 2. Based on visibility data, determine the visibility relationship between the second scene space unit and the second camera space unit in the camera space; wherein, the second camera space unit refers to the camera space unit where the virtual camera is located at the second moment;
[0130] 3. When the visibility relationship between the second scene space unit and the second camera space unit is invisible, remove the second scene element from the various scene elements contained in the scene space to obtain the remaining scene elements in the scene space.
[0131] 4. Based on the remaining scene elements in the scene space, render the content within the virtual camera's field of view in the scene space to obtain the scene image at the second moment.
[0132] In the above implementation, after obtaining the scene image at the first moment, occlusion and culling processes are performed on the scene elements in the scene space at subsequent moments to obtain the scene images at subsequent moments. For example, after rendering a certain frame of the scene image, the next frame of the scene image is rendered as described above. Thus, continuous rendering can be performed to obtain continuous scene images in the scene space, achieving dynamic display of the scene images.
[0133] In some possible implementations, the number of first scene space units occupied by the first scene element is multiple, such as... Figure 11 As shown, the above Figure 3 Step 330 in the above can be replaced by the following steps (332-334):
[0134] Step 332: From multiple first scene spatial units, determine the first scene spatial units that are invisible in terms of visibility relationship with the first camera spatial unit;
[0135] Step 334: Remove the element portion of the first scene element located in the invisible first scene space unit to obtain the remaining element portion of the first scene element.
[0136] The remaining scene elements in the scene space include the remaining elements of the first scene element.
[0137] In the above implementation, scene space elements may occupy more than one scene space unit. Therefore, the elements of the scene space units that are visible relative to the first camera space unit are retained, while the elements of the scene space units that are not visible relative to the first camera space unit are occluded and removed. This achieves partial occlusion and removal of scene space elements, thereby improving the display accuracy of the scene image.
[0138] The following are embodiments of the apparatus described in this application, which can be used to execute the embodiments of the method described in this application. For details not disclosed in the apparatus embodiments of this application, please refer to the embodiments of the method described in this application.
[0139] Please refer to Figure 12 This diagram illustrates a block diagram of a scene rendering apparatus according to an embodiment of this application. The apparatus has the functionality of an example method for rendering the aforementioned scene, which can be implemented in hardware or by hardware executing corresponding software. The apparatus can be the terminal device described above, or it can be installed on a terminal device. The apparatus 1200 may include: a spatial unit determination module 1210, a visibility determination module 1220, an element culling module 1230, and a rendering module 1240.
[0140] The spatial unit determination module 1210 is used to determine the first scene spatial unit where the first scene element in the scene space is located at the first moment from n scene spatial units contained in the scene space, where n is an integer greater than 1.
[0141] The visibility determination module 1220 is used to determine the visibility relationship between the first scene space unit and the first camera space unit in the camera space based on pre-stored visibility data; wherein, the visibility data includes the visibility relationship between the n scene space units and the m camera space units contained in the camera space, the first camera space unit refers to the camera space unit where the virtual camera is located at the first moment, and m is an integer greater than 1.
[0142] The element removal module 1230 is used to remove the first scene element from each scene element contained in the scene space when the visibility relationship between the first scene space unit and the first camera space unit is invisible, so as to obtain the remaining scene elements in the scene space.
[0143] The rendering module 1240 is used to render the content within the viewpoint of the virtual camera in the scene space based on the remaining scene elements in the scene space, so as to obtain the scene image at the first moment.
[0144] In some embodiments, the space unit determining module 1210 is configured to:
[0145] Obtain the coordinate and size information of the first scene element at the first moment;
[0146] Based on the coordinate and size information of the first scene element, determine the center point of the first scene element;
[0147] From the n scene space units, the scene space unit where the center point of the first scene element is located is determined as the first scene space unit.
[0148] In some embodiments, the space unit determining module 1210 is configured to:
[0149] Determine the offset of the center point of the first scene element relative to the starting point of the scene space in at least one spatial dimension at the first moment;
[0150] For each of the at least one spatial dimension, the offset corresponding to the dimension is divided by the size of the scene spatial unit in the dimension to obtain the number of scene units between the starting point and the center point in the spatial dimension.
[0151] Based on the number of scene units between the starting point and the center point in each spatial dimension, the first scene spatial unit where the first scene element is located is determined.
[0152] In some embodiments, the visibility data includes m binary sequences, each binary sequence indicating the visibility relationship between the n scene spatial units and the same camera spatial unit.
[0153] In some embodiments, the binary sequence includes at least n bits, and the value of each bit is a first value or a second value; wherein, the first value is used to indicate that the visibility relationship between the scene space unit corresponding to the bit and the camera space unit is invisible, and the second value is used to indicate that the visibility relationship between the scene space unit corresponding to the bit and the camera space unit is visible.
[0154] In some embodiments, the scene space is a space that dynamic scene elements in a virtual environment have a probability of reaching, and each binary sequence includes a first sequence segment and a second sequence segment; wherein, the first sequence segment is used to indicate the visibility relationship between the n scene space units and the same camera space unit, and the second sequence segment is used to indicate the visibility relationship between at least one static scene element in the virtual environment and the same camera space unit.
[0155] In some embodiments, the visibility relationship between the scene space unit and the camera space unit is determined based on the visibility relationship between the magnified space unit corresponding to the scene space unit and the camera space unit; wherein, the magnified space unit is a space unit with a size larger than the scene space unit and containing the scene space unit.
[0156] In some embodiments, the side length of the magnified spatial unit is equal to the sum of the side length of the scene spatial unit and the length of the largest dynamic scene element, where the largest dynamic scene element refers to the largest dynamic scene element in the virtual scene.
[0157] In some embodiments, such as Figure 13 As shown, the device 1200 further includes: an information determination module 1250, a space division module 1260, and a data storage module 1270.
[0158] The information determination module 1250 is used to determine spatial unit parameter information, the area range of the scene space, and the area range of the camera space; wherein, the spatial unit parameter information includes the size parameters of the camera space unit and the scene space unit.
[0159] The space division module 1260 is used to divide the scene space into n scene space units and the camera space into m camera space units according to the space unit parameter information, the area range of the scene space and the area range of the camera space.
[0160] The visibility determination module 1220 is further configured to determine the visibility relationship between the n scene space units and the m camera space units, and obtain the visibility data.
[0161] The data storage module 1270 is used to store the visibility data.
[0162] In some embodiments, the visibility data includes m binary sequences, each binary sequence indicating the visibility relationship between the n scene spatial units and the same camera spatial unit; such as Figure 13 As shown, the data storage module 1270 is used for:
[0163] Based on the Hamming distance between the binary sequences and the central sequence, the m binary sequences are clustered to obtain K cluster sets, where K is a positive integer; wherein, the Hamming distance refers to the number of different bit values between the binary sequences and the central sequence.
[0164] For each of the K cluster sets, the center sequence corresponding to the cluster set is determined based on the binary sequences contained in the cluster set;
[0165] If the center sequence corresponding to each cluster set satisfies the clustering stopping condition, for each cluster set, each binary sequence contained in the cluster set is replaced by the center sequence corresponding to the cluster set.
[0166] The compressed visibility data is saved; wherein the compressed visibility data includes the center sequences corresponding to the K cluster sets respectively; for the visibility relationship between multiple camera space units and the n scene space units corresponding to the cluster set to which each center sequence belongs, the visibility relationship between the camera space units indicated by the center sequence and the n scene space units is replaced by the representation.
[0167] In some embodiments, such as Figure 13 As shown, the data storage module 1270 is used for:
[0168] Based on the value of each binary sequence in the cluster set at the i-th bit, a first quantity and a second quantity are determined; wherein, the first quantity is the number of binary sequences with the value of 1 at the i-th bit, and the second quantity is the number of binary sequences with the value of 0 at the i-th bit, where i is a positive integer;
[0169] Based on the relationship between the first quantity and the second quantity, determine the value of the i-th position of the center sequence corresponding to the cluster set;
[0170] The center sequence corresponding to the cluster set is obtained based on the value of each bit in the center sequence corresponding to the cluster set.
[0171] In some embodiments, the size of the scene space unit is related to at least one of the following: the surface type of the scene space, and the maximum size of the scene elements in the scene space.
[0172] In some embodiments, the scene space has k different unit division methods, and different unit division methods correspond to different scene element types and different visibility data, where k is an integer greater than 1; the visibility relationship related to the first scene element is determined according to the first visibility data, wherein the first visibility data is the visibility data corresponding to the scene element type to which the first scene element belongs.
[0173] In some embodiments, the spatial unit determining module 1210 is further configured to determine, from the n scene spatial units contained in the scene space, the second scene element in the scene space is located at a second time moment; wherein, the second time moment is after the first time moment, and the second scene element is a scene element that exists in the scene space at the second time moment.
[0174] The visibility determination module 1220 is further configured to determine the visibility relationship between the second scene space unit and the second camera space unit in the camera space based on the visibility data; wherein, the second camera space unit refers to the camera space unit in which the virtual camera is located at the second moment.
[0175] The element removal module 1230 is further configured to remove the second scene element from each scene element contained in the scene space when the visibility relationship between the second scene space unit and the second camera space unit is invisible, thereby obtaining the remaining scene elements in the scene space.
[0176] The rendering module 1240 is further configured to render the content within the viewpoint of the virtual camera in the scene space based on the remaining scene elements in the scene space, so as to obtain the scene image at the second moment.
[0177] In some embodiments, the visibility determination module 1220 is further configured to determine, from among the plurality of first scene space units, a first scene space unit whose visibility relationship with the first camera space unit is invisible.
[0178] The element removal module 1230 is further configured to remove the element portion of the first scene element located in the invisible first scene space unit to obtain the remaining element portion of the first scene element; wherein, the remaining scene elements in the scene space include the remaining element portion of the first scene element.
[0179] In summary, the technical solution provided in this application pre-stores the visibility relationship between scene space units and camera space units in the form of visibility data. During the actual rendering of the scene, after determining the scene space unit where the scene space element is located and the camera space unit where the virtual camera is located, the visibility relationship between the scene space element and the virtual camera can be determined by querying the visibility data, and the scene can be rendered. This eliminates the need to calculate the visibility of scene elements in real time, improves the efficiency of determining the visibility of scene elements, and thus improves the rendering efficiency of the scene.
[0180] It should be noted that the apparatus provided in the above embodiments is only illustrated by the division of the above functional modules when implementing its functions. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the apparatus and method embodiments provided in the above embodiments belong to the same concept, and the specific implementation process can be found in the method embodiments, which will not be repeated here.
[0181] Please refer to Figure 14 This diagram illustrates a structural block diagram of a terminal device 1400 provided in one embodiment of this application. The terminal device 1400 can be an electronic device such as a mobile phone, tablet computer, game console, e-book reader, multimedia playback device, wearable device, or PC. This terminal device is used to implement the scene rendering method provided in the above embodiments. The terminal device can be... Figure 3 Terminal device 11 in the implementation environment shown. Specifically:
[0182] Typically, terminal device 1400 includes a processor 1401 and a memory 1402.
[0183] Processor 1401 may include one or more processing cores, such as a quad-core processor, an octa-core processor, etc. Processor 1401 may be implemented using at least one hardware form selected from DSP (Digital Signal Processing), FPGA (Field Programmable Gate Array), and PLA (Programmable Logic Array). Processor 1401 may also include a main processor and a coprocessor. The main processor, also known as a CPU (Central Processing Unit), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, processor 1401 may integrate a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, processor 1401 may also include an AI (Artificial Intelligence) processor, which is used to handle computational operations related to machine learning.
[0184] The memory 1402 may include one or more computer-readable storage media, which may be non-transitory. The memory 1402 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In some embodiments, the non-transitory computer-readable storage media in the memory 1402 are used to store at least one instruction, at least one program, code set, or instruction set, and are configured to be executed by one or more processors to implement the above-described scene rendering method.
[0185] In some embodiments, the terminal device 1400 may also optionally include a peripheral device interface 1403 and at least one peripheral device. The processor 1401, memory 1402, and peripheral device interface 1403 can be connected via a bus or signal line. Each peripheral device can be connected to the peripheral device interface 1403 via a bus, signal line, or circuit board. Specifically, the peripheral device includes at least one of a radio frequency circuit 1404, a display screen 1405, an audio circuit 1406, and a power supply 1407.
[0186] Those skilled in the art will understand that Figure 14 The structure shown does not constitute a limitation on the terminal device 1400, and may include more or fewer components than shown, or combine certain components, or use different component arrangements.
[0187] In an exemplary embodiment, a computer-readable storage medium is also provided, wherein at least one program is stored therein, which, when executed by a processor, implements the above-described method for rendering the scene.
[0188] Optionally, the computer-readable storage medium may include: ROM (Read-Only Memory), RAM (Random-Access Memory), SSD (Solid State Drives), or optical disc, etc. The random access memory may include ReRAM (Resistance Random Access Memory) and DRAM (Dynamic Random Access Memory).
[0189] In an exemplary embodiment, a computer program product or computer program is also provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the aforementioned scene rendering method.
[0190] It should be understood that "multiple" as used in this article refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.
[0191] The above description is merely an exemplary embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for rendering a scene, characterized in that, The method includes: From the n scene space units contained in the scene space, determine the first scene space unit where the first scene element is located at the first moment, where n is an integer greater than 1; Based on pre-stored visibility data, the visibility relationship between the first scene space unit and the first camera space unit in the camera space is determined; wherein, the visibility data includes the visibility relationship between the n scene space units and the m camera space units contained in the camera space, the visibility relationship between the scene space units and the camera space units is determined based on the visibility relationship between the magnified space unit corresponding to the scene space unit and the camera space unit, the magnified space unit is a space unit with a size larger than the scene space unit and containing the scene space unit, the side length of the magnified space unit is equal to the sum of the side length of the scene space unit and the length of the largest dynamic scene element, the largest dynamic scene element refers to the largest dynamic scene element in the virtual scene, the first camera space unit refers to the camera space unit where the virtual camera is located at the first moment, and m is an integer greater than 1; When the visibility relationship between the first scene space unit and the first camera space unit is invisible, the first scene element is removed from each scene element contained in the scene space to obtain the remaining scene elements in the scene space; Based on the remaining scene elements in the scene space, the content within the viewpoint of the virtual camera in the scene space is rendered to obtain the scene image at the first moment.
2. The method according to claim 1, characterized in that, Determining the first scene space unit where the first scene element is located at the first moment from the n scene space units contained in the scene space includes: Obtain the coordinate and size information of the first scene element at the first moment; Based on the coordinate and size information of the first scene element, determine the center point of the first scene element; From the n scene space units, the scene space unit where the center point of the first scene element is located is determined as the first scene space unit.
3. The method according to claim 2, characterized in that, Determining the first scene space unit where the first scene element is located at the first moment from the n scene space units contained in the scene space includes: Determine the offset of the center point of the first scene element relative to the starting point of the scene space in at least one spatial dimension at the first moment; For each of the at least one spatial dimension, the offset corresponding to the dimension is divided by the size of the scene spatial unit in the dimension to obtain the number of scene units between the starting point and the center point in the spatial dimension. Based on the number of scene units between the starting point and the center point in each spatial dimension, the first scene spatial unit where the first scene element is located is determined.
4. The method according to claim 1, characterized in that, The visibility data includes m binary sequences, each binary sequence indicating the visibility relationship between the n scene spatial units and the same camera spatial unit.
5. The method according to claim 4, characterized in that, The binary sequence includes at least n bits, and the value of each bit is either a first value or a second value; Wherein, the first value is used to indicate that the visibility relationship between the scene space unit corresponding to the bit and the camera space unit is invisible, and the second value is used to indicate that the visibility relationship between the scene space unit corresponding to the bit and the camera space unit is visible.
6. The method according to claim 4, characterized in that, The scene space is the space that dynamic scene elements in the virtual environment have a probability of reaching, and each binary sequence includes a first sequence segment and a second sequence segment. Wherein, the first sequence segment is used to indicate the visibility relationship between the n scene space units and the same camera space unit, and the second sequence segment is used to indicate the visibility relationship between at least one static scene element in the virtual environment and the same camera space unit.
7. The method according to claim 1, characterized in that, Before determining the visibility relationship between the first scene spatial unit and the first camera spatial unit in the camera space based on pre-stored visibility data, the method further includes: The spatial unit parameter information, the area range of the scene space, and the area range of the camera space are determined; wherein, the spatial unit parameter information includes the size parameters of the camera space unit and the scene space unit; According to the spatial unit parameter information, the area range of the scene space, and the area range of the camera space, the scene space is divided into the n scene space units, and the camera space is divided into the m camera space units; Determine the visibility relationship between the n scene spatial units and the m camera spatial units to obtain the visibility data; Save the visibility data.
8. The method according to claim 7, characterized in that, The visibility data includes m binary sequences, each binary sequence indicating the visibility relationship between the n scene spatial units and the same camera spatial unit; The process of saving the visibility data includes: Based on the Hamming distance between the binary sequences and the central sequence, the m binary sequences are clustered to obtain K cluster sets, where K is a positive integer; wherein, the Hamming distance refers to the number of different bit values between the binary sequences and the central sequence. For each of the K cluster sets, the center sequence corresponding to the cluster set is determined based on the binary sequences contained in the cluster set. If the center sequence corresponding to each cluster set satisfies the clustering stopping condition, for each cluster set, each binary sequence contained in the cluster set is replaced by the center sequence corresponding to the cluster set. The compressed visibility data is saved; wherein the compressed visibility data includes the center sequences corresponding to the K cluster sets respectively; for the visibility relationship between multiple camera space units and the n scene space units corresponding to the cluster set to which each center sequence belongs, the visibility relationship between the camera space units indicated by the center sequence and the n scene space units is replaced by the representation.
9. The method according to claim 8, characterized in that, The step of determining the center sequence corresponding to the cluster set based on each binary sequence contained in the cluster set includes: Based on the value of each binary sequence in the cluster set at the i-th bit, a first quantity and a second quantity are determined; wherein, the first quantity is the number of binary sequences with the value of 1 at the i-th bit, and the second quantity is the number of binary sequences with the value of 0 at the i-th bit, where i is a positive integer; Based on the relationship between the first quantity and the second quantity, determine the value of the i-th position of the center sequence corresponding to the cluster set; The center sequence corresponding to the cluster set is obtained based on the value of each bit in the center sequence corresponding to the cluster set.
10. The method according to claim 1, characterized in that, The size of the scene space unit is related to at least one of the following: the surface type of the scene space, and the maximum size of the scene elements in the scene space.
11. The method according to claim 1, characterized in that, The scene space has k different unit division methods, and different unit division methods correspond to different scene element types and different visibility data, where k is an integer greater than 1; The visibility relationship associated with the first scene element is determined based on the first visibility data, wherein the first visibility data is the visibility data corresponding to the scene element type to which the first scene element belongs.
12. The method according to claim 1, characterized in that, After rendering the content within the virtual camera's field of view in the scene space based on the remaining scene elements in the scene space to obtain the scene image at the first moment, the method further includes: From the n scene space units contained in the scene space, determine the second scene space unit in which the second scene element is located at the second time; wherein the second time is after the first time, and the second scene element is a scene element that exists in the scene space at the second time; Based on the visibility data, the visibility relationship between the second scene space unit and the second camera space unit in the camera space is determined; wherein, the second camera space unit refers to the camera space unit in which the virtual camera is located at the second moment; When the visibility relationship between the second scene space unit and the second camera space unit is invisible, the second scene element is removed from each scene element contained in the scene space to obtain the remaining scene elements in the scene space; Based on the remaining scene elements in the scene space, the content within the viewpoint of the virtual camera in the scene space is rendered to obtain the scene image at the second moment.
13. The method according to claim 1, characterized in that, The number of first scene space units occupied by the first scene element is multiple, and the method further includes: From a plurality of first scene spatial units, determine the first scene spatial units that are invisible to the first camera spatial unit based on their visibility relationship; The element portion of the first scene element located in the invisible first scene space unit is removed to obtain the remaining element portion of the first scene element; The remaining scene elements in the scene space include the remaining elements of the first scene element.
14. A scene rendering device, characterized in that, The device includes: The spatial unit determination module is used to determine the first scene spatial unit where the first scene element is located at the first moment from n scene spatial units contained in the scene space, where n is an integer greater than 1. A visibility determination module is used to determine the visibility relationship between the first scene space unit and the first camera space unit in the camera space based on pre-stored visibility data. The visibility data includes the visibility relationship between the n scene space units and the m camera space units contained in the camera space. The visibility relationship between the scene space units and the camera space units is determined based on the visibility relationship between the magnified space unit corresponding to the scene space unit and the camera space unit. The magnified space unit is a space unit with a size larger than the scene space unit and containing the scene space unit. The side length of the magnified space unit is equal to the sum of the side length of the scene space unit and the length of the largest dynamic scene element. The largest dynamic scene element refers to the largest dynamic scene element in the virtual scene. The first camera space unit refers to the camera space unit where the virtual camera is located at the first moment, and m is an integer greater than 1. The element removal module is used to remove the first scene element from each scene element contained in the scene space when the visibility relationship between the first scene space unit and the first camera space unit is invisible, so as to obtain the remaining scene elements in the scene space. The rendering module is used to render the content within the viewpoint of the virtual camera in the scene space based on the remaining scene elements in the scene space, so as to obtain the scene image at the first moment.
15. A computer device, characterized in that, The computer device includes a processor and a memory, the memory storing a computer program, which is loaded and executed by the processor to implement the scene rendering method as described in any one of claims 1 to 13.
16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which is loaded and executed by a processor to implement the scene rendering method as described in any one of claims 1 to 13.
17. A computer program product, characterized in that, The computer program product includes a computer program stored in a computer-readable storage medium, and a processor reads from and executes the computer program to implement the scene rendering method as described in any one of claims 1 to 13.