Safety area ground generation method and virtual reality equipment
By filtering and generating the target boundary point set, calculating the center point and UV coordinates, the ground rendering of the safe area in the VR device is realized, solving the problem of not generating the ground in the prior art, and improving user experience and security.
Patent Information
- Application Number
- CN202310843201.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-10
- Publication Date
- 2025-01-10
AI Technical Summary
When creating a secure area, existing VR devices fail to generate ground, causing users to create a suspended state in the virtual environment, reducing the security and user experience of the immersive experience.
By obtaining the original set of boundary points for the safe area delineated by the handle ray on the real ground in perspective mode, filtering inflection points to generate the target boundary point set, calculating the center point, generating a triangle ground rendering mesh, and according to the range of the ground texture map Determine the UV coordinates and perform rasterization rendering to display the ground of the safe area.
It improves the generation efficiency and display effect of the ground in the safe area, is suitable for safe areas with complex shapes, prevents texture compression or stretching problems, and enhances the user's immersive experience and security.
Smart Images

Figure CN119295703A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of virtual reality (VR) technology, and provides a safe area ground generation method and a virtual reality device. Background Art
[0002] When users use VR devices for an immersive experience, their vision is isolated from the real environment, and they cannot know the real environment they are in, which may lead to dangers such as collisions and tripping. To ensure user safety, a safe area is generally created when using VR devices, and a safety warning is issued when the user approaches the boundary of the safe area or walks out of the safe area.
[0003] In order to ensure that users have enough space, VR devices can provide irregular and complex-shaped safety areas based on regular-shaped safety areas (such as cylinders).
[0004] At present, when creating a safe area, most VR products on the market display the safe area through a simple fence, and do not generate the ground of the safe area, and cannot give users the most direct ground feedback. In this way, users are prone to illusions (such as a suspended state) in the virtual environment, which reduces the user experience. Summary of the invention
[0005] The embodiments of the present application provide a safe area ground generation method and a virtual reality device for improving the safety of immersive experience.
[0006] On the one hand, an embodiment of the present application provides a method for generating a safe area ground, including:
[0007] Get the original boundary point set of the safe area delineated by the handle ray on the real ground in perspective mode;
[0008] Selecting a plurality of inflection points in the original boundary point set to generate a target boundary point set for the safety area;
[0009] Calculating the centroid point of the geometric shape formed by the target boundary points, and generating triangular ground rendering grids according to the centroid point and every two target boundary points;
[0010] Determine the UV coordinates of the centroid point according to the range of the pre-generated ground texture map, and determine the UV coordinates of each target boundary point according to the UV coordinates of the centroid point and the range of the ground texture map;
[0011] Rasterizing each surface rendering grid, and obtaining the UV coordinates of each fragment after rasterization according to the UV coordinates of each target boundary point and the centroid point;
[0012] Sampling is performed from the ground texture map according to the UV coordinates of each fragment, and the ground of the safety area is rendered and displayed.
[0013] On the other hand, an embodiment of the present application provides a virtual reality device, including a processor, a memory, a display, and a communication interface, wherein the communication interface, the display, the memory, and the processor are connected via a bus;
[0014] The memory stores a computer program, and the processor performs the following operations according to the computer program:
[0015] Obtaining, through the communication interface, an original boundary point set of a safety area delineated by the handle ray on the real ground in perspective mode;
[0016] Selecting a plurality of inflection points in the original boundary point set to generate a target boundary point set for the safety area;
[0017] Calculating the centroid point of the geometric shape formed by the target boundary points, and generating a triangular ground rendering grid according to the centroid point and every two target boundary points;
[0018] Determine the UV coordinates of the centroid point according to the normalized range of the pre-generated ground texture map, and determine the UV coordinates of each target boundary point according to the UV coordinates of the centroid point and the range of the ground texture map;
[0019] Rasterizing each surface rendering grid, and obtaining the UV coordinates of each fragment after rasterization according to the UV coordinates of each target boundary point and the centroid point;
[0020] Sampling is performed from the ground texture map according to the UV coordinates of each fragment, and the ground of the safety area is rendered and displayed through the display.
[0021] Optionally, the processor selects multiple inflection points in the original boundary point set to generate a target boundary point set for the safety area, and the specific operation is:
[0022] For each original boundary point in the original boundary point set, calculate the vector angles formed by the original boundary point and the adjacent left original boundary point and right original boundary point, and take the original boundary point corresponding to the vector angle greater than a preset angle threshold as a first-level inflection point;
[0023] Determine a straight line according to each two adjacent first-level inflection points, calculate the offset of the original boundary points corresponding to the straight line between each two adjacent first-level inflection points, and take at least one original boundary point with an offset greater than a preset offset threshold as a second-level inflection point;
[0024] A target boundary point set of the safety area is generated according to each primary inflection point and each secondary inflection point.
[0025] Optionally, the processor determines the UV coordinates of the centroid point according to the range of the pre-generated ground texture map, and determines the UV coordinates of each target boundary point according to the UV coordinates of the centroid point and the range of the ground texture map, and the specific operation is:
[0026] Determining the UV coordinates of the centroid point according to the position coordinates of the centroid point and the range of the ground texture map;
[0027] The relative coordinates of each target boundary point and the centroid point are calculated, and the UV coordinates of each target boundary point are determined by combining the UV coordinates of the centroid point and the range of the ground texture map.
[0028] Optionally, the formula for the UV coordinates of each target boundary point is expressed as:
[0029]
[0030]
[0031] Among them, (a ix , a iy ) represents the position coordinates of the i-th target boundary point, (a 0x , a 0y ) represents the position coordinates of the centroid point, M represents the length of the ground texture map, N represents the width of the ground texture map, (U i , V i ) represents the UV coordinate of the i-th target boundary point, (a 0x / M,a 0y / N) represents the UV coordinate of the centroid point.
[0032] Optionally, when the centroid point is the center point of the range of the ground texture map, the UV coordinates of the centroid point are (0.5, 0.5).
[0033] Optionally, the processor 1301 calculates the centroid point of the geometric shape formed by the target boundary points, and the specific operation is:
[0034] Calculating the sum of the coordinates of each target boundary point in the target boundary point set on each coordinate axis;
[0035] The sum of the coordinates corresponding to each coordinate axis is divided by the total number of target boundary points of the target boundary point set to obtain the centroid point of the geometric shape surrounded by the target boundary point set.
[0036] Optionally, for each point of each ground grid, a normal vector perpendicular to the ground and an initial color value corresponding to different effects are respectively set;
[0037] The processor samples from the ground texture map according to the UV coordinates of each fragment, renders the ground of the safety area and displays it through the display, and the specific operations are:
[0038] For each fragment, determine the normal vector of the fragment according to the normal vectors of three points of the ground rendering grid corresponding to the fragment, and determine the initial color value of the fragment according to the initial color values of the three points of the ground rendering grid corresponding to the fragment;
[0039] According to the ground effect of the preset safety area in the virtual scene, the initial color value of each fragment is merged with the color value sampled from the ground texture map to obtain the target color value of each fragment;
[0040] According to the target color value of each fragment, the ground of the safety area is rendered and displayed through the display.
[0041] On the other hand, an embodiment of the present application provides a computer-readable storage medium, which stores computer-executable instructions, and the computer-executable instructions are used to enable a computer device to execute the steps of a safety area ground generation method provided in an embodiment of the present application.
[0042] In a method for generating a ground surface in a safe area and a virtual reality device provided by an embodiment of the present application, in an application scenario using a virtual reality device, after obtaining the original boundary point set of the safe area for protecting the safety of the user, the original boundary point set is screened based on the inflection point, the number of boundary points is reduced, and a simplified target boundary point set is obtained, thereby improving the efficiency of generating the ground surface in the safe area. In the process of generating the ground surface in the safe area, a triangular ground rendering grid is generated according to the centroid point of the geometric shape enclosed by the ground surface in the safe area and every two target boundary points. Compared with directly generating a triangular ground rendering grid according to three target boundary points, the standardization of the ground rendering grid is improved, so that it can meet the generation requirements of the ground surface in a complex shape in the safe area. At the same time, the UV coordinates of the texture sampling are calculated based on the range of the ground texture map and the position coordinates of each ground rendering grid point in the spatial coordinate system, so as to prevent the problem of texture compression or stretching when the ground texture map is inconsistent with the size of the ground surface in the safe area, thereby improving the ground display effect in the safe area.
[0043] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0045] Figure 1A A display effect diagram of a safety area with a regular shape provided in an embodiment of the present application;
[0046] Figure 1B A display effect diagram of a safety area with a complex shape provided in an embodiment of the present application;
[0047] Figure 2 A flow chart of a method for generating a safe area ground surface provided in an embodiment of the present application;
[0048] Figure 3 A schematic diagram of a virtual reality device provided in an embodiment of the present application;
[0049] Figure 4 A schematic diagram of an original boundary point set provided in an embodiment of the present application;
[0050] Figure 5 A flow chart of a method for selecting a target boundary point set provided in an embodiment of the present application;
[0051] Figure 6 A schematic diagram of the original boundary point screening provided in the embodiment of the present application;
[0052] Figure 7 A schematic diagram showing the comparison before and after the original boundary point set screening provided in the embodiment of the present application;
[0053] Figure 8 A schematic diagram of generating a ground rendering grid provided in an embodiment of the present application;
[0054] Fig. 9 A flow chart of a method for calculating UV coordinates provided in an embodiment of the present application;
[0055] Fig.10 The display effect of the ground in the safety area with regular shape provided by the embodiment of the present application;
[0056] Fig.11The display effect of the irregularly shaped safety area ground provided in the embodiment of the present application;
[0057] Fig.12 A complete flow chart for generating the safety area ground provided in the embodiment of the present application;
[0058] Fig.13 The structure of the virtual reality device provided in the embodiment of the present application. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.
[0060] like Figure 1A and Figure 1B As shown in the figure, the schematic diagram of the safety area with regular shape and the schematic diagram of the safety area with irregular shape created for VR devices respectively, the user can ensure his own safety by displaying the safety area in the virtual scene. However, when displaying the safety area, the safety area is only displayed through a simple ground fence, and the ground of the safety area is not generated, so the most direct ground feedback cannot be given to the user. In this way, the user is prone to illusion in VR mode, affecting the immersive experience.
[0061] Therefore, generating a visual ground based on the boundaries of the safe area to allow users to obtain the most direct ground feedback and improve the safety of VR devices is an important technology in the VR field.
[0062] At present, in order to solve the above problems, the related technology generates a complex shape of the ground in the safety zone created by the VR device through programming of the Graphics Processing Unit (GPU). However, the ground texture effect generated by this method is poor and it increases the rendering and display burden of the GPU.
[0063] In view of this, the embodiment of the present application provides a method for generating the ground in a safe area, which screens and simplifies the boundary points of the safe area delineated by the handle ray on the real ground in the perspective mode, thereby improving the generation efficiency of the ground in the safe area, and regularly generates a triangular ground rendering grid based on the centroid point of the geometric shape formed by the screened and simplified target boundary points and every two target boundary points. Compared with directly generating a triangular ground rendering grid based on three target boundary points, the standardization of the ground rendering grid is improved, so that it can meet the generation requirements of the ground in a safe area with complex shapes. At the same time, the UV coordinates of the texture sampling are calculated based on the range of the ground texture map and the position coordinates of each ground rendering grid point in the spatial coordinate system, so as to prevent the problem of texture compression or stretching when the ground texture map is inconsistent with the size of the ground in the safe area, thereby improving the ground display effect in the safe area.
[0064] like Figure 2 FIG. 1 is a flow chart of a method for generating a safe area ground provided in an embodiment of the present application. The process is executed by a virtual reality device and mainly includes the following steps:
[0065] S20 1: Obtain the original boundary point set of the safety area delineated by the handle ray on the real ground in the perspective mode.
[0066] Generally, virtual reality equipment is equipped with multiple cameras, such as Figure 3 As shown, when the perspective mode is turned on, the user can view the real environment he is in through the multi-eye camera, and according to the real environment, the user can define a custom safety area on the real ground through the rays emitted by the handle to prevent collision with objects in the environment during the VR experience. In the process of defining the safety area, the virtual reality device receives and records the boundary points of a safety area sent by the handle every preset period (such as 0.1 seconds), and removes unreasonable boundary points (such as duplicate points, cross curve points, etc.) according to the recording results. When the safety area is delineated, the original boundary point set of the safety area is obtained.
[0067] like Figure 4 As shown, it is the original boundary point set of the safety area demarcated by the user, and the shape of the safety area enclosed by the original boundary point set is irregular.
[0068] S202: Select multiple inflection points in the original boundary point set to generate a target boundary point set for the safety area.
[0069] Before drawing the safe area, the present application embodiment designs a method for screening and simplifying the original boundary point set based on the inflection point. For the specific process, see Figure 5 , mainly includes the following steps:
[0070] S2021: For each original boundary point in the original boundary point set, calculate the vector angles formed by the original boundary point and the adjacent left original boundary point and right original boundary point, and take the original boundary point corresponding to the vector angle less than a preset angle threshold as a first-level inflection point.
[0071] Take an original boundary point as an example, assuming that the position coordinates of the original boundary point in the two-dimensional ground space coordinate system are (x i ,y i ), and the position coordinates of the adjacent left original boundary point are (x i-1 ,y i-1 ), and the position coordinates of the adjacent right original boundary point are (x i+1 ,y i+1 ), then the coordinates of the first vector composed of the original boundary point and the left original boundary point are expressed as (x i -x i-1 ,y i -y i-1 ), and the coordinates of the second vector composed of the right original boundary point are expressed as (x i+1 -x i ,y i+1 -y i ), the angle between the first vector and the second phase vector is Compare α with the preset angle threshold. If α is greater than the preset angle threshold, determine that the original boundary point is a first-level inflection point and record the position. Otherwise, determine that the original boundary point is not a first-level inflection point.
[0072] In one example, the first-level inflection points selected from the original boundary point set are as follows: Figure 6 As shown, they are circled with thick solid lines, where the number of first-order inflection points is only an example and does not represent all first-order inflection points in the original boundary point set.
[0073] S2022: Determine a straight line according to each two adjacent first-level inflection points, calculate the offset of each original boundary point between each two adjacent first-level inflection points and the corresponding straight line, and take at least one original boundary point with an offset greater than a preset offset threshold as a second-level inflection point.
[0074] Taking two adjacent first-order inflection points as an example, assuming that a straight line is determined based on the position coordinates of the two adjacent first-order inflection points as y=kx+b, for each original boundary point (x j ,y j ), calculate (x j ,y j ) to the distance offset from y = kx + b Compare d with the preset offset threshold. If d is greater than the preset angle threshold, the original boundary point is determined to be a secondary inflection point and the position is recorded. Otherwise, the original boundary point is determined to be a redundant boundary point.
[0075] like Figure 6 As shown, the screened secondary inflection points are circled with thick dotted circles, and the redundant boundary points are circled with thick single dot circles, wherein the number of secondary inflection points and redundant boundary points is only an example, and does not represent all secondary inflection points and all redundant boundary points in the original boundary point set.
[0076] S2023: Generate a target boundary point set of the safety area according to each primary inflection point and each secondary inflection point.
[0077] like Figure 7 As shown, it is a target boundary point set screened based on the first-level inflection point and the second-level inflection point.
[0078] Compared with traditional boundary point smoothing and direct use of original boundary points for safety area drawing, the embodiment of the present application screens and simplifies the original boundary point set through primary inflection points and secondary inflection points to obtain a smaller number of target boundary point sets that can characterize the geometric shape of the safety area. It has a better expression effect for complex and irregularly shaped safety areas, and can more efficiently generate safety boundary ground drawing.
[0079] At present, when generating the ground in the safe area, the relevant technology uses a fixed square-shaped rendering grid to program the GPU side to achieve the generation of complex-shaped ground. However, this method requires active control of the position of the rendering grid, and the GPU needs to determine whether the rendering grid is within the safe area. The GPU's logical judgment ability is poor, which will reduce the efficiency of drawing the ground in the safe area, especially when the boundary of the safe area is complex and irregular in shape, the rendering efficiency will be even lower.
[0080] In order to solve this problem, before rendering the ground of the safe area in the embodiment of the present application, a method of automatically generating a rendering grid within a geometric shape corresponding to the safe area is designed based on a simplified target boundary point set. This method does not require active control of the position of the rendering grid, and because the rendering grid is generated before rendering, it can avoid the GPU from performing complex safe area range judgments, further improving the drawing efficiency of the ground in the safe area. See S203 for details.
[0081] S203: Calculate the centroid point of the geometric shape formed by the target boundary points, and generate triangular ground rendering grids according to the centroid point and every two target boundary points.
[0082] In one example, the calculation process of the centroid point of the geometric shape of the safety area surrounded by the target boundary point set is: first calculate the sum of the coordinates of each target boundary point in the target boundary point set on each coordinate axis in the ground space coordinate system, and then divide the sum of the coordinates corresponding to each coordinate axis by the total number of target boundary points in the target boundary point set to obtain the centroid point of the geometric shape surrounded by the target boundary point set. The formula is expressed as follows:
[0083]
[0084] Where n is the total number of target boundary points.
[0085] The centroid point (a 0x , a 0y ) as the base point, connected to every two target boundary points, to generate a triangular ground rendering grid, such as Figure 8 shown.
[0086] Compared with generating a rendering grid based purely on target boundary points, the embodiment of the present application introduces additional base points, through which a ground rendering grid is formed more concisely and efficiently with the filtered and simplified target boundary points. The formed rendering grid is more standardized and more suitable for rendering planar areas with complex boundary shapes. Moreover, since the number of target boundary points is smaller than that of the original boundary points, the memory occupied by the ground rendering grid is reduced.
[0087] Traditional model textures and rendering grids are based on the visual position of image pixels and 3D models. At this time, the entire rendering grid will be covered when ground texture mapping is performed, and in most cases, the UV coordinates of the texture sampling must be matched with those of the rendering grid within the range of (0-1). However, the safe area is a small area demarcated by the user on the real ground, and its shape and size are not fixed. The texture map expresses the ground range that covers the entire safe area. In this way, using the traditional VU coordinate calculation method, when the safe area is small, the ground texture map will be compressed, and when the safe area is large, the ground texture map will be stretched, and the direction of the texture map will be different due to the different starting points of each safe area demarcation, affecting the drawing effect of the ground in the safe area.
[0088] In order to improve the drawing quality of the ground in the safe area, the embodiment of the present application designs a method for calculating the UV coordinates for texture sampling based on the position coordinates of the target boundary point in the ground space coordinate system, see step S204 for details.
[0089] S204: Determine the UV coordinates of the centroid point according to the range of the pre-generated ground texture map, and determine the UV coordinates of each target boundary point according to the UV coordinates of the centroid point and the range of the ground texture map.
[0090] In one example, the ground texture map can be pre-generated by an artist based on the ground range, where the ground range can be determined based on the current virtual space, the hardware computing power of the virtual reality device, and the limitations of the software algorithm. This ground texture map can cover the entire safe area by default. Based on the range of this ground texture map, the UV coordinates of each target boundary point can be determined. For the specific process, see Fig. 9 , mainly includes the following steps:
[0091] S2041: Determine the UV coordinates of the centroid point according to the position coordinates of the centroid point and the range of the ground texture map.
[0092] In one example, the relative position of the centroid point of the calculated geometric shape of the safety zone within the range of the ground texture map is calculated. Specifically, assuming that the range of the ground texture map is M*N (unit: meter), the position coordinates of the centroid point a0 are (a 0x , a 0y ), divide the horizontal coordinate of the centroid by M to obtain the U coordinate of the centroid U = a 0x / M, divide the vertical coordinate of the centroid by N to obtain the V coordinate of the centroid V = a 0y / N.
[0093] S2042: Calculate the relative coordinates of each target boundary point with respect to the centroid point, and determine the UV coordinates of each target boundary point by combining the UV coordinates of the centroid point and the range of the ground texture map.
[0094] Take a target boundary point a i For example, assuming its coordinates are (a ix , a iy ), then the relative coordinate of the centroid on the X-axis in the ground plane coordinate system is (a ix -a 0x ), the relative coordinate on the Y axis is (a iy -a 0y ), and then the target boundary point a i The relative coordinate of the centroid point a0 on the X axis is divided by the length M of the ground texture map, and the result of the division is translated according to the U coordinate of the centroid point a0 to obtain the target boundary point a i The U coordinate of the target boundary point a i The relative coordinate of the centroid point a0 on the Y axis is divided by the width N of the ground texture map, and the result of the division is translated according to the V coordinate of the centroid point a0 to obtain the target boundary point a i The V coordinate is expressed as
[0095] In one example, in order to simplify the calculation of UV coordinates, the centroid point can also be aligned with the center point of the range of the ground texture map, that is, the centroid point coincides with the center point of the range of the ground texture map. At this time, the UV coordinates of the centroid point a0 are (0.5, 0.5).
[0096] It should be noted that when computers perform mathematical operations, they generally normalize the values within the range of (0-1) for calculation, including position coordinates, image resolution, range size, etc.
[0097] S205: Rasterize each surface rendering grid, and obtain the UV coordinates of each fragment after rasterization according to the UV coordinates of each target boundary point and centroid point.
[0098] In one example, based on the rendering engine inside the virtual reality device, rasterization is performed on various surface rendering grids formed by the target boundary points and the centroid points to obtain a number of fragments, each of which corresponds to a pixel to be rendered. During the rasterization process, the rendering engine interpolates the UV coordinates of the target boundary points and the UV coordinates of the centroid points to obtain the UV coordinates of each fragment.
[0099] S206: Sampling is performed from the ground texture map according to the UV coordinates of each fragment, and the ground in the safe area is rendered and displayed.
[0100] The ground texture map is sampled according to the UV coordinates of each fragment to obtain the color value of each pixel to be rendered, thereby rendering the ground in the safe area and displaying it when the safe area is displayed in the virtual screen.
[0101] In one example, when displaying a safety area, a fence of the safety area may be rendered around the boundary of the safety area to form a three-dimensional safety area. In this way, when the user's upper limbs approach the fence or cross the fence, a safety prompt may also be given.
[0102] It should be noted that the method for generating the ground of a safety area provided in the embodiment of the present application can be applied to safety areas with regular shapes or safety areas with irregular shapes, and there are no restrictive requirements on the height, shape, number, etc. of the fence.
[0103] like Fig.10 and Fig.11 As shown, the ground display effect of the safety area with regular shape and the ground display effect of the safety area with complex irregular shape provided in the embodiments of the present application are respectively shown, wherein the ground is filled with oblique lines.
[0104] In one example, in order to reduce the interference of safety areas and fences on the virtual screen, when the distance between the user and the boundary of the safety area is greater than a preset distance threshold, it indicates that the probability of the user being in danger is small, and the safety area and fence can be hidden. When the user approaches the boundary of the safety area, the possibility of exceeding the safety area during the VR experience is high. In order to protect the user's safety, the safety area and fence are displayed.
[0105] In one example, when generating a ground rendering grid, you can also set the normal vectors perpendicular to the ground and the initial color values of different effects (such as spotlight effects of different colors) contained in each ground grid (including target boundary points and centroid points). By setting the normal vectors and color values, you can flexibly meet the display requirements of different ground surfaces.
[0106] In specific implementation, the normal vector of each fragment is determined according to the normal vectors of the three points of the ground rendering grid corresponding to each fragment, and the initial color value of each fragment is determined according to the initial color values of the three points of the ground rendering grid corresponding to each fragment. Then, according to the ground effect of the safe area preset in the virtual scene, the initial color value of each fragment is merged with the color value sampled from the ground texture map to obtain the target color value of each fragment; finally, according to the target color value of each fragment, the ground in the safe area is rendered and displayed.
[0107] For example, in a VR dance scene, a red virtual light source will shine on the location of the virtual character to highlight the character. At this time, the initial color value (red) of each fragment and the sampled color value can be fused to render the ground.
[0108] It should be noted that, if there is no special design requirement, the normal vector or color value may not be set, or the color value may be set to white.
[0109] It should be noted that, in the case where a ground texture map is not designed in advance, ground rendering can also be performed directly according to the initial color value and normal vector of each fragment.
[0110] See also Fig.12 , which is a complete implementation process of the safe area ground generation method provided in the embodiment of the present application, mainly includes the following steps:
[0111] S1201: Obtain the original boundary point set of the safety area delineated by the handle ray on the real ground in the perspective mode.
[0112] S1202: Obtain an original boundary point in the original boundary point set, and calculate the vector angle formed by the original boundary point and two adjacent original boundary points on the left and right.
[0113] S1203 determines whether the vector angle is greater than a preset angle threshold, if so, execute S1204, otherwise, execute S1205.
[0114] S1204: The original boundary point is recorded as a first-level inflection point.
[0115] S1205: Determine whether all original boundary points have been traversed, if so, execute S1206, otherwise, return to S1202.
[0116] S1206: Obtain two adjacent first-order inflection points in sequence, and generate a straight line according to the two adjacent first-order inflection points.
[0117] S1207: Obtain an original boundary point between two adjacent first-level inflection points, and calculate the offset from the original boundary point to the straight line.
[0118] S1208: Determine whether the offset is greater than a preset offset threshold, if so, execute S1209, otherwise, execute S1210.
[0119] S1209: The original boundary point is recorded as a secondary inflection point.
[0120] S1210 determines whether the original boundary points between the two adjacent first-level inflection points have been traversed. If so, execute S1211; otherwise, return to S1207.
[0121] S1211: retaining each first-order inflection point and second-order inflection point as a target boundary point, and deleting the remaining original boundary points.
[0122] S1212: Calculate the centroid point of the geometric shape enclosed by each target boundary point, and generate a triangular ground rendering grid by combining each target boundary point.
[0123] S1213: Calculate the UV coordinates of the centroid point and each target boundary point according to the range of the ground texture map.
[0124] S1214: Rasterize each surface rendering grid and interpolate to generate UV coordinates of each fragment.
[0125] S1215: Perform texture sampling according to the UV coordinates of each fragment and render the ground in the safe area.
[0126] S1216: Render a fence of the safety area around the boundary of the safety area.
[0127] S1217: Determine whether the fence is drawn, if so, execute S1218, otherwise, return to S1216.
[0128] S1218: Displaying a safety area with a ground and a fence in a virtual image.
[0129] In a method for generating a safe area ground provided by an embodiment of the present application, the original boundary point set when the user demarcates the safe area on the real ground through the handle ray is screened based on the first-level inflection point and the second-level inflection point, the number of boundary points is reduced, and a simplified target boundary point set is obtained, thereby improving the generation efficiency of the safe area ground. Among them, before rendering the safe area ground, the centroid point of the geometric shape of the safe area surrounded by the target boundary point set is connected to two target boundary points respectively to generate a triangular ground rendering grid. Compared with directly generating a triangular ground rendering grid based on three target boundary points, the standardization of the ground rendering grid is improved, so that it can be applied to the generation requirements of the safe area ground of complex shapes, and the number of boundary points is reduced due to simplification, and the memory occupied by the ground rendering grid is reduced. When rendering the safe area ground, the UV coordinates of the texture sampling are calculated based on the range of the ground texture map and the position coordinates of each ground rendering grid point in the ground space coordinate system, which reduces the range judgment process of the GPU ground rendering grid, further improves the rendering efficiency of the safe area ground, and can prevent the problem of texture compression or stretching when the ground texture map is inconsistent with the size of the safe area ground, and improves the ground display effect of the safe area.
[0130] Based on the same technical concept, an embodiment of the present application provides a virtual reality device, which can implement the steps of the positioning method of the above-mentioned virtual reality device and achieve the same technical effect.
[0131] See also Fig.13 , the virtual reality device processor 1301, memory 1302, display 1303 and communication interface 1304, the communication interface 1304, display 1303, memory 1302 and processor 1301 are connected via a bus 1305;
[0132] The memory 1302 stores a computer program, and the processor 1301 performs the following operations according to the computer program:
[0133] Obtaining, through the communication interface 1304, an original boundary point set of a safety area delineated by the handle ray on the real ground in the perspective mode;
[0134] Select multiple inflection points from the original boundary point set to generate a target boundary point set for the safety area;
[0135] Calculate the centroid point of the geometric shape formed by the target boundary points, and generate a triangular ground rendering grid based on the centroid point and every two target boundary points;
[0136] According to the normalized range of the pre-generated ground texture map, the UV coordinates of the centroid point are determined, and according to the UV coordinates of the centroid point and the range of the ground texture map, the UV coordinates of each target boundary point are determined;
[0137] Rasterize each surface rendering grid, and obtain the UV coordinates of each fragment after rasterization based on the UV coordinates of each target boundary point and centroid point;
[0138] The ground texture map is sampled according to the UV coordinates of each fragment, and the ground in the safe area is rendered and displayed through the display 1303.
[0139] The optional processor 1301 selects multiple inflection points in the original boundary point set to generate a target boundary point set of the safety area. The specific operation is:
[0140] For each original boundary point in the original boundary point set, calculate the vector angles formed by the original boundary point and the adjacent left original boundary point and right original boundary point, and take the original boundary point corresponding to the vector angle greater than the preset angle threshold as a first-level inflection point;
[0141] Determine a straight line according to each two adjacent first-level inflection points, calculate the offset of the original boundary points corresponding to the straight line between each two adjacent first-level inflection points, and take at least one original boundary point with an offset greater than a preset offset threshold as a second-level inflection point;
[0142] A target boundary point set of the safety area is generated according to each primary inflection point and each secondary inflection point.
[0143] Optionally, the processor 1301 determines the UV coordinates of the centroid point according to the range of the pre-generated ground texture map, and determines the UV coordinates of each target boundary point according to the UV coordinates of the centroid point and the range of the ground texture map. The specific operation is:
[0144] Determine the UV coordinates of the centroid point based on the position coordinates of the centroid point and the range of the ground texture map;
[0145] Calculate the relative coordinates of each target boundary point and the centroid point, and determine the UV coordinates of each target boundary point by combining the UV coordinates of the centroid point and the range of the ground texture map.
[0146] Optionally, the formula for the UV coordinates of each target boundary point is expressed as:
[0147]
[0148]
[0149] Among them, (a ix , a iy) represents the position coordinates of the i-th target boundary point, (a 0x , a 0y ) represents the position coordinates of the centroid point, M represents the length of the ground texture map, N represents the width of the ground texture map, (U i , V i ) represents the UV coordinate of the i-th target boundary point, (a 0x / M,a 0y / N) represents the UV coordinates of the centroid point.
[0150] Optionally, when the centroid point is the center point of the range of the ground texture map, the UV coordinates of the centroid point are (0.5, 0.5). Optionally, the processor 1301 calculates the centroid point of the geometric shape surrounded by the target boundary points, and the specific operation is:
[0151] Calculate the sum of the coordinates of each target boundary point in the target boundary point set on each coordinate axis;
[0152] The sum of the coordinates corresponding to each coordinate axis is divided by the total number of target boundary points of the target boundary point set to obtain the centroid point of the geometric shape surrounded by the target boundary point set.
[0153] Optionally, for each point of each ground grid, a normal vector perpendicular to the ground and an initial color value corresponding to different effects are set respectively;
[0154] The processor 1301 samples from the ground texture map according to the UV coordinates of each fragment, renders the ground in the safe area and displays it through the display 1303. The specific operations are:
[0155] For each fragment, determine the normal vector of the fragment according to the normal vectors of the three points of the ground rendering grid corresponding to the fragment, and determine the initial color value of the fragment according to the initial color values of the three points of the ground rendering grid corresponding to the fragment;
[0156] According to the ground effect of the preset safe area in the virtual scene, the initial color value of each fragment is merged with the color value sampled from the ground texture map to obtain the target color value of each fragment;
[0157] According to the target color value of each fragment, the ground in the safe area is rendered and displayed through the display 1303.
[0158] Optionally, when the display 1303 displays the ground in the safety area, the processor 1301 further executes:
[0159] Around the boundary of the safety area, a fence of the safety area is rendered and displayed via display 1303 .
[0160] The memory 1302 may be a volatile memory, such as a random-access memory (RAM); the memory 1302 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or the memory 1302 may be any other medium that can be used to carry or store a desired computer program in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 1302 may be a combination of the above memories;
[0161] The processor 1301 may include one or more central processing units (CPU) or a digital processing unit, etc.
[0162] It should be noted that Fig.13 This is just an example, and provides the necessary hardware for the virtual reality device to execute the steps of a method for generating a safe area ground provided in an embodiment of the present application. If not shown, the virtual reality device may also include conventional hardware such as a speaker, a microphone, and a power supply.
[0163] An embodiment of the present application also provides a computer-readable storage medium for storing some instructions, which, when executed, can complete a method for generating a safe area ground in the aforementioned embodiment.
[0164] An embodiment of the present application also provides a computer program product for storing a computer program, wherein the computer program is used to execute a method for generating a safe area ground in the aforementioned embodiment.
[0165] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0166] The present application is described with reference to the flowchart and / or block diagram of the method, device (system), and computer program product according to the present application. It should be understood that each flow process and / or box in the flow chart and / or block diagram, and the combination of the flow process and / or box in the flow chart and / or block diagram can be realized by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processing machine or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for realizing the function specified in one flow chart or multiple flows and / or one box or multiple boxes in the block diagram.
[0167] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0168] These computer program instructions may also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, whereby the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0169] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A method for generating a safe area ground, characterized in that: include: Get the original boundary point set of the safe area delineated by the handle ray on the real ground in perspective mode; Selecting a plurality of inflection points in the original boundary point set to generate a target boundary point set for the safety area; Calculating the centroid point of the geometric shape formed by the target boundary points, and generating triangular ground rendering grids according to the centroid point and every two target boundary points; Determine the UV coordinates of the centroid point according to the range of the pre-generated ground texture map, and determine the UV coordinates of each target boundary point according to the UV coordinates of the centroid point and the range of the ground texture map; Rasterizing each surface rendering grid, and obtaining the UV coordinates of each fragment after rasterization according to the UV coordinates of each target boundary point and the centroid point; Sampling is performed from the ground texture map according to the UV coordinates of each fragment, and the ground of the safety area is rendered and displayed.
2. The method according to claim 1, characterized in that The step of selecting a plurality of inflection points from the original boundary point set to generate a target boundary point set for the safety area includes: For each original boundary point in the original boundary point set, calculate the vector angles formed by the original boundary point and the adjacent left original boundary point and right original boundary point, and take the original boundary point corresponding to the vector angle greater than a preset angle threshold as a first-level inflection point; Determine a straight line according to each two adjacent first-level inflection points, calculate the offset of the original boundary points corresponding to the straight line between each two adjacent first-level inflection points, and take at least one original boundary point with an offset greater than a preset offset threshold as a second-level inflection point; A target boundary point set of the safety area is generated according to each primary inflection point and each secondary inflection point.
3. The method according to claim 1, characterized in that The step of determining the UV coordinates of the centroid point according to the range of the pre-generated ground texture map, and determining the UV coordinates of each target boundary point according to the UV coordinates of the centroid point and the range of the ground texture map, comprises: Determining the UV coordinates of the centroid point according to the position coordinates of the centroid point and the range of the ground texture map; The relative coordinates of each target boundary point and the centroid point are calculated, and the UV coordinates of each target boundary point are determined by combining the UV coordinates of the centroid point and the range of the ground texture map.
4. The method according to claim 3, characterized in that The formula for the UV coordinates of each target boundary point is expressed as: Among them, (a ix , a iy ) represents the position coordinates of the i-th target boundary point, (a 0x , a 0y ) represents the position coordinates of the centroid point, M represents the length of the ground texture map, N represents the width of the ground texture map, (U i , V i ) represents the UV coordinate of the i-th target boundary point, (a 0x / M,a 0y / N) represents the UV coordinate of the centroid point.
5. The method according to claim 3 or 4, characterized in that When the centroid point is the center point of the range of the ground texture map, the UV coordinate of the centroid point is (0.5, 0.5).
6. The method according to any one of claims 1 to 4, characterized in that The calculating of the centroid point of the geometric shape formed by the target boundary points includes: Calculating the sum of the coordinates of each target boundary point in the target boundary point set on each coordinate axis; The sum of the coordinates corresponding to each coordinate axis is divided by the total number of target boundary points of the target boundary point set to obtain the centroid point of the geometric shape surrounded by the target boundary point set.
7. The method according to claim 1, characterized in that For each point of each ground grid, a normal vector perpendicular to the ground and an initial color value corresponding to different effects are respectively set; The step of sampling from the ground texture map according to the UV coordinates of each fragment, rendering and displaying the ground in the safety area includes: For each fragment, determine the normal vector of the fragment according to the normal vectors of three points of the ground rendering grid corresponding to the fragment, and determine the initial color value of the fragment according to the initial color values of the three points of the ground rendering grid corresponding to the fragment; According to the ground effect of the preset safety area in the virtual scene, the initial color value of each fragment is merged with the color value sampled from the ground texture map to obtain the target color value of each fragment; According to the target color value of each fragment, the ground of the safety area is rendered and displayed.
8. The method according to claim 1 or 7, characterized in that When displaying the ground of the safety area, the method further includes: A fence of the safety area is rendered and displayed around a boundary of the safety area.
9. A virtual reality device, characterized in that: It includes a processor, a memory, a display and a communication interface, wherein the communication interface, the display, the memory and the processor are connected via a bus; The memory stores a computer program, and the processor performs the following operations according to the computer program: Obtaining, through the communication interface, an original boundary point set of a safety area delineated by the handle ray on the real ground in perspective mode; Selecting a plurality of inflection points in the original boundary point set to generate a target boundary point set for the safety area; Calculating the centroid point of the geometric shape formed by the target boundary points, and generating a triangular ground rendering grid according to the centroid point and every two target boundary points; Determine the UV coordinates of the centroid point according to the normalized range of the pre-generated ground texture map, and determine the UV coordinates of each target boundary point according to the UV coordinates of the centroid point and the range of the ground texture map; Rasterizing each surface rendering grid, and obtaining the UV coordinates of each fragment after rasterization according to the UV coordinates of each target boundary point and the centroid point; Sampling is performed from the ground texture map according to the UV coordinates of each fragment, and the ground of the safety area is rendered and displayed through the display.
10. The virtual reality device according to claim 9, characterized in that: For each point of each ground grid, a normal vector perpendicular to the ground and an initial color value corresponding to different effects are respectively set; The processor samples from the ground texture map according to the UV coordinates of each fragment, renders the ground of the safety area and displays it through the display, and the specific operations are: For each fragment, determine the normal vector of the fragment according to the normal vectors of three points of the ground rendering grid corresponding to the fragment, and determine the initial color value of the fragment according to the initial color values of the three points of the ground rendering grid corresponding to the fragment; According to the ground effect of the preset safety area in the virtual scene, the initial color value of each fragment is merged with the color value sampled from the ground texture map to obtain the target color value of each fragment; According to the target color value of each fragment, the ground of the safety area is rendered and displayed through the display.