Method and device for determining model normal, electronic equipment and storage medium
By obtaining the model vertex color mask information map and using partial derivative functions and matrix transformations, the normals at the intersection of mixed materials are accurately determined, which solves the problem of missing normal information during the rendering process and improves the reusability and controllability of the model.
Patent Information
- Application Number
- CN202111596051.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2041-12-24
AI Technical Summary
During the rendering process, the normal information at the junction of two materials cannot be obtained from the model information. The existing method affects the reusability and controllability of the model.
By obtaining the vertex color mask information map of the model, the partial derivative function is used to determine the coordinates of the normal of the target pixel point in the tangent space. Combined with the preset matrix transformation and attenuation coefficient adjustment, the normal at the intersection of the mixed materials is accurately determined.
The accuracy of model normal determination at the intersection of mixed materials is improved, which increases the reusability and controllability of the model and reduces GPU consumption and art production process.
Smart Images

Figure CN114529659B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of normal simulation technology, and in particular to a method, device, electronic device, and storage medium for determining a model normal. Background Art
[0002] This section is intended to provide a background or context to the embodiments of the application that are recited in the claims. No statement herein is admitted to be prior art by virtue of its inclusion in this section.
[0003] Normals are an essential piece of model information in modern rendering technology. However, during the rendering process, it's impossible to obtain normal information at the interface between two materials (textures) from the model itself. This information is often applied to mixed materials, such as mud and snow, which have distinctly uneven edges in real life. If dynamic rendering is abandoned to achieve distinction between the two material edges, and the mixed material information is instead hard-coded into the model's texture during modeling, the model's reusability and controllability will be reduced. Therefore, a method is needed to simulate normal information at the interface between mixed materials. Summary of the Invention
[0004] In view of the above technical problems, an improved method is urgently needed to determine the normal information of a model with mixed materials.
[0005] An exemplary embodiment of the present application provides a method for determining a model normal, comprising:
[0006] Get the vertex color mask information map of the model with mixed materials to be rendered;
[0007] Determining a target pixel from a plurality of pixel points of the vertex color mask information graph, determining a first pixel difference between the target pixel and an adjacent pixel point along a first direction using a partial derivative function, and determining a second pixel difference between the target pixel and an adjacent pixel point along a second direction using the partial derivative function, wherein the first direction is perpendicular to the second direction;
[0008] Determine a first coordinate of the normal of the target pixel point in the tangent space based on the first pixel difference and the second pixel difference;
[0009] A normal of the target pixel point is determined based on the target pixel point and the first coordinate.
[0010] In some exemplary embodiments, determining a first coordinate of a normal line of the target pixel point in a tangent space based on the first pixel difference value and the second pixel difference value specifically includes:
[0011] A second coordinate of the normal of the target pixel point in the screen space is determined based on the first pixel difference value and the second pixel difference value, and the second coordinate is converted into the first coordinate.
[0012] In some exemplary embodiments, converting the second coordinate into the first coordinate specifically includes:
[0013] Converting the second coordinate into a third coordinate of the normal of the target pixel point in the world space through a first preset matrix;
[0014] The third coordinate is converted into the first coordinate through a second preset matrix.
[0015] In some exemplary embodiments, converting the second coordinate into the first coordinate specifically includes:
[0016] Converting the second coordinate into a third coordinate of the normal of the target pixel point in the world space through a first preset matrix;
[0017] The third coordinate is converted into the first coordinate by the following formula;
[0018]
[0019] l=uu′;
[0020] Among them, u represents the vector corresponding to the third coordinate, v represents the normal vector of the model, u′ represents the projection of the vector corresponding to the third coordinate on the normal vector of the model, and l represents the vector corresponding to the first coordinate.
[0021] In some exemplary embodiments, after determining the first coordinate of the target pixel point in the tangent space based on the first pixel difference value and the second pixel difference value, the method further includes:
[0022] Obtaining the distance between the target pixel and the virtual camera;
[0023] In response to determining that the distance is greater than a preset threshold, a first attenuation coefficient of the normal of the target pixel is determined based on the distance, and the first coordinate is adjusted based on the first attenuation coefficient.
[0024] In some exemplary embodiments, after determining the first coordinate of the target pixel point in the tangent space based on the first pixel difference value and the second pixel difference value, the method further includes:
[0025] Obtaining the sight line of the target pixel in screen space;
[0026] Determining a normal of the target pixel based on the first coordinate, and determining an angle between the normal of the target pixel and the line of sight;
[0027] In response to determining that the absolute value of the difference between the included angle and the right angle is less than a preset angle, a second attenuation coefficient of the normal of the target pixel point is determined based on the included angle, and the first coordinate is adjusted based on the second attenuation coefficient.
[0028] In some exemplary embodiments, after obtaining a vertex color mask information map of a model with a mixed material to be rendered, the method further includes:
[0029] Adjusting the vertex color mask information graph in the model based on a preset gradient formula;
[0030] Wherein, the preset gradient formula is:
[0031] P = (1-x)*N*x*C+x;
[0032] Among them, P represents the vertex color of the adjusted vertex color mask information map, x represents the vertex color of the vertex color mask information map, N represents the vertex color of the preset noise map, and C represents the accuracy of the preset noise map.
[0033] In some exemplary embodiments, determining a target pixel from a plurality of pixels in the vertex color mask information map specifically includes:
[0034] In response to a third pixel difference between any pixel among the multiple pixels of the vertex color mask information graph and its adjacent pixel being greater than a preset threshold, the pixel is determined as a target pixel.
[0035] In some exemplary embodiments, the partial derivative function is: ddx / ddy or dFdx / dFdy.
[0036] Based on the same inventive concept, the exemplary embodiment of the present application further provides a device for determining a model normal, comprising:
[0037] Get the model block and obtain the vertex color mask information map of the model with mixed materials to be rendered;
[0038] a first determining module, which determines a target pixel from a plurality of pixels of the vertex color mask information graph, determines a first pixel difference between the target pixel and its adjacent pixels along a first direction using a partial derivative function, and determines a second pixel difference between the target pixel and its adjacent pixels along a second direction using the partial derivative function, wherein the first direction is perpendicular to the second direction;
[0039] a second determining module, determining a first coordinate of the normal of the target pixel point in a tangent space based on the first pixel difference and the second pixel difference;
[0040] A third determining module determines a normal of the target pixel point based on the target pixel point and the first coordinate.
[0041] Based on the same inventive concept, an exemplary embodiment of the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and runnable on the processor, wherein when the processor executes the program, the method for determining the model normal as described in any one of the above items is implemented.
[0042] Based on the same inventive concept, an exemplary embodiment of the present application further provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute any of the above methods for determining a model normal.
[0043] From the above, it can be seen that the method for determining the model normal provided in the embodiment of the present application first obtains the vertex color mask information map of the model with mixed materials to be rendered, determines the target pixel point from multiple pixel points of the vertex color mask information map, and determines the first pixel difference between the target pixel point and its adjacent pixel point along the first direction through the partial derivative function, and determines the second pixel difference between the target pixel point and its adjacent pixel point along the second direction through the partial derivative function, wherein the first direction is perpendicular to the second direction; determines the first coordinate of the normal of the target pixel point in the tangent space based on the first pixel difference and the second pixel difference; determines the normal of the target pixel point based on the target pixel point and the first coordinate, thereby providing a simple and effective method for determining the normal of multiple materials at the intersection of the model, thereby increasing the reusability and controllability of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the present disclosure or related technologies, the following briefly introduces the drawings required for use in the embodiments or related technical descriptions. Obviously, the drawings described below are only embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0045] Figure 1 This is a flow chart of a method for determining a model normal in an exemplary embodiment of the present application;
[0046] Figure 2 A schematic diagram of a vertex color mask information graph of a model with mixed materials in an exemplary embodiment of the present application;
[0047] Figure 3 This is a schematic diagram of a vertex color mask information graph of a local mixed material of a model in an exemplary embodiment of the present application;
[0048] Figure 4 is a schematic diagram of a noise map in an exemplary embodiment of the present application;
[0049] Figure 5 is a schematic diagram of another noise map in an exemplary embodiment of the present application;
[0050] Figure 6 This is a schematic diagram of a vertex color mask information graph of a local mixed material of a model in an exemplary embodiment of the present application;
[0051] Figure 7 This is a schematic diagram of a vertex color mask information graph at the intersection of mixed materials in another local model in an exemplary embodiment of the present application;
[0052] Figure 8 This is a schematic diagram of a normal vector relationship in an exemplary embodiment of the present application;
[0053] Figure 9 This is a schematic diagram comparing model rendering effects in an exemplary embodiment of the present application;
[0054] Figure 10 Schematic diagram of the structure of a device for determining a model normal in an exemplary embodiment of the present application;
[0055] Figure 11 This is a schematic structural diagram of a specific electronic device in an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0056] The principles and spirit of the present application will be described below with reference to several exemplary embodiments. It should be understood that these embodiments are provided solely to enable those skilled in the art to better understand and implement the present application, and are not intended to limit the scope of the present application in any way. Rather, these embodiments are provided to make the present application more thorough and complete, and to fully convey the scope of the present application to those skilled in the art.
[0057] According to the embodiments of the present application, a method, device, electronic device, and storage medium for determining a model normal are proposed.
[0058] It should be understood herein that any number of elements in the drawings is for illustration only and not for limitation, and any naming is only for distinction and does not have any limiting meaning.
[0059] The principles and spirit of the present application are explained in detail below with reference to several representative implementations of the present application. SUMMARY OF THE INVENTION
[0061] In the existing technology, it is impossible to obtain the normal information of the intersection of two materials (textures) from the model information during the rendering process. If you want to show the normal information at the intersection of two mixed materials, the first approach is to use vertex offset to offset the vertices of the target area in the direction, so as to achieve the concave and convex feeling at the intersection. The second solution is to draw the texture directly onto the model in the model making software during the model making process. Apply the material map you want to mix directly to the map of the model itself, and include it when baking the model normal information.
[0062] The first approach won't work well when the model has a low face count. When offsetting vertices at a low face count, the offset area will be very limited. For example, when drawing a moss texture on a rock, the model doesn't need many vertices to show the details of the rock. However, the moss can only be drawn based on the position of the vertices, and the moss can only cling to the entire surface of the model, which will look very unnatural at a low face count. If you need to apply tessellation to increase the number of vertices and thus increase the details, the face count will increase, which will increase GPU consumption.
[0063] While the second approach does provide a more accurate interpretation of the model's normal information, its limitations are also significant. It lacks versatility, as the model can only have one type of texture, and the texture's location is fixed. Reproducing different textures requires re-baking, which increases the number of textures, the art production process, and the package size. Furthermore, the texture accuracy of mixed materials may not be ideal. Typically, texture information requires higher precision to convey the texture's surface texture. Using this method, texture accuracy is limited to the model's own texture accuracy.
[0064] In order to solve the above problems, this application provides a method for determining a model normal, which specifically includes:
[0065] Obtain a vertex color mask information graph of a model with mixed materials to be rendered; determine a target pixel point from multiple pixel points of the vertex color mask information graph, determine a first pixel difference between the target pixel point and its adjacent pixel points along a first direction through a partial derivative function, and determine a second pixel difference between the target pixel point and its adjacent pixel points along a second direction through the partial derivative function, wherein the first direction is perpendicular to the second direction; determine a first coordinate of the normal of the target pixel point in the tangent space based on the first pixel difference and the second pixel difference; determine the normal of the target pixel point based on the target pixel point and the first coordinate, thereby providing a simple and effective method for determining the normal at the intersection of multiple materials of a model, thereby increasing the reusability and controllability of the model.
[0066] After introducing the basic principles of the present application, various non-limiting implementation methods of the present application are described in detail below.
[0067] Application Scenario Overview
[0068] In some specific application scenarios, the method for determining the model normal of the present application can be directly applied to software systems involved in model production. Optionally, the method for determining the model normal of the present application can be implemented using the Unity engine and its Shader language.
[0069] In some specific application scenarios, the model normal determination method of the present application can be directly applied and run locally, or it can be run on a cloud server. When running on a cloud server, the acquired data to be processed is sent to the cloud server via the network. The server processes the data to be processed using the model normal determination method of the present application and sends the processing results to the local computer via the network.
[0070] The following describes a method for determining a model normal according to an exemplary embodiment of the present application in conjunction with a specific application scenario. It should be noted that the above application scenario is only provided to facilitate understanding of the spirit and principles of the present application, and the embodiments of the present application are not limited in this respect. On the contrary, the embodiments of the present application can be applied to any applicable scenario.
[0071] Exemplary Methods
[0072] refer to Figure 1 , an embodiment of the present application provides a method for determining a model normal, comprising the following steps:
[0073] S101, obtaining a vertex color mask information graph of a model with mixed materials to be rendered.
[0074] In specific implementation, a hybrid material is a material that mixes two or more materials together on the same model through mask information. Mask information allows the same model to show two or more surface textures (materials). If you want the model to show a hybrid material, you usually draw the vertex color of the model to dynamically generate a vertex color mask information map of the model in the engine. The vertex color mask information map is used to determine which areas of the hybrid material displayed by the current model correspond to which material. For example Figure 2 , shows a vertex color mask information graph of an excavator, where the white parts of the excavator represent one material (cement) and the black parts represent another material (metal). Before determining the normals at the intersection of the model's mixed materials, it is necessary to first obtain the vertex color mask information graph of the model with the mixed materials to be rendered.
[0075] In some example embodiments, after obtaining the vertex color shader information map of the model with mixed materials to be rendered, the method further comprises:
[0076] adjusting the vertex color shader information map in the model with mixed materials based on a preset gradient formula;
[0077] wherein the preset gradient formula is:
[0078] P = (1 - x) * N * x * C + x;
[0079] wherein P represents the vertex color of the adjusted vertex color shader information map, x represents the vertex color of the vertex color shader information map, N represents the vertex color of the preset noise map, and C represents the accuracy of the preset noise map.
[0080] In a specific implementation, an image processing system, such as a GPU, generally performs linear interpolation on all vertex-to-vertex information. Therefore, at the junction of the two materials in the vertex color shader information map of the model with mixed materials, a smooth gradient process of the two materials is shown. Referring to Figure 3 wherein the white rectangular frame includes both black and white materials, and the color transition at the junction of the two materials is linear and smooth. However, such a smooth color transition does not conform to the display. For example, a metal excavator is used to mix cement, and part of the cement will be attached to the excavator, thereby forming a mixed material of cement and metal on the surface of the excavator. However, it is generally impossible for the junction of the cement and the metal to be such a very regular transition. At this time, in order to make the model closer to reality, it is necessary to show more details of the mixed material at the junction, thereby further improving the accuracy of subsequent determination of the normal. Therefore, after obtaining the vertex color shader information map, the present application adjusts the vertex color shader information map in the model with mixed materials through a preset gradient formula, wherein N in the preset gradient formula represents the vertex color of the preset noise map, which can be selected as needed and is not limited herein. Referring to Figure 4 which is a noise map. It should be noted that the black and white pixels in the noise map are randomly distributed. Such random distribution can add more details to the junction of the two materials, thereby making the finally generated effect picture more realistic. C represents the accuracy of the preset noise map, which can adjust the density of the white pixel points in the noise map. Referring to Figure 5 which is another noise map. Since Figure 5 the accuracy of Figure 4 is greater than the accuracy of Figure 5 , in , the white pixel points are more densely distributed.
[0081] The (1-x)*N*x*C in the above preset gradient formula means adjusting the pixel distribution at the intersection of the two materials in the original vertex color mask information map through the noise map. Figure 6 , is the adjustment result corresponding to this part. After completing the pixel distribution adjustment at the intersection of the two materials, the adjusted part is merged with the original vertex color mask information map to obtain the adjusted vertex color mask information map (P). Figure 7 , is a schematic diagram of the adjusted vertex color mask information graph, it can be seen Figure 7 and Figure 3 Compared to the original, it is obvious that more details are added at the intersection of the two materials, and the normal determined by the adjusted vertex color mask information map is more accurate.
[0082] In some embodiments, the preset gradient formula may also be:
[0083] P=saturate((1-x)*N*x*C+x);
[0084] Wherein, P represents the vertex color of the adjusted vertex color mask information graph, x represents the vertex color of the vertex color mask information graph, N represents the vertex color of the preset noise map, and C represents the precision of the preset noise map. saturate represents a normalization function used to adjust the range of the input value to the range of 0-1. Since the range of vertex colors in the vertex color mask information graph is between 0 and 1, in order to avoid the value calculated by (1-x)*N*x*C+x being greater than 1 or less than 0, it is adjusted to the range of 0-1 through the saturate function.
[0085] S102, determining a target pixel point from a plurality of pixel points of the vertex color mask information graph, determining a first pixel difference between the target pixel point and its adjacent pixel points along a first direction through a partial derivative function, and determining a second pixel difference between the target pixel point and its adjacent pixel points along a second direction through the partial derivative function, wherein the first direction is perpendicular to the second direction.
[0086] During specific implementation, the target pixel point can be each pixel point of the vertex color mask information graph, or some pixel points of the vertex color mask information graph can be selected as target pixel points as needed, which is not limited here. For the target pixel point of the vertex color mask information graph, the first pixel difference between the target pixel point and its adjacent pixel point is first determined along the first direction by the partial derivative function, and then the second pixel difference between the target pixel point and its adjacent pixel point is determined along the second direction by the partial derivative function. The partial derivative function can be selected as needed. Optionally, the partial derivative function can be ddx / ddy or dfdx / dfdy, which is not limited here. The partial derivative function is used to determine the pixel difference between two adjacent pixel points in the vertex color mask information graph. Optionally, the first direction represents the direction of the x-axis in the screen space, and the second direction represents the direction of the y-axis in the screen space.
[0087] In some embodiments, determining a target pixel from a plurality of pixels in the vertex color mask information map specifically includes:
[0088] In response to a third pixel difference between any pixel among the multiple pixels of the vertex color mask information graph and its adjacent pixel being greater than a preset threshold, the pixel is determined as a target pixel.
[0089] In a specific implementation, since the pixel differences between the pixels in the area where the mixed materials meet are generally large in the vertex color mask information map, and the differences between the pixels distributed in the same material are very small, or even 0, and this application wants to determine the normals at the junction of the mixed materials, a preset threshold is first used to filter out the target pixels at the junction of the mixed materials, and then only the normals of these target pixels are determined, thereby improving the efficiency of determining the normals. The preset threshold can be set as needed, and the specific value is not limited. Optionally, the preset threshold can be set to 0.
[0090] S103: Determine a first coordinate of the normal of the target pixel point in a tangent space based on the first pixel difference and the second pixel difference.
[0091] In some exemplary embodiments, determining a first coordinate of a normal line of the target pixel point in a tangent space based on the first pixel difference value and the second pixel difference value specifically includes:
[0092] A second coordinate of the normal of the target pixel point in the screen space is determined based on the first pixel difference value and the second pixel difference value, and the second coordinate is converted into the first coordinate.
[0093] After obtaining the first pixel difference and the second pixel difference, you can directly use the first pixel difference as the x-axis coordinate of the pixel point, use the second pixel difference as the y-axis coordinate of the pixel point, and set the z-axis coordinate of the pixel point to 0, so that you can directly obtain the second coordinate of the target pixel point in the screen space. Since the coordinates of the screen space cannot be used directly, because the screen space is referenced to the camera coordinate system and will change according to the position of the virtual camera, it needs to be converted to the tangent space to be used normally. Therefore, after obtaining the second coordinate of the target pixel point in the screen space, it is necessary to convert the second coordinate into the first coordinate of the target pixel point in the tangent space.
[0094] In some exemplary embodiments, converting the second coordinate into the first coordinate specifically includes:
[0095] Converting the second coordinate into a third coordinate of the normal of the target pixel point in the world space through a first preset matrix;
[0096] The third coordinate is converted into the first coordinate through a second preset matrix.
[0097] In a specific implementation, the second coordinate is first multiplied by the first preset matrix to obtain the third coordinate of the pixel point in world space, and then the third coordinate is multiplied by the second preset matrix to obtain the first coordinate. Alternatively, the first preset matrix and the second preset matrix may be multiplied to obtain a merged matrix, and then the merged matrix may be directly multiplied by the second coordinate to obtain the first coordinate.
[0098] It should be noted that the first preset matrix and the second preset matrix can be set as needed and are not limited here. Optionally, the first preset matrix and the second preset matrix are both 3*3 matrices.
[0099] In some exemplary embodiments, converting the second coordinate into the first coordinate specifically includes:
[0100] Converting the second coordinate into a third coordinate of the normal of the target pixel point in the world space through a first preset matrix;
[0101] The third coordinate is converted into the first coordinate by the following formula;
[0102]
[0103] l=uu′;
[0104] Among them, u represents the vector corresponding to the third coordinate, v represents the normal vector of the model, u′ represents the projection of the vector corresponding to the third coordinate on the normal vector of the model, l represents the vector corresponding to the first coordinate, and |v| represents the length of the normal vector of the model.
[0105] In actual implementation, in order to further improve the efficiency of the normal coordinate space conversion, after the third coordinate is obtained, the preset matrix is no longer used for the space coordinate conversion, but the third coordinate is first converted into a corresponding vector, then a projection of the third coordinate corresponding vector on the normal vector of the model is calculated, and then a vector difference between the projection and the third coordinate corresponding vector is calculated to obtain a first coordinate corresponding vector, and then the first coordinate corresponding vector is used to directly obtain the first coordinate, thereby improving the operation efficiency. Figure 8 wherein u represents the third coordinate corresponding vector, v represents the normal vector of the model, u' represents the projection of the third coordinate corresponding vector on the normal vector of the model, and l represents the first coordinate corresponding vector.
[0106] It should be noted that the above l is not exactly the same as the first coordinate corresponding vector obtained by the second preset matrix, and the two are only in the same direction. Since the normal line determined by the present application is mainly used for graphics processing, the present application mainly wants to determine the direction of the normal line, and does not care about the length of the obtained normal line, and therefore the first coordinate of the normal line of the target pixel point in the tangent space obtained by the above formula and the second preset matrix can be applied in the present application.
[0107] S104, determining the normal line of the target pixel point based on the target pixel point and the first coordinate.
[0108] In actual implementation, after the first coordinate is determined, the normal line of the target pixel point can be determined with the target pixel point as the origin and the first coordinate as the terminal point. The normal line of the target pixel point is the normal line of the model at the position of the target pixel point. Optionally, adding the normal lines of all target pixel points to the original normal line information of the model can determine all the normal lines of the model with mixed materials at the mixed material junctions. Reference Figure 9 wherein the left image is a rendering effect image in which the normal line of the mixed material is not determined by the method of the present application, and the right image is a rendering effect image in which the normal line of the mixed material is determined by the method of the present application. It can be seen that, in the right image, because the normal line at the mixed material junctions is determined, some uneven texture details are obviously added at the mixed material junctions.
[0109] When the number of pixels changes dramatically, the normal determined by the method of the present application will jitter. The reason is that when the number of pixels decreases, the accuracy of determining the first pixel difference between the target pixel and its adjacent pixel along the first direction and the second pixel difference along the second direction by the partial derivative function also decreases. That is, when the number of pixels decreases, the distance between two adjacent pixels will also become farther, resulting in a large pixel difference between the two adjacent pixels. The small number of pixels generally occurs when the pixel is too far away from the virtual camera, or when the angle between the line of sight of the pixel in the screen space and the normal is closer to vertical.
[0110] Taking the above factors into consideration, in some exemplary embodiments, after determining the first coordinate of the target pixel point in the tangent space based on the first pixel difference value and the second pixel difference value, the method further includes:
[0111] Obtaining the distance between the target pixel and the virtual camera;
[0112] In response to determining that the distance is greater than a preset threshold, a first attenuation coefficient of the normal of the target pixel point is determined based on the distance, and the first coordinate is adjusted based on the first attenuation coefficient so that when the target pixel point is farther away from the virtual camera, the normal strength can be weakened accordingly, thereby alleviating the jitter problem of the normal.
[0113] In some exemplary embodiments, after determining the first coordinate of the target pixel point in the tangent space based on the first pixel difference value and the second pixel difference value, the method further includes:
[0114] Obtaining the sight line of the target pixel in screen space;
[0115] Determining a normal of the target pixel based on the first coordinate, and determining an angle between the normal of the target pixel and the line of sight;
[0116] In response to determining that the absolute value of the difference between the angle and the right angle is less than a preset angle, a second attenuation coefficient of the normal of the target pixel point is determined based on the angle, and the first coordinate is adjusted based on the second attenuation coefficient, so that when the angle approaches vertical, the normal strength can be weakened accordingly, thereby alleviating the jitter problem of the normal.
[0117] It should be noted that, in the process of adjusting the first coordinate based on the attenuation coefficient in the above two embodiments, the attenuation coefficient can be directly multiplied by the first coordinate, or the attenuation coefficient can be subtracted from each sub-coordinate in the first coordinate, which is not limited here.
[0118] The method for determining the model normal provided in an embodiment of the present application first obtains a vertex color mask information map of a model with mixed materials to be rendered, determines a target pixel point from multiple pixel points of the vertex color mask information map, determines a first pixel difference between the target pixel point and its adjacent pixel points along a first direction through a partial derivative function, and determines a second pixel difference between the target pixel point and its adjacent pixel points along a second direction through the partial derivative function, wherein the first direction is perpendicular to the second direction; determines a first coordinate of the normal of the target pixel point in the tangent space based on the first pixel difference and the second pixel difference; determines the normal of the target pixel point based on the target pixel point and the first coordinate, thereby providing a simple and effective method for determining the normal of a model at the junction of multiple materials, thereby increasing the reusability and controllability of the model.
[0119] Exemplary devices
[0120] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a device for determining a model normal.
[0121] refer to Figure 10 , the device for determining the model normal includes:
[0122] Obtaining a model 201 to obtain a vertex color mask information graph of a model with mixed materials to be rendered;
[0123] A first determining module 202 determines a target pixel from a plurality of pixels of the vertex color mask information graph, determines a first pixel difference between the target pixel and its adjacent pixels along a first direction using a partial derivative function, and determines a second pixel difference between the target pixel and its adjacent pixels along a second direction using the partial derivative function, wherein the first direction is perpendicular to the second direction;
[0124] A second determining module 203 determines a first coordinate of the normal of the target pixel point in a tangent space based on the first pixel difference and the second pixel difference;
[0125] The third determination module 204 determines the normal of the target pixel based on the target pixel and the first coordinates. For ease of description, the above apparatus is described separately by function in various modules. Of course, when implementing the present disclosure, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0126] The apparatus of the above embodiment is used to implement the corresponding method for determining the model normal in any embodiment of the aforementioned exemplary method section, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0127] Based on the same inventive concept, corresponding to any of the above-mentioned embodiments and methods, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and runnable on the processor, wherein when the processor executes the program, the method for determining the model normal described in any of the above-mentioned embodiments is implemented.
[0128] Figure 11 10 is a schematic diagram showing a more specific hardware structure of an electronic device provided in this embodiment. The device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are communicatively connected to each other within the device via the bus 1050.
[0129] The processor 1010 can be implemented using a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.
[0130] The memory 1020 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage devices, dynamic storage devices, etc. The memory 1020 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1020 and is called and executed by the processor 1010.
[0131] The input / output interface 1030 is used to connect input / output modules to implement information input and output. The input / output modules can be configured as components within the device (not shown in the figure) or can be externally connected to the device to provide corresponding functions. Input devices may include a keyboard, mouse, touch screen, microphone, various sensors, etc., and output devices may include a display, speaker, vibrator, indicator light, etc.
[0132] The communication interface 1040 is used to connect to a communication module (not shown) to enable communication between the device and other devices. The communication module can communicate via a wired method (such as USB, network cable, etc.) or a wireless method (such as mobile network, WiFi, Bluetooth, etc.).
[0133] The bus 1050 includes multiple pathways that transmit information between various components of the device (eg, the processor 1010 , the memory 1020 , the input / output interface 1030 , and the communication interface 1040 ).
[0134] It should be noted that although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040, and the bus 1050, in a specific implementation, the device may also include other components necessary for normal operation. In addition, it will be understood by those skilled in the art that the above device may only include the components necessary to implement the embodiments of this specification, and does not necessarily include all the components shown in the figure.
[0135] The electronic device of the above embodiment is used to implement the corresponding method for determining the model normal in any embodiment of the above exemplary method section, and has the beneficial effects of the corresponding method embodiment, which will not be described in detail here.
[0136] Exemplary Program Products
[0137] Based on the same inventive concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a non-transitory computer-readable storage medium, wherein the non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method for determining the model normal of any of the above embodiments.
[0138] The above-mentioned non-transitory computer-readable storage medium can be any available medium or data storage device that can be accessed by a computer, including but not limited to magnetic storage (such as floppy disks, hard disks, magnetic tapes, magneto-optical disks (MO)), optical storage (such as CDs, DVDs, BDs, HVDs, etc.), and semiconductor storage (such as ROMs, EPROMs, EEPROMs, non-volatile memories (NAND FLASH), solid-state drives (SSDs)), etc.
[0139] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the method for determining the model normal as described in any embodiment of the exemplary method section above, and have the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0140] Those skilled in the art will appreciate that embodiments of the present invention may be implemented as a system, method, or computer program product. Therefore, the present application may be implemented in the following forms: complete hardware, complete software (including firmware, resident software, microcode, etc.), or a combination of hardware and software, generally referred to herein as a "circuit," "module," or "system." Furthermore, in some exemplary embodiments, the present invention may also be implemented in the form of a computer program product in one or more computer-readable media, wherein the computer-readable medium contains computer-readable program code.
[0141] Any combination of one or more computer-readable media can be used. A computer-readable medium can be a computer-readable signal medium or a computer-readable storage medium. A computer-readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or component, or any combination thereof. More specific examples (non-exhaustive examples) of computer-readable storage media can include, for example: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this document, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device.
[0142] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such propagated data signals may take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0143] Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0144] The computer program code for performing the operations of the present invention can be written in one or more programming languages, or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0145] It should be understood that each block in the flowchart and / or block diagram, and combinations of blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device to produce a machine. These computer program instructions are executed by the computer or other programmable data processing device to produce a device that implements the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0146] These computer program instructions can also be stored in a computer-readable medium that enables a computer or other programmable data processing device to operate in a specific manner. In this way, the instructions stored in the computer-readable medium produce a product that includes an instruction device that implements the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0147] Computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operational steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, such that the instructions executed on the computer or other programmable apparatus provide a process that implements the functions / operations specified in the blocks in the flowchart and / or block diagram.
[0148] Furthermore, although the operations of the present method are described in a particular order in the accompanying drawings, this does not require or imply that the operations must be performed in that particular order, or that all of the operations shown must be performed to achieve the desired results. Rather, the steps depicted in the flowcharts may be performed in a different order. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into a single step, and / or a single step may be broken down into multiple steps.
[0149] The use of the verbs "including," "comprising," "comprises," and "comprising," along with their derivatives, are used herein to mean that the process, method, object, composition, or step includes, but is not limited to, those elements specifically named. The use of the articles "a" and "an" are used herein to mean one or more than one (i.e., "one or more"), unless otherwise indicated by the context of the words or phrases. The use of the term "about" accompanying an expression of value or dosage is intended to indicate that the value or dosage is approximate, and that minor variations are intended to be within the scope of the disclosure.
[0150] While the principles and spirit of the application have been described with reference to several specific embodiments, it is to be understood that the application is not limited to the specific embodiments disclosed, and that the division of aspects is not meant to imply that features from these aspects cannot be combined to benefit, but is merely for ease of presentation. The application is intended to cover various modifications and equivalent arrangements included within the spirit and scope of the appended claims. The scope of the appended claims covers the entire scope of the expressions and encompasses all such modifications and equivalents.
Claims
1. A method for determining a model normal, characterized in that: include: Get the vertex color mask information map of the model with mixed materials to be rendered; Determining a target pixel from a plurality of pixel points of the vertex color mask information graph, determining a first pixel difference between the target pixel and an adjacent pixel point along a first direction using a partial derivative function, and determining a second pixel difference between the target pixel and an adjacent pixel point along a second direction using the partial derivative function, wherein the first direction is perpendicular to the second direction; Determining a second coordinate of the normal of the target pixel point in the screen space based on the first pixel difference and the second pixel difference, and converting the second coordinate into a first coordinate of the normal of the target pixel point in the tangent space; A normal of the target pixel point is determined based on the target pixel point and the first coordinate.
2. The method according to claim 1, characterized in that Converting the second coordinate into the first coordinate specifically includes: Converting the second coordinate into a third coordinate of the normal of the target pixel point in the world space through a first preset matrix; The third coordinate is converted into the first coordinate through a second preset matrix.
3. The method according to claim 1, characterized in that Converting the second coordinate into the first coordinate specifically includes: Converting the second coordinate into a third coordinate of the normal of the target pixel point in the world space through a first preset matrix; The third coordinate is converted into the first coordinate by the following formula; l=u=u ′ ; Wherein, u represents the vector corresponding to the third coordinate, v represents the normal vector of the model, and u ′ represents the projection of the vector corresponding to the third coordinate on the normal vector of the model, and l represents the vector corresponding to the first coordinate.
4. The method according to claim 1, wherein After determining the first coordinate of the target pixel point in the tangent space based on the first pixel difference value and the second pixel difference value, the method further includes: Obtaining the distance between the target pixel and the virtual camera; In response to determining that the distance is greater than a preset threshold, a first attenuation coefficient of the normal of the target pixel is determined based on the distance, and the first coordinate is adjusted based on the first attenuation coefficient.
5. The method according to claim 1, wherein After determining the first coordinate of the target pixel point in the tangent space based on the first pixel difference value and the second pixel difference value, the method further includes: Obtaining the sight line of the target pixel in screen space; Determining a normal of the target pixel based on the first coordinate, and determining an angle between the normal of the target pixel and the line of sight; In response to determining that the absolute value of the difference between the included angle and the right angle is less than a preset angle, a second attenuation coefficient of the normal of the target pixel point is determined based on the included angle, and the first coordinate is adjusted based on the second attenuation coefficient.
6. The method according to claim 1, characterized in that After obtaining the vertex color mask information map of the model with mixed materials to be rendered, the method further includes: Adjusting the vertex color mask information graph of the model based on a preset gradient formula; Wherein, the preset gradient formula is: P = (1-x)*N*x*C+x; Among them, P represents the vertex color of the adjusted vertex color mask information map, x represents the vertex color of the vertex color mask information map, N represents the vertex color of the preset noise map, and C represents the accuracy of the preset noise map.
7. The method according to claim 1, characterized in that Determining a target pixel from a plurality of pixel points in the vertex color mask information graph specifically includes: In response to a third pixel difference between any pixel among the multiple pixels of the vertex color mask information graph and its adjacent pixel being greater than a preset threshold, the pixel is determined as a target pixel.
8. The method according to claim 1, characterized in that The partial derivative function is: ddx / ddy or dFdx / dFdy.
9. A device for determining a model normal, characterized in that: include: Get the model block and obtain the vertex color mask information map of the model with mixed materials to be rendered; a first determining module, which determines a target pixel from a plurality of pixels of the vertex color mask information graph, determines a first pixel difference between the target pixel and its adjacent pixels along a first direction using a partial derivative function, and determines a second pixel difference between the target pixel and its adjacent pixels along a second direction using the partial derivative function, wherein the first direction is perpendicular to the second direction; a second determining module, configured to determine a second coordinate of the normal of the target pixel point in the screen space based on the first pixel difference and the second pixel difference, and convert the second coordinate into a first coordinate of the normal of the target pixel point in the tangent space; A third determining module determines a normal of the target pixel point based on the target pixel point and the first coordinate.
10. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method according to any one of claims 1 to 8 is implemented.
11. A non-transitory computer-readable storage medium, characterized in that The non-transitory computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Generation method and device of normal texture map, storage medium and electronic equipment
CN109829968A