Model rendering method and device, electronic equipment and storage medium
By obtaining the cutoff plane parameters and recalculating the mapping coordinates of the virtual object model, the problem of low cutoff plane rendering efficiency is solved, and the game's rendering efficiency and user experience are improved.
Patent Information
- Application Number
- CN202411455896.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2025-01-03
AI Technical Summary
In the prior art, when rendering local scenes of virtual object models in games, the cutoff plane rendering efficiency is low, resulting in poor user experience, which is mainly due to the need to dynamically perform grid Boolean operations, which is time-consuming.
By obtaining the plane parameters of the target cross-sectional plane, recalculate the mapping coordinates of the virtual object model, and rendering the cross-sectional plane based on the visual model part and texture coordinates to improve rendering efficiency.
Improves the efficiency of cross-sectional plane rendering, improves the user experience of the game, reduces rendering time, and adapts to the load to the virtual object model.
Smart Images

Figure CN119236398A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of game technology, and in particular to a model rendering method, device, electronic device and storage medium. Background Art
[0002] In games, the surface of a virtual object model is usually rendered to display the rendered virtual object model in the game screen. However, in games, there are scenes where only a part of the virtual object model is rendered. In this case, the virtual object model has a cut plane, which also needs to be rendered. However, the current method of rendering the cut plane is mainly to intersect the mesh image of the model with the cut plane to render the cut plane. This method requires dynamic mesh Boolean operations, which is time-consuming, affects the game rendering efficiency, and leads to a poor user experience. Summary of the invention
[0003] The embodiments of the present application provide a model rendering method, device, electronic device and storage medium, which can recalculate the coordinates of the virtual object model mapped to the target cross-section plane by combining the plane parameters of the target cross-section plane, so as to improve the rendering efficiency of the target cross-section plane and enhance the user experience.
[0004] In a first aspect, an embodiment of the present application provides a model rendering method, the method comprising:
[0005] Obtaining plane parameters of a target cut plane to be rendered on the virtual object model;
[0006] Based on the plane parameters and the camera parameters of the virtual camera that photographs the virtual object model, determine a first coordinate of a first pixel point of the virtual object model on the target area mapped to a second pixel point of the target cut plane;
[0007] Determining the texture coordinates of the second pixel point on the target section plane according to the first coordinates and the plane parameters;
[0008] Determine a visible model part and an invisible model part of the virtual object model on both sides of the target section plane;
[0009] A target model composed of the visible model part and the target cut plane is rendered according to the visible model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model.
[0010] In a second aspect, an embodiment of the present application provides a model rendering device, comprising:
[0011] A plane parameter acquisition module, used to acquire plane parameters of a target cut plane to be rendered on a virtual object model;
[0012] A first coordinate determination module, configured to determine, based on the plane parameters and the camera parameters of the virtual camera that photographs the virtual object model, a first coordinate of a first pixel point of the virtual object model on a target area mapped to a second pixel point of the target section plane;
[0013] A texture coordinate determination module, used to determine the texture coordinates of the second pixel point on the target section plane according to the first coordinates and the plane parameters;
[0014] A model visibility determination module, used to determine a visible model portion and an invisible model portion of the virtual object model on both sides of the target section plane;
[0015] A rendering module is used to render a target model composed of the visual model part and the target cut plane according to the visual model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model.
[0016] In a third aspect, an embodiment of the present application further provides an electronic device, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any model rendering method.
[0017] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, comprising a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any model rendering method.
[0018] In the fifth aspect, an embodiment of the present application also provides a computer program product, including a computer program, which is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs any step of the model rendering method provided in the embodiment of the present application.
[0019] By adopting the scheme of the embodiment of the present application, the plane parameters of the target cut plane to be rendered on the virtual object model can be obtained; based on the plane parameters and the camera parameters of the virtual camera that shoots the virtual object model, the first coordinate of the first pixel point of the virtual object model on the target area is mapped to the second pixel point of the target cut plane; according to the first coordinate and the plane parameters, the texture coordinates of the second pixel point on the target cut plane are determined; the visible model part and the invisible model part of the virtual object model on both sides of the target cut plane are determined; according to the visible model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model, the target model composed of the visible model part and the target cut plane is rendered. By combining the plane parameters of the target cut plane, the coordinates of the virtual object model mapped to the target cut plane are recalculated to provide rendering efficiency for the target cut plane and improve user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] 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.
[0021] Figure 1 This is a schematic diagram of an implementation environment scene of the model rendering method provided in an embodiment of the present application;
[0022] Figure 2 This is a flow chart of an embodiment of the model rendering method provided in the embodiments of the present application;
[0023] Figure 3a is a structural schematic diagram of a target cutting plane and a virtual camera provided in an embodiment of the present application;
[0024] Figure 3b It is a flow chart of a model rendering method provided in an embodiment of the present application;
[0025] Figure 3c is another flowchart of the model rendering method provided in an embodiment of the present application;
[0026] Figure 3d is another flowchart of the model rendering method provided in an embodiment of the present application;
[0027] Figure 3e This is a schematic diagram of the effect of not performing scaling adjustment in the model rendering method provided in the embodiment of the present application;
[0028] Figure 3f This is a schematic diagram of the effect of scaling adjustment in the model rendering method provided in the embodiment of the present application;
[0029] Figure 3g is another flowchart of the model rendering method provided in an embodiment of the present application;
[0030] Figure 3h is another flowchart of the model rendering method provided in an embodiment of the present application;
[0031] Figure 3i is another flowchart of the model rendering method provided in an embodiment of the present application;
[0032] Figure 3j It is a cross-sectional effect diagram after recalculating the world coordinates provided in the embodiment of the present application;
[0033] Figure 3k It is a cross-sectional effect diagram provided in the embodiment of the present application without recalculating the world coordinates;
[0034] Figure 3l It is a section of a plane effect diagram implemented based on the existing method provided in the embodiment of the present application;
[0035] Figure 4 is a structural diagram of a model rendering device provided in an embodiment of the present application;
[0036] Figure 5 It 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, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without making creative work are within the scope of protection of the present application. At the same time, in the description of the embodiments of the present application, the terms "first", "second", etc. are only used to distinguish the descriptions and cannot be understood as indicating or implying relative importance. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more features. In the description of the embodiments of the present application, the meaning of "multiple" is two or more, unless otherwise clearly and specifically defined.
[0038] The embodiment of the present application provides a model rendering method, device, electronic device and computer-readable storage medium. The model rendering device can be integrated in an electronic device, which can be a server or a terminal.
[0039] Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms. Terminals may include but are not limited to mobile phones, computers, intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. Terminals and servers can be directly or indirectly connected via wired or wireless communications, and this application does not limit this.
[0040] See also Figure 1 , taking the integration of the model rendering device into an electronic device as an example, Figure 1 A schematic diagram of an implementation scenario of the model rendering method provided in an embodiment of the present application, wherein the electronic device can be a terminal device, which obtains plane parameters of a target cross-section plane to be rendered on a virtual object model; determines, based on the plane parameters and the camera parameters of a virtual camera that photographs the virtual object model, a first coordinate of a first pixel point of the virtual object model on a target area mapped to a second pixel point of the target cross-section plane; determines, according to the first coordinate and the plane parameters, a texture coordinate of the second pixel point on the target cross-section plane; determines a visible model portion and an invisible model portion of the virtual object model on both sides of the target cross-section plane; and renders a target model consisting of the visible model portion and the target cross-section plane according to the visible model portion, the texture coordinates on the target cross-section plane, and a rendering map of the virtual object model.
[0041] It should be noted that Figure 1 The implementation environment scenario diagram of the model rendering method shown is only an example. The implementation environment scenario of the model rendering method described in the embodiment of the present application is to more clearly illustrate the technical solution of the embodiment of the present application, and does not constitute a limitation on the technical solution provided by the embodiment of the present application. It is known to those skilled in the art that with the evolution of data processing and the emergence of new business scenarios, the technical solution provided by the present application is also applicable to similar technical problems.
[0042] The solutions provided by the embodiments of the present application are specifically described by the following embodiments. It should be noted that the description order of the following embodiments is not intended to limit the preferred order of the embodiments.
[0043] This embodiment will be described from the perspective of a model rendering device, which may be integrated into an electronic device, which may be a terminal and / or a server, and this application does not limit this.
[0044] See also Figure 2 , Figure 2The model rendering method provided by the embodiment of the present application, the specific process of the model rendering method can be as follows: Step 101 to Step 105, wherein:
[0045] Step 101: Obtain plane parameters of a target cut plane to be rendered on a virtual object model.
[0046] Among them, the virtual object model refers to a model of virtual objects or objects contained in a virtual scene in a simulated game screen in a virtual digital space. The virtual object can be a virtual character, a virtual animal, etc. The objects contained in the virtual scene can be trees, pillars, houses, stones, etc., which can be adjusted according to actual conditions. For example, the virtual object model refers to a model of a stone in a simulated game screen in a virtual digital space, and for another example, the virtual object model refers to a model of a virtual character in a simulated game screen in a virtual digital space.
[0047] The target cutting plane refers to a plane that intersects with the surface where the model part that needs to be partially rendered of the virtual object model is located when the virtual object model needs to be partially rendered.
[0048] The plane parameters refer to parameter information used to describe the target cut plane or points on the target cut plane. The plane parameters may include position parameters of the cut plane, direction parameters of the cut plane, and the spatial relationship between the cut plane and the virtual object model, etc., which can be adjusted according to actual conditions and are not limited in the embodiments of the present application.
[0049] For example, the position parameters of the cutting plane include the coordinates of the center point of the cutting plane and the coordinate origin of the coordinate system where the cutting plane is located. The position parameters of the cutting plane include the tangent line of the cutting plane and the normal line of the cutting plane, wherein the tangent line of the cutting plane refers to a straight line that has the same direction as a point on the curve where the cutting plane is located when passing through a point on the curve where the cutting plane is located (i.e., the tangent point). The normal line of the cutting plane refers to a straight line that is always perpendicular to the cutting plane. The spatial relationship between the cutting plane and the virtual object model includes the specific position or specific height of the cutting plane on the virtual object model with the virtual object model as a reference.
[0050] There are many ways to obtain plane parameters, which can be adjusted according to actual conditions, and the embodiments of the present application do not limit them. For example, plane parameters (such as the normal of the cutting plane, the specific position of the cutting plane on the virtual object model) can be dynamically input to obtain the plane parameters of the target cutting plane to be rendered on the virtual object model. For another example, in response to a cutting operation on the virtual object model, the target plane parameters corresponding to the cutting operation are determined from a plurality of preset plane parameters as the plane parameters of the target cutting plane to be rendered on the virtual object model.
[0051] Step 102: Determine first coordinates of a first pixel point of the virtual object model on the target area mapped to a second pixel point of the target cut plane based on the plane parameters and the camera parameters of the virtual camera that photographs the virtual object model.
[0052] Among them, the virtual camera is a necessary component of the virtual scene, which is used to present the game screen corresponding to the virtual scene. One virtual scene corresponds to at least one virtual camera. According to actual needs, there can be two or more virtual cameras, which serve as the game rendering window to capture and present the screen content of the game world for the player. By setting the parameters of the virtual camera, the player's perspective of viewing the game world can be adjusted, such as the first-person perspective and the third-person perspective.
[0053] Among them, the camera parameters are used to describe the parameter information of the virtual camera. The camera parameters may include the position information of the virtual camera, the camera direction vector of the virtual camera, etc., wherein the camera direction vector is represented as a vector pointing from the camera position to the observed target. In three-dimensional space, the camera direction vector determines the direction of the camera and is a key part of the camera coordinate system. It can be adjusted according to actual conditions, and the embodiments of the present application are not limited.
[0054] The target area refers to the back area of the virtual object model. The back area refers to the surface in the counterclockwise direction according to the vertex order of the virtual object model. By rendering the back area, the rendering of the cut plane is realized.
[0055] The first pixel point refers to the pixel point on the back area of the virtual object model. The second pixel point refers to the pixel point corresponding to the first pixel point when it is mapped to the target section plane. The first coordinate is used to indicate the world coordinate information of the second pixel point on the target section plane in the world space coordinate system.
[0056] In some optional embodiments, the above-mentioned camera parameters include the second coordinates of the virtual camera.
[0057] The second coordinate refers to the position information of the virtual camera, which is used to indicate the world coordinate information of the virtual camera in the world space coordinate system.
[0058] In this embodiment, based on the plane parameters and the camera parameters of the virtual camera that photographs the virtual object model, the process of determining the first coordinates of the first pixel point of the virtual object model on the target area mapped to the second pixel point of the target cross-section plane can be: based on the plane parameters, the second coordinates of the virtual camera, and the third coordinates of the first pixel point, determining the coordinates of the intersection of the line between the virtual camera and the first pixel point and the target cross-section plane; and using the coordinates of the intersection as the first coordinates of the second pixel point mapped from the first pixel point to the target cross-section plane.
[0059] The third coordinate is used to indicate the world coordinate information of the first pixel point of the virtual object model on the target area in the world space coordinate system.
[0060] In some optional embodiments, the above-mentioned plane parameters include a normal line of the cutting plane and a fourth coordinate of a reference point of the cutting plane.
[0061] In this embodiment, based on the plane parameters, the second coordinates of the virtual camera, and the third coordinates of the first pixel, the process of determining the coordinates of the intersection point of the line between the virtual camera and the first pixel with the target section plane can be: based on the section plane normal, the fourth coordinates of the section plane reference point, and the third coordinates of the first pixel, calculating the first distance from the first pixel to the target section plane; based on the section plane normal, the fourth coordinates of the section plane reference point, and the second coordinates of the virtual camera, calculating the second distance from the virtual camera to the target section plane; according to the first distance, the second distance, the third coordinates of the first pixel, and the second coordinates of the virtual camera, calculating the coordinates of the intersection point of the line between the virtual camera and the first pixel with the target section plane.
[0062] Among them, the process of calculating the second distance from the virtual camera to the target cutting plane based on the cutting plane normal, the fourth coordinate of the cutting plane reference point, and the second coordinate of the virtual camera is: based on the cutting plane normal, the fourth coordinate of the cutting plane reference point, the camera direction vector of the virtual camera, and the second coordinate of the virtual camera, the second distance from the virtual camera to the target cutting plane is calculated.
[0063] The section plane reference point refers to a reference point on the target section plane and is used to determine the plane coordinate system of the target section plane. The fourth coordinate is used to indicate the world coordinate information of the section plane reference point in the world space coordinate system.
[0064] There are many options for the reference point of the cutting plane, which can be adjusted according to actual conditions, and the embodiments of the present application do not limit this. For example, the center point of the cutting plane can be used as the reference point of the cutting plane, or the center of the enclosing sphere where the virtual object model is located can be used as the reference point of the cutting plane, or the center of the enclosing sphere where the virtual object model is located can be adjusted based on various information of the enclosing sphere, and the reference point obtained can be used as the reference point of the cutting plane. There are many ways to determine the fourth coordinate of the reference point of the cutting plane, which can be adjusted according to the specific selection of the reference point of the cutting plane, and the embodiments of the present application do not limit this.
[0065] Exemplarily, when the cutting plane reference point refers to a reference point obtained by adjusting the center of the bounding sphere based on various information of the bounding sphere where the virtual object model is located, the fourth coordinate of the above-mentioned cutting plane reference point can be determined by: obtaining the fifth coordinate of the center of the bounding sphere where the virtual object model is located as the initial coordinate of the cutting plane reference point; obtaining the radius information of the bounding sphere and the section ratio information corresponding to the target cutting plane; adjusting the initial coordinate according to the cutting plane normal, radius information, and section ratio information, and using the adjusted coordinate as the fourth coordinate of the cutting plane reference point.
[0066] The fifth coordinate is used to indicate the world coordinate information of the center point of the enclosing sphere where the virtual object model is located in the world space coordinate system.
[0067] There are many ways to obtain the radius information of the enclosing sphere, which can be adjusted according to actual conditions, and the embodiments of the present application do not limit it. For example, the center of the enclosing sphere where the virtual object model is located and the length information of the enclosing sphere are determined, and the radius information of the enclosing sphere is determined according to the center of the enclosing sphere and the length information of the enclosing sphere. For another example, the radius information of the enclosing sphere input dynamically is obtained.
[0068] Among them, the section ratio information refers to the ratio of the target cutting plane dividing the virtual object model into two model parts. There are many ways to obtain the section ratio information, which can be adjusted according to the actual situation, and the embodiments of the present application are not limited. For example, the radius information of the enclosing sphere can be used as a reference, and a value can be randomly selected in (0,1). The section ratio information is determined according to the product between the value and the radius information of the enclosing sphere. For another example, a parameter value dynamically input between the range of (0,1) is obtained as the section ratio information.
[0069] Specifically, see Figure 3a to Figure 3c , combined with Figure 3a to Figure 3c The above embodiments are explained. Figure 3a As shown, point O is the origin of the coordinate system of the target section plane, that is, the reference point of the section plane is point O. N is the normal of the section plane. Point C is the second coordinate of the virtual camera, that is, point C is the camera position. The CW direction includes the camera direction vector Ray. Point w is the first pixel point of the virtual object model on the target area. Point P is the line between the virtual camera and the first pixel point, and the intersection with the target section plane. Among them, D1 / D2=CP / WP, and D1=dot(WO,N), D2=dot(Ray,N). As Figure 3b As shown in , dot(WO,N) indicates that according to the coordinate information of point O (i.e., the reference point of the cutting plane) and point W (i.e., the first pixel point), the line segment WO is determined, and the line segment WO is multiplied with the normal line of the cutting plane to obtain the first distance D1 from the first pixel point to the target cutting plane. Figure 3bAs shown in , dot(Ray,N) represents the point multiplication of the camera direction vector Ray and the normal of the cutting plane to obtain the unit distance D2 from the virtual camera to the target cutting plane. Through similar triangles, combined with the camera position, the first distance D1 from the first pixel to the target cutting plane, and the unit distance D2 from the virtual camera to the target cutting plane, the second distance CP from the virtual camera to the target cutting plane can be determined. Further, as Figure 3c As shown, the initial coordinates can be adjusted according to the normal of the cutting plane, the radius information, and the section ratio information, and the adjusted coordinates are used as the above-mentioned point O.
[0070] In some optional embodiments, it should be noted that in three-dimensional graphics rendering, it is necessary to perform front rendering on the virtual object model, that is, to render the virtual object model according to the surface orientation of the model in a clockwise direction according to the vertex order of the model. Front rendering is used to display the main appearance of the virtual object model, which is the default rendering method. However, the present application adds back rendering of the virtual object model, that is, to render the virtual object model according to the surface orientation of the model in a counterclockwise direction according to the vertex order of the model. Back rendering is used to realize the rendering of the cutting plane.
[0071] Therefore, in some optional embodiments, a target rendering channel can be drawn for the target area of the virtual object model. In the target rendering channel, based on the plane parameters and the camera parameters of the virtual camera that shoots the virtual object model, the first coordinates of the first pixel point of the virtual object model on the target area mapped to the second pixel point of the target cross-section plane are determined, and the texture coordinates of the second pixel point on the target cross-section plane are determined according to the first coordinates and the plane parameters; the visible model part and the invisible model part of the virtual object model on both sides of the target cross-section plane, the texture coordinates on the target cross-section plane, and the rendering map of the virtual object model are determined, and the target model consisting of the visible model part and the target cross-section plane is rendered.
[0072] The target rendering channel refers to a back-facing rendering channel that is different from the front-facing rendering channel. The target rendering channel is used to perform back-facing rendering of the virtual object model to achieve rendering of the cut plane.
[0073] In some optional embodiments, a back model of the virtual object model can also be constructed for the target area of the virtual object model. On the back model, based on the plane parameters and the camera parameters of the virtual camera that shoots the virtual object model, the first coordinate of the first pixel point on the back model mapped to the second pixel point of the target cut plane is determined, and the texture coordinates of the second pixel point on the target cut plane are determined according to the first coordinate and the plane parameters; the visible model part and the invisible model part of the virtual object model on both sides of the target cut plane, the texture coordinates on the target cut plane, and the rendering map of the virtual object model are determined, and the target cut plane is rendered on the back model. The front model and the back model are superimposed to obtain the target model.
[0074] It should be noted that, since there are scenes in the game where only a part of the virtual object model is rendered, there is a cut plane in the virtual object model at this time, and for this reason, the cut plane also needs to be rendered. For example, in a 2.5D top-down game, the problem of scene objects blocking the virtual character controlled by the game player often occurs. Generally, the upper half of the virtual object model of the blocked scene object is cut to maintain the role visibility of the virtual character controlled by the game player. This involves cutting the virtual object model and rendering the cut plane. There are various problems in the way of rendering the cut plane in the prior art. For example, in the method of using the mesh image of the virtual object model to intersect with the cut plane to obtain the actual cut plane, the operation is time-consuming due to the need to dynamically perform mesh Boolean operations, which is too costly for games that pursue high frame rates, resulting in low game rendering efficiency and poor user experience. For another example, in the method of using offset vertex rendering cut planes, by moving all vertices above the cut plane to the cut plane, the implementation is relatively simple, but the limitations are large, and it can only be used for object shapes that are small on the top and large on the bottom. For another example, the upper and lower models of a virtual object model are pre-made, and when an occlusion problem occurs, the upper or lower model is hidden as needed. However, since the cutting positions of the upper and lower models are fixed, the adaptability of cutting the virtual object model is poor, resulting in low game rendering efficiency and poor user experience.
[0075] In order to solve the above problems, the present application draws a target rendering channel for the target area of the virtual object model or constructs a back model of the virtual object model for the target area of the virtual object model, so as to complete the rendering processing of the target cross-section plane on the target rendering channel or the back model, so as to ensure that when the target cross-section plane is rendered, it can adapt to the virtual object model of the load, while improving the rendering efficiency and improving the user experience.
[0076] Step 103: Determine the texture coordinates of the second pixel point on the target section plane according to the first coordinates and the plane parameters.
[0077] The texture coordinates are used to indicate the two-dimensional coordinates of the second pixel point on the plane coordinate system of the target section plane, and are used to characterize the mapping relationship between the second pixel point and the texture image.
[0078] In some embodiments, the plane parameter includes a cutting plane normal, and the first coordinate is a coordinate in a world space coordinate system.
[0079] In this embodiment, the process of determining the texture coordinates of the second pixel point on the target section plane based on the first coordinates and the plane parameters can be: if the section plane normal is consistent with the first coordinate axis of the world space coordinate system, the texture coordinates of the second pixel point on the target section plane are determined based on the coordinate values of the first coordinate of the second pixel point on the second coordinate axis and the third coordinate axis, wherein the first coordinate axis is a vertically upward coordinate axis; if the section plane normal is inconsistent with the first coordinate axis of the world space coordinate system, the first coordinate of the second pixel point is converted to the plane coordinate system where the target section plane is located to obtain the texture coordinates of the second pixel point on the target section plane.
[0080] The first coordinate axis is used to indicate the vertically upward coordinate axis in the world space coordinate system. For example, the vertically upward coordinate axis in the world space coordinate system is the z axis, that is, the first coordinate axis is the z axis. The second coordinate axis and the third coordinate axis are used to indicate other non-vertically upward coordinate axes in the world space coordinate system.
[0081] In this embodiment, the process of determining the texture coordinates of the second pixel point on the target cross-section plane based on the coordinate values of the first coordinate of the second pixel point on the second coordinate axis and the third coordinate axis can be: obtaining the radius information of the bounding sphere where the virtual object model is located; determining the first adjustment parameter based on the radius information; determining the texture coordinates of the second pixel point on the target cross-section plane based on the first adjustment parameter and the coordinate values of the first coordinate of the second pixel point on the second coordinate axis and the third coordinate axis.
[0082] The first adjustment parameter refers to an adjustment parameter used to scale the texture coordinates of the second pixel point on the target section plane.
[0083] Exemplarily, assuming that the first coordinate axis is the z-axis, when the normal of the cutting plane is consistent with the z-axis in the world space coordinate system, the xy coordinate value of the first coordinate (i.e., the world coordinate) of the second pixel point is directly used, and combined with the vertex position after model scaling and the radius information of the bounding sphere, the xy coordinate value is scaled to obtain the real texture coordinates of the second pixel point on the target cutting plane to ensure that the texture image can evenly cover the surface of the virtual object model.
[0084] In this embodiment, the process of converting the first coordinate of the second pixel point to the plane coordinate system where the target section plane is located to obtain the texture coordinate of the second pixel point on the target section plane can be: constructing the plane coordinate system of the target section plane; determining the angle corresponding to the second pixel point and the normal of the section plane based on the first coordinate of the second pixel point; determining the second adjustment parameter based on the angle; converting the first coordinate to the plane coordinate system to obtain the initial texture coordinate; adjusting the initial texture coordinate based on the second adjustment parameter to obtain the texture coordinate of the second pixel point on the target section plane.
[0085] The second adjustment parameter refers to another adjustment parameter used to scale the texture coordinates of the second pixel point on the target section plane.
[0086] Specifically, see Figure 3d and Figure 3f , Figure 3d It is the process of determining texture coordinates based on the first coordinates as world coordinates and the plane coordinate system. Figure 3e is an image obtained without using the second adjustment parameter to adjust the texture coordinates of the second pixel point on the target section plane, in which the texture image cannot evenly cover the surface of the virtual object model. Figure 3f The image is obtained by adjusting the texture coordinates of the second pixel point on the target section plane using the second adjustment parameter, and the texture image in the image can evenly cover the surface of the virtual object model.
[0087] Specifically, the process of converting the first coordinate to a plane coordinate system to obtain the initial texture coordinate may include: if the cutting plane normal is consistent with the second coordinate axis of the world space coordinate system, determining the initial texture coordinate based on the coordinate values of the first coordinate of the second pixel point on the first coordinate axis and the third coordinate axis; if the cutting plane normal is consistent with the third coordinate axis of the world space coordinate system, converting to a plane coordinate system based on the coordinate values of the first coordinate of the second pixel point on the first coordinate axis and the second coordinate axis to obtain the initial texture coordinate; if the cutting plane normal is inconsistent with both the second coordinate axis and the third coordinate axis of the world space coordinate system, converting the first coordinate of the second pixel point to a plane coordinate system to obtain the initial texture coordinate.
[0088] Exemplarily, assuming that the second coordinate axis is the x-axis and the third coordinate axis is the y-axis, when the normal of the cutting plane is consistent with the x-axis in the world space coordinate system, the yz coordinate value of the first coordinate (i.e., the world coordinate) of the second pixel point is directly used, and the yz coordinate value is adjusted by the second adjustment parameter to obtain the real texture coordinate of the second pixel point on the target cutting plane to ensure that the texture coordinate is not deformed. When the normal of the cutting plane is consistent with the x-axis in the world space coordinate system, the xz coordinate value of the first coordinate (i.e., the world coordinate) of the second pixel point is directly used, and the xz coordinate value is adjusted by the second adjustment parameter to obtain the real texture coordinate of the second pixel point on the target cutting plane to ensure that the texture coordinate is not deformed.
[0089] Specifically, see Figure 3g to Figure 3h , combined with Figure 3g to Figure 3h The above embodiments are explained as follows Figure 3g As shown in FIG. 1 , a repetition value and radius information are input to the MF_PlaneSpace function for processing, and the texture coordinates of the second pixel point on the target plane are output. The repetition value is used to indicate the number of repetitions of the texture image. In addition, the specific execution process of the MF_PlaneSpace function is as follows: Figure 3f As shown, the MF_PlaneSpace function also receives the first coordinate of the second pixel point. The first adjustment parameter is determined through the radius information; the texture coordinates of the second pixel point on the target section plane are determined according to the first adjustment parameter and the coordinate values of the first coordinate of the second pixel point on the second coordinate axis and the third coordinate axis.
[0090] Step 104: Determine the visible model part and the invisible model part of the virtual object model on both sides of the target cutting plane.
[0091] The visible model part refers to the model part of the virtual object model whose transparency is not 0. The invisible model part refers to the model part of the virtual object model whose transparency is 0.
[0092] The visible model part can be made visible by adjusting the transparency parameter or the opacity parameter, and the invisible model part can be made invisible by adjusting the transparency parameter or the opacity parameter.
[0093] In some embodiments, the process of determining the visible model part and the invisible model part of the virtual object model on both sides of the target cross-section plane can be: according to the first coordinates of each second pixel point, the cross-section plane normal, and the cross-section plane reference point, calculate the angle value from the first pixel point corresponding to the second pixel point to the target cross-section plane; based on the angle value, determine the visible model part and the invisible model part of the virtual object model on both sides of the target cross-section plane.
[0094] Exemplarily, based on the normal of the cutting plane and the reference point of the cutting plane, the first coordinate of the second pixel point is calculated, that is, the cos value of the angle from the world coordinate in the world space coordinate to the plane coordinate system of the cutting plane. If the cos value of the angle is less than zero, it means that the pixel point is below the cutting plane and the opacity is set to 1. If the cos value of the angle is greater than zero, it means that the pixel point is above the cutting plane and the opacity is set to 0.
[0095] Furthermore, one can also use Figure 3i As shown in the distance calculation process, adding noise can simulate the effect of uneven edges and further enhance the realism of the effect. For models with regular shapes, the effect is more obvious.
[0096] Step 105 : Render the target model composed of the visible model part and the target cut plane according to the visible model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model.
[0097] In some optional embodiments, the rendering map includes a normal map of the target area.
[0098] In this embodiment, according to the visual model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model, the process of rendering the target model composed of the visual model part and the target cut plane may include: sampling according to the texture coordinates and the normal map to obtain the tangent space of the target cut plane; obtaining the transformation matrix between the tangent space and the world space; based on the transformation matrix, converting the texture coordinates of each second pixel point in the tangent space of the target cut plane into the corresponding world coordinates; according to the visual model part, the world coordinates corresponding to the texture coordinates on the target cut plane, and the rendering map of the virtual object model, rendering the target model composed of the visual model part and the target cut plane.
[0099] After obtaining the new texture coordinates, you can sample normal, base color, roughness and other conventional PBR rendering maps. However, the normal map needs additional processing. Sample according to the texture coordinates and normal map to obtain the tangent space of the target section plane, and convert the texture coordinates in the tangent space into the world coordinates in the world space coordinate system according to the conversion matrix. After this step, you can get the correct cross-section effect.
[0100] For specific effect diagrams, please refer to Figure 3j to Figure 3l ,in, Figure 3j It is a cutting plane rendering after the world coordinates of the cutting plane are recalculated according to the embodiment of the present application, that is, a correct rendering. Figure 3k This is a cross-sectional rendering of the embodiment of the present application without recalculating the world coordinates, that is, a rendering with an incorrect normal map. Figure 3lIt is an existing method, which fills the interior of the model with a solid color cross-section plane.
[0101] By adopting the scheme of the embodiment of the present application, the plane parameters of the target cut plane to be rendered on the virtual object model can be obtained; based on the plane parameters and the camera parameters of the virtual camera that shoots the virtual object model, the first coordinate of the first pixel point of the virtual object model on the target area is determined to be mapped to the second pixel point of the target cut plane; according to the first coordinate and the plane parameters, the texture coordinates of the second pixel point on the target cut plane are determined; the visible model part and the invisible model part of the virtual object model on both sides of the target cut plane are determined; according to the visible model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model, the target model composed of the visible model part and the target cut plane is rendered. Combined with the plane parameters of the target cut plane, the coordinates of the virtual object model mapped to the target cut plane are recalculated to provide rendering efficiency for the target cut plane and improve user experience.
[0102] This embodiment also provides a model rendering device, which can be integrated into a terminal device. Figure 4 As shown, the model rendering device may include:
[0103] A plane parameter acquisition module 201 is used to acquire plane parameters of a target cut plane to be rendered on a virtual object model;
[0104] A first coordinate determination module 202, configured to determine a first coordinate of a first pixel point of the virtual object model on the target area mapped to a second pixel point of the target section plane based on the plane parameters and the camera parameters of the virtual camera that photographs the virtual object model;
[0105] The texture coordinate determination module 203 is used to determine the texture coordinates of the second pixel point on the target section plane according to the first coordinates and the plane parameter;
[0106] A model visibility determination module 204, used to determine visible model parts and invisible model parts of the virtual object model on both sides of the target section plane;
[0107] The rendering module 205 is used to render the target model composed of the visible model part and the target cut plane according to the visible model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model.
[0108] Optionally, in the device of the embodiment of the present application, the above-mentioned camera parameters include the second coordinates of the virtual camera.
[0109] Based on this, in the first coordinate determination module 202, based on the plane parameters and the camera parameters of the virtual camera that shoots the virtual object model, determining the first coordinate of the first pixel point of the virtual object model on the target area mapped to the second pixel point of the target cut plane includes:
[0110] An intersection coordinate determination unit, used to determine the coordinates of the intersection of a line between the virtual camera and the first pixel point and a target section plane based on the plane parameters, the second coordinates of the virtual camera, and the third coordinates of the first pixel point;
[0111] The first coordinate determining unit is used to use the coordinates of the intersection point as the first coordinates of the second pixel point mapped to the target section plane.
[0112] Optionally, in the device of an embodiment of the present application, the above-mentioned plane parameters include a normal line of the cutting plane and a fourth coordinate of a reference point of the cutting plane.
[0113] Based on this, in the above-mentioned intersection coordinate determination unit, based on the plane parameters, the second coordinates of the virtual camera, and the third coordinates of the first pixel, the coordinates of the intersection of the line between the virtual camera and the first pixel and the target section plane are determined, including:
[0114] A first distance determination subunit, configured to calculate a first distance from the first pixel point to the target section plane based on the section plane normal, the fourth coordinate of the section plane reference point, and the third coordinate of the first pixel point;
[0115] A second distance determination subunit, configured to calculate a second distance from the virtual camera to the target cutting plane based on the cutting plane normal, the fourth coordinate of the cutting plane reference point, and the second coordinate of the virtual camera;
[0116] The intersection coordinate determination subunit is used to calculate the coordinates of the intersection of the line between the virtual camera and the first pixel point and the target section plane according to the first distance, the second distance, the third coordinate of the first pixel point and the second coordinate of the virtual camera.
[0117] Optionally, in the device of the embodiment of the present application, the model rendering device may further include:
[0118] An initial coordinate acquisition module, used to acquire the fifth coordinate of the center of the enclosing sphere where the virtual object model is located, as the initial coordinate of the reference point of the cutting plane;
[0119] An information acquisition module is used to obtain the radius information of the bounding sphere and the section ratio information corresponding to the target section plane;
[0120] The cutting plane reference point coordinate determination module is used to adjust the initial coordinates according to the cutting plane normal, radius information, and section ratio information, and use the adjusted coordinates as the fourth coordinates of the cutting plane reference point.
[0121] Optionally, in the device of the embodiment of the present application, in the above-mentioned model visibility determination module 204, determining the visible model part and the invisible model part of the virtual object model on both sides of the target cut plane includes:
[0122] An angle value calculation unit, used to calculate the angle value from the first pixel point corresponding to the second pixel point to the target section plane according to the first coordinates of each second pixel point, the section plane normal, and the section plane reference point;
[0123] The model visibility determination unit is used to determine the visible model part and the invisible model part of the virtual object model on both sides of the target cutting plane based on the angle value.
[0124] Optionally, in the device of an embodiment of the present application, the above-mentioned plane parameters include a normal of the cutting plane, and the above-mentioned first coordinates are coordinates in a world space coordinate system.
[0125] Based on this, in the texture coordinate determination module 203, the texture coordinate of the second pixel point on the target section plane is determined according to the first coordinate and the plane parameter, including:
[0126] a first texture coordinate determining unit, configured to determine the texture coordinates of the second pixel point on the target section plane according to the coordinate values of the first coordinate of the second pixel point on the second coordinate axis and the third coordinate axis if the section plane normal is consistent with the first coordinate axis of the world space coordinate system, wherein the first coordinate axis is a vertically upward coordinate axis;
[0127] The second texture coordinate determination unit is used to convert the first coordinate of the second pixel point to the plane coordinate system where the target cutting plane is located if the normal line of the cutting plane is inconsistent with the first coordinate axis of the world space coordinate system, so as to obtain the texture coordinate of the second pixel point on the target cutting plane.
[0128] Optionally, in the device of the embodiment of the present application, in the first texture coordinate determining unit, determining the texture coordinates of the second pixel point on the target section plane according to the coordinate values of the first coordinate of the second pixel point on the second coordinate axis and the third coordinate axis specifically includes:
[0129] Get the radius information of the enclosing sphere where the virtual object model is located;
[0130] Based on the radius information, determining a first adjustment parameter;
[0131] The texture coordinates of the second pixel point on the target section plane are determined according to the first adjustment parameter and the coordinate values of the first coordinate of the second pixel point on the second coordinate axis and the third coordinate axis.
[0132] Optionally, in the device of the embodiment of the present application, in the second texture coordinate determining unit, converting the first coordinate of the second pixel point to the plane coordinate system where the target section plane is located to obtain the texture coordinate of the second pixel point on the target section plane specifically includes:
[0133] Construct the plane coordinate system of the target section plane;
[0134] Determine, according to the first coordinate of the second pixel point, an angle between the second pixel point and the normal line of the section plane;
[0135] Determine a second adjustment parameter according to the angle;
[0136] Convert the first coordinate to the plane coordinate system to obtain the initial texture coordinate;
[0137] The initial texture coordinates are adjusted according to the second adjustment parameter to obtain the texture coordinates of the second pixel point on the target section plane.
[0138] Optionally, in the device of the embodiment of the present application, the above-mentioned conversion of the first coordinates into a plane coordinate system to obtain the initial texture coordinates specifically includes:
[0139] If the normal of the cutting plane is consistent with the second coordinate axis of the world space coordinate system, determining the initial texture coordinates based on the coordinate values of the first coordinate of the second pixel point on the first coordinate axis and the third coordinate axis;
[0140] If the normal of the cutting plane is consistent with the third coordinate axis of the world space coordinate system, based on the coordinate values of the first coordinate of the second pixel point on the first coordinate axis and the second coordinate axis, convert to the plane coordinate system to obtain the initial texture coordinates;
[0141] If the normal of the cutting plane is inconsistent with both the second coordinate axis and the third coordinate axis of the world space coordinate system, the first coordinate of the second pixel point is converted to the plane coordinate system to obtain the initial texture coordinates.
[0142] Optionally, in the device of the embodiment of the present application, the above-mentioned rendering map includes a normal map of the target area.
[0143] Based on this, in the rendering module 205, according to the visible model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model, the target model composed of the visible model part and the target cut plane is rendered, including:
[0144] A tangent space determination unit is used to perform sampling according to texture coordinates and normal maps to obtain the tangent space of the target cutting plane;
[0145] A conversion matrix acquisition unit, used to obtain the conversion matrix between the tangent space and the world space;
[0146] A world coordinate determination unit, configured to convert the texture coordinates of each second pixel point in the tangent space of the target section plane into corresponding world coordinates based on the conversion matrix;
[0147] The rendering unit is used to render the target model composed of the visible model part and the target cut plane according to the world coordinates corresponding to the texture coordinates on the visible model part and the target cut plane and the rendering map of the virtual object model.
[0148] Optionally, in the device of the embodiment of the present application, the model rendering device may further include:
[0149] A target rendering channel drawing module, used for drawing a target rendering channel for a target area of the virtual object model;
[0150] Based on this, in the first coordinate determination module 202, based on the plane parameters and the camera parameters of the virtual camera that shoots the virtual object model, determining the first coordinate of the first pixel point of the virtual object model on the target area mapped to the second pixel point of the target cut plane includes:
[0151] The first coordinate determination unit is used to determine, in a target rendering channel, a first coordinate of a first pixel point of the virtual object model on a target area mapped to a second pixel point of a target cut plane based on plane parameters and camera parameters of a virtual camera that photographs the virtual object model.
[0152] By adopting the scheme of the embodiment of the present application, the plane parameters of the target cut plane to be rendered on the virtual object model can be obtained through the plane parameter acquisition module 201; the first coordinate determination module 202 determines the first coordinate of the first pixel point of the virtual object model on the target area mapped to the second pixel point of the target cut plane based on the plane parameters and the camera parameters of the virtual camera that shoots the virtual object model; the texture coordinate determination module 203 determines the texture coordinates of the second pixel point on the target cut plane according to the first coordinate and the plane parameters; the model visibility determination module 204 determines the visible model part and the invisible model part of the virtual object model on both sides of the target cut plane; the rendering module 205 renders the target model composed of the visible model part and the target cut plane according to the visible model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model. By combining the plane parameters of the target cut plane, the coordinates of the virtual object model mapped to the target cut plane are recalculated to provide rendering efficiency for the target cut plane and improve user experience.
[0153] 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, Personal Computer), a personal digital assistant (Personal Digital Assistant, PDA) and other terminal devices. Alternatively, the electronic device may be a server.
[0154] like Figure 5 As shown, Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. The electronic device 300 includes a processor 301 having one or more processing cores, a memory 302 having one or more computer-readable storage media, and a computer program stored in the memory 302 and executable on the processor. The processor 301 is electrically connected to the memory 302. Those skilled in the art will appreciate 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, or combine certain components, or arrange components differently.
[0155] The processor 301 is the control center of the electronic device 300. It uses various interfaces and lines to connect various parts of the entire electronic device 300, and executes various functions and processes data of the electronic device 300 by running or loading software programs and / or units stored in the memory 302, and calling data stored in the memory 302, so as to monitor the electronic device 300 as a whole. The processor 301 can be a central processing unit CPU, a graphics processing unit GPU, a network processor (Network Processor, NP), etc., and can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present application.
[0156] In the embodiment of the present application, the processor 301 in the electronic device 300 will load instructions corresponding to the processes of one or more application programs into the memory 302 according to the following steps, and the processor 301 will run the application programs stored in the memory 302 to implement various functions, such as:
[0157] Obtaining plane parameters of a target cut plane to be rendered on the virtual object model;
[0158] Based on the plane parameters and the camera parameters of the virtual camera that photographs the virtual object model, determine a first coordinate of a first pixel point of the virtual object model on the target area mapped to a second pixel point of the target cut plane;
[0159] Determine the texture coordinates of the second pixel point on the target section plane according to the first coordinates and the plane parameter;
[0160] Determine a visible model part and an invisible model part of the virtual object model on both sides of the target section plane;
[0161] According to the visible model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model, the target model composed of the visible model part and the target cut plane is rendered.
[0162] The electronic device provided by the embodiment of the present application can obtain the plane parameters of the target cut plane to be rendered on the virtual object model; based on the plane parameters and the camera parameters of the virtual camera that shoots the virtual object model, determine the first coordinates of the first pixel point of the virtual object model on the target area mapped to the second pixel point of the target cut plane; determine the texture coordinates of the second pixel point on the target cut plane according to the first coordinate and the plane parameters; determine the visible model part and the invisible model part of the virtual object model on both sides of the target cut plane; render the target model composed of the visible model part and the target cut plane according to the visible model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model. Combined with the plane parameters of the target cut plane, recalculate the coordinates of the virtual object model mapped to the target cut plane to provide rendering efficiency for the target cut plane and improve user experience.
[0163] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0164] Optional, such as Figure 5 As shown, the electronic device 300 further includes: a touch screen 303, a radio frequency circuit 304, an audio circuit 305, an input unit 306, and a power supply 307. The processor 301 is electrically connected to the touch screen 303, the radio frequency circuit 304, the audio circuit 305, the input unit 306, and the power supply 307, respectively. Those skilled in the art can understand that Figure 5 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.
[0165] The touch display screen 303 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 303 may include a display panel and a touch panel. Among them, the display panel can 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 can be composed of graphics, text, icons, videos and any combination thereof. Optionally, the display panel can be configured in the form of a liquid crystal display (LCD, Liquid Crystal Display), an organic light-emitting diode (OLED, Organic Light-Emitting Diode) and the like. The touch panel can be used to collect the user's touch operation on or near it (such as the user uses 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 direction, 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 301, and can receive the command sent by the processor 301 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 301 to determine the type of touch event, and then the processor 301 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 303 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 303 can also be used as a part of the input unit 306 to realize the input function.
[0166] The radio frequency circuit 304 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 with the network device or other electronic devices.
[0167] The audio circuit 305 can be used to provide an audio interface between the user and the electronic device through a speaker and a microphone. The audio circuit 305 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 305 and converted into audio data, and then the audio data is output to the processor 301 for processing, and then sent to another electronic device through the radio frequency circuit 304, or the audio data is output to the memory 302 for further processing. The audio circuit 305 may also include an earplug jack to provide communication between an external headset and the electronic device.
[0168] The input unit 306 may be used to receive input of the visual impairment type of the game player, or other user information.
[0169] The power supply 307 is used to supply power to various components of the electronic device 300. Optionally, the power supply 307 can be logically connected to the processor 301 through a power management system, so that the power management system can manage charging, discharging, and power consumption. The power supply 307 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.
[0170] although Figure 5 Not shown, the electronic device 300 may also include a camera, a sensor, a wireless fidelity module, a Bluetooth module, etc., which will not be described in detail here.
[0171] 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.
[0172] 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.
[0173] To this end, an embodiment of the present application provides a computer-readable storage medium, in which multiple computer programs are stored, and the computer program can be loaded by a processor to execute any model rendering method provided in the embodiment of the present application. The computer program can execute the following steps of the model rendering method:
[0174] Obtaining plane parameters of a target cut plane to be rendered on the virtual object model;
[0175] Based on the plane parameters and the camera parameters of the virtual camera that photographs the virtual object model, determine a first coordinate of a first pixel point of the virtual object model on the target area mapped to a second pixel point of the target cut plane;
[0176] Determine the texture coordinates of the second pixel point on the target section plane according to the first coordinates and the plane parameter;
[0177] Determine a visible model part and an invisible model part of the virtual object model on both sides of the target section plane;
[0178] According to the visible model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model, the target model composed of the visible model part and the target cut plane is rendered.
[0179] By using the computer-readable storage medium provided in the embodiment of the present application, the plane parameters of the target cut plane to be rendered on the virtual object model can be obtained; based on the plane parameters and the camera parameters of the virtual camera that shoots the virtual object model, the first coordinate of the first pixel point of the virtual object model on the target area is determined to be mapped to the second pixel point of the target cut plane; according to the first coordinate and the plane parameters, the texture coordinates of the second pixel point on the target cut plane are determined; the visible model part and the invisible model part of the virtual object model on both sides of the target cut plane are determined; according to the visible model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model, the target model composed of the visible model part and the target cut plane is rendered. Combined with the plane parameters of the target cut plane, the coordinates of the virtual object model mapped to the target cut plane are recalculated to provide rendering efficiency for the target cut plane and improve user experience.
[0180] The specific implementation of the above operations can be found in the previous embodiments, which will not be described in detail here.
[0181] 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.
[0182] Since the computer program stored in the computer-readable storage medium can execute any one of the model rendering methods provided in the embodiments of the present application, the beneficial effects that can be achieved by any one of the model rendering 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.
[0183] According to one aspect of the present application, a computer program product or a computer program is also provided, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the methods provided in various optional implementations of the above embodiments.
[0184] In the above-mentioned model rendering device, computer-readable storage medium, electronic device, and computer program product embodiments, the description of each embodiment has its own emphasis. For parts not described in detail in a certain embodiment, reference can be made to the relevant description of other embodiments. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process and beneficial effects of the above-described model rendering device, computer-readable storage medium, computer program product, electronic device, and its corresponding units can refer to the description of the model rendering method in the above embodiment, and will not be repeated here.
[0185] The above is a detailed introduction to a model rendering method, device, electronic device, computer-readable storage medium and computer program product 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 scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A model rendering method, characterized in that: The method comprises: Obtaining plane parameters of a target cut plane to be rendered on the virtual object model; Based on the plane parameters and the camera parameters of the virtual camera that photographs the virtual object model, determine a first coordinate of a first pixel point of the virtual object model on the target area mapped to a second pixel point of the target cut plane; Determining the texture coordinates of the second pixel point on the target section plane according to the first coordinates and the plane parameters; Determine a visible model part and an invisible model part of the virtual object model on both sides of the target section plane; A target model composed of the visible model part and the target cut plane is rendered according to the visible model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model.
2. The model rendering method according to claim 1, characterized in that: The camera parameters include the second coordinates of the virtual camera, and determining, based on the plane parameters and the camera parameters of the virtual camera that photographs the virtual object model, the first coordinates of a first pixel point of the virtual object model on the target area mapped to a second pixel point of the target cut plane includes: Based on the plane parameters, the second coordinates of the virtual camera, and the third coordinates of the first pixel point, determining the coordinates of the intersection of a line between the virtual camera and the first pixel point and the target section plane; The coordinates of the intersection point are used as first coordinates of a second pixel point mapped from the first pixel point to the target section plane.
3. The model rendering method according to claim 2, characterized in that: The plane parameters include a normal line of the cutting plane and a fourth coordinate of a reference point of the cutting plane, and determining the coordinates of an intersection point of a line between the virtual camera and the first pixel point and the target cutting plane based on the plane parameters, the second coordinate of the virtual camera, and the third coordinate of the first pixel point includes: Calculate a first distance from the first pixel point to the target cutting plane based on the normal line of the cutting plane, the fourth coordinate of the reference point of the cutting plane, and the third coordinate of the first pixel point; Calculate a second distance from the virtual camera to the target cutting plane based on the cutting plane normal, the fourth coordinate of the cutting plane reference point, and the second coordinate of the virtual camera; The coordinates of the intersection of a line between the virtual camera and the first pixel point and the target section plane are calculated according to the first distance, the second distance, the third coordinate of the first pixel point and the second coordinate of the virtual camera.
4. The model rendering method according to claim 3, characterized in that: The method further comprises: Obtain the fifth coordinate of the center of the bounding sphere where the virtual object model is located as the initial coordinate of the reference point of the cutting plane; Obtaining radius information of the bounding sphere and section ratio information corresponding to the target section plane; The initial coordinates are adjusted according to the normal of the cutting plane, the radius information, and the section ratio information, and the adjusted coordinates are used as the fourth coordinates of the reference point of the cutting plane.
5. The model rendering method according to claim 3, characterized in that: The determining of the visible model part and the invisible model part of the virtual object model on both sides of the target cut plane includes: Calculate the angle between the first pixel point corresponding to the second pixel point and the target section plane according to the first coordinates of each of the second pixel points, the section plane normal, and the section plane reference point; Based on the angle value, a visible model part and an invisible model part of the virtual object model on both sides of the target section plane are determined.
6. The model rendering method according to claim 1, characterized in that: The plane parameter includes a cutting plane normal, and the first coordinate is a coordinate in a world space coordinate system; and determining the texture coordinate of the second pixel point on the target cutting plane according to the first coordinate and the plane parameter includes: If the normal of the cutting plane is consistent with the first coordinate axis of the world space coordinate system, determining the texture coordinates of the second pixel point on the target cutting plane according to the coordinate values of the first coordinate of the second pixel point on the second coordinate axis and the third coordinate axis, wherein the first coordinate axis is a vertically upward coordinate axis; If the normal of the cutting plane is inconsistent with the first coordinate axis of the world space coordinate system, the first coordinate of the second pixel point is converted to the plane coordinate system where the target cutting plane is located to obtain the texture coordinate of the second pixel point on the target cutting plane.
7. The model rendering method according to claim 6, characterized in that: The step of determining the texture coordinates of the second pixel point on the target section plane according to the coordinate values of the first coordinate of the second pixel point on the second coordinate axis and the third coordinate axis includes: Obtaining radius information of a bounding sphere where the virtual object model is located; Based on the radius information, determining a first adjustment parameter; The texture coordinates of the second pixel point on the target section plane are determined according to the first adjustment parameter and the coordinate values of the first coordinate of the second pixel point on the second coordinate axis and the third coordinate axis.
8. The model rendering method according to claim 6, characterized in that: The step of converting the first coordinate of the second pixel point to the plane coordinate system where the target cutting plane is located to obtain the texture coordinate of the second pixel point on the target cutting plane includes: Constructing a plane coordinate system of the target section plane; Determine, according to the first coordinate of the second pixel point, an angle between the second pixel point and the normal line of the section plane; determining a second adjustment parameter according to the angle; Convert the first coordinates to the plane coordinate system to obtain initial texture coordinates; The initial texture coordinates are adjusted according to the second adjustment parameter to obtain the texture coordinates of the second pixel point on the target section plane.
9. The model rendering method according to claim 8, characterized in that: The converting the first coordinates into the plane coordinate system to obtain initial texture coordinates includes: If the normal of the cutting plane is consistent with the second coordinate axis of the world space coordinate system, determining the initial texture coordinates based on the coordinate values of the first coordinate of the second pixel point on the first coordinate axis and the third coordinate axis; If the normal of the cutting plane is consistent with the third coordinate axis of the world space coordinate system, converting the coordinate values of the first coordinate of the second pixel point on the first coordinate axis and the second coordinate axis to the plane coordinate system to obtain initial texture coordinates; If the normal of the cutting plane is inconsistent with both the second coordinate axis and the third coordinate axis of the world space coordinate system, the first coordinate of the second pixel point is converted to the plane coordinate system to obtain initial texture coordinates.
10. The model rendering method according to any one of claims 1 to 9, characterized in that: The rendering map includes a normal map of the target area, and the rendering map of the virtual object model is used to render the target model composed of the visual model part and the target cut plane, including: Sampling is performed according to the texture coordinates and the normal map to obtain the tangent space of the target cutting plane; Obtaining a transformation matrix between the tangent space and the world space; Based on the transformation matrix, convert the texture coordinates of each second pixel point in the tangent space of the target section plane into corresponding world coordinates; The target model composed of the visual model part and the target cut plane is rendered according to the visible model part, the world coordinates corresponding to the texture coordinates on the target cut plane, and the rendering map of the virtual object model.
11. The model rendering method according to any one of claims 1 to 9, characterized in that: The method further comprises: Drawing a target rendering pass for a target area of the virtual object model; The determining, based on the plane parameters and the camera parameters of the virtual camera that photographs the virtual object model, a first coordinate of a first pixel point of the virtual object model on the target area mapped to a second pixel point of the target cut plane comprises: In the target rendering channel, based on the plane parameters and the camera parameters of the virtual camera that photographs the virtual object model, the first coordinates of the first pixel point of the virtual object model on the target area mapped to the second pixel point of the target cut plane are determined.
12. A model rendering device, characterized in that: The device comprises: A plane parameter acquisition module, used to acquire plane parameters of a target cut plane to be rendered on a virtual object model; A first coordinate determination module, configured to determine, based on the plane parameters and the camera parameters of the virtual camera that photographs the virtual object model, a first coordinate of a first pixel point of the virtual object model on a target area mapped to a second pixel point of the target cut plane; A texture coordinate determination module, used to determine the texture coordinates of the second pixel point on the target section plane according to the first coordinates and the plane parameters; A model visibility determination module, used to determine a visible model portion and an invisible model portion of the virtual object model on both sides of the target section plane; A rendering module is used to render a target model composed of the visual model part and the target cut plane according to the visual model part, the texture coordinates on the target cut plane, and the rendering map of the virtual object model.
13. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the model rendering method described in any one of claims 1 to 11.
14. A computer-readable storage medium, characterized in that: It includes a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the model rendering method described in any one of claims 1 to 11.
Citation Information
Cited By
Multi-model surface complementing method based on texture mixed accumulation, terminal and storage medium
CN121392105A
