A method and device for projecting decal material
By obtaining the depth information of the decal material in UE4 and combining with custom parameters to judge, the projection of the decal material in the particle system is realized, solving the problem that cannot be applied in the particle system in the existing technology, and improving the flexibility and control of art creation.
Patent Information
- Application Number
- CN202111396641.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-23
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2041-11-23
AI Technical Summary
In the prior art, decal material cannot achieve effects in the particle system in UE4, and the existing control methods cannot specifically set whether the receptor model accepts decal material, resulting in inconvenient art process creation.
By obtaining the scene depth and pixel depth of the decal material, the preset material function is used to convert it into texture coordinates, and combining the custom depth and template of the receptor model to determine whether it meets the decal projection conditions, the projection of the decal material in the particle system is achieved.
The application of decal material in particle systems is realized, which is suitable for art process creation, and allows the receptor model to flexibly set whether to accept specific decal effects, avoiding the problem that the receptor cannot be set in specific ways in the prior art.
Smart Images

Figure CN114119691B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of computer graphics processing, in particular to a method and a device for projecting decal material. Background Art
[0002] Decal materials are a very common special effects technique in game development. Their effect is to project a texture onto a receptor surface like a projection, thus displaying a decal effect. In UE4 (Unreal Engine 4), decal receptors are generated through Blueprint logic control and a decal material is assigned to this DecalActor. However, this method cannot implement decal material effects within a particle system, making it unsuitable for art workflow creation. Furthermore, this control method using decal receptors can only be set to accept all or none of the decal materials, and cannot be specifically set to accept only some decal materials. Summary of the Invention
[0003] In view of the fact that the above-mentioned method of generating DecalActor through blueprint logic control cannot realize the decal material effect in the particle system and is not suitable for art process creation, and the problem that unchecking ReceivesDecals to prevent the decal material from being applied to the receptor will make the receptor unable to accept all decal materials and cannot be specifically set for the receptor, an embodiment of the present invention is proposed to provide a method for projecting decal materials and a corresponding device for projecting decal materials to overcome the above-mentioned problems or at least partially solve the above-mentioned problems.
[0004] An embodiment of the present invention discloses a method for projecting a decal material, comprising:
[0005] Get the scene depth and pixel depth corresponding to the decal material;
[0006] Converting the scene depth and pixel depth according to a preset material function to obtain texture coordinates of the decal material; wherein the preset material function is used to project the decal material into a particle system;
[0007] Extract custom depth and custom template corresponding to the receptor model;
[0008] Determining whether the receptor model meets the decal projection conditions based on the custom depth and the custom template;
[0009] When the receptor model meets the decal projection condition, the decal material is projected onto the surface of the receptor model according to the texture coordinates.
[0010] Optionally, converting the scene depth and pixel depth according to a preset material function to obtain texture coordinates of the decal material includes:
[0011] Converting the scene depth and pixel depth according to a preset material function to obtain projection coordinates;
[0012] Convert the projection coordinates into coordinates in the particle system;
[0013] The texture coordinates of the decal material are obtained according to the coordinate transformation in the particle system.
[0014] Optionally, converting the scene depth and pixel depth according to a preset material function to obtain projection coordinates includes:
[0015] Performing a division operation on the scene depth and the pixel depth to obtain a first coordinate;
[0016] Obtain the absolute world coordinates of the pixel corresponding to the decal material and the absolute world coordinates of the camera;
[0017] performing a multiplication operation on the pixel absolute world coordinate and the first coordinate to obtain a second coordinate;
[0018] An addition operation is performed on the second coordinate and the absolute world coordinate of the camera to obtain a projection coordinate.
[0019] Optionally, converting the projection coordinates into coordinates in the particle system includes:
[0020] Obtain the relative coordinates of the decal material in the particle coordinate system;
[0021] performing a subtraction operation on the relative coordinates under the particle system and the projected coordinates to obtain a third coordinate;
[0022] The third coordinate is transformed to obtain the coordinate in the particle system.
[0023] Optionally, obtaining the texture coordinates of the decal material according to the coordinate conversion in the particle system includes:
[0024] The coordinates in the particle system are normalized to obtain the texture coordinates of the decal material.
[0025] Optionally, judging whether the receptor model meets the decal projection condition according to the custom depth and the custom template includes:
[0026] Performing a subtraction operation on the custom depth and the scene depth to obtain a depth difference;
[0027] When the depth difference is less than a preset first threshold, it is determined that the receptor model does not meet the decal projection condition.
[0028] Optionally, the determining whether the receptor model meets the decal projection condition according to the custom depth and the custom template further includes:
[0029] When the depth difference is greater than or equal to a preset first threshold, obtaining a material template value corresponding to the decal material;
[0030] If the custom template and the material template values are consistent, the receptor model is determined to meet the decal projection conditions;
[0031] If the custom template is inconsistent with the material template value, it is determined that the receptor model does not meet the decal projection conditions.
[0032] The embodiment of the present invention further discloses a device for projecting decal material, comprising:
[0033] Depth acquisition module, used to obtain the scene depth and pixel depth corresponding to the decal material;
[0034] a texture coordinate conversion module, configured to convert the scene depth and pixel depth according to a preset material function to obtain texture coordinates of the decal material; wherein the preset material function is used to realize projection of the decal material in the particle system;
[0035] Custom depth extraction module, used to extract custom depth and custom template corresponding to the receptor model;
[0036] a judgment module, configured to judge whether the receptor model meets the decal projection condition according to the custom depth and the custom template;
[0037] A decal material projection module is used to project the decal material onto the surface of the receptor model according to the texture coordinates when the receptor model meets the decal projection conditions.
[0038] An embodiment of the present invention further discloses an electronic device, including:
[0039] A processor and a storage medium, wherein the storage medium stores machine-readable instructions executable by the processor. When the electronic device is running, the processor executes the machine-readable instructions to perform the method as described in any one of the embodiments of the present invention.
[0040] An embodiment of the present invention further discloses a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the method according to any one of the embodiments of the present invention is executed.
[0041] The embodiments of the present invention include the following advantages:
[0042] In an embodiment of the present invention, a method for projecting a decal material is provided. By pre-creating a material function, the preset material function can project and transform the texture of the preset material function, so that the texture coordinates of the transformed decal material can be applied in the particle system, realizing the decal material effect, which is suitable for art process creation. At the same time, by setting a custom depth and a custom template, the receptor model is further identified according to these two parameters. Finally, the receptor model that needs to accept the decal material is set to perform corresponding projection, while the receptor model that does not need to accept the decal material is not projected. This allows the receptor model to flexibly set whether to accept a specific decal effect, avoiding the method of unchecking ReceivesDecals to prevent the decal material from being applied to the receptor model, which will make the receptor model unable to accept all decal materials and cannot set the receptor model specifically. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the description of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0044] Figure 1 It is a schematic diagram of the decal material effect in the prior art;
[0045] Figure 2 This is a flowchart of the steps of a method for projecting decal material provided by an embodiment of the present invention;
[0046] Figure 3 is a schematic diagram of a node connection provided by an embodiment of the present invention;
[0047] Figure 4 is a schematic diagram of another node connection provided by an embodiment of the present invention;
[0048] Figure 5 is a schematic diagram of another node connection provided by an embodiment of the present invention;
[0049] Figure 6 is a schematic diagram of another node connection provided by an embodiment of the present invention;
[0050] Figure 7A This is a schematic diagram of a decal material effect provided by an embodiment of the present invention where a model is not set to accept a special material;
[0051] Figure 7BThis is a schematic diagram of setting a model to accept a decal material effect of a special material provided by an embodiment of the present invention;
[0052] Figure 8 This is a structural block diagram of a device for projecting decal material provided by an embodiment of the present invention;
[0053] Figure 9 It is a structural block diagram of an electronic device of the present invention;
[0054] Figure 10 It is a structural block diagram of a computer-readable storage medium of the present invention. DETAILED DESCRIPTION
[0055] To make the above-mentioned objects, features, and advantages of the present invention more clearly understood, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments. It should be understood that the embodiments described are only a portion of the embodiments of the present invention, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are also within the scope of protection of the present invention.
[0056] In the prior art, in UE4 (Unreal Engine 4), decal materials are subject to the following two usage restrictions:
[0057] First, decal materials are used in conjunction with the DecalComponent. To spawn a decal material at a specific location, you need to use Blueprint logic to create a DecalActor as the decal recipient and assign the decal material to this DecalActor. The downside of this approach is that, since artists rarely use Blueprint tools, art production is not straightforward. If artists want to implement decal material effects in a particle system, it's not straightforward.
[0058] Secondly, the receptors of existing decal materials are applied by default to all receptor Actors, that is, as long as it is an object surface, the decal material will respond to this object and be projected onto it. Figure 1 As shown, to prevent decal materials from being projected onto an object's surface, the current method is to uncheck the ReceivesDecals option in the receptor model's details panel (UE4 has it checked by default). However, this also has two problems: first, it's inconvenient to manage in a standardized manner; second, models with this option checked will not accept all decal effects. If a model in the scene needs to accept decal A but not decal B, there's no way to handle this.
[0059] Therefore, the existing decal material control solution has the following problems: the method of generating DecalActor through Blueprint logic control cannot realize the decal material effect in the particle system, which is not suitable for art process creation. The method of unchecking ReceivesDecals to prevent decal materials from being applied to the receptor will make the receptor unable to accept all decal materials, and the receptor cannot be specifically set.
[0060] In order to solve the above technical problems, an embodiment of the present invention provides a method for projecting a decal material, which comprises obtaining the scene depth and pixel depth corresponding to the decal material; converting the scene depth and pixel depth according to a preset material function to obtain the texture coordinates of the decal material; extracting the custom depth and custom template corresponding to the receptor model; judging whether the receptor model meets the decal projection conditions based on the custom depth and custom template; and when the receptor model meets the decal projection conditions, projecting the decal material onto the surface of the receptor model based on the texture coordinates. By pre-creating a preset material function, the preset material function can project the texture of the preset material function, so that the texture coordinates of the converted decal material can be applied in the particle system, achieving a decal material effect, which is suitable for art process creation. At the same time, by setting a custom depth and a custom template, the receptor model is further identified according to these two parameters. Finally, the receptor model that needs to accept the decal material is projected accordingly, while the receptor model that does not need to accept the decal material is not projected. This allows the receptor model to flexibly set whether to accept a specific decal effect, avoiding the problem of unchecking ReceivesDecals to prevent the decal material from being applied to the receptor model, which will make the receptor model unable to accept all decal materials and cannot set the receptor model specifically.
[0061] Reference Figure 2 , shows a flowchart of a method for projecting decal material according to an embodiment of the present invention, which may include the following steps:
[0062] Step 201, obtaining the scene depth and pixel depth corresponding to the decal material;
[0063] Among them, scene depth SceneDepth indicates that the material does not calculate the depth corresponding to transparent objects, and pixel depth PixelDepth is used to indicate that the material calculates the depth corresponding to transparent objects.
[0064] Step 202: converting the scene depth and pixel depth according to a preset material function to obtain texture coordinates of the decal material; wherein the preset material function is used to project the decal material into the particle system;
[0065] Among them, the preset material function MaterialFunction is a pre-created material function used to realize the projection of decal materials in the particle system. Specifically, the preset material function projects a normal texture coordinate in the Z-axis direction by projecting the texture of the decal material to remove the influence of transparent objects. Because SceneDepth is obtained in the Pre-pass / Z-pass rendering stage, transparent objects are not rendered in this stage. After conversion, the texture coordinates of the decal material can be used in the particle system.
[0066] In an embodiment of the present invention, the scene depth and pixel depth of the decal material are converted according to a preset material function to obtain the texture coordinates of the decal material, so that the art process can also use the decal material to create in the particle system.
[0067] Step 203, extracting the custom depth and custom template corresponding to the receptor model;
[0068] The receptor model refers to the model on which the decal material needs to be projected. In a specific implementation, the receptor model can be any model in the game scene, such as a wall model, a building model, a road model, etc. The embodiment of the present invention does not limit this.
[0069] In this embodiment of the present invention, the receptor model has a corresponding custom depth (CustomDepth) and custom stencil (CustomStencil). These are set by the artist when creating the model. The custom stencil represents the decal materials accepted by the receptor model. Therefore, by setting the custom stencil, the receptor model can only accept certain specific decal materials.
[0070] Step 204 , determining whether the receptor model meets the decal projection conditions based on the custom depth and the custom template;
[0071] In an embodiment of the present invention, whether the receptor model meets the decal projection conditions can be determined based on the custom depth and the custom template. For receptor models that meet the decal projection conditions, the decal material needs to be projected onto the surface of the receptor model, while for receptor models that do not meet the decal projection conditions, the decal material does not need to be projected onto the surface of the receptor model.
[0072] Step 205 : When the receptor model meets the decal projection condition, project the decal material onto the surface of the receptor model according to the texture coordinates.
[0073] In an embodiment of the present invention, when the receptor model meets the decal projection conditions, the decal material can be projected onto the surface of the receptor model according to the texture coordinates to achieve the decal material effect.
[0074] In a preferred embodiment of the present invention, step 202 specifically includes the following sub-steps:
[0075] The scene depth and pixel depth are converted according to a preset material function to obtain projection coordinates; the projection coordinates are converted into coordinates in a particle system; and texture coordinates of the decal material are obtained according to the coordinate conversion in the particle system.
[0076] Specifically, the scene depth and pixel depth are converted according to the preset material function MaterialFunction to obtain the projection coordinates. This step mainly projects an ordinary texture coordinate in the Z-axis direction to remove the influence of transparent objects, because SceneDepth is obtained during the Pre-pass / Z-pass rendering stage, and transparent objects are not rendered at this stage. Then, the projection coordinates are converted into coordinates in the particle system. This step is mainly to enable the decal material to be used in the particle system. Finally, the texture coordinates of the decal material can be obtained according to the coordinate conversion in the particle system, so that the texture coordinates can be used in the subsequent steps to project the decal material onto the surface of the receptor model.
[0077] In a preferred embodiment of the present invention, converting the scene depth and pixel depth according to a preset material function to obtain projection coordinates includes:
[0078] Performing a division operation on the scene depth and the pixel depth to obtain a first coordinate; obtaining a pixel absolute world coordinate corresponding to the decal material and an absolute world coordinate of the camera; performing a multiplication operation on the pixel absolute world coordinate and the first coordinate to obtain a second coordinate; and performing an addition operation on the second coordinate and the absolute world coordinate of the camera to obtain a projection coordinate.
[0079] Among them, the camera's absolute world coordinate CameraPosition is used to represent the absolute coordinates of the camera shooting the decal material in the world coordinate system, and the pixel absolute world coordinate AbsoluteWorldPosition is used to represent the absolute coordinates corresponding to each pixel point in the decal material in the world coordinate system.
[0080] Specifically, UE4 provides some conversion nodes that can be used to perform coordinate conversion by connecting node pairs in UE4. In a specific implementation, the Divide node can be used to divide the scene depth SceneDepth and the pixel depth PixelDepth to obtain the first coordinate. Then, the absolute world coordinate AbsoluteWorldPosition of the pixel corresponding to the decal material and the absolute world coordinate CameraPosition of the camera are obtained, and the Multiply node is used to multiply the absolute world coordinate of the pixel and the first coordinate to obtain the second coordinate. Finally, the Add node is used to add the second coordinate and the absolute world coordinate of the camera to obtain the projected coordinate.
[0081] As an example, Figure 3 As shown, in UE4, by connecting the SceneDepth node and the PixelDepth node to the Divide node for division, connecting the Divide node to the AbsoluteWorldPosition node and the Multiply node for multiplication, and then connecting the Multiply node to the CameraPosition node, the final required projection coordinates can be output.
[0082] In a preferred embodiment of the present invention, converting the projection coordinates into coordinates in the particle system includes:
[0083] Obtaining the relative coordinates of the decal material in the particle coordinate system; performing a subtraction operation on the relative coordinates in the particle coordinate system and the projection coordinates to obtain a third coordinate; and converting the third coordinates to obtain coordinates in the particle system.
[0084] Specifically, the node for obtaining the projection coordinates is WorldPositionBehindTranslucency, which represents the world position after transparent material processing. The node for obtaining the relative coordinates of the particle coordinate system corresponding to the decal material is ParticlePosition. By connecting the WorldPositionBehindTranslucency node and the Particle Position node to the Subtract node for subtraction, and then connecting the Subtract node to the Transform Vector node for transformation, the coordinates of the decal material in the particle system are obtained, such as Figure 4 shown.
[0085] In a preferred embodiment of the present invention, the step of converting the coordinates in the particle system to obtain the texture coordinates of the decal material includes:
[0086] The coordinates in the particle system are normalized to obtain the texture coordinates of the decal material.
[0087] In an embodiment of the present invention, the coordinates in the particle system may be normalized using a Saturate node to obtain texture coordinates of the decal material.
[0088] In the specific implementation, you can also connect the coordinate node and the particle decal node in the particle system to the Divide node, and connect the data of the Offset channel of the Particle Decal node to the Add node, and connect the Mask node, scaleUVByCenter node, Saturate node and OutputUV node in sequence, such as Figure 5 As shown in the figure, connecting the data of the Offset channel of the Particle Decal node to the Add node can offset the coordinates to the center of the origin; the Mask node is used to extract the data of the RG channel as the texture coordinate UV; the scaleUVByCenter node is used to scale the coordinates according to the center of the origin. If no scaling is required, this node can be ignored; the Saturate node is used to normalize the data to the range of (0, 1); and the OutputUV node is used to output the texture coordinates.
[0089] In a preferred embodiment of the present invention, step 204 may specifically include the following sub-steps:
[0090] A subtraction operation is performed on the custom depth and the scene depth to obtain a depth difference; when the depth difference is less than a preset first threshold, it is determined that the receptor model does not meet the decal projection condition.
[0091] The preset first threshold is a pre-set depth threshold used to determine whether the receptor model meets the decal projection conditions. For example, assuming the preset first threshold is set to zero, when the depth difference is less than zero, it indicates that the receptor model does not meet the decal projection conditions; when the depth difference is greater than or equal to zero, it indicates that the receptor model meets the decal projection conditions.
[0092] In an embodiment of the present invention, a depth difference can be obtained by subtracting the custom depth from the scene depth, and then the size of the depth difference can be judged. When the depth difference is less than a preset first threshold, it is determined that the receptor model does not meet the decal projection conditions. In a specific implementation, the preset first threshold can be set to 0. This processing is mainly to distinguish whether the custom depth CustomDepth node is checked on the receptor model. If the CustomDepth node is checked, the depth difference of CustomDepth minus SceneDepth will be a positive value or 0. If the CustomDepth node is not checked, the depth difference will be less than 0. Based on this feature, the receptor object model can be identified. When the depth difference is less than 0, it is determined that the receptor model does not meet the decal projection conditions.
[0093] In a preferred embodiment of the present invention, the determining whether the receptor model meets the decal projection condition based on the custom depth and the custom template further includes:
[0094] When the depth difference is greater than or equal to a preset first threshold, the material template value corresponding to the decal material is obtained; if the custom template is consistent with the material template value, it is determined that the receptor model meets the decal projection conditions; if the custom template is inconsistent with the material template value, it is determined that the receptor model does not meet the decal projection conditions.
[0095] In this embodiment of the present invention, when the depth difference is greater than or equal to a preset first threshold, it indicates that the receptor model has the CustomDepth node enabled and can accept decal materials. At this point, it is possible to further determine whether the receptor model accepts the currently processed decal material. Specifically, by obtaining the material template value corresponding to the decal material, if the custom template and the material template values are consistent, the receptor model is determined to meet the decal projection conditions; if the custom template and the material template values are inconsistent, the receptor model is determined to not meet the decal projection conditions.
[0096] As an example, Figure 6As shown, by connecting the SceneTextureCustomDepth node and the SceneTextureSceneDepth node to the Subtract node for subtraction, connecting the Subtract node and the Input In Texture node to the If node, further connecting the If node and the SceneTextureCustomStencil node to the Multiply node for multiplication, and connecting the OutputColor node to output the final texture color value. The SceneTextureCustomDepth node is used to obtain the custom depth value of the receptor model, and the If node is used to determine the size of the depth difference. When CustomDepth is greater than SceneDepth, it is not connected to the Input In Texture node, but instead connected to SceneColor to obtain the scene color. When CustomDepth is less than or equal to SceneDepth, it is connected to the Input InTexture node to obtain the texture map corresponding to the decal material.
[0097] In addition, before connecting the SceneTextureCustomStencil node, you also need to connect the SceneTextureCustomStencil node to a Mask node to extract the color value, and then connect the Mask node to another If node. This If node is used to determine whether the custom stencil of the receptor model is greater than the material stencil value corresponding to the decal material. The SceneTextureCustomStencil node is used to obtain the custom stencil of the receptor model.
[0098] like Figure 7A This is a diagram of the effect of a decal material without setting up a model to accept a special material, where some unwanted decal materials are projected onto the square receptor model, such as Figure 7B This is a diagram of the effect of setting up a model to accept a decal material of a special material. The square receptor model does not have the unwanted decal material projected on it.
[0099] It should be noted that for the sake of simplicity, the method embodiments are described as a series of actions. However, those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, 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 this specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0100] Reference Figure 8, shows a structural block diagram of a decal material projection device provided by an embodiment of the present invention, which may specifically include the following modules:
[0101] Depth acquisition module 801, used to obtain scene depth and pixel depth corresponding to the decal material;
[0102] A texture coordinate conversion module 802 is configured to convert the scene depth and pixel depth according to a preset material function to obtain texture coordinates of the decal material; wherein the preset material function is used to realize the projection of the decal material in the particle system;
[0103] A custom depth extraction module 803 is used to extract the custom depth and custom template corresponding to the receptor model;
[0104] A judgment module 804 is configured to judge whether the receptor model meets the decal projection condition based on the custom depth and the custom template;
[0105] The decal material projection module 805 is configured to project the decal material onto the surface of the receptor model according to the texture coordinates when the receptor model meets the decal projection conditions.
[0106] In a preferred embodiment of the present invention, the texture coordinate conversion module 802 includes:
[0107] A first conversion submodule, configured to convert the scene depth and pixel depth according to a preset material function to obtain projection coordinates;
[0108] A second conversion submodule, configured to convert the projection coordinates into coordinates in a particle system;
[0109] The third conversion submodule is used to obtain the texture coordinates of the decal material according to the coordinate conversion in the particle system.
[0110] In a preferred embodiment of the present invention, the first conversion submodule comprises:
[0111] a division operation unit, configured to perform a division operation on the scene depth and the pixel depth to obtain a first coordinate;
[0112] A world coordinate acquisition unit, configured to acquire the absolute world coordinates of the pixels corresponding to the decal material and the absolute world coordinates of the camera;
[0113] a multiplication unit, configured to perform a multiplication operation on the absolute world coordinate of the pixel and the first coordinate to obtain a second coordinate;
[0114] An adding unit is used to perform an adding operation on the second coordinate and the absolute world coordinate of the camera to obtain a projection coordinate.
[0115] In a preferred embodiment of the present invention, the second conversion submodule comprises:
[0116] A particle coordinate acquisition unit, used to obtain the relative coordinates of the particle coordinate system corresponding to the decal material;
[0117] a subtraction operation unit, configured to perform a subtraction operation on the relative coordinate in the particle coordinate system and the projection coordinate to obtain a third coordinate;
[0118] The coordinate conversion unit is used to convert the third coordinate to obtain the coordinate in the particle system.
[0119] In a preferred embodiment of the present invention, the third conversion submodule comprises:
[0120] The normalization processing unit is used to perform normalization processing on the coordinates in the particle system to obtain the texture coordinates of the decal material.
[0121] In a preferred embodiment of the present invention, the judgment module 804 includes:
[0122] A subtraction operation submodule, configured to perform a subtraction operation on the custom depth and the scene depth to obtain a depth difference;
[0123] The first determination submodule is configured to determine that the receptor model does not meet the decal projection condition when the depth difference is less than a preset first threshold.
[0124] In a preferred embodiment of the present invention, the determining module 804 further includes:
[0125] a material template value acquisition submodule, configured to acquire a material template value corresponding to the decal material when the depth difference is greater than or equal to a preset first threshold;
[0126] A second determination submodule is configured to determine that the receptor model meets the decal projection condition if the custom template and the material template value are consistent;
[0127] The third determination submodule is configured to determine that the receptor model does not meet the decal projection condition if the custom template and the material template values are inconsistent.
[0128] 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.
[0129] The embodiment of the present invention further provides an electronic device, such as Figure 9 Shown, including:
[0130] Processor 901 and storage medium 902, wherein storage medium 902 stores machine-readable instructions executable by processor 901. When the electronic device is running, processor 901 executes the machine-readable instructions to perform the method as described in any of the embodiments of the present invention. The specific implementation methods and technical effects are similar and will not be repeated here.
[0131] The embodiment of the present invention also provides a computer readable storage medium, such as Figure 10 As shown, the storage medium stores a computer program 1001, which is executed by a processor to execute the method according to any one of the embodiments of the present invention. The specific implementation and technical effects are similar and will not be described in detail here.
[0132] 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.
[0133] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, apparatus, or computer program products. Thus, embodiments of the present invention may take the form of a fully hardware embodiment, a fully software embodiment, or an embodiment combining software and hardware. Furthermore, embodiments of the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0134] The embodiments of the present invention 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 invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce 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 process 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.
[0135] These computer program instructions may also be stored in a computer readable memory that can direct 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 1The function specified in one or more boxes.
[0136] 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 A step that specifies a function in one or more boxes.
[0137] Although the preferred embodiments of the present invention have been described, those skilled in the art may make additional changes and modifications to these embodiments once they become aware of the basic creative concepts. 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 invention.
[0138] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or terminal device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0139] The above is a detailed introduction to a method for projecting decal material and a device for projecting decal material provided by the present invention. Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A method for projecting decal material, characterized in that: include: Get the scene depth and pixel depth corresponding to the decal material; Converting the scene depth and pixel depth according to a preset material function to obtain projection coordinates; wherein the preset material function is used to project the decal material in the particle system; Obtain the relative coordinates of the decal material in the particle coordinate system; performing a subtraction operation on the relative coordinate in the particle coordinate system and the projection coordinate to obtain a third coordinate; Converting the third coordinate to obtain a coordinate in the particle system; Obtaining texture coordinates of the decal material according to coordinate conversion in the particle system; Extract custom depth and custom template corresponding to the receptor model; Determining whether the receptor model meets the decal projection conditions based on the custom depth and the custom template; When the receptor model meets the decal projection condition, the decal material is projected onto the surface of the receptor model according to the texture coordinates.
2. The method according to claim 1, characterized in that The converting the scene depth and pixel depth according to a preset material function to obtain projection coordinates includes: Performing a division operation on the scene depth and the pixel depth to obtain a first coordinate; Obtain the absolute world coordinates of the pixel corresponding to the decal material and the absolute world coordinates of the camera; performing a multiplication operation on the pixel absolute world coordinate and the first coordinate to obtain a second coordinate; An addition operation is performed on the second coordinate and the absolute world coordinate of the camera to obtain a projection coordinate.
3. The method according to claim 1, characterized in that The step of obtaining the texture coordinates of the decal material according to the coordinate conversion in the particle system includes: The coordinates in the particle system are normalized to obtain the texture coordinates of the decal material.
4. The method according to claim 1, wherein The determining whether the receptor model meets the decal projection condition according to the custom depth and the custom template includes: Performing a subtraction operation on the custom depth and the scene depth to obtain a depth difference; When the depth difference is less than a preset first threshold, it is determined that the receptor model does not meet the decal projection condition.
5. The method according to claim 4, characterized in that The determining whether the receptor model meets the decal projection condition according to the custom depth and the custom template further includes: When the depth difference is greater than or equal to a preset first threshold, obtaining a material template value corresponding to the decal material; If the custom template and the material template values are consistent, the receptor model is determined to meet the decal projection conditions; If the custom template is inconsistent with the material template value, it is determined that the receptor model does not meet the decal projection conditions.
6. A device for projecting decal material, characterized in that: include: Depth acquisition module, used to obtain the scene depth and pixel depth corresponding to the decal material; a texture coordinate conversion module, configured to convert the scene depth and pixel depth according to a preset material function to obtain texture coordinates of the decal material; wherein the preset material function is used to realize projection of the decal material in the particle system; Custom depth extraction module, used to extract custom depth and custom template corresponding to the receptor model; a judgment module, configured to judge whether the receptor model meets the decal projection condition according to the custom depth and the custom template; a decal material projection module, configured to project the decal material onto the surface of the receptor model according to the texture coordinates when the receptor model meets the decal projection conditions; Wherein, the texture coordinate conversion module includes: A first conversion submodule, configured to convert the scene depth and pixel depth according to a preset material function to obtain projection coordinates; A particle coordinate acquisition unit, used to obtain the relative coordinates of the particle coordinate system corresponding to the decal material; a subtraction operation unit, configured to perform a subtraction operation on the relative coordinate in the particle coordinate system and the projection coordinate to obtain a third coordinate; A coordinate conversion unit, configured to convert the third coordinate to obtain a coordinate in the particle system; The third conversion submodule is used to obtain the texture coordinates of the decal material according to the coordinate conversion in the particle system.
7. An electronic device, characterized in that: include: A processor and a storage medium, wherein the storage medium stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor executes the machine-readable instructions to perform the method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that The storage medium stores a computer program, which, when executed by a processor, executes the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Ground crack processing method and device
CN113160378A