Model anti-interpolation method and device, electronic device, and storage medium
By determining the target sub-model and storing its display position in 3D games, and combining the method of removing corresponding pixel points in the buffer, the problem of inserting the inner clothes of the character model into the outer clothes is solved, achieving an efficient model anti-interpolation effect.
Patent Information
- Application Number
- CN202210135013.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-14
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2042-02-14
AI Technical Summary
In 3D games, the inner clothes of the character model are easily inserted outside the outer clothes, or the skin is inserted outside the clothes, resulting in a decline in the game quality and poor user experience. The prior art solutions are inefficient or lead to misleading.
By determining the target submodel of the model to be rendered, and when rendering, the display location of the front pixel point of the target submodel is stored in the buffer. When rendering other submodels, pixel points with the same display position as the buffer store are removed to prevent interlude.
This method simply and efficiently solves the problem of model interpolation, avoids the phenomenon of misunderstanding, saves the time for art production personnel to adjust parameters, and retains better cloth dynamic effects.
Smart Images

Figure CN114470766B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a model anti-interpolation method and device, an electronic device, and a storage medium. Background Art
[0002] In 3D games, it is common for the inner layer of clothing of a character model to appear outside the outer layer of clothing, or for the character's skin to appear outside the clothing, resulting in compromised game quality and poor user experience.
[0003] In order to prevent the clothes of the character model from interlacing, there are generally two ways in the prior art. The first way is to adjust the physical parameters of the clothes and the character's body, the outer clothes and the inner clothes, so that a reasonable distance is maintained between the clothes and the character's body, and between the outer clothes and the inner clothes. However, adjusting the physical parameters in this way takes a lot of time, is inefficient, and makes the clothes look stretched, affecting the appearance.
[0004] The second method is to mark the inner clothing mesh and character body mesh that are blocked by the outer clothing during model making, and then remove the marked inner clothing mesh and character body mesh during rendering. However, when the model processed by this method moves, it is easy to have obvious glitches because the mesh blocked by the outer clothing is removed. For example, when a character wearing a long skirt moves, it needs to reveal part of the legs originally hidden in the skirt. Since the legs hidden in the skirt are removed during rendering, a broken leg appears, which produces obvious glitches. Summary of the invention
[0005] In view of the above problems, the present application is proposed to provide a model anti-interpolation method and device, electronic device, and storage medium that overcome the above problems or at least partially solve the above problems, including:
[0006] A model anti-interpolation method, the method comprising:
[0007] Determine a target sub-model of the model to be rendered; the target sub-model is a sub-model with a target number of levels among multiple sub-models constituting the model to be rendered;
[0008] Rendering the target sub-model, and storing the display position of the front pixel point corresponding to the target sub-model in a buffer;
[0009] When rendering other sub-models except the target sub-model in the model to be rendered, the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer are removed.
[0010] Optionally, rendering the target sub-model and storing the display positions of the front pixels corresponding to the target sub-model in a buffer includes:
[0011] The target sub-model is rendered with back-face culling, and the display position of the front pixel point corresponding to the target sub-model is stored in a buffer.
[0012] Optionally, rendering the target sub-model and storing the display positions of the front pixels corresponding to the target sub-model in a buffer includes:
[0013] When the target sub-model is composed of an outer mesh and an inner mesh, back-face culling rendering is performed on the outer mesh, and the display position of the front pixel point corresponding to the outer mesh is stored in a buffer;
[0014] Render the inner mesh.
[0015] Optionally, when rendering other sub-models except the target sub-model in the model to be rendered, removing the pixel points corresponding to the other sub-models whose display positions are the same as those stored in the buffer, further includes:
[0016] When the other sub-models are composed of more than two sub-models, the two or more sub-models are rendered in order from large to small in terms of their levels.
[0017] Optionally, the rendering in order of the levels of the two or more sub-models from large to small further includes:
[0018] When the rendering of the sub-model of the current level is completed, the display positions of the pixels that are not eliminated and correspond to the sub-model of the current level are stored in the buffer.
[0019] Optionally, the other sub-model consists of a first model part and a second model part, wherein a display position of a pixel point corresponding to the first model part is always different from a display position stored in the buffer;
[0020] When rendering other sub-models except the target sub-model in the model to be rendered, removing pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer, comprises:
[0021] When rendering the second model part, among the pixels corresponding to the second model part, the pixel points whose corresponding display positions are the same as the display positions stored in the buffer are removed;
[0022] After the rendering of the second model part is completed, the first model part is rendered.
[0023] Optionally, when rendering other sub-models except the target sub-model in the model to be rendered, the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer are removed, and further includes:
[0024] Perform backface culling rendering on the other sub-models.
[0025] Optionally, the target sub-model is a sub-model having a maximum number of levels among the sub-models corresponding to its coverage area.
[0026] A model anti-interpolation device, comprising:
[0027] A first determination module is used to determine a target sub-model of the model to be rendered; the target sub-model is a sub-model with a target number of levels among the multiple sub-models constituting the model to be rendered;
[0028] A first rendering module, used for rendering the target sub-model, and storing the display position of the front pixel point corresponding to the target sub-model in a buffer;
[0029] The second rendering module is used to remove the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer when rendering other sub-models except the target sub-model in the model to be rendered.
[0030] Optionally, the first rendering module includes:
[0031] The first back-face culling rendering module is used to perform back-face culling rendering on the target sub-model and store the display position of the front pixel point corresponding to the target sub-model in a buffer.
[0032] Optionally, the first rendering module includes:
[0033] An outer layer rendering module, used for performing back-face culling rendering on the outer layer mesh when the target sub-model is composed of an outer layer mesh and an inner layer mesh, and storing the display position of the front pixel point corresponding to the outer layer mesh in a buffer;
[0034] The inner layer rendering module is used to render the inner layer grid.
[0035] Optionally, the second rendering module includes:
[0036] A sequential rendering module is used to render the other sub-models in order from large to small according to the levels of the two or more sub-models when the other sub-models are composed of more than two sub-models.
[0037] Optionally, the sequential rendering module is specifically configured to store the display positions of the non-eliminated pixels corresponding to the current-level sub-model in the buffer when the rendering of the current-level sub-model is completed.
[0038] Optionally, the other sub-model is composed of a first model part and a second model part, wherein a display position of a pixel point corresponding to the first model part is always different from a display position stored in the buffer; and the second rendering module comprises:
[0039] A second model part rendering module, configured to remove, when rendering the second model part, pixel points corresponding to the second model part, whose corresponding display positions are the same as the display positions stored in the buffer;
[0040] The first model part rendering module is used to render the first model part after the second model part rendering is completed.
[0041] Optionally, the second rendering module further includes:
[0042] The second back-face culling rendering module is used to perform back-face culling rendering on the other sub-models.
[0043] Optionally, the target sub-model is a sub-model having a maximum number of levels among the sub-models corresponding to its coverage area.
[0044] An electronic device comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the steps of the model anti-interpolation method as described above are implemented when the computer program is executed by the processor.
[0045] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the model anti-interpolation method described above are implemented.
[0046] This application has the following advantages:
[0047] In an embodiment of the present application, by determining the target sub-model of the model to be rendered, when rendering the target sub-model, the display position of the front pixel points corresponding to the target sub-model is stored in a buffer zone, and when rendering sub-models other than the target sub-model in the model to be rendered, the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer zone are removed; thereby ensuring that the parts of the other sub-models that are obscured by the target sub-model will not be rendered and displayed, thereby solving the problem of model interlacing in a simple and efficient manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the description of the present application will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0049] Figure 1 A flowchart of the steps of a model anti-interpolation method according to an embodiment of the present application;
[0050] Figure 2 This is a flowchart of the steps in the first processing stage of the model anti-interpolation method according to an example of the present application;
[0051] Figure 3 This is a flowchart of the steps in the second processing stage of the model anti-interpolation method according to an example of the present application;
[0052] Figure 4 This is a structural block diagram of a model anti-penetration device according to an embodiment of the present application. DETAILED DESCRIPTION
[0053] In order to make the above-mentioned purposes, features and advantages of the present application more obvious and easy to understand, the present application is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.
[0054] In 3D games, in order to simulate the dynamic effects of real clothes, physical methods such as cloth systems or rigid bodies driving bones are usually used to drive the movement of clothing meshes. The game has strict requirements on the running time of each frame. Usually, for a 60-frame game, the running time of each frame is 16.6ms, and the time allocated for physical simulation will be even less. In such a short time, it is difficult to achieve accurate physical simulation, so it is common for the inner layer of clothes to be inserted into the outer layer of clothes, and the character's skin to be inserted outside the clothes.
[0055] There are generally two ways to prevent the model from interpenetrating in the prior art. The first way is to adjust the physical parameters of the clothes and the character's body, the outer clothes and the inner clothes, so that a reasonable distance is maintained between the clothes and the character's body, and between the outer clothes and the inner clothes. However, adjusting the physical parameters in this way takes a lot of time for the art production staff, which is inefficient and makes the clothes look stretched, resulting in an unrealistic overall image of the model and a serious loss of physical effects.
[0056] The second method is to mark the inner clothing mesh and character body mesh that are blocked by the outer clothing during model making, and then remove the marked inner clothing mesh and character body mesh during rendering. This processing method has high requirements for the selected marked meshes. If the marking range is too small, that is, some meshes that should be marked are not marked, there will still be interlacing; if the marking range is too large, that is, some meshes that are not blocked by the outer clothing are marked, it will cause the rendered model to be broken.
[0057] In view of this, an embodiment of the present application provides a model anti-interpolation method to overcome the defects of the prior art.
[0058] The model anti-penetration method in one embodiment of the present application can be run on a local terminal device or a server. When the model anti-penetration method is run on a server, the model anti-penetration method can be implemented and executed based on a cloud interaction system, wherein the cloud interaction system includes a server and a client device.
[0059] In an optional implementation, various cloud applications can be run under the cloud interaction system, such as cloud games. Taking cloud games as an example, cloud games refer to a game mode based on cloud computing. In the operation mode of cloud games, the operating body of the game program and the main body of the game screen presentation are separated. The storage and operation of the model anti-interpolation method are completed on the cloud game server. The role of the client device is used for receiving and sending data and presenting the game screen. For example, the client device can be a display device with data transmission function close to the user side, such as a first terminal device, a TV, a computer, a handheld computer, etc.; but the cloud game server in the cloud performs the model anti-interpolation method. When playing the game, the player operates the client device to send an operation instruction to the cloud game server. The cloud game server runs the game according to the operation instruction, encodes and compresses the game screen and other data, and returns it to the client device through the network. Finally, the client device decodes and outputs the game screen.
[0060] In an optional embodiment, taking a game as an example, a local terminal device stores a game program and is used to present a game screen. The local terminal device is used to interact with the player through a graphical user interface, that is, the game program is downloaded and installed by an electronic device and run conventionally. The local terminal device may provide the graphical user interface to the player in a variety of ways, for example, it may be rendered and displayed on a display screen of the terminal, or provided to the player through a holographic projection. For example, the local terminal device may include a display screen and a processor, the display screen is used to present a graphical user interface, the graphical user interface includes a game screen, and the processor is used to run the game, generate a graphical user interface, and control the display of the graphical user interface on the display screen.
[0061] Reference Figure 1 , shows a flow chart of the steps of a model anti-interpolation method provided by an embodiment of the present application, which may specifically include the following steps:
[0062] Step 101, determining a target sub-model of a model to be rendered;
[0063] Step 102, rendering the target sub-model, and storing the display position of the front pixel point corresponding to the target sub-model in a buffer;
[0064] Step 103 , when rendering other sub-models except the target sub-model in the model to be rendered, remove the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer.
[0065] In an embodiment of the present application, by determining the target sub-model of the model to be rendered, when rendering the target sub-model, the display position of the front pixel points corresponding to the target sub-model is stored in a buffer zone, and when rendering sub-models other than the target sub-model in the model to be rendered, the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer zone are removed; thereby ensuring that the parts of the other sub-models that are obscured by the target sub-model will not be rendered and displayed, thereby solving the problem of model interlacing in a simple and efficient manner.
[0066] Next, the model anti-penetration method in this exemplary embodiment will be further described.
[0067] In step 101, a target sub-model of a model to be rendered is determined.
[0068] In an embodiment of the present application, the model to be rendered may be a role model that needs to be displayed in real time during the running of a game application, such as a character model in a game.
[0069] The model to be rendered is generally composed of multiple sub-models. Taking a character model as an example, the character model is generally composed of a body model and a clothing model of the character.
[0070] Each sub-model has a corresponding level. According to the level corresponding to each sub-model, the target sub-model corresponding to the target level can be determined. The target level is generally the maximum level, that is, the target sub-model is the outermost sub-model of the model to be rendered. The target level can be the absolute maximum level or the relative maximum level. The two cases will be explained exemplarily later. Generally, during the model making stage, the art production staff can clearly define the levels of the multiple sub-models that make up the model to be rendered.
[0071] In one example, when determining the level of each sub-model, the artist may use the center line of the model to be rendered as a reference and determine the level of each sub-model according to the maximum vertical distance between each sub-model and the center line.
[0072] Exemplarily, when the model to be rendered is a character model, its center line is the straight line where the midline of the character model is located. If the character model is composed of a body model and a clothing model, the vertical distance between the body model and the center line in the character model is smaller than the vertical distance between the clothing model and the center line. Therefore, the body model is in the innermost layer and the clothing model is in the outermost layer, that is, the body model is in the first layer and the clothing model is in the second layer. It can be understood that the target sub-model of the model to be rendered is the sub-model with the largest vertical distance from the center line of the model to be rendered among the multiple sub-models constituting the model to be rendered, that is, the target sub-model is the sub-model with the largest number of levels among the sub-models constituting the model to be rendered.
[0073] Exemplarily, when the model to be rendered is a character model wearing a vest, long-sleeved underwear and a skirt, wherein the vest and the skirt do not overlap, and the long-sleeved underwear and the skirt do not overlap either, the body model of the character in the model to be rendered is the first layer, the long-sleeved underwear model is the second layer, the vest model is the third layer, and the skirt model is the second layer; it can be seen that among the multiple sub-models of the model to be rendered, the sub-model corresponding to the absolute maximum number of levels is the vest model. Therefore, in this example, the vest model is the target sub-model, and the long-sleeved underwear model, the skirt model and the body model belong to other sub-models.
[0074] When there are multiple sub-models with the largest number of levels, the sub-models corresponding to the multiple maximum number of levels are all target sub-models. For example, when the model to be rendered is a character model wearing a top and a skirt, wherein the top and the skirt do not overlap, the body model of the character in the model to be rendered is the first layer, the top model and the skirt model are both the second layer, and both are the maximum level, then the target sub-models are the top model and the skirt model.
[0075] In an optional embodiment, the target sub-model is the sub-model with the maximum number of levels in the sub-models corresponding to its coverage area. That is, the target number of levels corresponding to the target sub-model is the relative maximum number of levels. It can be understood that in this embodiment, it is possible to determine whether the sub-model is located at the maximum level in its coverage area based on the area (i.e., coverage area) corresponding to each sub-model, and if so, the sub-model is determined as the target sub-model.
[0076] Exemplarily, when the model to be rendered is a character model wearing a vest, long-sleeved underwear and a skirt, wherein the vest does not overlap with the skirt, and the long-sleeved underwear does not overlap with the skirt, the body model of the character in the model to be rendered is the first layer, the long-sleeved underwear model is the second layer, the vest model is the third layer, and the skirt model is the second layer. For the skirt model, its coverage area only involves the body model, and the body model is the first layer, which is less than the number of levels of the skirt model, that is, the skirt model is the sub-model with the largest number of levels in its coverage area, and therefore, it can be determined that the skirt model is the target sub-model. Similarly, for the vest layer, its coverage area involves the body model and the long-sleeved underwear model, wherein the body model is the first layer, and the long-sleeved underwear model is the second layer, both of which are less than the number of levels of the vest model, that is, the vest model is the sub-model with the largest number of levels in its coverage area, and therefore, it can be determined that the vest model is also the target sub-model. For the long-sleeved underwear model, its coverage area involves the body model and the vest model. Since the number of levels of the long-sleeved underwear model is less than that of the vest model, that is, the long-sleeved underwear model is not the sub-model with the largest number of levels in its coverage area, the long-sleeved underwear model is not the target sub-model. That is, in this example, the target sub-model includes the skirt model and the vest model, and the long-sleeved underwear model and the body model belong to other sub-models.
[0077] In step 102, the target sub-model is rendered, and the display positions of the front pixels corresponding to the target sub-model are stored in a buffer.
[0078] In an embodiment of the present application, when rendering the model to be rendered, the target sub-model is rendered first, and when rendering the target sub-model, the display position of the front pixel points corresponding to the target sub-model is stored in the buffer. Among them, the front pixel points refer to the pixel points corresponding to the front side in the target sub-model; and the front side generally refers to the face of the target sub-model that can be directly seen visually when the model to be rendered is displayed normally. The specific judgment of whether a face is the front side is related to the specifications set when the model is made according to the art. For example, when making a model, the points in the polygon (i.e., the face) that appear in clockwise order can be set as the front side; therefore, when the points in the face appear in clockwise order, it is the front side.
[0079] The display position of the front pixel points corresponding to the target sub-model is stored in the buffer for reference when rendering other sub-models later, to prevent the pixel points corresponding to other sub-models from being displayed at the display position stored in the buffer, causing the target sub-model to be interspersed.
[0080] In an optional embodiment of the present application, the above-mentioned rendering of the target sub-model and storing the display position of the front pixel point corresponding to the target sub-model in the buffer includes:
[0081] The target sub-model is rendered with back-face culling, and the display position of the front pixel point corresponding to the target sub-model is stored in a buffer.
[0082] In this embodiment, back-face culling rendering means that during rendering, the back face of the target sub-model is culled and not rendered, and only the front face of the target sub-model is rendered, so as to reduce the number of rendering faces, thereby improving rendering efficiency. Among them, the back face generally refers to the face of the target sub-model that cannot be directly seen visually when the model to be rendered is displayed normally. The specific judgment of whether a face is the back face is related to the specifications set when the model is made according to the artist. For example, when the artist makes the model, it can be set that the points in the polygon (i.e., the face) appearing in clockwise order are the front face. Therefore, when the points in the face appear in clockwise order, it is the front face. Correspondingly, when the points in the face appear in counterclockwise order, it is the back face.
[0083] Further, in an optional embodiment of the present application, when the target sub-model represents clothing, the above-mentioned rendering of the target sub-model and storing the display position of the front pixel point corresponding to the target sub-model in the buffer includes:
[0084] When the target sub-model is composed of an outer mesh and an inner mesh, back-face culling rendering is performed on the outer mesh, and the display position of the front pixel point corresponding to the outer mesh is stored in a buffer;
[0085] Render the inner mesh.
[0086] When there is a need to see the inside of a garment, art production staff will use two layers of mesh with exactly the same shape inside and outside when making a model to represent the garment. There is a certain thickness between the two layers of mesh, and there will be no overlap or interweaving, so that the inside of the garment can be displayed in scenes where it is necessary to see the inside of the garment.
[0087] In an embodiment of the present application, for the rendering of a target sub-model composed of an outer mesh and an inner mesh, back-face culling rendering can be performed on the outer mesh first to reduce the number of rendering surfaces, and the inner mesh can be rendered directly to avoid the inner mesh not being rendered when it needs to be displayed due to back-face culling rendering.
[0088] In step 103, when rendering other sub-models except the target sub-model in the model to be rendered, the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer are removed.
[0089] When the rendering of the target sub-model is completed, the other sub-models in the model to be rendered except the target sub-model are rendered. When rendering other sub-models, the pixel points corresponding to other sub-models whose corresponding display positions are the same as the display positions stored in the buffer are removed, so that only the target sub-model is displayed in the display area displaying the target sub-model, which can prevent other sub-models from interlacing the target sub-model.
[0090] In a specific implementation, when rendering other sub-models, the display position of each pixel corresponding to the other sub-models can be compared with the display position in the buffer. When the display position of the pixel corresponding to the other sub-model is different from any display position stored in the buffer, rendering and writing are performed; when the display position of the pixel corresponding to the other sub-model is the same as one of the display positions stored in the buffer, rendering and writing are not performed, that is, among the pixels corresponding to the other sub-models, the pixels whose corresponding display positions are the same as the display positions stored in the buffer are eliminated.
[0091] In an optional embodiment of the present application, the other sub-models may be divided into a first model part and a second model part, wherein the display position of the pixel points corresponding to the first model part is always different from the display position stored in the buffer; when rendering the other sub-models except the target sub-model in the model to be rendered, the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer are removed, which may include:
[0092] When rendering the second model part, among the pixels corresponding to the second model part, the pixel points whose corresponding display positions are the same as the display positions stored in the buffer are removed;
[0093] After the rendering of the second model part is completed, the first model part is rendered.
[0094] In this embodiment, the art production personnel can divide the other sub-models into the first model part and the second model part based on experience, ensuring that the display position of the pixel points corresponding to the first model part is always different from the display position stored in the buffer. For example, when the model to be rendered corresponds to a character model wearing a dress, the target sub-model of the model to be rendered is the dress model, and the other sub-models are the body model of the character. Considering that the head of the character will never be blocked by the dress, the body model can be divided into the head and other parts, the head is the first model part, and the other parts are the second model part. Of course, it can also be considered that the palms and soles of the character will never be blocked by the dress. Therefore, the body model can be divided into the head, palms, soles and other remaining parts. The head, palms, and soles of the feet constitute the first model part, and the remaining other parts are the second model part.
[0095] Since the display position of the pixel points corresponding to the first model part is always different from the display position stored in the buffer, the first model part can be directly rendered to reduce the number of pixel points that need to be compared and improve rendering efficiency.
[0096] Since this embodiment will compare the display position of the pixel points corresponding to the second model part with the display position stored in the buffer when rendering the second model part, and remove them if they are the same; therefore, this embodiment does not need to be very precise in the division of the first model part and the second model part, which can reduce the difficulty of division for art production personnel. For example, in the above-mentioned character model example of the dress, the first model part can be only the head of the character's body model, or it can be composed of the head, palms, and soles of the character's body model; it can be seen that the division does not need to be very precise.
[0097] In an optional embodiment of the present application, when the model to be rendered is composed of more than three sub-models, that is, when the other sub-models include more than two sub-models, when rendering the other sub-models except the target sub-model in the model to be rendered, the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer are removed, which may also include:
[0098] The two or more sub-models are rendered in order from the largest to the smallest level.
[0099] In this embodiment, for a model to be rendered that is composed of multiple sub-models, the sub-models may be rendered in order from large to small levels.
[0100] Exemplarily, when the model to be rendered corresponds to a character model wearing a dress and a vest, the first level is the character model, the second level is the dress model, and the third level is the vest model. Therefore, the target sub-model of the model to be rendered is the vest model, and the other sub-models are the dress model and the body model of the character, and the level of the dress model is greater than the level of the body model. At this time, after the vest model is rendered, the dress model is rendered. When rendering the dress model, the display position of the pixel points corresponding to the dress model is compared to the display position stored in the buffer. If they are the same, the pixel points corresponding to the dress model are removed. After the dress model is rendered, the body model is rendered. When rendering the body model, the display position of the pixel points corresponding to the body model is compared to the display position stored in the buffer. If they are the same, the pixel points corresponding to the body model are removed; this ensures that the outermost vest model will not be interspersed with the inner model.
[0101] Furthermore, the rendering in order of the levels of the two or more sub-models from large to small may also include:
[0102] When the rendering of the sub-model of the current level is completed, the display positions of the pixels that are not eliminated and correspond to the sub-model of the current level are stored in the buffer.
[0103] Among them, the current level sub-model can be any level sub-model. During the rendering process of the current level sub-model, the display position of the pixel points corresponding to the current level sub-model is compared with the display position stored in the buffer. If they are the same, they are eliminated; if they are different, the different display positions are added to the buffer. In this way, when rendering the next level sub-model (that is, the sub-model with a smaller level number than the current level sub-model), it can be determined whether the display position of the pixel points corresponding to the next level sub-model coincides with the display position of the pixel points corresponding to the previously rendered level sub-model, and the overlapping pixels are eliminated to prevent the next level sub-model from being interspersed with the previously rendered sub-model.
[0104] Continuing with the above-mentioned character model wearing a dress and a vest as an example, the rendering process of the vest model and the dress model is consistent with the previous description, and will not be repeated here. When the dress model is rendered, the display position of the pixel points corresponding to the dress model is added to the buffer. At this time, the buffer stores the display area of the vest and the display area where the dress does not overlap with the vest. Then the body model is rendered, and the pixel points corresponding to the body model that fall in the display area of the vest and the display area where the dress does not overlap with the vest are removed to prevent the body model from being inserted outside the dress model or the vest model.
[0105] Optionally, when rendering in order from large to small according to the hierarchy of the two or more sub-models, the sub-model of the current level can also be divided into an outer-model part and an inner-model part, wherein the outer-model part and the inner-model part are relative to the sub-model that has been rendered, that is, the sub-model of the current level can be divided into an outer-model part and an inner-model part that will never be blocked by the sub-model that has been rendered. In a specific implementation, the art production personnel can make the division and mark it according to experience. When rendering the outer-model part of the sub-model of the current level, it can be rendered directly, and when the rendering is completed, the display position of the corresponding pixel point of the outer-model part is stored in the buffer; when rendering the inner-model part of the sub-model of the current level, it is necessary to perform a comparison process with the display position in the buffer, and when the rendering of the inner-model part is completed, the display position of the pixel point of the inner-model part that has not been eliminated is stored in the buffer.
[0106] Further, in an optional embodiment of the present application, when rendering other sub-models except the target sub-model in the model to be rendered, removing the pixel points corresponding to the other sub-models, which are the same as the display position stored in the buffer, may also include:
[0107] Perform backface culling rendering on the other sub-models.
[0108] In this embodiment, when rendering other sub-models, back-face culling rendering may be selected to reduce the number of rendered faces and improve rendering efficiency.
[0109] The model anti-penetration method provided in the embodiment of the present application corrects the interpenetration part from the rendering level, and solves the model interpenetration problem caused by inaccurate physical simulation. Compared with the first method of the prior art in which the art production personnel adjust the physical parameters, the embodiment of the present application does not need to change the physical parameters to eliminate the interpenetration, which can retain better cloth dynamic effects, and can save a lot of parameter adjustment time for art production personnel; in addition, compared with the second method of the prior art in which the model part that may produce interpenetration is directly cut off, the embodiment of the present application uses a pixel-by-pixel method to remove the interpenetration during rendering, which is more accurate and will not cause the goof phenomenon that occurs when the cut-off part needs to be displayed. Furthermore, the embodiment of the present application can further improve the model rendering efficiency by not requiring the operation of accurately marking the removed part, and the operation that does not require the accurate marking of the removed part will not bring a lot of workload to the art production personnel. The embodiment of the present application can achieve the correct handling of the interpenetration problem, reduce the workload of art, and improve the model rendering efficiency under the premise of ensuring the physical effect of the clothes.
[0110] In order to facilitate those skilled in the art to understand the present solution, the model anti-interpolation method provided in the embodiment of the present application will be described below with reference to specific examples.
[0111] In this example, the model to be rendered corresponds to a person model wearing a dress; the implementation process of the model anti-penetration method may include two processing stages, the first processing stage is an offline processing stage, and the second processing stage is a running stage. Figure 2 As shown, the first processing stage may include the following steps:
[0112] Step 201, determining the outer mesh of the target sub-model.
[0113] In this example, the target sub-model is a dress model. When the dress model consists of an inner mesh and an outer mesh, it is necessary to determine the outer mesh of the dress model and save the outer mesh of the dress model as a separate material group. When the dress model consists of only one layer of mesh, the mesh of the dress model is the outer mesh and is saved as a separate material group.
[0114] Step 202: divide the sub-models except the target sub-model in the model to be rendered into a first model part and a second model part, wherein the display position of the pixel points corresponding to the first model part is always different from the display position stored in the buffer.
[0115] In this example, the other sub-models are the body model. The art production personnel can divide the body model into a first model part including the head, palms, and soles and the remaining second model part based on experience, so as to improve the operation efficiency in the subsequent operation process.
[0116] like Figure 3 As shown, the second processing stage of this example may include the following steps:
[0117] Step 301 , performing backface culling rendering on the outer mesh of the target sub-model, and storing the display positions corresponding to the pixel points of the outer mesh after rendering in the first template buffer.
[0118] In this example, before rendering begins, you can turn on the template test, which is a sample-by-sample operation provided by the 3D graphics pipeline and performed after the Fragment Shader. Set the Stencil function of the template test to Always passes, set the stencil Ref to 0x48 (0x48 here is just an example, it can be any value between 0x01-0xff); set the stencil operation to Replace; after the template test is set, perform backface culling on the outer mesh before rendering, and after the outer mesh is rendered, store the display position of the pixel corresponding to the outer mesh in 0X48 of the template buffer.
[0119] Step 302: Render the inner mesh of the target sub-model.
[0120] When the target sub-model contains an inner mesh, after the outer mesh of the target sub-model is rendered, modify the stencil Ref to 0X16 (0x16 here is just an example, it can be any value from 0x01-0xff except 0X48), and then render the inner mesh. That is, after the inner mesh is rendered, the display position of the pixel corresponding to the inner mesh will be stored in 0X16 of the template buffer.
[0121] Step 303: Render the second model parts of other sub-models.
[0122] In this example, after the target sub-model is rendered, it is necessary to set the Stencil function to Not Equal, the stencil Ref to 0X48 (the 0X48 needs to be consistent with the stencil Ref set in step 301), and then render the second model part of the other sub-models. When rendering the second model part, it will be compared with the display position in the template buffer. Specifically, the template buffer stores the value corresponding to the display position. During the comparison, if the value of the display position of the corresponding pixel is equal to the value stored in the template buffer, the pixels with equal values will be eliminated; if the value of the display position of the corresponding pixel is not equal to the value stored in the template buffer, rendering can be performed, and the value of the display position of the pixel will be increased in the template buffer.
[0123] Step 304: Render the first model parts of other sub-models.
[0124] Since the first model part is the part that will never be blocked by the outer sub-model, the template test can be turned off before rendering the first model part, that is, the first model part is directly rendered without special processing.
[0125] In this example, the outer mesh of the target sub-model of the model to be rendered can be separated in the offline stage, and the other sub-models in the model to be rendered except the target sub-model can be divided into a first model part that is never blocked by the target sub-model and a remaining second model part; in the running stage, the outer mesh of the target sub-model is first rendered, the value of the display position of the pixel corresponding to the outer mesh is stored in the specified template buffer, and then the second model part of the other sub-model is rendered. When rendering the second model part, the pixels whose display position value of the pixel corresponding to the second model part is equal to the value stored in the template buffer are removed, and finally the first model part of the other sub-model is rendered; or, in the running stage, the first model part of the other sub-model can be rendered first, and then the template test is turned on, the outer mesh of the target sub-model is rendered, the value of the actual position of the pixel corresponding to the outer mesh is stored in the specified template buffer, and finally the second model part of the other sub-model is rendered. When rendering the second model part, the pixels whose display position value of the pixel corresponding to the second model part is equal to the value stored in the template buffer are removed; the model interlacing can be effectively prevented from occurring, and compared with the processing method of the prior art, the efficiency is higher and the effect is better.
[0126] It should be noted that, for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the described order of actions, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
[0127] Reference Figure 4 , shows a structural block diagram of an embodiment of a model anti-interpolation device of the present application. In the embodiment of the present application, the model anti-interpolation device may specifically include the following modules:
[0128] The first determination module 401 is used to determine a target sub-model of the model to be rendered; the target sub-model is a sub-model with a target number of levels among the multiple sub-models constituting the model to be rendered;
[0129] A first rendering module 402, configured to render the target sub-model and store the display positions of the front pixels corresponding to the target sub-model in a buffer;
[0130] The second rendering module 403 is used to remove the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer when rendering other sub-models except the target sub-model in the model to be rendered.
[0131] In an optional embodiment of the present application, the target sub-model is a sub-model having a maximum number of levels among the sub-models corresponding to its coverage area.
[0132] In an optional embodiment of the present application, the first rendering module 402 includes:
[0133] The first back-face culling rendering module is used to perform back-face culling rendering on the target sub-model and store the display position of the front pixel point corresponding to the target sub-model in a buffer.
[0134] In an optional embodiment of the present application, the first rendering module 402 includes:
[0135] An outer layer rendering module, used for performing back-face culling rendering on the outer layer mesh when the target sub-model is composed of an outer layer mesh and an inner layer mesh, and storing the display position of the front pixel point corresponding to the outer layer mesh in a buffer;
[0136] The inner layer rendering module is used to render the inner layer grid.
[0137] In an optional embodiment of the present application, the second rendering module 403 includes:
[0138] A sequential rendering module is used to render the other sub-models in order from large to small according to the levels of the two or more sub-models when the other sub-models are composed of more than two sub-models.
[0139] In an optional embodiment of the present application, the sequential rendering module is specifically used to store the display positions of the non-culled pixels corresponding to the current level sub-model in the buffer when the rendering of the current level sub-model is completed.
[0140] In an optional embodiment of the present application, the other sub-model is composed of a first model part and a second model part, wherein the display position of the pixel point corresponding to the first model part is always different from the display position stored in the buffer; the second rendering module 403 includes:
[0141] A second model part rendering module, configured to remove, when rendering the second model part, pixel points corresponding to the second model part, whose corresponding display positions are the same as the display positions stored in the buffer;
[0142] The first model part rendering module is used to render the first model part after the second model part rendering is completed.
[0143] In an optional embodiment of the present application, the second rendering module 403 further includes:
[0144] The second back-face culling rendering module is used to perform back-face culling rendering on the other sub-models.
[0145] In an embodiment of the present application, a target sub-model of a model to be rendered is determined by a first determination module 401. When the first rendering module 402 renders the target sub-model, the display position of the front pixel points corresponding to the target sub-model is stored in a buffer. When the second rendering module 403 renders sub-models other than the target sub-model in the model to be rendered, the pixel points corresponding to other sub-models whose corresponding display positions are the same as the display positions stored in the buffer are removed; thereby ensuring that parts of other sub-models that are obscured by the target sub-model will not be rendered and displayed, thereby solving the problem of model interlacing in a simple and efficient manner.
[0146] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0147] An embodiment of the present application also discloses an electronic device, including a processor, a memory, and a computer program stored in the memory and capable of running on the processor, wherein the computer program implements the steps of the model anti-interpolation method as described above when executed by the processor.
[0148] The embodiment of the present application also discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the model anti-interpolation method as described above are implemented.
[0149] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0150] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application can adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0151] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, terminal devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0152] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0153] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0154] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the embodiments of the present application.
[0155] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or terminal device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or terminal device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or terminal device including the elements.
[0156] The above is a detailed introduction to a model anti-penetration method and device, electronic device and storage medium provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for general technical personnel in this field, according to the idea of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A model anti-interpolation method, characterized in that: The method comprises: Determine a target sub-model of the model to be rendered; the target sub-model is a sub-model whose number of levels is a target number of levels among multiple sub-models constituting the model to be rendered; wherein the target sub-model is the outermost sub-model of the model to be rendered, and the target number of levels is an absolute maximum number of levels or a relative maximum number of levels; Rendering the target sub-model, and storing the display position of the front pixel point corresponding to the target sub-model in a buffer; When rendering other sub-models except the target sub-model in the model to be rendered, the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer are removed.
2. The method according to claim 1, characterized in that The step of rendering the target sub-model and storing the display position of the front pixel point corresponding to the target sub-model in a buffer includes: The target sub-model is rendered with back-face culling, and the display position of the front pixel point corresponding to the target sub-model is stored in a buffer.
3. The method according to claim 1, characterized in that The step of rendering the target sub-model and storing the display position of the front pixel point corresponding to the target sub-model in a buffer includes: When the target sub-model is composed of an outer mesh and an inner mesh, back-face culling rendering is performed on the outer mesh, and the display position of the front pixel point corresponding to the outer mesh is stored in a buffer; Render the inner mesh.
4. The method according to claim 1, characterized in that: When rendering other sub-models except the target sub-model in the model to be rendered, removing the pixel points corresponding to the other sub-models whose display positions are the same as those stored in the buffer, further comprising: When the other sub-models are composed of more than two sub-models, the two or more sub-models are rendered in order from large to small in terms of their levels.
5. The method according to claim 4, characterized in that The rendering in order of the levels of the two or more sub-models from large to small also includes: When the rendering of the sub-model of the current level is completed, the display positions of the pixels that are not eliminated and correspond to the sub-model of the current level are stored in the buffer.
6. The method according to claim 1, characterized in that The other sub-model is composed of a first model part and a second model part, wherein the display position of the pixel point corresponding to the first model part is always different from the display position stored in the buffer; When rendering other sub-models except the target sub-model in the model to be rendered, removing pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer, comprises: When rendering the second model part, among the pixels corresponding to the second model part, the pixel points whose corresponding display positions are the same as the display positions stored in the buffer are removed; After the rendering of the second model part is completed, the first model part is rendered.
7. The method according to any one of claims 1 to 6, characterized in that: When rendering other sub-models except the target sub-model in the model to be rendered, the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer are removed, further comprising: Perform backface culling rendering on the other sub-models.
8. The method according to claim 1, characterized in that The target sub-model is a sub-model with the maximum number of levels among the sub-models corresponding to its coverage area.
9. A model anti-interpolation rendering device, characterized in that: The device comprises: A first determination module is used to determine a target sub-model of the model to be rendered; the target sub-model is a sub-model whose number of levels is a target number of levels among multiple sub-models constituting the model to be rendered; wherein the target sub-model is the outermost sub-model of the model to be rendered, and the target number of levels is an absolute maximum number of levels or a relative maximum number of levels; A first rendering module, used for rendering the target sub-model, and storing the display position of the front pixel point corresponding to the target sub-model in a buffer; The second rendering module is used to remove the pixel points corresponding to the other sub-models whose corresponding display positions are the same as the display positions stored in the buffer when rendering other sub-models except the target sub-model in the model to be rendered.
10. An electronic device, characterized in that: The method comprises a processor, a memory and a computer program stored in the memory and capable of running on the processor, wherein the computer program, when executed by the processor, implements the steps of the model anti-interpolation method as claimed in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the model anti-interpolation method according to any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Calculation method and device for occlusion rate, storage medium and electronic device
CN109568961A
Picture rendering method and device, storage medium and electronic equipment
CN112316425A