Model local modification method, device, electronic device and storage medium
By generating the inclusion model and performing template testing, the modification area of the 3D model attachment is accurately determined, the mold penetration problem is solved, the degree of cropping freedom and modification accuracy is improved, and the complex shader modification process is simplified.
Patent Information
- Application Number
- CN202210652033.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-09
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2042-06-09
AI Technical Summary
The prior art is prone to mold penetration problems when assembling 3D models and attachment models, and the modification process is limited by the cut shape of the attachment model, with low cut freedom, complex shader modification, and it is difficult to accurately determine the target modification location, resulting in poor portability.
By determining the occlusion and modification parts of the target model, an inclusion model is generated, and the template testing method is used to determine the relative position of each pixel point and the inclusion model on the image of the depth value of the target modification part, and the modification area is accurately determined for modification.
It improves the freedom and portability of attachment model cutting, improves the accuracy and fineness of the modification area, and simplifies the modification process.
Smart Images

Figure CN115131535B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of model making technology, and in particular to a method, device, electronic device and storage medium for local modification of a model. Background Art
[0002] In the current field of animation and game production, in order to make the characters, objects, and other objects more realistic, the use of three-dimensional (3D) models is increasing in the field, so as to create 3D animations or 3D games. When creating these objects, they are generally equipped with a large number of accessory models, such as different clothing, jewelry, and decorations.
[0003] Because 3D models and accessory models are usually created separately, the two models are prone to intersecting during assembly. For example, when attaching accessories such as hats to character models, in order to achieve a harmonious placement of the hat, in most cases, the hat will intersect with the character model, causing intersecting parts. Existing solutions generally use plane cropping to modify intersecting parts. However, this modification method can only modify simple styles. With the diversification of accessory styles, on the one hand, the cutout shape of the accessory model limits the freedom of cropping the accessory model, making it difficult to accurately determine the target modification area with current methods. On the other hand, with the development of gaming and animation production and the diversification of accessory styles, the number of shaders for 3D models and accessory models has increased. Modifications may involve numerous shader modifications, which is a huge workload, difficult to maintain, and has poor portability, resulting in low modification accuracy. Summary of the Invention
[0004] In view of this, the present application proposes a method, device, electronic device and storage medium for local modification of a model, so that the modification is not limited to the cut shape of the accessory model, thereby improving the freedom and portability of the accessory model cutting, thereby quickly solving the problem of mold penetration.
[0005] Based on the above objectives, this application provides a method for local modification of a model, including:
[0006] Determining an occluded portion and a target modified portion of a target model, and determining an inclusion model of the occluded portion and a depth value image of the target modified portion;
[0007] Performing a template test on the inclusion model to determine the relative position of each pixel point on the depth value image of the target modification part and the inclusion model;
[0008] A modification area of the target modification part is determined according to the relative position, and a modification operation is performed on the modification area.
[0009] Based on the same concept, the present application also provides a model local modification device, including:
[0010] A determination module, configured to determine an occluded portion and a target modified portion of a target model, and determine an inclusion model of the occluded portion and a depth value image of the target modified portion;
[0011] A testing module, configured to perform a template test on the inclusion model to determine the relative position of each pixel point on the depth value image of the target modification portion and the inclusion model;
[0012] The modification module is used to determine a modification area of the target modification part according to the relative position, and perform a modification operation on the modification area.
[0013] Based on the same concept, the present application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements any of the above methods when executing the program.
[0014] Based on the same concept, the present application also provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to implement any of the methods described above.
[0015] From the above, it can be seen that the present application provides a method, device, electronic device and storage medium for local modification of a model, including: determining the occluded part and the target modification part of the target model, determining the inclusion model of the occluded part and the depth value image of the target modification part; performing a template test on the inclusion model to determine the relative position of each pixel point on the depth value image of the target modification part and the inclusion model; determining the modification area of the target modification part according to the relative position, and performing a modification operation on the modification area. After determining the spatial range of the occluded part through the inclusion model, the present application accurately determines the range of the area that needs to be modified in each location of the target modification part through the template testing method, thereby completing the modification of the target modification part in a manner that does not depend on the incision shape of the occluded part, improving the freedom and portability of cropping the target modification part, and improving the accuracy and precision of the modification area confirmation. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the embodiments of the present application 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 merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0017] Figure 1 A flowchart of a method for local modification of a model proposed in an embodiment of the present application;
[0018] Figure 2 A partial schematic diagram of a target model proposed in an embodiment of the present application;
[0019] Figure 3 A schematic diagram of a model of an occluded area and a corresponding inclusion model proposed in an embodiment of the present application;
[0020] Figure 4 A schematic diagram of the depth value of a target modification part proposed in an embodiment of the present application;
[0021] Figure 5 This is a schematic diagram of the principle of the shadow volume algorithm proposed in the embodiment of the present application;
[0022] Figure 6 This is a schematic diagram of the target modification part after removing the modification area proposed in the embodiment of the present application;
[0023] Figure 7 This is a schematic diagram of the effect after the target model proposed in the embodiment of the present application is modified;
[0024] Figure 8 A schematic diagram of the structure of a model local modification device proposed in an embodiment of the present application;
[0025] Figure 9 This is a schematic diagram of the electronic device structure proposed in an embodiment of the present application. DETAILED DESCRIPTION
[0026] In order to make the purpose, technical solutions and advantages of this specification more clear, this specification is further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
[0027] It should be noted that, unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should have the usual meanings understood by people with ordinary skills in the field to which this application belongs. The "first", "second" and similar words used in the embodiments of the present application do not indicate any order, quantity or importance, but are only used to distinguish different components. "Include" or "comprise" and similar words mean that the elements, objects or method steps that appear before the word cover the elements, objects or method steps listed after the word and their equivalents, without excluding other elements, objects or method steps. "Connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. "Up", "down", "left", "right" and the like are only used to indicate relative positional relationships. When the absolute position of the described object changes, the relative positional relationship may also change accordingly.
[0028] As mentioned in the background section, 3D models are increasingly being used in animation and game production, and the images of these models are becoming increasingly diverse. For example, in the current gaming market, there are a growing number of options for players to customize their characters, from hairstyles and fashion to accessories. With the introduction of these diverse models, interplay between models inevitably arises. For example, when a character wears a hat, the interplay between the character's hairstyle and the hat becomes a pressing issue. Current games generally avoid matching hats or only support a very limited selection of hat styles, limiting the flexibility and effectiveness of culling. Some currently available games have implemented simple clipping solutions to address the issue of clipping between accessories such as hats. This existing approach involves defining a clipping plane for the hat and clipping hair and accessories located on one side of this plane. This specific implementation involves passing the plane definition into the vertex shader. During the vertex shading phase, the positional relationship between pixels and the plane is determined, and the alpha value of the vertex color located above the plane is set to 0.0. When drawing hair using this method, since the hair on the upper side of the plane is completely transparent, it will not be displayed on the screen after color blending, achieving the purpose of removing hair outside the hat. However, this method of through-molding clipping can only clip based on the plane and can only handle the situation where the hat brim is flush. As a result, the form of accessories such as hats can only be relatively simple. At the same time, this "one-size-fits-all" approach cannot effectively guarantee the accuracy and precision of clipping or modification. With the diversification of accessory styles, on the one hand, the freedom of clipping accessory models is limited due to the shape of the cutouts of the accessory models, making it difficult to accurately determine the target modification area with current methods. On the other hand, with the development of the game and animation production fields and the diversification of accessory styles, the number of shaders for 3D models and accessory models has increased. Modifications may involve numerous shader modifications, which is a huge workload, difficult to maintain, and has poor portability, and low modification accuracy.
[0029] In view of the above-mentioned actual situation, the embodiment of the present application proposes a local modification scheme for the model. After determining the spatial range of the occluded part through the inclusion model, the template testing method is used to accurately determine the area range that needs to be modified in each location of the target modification part, thereby completing the modification of the target modification part in a manner that does not depend on the incision shape of the occluded part, thereby improving the freedom and portability of cropping the target modification part, and improving the accuracy and precision of the modification area confirmation.
[0030] like Figure 1 FIG. 1 is a flow chart of a method for local modification of a model proposed in this application, which specifically includes:
[0031] Step 101: Determine an occluded portion and a target modified portion of a target model, and determine an inclusion model of the occluded portion and a depth value image of the target modified portion.
[0032] In this step, the target model is a character or object model used for animation production or game production. These models are usually equipped with some accessories or pendants, so that there may be a problem of penetration between the model and these accessories. Therefore, the occluded parts of the target model are these accessory models or parts that will cause the problem of penetration, and the target modification parts are the parts of the target model where these accessory models or parts are worn or added. For example: a 3D character model wearing a hat, the hat is the occluded part, and the hair or head of the corresponding 3D character model is the target modification part; or a 3D tree model with decorative lights (such as a Christmas tree equipped with a five-pointed star light, etc.), the decorative lights are the occluded parts, and the corresponding part of the 3D tree model where the decorative lights are installed is the target modification part (such as the pointed top of the Christmas tree model, etc.), etc. In the target model, the relative positional relationship between the occluded parts and the target modification parts is generally set in advance, such as Figure 2 As shown, taking the character model wearing a hat as an example, after the character is created, the position where the hat is worn and the height of the hat have been set. Figure 2 The lotus leaf hat shown clearly shows parts such as hair protruding from the model. The lotus leaf hat is the occluded part, and the hair or head is the target part to be modified. For example, a character model wearing a hat is the target model, and the target part to be modified is the head part or hair part of the character model that is designed to wear the hat. The occluded part is the hat model worn on the head part or hair part. The hat model has a fixed shape and is attached to the head part or hair part of the character model.
[0033] Afterwards, the inclusion model of the occluded part is the coverage area model or shadow area model of the occluded part, etc. It is a closed geometric model, and the area included in it is the area that cannot be modified. Figure 3 The figure shows a schematic diagram of a shielding part (hat) and its corresponding inclusion in a specific application scenario, where Figure 3 a is the shielding part, i.e., the schematic diagram of the lotus leaf hat model; Figure 3 b is a schematic diagram of the inclusion model of the occluded part; Figure 3Figure c is a schematic diagram of an occlusion area superimposed with an inclusion. The inclusion is typically designed and created by the designer when creating the occlusion area. It is then integrated with the target model along with the occlusion area. The inclusion model is created based on the shape of the occlusion area, reflecting the internal space of the occlusion area and preventing modification. Using the inclusion model, the occlusion range of the occlusion area can be quickly determined, and thus the modification area of the target modification area can be quickly determined. For example, using a hat as an occlusion area, the target modification area is the hair. In a specific embodiment, a layer of the hat model can be copied first. The outer edge of the hat model is then found and extruded along it to create a model piece. The extrusion function is then repeated multiple times, combined with the engineer's input, to adjust the model's points, lines, and surfaces. This allows the inclusion model to have a larger range of physical movement than the character's hair when wearing the hat. Finally, after the inclusion model completely encompasses the hat's range of motion, the inclusion model is closed, making it a completely closed body. Additionally, when duplicating the hat model, you can slightly resize the duplicate by adjusting the PushValue (lowering it by approximately 0.05) to improve the fit of the inclusion with the hat model. In specific application scenarios, you can use the Extrude tool in 3D Max. The Extrude tool is a DCC modeling tool that allows you to extrude a face through an edge or face. This tool is simply for faster creation of the desired model. For example, using the hat model as an example, the extrusion process involves extrude a line from one edge of the hat, creating another line, adjusting the size of this line, and then extruding again, repeating this process until the desired inclusion is achieved. The new extruded surface is typically further from the center of the hat and extends diagonally downward along the hat (i.e., along the hair's range of motion). Finally, after completely enclosing the hair's range of motion, the model is closed. The extruded lines are merged into a single point. In specific application scenarios, approximately 15 to 20 extrusions are performed before the model is closed. Finally, the inclusion body is a conceptual model, which only provides a conceptual area during design to facilitate users or designers to make or modify the model. It is not an actual model and will not be displayed after the target model is completed.
[0034] After that, the depth value is the image depth, which refers to the number of bits actually required to store the grayscale or color of the image in the pixel depth. Assuming that the pixel depth of the image is 16 bits, but the number of bits used to represent the grayscale or color of the image is only 15 bits, the image depth of the image is 15. The image depth determines the possible number of colors for each pixel of the image, or the possible number of grayscale levels. For example: each pixel of a color image is represented by three components R, G, and B, each component uses 8 bits, and the pixel depth is 24 bits. In 3D computer graphics and computer vision, a depth map is an image or image channel that contains information about the distance from the surface of the scene object to the viewpoint, which is used to simulate the 3D shape or reconstruct them. More vividly, the depth range of an image is generally a range from 0 to 1. The depth represents the distance from each point on the image to the camera, lens or viewpoint position, where the viewpoint position or camera position is a set image channel position or shooting position. The depth value at the viewpoint position is 0, and the depth value at the position of the maximum line of sight of the viewpoint is 1. Then, the depth value of each point on the image can be determined, thereby generating a depth value image. For example Figure 4 The figure shows a schematic diagram of a depth value image of the hair on the model's head in a specific application scenario.
[0035] Finally, since the positional relationship between the occluded portion and the target modified portion on the target model has already been set, the positional relationship between the inclusion model and the depth value image is also set similarly accordingly.
[0036] Step 102: Perform a template test on the inclusion model to determine the relative position of each pixel point on the depth value image of the target modification part and the inclusion model.
[0037] In this step, after determining the inclusion model, i.e., the depth value image, a template test can be performed on the depth value image by means of a shadow body algorithm or the like. The template test is a test process performed during the drawing of the inclusion model, which can be divided into front drawing and back drawing, etc. When performing the template test, a depth test can be performed by means of a shadow body algorithm or the like, and the depth value of the point on the inclusion model determined during the drawing process is compared with the depth value of each pixel point on the depth value image of the target modification part, so that the positional relationship between each pixel point on the target modification part and the inclusion model can be determined.
[0038] In some embodiments, the stencil test can be performed using a Z-pass algorithm or a Z-fail algorithm. Taking the Z-fail algorithm as an example, the stencil value in the depth / stencil buffer is first cleared, and then the front of the inclusion model is rendered. If the depth test of a pixel fails, the stencil value of that pixel in the depth / stencil buffer is decremented by 1. The back of the inclusion model is rendered. If the depth test of a pixel fails, the stencil value of that pixel in the depth / stencil buffer is incremented by 1.
[0039] by Figure 5 For example, the largest irregular closed curve is a schematic diagram of a section of the inclusion body. Later, in graphics, it is stipulated that the normal line in the figure is facing the viewpoint, and the normal line is facing away from the viewpoint. Therefore, a face can be both the front and the back. The key is the viewpoint or camera position. Figure 5 In the figure, assuming point A is the viewpoint, the inclusion is divided into the front side C and the back side D, with the dotted line B marking the dividing line between the two sides. Figures a, b, and c are schematic diagrams of the target modification area, where points a and c are outside the inclusion model, and point b is inside. During the front template test, the test ray from point A to point C is blocked by point a, causing the depth test at point a to fail. The template value at point a is reduced by 1 to -1. Since the test rays at points b and c both reach point C, the depth tests pass, and the template values at points b and c remain unchanged at 0. Similarly, the template test is performed on the back side. Similarly, if the test ray is blocked by points a and b, the template values at points a and b are increased by 1, while the template value at point c remains unchanged. Ultimately, the template values at points a and c are 0, indicating they are outside the inclusion model; the template value at point b is 1, indicating they are inside the inclusion model. Through this template test, the template value of each pixel on the target modification area is determined, thereby ultimately determining the relative positional relationship between each pixel on the target modification area and the inclusion model. Of course, other algorithms, such as the Z-pass algorithm, can also be used to perform template testing on the image, thereby determining the relative position relationship between each pixel in the depth value image and the inclusion model.
[0040] Step 103: Determine a modification area of the target modification part according to the relative position, and perform a modification operation on the modification area.
[0041] In this step, after the relative position is determined through step 102, the part outside the package body can be used as the modification area of the target modification part, and then this modification area can be modified. The modification method can be deletion, hiding, setting transparency, not drawing or rendering, etc., so that the modification area is invisible to the user (visually) on the graphical user interface.
[0042] In specific application scenarios, such as Figure 6As shown in the figure, this is the modified model of the hair model in the above example, where the white area is the retained model after removing the modified model from the hair model, that is, the part that needs to be produced or displayed. Finally, the local modification of the target model is completed, forming the following Figure 7 The target model shown.
[0043] Afterward, the modified target model can be output. This can involve displaying the target model for engineers to make further adjustments or add additional components, such as drawing. Alternatively, the completed target model can be inspected and sent to downstream terminals for continued production steps. In other words, the target model can be output for storage, display, use, or further processing. The specific output method for the target model can be flexibly selected based on different application scenarios and implementation needs.
[0044] For example, for an application scenario where the method of this embodiment is executed on a single device, the target model can be directly output in a displayed manner on the display component (display, projector, etc.) of the current device, so that the operator of the current device can directly see the content of the target model from the display component.
[0045] For another example, in an application scenario where the method of this embodiment is executed on a system composed of multiple devices, the target model can be sent to other preset devices serving as receivers in the system, i.e., synchronization terminals, through any data communication method (wired connection, NFC, Bluetooth, wifi, cellular mobile network, etc.), so that the synchronization terminals can perform subsequent processing on them. Optionally, the synchronization terminal can be a preset server, which is generally set up in the cloud and serves as a data processing and storage center, capable of storing and distributing the target model; wherein the recipient of the distribution is the terminal device, and the holders or operators of these terminal devices can be binding engineers, downstream animation, game production engineers, animation, and game production companies’ public databases to record the work results of each engineer, etc.
[0046] For another example, in an application scenario where the method of this embodiment is executed on a system composed of multiple devices, the target model can be sent directly to a preset terminal device through any data communication method, and the terminal device can be one or more of the ones listed in the preceding paragraphs.
[0047] From the above description, it can be seen that a local modification method of a model in an embodiment of the present application includes: determining the occluded part and the target modification part of the target model, determining the inclusion model of the occluded part and the depth value image of the target modification part; performing a template test on the inclusion model to determine the relative position of each pixel point on the depth value image of the target modification part and the inclusion model; determining the modification area of the target modification part according to the relative position, and performing a modification operation on the modification area. After determining the spatial range of the occluded part through the inclusion model, the present application accurately determines the range of the area that needs to be modified at each location in the target modification part through the template testing method, thereby completing the modification of the target modification part in a manner that does not depend on the incision shape of the occluded part, improving the freedom and portability of cropping the target modification part, and improving the accuracy and precision of the modification area confirmation.
[0048] It should be noted that the method of the embodiment of the present application can be performed by a single device, such as a computer or server. The method of the embodiment of the present application can also be applied in a distributed scenario and completed by multiple devices working together. In the case of such a distributed scenario, one of the multiple devices may only perform one or more steps of the method of the embodiment of the present application, and the multiple devices will interact with each other to complete the method described.
[0049] It should be noted that the above description is of specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that described in the above embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order shown or the sequential order to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0050] In an optional exemplary embodiment, performing a template test on the inclusion model includes: performing a template test on the inclusion model using a shadow volume algorithm.
[0051] In this embodiment, shadow volume or shadow cone is a technology used in three-dimensional computer graphics to add shadows to the drawn scene. The shadow volume algorithm determines whether a given pixel of the test drawn image is in the shadow. The shadow volume itself needs to be drawn, but it is drawn to the template cache, not the final image. For the front side of each shadow volume, the value in the template cache is increased; for the back side, it is decreased. Utilizing the corresponding concept, it is added to the model modification, and the calculation of shadow is changed to the calculation of depth, and corresponding adjustments are made to complete the template test. Ultimately, the shadow volume algorithm can quickly, accurately and conveniently determine the template test results of each pixel on the inclusion model. The test results of the pixel points outside the inclusion model are consistent, and the test results of the pixel points inside the inclusion model are consistent. Therefore, based on the test results, the relative position relationship between each pixel point and the inclusion model can be accurately determined.
[0052] In an optional exemplary embodiment, the determination of the relative position of each pixel point on the depth value image of the target modification part and the inclusion model includes: determining the graphical front and graphical back of the inclusion model; drawing the graphical front to perform a front template test on each pixel point of the target modification part and determine the front test result of each pixel point; drawing the graphical back to perform a back template test on each pixel point of the target modification part and determine the back test result of each pixel point; determining the pixel points on the target modification part located outside the inclusion model and the pixel points located inside the inclusion model based on the front test result and the back test result. The position of each pixel point is determined by this specific calculation, thereby distinguishing the pixel points located inside the inclusion model from the pixel points located outside the inclusion model.
[0053] In this embodiment, the front and back sides of the inclusion model are first determined, such as Figure 5 As shown in the figure, taking viewpoint A as an example, surface C is the front of the inclusion model section, and surface D is the back of the inclusion model section. The dotted line B is the dividing line between the back and front. Afterwards, when performing a template test on the inclusion model, a template value calculation is required. The depth value of each pixel on the inclusion model is compared with the depth value of each pixel on the depth value image. During the drawing process, the template value of the corresponding pixel is obtained by performing corresponding processing on the pixel that fails the test.
[0054]
[0055] Among them, StencilValue is the template value of a pixel.
[0056] like Figure 5 As shown, a, b, and c are three exemplary pixel points. Since point a is located between the inclusion model and the viewpoint, it will fail the test when performing both the front and back template tests, so its final template value is 0-1+1=0. Point b is located inside the inclusion model. It will pass the test when performing the front template test, but fail the test when performing the back template test, so its final template value is 0+1=1. Point c is located behind the outside of the inclusion model, so it will pass the test when performing both the front and back template tests, so its final template value is 0. It can be seen that after the front test results are combined with the back test results, the template values of the pixels located outside the inclusion are all 0, while the template values of the pixels located inside the inclusion are all 1. Therefore, it is possible to determine whether each pixel of the target modification part is located outside or inside the inclusion model based on the front test results and the back test results, and then determine the relative position of each pixel point and the inclusion model.
[0057] In an optional exemplary embodiment, determining the modification area of the target modification portion based on the relative position and performing the modification operation on the modification area includes: using the area consisting of pixels located outside the inclusion model as the modification area, and performing a non-rendering operation on the modification area. Thus, the corresponding portion of the model is modified without rendering, thereby reducing the workload and difficulty of model creation for engineers and improving overall efficiency.
[0058] In this embodiment, if Figure 6 The figure shows a schematic diagram of the target modification part after the modification area is removed, where the white part is the retained part. In some embodiments, when making a model, since the production processes for colored objects and transparent objects are two completely different sets of processes, when addressing problems such as mold penetration, if a transparent drawing method is used, for a hair, part may need to be drawn in color and part may need to be drawn transparently. The two drawing methods are completely different, which will increase the workload of engineers, and the splicing effect after drawing may not be very accurate. Therefore, by not drawing, the corresponding pixel points are not drawn directly, thereby fundamentally reducing the workload of engineers, being simple and accurate, and improving overall efficiency.
[0059] In an optional exemplary embodiment, determining the occluded part and the target modified part of the target model includes: determining the attached attachment on the target model, and judging whether the attached attachment and the attached part of the target model are interspersed; if so, using the attached attachment as the occluded part, and using the attached part of the target model to which the occluded part is attached as the target modified part.
[0060] In this embodiment, the component that penetrates the model is generally an attached accessory on the target model. The attached accessory is an additional component of the target model, which can be various components, such as a hat, brooch, tie, etc. of a character model. When these components are set on the target model, they usually have an attachment site, such as a hat attached to the head and a tie attached to the chest. Then, the occlusion site and the target modification site can be determined by directly checking whether the attached component and the attachment site intersect on the model. Taking a character model wearing a hat as an example, the character model itself is the target model, and the target modification site is the head site or hair site of the character model used to wear the hat, and the occlusion site is the hat model worn on the head site or hair site. The hat model has a fixed shape and is attached to the head site or hair site of the character model.
[0061] In an optional exemplary embodiment, determining the inclusion model of the occluded part includes: copying the model of the occluded part to generate an initial model; determining the maximum movement range of the target modification part, determining the edge vertices of the initial model, and performing multiple extrusion operations on the edge vertices according to the maximum movement range, so that the distance between the extruded vertices and the center of the initial model is greater than the distance between the vertices before extrusion and the center of the initial model; in response to the intermediate model composed of vertices generated by the extrusion operation enclosing the maximum movement range of the target modification part, closing the intermediate model to generate the inclusion model. In this way, the corresponding inclusion model is quickly generated.
[0062] In this embodiment, taking a hat model as an example, a layer of the hat model can be copied to form an initial model. The outer edge of the hat model is then found and extruded along the outer edge to extrude the model piece. The extrusion operation involves extruding a circle of lines along the hat's edge to create another circle of lines. This circle is then resized and extruded again, repeating this process to achieve the desired inclusion shape. The newly extruded surface is generally farther from the center of the hat and extends diagonally downward along the hat (i.e., extending along the range and motion of the hair). Finally, after completely enclosing the range of motion of the hair, the model is closed. The extrusion function is then repeated multiple times, and the points, lines, and surfaces of the model are adjusted based on the engineer's input, so that the inclusion model has a larger range of motion than the character's hair when wearing the hat. Finally, after the inclusion model completely encloses the range of motion of the hat, it is closed, making it a completely closed body. In addition, when copying the hat model, you can make the copied model slightly smaller. You can adjust the PushValue of the model (down by about 0.05) to improve the matching degree between the inclusion and the hat model.
[0063] In an optional exemplary embodiment, determining the depth value image of the target modification part includes: determining the nearest camera position and the corresponding farthest camera position, and determining the depth value of each pixel point based on the positional relationship between each pixel point of the target modification part and the nearest camera position or the farthest camera position to generate the depth value image.
[0064] In this embodiment, at a pre-set viewpoint position, the viewpoint position is the closest camera position, and the farthest viewpoint position is the farthest camera position. The depth value at the viewpoint position on a line of sight ray is 0, and the depth value at the farthest viewpoint position is 1. During the animation or game production process, a position for capturing the model is set for each model, which is the viewpoint position. When playing the animation, the image the user sees is the image captured through this point. In a specific scene, this can be the position of the camera. The line of sight is the light emitted or received from this viewpoint, and the farthest viewpoint position is the farthest position in the image captured through this viewpoint. Thus, each pixel located at the target modification location corresponds to a line of sight ray (a ray formed by two points). Therefore, the pixel's position on the line of sight ray relative to the closest camera position or the farthest camera position is fixed, and its depth value is ultimately determined within the range of 0 to 1. Finally, a depth value image is generated. It can be seen that the depth values of pixels on the same section on the depth value image may be the same, but due to the relative relationship between each pixel and the viewpoint, the corresponding line of sight rays are different. Therefore, the actual position of each pixel can also be determined based on the depth value image.
[0065] In an optional exemplary embodiment, generating the depth value image includes adjusting the color parameters of each pixel to generate the depth value image as a grayscale image, thereby accelerating processing speed and improving overall processing efficiency.
[0066] In this embodiment, since adding color information to each pixel involves multiple channels, and adding color itself is not very useful for local modification, and the depth value image does not require color information, the depth value image can be generated as a grayscale image to speed up processing. For example, when drawing, you can set the BlendState's WriteMask to 0.
[0067] Based on the same concept, corresponding to any of the above-mentioned embodiment methods, the present application also provides a model local modification device.
[0068] refer to Figure 8 , the model local modification device includes:
[0069] A determination module 810 is configured to determine an occluded portion and a target modified portion of a target model, and determine an inclusion model of the occluded portion and a depth value image of the target modified portion;
[0070] A testing module 820 is configured to perform a template test on the inclusion model to determine the relative position of each pixel point of the depth value image of the target modification portion and the inclusion model;
[0071] The modification module 830 is configured to determine a modification area of the target modification portion according to the relative position, and perform a modification operation on the modification area.
[0072] For the convenience of description, the above devices are described as being divided into various modules according to their functions. Of course, when implementing the embodiments of the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.
[0073] The device of the above embodiment is used to implement the corresponding model local modification method in the above embodiment, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0074] In an optional exemplary embodiment, the testing module 820 is further configured to:
[0075] The template test is performed on the inclusion model using a shadow volume algorithm.
[0076] In an optional exemplary embodiment, the testing module 820 is further configured to:
[0077] determining a graphical front side and a graphical back side of the inclusion model;
[0078] Drawing the graphical front to perform a front template test on each pixel point of the target modification portion, and determining a front test result of each pixel point;
[0079] Drawing the back surface of the graphics to perform a back surface template test on each pixel point of the target modification portion, and determining a back surface test result of each pixel point;
[0080] The pixel points located outside the inclusion model and the pixel points located inside the inclusion model on the target modification portion are determined according to the front test result and the back test result.
[0081] In an optional exemplary embodiment, the modification module 830 is further configured to:
[0082] An area composed of pixel points located outside the inclusion model is used as the modification area, and a no-drawing operation is performed on the modification area.
[0083] In an optional exemplary embodiment, the determining module 810 is further configured to:
[0084] Determining an attached attachment on the target model, and judging whether the attached attachment intersects with an attached portion of the target model;
[0085] If so, the attached attachment is used as the occluding part, and the attached part on the target model to which the occluding part is attached is used as the target modified part.
[0086] In an optional exemplary embodiment, the determining module 810 is further configured to:
[0087] Copying the model of the blocked part to generate an initial model;
[0088] Determining a maximum movement range of the target modification portion, determining edge vertices of the initial model, and performing multiple extrusion operations on the edge vertices according to the maximum movement range, so that the distance between the extruded vertices and the center of the initial model is greater than the distance between the vertices before extrusion and the center of the initial model;
[0089] In response to the intermediate model composed of vertices generated by the extrusion operation enclosing the maximum movement range of the target modification part, the intermediate model is closed to generate the inclusion model.
[0090] In an optional exemplary embodiment, the determining module 810 is further configured to:
[0091] Determine the nearest camera position and the corresponding farthest camera position, and determine the depth value of each pixel point according to the positional relationship between each pixel point of the target modification part and the nearest camera position or the farthest camera position to generate the depth value image.
[0092] In an optional exemplary embodiment, the determining module 810 is further configured to:
[0093] The color parameters of the respective pixels are adjusted to generate the depth value image which is a grayscale image.
[0094] Based on the same concept, corresponding to any of the above-mentioned embodiments, 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 model local modification method described in any of the above embodiments is implemented.
[0095] Figure 910 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.
[0096] 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.
[0097] 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.
[0098] 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.
[0099] 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.).
[0100] The bus 1050 comprises a path for transmitting information between the various components of the device (eg, the processor 1010 , the memory 1020 , the input / output interface 1030 , and the communication interface 1040 ).
[0101] 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.
[0102] The electronic device of the above embodiment is used to implement the corresponding model local modification method in any of the above embodiments, and has the beneficial effects of the corresponding method embodiment, which will not be repeated here.
[0103] Based on the same concept, corresponding to any of the above-mentioned embodiments and methods, the present application also provides a computer-readable storage medium, which stores computer instructions, and the computer instructions are used to enable the computer to execute the model local modification method described in any of the above embodiments.
[0104] The computer-readable media of this embodiment include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. The information can be computer-readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, read-only compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device.
[0105] The computer instructions stored in the storage medium of the above embodiment are used to enable the computer to execute the model local modification method described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.
[0106] Those skilled in the art should understand that the discussion of any of the above embodiments is merely illustrative and is not intended to imply that the scope of the present application (including the claims) is limited to these examples. Within the scope of the present application, the technical features in the above embodiments or different embodiments may be combined, the steps may be implemented in any order, and there are many other variations of the different aspects of the embodiments of the present application as described above, which are not provided in detail for the sake of simplicity.
[0107] In addition, for simplicity of description and discussion, and in order not to make the embodiment of the application difficult to understand, the known power supply / ground connection with integrated circuit (IC) chip and other components may or may not be shown in the accompanying drawings provided. In addition, the device can be shown in the form of a block diagram to avoid making the embodiment of the application difficult to understand, and this also takes into account the following fact, that is, the details of the embodiment of these block diagram devices are highly dependent on the platform to be implemented in the embodiment of the application (that is, these details should be fully within the scope of understanding of those skilled in the art). When specific details (for example, circuit) are set forth to describe exemplary embodiments of the application, it will be apparent to those skilled in the art that the embodiment of the application can be implemented without these specific details or when these specific details are changed. Therefore, these descriptions should be considered to be illustrative rather than restrictive.
[0108] Although the present invention has been described in conjunction with specific embodiments thereof, many alternatives, modifications, and variations of these embodiments will be apparent to those skilled in the art based on the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may utilize the embodiments discussed.
[0109] The embodiments of the present application are intended to cover all such substitutions, modifications, and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application should be included in the scope of protection of this application.
Claims
1. A method for local modification of a model, characterized in that: include: Determining an occluded portion and a target modified portion of the target model, and determining an inclusion model of the occluded portion and a depth image of the target modified portion; wherein the inclusion model is a closed model obtained by performing an extrusion operation along the outer edge of the target model to obtain a larger range than the movable range of the target modified portion; Performing a template test on the inclusion model to determine the relative position of each pixel point on the depth value image of the target modification part and the inclusion model; A modification area of the target modification part is determined according to the relative position, and a modification operation is performed on the modification area.
2. The method according to claim 1, characterized in that The performing of template testing on the inclusion model includes: The template test is performed on the inclusion model using a shadow volume algorithm.
3. The method according to claim 2, characterized in that Determining the relative position of each pixel point on the depth value image of the target modification part and the inclusion model includes: determining a graphical front side and a graphical back side of the inclusion model; Drawing the graphical front to perform a front template test on each pixel point of the target modification portion, and determining a front test result of each pixel point; Drawing the back surface of the graphics to perform a back surface template test on each pixel point of the target modification portion, and determining a back surface test result of each pixel point; The pixel points located outside the inclusion model and the pixel points located inside the inclusion model on the target modification portion are determined according to the front test result and the back test result.
4. The method according to claim 3, characterized in that Determining a modification area of the target modification part according to the relative position, and performing a modification operation on the modification area, includes: An area composed of pixel points located outside the inclusion model is used as the modification area, and a no-drawing operation is performed on the modification area.
5. The method according to claim 1, wherein The determining of the blocked portion and the target modified portion of the target model includes: Determining an attached attachment on the target model, and judging whether the attached attachment intersects with an attached portion of the target model; If so, the attached attachment is used as the occluding part, and the attached part on the target model to which the occluding part is attached is used as the target modified part.
6. The method according to claim 1, characterized in that Determining the inclusion model of the occluded part includes: Copying the model of the blocked part to generate an initial model; Determining a maximum movement range of the target modification portion, determining edge vertices of the initial model, and performing multiple extrusion operations on the edge vertices according to the maximum movement range, so that the distance between the extruded vertices and the center of the initial model is greater than the distance between the vertices before extrusion and the center of the initial model; In response to the intermediate model composed of vertices generated by the extrusion operation enclosing the maximum movement range of the target modification part, the intermediate model is closed to generate the inclusion model.
7. The method according to claim 1, characterized in that The determining of the depth value image of the target modification part includes: Determine the nearest camera position and the corresponding farthest camera position, and determine the depth value of each pixel point according to the positional relationship between each pixel point of the target modification part and the nearest camera position or the farthest camera position to generate the depth value image.
8. The method according to claim 7, characterized in that The step of generating the depth value image includes: The color parameters of the respective pixels are adjusted to generate the depth value image which is a grayscale image.
9. A model local modification device, characterized in that: include: a determination module, configured to determine an occluded portion and a target modified portion of a target model, and determine an inclusion model of the occluded portion and a depth image of the target modified portion; wherein the inclusion model is a closed model obtained by performing an extrusion operation along the outer edge of the target model to obtain a larger range than the movable range of the target modified portion; A testing module, configured to perform a template test on the inclusion model to determine the relative position of each pixel point on the depth value image of the target modification portion and the inclusion model; The modification module is used to determine a modification area of the target modification part according to the relative position, and perform a modification operation on the modification area.
10. An electronic device comprising 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 computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to implement the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Method for rendering contour edges of models
CN102708585A
Environment shielding rendering method, environment shielding rendering device, computer readable storage medium and electronic equipment.
CN112734896A