Rendering method and device of insert model, equipment and storage medium
By subdividing the insert model and three-dimensional coordinate processing, determining the observation normal direction and calculating the rendering parameters, the problem of unrealistic lighting rendering effect of the insert model in the prior art is solved, and a more realistic lighting rendering effect is achieved.
Patent Information
- Application Number
- CN202411639299.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-03-04
AI Technical Summary
The prior art cannot effectively calculate the performance effect of the insert model under different lighting, resulting in unreal lighting rendering effects.
By subdividing the insertion model, the three-dimensional coordinates of each target pixel point are obtained, and the observation normal direction is determined based on these coordinates and the projection plane of the sub-insert model, and the rendering parameters are calculated for lighting rendering.
The real rendering effect of different target pixels on the same plane under different lighting is achieved, improving the authenticity of the lighting rendering of the insert model.
Smart Images

Figure CN119559315A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of rendering technology, and in particular to a rendering method, device, equipment and storage medium for an insert model. Background Art
[0002] In the field of computer graphics, the application of plug-in models often appears in the design of games and film and television. Because the plug-in model has fewer faces and a simpler structure, it is often used as a production method for optimizing the performance of some special effects or plants. If the plug-in model is used, the basic three-dimensional shape of the model can be maintained at a relatively long distance, which does not affect our observation effect and improves the operating efficiency of our working environment.
[0003] The insert structure is relatively simple, the surface is very flat, and the normal distribution is very uniform. In the related technology, it is impossible to calculate the performance of the insert model under different lighting conditions. Summary of the invention
[0004] The purpose of this application is to provide a rendering method, device, equipment and storage medium for an insert model in view of the deficiencies in the above-mentioned prior art, so as to solve the above-mentioned technical problems existing in the related art.
[0005] To achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0006] In a first aspect, an embodiment of the present application provides a method for rendering an insert model, wherein the insert model includes a plurality of basic face patches, wherein each of the basic face patches has the same size at least in a first direction, and the plurality of basic face patches intersect each other through a center position in the first direction to form the insert model, the method comprising:
[0007] Subdividing the insert model in a second direction perpendicular to the first direction to obtain a plurality of sub-insert models;
[0008] Obtaining the three-dimensional coordinates of each target pixel point of the sub-slice model in a preset line of sight direction in a preset three-dimensional space;
[0009] Determine, according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-slice model in the second direction, the observation normal direction corresponding to the target pixel point in the preset line of sight direction;
[0010] Determining, according to the observation normal direction corresponding to the target pixel point, a rendering parameter of the target pixel point in a preset illumination direction;
[0011] According to the rendering parameters of the target pixel point, the insert model is subjected to lighting rendering to obtain a rendered insert model.
[0012] In a second aspect, an embodiment of the present application further provides a rendering device for an insert model, wherein the insert model includes a plurality of basic face patches, wherein each basic face patch has the same size at least in a first direction, and the plurality of basic face patches intersect each other through a center position in the first direction to form the insert model, the device including:
[0013] A subdivision module, used to subdivide the insert model in a preset extension direction in a second direction perpendicular to the first direction to obtain a plurality of sub-insert models;
[0014] An acquisition module, used for acquiring the three-dimensional coordinates of each target pixel point of the sub-slice model in a preset line of sight direction in a preset three-dimensional space;
[0015] A determination module, used to determine the observation normal direction corresponding to the target pixel point in the preset sight line direction according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-slice model in the second direction; and determine the rendering parameters of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point;
[0016] The lighting rendering module is used to perform lighting rendering on the insert model according to the rendering parameters of the target pixel point to obtain a rendered insert model.
[0017] In a third aspect, an embodiment of the present application further provides a rendering device for an insert model, comprising: a memory and a processor, wherein the memory stores a computer program executable by the processor, and when the processor executes the computer program, the rendering method for the insert model described in any one of the first aspect above is implemented.
[0018] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is read and executed, the method for rendering the insert model described in any one of the first aspects above is implemented.
[0019] The beneficial effects of the present application are as follows: an embodiment of the present application provides a rendering method for a patch model, the patch model comprising a plurality of basic patches, wherein each basic patch has the same size at least in a first direction, and the plurality of basic patches intersect each other through a center position in the first direction to form a patch model, the method comprising: subdividing the patch model in a second direction perpendicular to the first direction to obtain a plurality of sub-patch models; obtaining the three-dimensional coordinates of each target pixel point of the sub-patch model in a preset line of sight direction in a preset three-dimensional space; determining the observation normal direction corresponding to the target pixel point in the preset line of sight direction according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-patch model in the second direction; determining the rendering parameters of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point; performing illumination rendering on the patch model according to the rendering parameters of the target pixel point to obtain a rendered patch model. The patch model is subdivided to obtain multiple sub-patch models, and the observation normal direction corresponding to the target pixel point is simulated based on the three-dimensional coordinates of the target pixel point and the projection plane of the sub-patch model in the second direction, so that the observation normal directions corresponding to different target pixels on the same plane of the sub-patch model are different. The rendering parameters are calculated based on the observation normal direction and lighting rendering is performed, which can show different performance effects of different target pixels on the same plane under different lighting, making the lighting rendering effect of the patch model more realistic. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 Schematic diagram of UV distribution of a basic patch provided in an embodiment of the present application Figure 1 ;
[0022] Figure 2 Schematic diagram of UV distribution of a basic patch provided in an embodiment of the present application Figure 2 ;
[0023] Figure 3 Schematic diagram of an optional deformation of a basic surface provided in an embodiment of the present application Figure 1 ;
[0024] Figure 4 Schematic diagram of an optional deformation of a basic surface provided in an embodiment of the present application Figure 2 ;
[0025] Figure 5A schematic diagram of an insert model provided in an embodiment of the present application;
[0026] Figure 6 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 1 ;
[0027] Figure 7 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 2 ;
[0028] Figure 8 A schematic diagram of a projection plane and a projection cross section provided in an embodiment of the present application;
[0029] Fig. 9 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 3 ;
[0030] Fig.10 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 4 ;
[0031] Fig.11 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 5 ;
[0032] Fig.12 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 6 ;
[0033] Fig.13 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 7 ;
[0034] Fig.14 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 8 ;
[0035] Fig.15 A schematic diagram of the structure of a rendering device for an insert model provided in an embodiment of the present application;
[0036] Fig.16 A schematic diagram of the structure of a rendering device for an insert model provided in an embodiment of the present application. DETAILED DESCRIPTION
[0037] In order to make the purpose, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below in combination with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments.
[0038] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0039] In the description of the present application, it should be noted that if the terms "upper", "lower", etc. appear, the orientation or position relationship indicated is based on the orientation or position relationship shown in the drawings, or is the orientation or position relationship in which the product of the application is usually placed when used. It is only for the convenience of describing the present application and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application.
[0040] In addition, the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0041] It should be noted that, in the absence of conflict, the features in the embodiments of the present application may be combined with each other.
[0042] The following is an explanation of the terms involved in the embodiments of the present application.
[0043] UV: are two-dimensional texture coordinate points residing on the vertices of polygonal meshes. They define a two-dimensional texture coordinate system, called UV texture space. UV provides a connection between a model surface and a texture image, and is responsible for determining on which vertex of the model surface a point (pixel) on the texture image should be placed, thereby covering the entire texture on the model.
[0044] Among them, in computer graphics, there are two most important coordinate systems for three-dimensional models, one is the position (x, y, z) coordinates of the vertices, and the other is the texture map UV coordinates. In short, the texture map UV coordinates are the basis for mapping the map to the surface of the model. Generally speaking, it should be (U, V, W) coordinates (to distinguish it from XYZ coordinates), where U and V are the coordinates of the texture map in the horizontal and vertical directions of the display, respectively, and the values are usually 0 to 1. In other words, it can represent the Uth pixel / image width in the horizontal direction and the Vth pixel / image height in the vertical direction; in addition, the direction of the coordinate W is perpendicular to the display surface, which is usually used for program mapping or specific three-dimensional mapping technology, but W is usually not used for games, so it is referred to as UV coordinates.
[0045] Insert model: Usually, several identical or slightly different patch models are cross-combined together, which is called an insert model. An insert model generally has at least two patches cross-combined, which are vertically distributed or cross-distributed at a certain angle.
[0046] An embodiment of the present application provides a method for rendering a plug-in model, which is applied to a rendering device for a plug-in model. The rendering device for the plug-in model may be a terminal device, which may be any one of the following: a computer device, a laptop computer, a tablet computer, a smart phone, etc.
[0047] The following is an explanation of a rendering method for an insert model provided in an embodiment of the present application.
[0048] The insert model in the embodiment of the present application includes: a plurality of basic surface patches, wherein each basic surface patch has the same size at least in the first direction, and the plurality of basic surface patches intersect each other through the center positions in the first direction to form the insert model.
[0049] The number of basic patches is [2, m], where m is any natural number greater than or equal to 2.
[0050] In some embodiments, multiple basic face patches are made, the first direction may be the U direction, each basic face patch has the same size in the U direction, and the size in the U direction is [0, 1], and multiple basic face patches are crossed with each other through the center position in the U direction to form an insert model, wherein the center position in the U direction is the position where U is 0.5. When crossing, an equally spaced angle may be used so that each basic face patch is evenly spaced by a preset angle.
[0051] Optionally, the base patch may be a base square patch, Figure 1 Schematic diagram of UV distribution of a basic patch provided in an embodiment of the present application Figure 1 ,like Figure 1As shown, the basic patch is [0, 1] in both the U direction and the V direction. In the embodiment of the present application, the lengths of multiple basic patches in the U direction may be recorded as L.
[0052] It should be noted that multiple basic patches can be scaled arbitrarily in the V direction. Figure 2 Schematic diagram of UV distribution of a basic patch provided in an embodiment of the present application Figure 2 ,like Figure 2 As shown, after scaling, its UV distribution is [0, 1] in the U direction and [0, n] in the V direction, where n can be any number greater than or equal to 0.
[0053] In the embodiment of the present application, the scaled base face can be arbitrarily distorted in the V direction, such as bending in the middle or distorting the whole face. Figure 3 Schematic diagram of an optional deformation of a basic surface provided in an embodiment of the present application Figure 1 ,like Figure 3 As shown, the base surface piece is bent after being stretched in the V direction. Figure 4 Schematic diagram of an optional deformation of a basic surface provided in an embodiment of the present application Figure 2 ,like Figure 4 As shown, the base patch is twisted after being stretched in the V direction.
[0054] For example, Figure 5 A schematic diagram of a plug-in model provided in an embodiment of the present application, such as Figure 5 As shown, the number of basic face patches is three, and the central positions of the three basic face patches in the U direction intersect with each other to form an insert model, the three basic face patches are evenly spaced 60 degrees apart, and the insert model has an arc in the V direction. Of course, the number of basic face patches, the angles between the basic face patches, and the curved shape in the V direction can be set according to actual needs, and the embodiments of the present application do not impose specific restrictions on this.
[0055] In practical applications, different plug-in models can be obtained by crossing basic patches of different shapes in the U direction and deforming them in the V direction. The plug-in model can be used to simulate some elements of columnar parabolas, such as smoke trails, water columns, plant branches and leaves, etc.
[0056] Figure 6 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 1 ,like Figure 6 As shown, the method may include:
[0057] S101 . Subdivide a plug-in model in a second direction perpendicular to the first direction to obtain a plurality of sub-plug-in models.
[0058] The first direction and the second direction are perpendicular to each other, the first direction may be the U direction, and the second direction may be the V direction. In the embodiment of the present application, according to the UV distribution of the insert face in the insert model, a V-direction seamless texture may be used on the insert face to make it appear continuous in the V direction, thereby showing different effects.
[0059] It should be noted that the insert model is infinitely differentiated in the V direction to obtain a plurality of sub-insert models, and the thickness of each sub-insert model is approximately zero.
[0060] In some embodiments, for Figure 5 The insert model in can be approximated as a curved cylinder. By subdividing the cylinder in the V direction, multiple sub-insert models can be obtained. Each sub-insert model can be regarded as a circle with approximately no thickness.
[0061] S102: Obtain the three-dimensional coordinates of each target pixel point of the sub-slice model in a preset line of sight direction in a preset three-dimensional space.
[0062] The insert model and the virtual camera both exist in a preset three-dimensional space, and the preset sight line direction is a sight line direction determined based on the position of the virtual camera in the preset three-dimensional space.
[0063] In an embodiment of the present application, there may be multiple target pixel points in a preset line of sight direction, and the three-dimensional coordinates of the multiple target pixel points are preset.
[0064] S103: Determine the observation normal direction corresponding to the target pixel point in the preset sight line direction according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-slice model in the second direction.
[0065] In some embodiments, a preset normal direction calculation formula may be used to determine the observation normal direction corresponding to the target pixel point in the preset line of sight direction according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-plug model in the second direction.
[0066] It should be noted that in the related art, the normals of different target pixels on the same plane of the insert model are the same, so it is impossible to calculate different lighting effects for these target pixels, that is, it is impossible to perform lighting operations. In the embodiment of the present application, the observation normal direction corresponding to the target pixel is simulated according to the three-dimensional coordinates of the target pixel and the projection plane of the sub-insert model in the second direction, so that the observation normal directions corresponding to different target pixels on the same plane are different, so that different lighting effects can be calculated for these target pixels.
[0067] S104 . Determine rendering parameters of the target pixel point in a preset lighting direction according to the observation normal direction corresponding to the target pixel point.
[0068] The rendering parameters calculated for different target pixels may be different.
[0069] In some implementations, a preset rendering parameter calculation formula is used to determine the rendering parameters of the target pixel point in the preset lighting direction according to the observation normal direction corresponding to the target pixel point and the preset lighting direction.
[0070] It should be noted that different observation normal directions can be simulated for different target pixel points on the same plane in the insert model; and different rendering parameters can be calculated for different target pixel points on the same plane according to the observation normal directions.
[0071] S105 . Perform illumination rendering on the insert model according to the rendering parameters of the target pixel point to obtain a rendered insert model.
[0072] In an embodiment of the present application, the insert model is illuminated and rendered according to different rendering parameters of different target pixels, so that different target pixels on the same plane in the insert model can present different lighting effects in a preset lighting direction, thereby realizing the observation normal direction and lighting differences based on different target pixels, showing the lighting intensity of different target pixels, and making the lighting rendering effect of the insert model more realistic.
[0073] In summary, an embodiment of the present application provides a rendering method for a patch model, wherein the patch model includes multiple basic face patches, wherein each basic face patch has the same size at least in a first direction, and multiple basic face patches intersect with each other through the center position in the first direction to form the patch model, the method including: subdividing the patch model in a second direction perpendicular to the first direction to obtain multiple sub-patch models; obtaining the three-dimensional coordinates of each target pixel point of the sub-patch model in a preset line of sight direction in a preset three-dimensional space; determining the observation normal direction corresponding to the target pixel point in the preset line of sight direction according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-patch model in the second direction; determining the rendering parameters of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point; performing illumination rendering on the patch model according to the rendering parameters of the target pixel point to obtain a rendered patch model. The patch model is subdivided to obtain multiple sub-patch models, and the observation normal direction corresponding to the target pixel point is simulated based on the three-dimensional coordinates of the target pixel point and the projection plane of the sub-patch model in the second direction, so that the observation normal directions corresponding to different target pixels on the same plane of the sub-patch model are different. The rendering parameters are calculated based on the observation normal direction and lighting rendering is performed, which can show different performance effects of different target pixels on the same plane under different lighting, making the lighting rendering effect of the patch model more realistic.
[0074] Optionally, Figure 7 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 2 ,like Figure 7 As shown, the process of determining the observation normal direction corresponding to the target pixel point in the preset sight line direction according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-slice model in the second direction in the above S103 may include:
[0075] S201, determining the three-dimensional coordinates of the center point of the projection section and the three-dimensional coordinates of the mapping point on the projection plane according to the three-dimensional coordinates of the target pixel point and the preset sight line observation point in the preset sight line direction.
[0076] The projection section is the section on the projection plane on the sub-plug model.
[0077] It should be noted that the preset sight observation point in the preset sight direction refers to the position of the virtual camera in the preset three-dimensional space; the position of the virtual camera in the preset three-dimensional space is projected onto the projection plane, and the projected point is the mapping point. The projection plane can be the plane where the sub-plug model is located.
[0078] In addition, the projection cross section on the projection plane refers to the cross section corresponding to the sub-plug-in model on the projection plane, and the center point of the projection cross section refers to the center point of the cross section corresponding to the sub-plug-in model. For example, Figure 5 The projected cross section of the insert model shown is a circle, and the center point of the projected cross section is the center of the circle.
[0079] S202 . Calculate the three-dimensional coordinates of the intersection of the line between the mapping point and the target pixel and the projection cross section according to the three-dimensional coordinates of the target pixel and the mapping point.
[0080] The intersection point of the line between the mapping point and the target pixel point and the projection cross section can be regarded as the intersection point of the line between the mapping point and the target pixel point and the outer contour of the projection cross section.
[0081] Figure 8 A schematic diagram of a projection plane and a projection cross section provided in an embodiment of the present application, such as Figure 8 As shown, the projection plane has a projection section and a mapping point Vp. Figure 5 The projection cross section corresponding to the sub-plug-in model of the plug-in model shown can be regarded as a regular circle, with a target pixel point P on the sub-plug-in model, and the intersection point of the line connecting the mapping point Vp and the target pixel point P and the circle is T. That is to say, in the present application, the three-dimensional coordinates of the intersection point T can be calculated according to the three-dimensional coordinates of the target pixel point P and the three-dimensional coordinates of the mapping point Vp, and the center of the circle can be represented as O.
[0082] S203. Determine the direction of the observation normal according to the direction vector from the three-dimensional coordinates of the center point to the three-dimensional coordinates of the intersection point.
[0083] Among them, the center point can be represented as O, the intersection point can be represented as T, and the direction vector of the three-dimensional coordinate of the center point pointing to the three-dimensional coordinate of the intersection point, that is, the vector in the OT direction can be represented as n OT .
[0084] In the embodiment of the present application, the direction vector of the three-dimensional coordinates of the center point pointing to the three-dimensional coordinates of the intersection point is used to simulate the observation normal direction of the target pixel point. In this way, the intersection points corresponding to different target pixels are different, and when the center point is the same, the simulated observation normal directions are different. Therefore, different observation normal directions can be determined for different target pixels on the same plane.
[0085] Optionally, Fig. 9 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 3 ,like Fig. 9 As shown, the process of determining the three-dimensional coordinates of the center point of the projection cross section and the three-dimensional coordinates of the mapping point on the projection plane according to the three-dimensional coordinates of the target pixel point and the preset sight line observation point in the preset sight line direction in the above S201 may include:
[0086] S301. Calculate the three-dimensional coordinates of the center point in a preset three-dimensional space according to the three-dimensional coordinates of the target pixel point.
[0087] Among them, the three-dimensional coordinates of the center point in the preset three-dimensional space can also be called the world position of the center point.
[0088] In some implementations, the three-dimensional coordinates of the center point in the preset three-dimensional space are calculated according to the three-dimensional coordinates of the target pixel, the size of the sub-slice model, and the tangent line of the target pixel.
[0089] S302, mapping a preset sight observation point onto a projection plane according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the center point to obtain the three-dimensional coordinates of the mapping point.
[0090] In some embodiments, an equation is constructed based on the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the center point, and then the equation is solved to map a preset line of sight observation point in a preset three-dimensional space to a projection plane to obtain the three-dimensional coordinates of the mapping point.
[0091] Optionally, Fig.10 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 4 ,like Fig.10 As shown, according to the three-dimensional coordinates of the target pixel point, the three-dimensional coordinates of the center point of the projection plane in the preset three-dimensional space are calculated, including:
[0092] S401 . Calculate a target value of a target pixel in a first direction according to the three-dimensional coordinates of the target pixel.
[0093] The target value of the target pixel in the first direction refers to the value of the target pixel in the U direction. The target pixel can be represented as P, and the target value can be represented as U p .
[0094] S402, calculating the three-dimensional coordinates of the center point according to the target value, the size of the sub-slice model, the tangent line of the target pixel point and the three-dimensional coordinates of the target pixel point.
[0095] It should be noted that if the sub-plug-in model is a circle, the size of the sub-plug-in model can be the diameter of the circle, the diameter can be expressed as L, and the tangent line of the target pixel point can be expressed as Tangent p , the three-dimensional coordinates of the target pixel can be expressed as Pos p The tangent line of the target pixel point refers to the direction from the center point to the target pixel point, pointing to the outside of the projection section.
[0096] The above process can be expressed as:
[0097] Pos O =|0.5-U P |*L*Tangent P +Pos P
[0098] Among them, Pos o are the calculated three-dimensional coordinates of the center point.
[0099] Optionally, Fig.11 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 5 ,like Fig.11 As shown, the process of mapping the preset sight observation point to the projection plane according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the center point in the above S302 to obtain the three-dimensional coordinates of the mapping point may include:
[0100] S501 . Construct a plane equation of the projection plane according to the three-dimensional coordinates of the target pixel point and the plane normal vector of the projection plane.
[0101] Among them, the plane equation of the projection plane is the equation of the plane where the projection section lies.
[0102] In some embodiments, the projected cross section may be a circle, and the equation of the plane where the circle is located is the plane equation of the projection plane, which can be expressed as:
[0103] nx (x-pos p .x)+n y (y-pos p .y)+n z (z-pos p .z)=0
[0104] Among them, Pos p represents the three-dimensional coordinates of the target pixel point P, n = (n x , n y , n z ) is the plane normal vector of the projection plane where the target pixel point P is located.
[0105] S502: Construct a target equation according to the three-dimensional coordinates of the center point and the plane normal vector of the projection plane.
[0106] In the embodiment of the present application, the target equation can be expressed as:
[0107]
[0108] Among them, Pos o is the three-dimensional coordinate of the center point, n=(n x , n y , n z ) is the plane normal vector of the projection plane where the target pixel point P is located.
[0109] S503, solving the plane equation and the target equation to obtain the three-dimensional coordinates of the mapping point.
[0110] Optionally, calculating the three-dimensional coordinates of the intersection of the line between the mapping point and the target pixel point and the projection cross section according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the mapping point includes:
[0111] The three-dimensional coordinates of the intersection point are calculated according to the three-dimensional coordinates of the target pixel point, the three-dimensional coordinates of the mapping point and the three-dimensional coordinates of the center point.
[0112] Optionally, Fig.12 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 6 ,like Fig.12 As shown, the process of calculating the three-dimensional coordinates of the intersection point according to the three-dimensional coordinates of the target pixel point, the three-dimensional coordinates of the mapping point and the three-dimensional coordinates of the center point may include:
[0113] S601, constructing a line equation according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the mapping point.
[0114] In some implementations, the line equation between the target pixel and the mapping point can be expressed as follows:
[0115] x=pos p .x+(pos Vp .x-pos p .x)t
[0116] y=pos p .y+(pos Vp .y-pos p .y)t
[0117] z=pos p .z+(pos Vp .z-pos p .z)t
[0118] Among them, Pos p Represents the three-dimensional coordinates of the target pixel point P, Pos Vp It represents the three-dimensional coordinates of the mapping point Vp, that is, the world position of the mapping point Vp, and t is the coefficient of the equation.
[0119] S602: construct a projection section equation according to the three-dimensional coordinates of the center point and the size of the sub-slice model.
[0120] In some embodiments, the projected cross section may be circular, and the projected cross section equation may be expressed as:
[0121] (x-pos o .x) 2 +(y-pos o .y) 2 +(z-pos o .z) 2 =(L / 2) 2
[0122] Among them, Pos o It represents the three-dimensional coordinates of the center point O, and L is the diameter when the sub-plug model is a circle.
[0123] S603, solving the connecting line equation and the projection section equation to obtain the three-dimensional coordinates of the intersection point.
[0124] It should be noted that the connection line equation and the projection section equation are solved to obtain the three-dimensional coordinates of the intersection of the line between the mapping point and the target pixel point and the outer contour of the projection section, that is, the three-dimensional coordinates of Vp.
[0125] Optionally, Fig.13 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 7 ,like Fig.13 As shown, according to the observation normal direction corresponding to the target pixel point, the rendering parameters of the target pixel point in the preset illumination direction are determined, including:
[0126] S701. Calculate the illumination intensity parameter of the target pixel point in a preset illumination direction according to the observation normal direction corresponding to the target pixel point.
[0127] In an embodiment of the present application, the direction vector pointing from the center point to the intersection is used to simulate the observed normal direction corresponding to the target pixel point. The direction vector calculated based on the center point pointing to the intersection is essentially the light intensity parameter of the intersection. The light intensity parameter of the intersection is used to simulate the light intensity parameter of the target pixel point, that is, the light intensity of the target pixel point is simulated by the light intensity of the intersection.
[0128] S702: Calculate rendering color parameters of the target pixel point in a preset lighting direction according to the basic rendering color and lighting intensity parameters of the target pixel point on the insert model.
[0129] The basic rendering color of the target pixel on the insert model refers to the original color of the target pixel on the insert model.
[0130] In some embodiments, the basic rendering color and the illumination intensity parameter of the target pixel on the insert model are multiplied to calculate the rendering color parameter of the target pixel in the preset illumination direction. In this way, the illumination intensity of different target pixels can be displayed according to the difference between the observation normal direction and the preset illumination direction corresponding to different target pixels, making the illumination rendering of the insert model more realistic.
[0131] Optionally, the process of calculating the illumination intensity parameter of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point in S702 may include:
[0132] The illumination intensity parameter of the target pixel is calculated according to the observed normal direction corresponding to the target pixel and the direction vector of the preset illumination direction.
[0133] In some embodiments, a mathematical dot multiplication function is used to perform dot multiplication on the observed normal direction corresponding to the target pixel and the direction vector of the preset lighting direction to obtain a first value after the dot multiplication; the maximum value between 0 and the first value after the dot multiplication is obtained, and the obtained maximum value is used as the illumination intensity parameter of the target pixel.
[0134] The above process can be expressed as: max(0,dot(n OT ,Light)), where max represents the function of finding the maximum value of two values, dot function represents the mathematical dot multiplication function, n OT It represents the vector in the OT direction, that is, the direction vector of the three-dimensional coordinates of the center point O pointing to the three-dimensional coordinates of the intersection point T, which replaces the observation normal direction corresponding to the target pixel point. Light represents the direction vector of the preset lighting direction.
[0135] Correspondingly, Color1=Color0*max(0,dot(n OT ,Light)), where Color1 represents the rendering color parameter of the target pixel in the preset lighting direction, and Color0 represents the basic rendering color of the target pixel on the insert model.
[0136] Optionally, Fig.14 A schematic diagram of a rendering method for a plug-in model provided in an embodiment of the present application Figure 8 ,like Fig.14 As shown, the process of determining the rendering parameters of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point in the above S702 may include:
[0137] S801, obtaining a direction vector of a preset sight line direction according to the three-dimensional coordinates of the intersection point and the three-dimensional coordinates of a preset sight line observation point;
[0138] In some implementations, the difference between the three-dimensional coordinates of the preset sight observation point and the three-dimensional coordinates of the intersection point is calculated to obtain the direction vector of the preset sight direction. This process can be expressed as:
[0139] view=pos cam -pos T
[0140] Among them, pos cam Represents the three-dimensional coordinates of the preset sight observation point, pos T Represents the three-dimensional coordinates of the intersection point, and view represents the direction vector of the preset sight direction, that is, the direction vector of the virtual camera viewing angle.
[0141] S802: Perform a normalization operation on the direction vector of the preset illumination direction and the direction vector of the preset sight line direction to obtain a normalized vector.
[0142] In the embodiment of the present application, the sum of the direction vector of the preset illumination direction and the direction vector of the preset sight line direction is calculated, and the sum is normalized to obtain a normalized vector. This process can be expressed as:
[0143] H = normalize (light + view)
[0144] Among them, light represents the direction vector of the preset lighting direction, view represents the direction vector of the preset sight direction, and H represents the normalized vector.
[0145] S803 , calculating the illumination intensity parameter of the target pixel point according to the normalized vector and the direction vector of the observation normal direction corresponding to the target pixel point.
[0146] In some embodiments, a mathematical dot multiplication function is used to perform dot multiplication on the normalized vector and the direction vector of the observation normal direction corresponding to the target pixel point to obtain a second value after the dot multiplication; the maximum value between 0 and the second value after the dot multiplication is obtained, and the obtained maximum value is used as the light intensity parameter of the target pixel point.
[0147] The above process can be expressed as: max(0,dot(n OT ,H), where max represents the function of finding the maximum value of two values, dot function represents the mathematical dot multiplication function, n OT It represents the vector in the OT direction, that is, the direction vector from the center point O to the intersection point T, which replaces the direction vector of the observation normal direction corresponding to the target pixel point. H represents the normalized vector.
[0148] Correspondingly, Color1=Color0*max(0,dot(n OT ,H), where Color1 represents the rendering color parameter of the target pixel point in the preset lighting direction, and Color0 represents the basic rendering color of the target pixel point on the insert model.
[0149] It should be noted that the embodiment of the present application provides two methods for calculating the illumination intensity parameters of the target pixel points, which makes the calculation of the illumination intensity parameters of the target pixel points more flexible.
[0150] In summary, the embodiment of the present application provides a rendering method for a patch model, which subdivides the patch model to obtain multiple sub-patch models, and simulates the observation normal direction corresponding to the target pixel based on the three-dimensional coordinates of the target pixel and the projection plane of the sub-patch model in the second direction, so that the observation normal directions corresponding to different target pixels on the same plane of the sub-patch model are different, and the rendering parameters are calculated based on the observation normal direction and lighting rendering is performed, which can show different performance effects of different target pixels on the same plane for different lighting, making the lighting rendering effect of the patch model more realistic. The problem of calculating normal lighting of the patch plane in the patch model is solved, and the problem of using other models to replace the patch model to achieve lighting rendering in the related art can also be avoided.
[0151] In addition, the rendering method of the insert model provided in the embodiment of the present application adds more realistic effects to the rendering performance of the insert model, replacing the viewing angle problem of a single facet, and this method can observe the insert model from any viewing angle. It also avoids the performance problem of using a complex model.
[0152] The following describes the insert model rendering device, equipment, storage medium, etc. used to execute the insert model rendering method provided in this application. Its specific implementation process and technical effects can be found in the relevant content of the above-mentioned insert model rendering method, which will not be repeated below.
[0153] Fig.15 A schematic diagram of a rendering device for a plug-in model provided in an embodiment of the present application is shown in FIG. Fig.15 As shown, the device comprises:
[0154] For example, the device may include:
[0155] A subdivision module 101, configured to subdivide the insert model in a second direction perpendicular to the first direction to obtain a plurality of sub-insert models;
[0156] An acquisition module 102 is used to acquire the three-dimensional coordinates of each target pixel point of the sub-slice model in a preset line of sight direction in a preset three-dimensional space;
[0157] A determination module 103 is used to determine the observation normal direction corresponding to the target pixel point in the preset sight line direction according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-slice model in the second direction; and to determine the rendering parameters of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point;
[0158] The lighting rendering module 104 is used to perform lighting rendering on the insert model according to the rendering parameters of the target pixel point to obtain a rendered insert model.
[0159] Optionally, the determination module 103 is specifically used to determine the three-dimensional coordinates of the center point of the projection section and the three-dimensional coordinates of the mapping point on the projection plane according to the three-dimensional coordinates of the target pixel point and the preset line of sight observation point in the preset line of sight direction; wherein the projection section is the section on the projection plane on the sub-insert model; according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the mapping point, calculate the three-dimensional coordinates of the intersection of the line between the mapping point and the target pixel point and the projection section; determine the observation normal direction according to the direction vector of the three-dimensional coordinates of the center point pointing to the three-dimensional coordinates of the intersection.
[0160] Optionally, the determination module 103 is specifically used to calculate the three-dimensional coordinates of the center point in the preset three-dimensional space based on the three-dimensional coordinates of the target pixel point; based on the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the center point, map the preset line of sight observation point to the projection plane to obtain the three-dimensional coordinates of the mapping point.
[0161] Optionally, the determination module 103 is specifically used to calculate the target value of the target pixel point in the first direction according to the three-dimensional coordinates of the target pixel point; and calculate the three-dimensional coordinates of the center point according to the target value, the size of the sub-plug model, the tangent of the target pixel point and the three-dimensional coordinates of the target pixel point.
[0162] Optionally, the determination module 103 is specifically used to construct the plane equation of the projection plane according to the three-dimensional coordinates of the target pixel point and the plane normal vector of the projection plane; construct the target equation according to the three-dimensional coordinates of the center point and the plane normal vector of the projection plane; solve the plane equation and the target equation to obtain the three-dimensional coordinates of the mapping point.
[0163] Optionally, the determination module 103 is specifically configured to calculate the three-dimensional coordinates of the intersection point according to the three-dimensional coordinates of the target pixel point, the three-dimensional coordinates of the mapping point and the three-dimensional coordinates of the center point.
[0164] Optionally, the determination module 103 is specifically used to construct a line equation according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the mapping point; construct a projection section equation according to the three-dimensional coordinates of the center point and the size of the sub-plug model; and solve the line equation and the projection section equation to obtain the three-dimensional coordinates of the intersection.
[0165] Optionally, the determination module 103 is specifically used to calculate the illumination intensity parameters of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point; and calculate the rendering color parameters of the target pixel point in the preset illumination direction according to the basic rendering color of the target pixel point on the insert model and the illumination intensity parameters.
[0166] Optionally, the determination module 103 is specifically configured to calculate the illumination intensity parameter of the target pixel point according to the observation normal direction corresponding to the target pixel point and the direction vector of the preset illumination direction.
[0167] Optionally, the determination module 103 is specifically used to obtain the direction vector of the preset line of sight direction based on the three-dimensional coordinates of the intersection point and the three-dimensional coordinates of the preset line of sight observation point; normalize the direction vector of the preset illumination direction and the direction vector of the preset line of sight direction to obtain a normalized vector; calculate the illumination intensity parameter of the target pixel point based on the normalized vector and the direction vector of the observation normal direction corresponding to the target pixel point.
[0168] The above-mentioned device is used to execute the method provided by the aforementioned embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0169] The above modules may be one or more integrated circuits configured to implement the above methods, such as one or more application specific integrated circuits (ASIC), or one or more digital singnal processors (DSP), or one or more field programmable gate arrays (FPGA). For another example, when a module is implemented in the form of a processing element scheduling program code, the processing element may be a general-purpose processor, such as a central processing unit (CPU) or other processor that can call program code. For another example, these modules may be integrated together and implemented in the form of a system-on-a-chip (SOC).
[0170] Fig.16 A schematic diagram of a rendering device for a plug-in model provided in an embodiment of the present application is shown in FIG. Fig.16 As shown, the device includes: a processor 201 and a memory 202.
[0171] The memory 202 is used to store programs, and the processor 201 calls the programs stored in the memory 202 to execute the above method embodiment. The specific implementation method and technical effect are similar and will not be repeated here.
[0172] For example, the method may include:
[0173] Subdividing the insert model in a second direction perpendicular to the first direction to obtain a plurality of sub-insert models;
[0174] Obtaining the three-dimensional coordinates of each target pixel point of the sub-slice model in a preset line of sight direction in a preset three-dimensional space;
[0175] Determine, according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-slice model in the second direction, the observation normal direction corresponding to the target pixel point in the preset line of sight direction;
[0176] Determining, according to the observation normal direction corresponding to the target pixel point, a rendering parameter of the target pixel point in a preset illumination direction;
[0177] According to the rendering parameters of the target pixel point, the insert model is subjected to lighting rendering to obtain a rendered insert model.
[0178] Optionally, determining the observation normal direction corresponding to the target pixel point in the preset sight line direction according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-slice model in the second direction includes:
[0179] According to the three-dimensional coordinates of the target pixel point and the preset sight observation point in the preset sight direction, the three-dimensional coordinates of the center point of the projection section and the three-dimensional coordinates of the mapping point are determined from the projection plane; wherein the projection section is a section on the projection plane on the sub-slice model;
[0180] Calculating the three-dimensional coordinates of the intersection of the line between the mapping point and the target pixel and the projection cross section according to the three-dimensional coordinates of the target pixel and the three-dimensional coordinates of the mapping point;
[0181] The observation normal direction is determined according to a direction vector pointing from the three-dimensional coordinates of the center point to the three-dimensional coordinates of the intersection point.
[0182] Optionally, determining the three-dimensional coordinates of the center point of the projection cross section and the three-dimensional coordinates of the mapping point from the projection plane according to the three-dimensional coordinates of the target pixel point and the preset sight line observation point in the preset sight line direction includes:
[0183] Calculating the three-dimensional coordinates of the center point in the preset three-dimensional space according to the three-dimensional coordinates of the target pixel point;
[0184] According to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the center point, the preset line of sight observation point is mapped onto the projection plane to obtain the three-dimensional coordinates of the mapping point.
[0185] Optionally, calculating the three-dimensional coordinates of the center point of the projection plane in the preset three-dimensional space according to the three-dimensional coordinates of the target pixel point includes:
[0186] Calculating a target value of the target pixel point in the first direction according to the three-dimensional coordinates of the target pixel point;
[0187] The three-dimensional coordinates of the center point are calculated according to the target value, the size of the sub-slice model, the tangent line of the target pixel point and the three-dimensional coordinates of the target pixel point.
[0188] Optionally, mapping the preset sight line observation point onto the projection plane according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the center point to obtain the three-dimensional coordinates of the mapping point includes:
[0189] Constructing a plane equation of the projection plane according to the three-dimensional coordinates of the target pixel point and the plane normal vector of the projection plane;
[0190] Constructing a target equation according to the three-dimensional coordinates of the center point and the plane normal vector of the projection plane;
[0191] The plane equation and the target equation are solved to obtain the three-dimensional coordinates of the mapping point.
[0192] Optionally, calculating the three-dimensional coordinates of the intersection of the line between the mapping point and the target pixel point and the projection cross section according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the mapping point includes:
[0193] The three-dimensional coordinates of the intersection point are calculated according to the three-dimensional coordinates of the target pixel point, the three-dimensional coordinates of the mapping point and the three-dimensional coordinates of the center point.
[0194] Optionally, calculating the three-dimensional coordinates of the intersection point according to the three-dimensional coordinates of the target pixel point, the three-dimensional coordinates of the mapping point and the three-dimensional coordinates of the center point includes:
[0195] Constructing a connection equation according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the mapping point;
[0196] Constructing a projection section equation according to the three-dimensional coordinates of the center point and the size of the sub-slice model;
[0197] Solve the connecting line equation and the projection section equation to obtain the three-dimensional coordinates of the intersection point.
[0198] Optionally, determining the rendering parameters of the target pixel point in a preset illumination direction according to the observation normal direction corresponding to the target pixel point includes:
[0199] Calculate the illumination intensity parameter of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point;
[0200] The rendering color parameter of the target pixel point in the preset lighting direction is calculated according to the basic rendering color of the target pixel point on the insert model and the lighting intensity parameter.
[0201] Optionally, calculating the illumination intensity parameter of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point includes:
[0202] The illumination intensity parameter of the target pixel point is calculated according to the observation normal direction corresponding to the target pixel point and the direction vector of the preset illumination direction.
[0203] Optionally, determining the rendering parameters of the target pixel point in a preset illumination direction according to the observation normal direction corresponding to the target pixel point includes:
[0204] Obtaining a direction vector of the preset line of sight direction according to the three-dimensional coordinates of the intersection point and the three-dimensional coordinates of the preset line of sight observation point;
[0205] Normalizing the direction vector of the preset illumination direction and the direction vector of the preset sight line direction to obtain a normalized vector;
[0206] The illumination intensity parameter of the target pixel is calculated according to the normalized vector and the direction vector of the observation normal direction corresponding to the target pixel.
[0207] In summary, an embodiment of the present application provides a rendering method for a patch model, which subdivides the patch model to obtain multiple sub-patch models, and simulates the observation normal direction corresponding to the target pixel point based on the three-dimensional coordinates of the target pixel point and the projection plane of the sub-patch model in the second direction, so that the observation normal directions corresponding to different target pixels on the same plane of the sub-patch model are different, and the rendering parameters are calculated based on the observation normal direction and lighting rendering is performed, which can show different performance effects of different target pixels on the same plane under different lighting, making the lighting rendering effect of the patch model more realistic.
[0208] Optionally, the present application also provides a program product, such as a computer-readable storage medium, including a program, which is used to execute the above method embodiment when executed by a processor.
[0209] For example, the method may include:
[0210] Subdividing the insert model in a second direction perpendicular to the first direction to obtain a plurality of sub-insert models;
[0211] Obtaining the three-dimensional coordinates of each target pixel point of the sub-slice model in a preset line of sight direction in a preset three-dimensional space;
[0212] Determine, according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-slice model in the second direction, the observation normal direction corresponding to the target pixel point in the preset line of sight direction;
[0213] Determining, according to the observation normal direction corresponding to the target pixel point, a rendering parameter of the target pixel point in a preset illumination direction;
[0214] According to the rendering parameters of the target pixel point, the insert model is subjected to lighting rendering to obtain a rendered insert model.
[0215] Optionally, determining the observation normal direction corresponding to the target pixel point in the preset sight line direction according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-slice model in the second direction includes:
[0216] According to the three-dimensional coordinates of the target pixel point and the preset sight observation point in the preset sight direction, the three-dimensional coordinates of the center point of the projection section and the three-dimensional coordinates of the mapping point are determined from the projection plane; wherein the projection section is a section on the projection plane on the sub-slice model;
[0217] Calculating the three-dimensional coordinates of the intersection of the line between the mapping point and the target pixel and the projection cross section according to the three-dimensional coordinates of the target pixel and the three-dimensional coordinates of the mapping point;
[0218] The observation normal direction is determined according to a direction vector pointing from the three-dimensional coordinates of the center point to the three-dimensional coordinates of the intersection point.
[0219] Optionally, determining the three-dimensional coordinates of the center point of the projection cross section and the three-dimensional coordinates of the mapping point from the projection plane according to the three-dimensional coordinates of the target pixel point and the preset sight line observation point in the preset sight line direction includes:
[0220] Calculating the three-dimensional coordinates of the center point in the preset three-dimensional space according to the three-dimensional coordinates of the target pixel point;
[0221] According to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the center point, the preset sight observation point is mapped onto the projection plane to obtain the three-dimensional coordinates of the mapping point.
[0222] Optionally, calculating the three-dimensional coordinates of the center point of the projection plane in the preset three-dimensional space according to the three-dimensional coordinates of the target pixel point includes:
[0223] Calculating a target value of the target pixel point in the first direction according to the three-dimensional coordinates of the target pixel point;
[0224] The three-dimensional coordinates of the center point are calculated according to the target value, the size of the sub-slice model, the tangent line of the target pixel point and the three-dimensional coordinates of the target pixel point.
[0225] Optionally, mapping the preset sight line observation point onto the projection plane according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the center point to obtain the three-dimensional coordinates of the mapping point includes:
[0226] Constructing a plane equation of the projection plane according to the three-dimensional coordinates of the target pixel point and the plane normal vector of the projection plane;
[0227] Constructing a target equation according to the three-dimensional coordinates of the center point and the plane normal vector of the projection plane;
[0228] The plane equation and the target equation are solved to obtain the three-dimensional coordinates of the mapping point.
[0229] Optionally, calculating the three-dimensional coordinates of the intersection of the line between the mapping point and the target pixel point and the projection cross section according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the mapping point includes:
[0230] The three-dimensional coordinates of the intersection point are calculated according to the three-dimensional coordinates of the target pixel point, the three-dimensional coordinates of the mapping point and the three-dimensional coordinates of the center point.
[0231] Optionally, calculating the three-dimensional coordinates of the intersection point according to the three-dimensional coordinates of the target pixel point, the three-dimensional coordinates of the mapping point and the three-dimensional coordinates of the center point includes:
[0232] Constructing a connection equation according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the mapping point;
[0233] Constructing a projection section equation according to the three-dimensional coordinates of the center point and the size of the sub-slice model;
[0234] Solve the connecting line equation and the projection section equation to obtain the three-dimensional coordinates of the intersection point.
[0235] Optionally, determining the rendering parameters of the target pixel point in a preset illumination direction according to the observation normal direction corresponding to the target pixel point includes:
[0236] Calculate the illumination intensity parameter of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point;
[0237] The rendering color parameter of the target pixel point in the preset lighting direction is calculated according to the basic rendering color of the target pixel point on the insert model and the lighting intensity parameter.
[0238] Optionally, calculating the illumination intensity parameter of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point includes:
[0239] The illumination intensity parameter of the target pixel point is calculated according to the observation normal direction corresponding to the target pixel point and the direction vector of the preset illumination direction.
[0240] Optionally, determining the rendering parameters of the target pixel point in a preset illumination direction according to the observation normal direction corresponding to the target pixel point includes:
[0241] Obtaining a direction vector of the preset line of sight direction according to the three-dimensional coordinates of the intersection point and the three-dimensional coordinates of the preset line of sight observation point;
[0242] Normalizing the direction vector of the preset illumination direction and the direction vector of the preset sight line direction to obtain a normalized vector;
[0243] The illumination intensity parameter of the target pixel is calculated according to the normalized vector and the direction vector of the observation normal direction corresponding to the target pixel.
[0244] In summary, an embodiment of the present application provides a rendering method for a patch model, which subdivides the patch model to obtain multiple sub-patch models, and simulates the observation normal direction corresponding to the target pixel point based on the three-dimensional coordinates of the target pixel point and the projection plane of the sub-patch model in the second direction, so that the observation normal directions corresponding to different target pixels on the same plane of the sub-patch model are different, and the rendering parameters are calculated based on the observation normal direction and lighting rendering is performed, which can show different performance effects of different target pixels on the same plane under different lighting, making the lighting rendering effect of the patch model more realistic.
[0245] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0246] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0247] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional units.
[0248] The above-mentioned integrated unit implemented in the form of a software functional unit can be stored in a computer-readable storage medium. The above-mentioned software functional unit is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor (English: processor) to perform some steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (English: Read-Only Memory, abbreviated: ROM), random access memory (English: Random Access Memory, abbreviated: RAM), disk or optical disk and other media that can store program codes.
[0249] The above are only preferred embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A method for rendering an insert model, characterized in that: The insert model includes a plurality of basic face patches, wherein each of the basic face patches has the same size at least in a first direction, and the plurality of basic face patches intersect each other through center positions in the first direction to form the insert model, and the method includes: Subdividing the insert model in a second direction perpendicular to the first direction to obtain a plurality of sub-insert models; Obtaining the three-dimensional coordinates of each target pixel point of the sub-slice model in a preset line of sight direction in a preset three-dimensional space; Determine, according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-slice model in the second direction, the observation normal direction corresponding to the target pixel point in the preset line of sight direction; Determining, according to the observation normal direction corresponding to the target pixel point, a rendering parameter of the target pixel point in a preset illumination direction; According to the rendering parameters of the target pixel point, the insert model is subjected to lighting rendering to obtain a rendered insert model.
2. The method according to claim 1, characterized in that The determining, according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-slice model in the second direction, the observation normal direction corresponding to the target pixel point in the preset sight line direction includes: According to the three-dimensional coordinates of the target pixel point and the preset sight observation point in the preset sight direction, the three-dimensional coordinates of the center point of the projection section and the three-dimensional coordinates of the mapping point are determined from the projection plane; wherein the projection section is a section on the projection plane on the sub-slice model; Calculating the three-dimensional coordinates of the intersection of the line between the mapping point and the target pixel and the projection cross section according to the three-dimensional coordinates of the target pixel and the three-dimensional coordinates of the mapping point; The observation normal direction is determined according to a direction vector pointing from the three-dimensional coordinates of the center point to the three-dimensional coordinates of the intersection point.
3. The method according to claim 2, characterized in that The step of determining the three-dimensional coordinates of the center point of the projection cross section and the three-dimensional coordinates of the mapping point on the projection plane according to the three-dimensional coordinates of the target pixel point and the preset sight line observation point in the preset sight line direction comprises: Calculating the three-dimensional coordinates of the center point in the preset three-dimensional space according to the three-dimensional coordinates of the target pixel point; According to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the center point, the preset sight observation point is mapped onto the projection plane to obtain the three-dimensional coordinates of the mapping point.
4. The method according to claim 3, characterized in that The step of calculating the three-dimensional coordinates of the center point of the projection plane in the preset three-dimensional space according to the three-dimensional coordinates of the target pixel point includes: Calculating a target value of the target pixel point in the first direction according to the three-dimensional coordinates of the target pixel point; The three-dimensional coordinates of the center point are calculated according to the target value, the size of the sub-slice model, the tangent line of the target pixel point and the three-dimensional coordinates of the target pixel point.
5. The method according to claim 3, characterized in that: The step of mapping the preset sight line observation point onto the projection plane according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the center point to obtain the three-dimensional coordinates of the mapping point includes: Constructing a plane equation of the projection plane according to the three-dimensional coordinates of the target pixel point and the plane normal vector of the projection plane; Constructing a target equation according to the three-dimensional coordinates of the center point and the plane normal vector of the projection plane; The plane equation and the target equation are solved to obtain the three-dimensional coordinates of the mapping point.
6. The method according to claim 2, characterized in that The calculating, according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the mapping point, the three-dimensional coordinates of the intersection of the line between the mapping point and the target pixel point and the projection cross section comprises: The three-dimensional coordinates of the intersection point are calculated according to the three-dimensional coordinates of the target pixel point, the three-dimensional coordinates of the mapping point and the three-dimensional coordinates of the center point.
7. The method according to claim 6, characterized in that The calculating the three-dimensional coordinates of the intersection point according to the three-dimensional coordinates of the target pixel point, the three-dimensional coordinates of the mapping point and the three-dimensional coordinates of the center point comprises: Constructing a connection equation according to the three-dimensional coordinates of the target pixel point and the three-dimensional coordinates of the mapping point; Constructing a projection section equation according to the three-dimensional coordinates of the center point and the size of the sub-slice model; Solve the connecting line equation and the projection section equation to obtain the three-dimensional coordinates of the intersection point.
8. The method according to claim 2, characterized in that: The step of determining the rendering parameters of the target pixel point in a preset illumination direction according to the observation normal direction corresponding to the target pixel point includes: Calculate the illumination intensity parameter of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point; The rendering color parameter of the target pixel point in the preset lighting direction is calculated according to the basic rendering color of the target pixel point on the insert model and the lighting intensity parameter.
9. The method according to claim 8, characterized in that Calculating the illumination intensity parameter of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point includes: The illumination intensity parameter of the target pixel point is calculated according to the observation normal direction corresponding to the target pixel point and the direction vector of the preset illumination direction.
10. The method according to claim 8, characterized in that The step of determining the rendering parameters of the target pixel point in a preset illumination direction according to the observation normal direction corresponding to the target pixel point includes: Obtaining a direction vector of the preset line of sight direction according to the three-dimensional coordinates of the intersection point and the three-dimensional coordinates of the preset line of sight observation point; Normalizing the direction vector of the preset illumination direction and the direction vector of the preset sight line direction to obtain a normalized vector; The illumination intensity parameter of the target pixel is calculated according to the normalized vector and the direction vector of the observation normal direction corresponding to the target pixel.
11. A rendering device for an insert model, characterized in that: The insert model includes a plurality of basic face patches, wherein each basic face patch has the same size at least in a first direction, and the plurality of basic face patches intersect each other through the center position in the first direction to form the insert model, and the device includes: A subdivision module, used to subdivide the insert model in a preset extension direction in a second direction perpendicular to the first direction to obtain a plurality of sub-insert models; An acquisition module, used for acquiring the three-dimensional coordinates of each target pixel point of the sub-slice model in a preset line of sight direction in a preset three-dimensional space; A determination module, used to determine the observation normal direction corresponding to the target pixel point in the preset sight line direction according to the three-dimensional coordinates of the target pixel point and the projection plane of the sub-slice model in the second direction; and determine the rendering parameters of the target pixel point in the preset illumination direction according to the observation normal direction corresponding to the target pixel point; The lighting rendering module is used to perform lighting rendering on the insert model according to the rendering parameters of the target pixel point to obtain a rendered insert model.
12. A rendering device for an insert model, characterized in that: include: A memory and a processor, wherein the memory stores a computer program executable by the processor, and when the processor executes the computer program, the method for rendering the insert model described in any one of claims 1 to 10 is implemented.
13. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is read and executed, the method for rendering the insert model described in any one of claims 1 to 10 is implemented.