Road generation method and device, electronic equipment and computer readable storage medium
By obtaining the road information of the virtual road and determining the offset information of the mesh model vertex, generating the deformation mesh model and performing batch rendering, the problem of high overhead of virtual road rendering in the prior art is solved and game performance is improved.
Patent Information
- Application Number
- CN202411537378.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-30
- Publication Date
- 2025-02-25
AI Technical Summary
When generating virtual roads in games, the GPU cannot render in batches due to different small models, resulting in high rendering overhead, reduced game frame rate, and lag.
By obtaining the road information of the virtual road, including multiple control points of each virtual road section, the offset information of the vertices on the preset grid model is determined, and the deformation grid model is obtained, and batch rendering is performed to generate the virtual road.
It realizes the batch rendering of grid models after different deformations during rendering, which reduces the rendering overhead, increases the game frame rate, and reduces the probability of lag.
Smart Images

Figure CN119516151A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of virtual path technology, and in particular to a road generation method, device, electronic device and computer-readable storage medium. Background Art
[0002] As games develop, the game screen becomes more and more rich. For example, various virtual roads can be displayed on the game screen.
[0003] The current method for generating virtual roads in games is: divide the grid model into multiple small models, each small model represents a road section, generate decals for each small model through RVT decal technology, render according to the small models and their decals, and generate virtual roads.
[0004] However, during this process, since each small model is different, the GPU cannot batch render the small models according to the decals, resulting in high rendering overhead, reduced game frame rate, and causing lag. Summary of the invention
[0005] The embodiments of the present application provide a road generation method, device, electronic device and computer-readable storage medium, which can perform batch rendering, reduce rendering overhead, and reduce the probability of lag.
[0006] In a first aspect, an embodiment of the present application provides a road generation method, the method comprising:
[0007] Acquire road information corresponding to the virtual road to be generated, the road information including a plurality of control points of each virtual road section in the virtual road;
[0008] Based on the control information of the plurality of control points of the virtual road segment, determining the offset information of the vertices on the preset grid model for the virtual road segment;
[0009] According to the offset information for the virtual road section, the vertices on the preset mesh model are offset to obtain a deformed mesh model for the virtual road section;
[0010] The deformed mesh models of the virtual road sections are batch rendered to generate the virtual road.
[0011] In a second aspect, an embodiment of the present application further provides a road generation device, the device comprising:
[0012] An acquisition module, used to acquire road information corresponding to the virtual road to be generated, wherein the road information includes a plurality of control points of each virtual road section in the virtual road;
[0013] A determination module, configured to determine offset information of vertices on a preset grid model for the virtual road segment based on control information of a plurality of control points of the virtual road segment;
[0014] An offset module, used for offsetting the vertices on the preset mesh model according to the offset information for the virtual road section, to obtain a deformed mesh model for the virtual road section;
[0015] The rendering module is used to batch render the deformed mesh models of the virtual road sections to generate the virtual roads.
[0016] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a memory storing a plurality of instructions; the above-mentioned processor loads instructions from the above-mentioned memory to execute any one of the road generation methods provided in the embodiments of the present application.
[0017] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for loading by a processor to execute any one of the road generation methods provided in the embodiment of the present application.
[0018] In an embodiment of the present application, road information corresponding to a virtual road to be generated is obtained, the road information including multiple control points for each virtual road section in the virtual road; based on the control information of the multiple control points of the virtual road section, the offset information of the vertices on the preset grid model for the virtual road section is determined; according to the offset information for the virtual road section, the vertices on the preset grid model are offset to obtain a deformed grid model for the virtual road section; the deformed grid models for the virtual road section are batch rendered to generate a virtual road. Since different deformed grid models are obtained by deforming the same preset grid model during rendering, rendering different deformed grid models is equivalent to rendering the same preset grid model. Therefore, different deformed grid models can be batch rendered to reduce rendering overhead, improve game frame rate, and reduce the probability of lag. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.
[0020] Figure 1 This is a schematic diagram of an embodiment of the road generation method provided in the embodiment of the present application;
[0021] Figure 2is a schematic diagram of a preset grid model provided in an embodiment of the present application;
[0022] Figure 3 is a schematic diagram of control points provided in an embodiment of the present application;
[0023] Figure 4 is a schematic diagram of the vertices provided in the embodiments of the present application;
[0024] Figure 5 is a schematic diagram of a virtual road section provided in an embodiment of the present application;
[0025] Figure 6 is another schematic diagram of a virtual road section provided in an embodiment of the present application;
[0026] Figure 7 is another schematic diagram of the control points provided in the embodiments of the present application;
[0027] Figure 8 is a schematic diagram of a virtual road provided in an embodiment of the present application;
[0028] Fig. 9 It is a schematic diagram of another embodiment flow chart of the road generation method provided in the embodiments of the present application;
[0029] Fig.10 This is a node diagram for determining candidate offset information and width change information provided by an embodiment of the present application;
[0030] Fig.11 It is an internal structure diagram of the "MF_CR_calculateWidthScale" node provided in an embodiment of the present application;
[0031] Fig.12 is a node diagram for determining target offset information and adjusted texture vectors provided in an embodiment of the present application;
[0032] Fig.13 It is an internal structure diagram of the "MF_CR_calculateNormal" node provided in an embodiment of the present application;
[0033] Fig.14 It is a schematic diagram of nodes for determining target texture coordinates, performing offsets, and performing rendering provided by an embodiment of the present application;
[0034] Fig.15 is a schematic diagram of all nodes for generating a virtual road provided in an embodiment of the present application;
[0035] Fig.16 is a schematic diagram of the structure of a road generation device provided in an embodiment of the present application;
[0036] Fig.17It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of this application.
[0038] Before explaining the embodiments of the present application in detail, some terms involved in the embodiments of the present application are first explained.
[0039] Among them, in the description of the embodiment of the present application, the terms "first", "second", etc. can be used in this article to describe various concepts, but unless otherwise specified, these concepts are not limited by these terms. These terms are only used to distinguish one concept from another concept. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices. "Multiple" refers to two or more.
[0040] The embodiments of the present application provide a road generation method, device, electronic device and computer-readable storage medium. Specifically, the road generation method of the embodiments of the present application can be executed by an electronic device, wherein the electronic device can be a terminal or a server.
[0041] The terminal can be a terminal device such as a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC), a personal digital assistant (PDA), etc. The terminal can also include a client, which can be a game application client, a browser client carrying a game program, or an instant messaging client, etc.
[0042] The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), as well as big data and artificial intelligence platforms.
[0043] The following is a detailed description of the embodiments in conjunction with the accompanying drawings. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments. Although the logical order is shown in the flow chart, in some cases, the steps shown or described may be performed in an order different from that shown in the accompanying drawings.
[0044] In this embodiment, a terminal is used as an example for explanation. This embodiment provides a road generation method, such as Figure 1 As shown, the specific process of the road generation method can be as follows:
[0045] 101. Obtain road information corresponding to a virtual road to be generated, where the road information includes a plurality of control points of each virtual road section in the virtual road.
[0046] The virtual road includes at least two virtual sections. The multiple control points of a virtual section are used to control the generation of the virtual section, that is, after the virtual section is generated according to the control points, the virtual section includes multiple control points. The multiple control points of a virtual section may include at least two.
[0047] For example, the virtual road includes a virtual section r1 and a virtual section r2. The multiple control points of the virtual section r1 include a1, a2, a3 and a4. The multiple control points of the virtual section r2 include a4, a5, a6 and a7. The virtual road r1 is generated according to a1, a2, a3 and a4, and the virtual road r2 is generated according to a4, a5, a6 and a7.
[0048] Optionally, the terminal may obtain the road information corresponding to the virtual road from other devices, or the terminal device may also obtain the road information corresponding to the virtual road in response to user input, which is not limited in the embodiments of the present application.
[0049] 102. Determine offset information of vertices on a preset grid model for the virtual road section based on control information of a plurality of control points of the virtual road section.
[0050] Among them, the offset information of the vertices on the preset mesh model for the virtual road section can be determined by the vertex shader based on the control information of multiple control points of the virtual road section.
[0051] The vertex shader is located in the graphics processing unit (GPU). The control information of the control point refers to the information needed to control the generation of the virtual road segment. For example, the control information of the control point can be the coordinate information of the control point. For another example, the control information of the control point can include the coordinate information of the control point and the width information corresponding to the control point. The width information corresponding to the control point is used to indicate the left and right widths corresponding to the control point.
[0052] A preset mesh model (mesh model) is a model that uses a series of polygons (usually triangles) of similar size and shape to approximate a three-dimensional object. For example, a preset mesh model can be as follows: Figure 2 shown.
[0053] When the control points of the virtual road segment are different, the offset information determined based on the control information of multiple control points is also different. Therefore, based on the control information of multiple control points of each virtual road segment, the offset information of the vertices on the preset grid model for each virtual road segment can be determined.
[0054] In some embodiments, based on the control information of the plurality of control points of the virtual road segment, determining the offset information of the vertices on the preset grid model for the virtual road segment includes:
[0055] Obtaining a preset corresponding relationship, where the preset corresponding relationship indicates a corresponding relationship between a control point and a vertex;
[0056] According to the preset corresponding relationship, determining the vertices corresponding to the multiple control points of the virtual road section in the preset grid model;
[0057] According to the control information of the multiple control points, the offset information of the vertices corresponding to the multiple control points on the preset grid model with respect to the virtual road section is determined.
[0058] Among them, the proportion of the vertex on the preset grid model can be represented by the ratio between the coordinate information of the vertex on the target coordinate axis and the length of the preset grid model on the target coordinate axis. For example, the target coordinate axis is the y-axis, the coordinate information of the vertex on the target coordinate axis is the y-coordinate value of the vertex, the y-coordinate value of vertex 1 is 0 times the length value of the preset grid model, the y-coordinate value of vertex 2 is 1 / 3 of the length value of the preset grid model, the y-coordinate value of vertex 3 is 2 / 3 of the length value of the preset grid model, and the y-coordinate value of vertex 4 is 1 times the length value of the preset grid model. Then vertex 1 is located at the 0 position of the preset grid model, vertex 2 is located at the 1 / 3 position of the preset grid model, vertex 3 is located at the 2 / 3 position of the preset grid model, and vertex 4 is located at the 1 position of the preset grid model.
[0059] When there is a preset correspondence between multiple control points of a virtual road segment and vertices on a preset grid model, it indicates that the positions of the multiple control points are the positions of the vertices after the vertices are offset. For example, the multiple control points include a1, a2, a3, and a4, a1 is the first control point, a2 is the second control point, a3 is the third control point, and a4 is the fourth control point. The preset correspondence is that the first control point corresponds to the vertex at the 0 position of the preset grid model, the second control point corresponds to the vertex at the 1 / 3 position of the preset grid model, the third control point corresponds to the vertex at the 1 / 3 position of the preset grid model, and the fourth control point corresponds to the vertex at the 1 position of the preset grid model. The vertex at the 0 position of the preset grid model is vertex 1, the vertex at the 1 / 3 position of the preset grid model is vertex 2, the vertex at the 2 / 3 position of the preset grid model is vertex 3, and the vertex at the 1 position of the preset grid model is vertex 4. Therefore, the position of a1 is the position of vertex 1 after the vertices are offset, the position of a2 is the position of vertex 2 after the vertices are offset, the position of a3 is the position of vertex 3 after the vertices are offset, and the position of a4 is the position of vertex 4 after the vertices are offset.
[0060] After determining the vertex corresponding to the control point, since the position of the control point is the position of the corresponding vertex after offset, the control information of the control point includes the coordinate information of the control point. Therefore, the coordinate information of the control point and the coordinate information of the vertex corresponding to the control point can be subtracted to obtain the offset information of the vertex corresponding to the control point.
[0061] For example, multiple control points include a1, a2, a3 and a4, the vertex corresponding to a1 is vertex 1, the vertex corresponding to a2 is vertex 2, the vertex corresponding to a3 is vertex 3, and the vertex corresponding to a4 is vertex 4. The coordinate information of a1 is subtracted from the coordinate information of vertex 1 to obtain the offset information of vertex 1, the coordinate information of a2 is subtracted from the coordinate information of vertex 2 to obtain the offset information of vertex 2, the coordinate information of a3 is subtracted from the coordinate information of vertex 3 to obtain the offset information of vertex 3, and the coordinate information of a4 is subtracted from the coordinate information of vertex 4 to obtain the offset information of vertex 4.
[0062] It is understandable that when the number of control points is large, all vertices on the preset grid model have corresponding control points, so the offset information of the vertices on the preset grid model for the virtual road section can be directly obtained. When the number of control points is small, there may be no corresponding control points for the vertices on the preset grid model. In this case, interpolation processing can be performed based on multiple control points to obtain interpolation points, and then the offset information of the vertices corresponding to the interpolation points is determined based on the interpolation information of the interpolation points (the interpolation information may include the coordinate information of the interpolation points). At this time, based on the control information of multiple control points of the virtual road section, the offset information of the vertices on the preset grid model for the virtual road section is determined, including:
[0063] Obtaining positional relationship parameters between vertices on a preset mesh model and the preset mesh model;
[0064] Based on the position relationship parameters and the control information of the multiple control points for the virtual road section, the offset information of the vertices on the preset grid model for the virtual road section is determined.
[0065] The position relationship parameter can be determined based on the coordinate information of the vertex on the target coordinate axis and the length of the preset grid model on the target coordinate axis, and is used to indicate the proportion of the vertex on the preset grid model. For example, the position relationship parameter can be 1 / 3, indicating that the vertex is at 1 / 3 of the preset grid model.
[0066] The terminal may perform interpolation processing based on the position relationship parameters and the control information of multiple control points of the virtual road segment to obtain interpolation information of the interpolation points, and determine the offset information of the vertex corresponding to the interpolation point for the virtual road segment according to the interpolation information of the interpolation points.
[0067] Since the position relationship parameters represent the proportion of the vertex on the preset grid model, interpolation processing is performed based on the position relationship parameters and the control information of multiple control points of the virtual road section, and the position of the interpolation point obtained is the position of the vertex after offset on the proportion indicated by the position relationship parameters.
[0068] For example, if the position relationship parameter is 1 / 3, interpolation processing is performed based on 1 / 3 and the control information of multiple control points, and the interpolation point obtained is the point at the 1 / 3 position of the curve connected by the control points. At this time, the interpolation point is the position after the vertex is offset at the 1 / 3 position of the preset mesh model.
[0069] Optionally, the position relationship parameters may not include the position relationship parameters between the vertex corresponding to the control point and the preset grid model. The terminal may determine the vertex corresponding to the control point in the preset grid model based on the preset corresponding relationship, perform interpolation processing based on the position relationship parameters between the vertex and the preset grid model and the control information of multiple control points to obtain the interpolation point corresponding to the vertex, subtract the control information of the control point from the coordinate information of the vertex corresponding to the control point on the preset grid model to obtain the offset information of the vertex corresponding to the control point, and subtract the interpolation information of the interpolation point corresponding to the vertex from the coordinate information of the vertex to obtain the offset information of the vertex.
[0070] For example, multiple control points include a1 and a2. Vertex 1 corresponds to control point a1. The position of a1 is the offset position of vertex 1. The coordinate information of a1 is subtracted from the coordinate information of vertex 1 to obtain the offset information of vertex 1. Vertex 4 corresponds to control point a2. The position of a2 is the offset position of vertex 4. The coordinate information of a2 is subtracted from the coordinate information of vertex 4 to obtain the offset information of vertex 4. Since there are no corresponding control points for vertex 2 and vertex 3, it is necessary to obtain the interpolation points corresponding to vertex 2 and vertex 3 through interpolation processing. Vertex The position relationship parameter of vertex 2 is t11, and the position relationship parameter of vertex 3 is t12. Interpolation processing is performed according to t11, a1 and a2 to obtain the interpolation point c1. The position of interpolation point c1 is the position of vertex 2 after offset. The coordinate information of interpolation point c1 is subtracted from the coordinate information of vertex 2 to obtain the offset information of vertex 2. Interpolation processing is performed according to t12, a1 and a2 to obtain the interpolation point c2. The position of interpolation point c2 is the position of vertex 3 after offset. The coordinate information of interpolation point c2 is subtracted from the coordinate information of vertex 3 to obtain the offset information of vertex 3.
[0071] Alternatively, the position relationship parameter may include a position relationship parameter between a vertex corresponding to the control point and a preset grid model. In this case, based on the position relationship parameter and control information of a plurality of control points for the virtual road segment, the offset information of the vertex on the preset grid model for the virtual road segment is determined, including:
[0072] Performing interpolation processing based on the position relationship parameters and the control information of the multiple control points of the virtual road section to obtain interpolation information of the interpolation points;
[0073] Based on the interpolation information of the interpolation point, the offset information of the vertex on the preset grid model for the virtual road segment is determined.
[0074] Among them, since the position relationship parameters include the position relationship parameters between the vertex corresponding to the control point and the preset grid model, the interpolation point includes the control point. At this time, the interpolation information of the interpolation point and the coordinate information of the vertex corresponding to the interpolation point on the preset grid model can be directly subtracted to obtain the offset information of the vertex.
[0075] For example, multiple control points include a1 and a2, the position relationship parameter of vertex 1 is t1, the position relationship parameter of vertex 2 is t11, the position relationship parameter of vertex 3 is t12, and the position relationship parameter of vertex 4 is t2. Interpolation processing is performed according to t1, a1 and a2 to obtain interpolation point c1, which is control point a1. The position of interpolation point c1 is the position of vertex 1 after offset. The coordinate information of interpolation point c1 is subtracted from the coordinate information of vertex 1 to obtain the offset information of vertex 2. Interpolation processing is performed according to t11, a1 and a2 to obtain interpolation point c2. The position of interpolation point c2 is the position of vertex 2 after offset. Subtract the coordinate information of the interpolation point c2 from the coordinate information of vertex 2 to obtain the offset information of vertex 2. Perform interpolation processing according to t12, a1 and a2 to obtain the interpolation point c3. The position of the interpolation point c3 is the position of vertex 3 after offset. Subtract the coordinate information of the interpolation point c3 from the coordinate information of vertex 3 to obtain the offset information of vertex 3. Perform interpolation processing according to t2, a1 and a2 to obtain the interpolation point c4. The interpolation point c4 is the control point a2. The position of the interpolation point c4 is the position of vertex 4 after offset. Subtract the coordinate information of the interpolation point c4 from the coordinate information of vertex 4 to obtain the offset information of vertex 4.
[0076] It can be understood that, since the preset grid model includes at least one vertex with the same coordinate information on the target coordinate axis, and the positional relationship parameters between the vertices with the same coordinate information on the target coordinate axis and the preset grid model are the same, a control point may correspond to at least one vertex on the preset grid model. For example, if the control point is a2, and a2 corresponds to the vertex at the 1 / 3 position of the preset grid model, then the 1 / 3 position of the preset grid model includes 8 vertices, and the vertices corresponding to the control point include 8.
[0077] In this embodiment, the position relationship parameters between the vertices on the preset grid model and the preset grid model are obtained, and based on the position relationship parameters and the control information of multiple control points for the virtual road section, the offset information of the vertices on the preset grid model for the virtual road section is determined.
[0078] In some embodiments, obtaining position relationship parameters between vertices on a preset mesh model and the preset mesh model includes:
[0079] Get the length of the preset grid model;
[0080] Based on the number of multiple control points of the virtual road segment, the length is divided to obtain multiple length ranges;
[0081] According to the length range, position relationship parameters between vertices on the preset mesh model and the preset mesh model are determined.
[0082] Among them, since segmented interpolation can be performed during the interpolation processing, in the segmented interpolation, the position relationship parameters are used to indicate the proportion of the vertex in the segment length of the preset grid model. Therefore, the length can be divided based on the number of multiple control points of the virtual road section to obtain multiple length ranges, and the position relationship parameters between the vertices on the preset grid model and the preset grid model are determined according to the length range.
[0083] For example, if the number of the multiple control points is 4, the length of the preset grid model on the target coordinate axis can be divided into 3 length ranges, and the position relationship parameters of the vertices within the length range represent the proportion of the vertex in the length range.
[0084] Each length range has the same length, and the specific value of each length range can be set according to the length of the preset grid model. For example, if the length of the preset grid model is 900 and the number of multiple control points is 4, the three length ranges obtained are 0-300, 300-600 and 600-900, and the lengths of the three length ranges are all 300.
[0085] After obtaining multiple length ranges, the terminal can determine the length range of the vertex based on the coordinate information of the vertex on the target coordinate axis, and map the coordinate information of the vertex on the target coordinate axis according to the mapping strategy corresponding to the length range of the vertex to obtain the coordinate information of the vertex for the length range, and divide the coordinate information of the vertex for the length range by the length corresponding to the length range to obtain the position relationship parameters of the vertex.
[0086] For example, the target coordinate axis is the y-axis, the coordinate information of the vertex on the target coordinate axis is the y value of the vertex, the length of the preset grid model on the y-axis is d, the number of multiple control points is 4, namely a1, a2, a3 and a4, and the three length ranges obtained by division are 0-d / 3, d / 3-2d / 3 and 2d / 3-d, respectively. The length corresponding to each length range is d / 3, a1 corresponds to the vertex at position 0 in the preset grid model, a2 corresponds to the vertex at position d / 3 in the preset grid model, a3 corresponds to the vertex at position 2d / 3 in the preset grid model, and a4 corresponds to the vertex at position d in the preset grid model.
[0087] If the y value of the vertex is less than or equal to d / 3, it means that the length range of the vertex is 0-d / 3, and the mapping strategy corresponding to 0-d / 3 is v=y. At this time, v represents the coordinate information of the vertex for 0-d / 3. Divide v by d / 3 to obtain the position relationship parameter of the vertex. For example, the y value of the vertex is 200 and d is 900, then the position relationship parameter of the vertex is 2 / 3, indicating that the vertex is at the 2 / 3 position in 0-d / 3. At this time, interpolation processing is performed based on the position relationship parameter and the control information of the control point, and the interpolation point at the 2 / 3 position between a1 and a2 can be obtained. The interpolation point at the 2 / 3 position between a1 and a2 is the interpolation point corresponding to the vertex, and the position of the interpolation point at the 2 / 3 position between a1 and a2 is the position of the vertex after offset.
[0088] If the y value of the vertex is greater than d / 3 and less than or equal to 2d / 3, it means that the length range of the vertex is d / 3-2d / 3, and the mapping strategy corresponding to d / 3-2d / 3 is v=yd / 3. At this time, v represents the coordinate information of the vertex for d / 3-2d / 3. Divide v by d / 3 to obtain the position relationship parameter of the vertex. For example, the y value of the vertex is 400 and d is 900, then the position relationship parameter of the vertex is 1 / 3, indicating that the vertex is at the 1 / 3 position in d / 3-2d / 3. At this time, interpolation processing is performed based on the position relationship parameters and the control information of the control point to obtain the interpolation point at the 1 / 3 position between a2 and a3. The interpolation point at the 1 / 3 position between a2 and a3 is the interpolation point corresponding to the vertex, and the position of the interpolation point at the 1 / 3 position between a2 and a3 is the position of the vertex after offset.
[0089] If the y value of the vertex is greater than 2d / 3 and less than or equal to d, it means that the length range of the vertex is 2d / 3-d, and the mapping strategy corresponding to 2d / 3-d is v=y-2d / 3. At this time, v represents the coordinate information of the vertex for 2d / 3-d. Divide v by d / 3 to obtain the position relationship parameter of the vertex. For example, the y value of the vertex is 800 and d is 900, then the position relationship parameter of the vertex is 2 / 3, indicating that the vertex is at the 2 / 3 position in 2d / 3-d. At this time, interpolation processing is performed based on the position relationship parameter and the control information of the control point to obtain the interpolation point at the 2 / 3 position between a3 and a4. The interpolation point at the 2 / 3 position between a3 and a4 is the interpolation point corresponding to the vertex, and the position of the interpolation point at the 2 / 3 position between a3 and a4 is the position of the vertex after offset.
[0090] In an embodiment of the present application, the length of a preset grid model is obtained, and based on the number of multiple control points of a virtual road segment, the length is divided to obtain multiple length ranges. According to the length ranges, the position relationship parameters between the vertices on the preset grid model and the preset grid model are determined, and the position relationship parameters are determined based on the length range. This allows segmented interpolation processing to be performed using the position relationship parameters and the control information of the control points, thereby making the offset information of the vertices determined according to the interpolation points more accurate.
[0091] In some embodiments, when determining the interpolation points corresponding to the vertices within each length range, the control points corresponding to the vertices at the endpoints of each length range and the control points adjacent to them are required. When the adjacent control points do not exist, virtual control points can be determined based on the control points, and interpolation processing is performed according to the control information of the control points, the control information of the virtual control points, and the position relationship parameters to obtain the interpolation points corresponding to the vertices within each length range.
[0092] For example, the target coordinate axis is the y-axis, the coordinate information of the vertex on the target coordinate axis is the y value of the vertex, the length of the preset grid model on the y-axis is d, the number of multiple control points is 4, namely a1, a2, a3 and a4, and the three length ranges obtained by division are 0-d / 3, d / 3-2d / 3 and 2d / 3-d, respectively. The length corresponding to each length range is d / 3, a1 corresponds to the vertex at position 0 in the preset grid model, a2 corresponds to the vertex at position d / 3 in the preset grid model, a3 corresponds to the vertex at position 2d / 3 in the preset grid model, and a4 corresponds to the vertex at position d in the preset grid model.
[0093] When determining the interpolation points corresponding to the vertices within the length range 0-d / 3, that is, when determining the interpolation points between a1 and a2, the control points corresponding to the vertices on the end points of the length range 0-d / 3 are a1 and a2, the control point adjacent to a2 and located after a2 is a3, and the control point adjacent to a1 and located before a1 does not exist. Therefore, based on a1 and a2, a virtual control point adjacent to a1 and located before a1 is determined.
[0094] For example, a1, a2, a3 and a4 can be Figure 3 As shown in 301, the virtual control point adjacent to a1 and located before a1 can be Figure 3 a11 shown in 301.
[0095] When determining the interpolation points corresponding to the vertices within the length range d / 3-2d / 3, that is, when determining the interpolation points between a2 and a3, the control points corresponding to the vertices on the end points of the length range d / 3-2d / 3 are a2 and a3, the control point adjacent to a3 and located after a3 is a4, and the control point adjacent to a2 and located before a2 is a1. At this time, there is no need to determine the virtual control points.
[0096] When determining the interpolation points corresponding to the vertices within the length range 2d / 3-d, that is, when determining the interpolation points between a3 and a4, the control points corresponding to the vertices on the end points of the length range 2d / 3-d are a3 and a4, and the control point adjacent to a4 and located after a4 does not exist. The control point adjacent to a3 and located before a3 is a2. Therefore, based on a2 and a4, a virtual control point adjacent to a4 and located after a4 is determined.
[0097] For example, a1, a2, a3 and a4 can be Figure 3 As shown in 302, the virtual control point adjacent to a4 and located after a4 can be Figure 3 a41 shown in 302.
[0098] In some embodiments, since the preset grid model includes multiple vertices with the same coordinate information on the target coordinate axis, and the offset information of the vertices with the same coordinate information on the target coordinate axis is the same, the offset information of other vertices with the same coordinate information on the target coordinate axis can be determined according to the offset information of one of the vertices with the same coordinate information on the target coordinate axis, so that there is no need to directly calculate the offset information of other vertices, thereby reducing the amount of calculation. In this case, the preset grid model is an axisymmetric model, the preset grid model includes a first vertex and a second vertex, the first vertex is a vertex on the center line of the preset grid model, the second vertex is a vertex in the preset grid model other than the first vertex, the position relationship parameter is the position relationship parameter of the first vertex, and based on the position relationship parameter and the control information of multiple control points for the virtual road segment, the offset information of the vertex on the preset grid model for the virtual road segment is determined, including:
[0099] Determine the offset information of the first vertex for the virtual road segment based on the position relationship parameter and the control information of the plurality of control points for the virtual road segment;
[0100] The offset information of a second vertex within the length range where the first vertex is located is determined according to the offset information of the first vertex with respect to the virtual road segment.
[0101] The vertex on the midline of the preset grid model is called the first vertex, and the second vertex is the vertex in the preset grid model other than the first vertex. The midline of the preset grid model can be a line that actually exists in the preset grid model, or a line that does not exist in the preset grid model. When the midline is a line that does not exist in the preset grid model, each vertex at the middle position of the preset grid model can be obtained, and each vertex at the middle position is the first vertex.
[0102] The terminal can perform interpolation processing based on the position relationship parameters of the first vertex and the control information of multiple control points to obtain interpolation points, and determine the offset information of the first vertex according to the interpolation information of the interpolation points. When the second vertex in the preset grid model is read, since the second vertex with the same coordinate information as the first vertex on the target coordinate axis is located in the same length range as the first vertex, the offset information of the first vertex is determined as the offset information of the second vertex with the same coordinate information as the first vertex on the target coordinate axis.
[0103] For example, if the target coordinate axis is the y-axis, the coordinate information on the target coordinate axis is the y value, and the first vertex can be Figure 4 The vertices 1, 2, 3, 4, 5 and 6 are shown, the second vertices are 31, 32, 33, 34 and 21, the length ranges are L1, L2 and L3 respectively, the multiple control points are a1, a2, a3 and a4, wherein a1 corresponds to the vertex 1, a2 corresponds to the vertex 4, a3 corresponds to the vertex 6, a4 corresponds to the vertex 9, the virtual control point is determined according to a1 and a2, the interpolation processing is performed according to the control information of the virtual control point, the control information of a1, the control information of a2, the control information of a3 and the position relationship parameters of the vertex 2, and the interpolation point corresponding to the vertex 2 is obtained, and the interpolation point information and the vertex 2 are obtained according to the interpolation information of the interpolation point. The offset information of vertex 2 is determined to be p1. Interpolation is performed according to the control information of the virtual control point, the control information of a1, the control information of a2, the control information of a3 and the positional relationship parameters of vertex 3 to obtain the interpolation point corresponding to vertex 3. According to the interpolation information of the interpolation point and the coordinate information of vertex 3, the offset information of vertex 3 is determined to be p2. Since the y values of vertex 31, vertex 32, vertex 33 and vertex 34 are the same as the y value of vertex 3, p1 is used as the offset information of vertex 31, vertex 32, vertex 33 and vertex 34. Since the y value of vertex 21 is the same as the y value of vertex 2, p2 is used as the offset information of vertex 21.
[0104] Alternatively, after obtaining the offset information of the first vertex, the first vertex can be offset to obtain the curve corresponding to the center line, and the curve corresponding to the center line is composed of sub-curves corresponding to each length range. Therefore, according to the offset information of the first vertex for the virtual road section, the offset information of the second vertex within the length range where the first vertex is located is determined. It can be understood that according to the offset information, the first vertex is offset to obtain the sub-curve, the sub-curve where the second vertex is located is determined, and the coordinate information of the second vertex is input into the expression corresponding to the sub-curve for calculation to obtain the offset information of the second vertex.
[0105] For example, if the target coordinate axis is the y-axis, the coordinate information on the target coordinate axis is the y value, and the first vertex can be Figure 4The vertices 1, 2, 3, 4, 5 and 6 are shown, the second vertices are 31, 32, 33, 34 and 21, the length ranges are L1, L2 and L3 respectively, the multiple control points are a1, a2, a3 and a4, wherein a1 corresponds to the vertex 1, a2 corresponds to the vertex 4, a3 corresponds to the vertex 6, a4 corresponds to the vertex 9, the virtual control point is determined according to a1 and a2, the interpolation processing is performed according to the control information of the virtual control point, the control information of a1, the control information of a2, the control information of a3 and the position relationship parameters of the vertex 2 to obtain the interpolation point corresponding to the vertex 2, and the offset information of the vertex 2 is determined according to the interpolation information of the interpolation point and the coordinate information of the vertex 2 as p1 , interpolation processing is performed according to the control information of the virtual control point, the control information of a1, the control information of a2, the control information of a3 and the position relationship parameters of vertex 3 to obtain the interpolation point corresponding to vertex 3, and the offset information of vertex 3 is determined as p2 according to the interpolation information of the interpolation point and the coordinate information of vertex 3. According to the control information of a1 and the coordinate information of vertex 1, the offset information p3 of vertex 1 is determined. According to the control information of a2 and the coordinate information of vertex 4, the offset information of vertex 4 is determined as p4. According to p1, the vertex 2 of the midline is offset, according to p2, the vertex 3 of the midline is offset, according to p3, the vertex 1 of the midline is offset, and according to p4, the vertex 4 of the midline is offset. The sub-curve corresponding to the length range L1 can be obtained as follows Figure 4 As shown, the offset information of vertex 31 , vertex 32 , vertex 33 , vertex 34 and vertex 21 are calculated based on the sub-curve of length range L1 .
[0106] In an embodiment of the present application, based on position relationship parameters and control information of multiple control points for a virtual road segment, the offset information of the first vertex for the virtual road segment is determined, and based on the offset information of the first vertex for the virtual road segment, the offset information of the second vertex within the length range of the first vertex is determined, thereby reducing the amount of calculation for determining the offset information.
[0107] In some embodiments, based on the position relationship parameter and the control information of the plurality of control points for the virtual road segment, determining the offset information of the vertices on the preset grid model for the virtual road segment includes:
[0108] Determine candidate offset information of vertices on the preset grid model on three coordinate axes for the virtual road section based on the position relationship parameters and control information for multiple control points of the virtual road section;
[0109] The candidate offset information of the vertices on the preset grid model on the target coordinate axis for the virtual road section is corrected to obtain the offset information of the vertices on the preset grid model for the virtual road section, and the target coordinate axis is one of the three coordinate axes.
[0110] Among them, after determining the candidate offset information of the vertices on the preset grid model on the three coordinate axes for the virtual road segment based on the position relationship parameters and the control information of the multiple control points for the virtual road segment, if the candidate offset information for the virtual road segment on the target coordinate axis is not corrected (for example, when the target coordinate axis is the y-axis, the candidate offset information for the y-axis in the candidate offset information of the virtual road segment is not corrected), the two sides of the finally generated virtual road segment will be vertical on the target coordinate axis, for example, Figure 5 shown.
[0111] Therefore, in an embodiment of the present application, based on the position relationship parameters and the control information of multiple control points for the virtual road section, the candidate offset information of the vertices on the preset grid model for the virtual road section on the three coordinate axes is determined, and the candidate offset information of the vertices on the preset grid model for the virtual road section on the target coordinate axis is corrected to obtain the offset information of the vertices on the preset grid model for the virtual road section, and the target coordinate axis is one of the three coordinate axes, so that the virtual road section finally generated according to the offset information is more natural.
[0112] For example, correct the virtual road segment before Figure 5 As shown in the figure, the corrected virtual road segment is as follows Figure 6 shown.
[0113] In some embodiments, the control information of the control point includes coordinate information and width information, the candidate offset information is determined according to the coordinate information, and the candidate offset information of the vertex on the preset grid model for the virtual road section on the target coordinate axis is corrected to obtain the offset information of the vertex on the preset grid model for the virtual road section, including:
[0114] Determining, based on the control information of the plurality of control points for the virtual road segment, a normal direction of a tangent line of the vertex after being offset according to the offset information for the virtual road segment;
[0115] According to the normal direction and width information, the candidate offset information of the vertices on the preset grid model on the target coordinate axis for the virtual road section is corrected to obtain the offset information of the vertices on the preset grid model for the virtual road section.
[0116] When the positional relationship parameter is determined based on the length range, the normal direction of the tangent of the vertex after being offset according to the offset information for the virtual road segment can be determined according to the control information of the control point corresponding to the length range.
[0117] The control information includes coordinate information and width information. The terminal can determine the candidate offset information of the vertex based on the coordinate information, and can determine the width change information of the vertex based on the width information. The process of determining the width change information of the vertex can refer to the process of determining the candidate offset information of the vertex based on the coordinate information, and this embodiment will not be repeated here.
[0118] The terminal can determine the first texture coordinate corresponding to the vertex after the offset based on the normal direction, and then determine the correction information based on the first texture coordinate and the width change information of each vertex. Based on the correction information, the candidate offset information on the target coordinate axis is corrected to obtain the offset information of the vertex on the preset grid model for the virtual road section.
[0119] 103. According to the offset information for the virtual road section, the vertices on the preset mesh model are offset to obtain a deformed mesh model for the virtual road section.
[0120] Among them, the vertex shader can be used to offset the vertices on the preset mesh model according to the offset information for the virtual road section to obtain a deformed mesh model for the virtual road section.
[0121] Since the control points of different virtual road sections are different, the deviation information of the vertices for different virtual road sections is different. According to the offset information, the vertices on the preset grid model are offset, and the deformed grid models obtained are also different. According to the control points of a virtual road section, the preset grid model is deformed to obtain the deformed grid model for the virtual road section.
[0122] 104. Batch rendering is performed on the deformed mesh models of the virtual road sections to generate a virtual road.
[0123] Among them, the deformed mesh model for the virtual road section is batch rendered, so that the virtual road section can be obtained first, and then the virtual road can be generated according to the virtual road section.
[0124] Specifically, after obtaining the virtual road segments, the terminal can combine the virtual road segments to obtain a virtual road. For example, the virtual road segments include virtual road segment r1, virtual road segment r2, virtual road segment r3, virtual road segment r4, virtual road segment r5 and virtual road segment r6. The control points of each virtual road segment can be as follows: Figure 7 As shown in , the generated virtual road segments can be Figure 8 shown.
[0125] Batch rendering refers to rendering by merging multiple identical models into one rendering batch. In the related art, each small model is first obtained, and then each small model is stored in a different vertex buffer. When rendering, the small model is taken out from the vertex buffer. At this time, since each small model is different, it is impossible to batch render each small model.
[0126] In an embodiment of the present application, a preset mesh model is first stored in a vertex buffer. During rendering, the preset mesh model is taken out from the vertex buffer through a vertex shader, and then the preset mesh model is deformed according to control information of multiple control points to obtain different deformed mesh models. The different deformed mesh models are then directly rendered. Since different deformed mesh models are obtained by deforming the same preset mesh model during rendering, rendering different deformed mesh models is equivalent to rendering the same preset mesh model. Therefore, different deformed mesh models can be batch rendered to reduce rendering overhead and improve the frame rate of rendered games.
[0127] In some embodiments, batch rendering is performed on the deformed mesh models for the virtual road segments to generate the virtual road, including:
[0128] According to the width information, the texture coordinates corresponding to the preset mesh model are adjusted to obtain the target texture coordinates corresponding to the deformed mesh model for the virtual road section;
[0129] Based on the target texture coordinates, the deformed mesh models of the virtual road section are batch rendered to generate a virtual road.
[0130] The target texture coordinates refer to the texture coordinates corresponding to the vertex after the offset. Since the vertices in the preset mesh model are offset, if the texture coordinates corresponding to the vertex are not adjusted, material stretching problems may occur.
[0131] Therefore, in this embodiment, the texture coordinates corresponding to the preset mesh model are adjusted according to the width information to obtain the target texture coordinates corresponding to the deformed mesh model for the virtual road section, and based on the target texture coordinates, the deformed mesh model for the virtual road section is rendered to obtain the virtual road section, and based on the virtual road section, a virtual road is generated to solve the material stretching problem.
[0132] In some embodiments, the texture coordinates corresponding to the preset mesh model are adjusted according to the width information to obtain the target texture coordinates corresponding to the deformed mesh model for the virtual road segment. The process may be:
[0133] Determine, according to the width information, a texture scaling parameter of a preset grid model for the virtual road segment;
[0134] According to the texture scaling parameters, the texture coordinates corresponding to the preset mesh model are adjusted to obtain the target texture coordinates corresponding to the deformed mesh model for the virtual road section.
[0135] The texture scaling parameter may be used to indicate the scaling ratio of the u coordinate in the texture coordinates. The u coordinate may also be referred to as the first texture coordinate.
[0136] The terminal can determine the width change information of the vertex based on the width information, determine the texture scaling parameters of the first texture coordinates corresponding to the preset mesh model based on the width change information and the first texture coordinates corresponding to the vertex after the offset, and then adjust the first texture coordinates in the texture coordinates corresponding to the preset mesh model based on the texture scaling parameters to obtain the target texture coordinates corresponding to the deformed mesh model for the virtual road section.
[0137] From the above content, it can be seen that in an embodiment of the present application, road information corresponding to the virtual road to be generated is obtained, and the road information includes multiple control points for each virtual road section in the virtual road; based on the control information of the multiple control points of the virtual road section, the offset information of the vertices on the preset grid model for the virtual road section is determined; according to the offset information for the virtual road section, the vertices on the preset grid model are offset to obtain a deformed grid model for the virtual road section; the deformed grid models for the virtual road section are batch rendered to generate a virtual road. Since different deformed grid models are obtained by deforming the same preset grid model during rendering, rendering different deformed grid models is equivalent to rendering the same preset grid model. Therefore, different deformed grid models can be batch rendered to reduce rendering overhead, improve game frame rate, and reduce the probability of lag.
[0138] According to the following Fig. 9 , the road generation method provided in this application is further explained.
[0139] 901. Obtain road information corresponding to a virtual road to be generated, where the road information includes a plurality of control points of each virtual road section in the virtual road.
[0140] For example, the multiple control points may include 4, and the 4 control points may be as follows Fig.10 CP1, CP2, CP3 and CP4 shown in FIG. , the control information includes coordinate information and width information, Fig.10 Here, x, y, and z represent coordinate information, and a represents width information.
[0141] Optionally, one of the four control points may be used as the local space origin, and the relative spatial positions of the other three control points may be calculated to obtain the coordinate information of the four control points.
[0142] 902. Obtain positional relationship parameters between the first vertex of the center line on the preset grid model and the preset grid model, and perform interpolation processing according to the positional relationship parameters and control information of multiple control points of the virtual road section to obtain interpolation information of the interpolation points.
[0143] Among them, since the position relationship parameters between the first vertex and the preset mesh model are already determined, the position relationship parameters can be calculated first, so that the position relationship parameters can be directly used when performing interpolation processing.
[0144] For example, Fig.10 As shown, Fig.10 The "calculate t" node in is used to output the positional relationship parameters between the first vertex and the preset mesh model. The input of the "calculate t" node is the y value of the first vertex. Fig.10 The "MeshLengthParam(900)" in is used to output the length of the preset mesh model, and 900 represents the length of the preset mesh model.
[0145] In some embodiments, obtaining position relationship parameters between vertices on a preset mesh model and the preset mesh model includes:
[0146] Get the length of the preset grid model;
[0147] Based on the number of multiple control points of the virtual road segment, the length is divided to obtain multiple length ranges;
[0148] According to the length range, position relationship parameters between vertices on the preset mesh model and the preset mesh model are determined.
[0149] When the position relationship parameters are determined as above, the calculation logic of the "calculate t" node can be:
[0150] If the y value of the vertex is less than or equal to d / 3, then v=y; if the y value of the vertex is greater than d / 3 and less than or equal to 2d / 3, then v=yd / 3; if the y value of the vertex is greater than 2d / 3 and less than or equal to d, v=y-2d / 3, t=v / d / 3.
[0151] t is the position relationship parameter.
[0152] The length of the preset grid model may refer to the length of the preset grid model in the local space of the model, and the y value of the vertex refers to the y value of the preset grid model in the local space of the model.
[0153] 903. Determine candidate offset information of the first vertex on three coordinate axes for the virtual road segment based on the interpolation information of the interpolation point.
[0154] Among them, it is also possible to determine only the candidate offset information of the first vertex on the two coordinate axes for the virtual road segment. In this case, the two coordinate axes are the coordinate axes other than the target coordinate axis among the three coordinate axes. The two coordinate axes can be called the first target coordinate axis and the second target coordinate axis. When the target coordinate axis is the y axis, the two coordinate axes can be the x axis and the z axis. Alternatively, when determining the candidate offset information for the virtual road segment on the three coordinate axes, the candidate offset information for the virtual road segment on the target coordinate axis can be 0 or not 0.
[0155] In some embodiments, before interpolation processing is performed based on the position relationship parameters and the control information of the multiple control points of the virtual road segment, the coordinate information in the control information of the multiple control points may be scaled.
[0156] For example, Fig.10 As shown in Fig.10 The "convert" node in the control information enlarges the coordinate information in the control information, and then passes Fig.10 The "Append" node in the MF_CR_calculateWidthScale node combines the enlarged coordinate information and width and inputs them into the "MF_CR_calculateWidthScale" node for interpolation processing.
[0157] In some embodiments, when interpolating the first vertex in each length range based on position relationship parameters and multiple control points, the required control points may be missing. In this case, virtual control points can be determined based on the control points corresponding to the vertices at the endpoints of the length range.
[0158] For example, the length range includes 3. When determining the first length range, the virtual control point is determined according to CP1 and CP2. The first vertex in the first length range is interpolated according to the virtual control point, CP1, CP2, CP3 and the position relationship parameter. The process of determining the virtual control point according to CP1 and CP2 can be as follows: Fig.10 shown.
[0159] For another example, the length range includes 3. When determining the third length range, the virtual control point is determined according to CP3 and CP4. The first vertex in the first length range is interpolated according to the virtual control point, CP2, CP3, CP4 and the position relationship parameter. The process of determining the virtual control point according to CP3 and CP4 can be as follows: Fig.10 shown.
[0160] Fig.10 "Multiply" means multiplication operation, and "Subtract" means subtraction operation.
[0161] In some embodiments, the interpolation processing algorithm in the "MF_CR_calculateWidthScale" node can be set according to actual conditions. For example, when the interpolation processing algorithm in the "MF_CR_calculateWidthScale" node is the Catmull-Rom algorithm, the internal structure of the "MF_CR_calculateWidthScale" node can be as follows: Fig.11 shown.
[0162] In some embodiments, since the width change information is needed later, the "MF_CR_calculateWidthScale" node may perform interpolation processing according to the coordinate information and the width information to obtain candidate offset information and width change information.
[0163] For example, Fig.11 As shown in the figure, the control information of the control point or virtual control point is split into coordinate information and width information through the "BreakOutFloat4Components" node. The output RGB is the coordinate information of the control point or virtual control point, and the output A is the width information of the control point or virtual control point. The "MakeFloat3" node is used to convert the input into a floating point constant. The output of the "Output Result" node is Fig.10 The output of the "Result" of the "MF_CR_calculateWidthScale" node in the output is used to output candidate offset information. The output of the "Output ScaleSize" node is the output of the "ScaleSize" of the "MF_CR_calculateWidthScale" node, which is used to output width change information. The "Add" node represents addition operations, and the "power" node represents power operations.
[0164] 904. Determine candidate offset information of a second vertex within a length range of the first vertex according to the candidate offset information of the first vertex for the virtual road segment, where the second vertex is a vertex other than the first vertex in the preset mesh model.
[0165] Among them, the terminal can offset the first vertex in each length range according to the candidate offset information in each length range to obtain the sub-curve corresponding to each length range, and then input the first vertex and the second vertex in each length range into the expression of the sub-curve corresponding to each length range to obtain the candidate offset information of all vertices in the preset grid model.
[0166] For example, Fig.10As shown, the input of "choose curve" includes vertices in the preset grid model, lenght represents the length of the preset grid model, curveA represents the sub-curve corresponding to the first length range, curveB represents the sub-curve corresponding to the second length range, and curveB represents the sub-curve corresponding to the third length range. When the y value of the input vertex is less than or equal to lenght / 3, the candidate offset information of the vertex is calculated by curveA. When the y value of the input vertex is greater than lenght / 3 and less than or equal to lenght2 / 3, the candidate offset information of the vertex is calculated by curveB. When the y value of the input vertex is greater than lenght2 / 3 and less than or equal to lenght, the candidate offset information of the vertex is calculated by curveB.
[0167] Similarly, the terminal can determine the width sub-curve corresponding to each length range based on the width change information within each length range, and then input the first vertex and the second vertex within each length range into the width sub-curve corresponding to each length range to obtain the width change information of all vertices in the preset grid model.
[0168] 905. Determine, based on the control information of the multiple control points for the virtual road segment, the normal direction of the tangent of the vertex after being offset according to the candidate offset information for the virtual road segment.
[0169] 906. Correct candidate offset information of vertices on the preset grid model on the target coordinate axis for the virtual road section according to the normal direction and width information to obtain offset information of vertices on the preset grid model for the virtual road section.
[0170] Among them, the terminal can determine the tangent vector of the tangent of the first vertex according to the position relationship parameters and the control information of multiple control points, so as to determine the normal direction of the tangent according to the tangent vector, and determine the first texture vector and target offset information corresponding to the vertex after the offset according to the normal direction. The first texture vector includes the first texture coordinate. According to the first texture vector and the width change information of each vertex, the correction information is determined. According to the correction information and the target offset information, the candidate offset information on the target coordinate axis is corrected to obtain the offset information of the vertex on the preset grid model for the virtual road section.
[0171] For example, you can Fig.12 (The Divide node represents a division operation. Fig.12 The "MeshLengthParam(200)" node outputs the width of the preset mesh model, and "Abs" represents the absolute value operation. The "calculate tangentVector" node is used to calculate the tangent vector of the tangent. Its calculation logic can be:
[0172] float3 tanV=(pt2-pt0) / 2+(2*pt0-5*pt1+4*pt2-pt3)*t+3*(-pt0+3*pt1-3*pt2+pt3) / 2*t*t
[0173] Among them, float3 tanV represents the tangent vector of the tangent line, and t represents the position relationship parameter.
[0174] After obtaining the tangent vector of the tangent line, the first texture vector and target offset information can be calculated by inputting the tangent vector into the "MF_CR_calculateNormal" node, where the first texture vector is the u vector.
[0175] The internal structure of the "MF_CR_calculateNormal" node can be as follows Fig.13 (The "VectorLength" node is used to output the length of the vector, the "Normalize" node represents the normalization process, and the "Dot" node represents the dot product process), where: Fig.13 The output of the "Output uVector" node in is Fig.12 The output of "uVector" in the "MF_CR_calculateNormal" node is used to output the first texture coordinate of the first vertex in each length range. The first texture coordinates of each vertex constitute the first texture vector. Fig.13 The output of the "Output Result" node in is Fig.12 The output of "Result" in the "MF_CR_calculateNormal" node is used to output the target offset information of the first vertex on the target coordinate axis within each length range, and then determine the target offset information of the second vertex on the target coordinate axis based on the target offset information of the first vertex. This process refers to the process of determining the candidate offset information of the second vertex based on the candidate offset information of the first vertex, and this embodiment will not be repeated here.
[0176] After obtaining the first texture vector, the first texture vector is adjusted to obtain an adjusted texture vector, correction information is determined according to the adjusted texture vector and width change information, and the correction information, target offset information and candidate offset information are added to obtain offset information.
[0177] The process of adjusting the first texture vector can allow Fig.12 shown.
[0178] 907. According to the offset information for the virtual road section, the vertices on the preset mesh model are offset to obtain a deformed mesh model for the virtual road section.
[0179] After obtaining the offset information, the terminal can input the offset information into Fig.14 In the “M_VertexBend_Catmull_Rom” node of the virtual road, the vertices on the preset mesh model are offset through the “M_VertexBend_Catmull_Rom” node to obtain the deformed mesh model for the virtual road section.
[0180] 908. Determine the texture scaling parameters of the preset mesh model for the virtual road section according to the normal direction and width information, and adjust the texture coordinates corresponding to the preset mesh model according to the texture scaling parameters to obtain the target texture coordinates corresponding to the deformed mesh model for the virtual road section.
[0181] The correction information can be determined according to the normal direction and width information, and the texture scaling parameter can be determined according to the correction information. The process of determining the correction information according to the normal direction and width information can refer to the above-mentioned determination of the correction information, which will not be repeated in this embodiment.
[0182] Based on the correction information, the process of determining the texture scaling parameters can be as follows Fig.14 According to the texture scaling parameters, the process of adjusting the texture coordinates corresponding to the preset mesh model can be as follows Fig.14 As shown. Among them, Fig.14 The "TexCoord" node in is used to output the texture coordinates corresponding to the preset mesh model.
[0183] Provided below Fig.15 , Fig.15 is the overall node diagram of this embodiment, wherein: Fig.15 The w1 in Fig.10 The content of w2 corresponds to Fig.12 content.
[0184] 909. Rendering the deformed mesh model for the virtual road section based on the target texture coordinates to obtain the virtual road section, and generating a virtual road based on the virtual road section.
[0185] The specific implementation method and corresponding beneficial effects of this embodiment can be specifically referred to the above method embodiment, and this embodiment will not be described in detail here.
[0186] In order to better implement the above method, the embodiment of the present application also provides a road generation device, which can be specifically integrated into an electronic device, such as a computer device, which can be a terminal, a server, or other device.
[0187] Among them, the terminal can be a mobile phone, a tablet computer, a smart Bluetooth device, a laptop computer, a personal computer and other devices; the server can be a single server or a server cluster composed of multiple servers.
[0188] For example, in this embodiment, the method of the embodiment of the present application is described in detail by taking the road generation device specifically integrated in the terminal as an example. This embodiment provides a road generation device, such as Fig.16 As shown, the road generating device may include:
[0189] The acquisition module 1601 is used to acquire road information corresponding to the virtual road to be generated, where the road information includes a plurality of control points of each virtual road section in the virtual road.
[0190] The determination module 1602 is used to determine the offset information of the vertices on the preset grid model for the virtual road segment based on the control information of the multiple control points of the virtual road segment.
[0191] The offset module 1603 is used to offset the vertices on the preset mesh model according to the offset information for the virtual road section to obtain a deformed mesh model for the virtual road section.
[0192] The rendering module 1604 is used to batch render the deformed mesh models of the virtual road sections to generate a virtual road.
[0193] In some embodiments, the determination module 1602 is specifically configured to perform:
[0194] Obtaining positional relationship parameters between vertices on a preset mesh model and the preset mesh model;
[0195] Based on the position relationship parameters and the control information of the multiple control points for the virtual road section, the offset information of the vertices on the preset grid model for the virtual road section is determined.
[0196] In some embodiments, the determination module 1602 is specifically configured to perform:
[0197] Get the length of the preset grid model;
[0198] Based on the number of multiple control points of the virtual road segment, the length is divided to obtain multiple length ranges;
[0199] According to the length range, position relationship parameters between vertices on the preset mesh model and the preset mesh model are determined.
[0200] In some embodiments, the preset mesh model is an axisymmetric model, the preset mesh model includes a first vertex and a second vertex, the first vertex is a vertex on the midline of the preset mesh model, the second vertex is a vertex in the preset mesh model other than the first vertex, the position relationship parameter is a position relationship parameter of the first vertex, and the determination module 1602 is specifically used to execute:
[0201] Determine the offset information of the first vertex for the virtual road segment based on the position relationship parameter and the control information of the plurality of control points for the virtual road segment;
[0202] The offset information of a second vertex within the length range where the first vertex is located is determined according to the offset information of the first vertex with respect to the virtual road segment.
[0203] In some embodiments, the determination module 1602 is specifically configured to perform:
[0204] Performing interpolation processing based on the position relationship parameters and the control information of the multiple control points of the virtual road section to obtain interpolation information of the interpolation points;
[0205] Based on the interpolation information of the interpolation point, the offset information of the vertex on the preset grid model for the virtual road segment is determined.
[0206] In some embodiments, the determination module 1602 is specifically configured to perform:
[0207] Determine candidate offset information of vertices on the preset grid model on three coordinate axes for the virtual road section based on the position relationship parameters and control information for multiple control points of the virtual road section;
[0208] The candidate offset information of the vertices on the preset grid model on the target coordinate axis for the virtual road section is corrected to obtain the offset information of the vertices on the preset grid model for the virtual road section, and the target coordinate axis is one of the three coordinate axes.
[0209] In some embodiments, the control information of the control point includes coordinate information and width information, and the candidate offset information is determined according to the coordinate information. The determination module 1602 is specifically used to perform:
[0210] Determining, based on the control information of the plurality of control points for the virtual road segment, a normal direction of a tangent line of the vertex after being offset according to the offset information for the virtual road segment;
[0211] According to the normal direction and width information, the candidate offset information of the vertices on the preset grid model on the target coordinate axis for the virtual road section is corrected to obtain the offset information of the vertices on the preset grid model for the virtual road section.
[0212] In some embodiments, the control information includes width information, and the rendering module 1604 is specifically used to:
[0213] According to the width information, the texture coordinates corresponding to the preset mesh model are adjusted to obtain the target texture coordinates corresponding to the deformed mesh model for the virtual road section;
[0214] Based on the target texture coordinates, the deformed mesh models of the virtual road section are batch rendered to generate a virtual road.
[0215] In some embodiments, the rendering module 1604 is specifically used to:
[0216] Determine, according to the width information, a texture scaling parameter of a preset grid model for the virtual road segment;
[0217] According to the texture scaling parameters, the texture coordinates corresponding to the preset mesh model are adjusted to obtain the target texture coordinates corresponding to the deformed mesh model for the virtual road section.
[0218] In specific implementation, the above modules can be implemented as independent entities, or can be arbitrarily combined and implemented as the same or several entities. The specific implementation methods and corresponding beneficial effects of the above modules can be found in the previous method embodiments, which will not be repeated here.
[0219] Accordingly, an embodiment of the present application further provides an electronic device, which may be a terminal, and the terminal may be a smart phone, a tablet computer, a laptop computer, a touch screen, a game console, a personal computer (PC), a personal digital assistant (PDA), or other terminal devices. Fig.17 As shown, Fig.17 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 1700 includes a processor 1701 having one or more processing cores, a memory 1702 having one or more computer-readable storage media, and a computer program stored in the memory 1702 and executable on the processor. The processor 1701 is electrically connected to the memory 1702. It will be understood by those skilled in the art that the electronic device structure shown in the figure does not constitute a limitation on the electronic device, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0220] Processor 1701 is the control center of electronic device 1700. It uses various interfaces and lines to connect various parts of the entire electronic device 1700, executes various functions of electronic device 1700 and processes data by running or loading software programs and / or modules stored in memory 1702, and calling data stored in memory 1702, thereby monitoring electronic device 1700 as a whole.
[0221] In the embodiment of the present application, the processor 1701 in the electronic device 1700 will load instructions corresponding to the processes of one or more application programs into the memory 1702 according to the following steps, and the processor 1701 will run the application programs stored in the memory 1702 to implement various functions, such as:
[0222] Acquire road information corresponding to the virtual road to be generated, the road information including a plurality of control points of each virtual road section in the virtual road;
[0223] Determine, based on the control information of the plurality of control points of the virtual road section, the offset information of the vertices on the preset grid model for the virtual road section;
[0224] According to the offset information for the virtual road section, the vertices on the preset mesh model are offset to obtain a deformed mesh model for the virtual road section;
[0225] The deformed mesh models of the virtual road sections are batch rendered to generate a virtual road.
[0226] The specific implementation methods and corresponding beneficial effects of the above operations can be found in the detailed description of the road generation method above, which will not be elaborated here.
[0227] Optional, such as Fig.17 As shown, the electronic device 1700 further includes: a touch screen 1703, a radio frequency circuit 1704, an audio circuit 1705, an input unit 1706, and a power supply 1707. The processor 1701 is electrically connected to the touch screen 1703, the radio frequency circuit 1704, the audio circuit 1705, the input unit 1706, and the power supply 1707, respectively. Those skilled in the art can understand that Fig.17 The electronic device structure shown in the figure does not constitute a limitation of the electronic device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0228] The touch display screen 1703 can be used to display a graphical user interface and receive operation instructions generated by the user acting on the graphical user interface. The touch display screen 1703 may include a display panel and a touch panel. Among them, the display panel may be used to display information input by the user or information provided to the user and various graphical user interfaces of the electronic device, and these graphical user interfaces may be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel may be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light emitting diode (OLED, Organic Light-EmittingDiode) and the like. The touch panel may be used to collect the user's touch operation on or near it (such as the user using any suitable object or attachment such as a finger, a stylus, etc. on the touch panel or near the touch panel), and generate corresponding operation instructions, and the operation instructions execute corresponding programs. Optionally, the touch panel may include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the user's touch orientation, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into the touch point coordinates, and then sends it to the processor 1701, and can receive the command sent by the processor 1701 and execute it. The touch panel can cover the display panel. When the touch panel detects a touch operation on or near it, it is transmitted to the processor 1701 to determine the type of touch event, and then the processor 1701 provides a corresponding visual output on the display panel according to the type of touch event. In an embodiment of the present application, the touch panel and the display panel can be integrated into the touch display screen 1703 to realize the input and output functions. However, in some embodiments, the touch panel and the touch panel can be used as two independent components to realize the input and output functions. That is, the touch display screen 1703 can also be used as a part of the input unit 1706 to realize the input function.
[0229] The radio frequency circuit 1704 may be used to send and receive radio frequency signals, so as to establish wireless communication with a network device or other electronic devices through wireless communication, and to send and receive signals between the network device or other electronic devices.
[0230] The audio circuit 1705 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 1705 can transmit the electrical signal converted from the received audio data to the speaker, which is converted into a sound signal for output; on the other hand, the microphone converts the collected sound signal into an electrical signal, which is received by the audio circuit 1705 and converted into audio data, and then the audio data is output to the processor 1701 for processing, and then sent to another electronic device through the radio frequency circuit 1704, or the audio data is output to the memory 1702 for further processing. The audio circuit 1705 may also include an earplug jack to provide communication between an external headset and an electronic device.
[0231] The input unit 1706 may be used to receive input numbers, character information or user feature information (such as fingerprint, iris, facial information, etc.), and to generate keyboard, mouse, joystick, optical or trackball signal inputs related to user settings and function control.
[0232] The power supply 1707 is used to supply power to various components of the electronic device 1700. Optionally, the power supply 1707 can be logically connected to the processor 1701 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 1707 can also include one or more DC or AC power supplies, recharging systems, power failure detection circuits, power converters or inverters, power status indicators, and other arbitrary components.
[0233] although Fig.17 Not shown, the electronic device 1700 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0234] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0235] A person of ordinary skill in the art will appreciate that all or part of the steps in the various methods of the above embodiments may be completed by instructions, or by controlling related hardware through instructions. The instructions may be stored in a computer-readable storage medium and loaded and executed by a processor.
[0236] To this end, an embodiment of the present application provides a computer-readable storage medium, in which a plurality of computer programs are stored, and the computer program can be loaded by a processor to execute any of the road generation methods provided in the embodiment of the present application. For example, the computer program can execute the following steps:
[0237] Acquire road information corresponding to the virtual road to be generated, the road information including a plurality of control points of each virtual road section in the virtual road;
[0238] Determine, based on the control information of the plurality of control points of the virtual road section, the offset information of the vertices on the preset grid model for the virtual road section;
[0239] According to the offset information for the virtual road section, the vertices on the preset mesh model are offset to obtain a deformed mesh model for the virtual road section;
[0240] The deformed mesh models of the virtual road sections are batch rendered to generate a virtual road.
[0241] The specific implementation methods and corresponding beneficial effects of the above operations can be found in the detailed description of the road generation method above, which will not be elaborated here.
[0242] The computer-readable storage medium may include: a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0243] Since the computer program stored in the computer-readable storage medium can execute any one of the road generation methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the road generation methods provided in the embodiments of the present application can be achieved. Please refer to the previous embodiments for details and will not be repeated here.
[0244] The above is a detailed introduction to a road generation method, device, electronic device and computer-readable storage medium provided in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A road generation method, characterized in that: The method comprises: Acquire road information corresponding to the virtual road to be generated, wherein the road information includes a plurality of control points of each virtual road section in the virtual road; Determining, based on control information of a plurality of control points of the virtual road segment, offset information of vertices on a preset grid model for the virtual road segment; According to the offset information for the virtual road section, the vertices on the preset mesh model are offset to obtain a deformed mesh model for the virtual road section; The deformed mesh models for the virtual road section are batch rendered to generate the virtual road.
2. The road generation method according to claim 1, characterized in that: The step of determining the offset information of the vertices on the preset grid model for the virtual road segment based on the control information of the plurality of control points of the virtual road segment comprises: Obtaining positional relationship parameters between vertices on the preset mesh model and the preset mesh model; Based on the position relationship parameters and the control information of the plurality of control points for the virtual road segment, the offset information of the vertices on the preset grid model for the virtual road segment is determined.
3. The road generation method according to claim 2, characterized in that: The obtaining of position relationship parameters between vertices on the preset mesh model and the preset mesh model includes: Obtaining the length of the preset grid model; Based on the number of the multiple control points of the virtual road segment, the length is divided to obtain multiple length ranges; According to the length range, position relationship parameters between vertices on the preset mesh model and the preset mesh model are determined.
4. The road generation method according to claim 3, characterized in that: The preset grid model is an axisymmetric model, the preset grid model includes a first vertex and a second vertex, the first vertex is a vertex on the midline of the preset grid model, the second vertex is a vertex in the preset grid model other than the first vertex, and the position relationship parameter is a position relationship parameter of the first vertex; The step of determining the offset information of the vertices on the preset grid model for the virtual road section based on the position relationship parameter and the control information of the plurality of control points for the virtual road section comprises: Determining offset information of the first vertex with respect to the virtual road segment based on the position relationship parameter and control information of a plurality of control points with respect to the virtual road segment; The offset information of a second vertex within the length range where the first vertex is located is determined according to the offset information of the first vertex with respect to the virtual road segment.
5. The road generation method according to claim 2, characterized in that: The step of determining the offset information of the vertices on the preset grid model for the virtual road section based on the position relationship parameter and the control information of the plurality of control points for the virtual road section comprises: Performing interpolation processing based on the position relationship parameter and control information of multiple control points of the virtual road section to obtain interpolation information of the interpolation point; Based on the interpolation information of the interpolation point, the offset information of the vertex on the preset grid model for the virtual road segment is determined.
6. The road generation method according to claim 2, characterized in that: The step of determining the offset information of the vertices on the preset grid model for the virtual road segment based on the position relationship parameter and the control information of the plurality of control points for the virtual road segment comprises: Determine candidate offset information of vertices on the preset grid model on three coordinate axes for the virtual road segment based on the position relationship parameters and control information for a plurality of control points of the virtual road segment; The candidate offset information of the vertices on the preset grid model on the target coordinate axis for the virtual road section is corrected to obtain the offset information of the vertices on the preset grid model for the virtual road section, wherein the target coordinate axis is one of the three coordinate axes.
7. The road generation method according to claim 6, characterized in that: The control information of the control point includes coordinate information and width information, and the candidate offset information is determined according to the coordinate information; The step of correcting the candidate offset information of the vertices on the preset grid model on the target coordinate axis for the virtual road segment to obtain the offset information of the vertices on the preset grid model for the virtual road segment includes: Determining, based on control information of a plurality of control points of the virtual road segment, a normal direction of a tangent line of the vertex after being offset according to the offset information of the virtual road segment; According to the normal direction and the width information, the candidate offset information of the vertices on the preset grid model on the target coordinate axis for the virtual road segment is corrected to obtain the offset information of the vertices on the preset grid model for the virtual road segment.
8. The road generation method according to any one of claims 1 to 7, characterized in that: The control information includes width information, and the batch rendering of the deformed mesh model for the virtual road section to generate the virtual road includes: According to the width information, adjusting the texture coordinates corresponding to the preset mesh model to obtain target texture coordinates corresponding to the deformed mesh model for the virtual road section; Based on the target texture coordinates, batch rendering is performed on the deformed mesh model for the virtual road section to generate the virtual road.
9. The road generation method according to claim 8, characterized in that: The step of adjusting the texture coordinates corresponding to the preset mesh model according to the width information to obtain target texture coordinates corresponding to the deformed mesh model for the virtual road section includes: Determining, according to the width information, a texture scaling parameter of the preset grid model for the virtual road segment; According to the texture scaling parameters, the texture coordinates corresponding to the preset mesh model are adjusted to obtain target texture coordinates corresponding to the deformed mesh model for the virtual road section.
10. A road generation device, characterized in that: The device comprises: An acquisition module, used for acquiring road information corresponding to the virtual road to be generated, wherein the road information includes a plurality of control points of each virtual road section in the virtual road; A determination module, configured to determine offset information of vertices on a preset grid model for the virtual road segment based on control information of a plurality of control points of the virtual road segment; An offset module, configured to offset vertices on the preset mesh model according to the offset information for the virtual road section, so as to obtain a deformed mesh model for the virtual road section; The rendering module is used to batch render the deformed mesh model for the virtual road section to generate the virtual road.
11. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a plurality of instructions; the processor loads instructions from the memory to execute the road generation method as claimed in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a plurality of instructions, and the instructions are suitable for being loaded by a processor to execute the road generation method according to any one of claims 1 to 9.
Citation Information
Cited By
Model rendering method and device, electronic equipment, storage medium and program product
CN122134964A
Model rendering method and apparatus, electronic device, storage medium, and program product
CN122134964B