Model rendering method and apparatus, electronic device, and computer-readable storage medium
By automatically adding height differences to model components and using a preset algorithm to calculate and apply offsets, the problem of manually adjusting model height being tedious and error-prone is solved, improving rendering efficiency and making it particularly suitable for fixed-view scenes.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NETEASE (SHANGHAI) NETWORK CO LTD
- Filing Date
- 2026-03-12
- Publication Date
- 2026-06-12
AI Technical Summary
The existing method of manually adjusting the height of overlapping models is cumbersome, error-prone, and results in low rendering efficiency and the possibility of omissions.
By automatically adding controllable height differences to model components that are on the same horizontal plane and overlap, the algorithm calculates the height difference information of each model component and applies small but different offsets during the rendering process to ensure that the model components have height differences in depth.
It effectively eliminates rendering flickering or texture jump issues, improves rendering efficiency, and avoids human oversights and configuration errors. It is especially suitable for fixed-view scenes containing a large number of overlapping models.
Smart Images

Figure CN122199768A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of rendering technology, and more specifically, to a model rendering method, apparatus, electronic device, and computer-readable storage medium. Background Technology
[0002] In fixed-perspective games, scenes are usually composed of a large number of models, such as buildings and walls. When multiple wall models overlap at corners or intersections, if multiple wall models are on the same horizontal plane, visual defects such as flickering and texture jumps will occur during rendering, which will seriously affect the image quality.
[0003] Currently, the method to solve rendering flickering is to manually adjust the world space height of overlapping models on the same plane. For example, if there are overlapping models A and B on the same horizontal plane, the world space height of model A is manually adjusted to 0, and the world space height of model B is adjusted to 1. However, this method of manually adjusting the height of overlapping models is cumbersome, error-prone, and prone to omissions, resulting in low rendering efficiency. Summary of the Invention
[0004] The purpose of this application is to address the shortcomings of the prior art by providing a model rendering method, apparatus, electronic device, and computer-readable storage medium, so as to solve the problems that the method of manually adjusting the height of overlapping models in the prior art is cumbersome, error-prone, and prone to omissions, resulting in low rendering efficiency.
[0005] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows: In a first aspect, embodiments of this application provide a model rendering method, the method comprising: Determine the horizontal plane region of the model to be rendered, wherein the model to be rendered includes at least two model components, and the same-side planes of at least two model components are on the same horizontal plane. The same-side plane is a surface in which at least two model components face the same direction in space. The horizontal plane region is formed by the same-side planes of at least two model components. The position coordinates of each model component are obtained, and the drop information of each model component is calculated based on the position coordinates of each model component and a preset algorithm. The drop information is used to indicate the drop of the model component relative to the horizontal plane area in a preset direction. Based on the drop information of each model component, the vertices of each model component in the horizontal plane region are moved to obtain the position coordinates of each vertex after the movement; Based on the position coordinates of each vertex after movement, the model to be rendered is rendered to obtain the rendered model.
[0006] Secondly, embodiments of this application provide a model rendering apparatus, the apparatus comprising: The first determining module is used to determine the horizontal plane region of the model to be rendered. The model to be rendered includes at least two model components. The planes on the same side of the at least two model components are on the same horizontal plane. The planes on the same side are surfaces on which the at least two model components face the same direction in space. The horizontal plane region is formed by the planes on the same side of the at least two model components. The second determining module is used to obtain the position coordinates of each of the model components, and calculate the drop information of each of the model components based on the position coordinates of each of the model components and a preset algorithm. The drop information is used to indicate the drop of the model component relative to the horizontal plane area in a preset direction. The processing module is used to move the vertices of each model component in the horizontal plane region according to the drop information of each model component, and obtain the position coordinates of each vertex after movement; The rendering module is used to render the model to be rendered based on the position coordinates of each vertex after movement, and obtain the rendered model.
[0007] Thirdly, embodiments of this application provide an electronic device, including: a processor, a storage medium, and a bus. The storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor communicates with the storage medium via the bus, and the processor executes the machine-readable instructions to perform the steps of the model rendering method as described in any of the first aspects above.
[0008] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the model rendering method as described in any of the first aspects above.
[0009] The model rendering method, apparatus, electronic device, and storage medium provided in this application identify overlapping horizontal plane regions on the same horizontal plane in the model to be rendered, ensuring that only surfaces with depth conflicts are processed. Based on this, and using the unique position coordinates of each model component in world space, a preset algorithm automatically generates differentiated height difference information, thereby assigning a small but distinct offset to each model component. This height difference information is applied only along a preset height difference direction within the identified horizontal plane regions. Thus, during the rendering stage, since the model components already have height differences in depth, rendering flickering or texture jumps are effectively eliminated. In this process, users do not need to manually adjust the height of each model individually, avoiding human error and configuration mistakes, thereby significantly improving rendering efficiency, especially suitable for fixed-view scenes containing a large number of overlapping models. Attached Figure Description
[0010] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0011] Figure 1 This illustration shows a rendering effect provided by an embodiment of this application; Figure 2 A schematic flowchart of a model rendering method provided in an embodiment of this application is shown; Figure 3 This illustration shows another rendering effect provided by an embodiment of this application; Figure 4 A flowchart illustrating a method for determining a horizontal plane region according to an embodiment of this application is shown. Figure 5 This illustration shows a schematic diagram of a horizontal plane region provided in an embodiment of this application; Figure 6 A flowchart illustrating a method for calculating elevation difference information provided in an embodiment of this application is shown. Figure 7 A flowchart illustrating a method for determining the position coordinates of a vertex after movement, provided in an embodiment of this application, is shown. Figure 8 This paper shows a schematic diagram of the structure of a model rendering apparatus provided in an embodiment of this application; Figure 9 A schematic diagram of the structure of an electronic device provided in an embodiment of this application is shown. Detailed Implementation
[0012] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. It should be understood that the accompanying drawings in this application are for illustrative and descriptive purposes only and are not intended to limit the scope of protection of this application. Furthermore, it should be understood that the schematic drawings are not drawn to scale. The flowcharts used in this application illustrate operations implemented according to some embodiments of this application. It should be understood that the operations in the flowcharts may not be implemented in sequence, and steps without logical contextual relationships may be reversed or implemented simultaneously. In addition, those skilled in the art, guided by the content of this application, may add one or more other operations to the flowcharts, or remove one or more operations from the flowcharts.
[0013] Furthermore, the described embodiments are merely some, not all, of the embodiments of this application. The components of the embodiments of this application described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0014] It should be noted that the term "comprising" will be used in the embodiments of this application to indicate the presence of the features declared thereafter, but does not exclude the addition of other features.
[0015] In games with a fixed perspective, horizontal planes may overlap between model components. (Refer to...) Figure 1 As shown, if the planes on the same side of two model components are on the same horizontal plane, they overlap. Here, "planes on the same side" refers to the surfaces of the two model components that face the same direction in space, such as... Figure 1 The model in the image consists of two corresponding model components, one on the left and one on the right. Each model component has multiple faces, including top, bottom, left, right, front, and back. However, if the same-side planes of the two model components are both facing upwards, a flickering sorting issue may occur during normal rendering (e.g., ...). Figure 1 (As shown by the wavy line). Existing technologies typically address the issue of overlapping and flickering during model rendering by manually adjusting the heights of two model components to create a horizontal height difference. However, manually adjusting model heights is cumbersome, error-prone, and prone to omissions, leading to low rendering efficiency. To address this, this application provides a model rendering method that automatically adds a controllable height difference to at least two overlapping model components on the same horizontal plane, eliminating the tedious manual adjustment process and effectively solving the problem of overlapping rendering flickering, thereby improving rendering efficiency. The model rendering method provided in this application will be described in detail below.
[0016] Figure 2 This illustration shows a flowchart of a model rendering method provided in an embodiment of this application. (Refer to...) Figure 2 As shown, the method specifically includes the following steps: S201. Determine the horizontal plane area of the model to be rendered.
[0017] Optionally, continue to refer to Figure 1 As shown, the model to be rendered includes at least two model components, and the planes on the same side of the at least two model components are on the same horizontal plane.
[0018] Optionally, determining the horizontal plane region of the model to be rendered actually involves identifying the surface portion of the model facing directly upwards. Specifically, each vertex in the model component is traversed, and the vertex normal vector of each vertex is obtained. The vertex normal vector of each vertex is compared with a preset direction vector. The similarity between the two vectors is calculated to measure whether the vertex is close to being horizontal and upwards. Vertices that meet the conditions are then selected and marked as belonging to the horizontal plane region, thus obtaining the horizontal plane region.
[0019] S202. Obtain the position coordinates of each model component, and calculate the drop information of each model component based on the position coordinates of each model component and the preset algorithm.
[0020] Optionally, in this embodiment, the coordinates of the pivot point of each model component are extracted, and the drop information of each model component is calculated based on the pivot point coordinates. This drop information is used to indicate the drop of the model component relative to the horizontal plane area in a preset direction, which can reflect the differences between different surface model components in the preset direction, and visually present a staggered and orderly display effect. The preset direction is the vertical direction, such as... Figure 1 The blue arrow points to the depth direction. Since the pivot point of each model component is unique, the elevation difference information generated based on the pivot point is also unique, thus enabling differentiated elevation difference effects for different model components.
[0021] S203. Based on the elevation difference information of each model component, move the vertices of each model component in the horizontal area to obtain the position coordinates of each vertex after movement.
[0022] Optionally, for each vertex, if it is determined to belong to the horizontal plane area, the vertex is offset by a corresponding size along the preset drop direction according to the drop information. If the vertex does not belong to the horizontal plane area, no movement is performed, and the final position coordinates of each vertex after movement are obtained.
[0023] S204. Based on the position coordinates of each vertex after movement, render the model to be rendered to obtain the rendered model.
[0024] Optionally, after dynamically offsetting the vertex positions, the rendering pipeline uses the updated vertex coordinates for the rendering process, ultimately generating a visual model with varying elevations. It's worth noting that because the offset only applies to the horizontal plane and the elevation differences between model components vary, flickering issues will no longer occur during rendering.
[0025] Optionally, refer to Figure 3 As shown, the flickering problem will no longer occur when rendering the final model, that is, compared to Figure 1 As shown, after applying the model rendering method provided in the embodiments of this application, the following issues will no longer occur. Figure 1 The wavy lines shown effectively solve the problem of flickering in overlapping model rendering.
[0026] Based on this, the model rendering method according to the embodiments of this application identifies overlapping horizontal plane regions on the same horizontal plane in the model to be rendered, ensuring that only surfaces with depth conflicts are processed. Furthermore, based on the unique position coordinates of each model component in world space, a preset algorithm automatically generates differentiated height difference information, thereby assigning a small but distinct offset to each model component. This height difference information is applied only along a preset height difference direction within the identified horizontal plane regions. Thus, during the rendering stage, since the model components already have height differences in depth, rendering flickering or texture jumps are effectively eliminated. In the above process, users do not need to manually adjust the height of each model individually, avoiding human error and configuration mistakes, thereby significantly improving rendering efficiency, especially suitable for fixed-view scenes containing a large number of overlapping models.
[0027] Figure 4 A flowchart illustrating a method for determining a horizontal plane region according to an embodiment of this application is shown. (Refer to...) Figure 4 As shown, step S201 above determines the horizontal plane region of the model to be rendered, specifically including the following steps: S401. Obtain the vertex normal vectors of all vertices in each model component.
[0028] Optionally, the vertex normal vector (VertexNormal) of each vertex in each model component is extracted. The vertex normal vector (VertexNormal) is a vector perpendicular to the surface of the model component at the corresponding vertex, used to describe the orientation of the model surface at the vertex.
[0029] S402. Determine the scalar value of each vertex based on the vertex normal vector and the preset direction vector.
[0030] Optionally, the preset direction vector is, for example, (0, 0, 1), which also represents the depth direction.
[0031] Optionally, in this embodiment of the application, the dot product of the vertex normal vector and the preset direction vector of each vertex can be used as the scalar value of each vertex.
[0032] For example, for each vertex, the dot product between the vertex's normal vector (VertexNormal) and the preset direction vector (0, 0, 1) is calculated, and the resulting dot product is used as the vertex's scalar value, with the range of -1 to 1. Specifically, the dot product is represented as dot(VertexNormal, (0, 0, 1)), where dot represents the dot product operation. It is worth noting that calculating the dot product between the vertex's normal vector and the preset direction vector actually measures the similarity between the vertex normal direction represented by the vertex normal vector and the depth direction represented by the preset direction vector. The final scalar value is a value between -1 and 1, reflecting the angular relationship between the vertex normal direction and the depth direction.
[0033] S403. Based on the scalar values of each vertex, determine the horizontal plane region of the model to be rendered.
[0034] Optionally, the scalar values of each vertex are mapped to obtain the target scalar values of each vertex. The target scalar values of each vertex are compared with a preset threshold, and the vertices with target scalar values greater than the preset threshold are taken as vertices constituting the horizontal plane region, thus obtaining the horizontal plane region.
[0035] Optionally, in this embodiment, the scalar value obtained by dot product can be remapped by applying the SmoothStep function, converting the scalar value of the vertex into the target scalar value. The SmoothStep function is an interpolation function used to smoothly map a value from one range to another.
[0036] For example, the preset threshold is 0.95. For each vertex, the SmoothStep function is applied to remap the vertex's scalar value dot(VertexNormal, (0, 0, 1)) to obtain the vertex's target scalar value. This target scalar value is then compared with the preset threshold of 0.95. If the target scalar value is greater than the preset threshold of 0.95, the vertex is determined to belong to the horizontal plane region, displayed in white, and is used as a vertex constituting the horizontal plane region. Conversely, if the target scalar value is less than or equal to the preset threshold of 0.95, the vertex is determined not to belong to the horizontal plane region, displayed in black, and is not used as a vertex constituting the horizontal plane region.
[0037] For example, refer to Figure 5 As shown, the final determined horizontal plane area is... Figure 5 The white area shown is the horizontal area, which is also the range of elevation difference that ultimately generates the height difference.
[0038] Based on this, the embodiments of this application obtain the vertex normal vectors of all vertices and multiply them with the preset direction vectors to obtain a scalar value representing the consistency of orientation. Then, the SmoothStep function is used to perform nonlinear threshold mapping on the scalar value to filter out vertices that are close to vertically upward as vertices constituting the horizontal plane region, thereby efficiently and accurately identifying the horizontal plane region with a near-horizontal orientation in the model to be rendered.
[0039] Figure 6 A flowchart illustrating a method for calculating elevation difference information according to an embodiment of this application is shown. (Refer to...) Figure 6 As shown, step S202 above obtains the position coordinates of each model component, and calculates the drop information of each model component based on the position coordinates of each model component and a preset algorithm. Specifically, it includes the following steps: S601. Obtain the world space coordinates of the pivot point of the model component.
[0040] Optionally, for different model components, their pivot point is unique. The world space coordinates of this pivot point, ActorPositon, consist of a first coordinate component, ActorPositon.X, and a second coordinate component, ActorPositon.Y. That is, the world space coordinates of the pivot point, ActorPositon, are denoted as (ActorPositon.X, ActorPositon.Y). Among them, the first coordinate component, ActorPositon.X, is the coordinate of the pivot point in the X-axis direction of the world space horizontal plane, and the second coordinate component, ActorPositon.Y, is the coordinate of the pivot point in the Y-axis direction of the world space horizontal plane.
[0041] S602. Generate a first random value and a second random value based on the world space coordinates of the pivot point of the model component.
[0042] Optionally, a first random value is determined based on the first coordinate component and the first mapping relationship of the world space coordinates of the pivot point.
[0043] For example, a first random value is calculated based on the first mapping relationship shown in the following expression (1), which is also the X-axis random value: (1) in, Indicates the first random value. Indicates the first coordinate component. This represents the sine function.
[0044] Optionally, a second random value is determined based on the second coordinate component and the second mapping relationship of the world space coordinates of the pivot point.
[0045] For example, a second random value is calculated based on the second mapping relationship shown in the following expression (2), which is also the Y-axis random value: (2) in, Indicates the second random value. Indicates the second coordinate component. This represents the sine function.
[0046] S603. Based on the first random value and the second random value, a preset algorithm is used to calculate and obtain the drop information of the model components.
[0047] Optionally, based on the first and second random values, the drop information of the model components can be calculated using the following expression (3): (3) in, This indicates the elevation difference information of the model components. Indicates the first random value. This represents the second random value.
[0048] Based on this, the embodiments of this application use the unique world space coordinates of the pivot point of each model component to generate pseudo-random values in the X and Y axes using a sine function, and then fuse the pseudo-random values in the two axes to calculate the height difference information between 0 and 1. Since the pivot point of each model component is unique in space, the height difference of each model component generated based on the world space coordinates of the pivot point is also unique. In this way, during rendering, it is ensured that each model component has its own unique height difference, thereby avoiding the cumbersome operation of manually adjusting the height of the model components and improving rendering efficiency.
[0049] Figure 7 A flowchart illustrating a method for determining the position coordinates of a vertex after movement, provided in an embodiment of this application, is shown. (Refer to...) Figure 7 As shown, step S203 above moves the vertices of each model component in the horizontal plane region according to the drop information of each model component, and obtains the position coordinates of each vertex after movement. Specifically, it includes the following steps: S701. Determine the vertex drop value of each vertex based on the drop information of each model component, the preset direction vector, and the drop of each model component vertex in the horizontal area.
[0050] Optionally, a preset direction vector indicates the direction of the drop. The drop of each vertex is determined based on the target scalar value of each vertex. If the target scalar value of a vertex is greater than a preset threshold of 0.95, the drop of that vertex is determined to be 1. Conversely, if the target scalar value of a vertex is less than or equal to the preset threshold of 0.95, the drop of that vertex is determined to be 0.
[0051] Optionally, the vertex drop value is calculated based on the following expression (4): (4) in, This represents the vertex drop value. This indicates the elevation difference information of the model components. Indicates the preset direction vector. This represents the height difference between the vertices of each model component in the horizontal plane region.
[0052] S702. Move each vertex of each model component in the horizontal area along the drop direction indicated by the preset direction vector to obtain the position coordinates of each vertex after the movement.
[0053] Optionally, since the preset direction vector is (0, 0, 1), the offset is only performed along the Z-axis, i.e., the vertical direction, and the original vertex position coordinates are compared with the vertex drop value. Adding them together gives the coordinates of the vertex after its movement. It's important to note that this only applies if the vertex belongs to the horizontal plane region (i.e.,...). Displacement only occurs in non-horizontal regions (i.e., horizontal regions). The vertex of the plane remains in place, thus achieving the effect of selectively raising only the horizontal area.
[0054] Based on this, the embodiments of this application utilize the unique drop value generated by the axis point of each model component to ensure that different model components exhibit different heights on the horizontal plane, while strictly limiting the displacement to only act on the truly upward-facing horizontal plane vertex, ensuring that non-horizontal areas are not disturbed.
[0055] As one possible implementation, in Unreal Engine (UE), to achieve the height difference effect based on horizontal plane regions provided in this application, a shared scene shader can be used uniformly in the scene materials. By adding controllable logic nodes to this shader, the height difference effect can be enabled on demand, ensuring it only applies to model components that overlap on horizontal planes. Specifically, in the material editor, the height difference information of each model component is calculated, and combined with vertex normals to determine whether it is in a horizontal plane region. Finally, the calculated offset is connected to the WorldPositionOffset input port of the material. It is worth noting that since this operation is performed at the material level, all model components using this material will automatically inherit this logic.
[0056] Furthermore, to avoid applying the height difference effect to all model components, a Boolean parameter can be introduced into the shader as a switch to control whether the height difference calculation process provided in this embodiment is activated. When the switch is on, only model components that overlap horizontally are lifted; when the switch is off, no processing is performed. This ensures both visual consistency and efficient reuse, while also providing good flexibility. It is particularly suitable for optimization needs requiring local dynamic changes in large-scale scenes, significantly improving rendering quality and efficiency.
[0057] Based on the same inventive concept, this application also provides a model rendering device corresponding to the model rendering method. Since the principle of the model rendering device in this application is similar to the model rendering method described above, the implementation of the model rendering device can refer to the implementation of the model rendering method, and the repeated parts will not be described again.
[0058] Reference Figure 8 The diagram shown is a structural schematic of a model rendering device provided in an embodiment of this application. The model rendering device 800 includes: a first determining module 801, a second determining module 802, a processing module 803, and a rendering module 804, wherein: The first determining module 801 is used to determine the horizontal plane region of the model to be rendered. The model to be rendered includes at least two model components. The planes on the same side of the at least two model components are on the same horizontal plane. The planes on the same side are surfaces on which the at least two model components face the same direction in space. The horizontal plane region is formed by the planes on the same side of the at least two model components. The second determining module 802 is used to obtain the position coordinates of each model component, and calculate the drop information of each model component based on the position coordinates of each model component and a preset algorithm. The drop information is used to indicate the drop of the model component relative to the horizontal plane area in a preset direction. The processing module 803 is used to move the vertices of each model component in the horizontal plane area according to the drop information of each model component, and obtain the position coordinates of each vertex after the movement. Rendering module 804 is used to render the model to be rendered based on the position coordinates of each vertex after movement, and obtain the rendered model.
[0059] Based on this, the model rendering apparatus according to the embodiments of this application identifies overlapping horizontal plane regions on the same horizontal plane in the model to be rendered, ensuring that only surfaces with depth conflicts are processed. Furthermore, based on the unique position coordinates of each model component in world space, a preset algorithm automatically generates differentiated height difference information, thereby assigning a small but distinct offset to each model component. This height difference information is applied only along a preset height difference direction within the identified horizontal plane regions. Thus, during the rendering stage, since the model components already have height differences in depth, rendering flickering or texture jumps are effectively eliminated. In the above process, there is no need for the user to manually adjust the height of each model individually, avoiding human error and configuration mistakes, thereby significantly improving rendering efficiency, especially suitable for fixed-view scenes containing a large number of overlapping models.
[0060] In one possible implementation, the first determining module 801 is specifically used for: Obtain the vertex normal vectors of all vertices in each model component; The scalar value of each vertex is determined based on the vertex normal vector and the preset direction vector. Based on the scalar values of each vertex, the horizontal plane region of the model to be rendered is determined.
[0061] In one possible implementation, the first determining module 801 is specifically used for: The dot product of the vertex normal vector and the preset direction vector is used as the scalar value of each vertex.
[0062] In one possible implementation, the first determining module 801 is specifically used for: Map the scalar values of each vertex to obtain the target scalar value of each vertex; The target scalar value of each vertex is compared with a preset threshold, and the vertices whose target scalar value is greater than the preset threshold are taken as the vertices that constitute the horizontal plane region, thus obtaining the horizontal plane region.
[0063] In one possible implementation, the second determining module 802 described above is specifically used for: Obtain the world space coordinates of the pivot point of the model component; Based on the world space coordinates of the pivot point of the model component, generate a first random value and a second random value; Based on the first and second random values, a preset algorithm is used to calculate and obtain the drop information of the model components.
[0064] In one possible implementation, the second determining module 802 described above is specifically used for: Based on the first coordinate component and the first mapping relationship of the world space coordinates of the pivot point, determine the first random value; The second random value is determined based on the second coordinate component and the second mapping relationship of the world space coordinates of the pivot point.
[0065] In one possible implementation, the processing module 803 is specifically used for: Based on the drop information of each model component, the preset direction vector, and the drop of each model component's vertices in the horizontal plane region, the vertex drop value of each vertex is determined. The preset direction vector indicates the drop direction, and the drop of each vertex is determined based on the target scalar value of each vertex. Move each vertex of each model component in the horizontal area along the drop direction indicated by the preset direction vector by the corresponding vertex drop value to obtain the position coordinates of each vertex after the movement.
[0066] The processing flow of each module in the device and the interaction flow between each module can be referred to the relevant descriptions in the above method embodiments, and will not be detailed here.
[0067] This application also provides an electronic device 900, such as... Figure 9 The diagram shows the structure of an electronic device 900 provided in this embodiment of the application, including a processor 901 and a memory 902. Optionally, it may also include a bus 903. The memory 902 stores machine-readable instructions executable by the processor 901. When the electronic device 900 is running, the processor 901 and the memory 902 communicate via the bus 903. When the machine-readable instructions are executed by the processor 901, the following processing is performed: Determine the horizontal plane region of the model to be rendered. The model to be rendered includes at least two model components. The planes on the same side of the at least two model components are on the same horizontal plane. The planes on the same side are surfaces on which the at least two model components face the same direction in space. The horizontal plane region is formed by the planes on the same side of the at least two model components. Obtain the position coordinates of each model component, and calculate the drop information of each model component based on the position coordinates of each model component and the preset algorithm. The drop information is used to indicate the drop of the model component relative to the horizontal plane area in the preset direction. Based on the drop information of each model component, the vertices of each model component in the horizontal plane area are moved to obtain the position coordinates of each vertex after the movement. Based on the position coordinates of each vertex after movement, the model to be rendered is rendered to obtain the rendered model.
[0068] In one possible implementation, when the processor 901 executes the instruction to determine the horizontal plane region corresponding to the model to be rendered, it specifically performs the following: Obtain the vertex normal vectors of all vertices in each model component; The scalar value of each vertex is determined based on the vertex normal vector and the preset direction vector. Based on the scalar values of each vertex, the horizontal plane region of the model to be rendered is determined.
[0069] In one possible implementation, when the processor 901 executes instructions to determine the scalar value of each vertex based on the vertex normal vector and a preset direction vector, it specifically performs the following: The dot product of the vertex normal vector and the preset direction vector is used as the scalar value of each vertex.
[0070] In one possible implementation, when the processor 901 executes instructions to determine the horizontal plane region corresponding to the model to be rendered based on the scalar values of each vertex, it specifically performs the following: Map the scalar values of each vertex to obtain the target scalar value of each vertex; The target scalar value of each vertex is compared with a preset threshold, and the vertices whose target scalar value is greater than the preset threshold are taken as the vertices that constitute the horizontal plane region, thus obtaining the horizontal plane region.
[0071] In one possible implementation, when the processor 901 executes the instruction to acquire the position coordinates of each model component and calculate the elevation difference information of each model component based on the position coordinates of each model component and a preset algorithm, it specifically performs the following: Obtain the world space coordinates of the pivot point of the model component; Based on the world space coordinates of the pivot point of the model component, generate a first random value and a second random value; Based on the first and second random values, a preset algorithm is used to calculate and obtain the drop information of the model components.
[0072] In one possible implementation, when the processor 901 executes instructions to generate a first random value and a second random value based on the world space coordinates of the pivot point of the model component, it specifically performs the following: Based on the first coordinate component and the first mapping relationship of the world space coordinates of the pivot point, determine the first random value; The second random value is determined based on the second coordinate component and the second mapping relationship of the world space coordinates of the pivot point.
[0073] In one possible implementation, when the processor 901 executes an instruction to move the vertices of each model component in the horizontal plane region based on the elevation difference information of each model component, and obtain the position coordinates of each vertex after movement, it specifically performs the following: Based on the drop information of each model component, the preset direction vector, and the drop of each model component's vertices in the horizontal plane region, the vertex drop value of each vertex is determined. The preset direction vector indicates the drop direction, and the drop of each vertex is determined based on the target scalar value of each vertex. Move each vertex of each model component in the horizontal area along the drop direction indicated by the preset direction vector by the corresponding vertex drop value to obtain the position coordinates of each vertex after the movement.
[0074] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the following steps: Define the horizontal plane region of the model to be rendered. The model to be rendered includes at least two model components. The planes on the same side of the at least two model components are on the same horizontal plane. The planes on the same side are the surfaces on which the at least two model components face the same direction in space. The horizontal plane region is formed by the planes on the same side of the at least two model components. Obtain the position coordinates of each model component, and calculate the drop information of each model component based on the position coordinates of each model component and the preset algorithm. The drop information is used to indicate the drop of the model component relative to the horizontal plane area in the preset direction. Based on the drop information of each model component, the vertices of each model component in the horizontal plane area are moved to obtain the position coordinates of each vertex after the movement. Based on the position coordinates of each vertex after movement, the model to be rendered is rendered to obtain the rendered model.
[0075] In one possible implementation, when the processor executes instructions to determine the horizontal plane region corresponding to the model to be rendered, it specifically performs the following: Obtain the vertex normal vectors of all vertices in each model component; The scalar value of each vertex is determined based on the vertex normal vector and the preset direction vector. Based on the scalar values of each vertex, the horizontal plane region of the model to be rendered is determined.
[0076] In one possible implementation, when the processor executes instructions to determine the scalar values of each vertex based on the vertex normal vectors and preset direction vectors, it specifically performs the following: The dot product of the vertex normal vector and the preset direction vector is used as the scalar value of each vertex.
[0077] In one possible implementation, when the processor executes instructions to determine the horizontal plane region corresponding to the model to be rendered based on the scalar values of each vertex, it specifically performs the following: Map the scalar values of each vertex to obtain the target scalar value of each vertex; The target scalar value of each vertex is compared with a preset threshold, and the vertices whose target scalar value is greater than the preset threshold are taken as the vertices that constitute the horizontal plane region, thus obtaining the horizontal plane region.
[0078] In one possible implementation, when the processor executes the instruction to acquire the position coordinates of each model component and calculate the elevation difference information of each model component based on the position coordinates of each model component and a preset algorithm, it specifically performs the following: Obtain the world space coordinates of the pivot point of the model component; Based on the world space coordinates of the pivot point of the model component, generate a first random value and a second random value; Based on the first and second random values, a preset algorithm is used to calculate and obtain the drop information of the model components.
[0079] In one possible implementation, when the processor executes instructions to generate a first random value and a second random value based on the world space coordinates of the pivot point of the model component, it specifically performs the following: Based on the first coordinate component and the first mapping relationship of the world space coordinates of the pivot point, determine the first random value; The second random value is determined based on the second coordinate component and the second mapping relationship of the world space coordinates of the pivot point.
[0080] In one possible implementation, when the processor executes the instruction to move the vertices of each model component in the horizontal plane region based on the drop information of each model component, and obtain the position coordinates of each vertex after movement, it specifically performs the following: Based on the drop information of each model component, the preset direction vector, and the drop of each model component's vertices in the horizontal plane region, the vertex drop value of each vertex is determined. The preset direction vector indicates the drop direction, and the drop of each vertex is determined based on the target scalar value of each vertex. Move each vertex of each model component in the horizontal area along the drop direction indicated by the preset direction vector by the corresponding vertex drop value to obtain the position coordinates of each vertex after the movement.
[0081] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems and devices described above can be referred to the corresponding processes in the method embodiments, and will not be repeated here. In the several embodiments provided in this application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of modules is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some communication interfaces; the indirect coupling or communication connection of devices or modules can be electrical, mechanical, or other forms.
[0082] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes: USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, optical disks, and other media capable of storing program code.
[0083] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.
Claims
1. A model rendering method, characterized in that, include: Determine the horizontal plane region of the model to be rendered, wherein the model to be rendered includes at least two model components, and the same-side planes of at least two model components are on the same horizontal plane. The same-side plane is a surface in which at least two model components face the same direction in space. The horizontal plane region is formed by the same-side planes of at least two model components. The position coordinates of each model component are obtained, and the drop information of each model component is calculated based on the position coordinates of each model component and a preset algorithm. The drop information is used to indicate the drop of the model component relative to the horizontal plane area in a preset direction. Based on the drop information of each model component, the vertices of each model component in the horizontal plane region are moved to obtain the position coordinates of each vertex after the movement; Based on the position coordinates of each vertex after movement, the model to be rendered is rendered to obtain the rendered model.
2. The method according to claim 1, characterized in that, Determining the horizontal plane region corresponding to the model to be rendered includes: Obtain the vertex normal vectors of all vertices in each of the aforementioned model components; The scalar value of each vertex is determined based on the vertex normal vector and the preset direction vector. Based on the scalar values of each vertex, the horizontal plane region of the model to be rendered is determined.
3. The method according to claim 2, characterized in that, The determination of the scalar value of each vertex based on its vertex normal vector and a preset direction vector includes: The dot product of the vertex normal vector and the preset direction vector is used as the scalar value of each vertex.
4. The method according to claim 2, characterized in that, Determining the horizontal plane region corresponding to the model to be rendered based on the scalar values of each vertex includes: Map the scalar values of each vertex to obtain the target scalar value of each vertex; The target scalar value of each vertex is compared with a preset threshold, and the vertices whose target scalar value is greater than the preset threshold are taken as the vertices constituting the horizontal plane region, thus obtaining the horizontal plane region.
5. The method according to claim 1, characterized in that, The step of obtaining the position coordinates of each model component and calculating the drop information of each model component based on the position coordinates of each model component and a preset algorithm includes: Obtain the world space coordinates of the pivot point of the model component; Based on the world space coordinates of the pivot point of the model component, a first random value and a second random value are generated; Based on the first random value and the second random value, a preset algorithm is used to calculate and obtain the drop information of the model components.
6. The method according to claim 5, characterized in that, The generation of a first random value and a second random value based on the world space coordinates of the pivot point of the model component includes: The first random value is determined based on the first coordinate component and the first mapping relationship of the world space coordinates of the central point; The second random value is determined based on the second coordinate component and the second mapping relationship of the world space coordinates of the central point.
7. The method according to claim 1, characterized in that, The step of moving the vertices of each model component in the horizontal plane region according to the drop information of each model component to obtain the position coordinates of each vertex after movement includes: Based on the drop information of each model component, the preset direction vector, and the drop of each vertex of each model component in the horizontal plane region, the vertex drop value of each vertex is determined, wherein the preset direction vector indicates the drop direction, and the drop of each vertex is determined based on the target scalar value of each vertex. The vertex of each model component in the horizontal plane region is moved along the drop direction indicated by the preset direction vector by the corresponding vertex drop value to obtain the position coordinates of each vertex after the movement.
8. A model rendering apparatus, characterized in that, include: The first determining module is used to determine the horizontal plane region of the model to be rendered. The model to be rendered includes at least two model components. The planes on the same side of the at least two model components are on the same horizontal plane. The planes on the same side are surfaces on which the at least two model components face the same direction in space. The horizontal plane region is formed by the planes on the same side of the at least two model components. The second determining module is used to obtain the position coordinates of each of the model components, and calculate the drop information of each of the model components based on the position coordinates of each of the model components and a preset algorithm. The drop information is used to indicate the drop of the model component relative to the horizontal plane area in a preset direction. The processing module is used to move the vertices of each model component in the horizontal plane region according to the drop information of each model component, and obtain the position coordinates of each vertex after movement; The rendering module is used to render the model to be rendered based on the position coordinates of each vertex after movement, and obtain the rendered model.
9. An electronic device, characterized in that, include: A processor and a memory, the memory storing machine-readable instructions executable by the processor, which, when the electronic device is running, are executed by the processor to perform the steps of the model rendering method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, performs the steps of the model rendering method as described in any one of claims 1 to 7.